<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[168055] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/168055">168055</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2014-04-30 15:57:08 -0700 (Wed, 30 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Updated ANGLE.
https://bugs.webkit.org/show_bug.cgi?id=132367
&lt;rdar://problem/16211451&gt;

Reviewed by Dean Jackson.


Source/ThirdParty/ANGLE: 
* ANGLE.plist:
Updated and xml encoded.
* ANGLE.xcodeproj/project.pbxproj:
Added needed new source files.
* changes.diff: 
Added to keep track of differences between WebKit's copy of ANGLE and the master repository.
        
Updated ANGLE source files to e7a453a5bd76705ccb151117fa844846d4aa90af.  Long list of changes omitted.

Source/WebCore: 
* CMakeLists.txt
Fixed ANGLE compiling with the update.
* platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:
(WebCore::Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE):
Removed SH_MAP_LONG_VARIABLE_NAMES which is no longer defined in ANGLE.
See https://chromium.googlesource.com/angle/angle/+/3cdfcce86b38ef31a0afd71855887193a7924468
* platform/graphics/opengl/Extensions3DOpenGLES.h:
* platform/graphics/opengl/Extensions3DOpenGLES.cpp:
Updated type names from ANGLE.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceThirdPartyANGLEANGLEplist">trunk/Source/ThirdParty/ANGLE/ANGLE.plist</a></li>
<li><a href="#trunkSourceThirdPartyANGLEANGLExcodeprojprojectpbxproj">trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceThirdPartyANGLEAUTHORS">trunk/Source/ThirdParty/ANGLE/AUTHORS</a></li>
<li><a href="#trunkSourceThirdPartyANGLECONTRIBUTORS">trunk/Source/ThirdParty/ANGLE/CONTRIBUTORS</a></li>
<li><a href="#trunkSourceThirdPartyANGLEChangeLog">trunk/Source/ThirdParty/ANGLE/ChangeLog</a></li>
<li><a href="#trunkSourceThirdPartyANGLEDEPS">trunk/Source/ThirdParty/ANGLE/DEPS</a></li>
<li><a href="#trunkSourceThirdPartyANGLEcodereviewsettings">trunk/Source/ThirdParty/ANGLE/codereview.settings</a></li>
<li><a href="#trunkSourceThirdPartyANGLEincludeEGLeglh">trunk/Source/ThirdParty/ANGLE/include/EGL/egl.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEincludeEGLeglexth">trunk/Source/ThirdParty/ANGLE/include/EGL/eglext.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEincludeEGLeglplatformh">trunk/Source/ThirdParty/ANGLE/include/EGL/eglplatform.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEincludeGLES2gl2h">trunk/Source/ThirdParty/ANGLE/include/GLES2/gl2.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEincludeGLES2gl2exth">trunk/Source/ThirdParty/ANGLE/include/GLES2/gl2ext.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEincludeGLSLANGShaderLangh">trunk/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrcbuild_anglegyp">trunk/Source/ThirdParty/ANGLE/src/build_angle.gyp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonRefCountObjecth">trunk/Source/ThirdParty/ANGLE/src/common/RefCountObject.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonangleutilsh">trunk/Source/ThirdParty/ANGLE/src/common/angleutils.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommondebugcpp">trunk/Source/ThirdParty/ANGLE/src/common/debug.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommondebugh">trunk/Source/ThirdParty/ANGLE/src/common/debug.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonevent_tracercpp">trunk/Source/ThirdParty/ANGLE/src/common/event_tracer.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilerpreprocessorDirectiveParsercpp">trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/DirectiveParser.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilerpreprocessorExpressionParsercpp">trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/ExpressionParser.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilerpreprocessorExpressionParsery">trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/ExpressionParser.y</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilerpreprocessorPreprocessorcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilerpreprocessorPreprocessorh">trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilerpreprocessorTokenizercpp">trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilerpreprocessorTokenizerh">trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilerpreprocessorTokenizerl">trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.l</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorBaseTypesh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BaseTypes.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorBuiltInFunctionEmulatorcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BuiltInFunctionEmulator.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorBuiltInFunctionEmulatorh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BuiltInFunctionEmulator.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorCodeGencpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/CodeGen.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorCommonh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Common.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorCompilercpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorConstantUnionh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ConstantUnion.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorDetectCallDepthh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DetectCallDepth.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorDiagnosticscpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Diagnostics.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorDiagnosticsh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Diagnostics.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorDirectiveHandlercpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DirectiveHandler.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorDirectiveHandlerh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DirectiveHandler.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorForLoopUnrollcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ForLoopUnroll.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorForLoopUnrollh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ForLoopUnroll.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorHashNamesh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/HashNames.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorInitializecpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Initialize.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorIntermTraversecpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/IntermTraverse.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorIntermediatecpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Intermediate.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorOutputESSLcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputESSL.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorOutputESSLh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputESSL.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorOutputGLSLcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSL.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorOutputGLSLh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSL.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorOutputGLSLBasecpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSLBase.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorOutputGLSLBaseh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSLBase.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorOutputHLSLcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputHLSL.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorOutputHLSLh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputHLSL.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorParseContextcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ParseContext.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorParseContexth">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ParseContext.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorQualifierAlivecpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/QualifierAlive.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorRemoveTreecpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/RemoveTree.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorShHandleh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShHandle.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorShaderLangcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShaderLang.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorSymbolTablecpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/SymbolTable.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorSymbolTableh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/SymbolTable.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorESSLcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorESSL.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorGLSLcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorGLSL.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorGLSLh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorGLSL.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorHLSLcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorHLSL.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorHLSLh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorHLSL.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorTypesh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Types.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorUnfoldShortCircuitASTcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/UnfoldShortCircuitAST.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorValidateLimitationscpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateLimitations.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorValidateLimitationsh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateLimitations.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorVariableInfocpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorVariableInfoh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorVariablePackercpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariablePacker.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorVersionGLSLh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VersionGLSL.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorgenerate_parsersh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/generate_parser.sh</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorglslangl">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.l</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorglslangy">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.y</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorglslang_lexcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_lex.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorglslang_tabcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorglslang_tabh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorintermOutcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermOut.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorintermediateh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermediate.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorlocalintermediateh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/localintermediate.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorossource_wincpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ossource_win.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorparseConstcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/parseConst.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatortimingRestrictFragmentShaderTimingcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatortimingRestrictFragmentShaderTimingh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictFragmentShaderTiming.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatortimingRestrictVertexShaderTimingcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictVertexShaderTiming.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatortimingRestrictVertexShaderTimingh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictVertexShaderTiming.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibEGLConfigcpp">trunk/Source/ThirdParty/ANGLE/src/libEGL/Config.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibEGLDisplaycpp">trunk/Source/ThirdParty/ANGLE/src/libEGL/Display.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibEGLDisplayh">trunk/Source/ThirdParty/ANGLE/src/libEGL/Display.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibEGLSurfacecpp">trunk/Source/ThirdParty/ANGLE/src/libEGL/Surface.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibEGLSurfaceh">trunk/Source/ThirdParty/ANGLE/src/libEGL/Surface.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibEGLlibEGLcpp">trunk/Source/ThirdParty/ANGLE/src/libEGL/libEGL.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Buffercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Bufferh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Contextcpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Context.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Contexth">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Fencecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Fenceh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Framebuffercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Framebufferh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2HandleAllocatorh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/HandleAllocator.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Programcpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Programh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Program.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2ProgramBinarycpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ProgramBinary.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2ProgramBinaryh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ProgramBinary.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Queryh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Query.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Renderbuffercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Renderbufferh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2ResourceManagercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ResourceManager.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2ResourceManagerh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ResourceManager.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Shadercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Shaderh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Texturecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Textureh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Uniformcpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Uniform.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Uniformh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Uniform.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2angletypesh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/angletypes.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2libGLESv2cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2libGLESv2def">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.def</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2mainh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/main.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2precompiledh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/precompiled.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererBufferStoragecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/BufferStorage.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererBufferStorageh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/BufferStorage.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererFenceImplh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/FenceImpl.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererImagecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Image.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererImageh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Image.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererIndexBuffercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexBuffer.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererIndexDataManagercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexDataManager.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererIndexRangeCachecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexRangeCache.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererIndexRangeCacheh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexRangeCache.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererRenderTargeth">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/RenderTarget.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererRenderercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Renderer.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererRendererh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Renderer.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererShaderExecutableh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/ShaderExecutable.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererTextureStoragecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/TextureStorage.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererTextureStorageh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/TextureStorage.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererVertexBuffercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexBuffer.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererVertexBufferh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexBuffer.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererVertexDataManagercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexDataManager.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererVertexDataManagerh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexDataManager.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11BufferStorage11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11BufferStorage11h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/BufferStorage11.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Fence11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Fence11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Fence11h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Fence11.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Image11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Image11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Image11h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Image11.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11IndexBuffer11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11InputLayoutCachecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11InputLayoutCacheh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/InputLayoutCache.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Query11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Query11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11RenderStateCachecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11RenderStateCacheh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderStateCache.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11RenderTarget11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11RenderTarget11h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderTarget11.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Renderer11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Renderer11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Renderer11h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Renderer11.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11ShaderExecutable11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11ShaderExecutable11h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/ShaderExecutable11.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11SwapChain11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/SwapChain11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11SwapChain11h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/SwapChain11.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11TextureStorage11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11TextureStorage11h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/TextureStorage11.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11VertexBuffer11cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11VertexBuffer11h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/VertexBuffer11.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11renderer11_utilscpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11renderer11_utilsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/renderer11_utils.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11shadersClear11hlsl">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Clear11.hlsl</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11shadersgenerate_shadersbat">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/generate_shaders.bat</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9BufferStorage9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9BufferStorage9h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/BufferStorage9.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Fence9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Fence9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Fence9h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Fence9.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Image9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Image9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Image9h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Image9.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9IndexBuffer9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Query9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Query9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9RenderTarget9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9RenderTarget9h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/RenderTarget9.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Renderer9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Renderer9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Renderer9h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Renderer9.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9ShaderExecutable9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9SwapChain9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/SwapChain9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9TextureStorage9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9TextureStorage9h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/TextureStorage9.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9VertexBuffer9cpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9VertexBuffer9h">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexBuffer9.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9VertexDeclarationCachecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9renderer9_utilscpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9renderer9_utilsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/renderer9_utils.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shadersBlitps">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/Blit.ps</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledcomponentmaskpsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledflipyvsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledluminancepsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledpassthroughpsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledstandardvsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shadersgenerate_shadersbat">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/generate_shaders.bat</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2renderergeneratemiph">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/generatemip.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrcthird_partycompilerArrayBoundsClamperh">trunk/Source/ThirdParty/ANGLE/src/third_party/compiler/ArrayBoundsClamper.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrcthird_partymurmurhashMurmurHash3cpp">trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrcthird_partymurmurhashMurmurHash3h">trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.h</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopenglExtensions3DOpenGLCommoncpp">trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopenglExtensions3DOpenGLEScpp">trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopenglExtensions3DOpenGLESh">trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceThirdPartyANGLEchangesdiff">trunk/Source/ThirdParty/ANGLE/changes.diff</a></li>
<li>trunk/Source/ThirdParty/ANGLE/include/GLES3/</li>
<li><a href="#trunkSourceThirdPartyANGLEincludeGLES3gl3h">trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEincludeGLES3gl3exth">trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3ext.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEincludeGLES3gl3platformh">trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3platform.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonblocklayoutcpp">trunk/Source/ThirdParty/ANGLE/src/common/blocklayout.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonblocklayouth">trunk/Source/ThirdParty/ANGLE/src/common/blocklayout.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonmathutilcpp">trunk/Source/ThirdParty/ANGLE/src/common/mathutil.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonmathutilh">trunk/Source/ThirdParty/ANGLE/src/common/mathutil.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonshadervarscpp">trunk/Source/ThirdParty/ANGLE/src/common/shadervars.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonshadervarsh">trunk/Source/ThirdParty/ANGLE/src/common/shadervars.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonutilitiescpp">trunk/Source/ThirdParty/ANGLE/src/common/utilities.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccommonutilitiesh">trunk/Source/ThirdParty/ANGLE/src/common/utilities.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslator64bitlexersafetypatch">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/64bit-lexer-safety.patch</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorFlagStd140Structscpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/FlagStd140Structs.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorFlagStd140Structsh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/FlagStd140Structs.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorLoopInfocpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/LoopInfo.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorLoopInfoh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/LoopInfo.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorValidateOutputscpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateOutputs.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorValidateOutputsh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateOutputs.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorlength_limitsh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/length_limits.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2DynamicHLSLcpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/DynamicHLSL.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2DynamicHLSLh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/DynamicHLSL.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2RenderbufferProxySetcpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/RenderbufferProxySet.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2RenderbufferProxySeth">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/RenderbufferProxySet.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Samplercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Sampler.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Samplerh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Sampler.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2TransformFeedbackcpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/TransformFeedback.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2TransformFeedbackh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/TransformFeedback.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2VertexArraycpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexArray.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2VertexArrayh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexArray.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2VertexAttributeh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexAttribute.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2angletypescpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/angletypes.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2formatutilscpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/formatutils.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2formatutilsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/formatutils.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2queryconversionscpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/queryconversions.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2queryconversionsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/queryconversions.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2renderercopyimagecpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyimage.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2renderercopyimageh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyimage.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2renderercopyvertexh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyvertex.h</a></li>
<li>trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d/</li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3dHLSLCompilercpp">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3dHLSLCompilerh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d/HLSLCompiler.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11shadersPassthrough2D11hlsl">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough2D11.hlsl</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorMapLongVariableNamescpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/MapLongVariableNames.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorMapLongVariableNamesh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/MapLongVariableNames.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibGLESv2Constantsh">trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Constants.h</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorBaseTypesh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BaseTypes.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorCommonh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Common.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorQualifierAlivecpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/QualifierAlive.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorUnfoldShortCircuitASTcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/UnfoldShortCircuitAST.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorVariableInfocpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorglslangl">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.l</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorglslang_lexcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_lex.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorglslang_tabcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorintermOutcpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermOut.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorlocalintermediateh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/localintermediate.h</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorossource_wincpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ossource_win.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrcthird_partymurmurhashMurmurHash3cpp">trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceThirdPartyANGLEANGLEplist"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/ANGLE.plist (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/ANGLE.plist        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/ANGLE.plist        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -2,21 +2,21 @@
</span><span class="cx"> &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
</span><span class="cx"> &lt;plist version=&quot;1.0&quot;&gt;
</span><span class="cx"> &lt;array&gt;
</span><del>-        &lt;dict&gt;
-                &lt;key&gt;OpenSourceProject&lt;/key&gt;
-                &lt;string&gt;ANGLE&lt;/string&gt;
-                &lt;key&gt;OpenSourceVersion&lt;/key&gt;
-                &lt;string&gt;836bd2176e5607b14846cf1fbc5932dbc91318f4&lt;/string&gt;
-                &lt;key&gt;OpenSourceWebsiteURL&lt;/key&gt;
-                &lt;string&gt;http://code.google.com/p/angleproject/&lt;/string&gt;
-                &lt;key&gt;OpenSourceSCM&lt;/key&gt;
-                &lt;string&gt;git clone https://code.google.com/p/angleproject/ &amp;&amp; cd angleproject &amp;&amp; git checkout 836bd2176e5607b14846cf1fbc5932dbc91318f4&lt;/string&gt;
-                &lt;key&gt;OpenSourceImportDate&lt;/key&gt;
-                &lt;string&gt;2014-02-18&lt;/string&gt;
-                &lt;key&gt;OpenSourceLicense&lt;/key&gt;
-                &lt;string&gt;BSD&lt;/string&gt;
-                &lt;key&gt;OpenSourceLicenseFile&lt;/key&gt;
-                &lt;string&gt;ANGLE.txt&lt;/string&gt;
-        &lt;/dict&gt;
</del><ins>+    &lt;dict&gt;
+        &lt;key&gt;OpenSourceProject&lt;/key&gt;
+        &lt;string&gt;ANGLE&lt;/string&gt;
+        &lt;key&gt;OpenSourceVersion&lt;/key&gt;
+        &lt;string&gt;e7a453a5bd76705ccb151117fa844846d4aa90af&lt;/string&gt;
+        &lt;key&gt;OpenSourceWebsiteURL&lt;/key&gt;
+        &lt;string&gt;http://code.google.com/p/angleproject/&lt;/string&gt;
+        &lt;key&gt;OpenSourceSCM&lt;/key&gt;
+        &lt;string&gt;git clone https://chromium.googlesource.com/angle/angle &amp;amp;&amp;amp; cd angle &amp;amp;&amp;amp; git checkout e7a453a5bd76705ccb151117fa844846d4aa90af&lt;/string&gt;
+        &lt;key&gt;OpenSourceImportDate&lt;/key&gt;
+        &lt;string&gt;2014-04-29&lt;/string&gt;
+        &lt;key&gt;OpenSourceLicense&lt;/key&gt;
+        &lt;string&gt;BSD&lt;/string&gt;
+        &lt;key&gt;OpenSourceLicenseFile&lt;/key&gt;
+        &lt;string&gt;ANGLE.txt&lt;/string&gt;
+    &lt;/dict&gt;
</ins><span class="cx"> &lt;/array&gt;
</span><span class="cx"> &lt;/plist&gt;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEANGLExcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -67,8 +67,6 @@
</span><span class="cx">                 31012E4118B97B9B0039062F /* intermOut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31012DD118B97B9B0039062F /* intermOut.cpp */; };
</span><span class="cx">                 31012E4218B97B9B0039062F /* IntermTraverse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31012DD218B97B9B0039062F /* IntermTraverse.cpp */; };
</span><span class="cx">                 31012E4318B97B9B0039062F /* localintermediate.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012DD318B97B9B0039062F /* localintermediate.h */; };
</span><del>-                31012E4418B97B9B0039062F /* MapLongVariableNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31012DD418B97B9B0039062F /* MapLongVariableNames.cpp */; };
-                31012E4518B97B9B0039062F /* MapLongVariableNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012DD518B97B9B0039062F /* MapLongVariableNames.h */; };
</del><span class="cx">                 31012E4618B97B9B0039062F /* MMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012DD618B97B9B0039062F /* MMap.h */; };
</span><span class="cx">                 31012E4718B97B9B0039062F /* NodeSearch.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012DD718B97B9B0039062F /* NodeSearch.h */; };
</span><span class="cx">                 31012E4818B97B9B0039062F /* osinclude.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012DD818B97B9B0039062F /* osinclude.h */; };
</span><span class="lines">@@ -115,8 +113,6 @@
</span><span class="cx">                 31012E7218B97B9B0039062F /* UnfoldShortCircuit.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012E0318B97B9B0039062F /* UnfoldShortCircuit.h */; };
</span><span class="cx">                 31012E7318B97B9B0039062F /* UnfoldShortCircuitAST.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31012E0418B97B9B0039062F /* UnfoldShortCircuitAST.cpp */; };
</span><span class="cx">                 31012E7418B97B9B0039062F /* UnfoldShortCircuitAST.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012E0518B97B9B0039062F /* UnfoldShortCircuitAST.h */; };
</span><del>-                31012E7518B97B9B0039062F /* Uniform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31012E0618B97B9B0039062F /* Uniform.cpp */; };
-                31012E7618B97B9B0039062F /* Uniform.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012E0718B97B9B0039062F /* Uniform.h */; };
</del><span class="cx">                 31012E7718B97B9B0039062F /* util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31012E0818B97B9B0039062F /* util.cpp */; };
</span><span class="cx">                 31012E7818B97B9B0039062F /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012E0918B97B9B0039062F /* util.h */; };
</span><span class="cx">                 31012E7918B97B9B0039062F /* ValidateLimitations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31012E0A18B97B9B0039062F /* ValidateLimitations.cpp */; };
</span><span class="lines">@@ -131,7 +127,30 @@
</span><span class="cx">                 31012E8418B97C860039062F /* compilerdebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012E8218B97C860039062F /* compilerdebug.h */; };
</span><span class="cx">                 312BDB0C15FECAC90097EBC7 /* ANGLE.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 312BDB0915FEC91E0097EBC7 /* ANGLE.plist */; };
</span><span class="cx">                 312BDB0E15FECAE50097EBC7 /* ANGLE.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 312BDB0A15FECA3A0097EBC7 /* ANGLE.txt */; };
</span><del>-                49951C0314B7AAB30060E96E /* length_limits.h in Headers */ = {isa = PBXBuildFile; fileRef = 49951C0214B7AAB30060E96E /* length_limits.h */; };
</del><ins>+                5C9FFF4E19102A000025B8FA /* FlagStd140Structs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C9FFF4C19102A000025B8FA /* FlagStd140Structs.cpp */; };
+                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 */; };
+                5CC7D46C19102620000B8C1F /* blocklayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D45B19102620000B8C1F /* blocklayout.cpp */; };
+                5CC7D46D19102620000B8C1F /* blocklayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D45C19102620000B8C1F /* blocklayout.h */; };
+                5CC7D46E19102621000B8C1F /* debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D45D19102620000B8C1F /* debug.cpp */; };
+                5CC7D46F19102621000B8C1F /* debug.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D45E19102620000B8C1F /* debug.h */; };
+                5CC7D47019102621000B8C1F /* event_tracer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D45F19102620000B8C1F /* event_tracer.cpp */; };
+                5CC7D47119102621000B8C1F /* event_tracer.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D46019102620000B8C1F /* event_tracer.h */; };
+                5CC7D47219102621000B8C1F /* mathutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D46119102620000B8C1F /* mathutil.cpp */; };
+                5CC7D47319102621000B8C1F /* mathutil.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D46219102620000B8C1F /* mathutil.h */; };
+                5CC7D47419102621000B8C1F /* RefCountObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D46319102620000B8C1F /* RefCountObject.cpp */; };
+                5CC7D47519102621000B8C1F /* RefCountObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D46419102620000B8C1F /* RefCountObject.h */; };
+                5CC7D47619102621000B8C1F /* shadervars.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D46519102620000B8C1F /* shadervars.cpp */; };
+                5CC7D47719102621000B8C1F /* shadervars.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D46619102620000B8C1F /* shadervars.h */; };
+                5CC7D47819102621000B8C1F /* system.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D46719102620000B8C1F /* system.h */; };
+                5CC7D47919102621000B8C1F /* utilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D46819102620000B8C1F /* utilities.cpp */; };
+                5CC7D47A19102621000B8C1F /* utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D46919102620000B8C1F /* utilities.h */; };
+                5CC7D47B19102621000B8C1F /* version.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D46A19102620000B8C1F /* version.h */; };
</ins><span class="cx">                 72309A56183C27DE00370B93 /* Tokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72309A55183C27DB00370B93 /* Tokenizer.cpp */; };
</span><span class="cx">                 72309A58183C27F300370B93 /* ExpressionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72309A57183C27F100370B93 /* ExpressionParser.cpp */; };
</span><span class="cx">                 A08C3CDC16D6CB61003F0B83 /* ArrayBoundsClamper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A08C3CDA16D6CB61003F0B83 /* ArrayBoundsClamper.cpp */; };
</span><span class="lines">@@ -243,8 +262,6 @@
</span><span class="cx">                 31012DD118B97B9B0039062F /* intermOut.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = intermOut.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 31012DD218B97B9B0039062F /* IntermTraverse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntermTraverse.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 31012DD318B97B9B0039062F /* localintermediate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = localintermediate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                31012DD418B97B9B0039062F /* MapLongVariableNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MapLongVariableNames.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                31012DD518B97B9B0039062F /* MapLongVariableNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapLongVariableNames.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 31012DD618B97B9B0039062F /* MMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMap.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 31012DD718B97B9B0039062F /* NodeSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeSearch.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 31012DD818B97B9B0039062F /* osinclude.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = osinclude.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -291,8 +308,6 @@
</span><span class="cx">                 31012E0318B97B9B0039062F /* UnfoldShortCircuit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnfoldShortCircuit.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 31012E0418B97B9B0039062F /* UnfoldShortCircuitAST.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnfoldShortCircuitAST.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 31012E0518B97B9B0039062F /* UnfoldShortCircuitAST.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnfoldShortCircuitAST.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                31012E0618B97B9B0039062F /* Uniform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Uniform.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                31012E0718B97B9B0039062F /* Uniform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Uniform.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 31012E0818B97B9B0039062F /* util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = util.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 31012E0918B97B9B0039062F /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 31012E0A18B97B9B0039062F /* ValidateLimitations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ValidateLimitations.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -308,7 +323,30 @@
</span><span class="cx">                 312BDB0915FEC91E0097EBC7 /* ANGLE.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ANGLE.plist; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 312BDB0A15FECA3A0097EBC7 /* ANGLE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ANGLE.txt; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 443A3E1512ECF6CC0004F9D7 /* iOS.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = iOS.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                49951C0214B7AAB30060E96E /* length_limits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = length_limits.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                5C9FFF4C19102A000025B8FA /* FlagStd140Structs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlagStd140Structs.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C9FFF4D19102A000025B8FA /* FlagStd140Structs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlagStd140Structs.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D44B191024E3000B8C1F /* LoopInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoopInfo.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D44C191024E4000B8C1F /* LoopInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoopInfo.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D44F191024E4000B8C1F /* Uniform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Uniform.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D450191024E4000B8C1F /* ValidateOutputs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ValidateOutputs.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D451191024E4000B8C1F /* ValidateOutputs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValidateOutputs.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D45A19102620000B8C1F /* angleutils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = angleutils.h; path = src/common/angleutils.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D45B19102620000B8C1F /* blocklayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = blocklayout.cpp; path = src/common/blocklayout.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D45C19102620000B8C1F /* blocklayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = blocklayout.h; path = src/common/blocklayout.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D45D19102620000B8C1F /* debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = debug.cpp; path = src/common/debug.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D45E19102620000B8C1F /* debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = debug.h; path = src/common/debug.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D45F19102620000B8C1F /* event_tracer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = event_tracer.cpp; path = src/common/event_tracer.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46019102620000B8C1F /* event_tracer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = event_tracer.h; path = src/common/event_tracer.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46119102620000B8C1F /* mathutil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mathutil.cpp; path = src/common/mathutil.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46219102620000B8C1F /* mathutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mathutil.h; path = src/common/mathutil.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46319102620000B8C1F /* RefCountObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RefCountObject.cpp; path = src/common/RefCountObject.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46419102620000B8C1F /* RefCountObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RefCountObject.h; path = src/common/RefCountObject.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46519102620000B8C1F /* shadervars.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = shadervars.cpp; path = src/common/shadervars.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46619102620000B8C1F /* shadervars.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = shadervars.h; path = src/common/shadervars.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46719102620000B8C1F /* system.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = system.h; path = src/common/system.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46819102620000B8C1F /* utilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = utilities.cpp; path = src/common/utilities.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46919102620000B8C1F /* utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = utilities.h; path = src/common/utilities.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5CC7D46A19102620000B8C1F /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = version.h; path = src/common/version.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 5D7C59C51208C68B001C873E /* ANGLE.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ANGLE.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5D7C59C61208C68B001C873E /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5D7C59C71208C68B001C873E /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -358,6 +396,13 @@
</span><span class="cx">                 31012D9F18B97B9B0039062F /* translator */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                5C9FFF4C19102A000025B8FA /* FlagStd140Structs.cpp */,
+                                5C9FFF4D19102A000025B8FA /* FlagStd140Structs.h */,
+                                5CC7D44B191024E3000B8C1F /* LoopInfo.cpp */,
+                                5CC7D44C191024E4000B8C1F /* LoopInfo.h */,
+                                5CC7D44F191024E4000B8C1F /* Uniform.cpp */,
+                                5CC7D450191024E4000B8C1F /* ValidateOutputs.cpp */,
+                                5CC7D451191024E4000B8C1F /* ValidateOutputs.h */,
</ins><span class="cx">                                 31012DA918B97B9B0039062F /* depgraph */,
</span><span class="cx">                                 31012DF618B97B9B0039062F /* timing */,
</span><span class="cx">                                 31012DA018B97B9B0039062F /* BaseTypes.h */,
</span><span class="lines">@@ -401,8 +446,6 @@
</span><span class="cx">                                 31012DD118B97B9B0039062F /* intermOut.cpp */,
</span><span class="cx">                                 31012DD218B97B9B0039062F /* IntermTraverse.cpp */,
</span><span class="cx">                                 31012DD318B97B9B0039062F /* localintermediate.h */,
</span><del>-                                31012DD418B97B9B0039062F /* MapLongVariableNames.cpp */,
-                                31012DD518B97B9B0039062F /* MapLongVariableNames.h */,
</del><span class="cx">                                 31012DD618B97B9B0039062F /* MMap.h */,
</span><span class="cx">                                 31012DD718B97B9B0039062F /* NodeSearch.h */,
</span><span class="cx">                                 31012DD818B97B9B0039062F /* osinclude.h */,
</span><span class="lines">@@ -445,8 +488,6 @@
</span><span class="cx">                                 31012E0318B97B9B0039062F /* UnfoldShortCircuit.h */,
</span><span class="cx">                                 31012E0418B97B9B0039062F /* UnfoldShortCircuitAST.cpp */,
</span><span class="cx">                                 31012E0518B97B9B0039062F /* UnfoldShortCircuitAST.h */,
</span><del>-                                31012E0618B97B9B0039062F /* Uniform.cpp */,
-                                31012E0718B97B9B0039062F /* Uniform.h */,
</del><span class="cx">                                 31012E0818B97B9B0039062F /* util.cpp */,
</span><span class="cx">                                 31012E0918B97B9B0039062F /* util.h */,
</span><span class="cx">                                 31012E0A18B97B9B0039062F /* ValidateLimitations.cpp */,
</span><span class="lines">@@ -495,6 +536,30 @@
</span><span class="cx">                         name = misc;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="cx">                 };
</span><ins>+                5CC7D45919102608000B8C1F /* common */ = {
+                        isa = PBXGroup;
+                        children = (
+                                5CC7D45A19102620000B8C1F /* angleutils.h */,
+                                5CC7D45B19102620000B8C1F /* blocklayout.cpp */,
+                                5CC7D45C19102620000B8C1F /* blocklayout.h */,
+                                5CC7D45D19102620000B8C1F /* debug.cpp */,
+                                5CC7D45E19102620000B8C1F /* debug.h */,
+                                5CC7D45F19102620000B8C1F /* event_tracer.cpp */,
+                                5CC7D46019102620000B8C1F /* event_tracer.h */,
+                                5CC7D46119102620000B8C1F /* mathutil.cpp */,
+                                5CC7D46219102620000B8C1F /* mathutil.h */,
+                                5CC7D46319102620000B8C1F /* RefCountObject.cpp */,
+                                5CC7D46419102620000B8C1F /* RefCountObject.h */,
+                                5CC7D46519102620000B8C1F /* shadervars.cpp */,
+                                5CC7D46619102620000B8C1F /* shadervars.h */,
+                                5CC7D46719102620000B8C1F /* system.h */,
+                                5CC7D46819102620000B8C1F /* utilities.cpp */,
+                                5CC7D46919102620000B8C1F /* utilities.h */,
+                                5CC7D46A19102620000B8C1F /* version.h */,
+                        );
+                        name = common;
+                        sourceTree = &quot;&lt;group&gt;&quot;;
+                };
</ins><span class="cx">                 5D7C59C41208C68B001C873E /* Configurations */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="lines">@@ -555,6 +620,7 @@
</span><span class="cx">                 FB39D0841200EDEB00088E69 /* src */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                5CC7D45919102608000B8C1F /* common */,
</ins><span class="cx">                                 FB39D2201200F35A00088E69 /* compiler */,
</span><span class="cx">                                 A08C3CD816D6CB35003F0B83 /* third_party */,
</span><span class="cx">                         );
</span><span class="lines">@@ -592,7 +658,6 @@
</span><span class="cx">                                 A264F89A16974DED006FAA5A /* ExpressionParser.h */,
</span><span class="cx">                                 A264F89B16974DED006FAA5A /* Input.cpp */,
</span><span class="cx">                                 A264F89C16974DED006FAA5A /* Input.h */,
</span><del>-                                49951C0214B7AAB30060E96E /* length_limits.h */,
</del><span class="cx">                                 A264F89D16974DED006FAA5A /* Lexer.cpp */,
</span><span class="cx">                                 A264F89E16974DED006FAA5A /* Lexer.h */,
</span><span class="cx">                                 A264F89F16974DED006FAA5A /* Macro.cpp */,
</span><span class="lines">@@ -630,12 +695,16 @@
</span><span class="cx">                         files = (
</span><span class="cx">                                 31012E3C18B97B9B0039062F /* InitializeParseContext.h in Headers */,
</span><span class="cx">                                 A08C3CDD16D6CB61003F0B83 /* ArrayBoundsClamper.h in Headers */,
</span><ins>+                                5CC7D46F19102621000B8C1F /* debug.h in Headers */,
+                                5CC7D47519102621000B8C1F /* RefCountObject.h in Headers */,
</ins><span class="cx">                                 31012E3E18B97B9B0039062F /* InitializeVariables.h in Headers */,
</span><span class="cx">                                 31012E1418B97B9B0039062F /* BuiltInFunctionEmulator.h in Headers */,
</span><span class="cx">                                 31012E5518B97B9B0039062F /* ParseContext.h in Headers */,
</span><ins>+                                5CC7D47719102621000B8C1F /* shadervars.h in Headers */,
</ins><span class="cx">                                 31012E2C18B97B9B0039062F /* ForLoopUnroll.h in Headers */,
</span><span class="cx">                                 31012E6D18B97B9B0039062F /* TranslatorGLSL.h in Headers */,
</span><span class="cx">                                 31012E4618B97B9B0039062F /* MMap.h in Headers */,
</span><ins>+                                5CC7D47319102621000B8C1F /* mathutil.h in Headers */,
</ins><span class="cx">                                 31012E6B18B97B9B0039062F /* TranslatorESSL.h in Headers */,
</span><span class="cx">                                 31012E1618B97B9B0039062F /* Common.h in Headers */,
</span><span class="cx">                                 31012E2018B97B9B0039062F /* DependencyGraphOutput.h in Headers */,
</span><span class="lines">@@ -649,32 +718,37 @@
</span><span class="cx">                                 31012E7E18B97B9B0039062F /* VariablePacker.h in Headers */,
</span><span class="cx">                                 31012E5018B97B9B0039062F /* OutputGLSLBase.h in Headers */,
</span><span class="cx">                                 31012E4018B97B9B0039062F /* intermediate.h in Headers */,
</span><ins>+                                5CC7D47119102621000B8C1F /* event_tracer.h in Headers */,
</ins><span class="cx">                                 31012E2518B97B9B0039062F /* DetectDiscontinuity.h in Headers */,
</span><span class="cx">                                 31012E5D18B97B9B0039062F /* RenameFunction.h in Headers */,
</span><span class="cx">                                 31012E3A18B97B9B0039062F /* InitializeGlobals.h in Headers */,
</span><del>-                                31012E4518B97B9B0039062F /* MapLongVariableNames.h in Headers */,
</del><span class="cx">                                 31012E8018B97B9B0039062F /* VersionGLSL.h in Headers */,
</span><ins>+                                5C9FFF4F19102A000025B8FA /* FlagStd140Structs.h in Headers */,
</ins><span class="cx">                                 31012E2718B97B9B0039062F /* Diagnostics.h in Headers */,
</span><ins>+                                5CC7D46B19102620000B8C1F /* angleutils.h in Headers */,
</ins><span class="cx">                                 31012E3218B97B9B0039062F /* glslang_tab.h in Headers */,
</span><span class="cx">                                 A264F8B116974DED006FAA5A /* DirectiveParser.h in Headers */,
</span><span class="cx">                                 31012E5818B97B9B0039062F /* Pragma.h in Headers */,
</span><span class="cx">                                 31012E6518B97B9B0039062F /* SymbolTable.h in Headers */,
</span><ins>+                                5CC7D458191024E4000B8C1F /* ValidateOutputs.h in Headers */,
</ins><span class="cx">                                 31012E7418B97B9B0039062F /* UnfoldShortCircuitAST.h in Headers */,
</span><span class="cx">                                 31012E7218B97B9B0039062F /* UnfoldShortCircuit.h in Headers */,
</span><span class="cx">                                 A264F8B316974DED006FAA5A /* ExpressionParser.h in Headers */,
</span><span class="cx">                                 31012E5C18B97B9B0039062F /* RemoveTree.h in Headers */,
</span><span class="cx">                                 31012E4818B97B9B0039062F /* osinclude.h in Headers */,
</span><span class="cx">                                 31012E3518B97B9B0039062F /* InfoSink.h in Headers */,
</span><ins>+                                5CC7D47819102621000B8C1F /* system.h in Headers */,
</ins><span class="cx">                                 31012E1C18B97B9B0039062F /* DependencyGraph.h in Headers */,
</span><span class="cx">                                 31012E6318B97B9B0039062F /* ShHandle.h in Headers */,
</span><span class="cx">                                 31012E7018B97B9B0039062F /* Types.h in Headers */,
</span><span class="cx">                                 31012E6718B97B9B0039062F /* RestrictFragmentShaderTiming.h in Headers */,
</span><span class="cx">                                 31012E4318B97B9B0039062F /* localintermediate.h in Headers */,
</span><ins>+                                5CC7D47B19102621000B8C1F /* version.h in Headers */,
</ins><span class="cx">                                 31012E7818B97B9B0039062F /* util.h in Headers */,
</span><span class="cx">                                 A264F8B516974DED006FAA5A /* Input.h in Headers */,
</span><ins>+                                5CC7D453191024E4000B8C1F /* LoopInfo.h in Headers */,
</ins><span class="cx">                                 A264F8CD169762AA006FAA5A /* khrplatform.h in Headers */,
</span><del>-                                49951C0314B7AAB30060E96E /* length_limits.h in Headers */,
-                                31012E7618B97B9B0039062F /* Uniform.h in Headers */,
</del><ins>+                                5CC7D47A19102621000B8C1F /* utilities.h in Headers */,
</ins><span class="cx">                                 31012E2318B97B9B0039062F /* DetectCallDepth.h in Headers */,
</span><span class="cx">                                 31012E3918B97B9B0039062F /* InitializeDll.h in Headers */,
</span><span class="cx">                                 A264F8B716974DED006FAA5A /* Lexer.h in Headers */,
</span><span class="lines">@@ -684,6 +758,7 @@
</span><span class="cx">                                 31012E5718B97B9B0039062F /* PoolAlloc.h in Headers */,
</span><span class="cx">                                 31012E3718B97B9B0039062F /* Initialize.h in Headers */,
</span><span class="cx">                                 31012E5218B97B9B0039062F /* OutputHLSL.h in Headers */,
</span><ins>+                                5CC7D46D19102620000B8C1F /* blocklayout.h in Headers */,
</ins><span class="cx">                                 31012E1A18B97B9B0039062F /* ConstantUnion.h in Headers */,
</span><span class="cx">                                 A264F8BB16974DED006FAA5A /* MacroExpander.h in Headers */,
</span><span class="cx">                                 31012E2D18B97B9B0039062F /* glslang.h in Headers */,
</span><span class="lines">@@ -787,14 +862,16 @@
</span><span class="cx">                                 A264F8AC16974DED006FAA5A /* DiagnosticsBase.cpp in Sources */,
</span><span class="cx">                                 31012E1518B97B9B0039062F /* CodeGen.cpp in Sources */,
</span><span class="cx">                                 31012E3F18B97B9B0039062F /* Intermediate.cpp in Sources */,
</span><ins>+                                5CC7D47219102621000B8C1F /* mathutil.cpp in Sources */,
</ins><span class="cx">                                 31012E3B18B97B9B0039062F /* InitializeParseContext.cpp in Sources */,
</span><ins>+                                5CC7D47019102621000B8C1F /* event_tracer.cpp in Sources */,
</ins><span class="cx">                                 31012E3118B97B9B0039062F /* glslang_tab.cpp in Sources */,
</span><span class="cx">                                 31012E2118B97B9B0039062F /* DependencyGraphTraverse.cpp in Sources */,
</span><span class="cx">                                 31012E5E18B97B9B0039062F /* RewriteElseBlocks.cpp in Sources */,
</span><span class="cx">                                 31012E5418B97B9B0039062F /* ParseContext.cpp in Sources */,
</span><span class="cx">                                 A264F8AE16974DED006FAA5A /* DirectiveHandlerBase.cpp in Sources */,
</span><del>-                                31012E7518B97B9B0039062F /* Uniform.cpp in Sources */,
</del><span class="cx">                                 31012E4D18B97B9B0039062F /* OutputGLSL.cpp in Sources */,
</span><ins>+                                5CC7D47619102621000B8C1F /* shadervars.cpp in Sources */,
</ins><span class="cx">                                 31012E3018B97B9B0039062F /* glslang_lex.cpp in Sources */,
</span><span class="cx">                                 31012E4118B97B9B0039062F /* intermOut.cpp in Sources */,
</span><span class="cx">                                 31012E6E18B97B9B0039062F /* TranslatorHLSL.cpp in Sources */,
</span><span class="lines">@@ -807,7 +884,9 @@
</span><span class="cx">                                 31012E5918B97B9B0039062F /* QualifierAlive.cpp in Sources */,
</span><span class="cx">                                 31012E7118B97B9B0039062F /* UnfoldShortCircuit.cpp in Sources */,
</span><span class="cx">                                 31012E6418B97B9B0039062F /* SymbolTable.cpp in Sources */,
</span><ins>+                                5CC7D456191024E4000B8C1F /* Uniform.cpp in Sources */,
</ins><span class="cx">                                 A264F8B416974DED006FAA5A /* Input.cpp in Sources */,
</span><ins>+                                5CC7D47919102621000B8C1F /* utilities.cpp in Sources */,
</ins><span class="cx">                                 A264F8B616974DED006FAA5A /* Lexer.cpp in Sources */,
</span><span class="cx">                                 31012E6218B97B9B0039062F /* ShaderLang.cpp in Sources */,
</span><span class="cx">                                 31012E3818B97B9B0039062F /* InitializeDll.cpp in Sources */,
</span><span class="lines">@@ -820,7 +899,6 @@
</span><span class="cx">                                 31012E1318B97B9B0039062F /* BuiltInFunctionEmulator.cpp in Sources */,
</span><span class="cx">                                 31012E3418B97B9B0039062F /* InfoSink.cpp in Sources */,
</span><span class="cx">                                 31012E5318B97B9B0039062F /* parseConst.cpp in Sources */,
</span><del>-                                31012E4418B97B9B0039062F /* MapLongVariableNames.cpp in Sources */,
</del><span class="cx">                                 31012E5618B97B9B0039062F /* PoolAlloc.cpp in Sources */,
</span><span class="cx">                                 31012E6618B97B9B0039062F /* RestrictFragmentShaderTiming.cpp in Sources */,
</span><span class="cx">                                 31012E7918B97B9B0039062F /* ValidateLimitations.cpp in Sources */,
</span><span class="lines">@@ -828,15 +906,21 @@
</span><span class="cx">                                 31012E7718B97B9B0039062F /* util.cpp in Sources */,
</span><span class="cx">                                 31012E5118B97B9B0039062F /* OutputHLSL.cpp in Sources */,
</span><span class="cx">                                 31012E3618B97B9B0039062F /* Initialize.cpp in Sources */,
</span><ins>+                                5CC7D47419102621000B8C1F /* RefCountObject.cpp in Sources */,
</ins><span class="cx">                                 31012E7B18B97B9B0039062F /* VariableInfo.cpp in Sources */,
</span><ins>+                                5CC7D452191024E4000B8C1F /* LoopInfo.cpp in Sources */,
</ins><span class="cx">                                 31012E1D18B97B9B0039062F /* DependencyGraphBuilder.cpp in Sources */,
</span><span class="cx">                                 31012E7D18B97B9B0039062F /* VariablePacker.cpp in Sources */,
</span><span class="cx">                                 31012E1F18B97B9B0039062F /* DependencyGraphOutput.cpp in Sources */,
</span><ins>+                                5CC7D46C19102620000B8C1F /* blocklayout.cpp in Sources */,
</ins><span class="cx">                                 31012E4B18B97B9B0039062F /* OutputESSL.cpp in Sources */,
</span><span class="cx">                                 A264F8BE16974DED006FAA5A /* Preprocessor.cpp in Sources */,
</span><ins>+                                5CC7D457191024E4000B8C1F /* ValidateOutputs.cpp in Sources */,
</ins><span class="cx">                                 31012E2B18B97B9B0039062F /* ForLoopUnroll.cpp in Sources */,
</span><ins>+                                5C9FFF4E19102A000025B8FA /* FlagStd140Structs.cpp in Sources */,
</ins><span class="cx">                                 31012E2218B97B9B0039062F /* DetectCallDepth.cpp in Sources */,
</span><span class="cx">                                 31012E1718B97B9B0039062F /* Compiler.cpp in Sources */,
</span><ins>+                                5CC7D46E19102621000B8C1F /* debug.cpp in Sources */,
</ins><span class="cx">                                 31012E6A18B97B9B0039062F /* TranslatorESSL.cpp in Sources */,
</span><span class="cx">                                 31012E4F18B97B9B0039062F /* OutputGLSLBase.cpp in Sources */,
</span><span class="cx">                                 31012E1B18B97B9B0039062F /* DependencyGraph.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEAUTHORS"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/AUTHORS (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/AUTHORS        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/AUTHORS        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -13,6 +13,8 @@
</span><span class="cx"> 
</span><span class="cx"> Adobe Systems Inc.
</span><span class="cx"> Autodesk, Inc.
</span><ins>+BlackBerry Limited
+Cable Television Laboratories, Inc.
</ins><span class="cx"> Cloud Party, Inc.
</span><span class="cx"> Intel Corporation
</span><span class="cx"> Mozilla Corporation
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLECONTRIBUTORS"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/CONTRIBUTORS (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/CONTRIBUTORS        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/CONTRIBUTORS        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx">  Adrienne Walker
</span><span class="cx">  thestig@chromium.org
</span><span class="cx">  Justin Schuh
</span><ins>+ Scott Graham
</ins><span class="cx"> 
</span><span class="cx"> Adobe Systems Inc.
</span><span class="cx">  Alexandru Chiculita
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/ChangeLog        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2014-04-30  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        Updated ANGLE.
+        https://bugs.webkit.org/show_bug.cgi?id=132367
+        &lt;rdar://problem/16211451&gt;
+
+        Reviewed by Dean Jackson.
+
+        * ANGLE.plist:
+        Updated and xml encoded.
+        * ANGLE.xcodeproj/project.pbxproj:
+        Added needed new source files.
+        * changes.diff: 
+        Added to keep track of differences between WebKit's copy of ANGLE and the master repository.
+        
+        Updated ANGLE source files to e7a453a5bd76705ccb151117fa844846d4aa90af.  Long list of changes omitted.
+
</ins><span class="cx"> 2014-03-25  Martin Robinson  &lt;mrobinson@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Remove the autotools build
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEDEPS"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/DEPS (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/DEPS        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/DEPS        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,18 +1,18 @@
</span><span class="cx"> deps = {
</span><del>-  &quot;trunk/third_party/gyp&quot;:
-      &quot;http://gyp.googlecode.com/svn/trunk@1564&quot;,
</del><ins>+  &quot;third_party/gyp&quot;:
+      &quot;http://gyp.googlecode.com/svn/trunk@1806&quot;,
</ins><span class="cx"> 
</span><del>-  &quot;trunk/third_party/googletest&quot;:
-      &quot;http://googletest.googlecode.com/svn/trunk@573&quot;, #release 1.6.0
</del><ins>+  &quot;tests/third_party/googletest&quot;:
+      &quot;http://googletest.googlecode.com/svn/trunk@629&quot;,
</ins><span class="cx"> 
</span><del>-  &quot;trunk/third_party/googlemock&quot;:
-      &quot;http://googlemock.googlecode.com/svn/trunk@387&quot;, #release 1.6.0
</del><ins>+  &quot;tests/third_party/googlemock&quot;:
+      &quot;http://googlemock.googlecode.com/svn/trunk@410&quot;,
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> hooks = [
</span><span class="cx">   {
</span><span class="cx">     # A change to a .gyp, .gypi, or to GYP itself should run the generator.
</span><span class="cx">     &quot;pattern&quot;: &quot;.&quot;,
</span><del>-    &quot;action&quot;: [&quot;python&quot;, &quot;trunk/build/gyp_angle&quot;],
</del><ins>+    &quot;action&quot;: [&quot;python&quot;, &quot;build/gyp_angle&quot;],
</ins><span class="cx">   },
</span><span class="cx"> ]
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEchangesdiff"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/changes.diff (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/changes.diff                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/changes.diff        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,227 @@
</span><ins>+diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h
+index 7970bfa..9cdcc24 100644
+--- a/include/GLSLANG/ShaderLang.h
++++ b/include/GLSLANG/ShaderLang.h
+@@ -23,7 +23,7 @@
+ #define COMPILER_EXPORT
+ #endif

+-#include &quot;KHR/khrplatform.h&quot;
++#include &quot;khrplatform.h&quot;
+ #include &lt;stddef.h&gt;

+ //
+diff --git a/src/common/mathutil.h b/src/common/mathutil.h
+index 9061bbd..0b4f384 100644
+--- a/src/common/mathutil.h
++++ b/src/common/mathutil.h
+@@ -478,7 +478,7 @@ inline unsigned int average(unsigned int a, unsigned int b)

+ inline signed int average(signed int a, signed int b)
+ {
+-    return ((long long)a + (long long)b) / 2;
++    return (signed int)((long long)a + (long long)b) / 2;
+ }

+ inline float average(float a, float b)
+diff --git a/src/common/shadervars.cpp b/src/common/shadervars.cpp
+index c9843dc..bc3d1c0 100644
+--- a/src/common/shadervars.cpp
++++ b/src/common/shadervars.cpp
+@@ -59,7 +59,7 @@ void Varying::resetRegisterAssignment()
+     elementIndex = GL_INVALID_INDEX;
+ }

+-BlockMemberInfo::BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix)
++BlockMemberInfo::BlockMemberInfo(long offset, long arrayStride, long matrixStride, bool isRowMajorMatrix)
+     : offset(offset),
+       arrayStride(arrayStride),
+       matrixStride(matrixStride),
+diff --git a/src/common/shadervars.h b/src/common/shadervars.h
+index eba0141..7466777 100644
+--- a/src/common/shadervars.h
++++ b/src/common/shadervars.h
+@@ -42,8 +42,8 @@ struct ShaderVariable

+ struct Uniform : public ShaderVariable
+ {
+-    unsigned int registerIndex;
+-    unsigned int elementIndex;     // For struct varyings
++    unsigned long registerIndex;
++    unsigned long elementIndex;     // For struct varyings
+     std::vector&lt;Uniform&gt; fields;

+     Uniform(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn,
+@@ -88,11 +88,11 @@ struct Varying : public ShaderVariable

+ struct BlockMemberInfo
+ {
+-    BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix);
++    BlockMemberInfo(long offset, long arrayStride, long matrixStride, bool isRowMajorMatrix);

+-    int offset;
+-    int arrayStride;
+-    int matrixStride;
++    long offset;
++    long arrayStride;
++    long matrixStride;
+     bool isRowMajorMatrix;

+     static const BlockMemberInfo defaultBlockInfo;
+diff --git a/src/compiler/preprocessor/ExpressionParser.cpp b/src/compiler/preprocessor/ExpressionParser.cpp
+index 7c6adc6..fe7a653 100644
+--- a/src/compiler/preprocessor/ExpressionParser.cpp
++++ b/src/compiler/preprocessor/ExpressionParser.cpp
+@@ -1,5 +1,7 @@
+ /* A Bison parser, made by GNU Bison 2.7.1.  */

++/* Apple Note: For the avoidance of doubt, Apple elects to distribute this file under the terms of the BSD license. */
++
+ /* Bison implementation for Yacc-like parsers in C
+    
+       Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+diff --git a/src/compiler/preprocessor/Tokenizer.cpp b/src/compiler/preprocessor/Tokenizer.cpp
+index 25aefa9..de8efff 100644
+--- a/src/compiler/preprocessor/Tokenizer.cpp
++++ b/src/compiler/preprocessor/Tokenizer.cpp
+@@ -549,6 +549,12 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
+ #pragma GCC diagnostic ignored &quot;-Wmissing-noreturn&quot;
+ #endif

++#if defined(__clang__)
++#pragma clang diagnostic push
++#pragma clang diagnostic ignored &quot;-Wunknown-pragmas&quot;
++#pragma clang diagnostic ignored &quot;-Wdeprecated-register&quot;
++#endif
++
+ typedef std::string YYSTYPE;
+ typedef pp::SourceLocation YYLTYPE;

+@@ -698,6 +704,8 @@ static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+ #endif

++#define YY_NO_INPUT
++
+ #ifndef YY_NO_INPUT

+ #ifdef __cplusplus
+@@ -2314,6 +2322,10 @@ void ppfree (void * ptr , yyscan_t yyscanner)

+ #define YYTABLES_NAME &quot;yytables&quot;

++#if defined(__clang__)
++#pragma clang diagnostic pop
++#endif
++
+ namespace pp {

+ Tokenizer::Tokenizer(Diagnostics* diagnostics)
+diff --git a/src/compiler/preprocessor/Tokenizer.l b/src/compiler/preprocessor/Tokenizer.l
+index ab9d99a..850c639 100644
+--- a/src/compiler/preprocessor/Tokenizer.l
++++ b/src/compiler/preprocessor/Tokenizer.l
+@@ -33,6 +33,12 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
+ #pragma GCC diagnostic ignored &quot;-Wmissing-noreturn&quot;
+ #endif

++#if defined(__clang__)
++#pragma clang diagnostic push
++#pragma clang diagnostic ignored &quot;-Wunknown-pragmas&quot;
++#pragma clang diagnostic ignored &quot;-Wdeprecated-register&quot;
++#endif
++
+ typedef std::string YYSTYPE;
+ typedef pp::SourceLocation YYLTYPE;

+@@ -265,6 +271,10 @@ FRACTIONAL_CONSTANT  ({DIGIT}*&quot;.&quot;{DIGIT}+)|({DIGIT}+&quot;.&quot;)

+ %%

++#if defined(__clang__)
++#pragma clang diagnostic pop
++#endif
++
+ namespace pp {

+ Tokenizer::Tokenizer(Diagnostics* diagnostics) : mHandle(0)
+diff --git a/src/compiler/translator/glslang.l b/src/compiler/translator/glslang.l
+index 518b78d..c8ff855 100644
+--- a/src/compiler/translator/glslang.l
++++ b/src/compiler/translator/glslang.l
+@@ -33,6 +33,11 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
+ #pragma warning(disable: 4505)
+ #pragma warning(disable: 4701)
+ #endif
++#if defined(__clang__)
++#pragma clang diagnostic push
++#pragma clang diagnostic ignored &quot;-Wunknown-pragmas&quot;
++#pragma clang diagnostic ignored &quot;-Wdeprecated-register&quot;
++#endif
+ }

+ %{
+@@ -379,6 +384,10 @@ O           [0-7]

+ %%

++#if defined(__clang__)
++#pragma clang diagnostic pop
++#endif
++
+ yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) {
+     pp::Token token;
+     yyget_extra(yyscanner)-&gt;preprocessor.lex(&amp;token);
+diff --git a/src/compiler/translator/glslang_lex.cpp b/src/compiler/translator/glslang_lex.cpp
+index 5cfbba6..456491b 100644
+--- a/src/compiler/translator/glslang_lex.cpp
++++ b/src/compiler/translator/glslang_lex.cpp
+@@ -18,8 +18,11 @@
+ #pragma warning(disable: 4505)
+ #pragma warning(disable: 4701)
+ #endif
+-
+-
++#if defined(__clang__)
++#pragma clang diagnostic push
++#pragma clang diagnostic ignored &quot;-Wunknown-pragmas&quot;
++#pragma clang diagnostic ignored &quot;-Wdeprecated-register&quot;
++#endif

+ #line 25 &quot;./glslang_lex.cpp&quot;

+@@ -3181,6 +3184,10 @@ void yyfree (void * ptr , yyscan_t yyscanner)

+ #define YYTABLES_NAME &quot;yytables&quot;

++#if defined(__clang__)
++#pragma clang diagnostic pop
++#endif
++
+ yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) {
+     pp::Token token;
+     yyget_extra(yyscanner)-&gt;preprocessor.lex(&amp;token);
+diff --git a/src/compiler/translator/glslang_tab.cpp b/src/compiler/translator/glslang_tab.cpp
+index 70d46d8..cba3cc4 100644
+--- a/src/compiler/translator/glslang_tab.cpp
++++ b/src/compiler/translator/glslang_tab.cpp
+@@ -1,5 +1,7 @@
+ /* A Bison parser, made by GNU Bison 2.7.1.  */

++/* Apple Note: For the avoidance of doubt, Apple elects to distribute this file under the terms of the BSD license. */
++
+ /* Bison implementation for Yacc-like parsers in C
+    
+       Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+diff --git a/src/compiler/translator/glslang_tab.h b/src/compiler/translator/glslang_tab.h
+index c6a61dc..09a38d4 100644
+--- a/src/compiler/translator/glslang_tab.h
++++ b/src/compiler/translator/glslang_tab.h
+@@ -1,5 +1,7 @@
+ /* A Bison parser, made by GNU Bison 2.7.1.  */

++/* Apple Note: For the avoidance of doubt, Apple elects to distribute this file under the terms of the BSD license. */
++
+ /* Bison interface for Yacc-like parsers in C
+    
+       Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEcodereviewsettings"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/codereview.settings (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/codereview.settings        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/codereview.settings        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><span class="cx"> # This file is used by gcl to get repository specific information.
</span><del>-CODE_REVIEW_SERVER: codereview.appspot.com
-CC_LIST: angleproject-review@googlegroups.com
-VIEW_VC: http://code.google.com/p/angleproject/source/detail?r=
</del><ins>+GERRIT_HOST: chromium-review.googlesource.com
+GERRIT_PORT: 29418
+CODE_REVIEW_SERVER: chromium-review.googlesource.com
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEincludeEGLeglh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/include/EGL/egl.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/include/EGL/egl.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/include/EGL/egl.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /* -*- mode: c; tab-width: 8; -*- */
</span><span class="cx"> /* vi: set sw=4 ts=8: */
</span><span class="cx"> /* Reference version of egl.h for EGL 1.4.
</span><del>- * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
</del><ins>+ * $Revision: 9356 $ on $Date: 2009-10-21 05:52:25 -0400 (Wed, 21 Oct 2009) $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEincludeEGLeglexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/include/EGL/eglext.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/include/EGL/eglext.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/include/EGL/eglext.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -6,7 +6,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /*
</span><del>-** Copyright (c) 2007-2012 The Khronos Group Inc.
</del><ins>+** Copyright (c) 2007-2013 The Khronos Group Inc.
</ins><span class="cx"> **
</span><span class="cx"> ** Permission is hereby granted, free of charge, to any person obtaining a
</span><span class="cx"> ** copy of this software and/or associated documentation files (the
</span><span class="lines">@@ -34,8 +34,8 @@
</span><span class="cx"> 
</span><span class="cx"> /* Header file version number */
</span><span class="cx"> /* Current version at http://www.khronos.org/registry/egl/ */
</span><del>-/* $Revision: 16473 $ on $Date: 2012-01-04 02:20:48 -0800 (Wed, 04 Jan 2012) $ */
-#define EGL_EGLEXT_VERSION 11
</del><ins>+/* $Revision: 20690 $ on $Date: 2013-02-22 20:15:05 -0500 (Fri, 22 Feb 2013) $ */
+#define EGL_EGLEXT_VERSION 15
</ins><span class="cx"> 
</span><span class="cx"> #ifndef EGL_KHR_config_attribs
</span><span class="cx"> #define EGL_KHR_config_attribs 1
</span><span class="lines">@@ -208,12 +208,12 @@
</span><span class="cx"> typedef void* EGLSyncNV;
</span><span class="cx"> typedef khronos_utime_nanoseconds_t EGLTimeNV;
</span><span class="cx"> #ifdef EGL_EGLEXT_PROTOTYPES
</span><del>-EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
-EGLBoolean eglDestroySyncNV (EGLSyncNV sync);
-EGLBoolean eglFenceNV (EGLSyncNV sync);
-EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
-EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
-EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
</del><ins>+EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync);
+EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync);
+EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
+EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
</ins><span class="cx"> #endif /* EGL_EGLEXT_PROTOTYPES */
</span><span class="cx"> typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
</span><span class="cx"> typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);
</span><span class="lines">@@ -250,7 +250,6 @@
</span><span class="cx">         EGLint                iHeight;
</span><span class="cx">         EGLint                iStride;
</span><span class="cx"> };
</span><del>-
</del><span class="cx"> #ifdef EGL_EGLEXT_PROTOTYPES
</span><span class="cx"> EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
</span><span class="cx"> #endif /* EGL_EGLEXT_PROTOTYPES */
</span><span class="lines">@@ -324,12 +323,10 @@
</span><span class="cx"> #define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV        0x3133
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if KHRONOS_SUPPORT_INT64   /* EGLTimeKHR requires 64-bit uint support */
</del><ins>+#if KHRONOS_SUPPORT_INT64   /* EGLuint64NV requires 64-bit uint support */
</ins><span class="cx"> #ifndef EGL_NV_system_time
</span><span class="cx"> #define EGL_NV_system_time 1
</span><del>-
</del><span class="cx"> typedef khronos_utime_nanoseconds_t EGLuint64NV;
</span><del>-
</del><span class="cx"> #ifdef EGL_EGLEXT_PROTOTYPES
</span><span class="cx"> EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
</span><span class="cx"> EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
</span><span class="lines">@@ -339,6 +336,86 @@
</span><span class="cx"> #endif
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */
+#ifndef EGL_KHR_stream
+#define EGL_KHR_stream 1
+typedef void* EGLStreamKHR;
+typedef khronos_uint64_t EGLuint64KHR;
+#define EGL_NO_STREAM_KHR                        ((EGLStreamKHR)0)
+#define EGL_CONSUMER_LATENCY_USEC_KHR                0x3210
+#define EGL_PRODUCER_FRAME_KHR                        0x3212
+#define EGL_CONSUMER_FRAME_KHR                        0x3213
+#define EGL_STREAM_STATE_KHR                        0x3214
+#define EGL_STREAM_STATE_CREATED_KHR                0x3215
+#define EGL_STREAM_STATE_CONNECTING_KHR                0x3216
+#define EGL_STREAM_STATE_EMPTY_KHR                0x3217
+#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR    0x3218
+#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR    0x3219
+#define EGL_STREAM_STATE_DISCONNECTED_KHR        0x321A
+#define EGL_BAD_STREAM_KHR                        0x321B
+#define EGL_BAD_STATE_KHR                        0x321C
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_consumer_gltexture
+#define EGL_KHR_stream_consumer_gltexture 1
+#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR        0x321E
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_producer_eglsurface
+#define EGL_KHR_stream_producer_eglsurface 1
+#define EGL_STREAM_BIT_KHR                        0x0800
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_producer_aldatalocator
+#define EGL_KHR_stream_producer_aldatalocator 1
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_fifo
+#define EGL_KHR_stream_fifo 1
+/* reuse EGLTimeKHR */
+#define EGL_STREAM_FIFO_LENGTH_KHR                0x31FC
+#define EGL_STREAM_TIME_NOW_KHR                        0x31FD
+#define EGL_STREAM_TIME_CONSUMER_KHR                0x31FE
+#define EGL_STREAM_TIME_PRODUCER_KHR                0x31FF
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
+#endif
+#endif
+
</ins><span class="cx"> #ifndef EGL_EXT_create_context_robustness
</span><span class="cx"> #define EGL_EXT_create_context_robustness 1
</span><span class="cx"> #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT        0x30BF
</span><span class="lines">@@ -347,8 +424,158 @@
</span><span class="cx"> #define EGL_LOSE_CONTEXT_ON_RESET_EXT                0x31BF
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef EGL_ANGLE_d3d_share_handle_client_buffer
+#define EGL_ANGLE_d3d_share_handle_client_buffer 1
+/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */
+#endif
+
+#ifndef EGL_ANGLE_window_fixed_size
+#define EGL_ANGLE_window_fixed_size 1
+#define EGL_FIXED_SIZE_ANGLE        0x3201
+#endif
+
+#ifndef EGL_KHR_create_context
+#define EGL_KHR_create_context 1
+#define EGL_CONTEXT_MAJOR_VERSION_KHR                            EGL_CONTEXT_CLIENT_VERSION
+#define EGL_CONTEXT_MINOR_VERSION_KHR                            0x30FB
+#define EGL_CONTEXT_FLAGS_KHR                                    0x30FC
+#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR                    0x30FD
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR  0x31BD
+#define EGL_NO_RESET_NOTIFICATION_KHR                            0x31BE
+#define EGL_LOSE_CONTEXT_ON_RESET_KHR                            0x31BF
+#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR                    0x00000001
+#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR            0x00000002
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR            0x00000004
+#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR                    0x00000001
+#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR    0x00000002
+#define EGL_OPENGL_ES3_BIT_KHR                                    0x00000040
+#endif
+
+#ifndef EGL_KHR_surfaceless_context
+#define EGL_KHR_surfaceless_context 1
+/* No tokens/entry points, just relaxes an error condition */
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_cross_process_fd
+#define EGL_KHR_stream_cross_process_fd 1
+typedef int EGLNativeFileDescriptorKHR;
+#define EGL_NO_FILE_DESCRIPTOR_KHR                ((EGLNativeFileDescriptorKHR)(-1))
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
+#endif
+#endif
+
+#ifndef EGL_EXT_multiview_window
+#define EGL_EXT_multiview_window 1
+#define EGL_MULTIVIEW_VIEW_COUNT_EXT                0x3134
+#endif
+
+#ifndef EGL_KHR_wait_sync
+#define EGL_KHR_wait_sync 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+#endif
+
+#ifndef EGL_NV_post_convert_rounding
+#define EGL_NV_post_convert_rounding 1
+/* No tokens or entry points, just relaxes behavior of SwapBuffers */
+#endif
+
+#ifndef EGL_NV_native_query
+#define EGL_NV_native_query 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV( EGLDisplay dpy, EGLNativeDisplayType* display_id);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV( EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType* window);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV( EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType* pixmap);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)(EGLDisplay dpy, EGLNativeDisplayType *display_id);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap);
+#endif
+
+#ifndef EGL_NV_3dvision_surface
+#define EGL_NV_3dvision_surface 1
+#define EGL_AUTO_STEREO_NV                        0x3136
+#endif
+
+#ifndef EGL_ANDROID_framebuffer_target
+#define EGL_ANDROID_framebuffer_target 1
+#define EGL_FRAMEBUFFER_TARGET_ANDROID                0x3147
+#endif
+
+#ifndef EGL_ANDROID_blob_cache
+#define EGL_ANDROID_blob_cache 1
+typedef khronos_ssize_t EGLsizeiANDROID;
+typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);
+typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
+#endif
+
+#ifndef EGL_ANDROID_image_native_buffer
+#define EGL_ANDROID_image_native_buffer 1
+#define EGL_NATIVE_BUFFER_ANDROID                0x3140
+#endif
+
+#ifndef EGL_ANDROID_native_fence_sync
+#define EGL_ANDROID_native_fence_sync 1
+#define EGL_SYNC_NATIVE_FENCE_ANDROID                0x3144
+#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID        0x3145
+#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID        0x3146
+#define EGL_NO_NATIVE_FENCE_FD_ANDROID                -1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, EGLSyncKHR);
+#endif
+
+#ifndef EGL_ANDROID_recordable
+#define EGL_ANDROID_recordable 1
+#define EGL_RECORDABLE_ANDROID                        0x3142
+#endif
+
+#ifndef EGL_EXT_buffer_age
+#define EGL_EXT_buffer_age 1
+#define EGL_BUFFER_AGE_EXT                        0x313D
+#endif
+
+#ifndef EGL_EXT_image_dma_buf_import
+#define EGL_EXT_image_dma_buf_import 1
+#define EGL_LINUX_DMA_BUF_EXT                        0x3270
+#define EGL_LINUX_DRM_FOURCC_EXT                0x3271
+#define EGL_DMA_BUF_PLANE0_FD_EXT                0x3272
+#define EGL_DMA_BUF_PLANE0_OFFSET_EXT                0x3273
+#define EGL_DMA_BUF_PLANE0_PITCH_EXT                0x3274
+#define EGL_DMA_BUF_PLANE1_FD_EXT                0x3275
+#define EGL_DMA_BUF_PLANE1_OFFSET_EXT                0x3276
+#define EGL_DMA_BUF_PLANE1_PITCH_EXT                0x3277
+#define EGL_DMA_BUF_PLANE2_FD_EXT                0x3278
+#define EGL_DMA_BUF_PLANE2_OFFSET_EXT                0x3279
+#define EGL_DMA_BUF_PLANE2_PITCH_EXT                0x327A
+#define EGL_YUV_COLOR_SPACE_HINT_EXT                0x327B
+#define EGL_SAMPLE_RANGE_HINT_EXT                0x327C
+#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D
+#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E
+#define EGL_ITU_REC601_EXT                        0x327F
+#define EGL_ITU_REC709_EXT                        0x3280
+#define EGL_ITU_REC2020_EXT                        0x3281
+#define EGL_YUV_FULL_RANGE_EXT                        0x3282
+#define EGL_YUV_NARROW_RANGE_EXT                0x3283
+#define EGL_YUV_CHROMA_SITING_0_EXT                0x3284
+#define EGL_YUV_CHROMA_SITING_0_5_EXT                0x3285
+#endif
+
</ins><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#endif
</del><ins>+#endif /* __eglext_h_ */
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEincludeEGLeglplatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/include/EGL/eglplatform.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/include/EGL/eglplatform.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/include/EGL/eglplatform.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> */
</span><span class="cx"> 
</span><span class="cx"> /* Platform-specific types and definitions for egl.h
</span><del>- * $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $
</del><ins>+ * $Revision: 12306 $ on $Date: 2010-08-25 12:51:28 -0400 (Wed, 25 Aug 2010) $
</ins><span class="cx">  *
</span><span class="cx">  * Adopters may modify khrplatform.h and this file to suit their platform.
</span><span class="cx">  * You are encouraged to submit all modifications to the Khronos group so that
</span><span class="lines">@@ -83,14 +83,8 @@
</span><span class="cx"> typedef void *EGLNativeWindowType;
</span><span class="cx"> typedef void *EGLNativePixmapType;
</span><span class="cx"> 
</span><del>-#elif defined(WL_EGL_PLATFORM)
</del><ins>+#elif defined(__unix__)
</ins><span class="cx"> 
</span><del>-typedef struct wl_display     *EGLNativeDisplayType;
-typedef struct wl_egl_pixmap  *EGLNativePixmapType;
-typedef struct wl_egl_window  *EGLNativeWindowType;
-
-#elif defined(__unix__) &amp;&amp; !defined(ANDROID)
-
</del><span class="cx"> /* X11 (tentative)  */
</span><span class="cx"> #include &lt;X11/Xlib.h&gt;
</span><span class="cx"> #include &lt;X11/Xutil.h&gt;
</span><span class="lines">@@ -99,14 +93,6 @@
</span><span class="cx"> typedef Pixmap   EGLNativePixmapType;
</span><span class="cx"> typedef Window   EGLNativeWindowType;
</span><span class="cx"> 
</span><del>-#elif defined(ANDROID)
-
-struct egl_native_pixmap_t;
-
-typedef struct ANativeWindow*           EGLNativeWindowType;
-typedef struct egl_native_pixmap_t*     EGLNativePixmapType;
-typedef void*                           EGLNativeDisplayType;
-
</del><span class="cx"> #else
</span><span class="cx"> #error &quot;Platform not recognized&quot;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEincludeGLES2gl2h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/include/GLES2/gl2.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/include/GLES2/gl2.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/include/GLES2/gl2.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> #ifndef __gl2_h_
</span><span class="cx"> #define __gl2_h_
</span><span class="cx"> 
</span><del>-/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
</del><ins>+/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */
</ins><span class="cx"> 
</span><span class="cx"> #include &lt;GLES2/gl2platform.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -431,7 +431,6 @@
</span><span class="cx"> #define GL_RGB5_A1                        0x8057
</span><span class="cx"> #define GL_RGB565                         0x8D62
</span><span class="cx"> #define GL_DEPTH_COMPONENT16              0x81A5
</span><del>-#define GL_STENCIL_INDEX                  0x1901
</del><span class="cx"> #define GL_STENCIL_INDEX8                 0x8D48
</span><span class="cx"> 
</span><span class="cx"> #define GL_RENDERBUFFER_WIDTH             0x8D42
</span><span class="lines">@@ -528,7 +527,7 @@
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
</span><del>-GL_APICALL int          GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
</del><ins>+GL_APICALL GLint        GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
</ins><span class="cx"> GL_APICALL void         GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
</span><span class="cx"> GL_APICALL GLenum       GL_APIENTRY glGetError (void);
</span><span class="lines">@@ -547,7 +546,7 @@
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
</span><del>-GL_APICALL int          GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
</del><ins>+GL_APICALL GLint        GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
</ins><span class="cx"> GL_APICALL void         GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
</span><span class="lines">@@ -569,7 +568,7 @@
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
</span><del>-GL_APICALL void         GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
</del><ins>+GL_APICALL void         GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
</ins><span class="cx"> GL_APICALL void         GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
</span><span class="cx"> GL_APICALL void         GL_APIENTRY glStencilMask (GLuint mask);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEincludeGLES2gl2exth"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/include/GLES2/gl2ext.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/include/GLES2/gl2ext.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/include/GLES2/gl2ext.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> #ifndef __gl2ext_h_
</span><span class="cx"> #define __gl2ext_h_
</span><span class="cx"> 
</span><del>-/* $Revision: 16482 $ on $Date:: 2012-01-04 13:44:55 -0500 #$ */
</del><ins>+/* $Revision: 20795 $ on $Date:: 2013-03-07 01:01:58 -0800 #$ */
</ins><span class="cx"> 
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> extern &quot;C&quot; {
</span><span class="lines">@@ -93,6 +93,25 @@
</span><span class="cx"> #define GL_DEPTH24_STENCIL8_OES                                 0x88F0
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_OES_required_internalformat */
+#ifndef GL_OES_required_internalformat 
+#define GL_ALPHA8_OES                                           0x803C
+#define GL_DEPTH_COMPONENT16_OES                                0x81A5
+/* reuse GL_DEPTH_COMPONENT24_OES */                            
+/* reuse GL_DEPTH24_STENCIL8_OES */                             
+/* reuse GL_DEPTH_COMPONENT32_OES */                            
+#define GL_LUMINANCE4_ALPHA4_OES                                0x8043
+#define GL_LUMINANCE8_ALPHA8_OES                                0x8045
+#define GL_LUMINANCE8_OES                                       0x8040
+#define GL_RGBA4_OES                                            0x8056
+#define GL_RGB5_A1_OES                                          0x8057
+#define GL_RGB565_OES                                           0x8D62
+/* reuse GL_RGB8_OES */                              
+/* reuse GL_RGBA8_OES */  
+/* reuse GL_RGB10_EXT */
+/* reuse GL_RGB10_A2_EXT */
+#endif 
+
</ins><span class="cx"> /* GL_OES_rgb8_rgba8 */
</span><span class="cx"> #ifndef GL_OES_rgb8_rgba8
</span><span class="cx"> #define GL_RGB8_OES                                             0x8051
</span><span class="lines">@@ -114,6 +133,10 @@
</span><span class="cx"> #define GL_STENCIL_INDEX4_OES                                   0x8D47
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef GL_OES_surfaceless_context
+#define GL_FRAMEBUFFER_UNDEFINED_OES                            0x8219
+#endif
+
</ins><span class="cx"> /* GL_OES_texture_3D */
</span><span class="cx"> #ifndef GL_OES_texture_3D
</span><span class="cx"> #define GL_TEXTURE_WRAP_R_OES                                   0x8072
</span><span class="lines">@@ -156,6 +179,85 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /*------------------------------------------------------------------------*
</span><ins>+ * KHR extension tokens
+ *------------------------------------------------------------------------*/
+
+#ifndef GL_KHR_debug
+typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS                             0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH                     0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION                              0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM                            0x8245
+#define GL_DEBUG_SOURCE_API                                     0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM                           0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER                         0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY                             0x8249
+#define GL_DEBUG_SOURCE_APPLICATION                             0x824A
+#define GL_DEBUG_SOURCE_OTHER                                   0x824B
+#define GL_DEBUG_TYPE_ERROR                                     0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR                       0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR                        0x824E
+#define GL_DEBUG_TYPE_PORTABILITY                               0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE                               0x8250
+#define GL_DEBUG_TYPE_OTHER                                     0x8251
+#define GL_DEBUG_TYPE_MARKER                                    0x8268
+#define GL_DEBUG_TYPE_PUSH_GROUP                                0x8269
+#define GL_DEBUG_TYPE_POP_GROUP                                 0x826A
+#define GL_DEBUG_SEVERITY_NOTIFICATION                          0x826B
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH                          0x826C
+#define GL_DEBUG_GROUP_STACK_DEPTH                              0x826D
+#define GL_BUFFER                                               0x82E0
+#define GL_SHADER                                               0x82E1
+#define GL_PROGRAM                                              0x82E2
+#define GL_QUERY                                                0x82E3
+/* PROGRAM_PIPELINE only in GL */                               
+#define GL_SAMPLER                                              0x82E6
+/* DISPLAY_LIST only in GL */                                   
+#define GL_MAX_LABEL_LENGTH                                     0x82E8
+#define GL_MAX_DEBUG_MESSAGE_LENGTH                             0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES                            0x9144
+#define GL_DEBUG_LOGGED_MESSAGES                                0x9145
+#define GL_DEBUG_SEVERITY_HIGH                                  0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM                                0x9147
+#define GL_DEBUG_SEVERITY_LOW                                   0x9148
+#define GL_DEBUG_OUTPUT                                         0x92E0
+#define GL_CONTEXT_FLAG_DEBUG_BIT                               0x00000002
+#define GL_STACK_OVERFLOW                                       0x0503
+#define GL_STACK_UNDERFLOW                                      0x0504
+#endif
+
+#ifndef GL_KHR_texture_compression_astc_ldr
+#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR                         0x93B0
+#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR                         0x93B1
+#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR                         0x93B2
+#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR                         0x93B3
+#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR                         0x93B4
+#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR                         0x93B5
+#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR                         0x93B6
+#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR                         0x93B7
+#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR                        0x93B8
+#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR                        0x93B9
+#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR                        0x93BA
+#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR                       0x93BB
+#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR                       0x93BC
+#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR                       0x93BD
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR                 0x93D0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR                 0x93D1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR                 0x93D2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR                 0x93D3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR                 0x93D4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR                 0x93D5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR                 0x93D6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR                 0x93D7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR                0x93D8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR                0x93D9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR                0x93DA
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR               0x93DB
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR               0x93DC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR               0x93DD
+#endif
+
+/*------------------------------------------------------------------------*
</ins><span class="cx">  * AMD extension tokens
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="lines">@@ -192,6 +294,18 @@
</span><span class="cx">  * ANGLE extension tokens
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+/* GL_ANGLE_depth_texture */
+#ifndef GL_ANGLE_depth_texture
+#define GL_DEPTH_COMPONENT                                      0x1902
+#define GL_DEPTH_STENCIL_OES                                    0x84F9
+#define GL_UNSIGNED_SHORT                                       0x1403
+#define GL_UNSIGNED_INT                                         0x1405
+#define GL_UNSIGNED_INT_24_8_OES                                0x84FA
+#define GL_DEPTH_COMPONENT16                                    0x81A5
+#define GL_DEPTH_COMPONENT32_OES                                0x81A7
+#define GL_DEPTH24_STENCIL8_OES                                 0x88F0
+#endif
+
</ins><span class="cx"> /* GL_ANGLE_framebuffer_blit */
</span><span class="cx"> #ifndef GL_ANGLE_framebuffer_blit
</span><span class="cx"> #define GL_READ_FRAMEBUFFER_ANGLE                               0x8CA8
</span><span class="lines">@@ -207,53 +321,49 @@
</span><span class="cx"> #define GL_MAX_SAMPLES_ANGLE                                    0x8D57
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_ANGLE_instanced_arrays */
+#ifndef GL_ANGLE_instanced_arrays 
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE                    0x88FE
+#endif
+
</ins><span class="cx"> /* GL_ANGLE_pack_reverse_row_order */
</span><del>-#ifndef GL_ANGLE_pack_reverse_row_order
</del><ins>+#ifndef GL_ANGLE_pack_reverse_row_order 
</ins><span class="cx"> #define GL_PACK_REVERSE_ROW_ORDER_ANGLE                         0x93A4
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_ANGLE_program_binary */
+#ifndef GL_ANGLE_program_binary
+#define GL_PROGRAM_BINARY_ANGLE                                 0x93A6
+#endif
+
</ins><span class="cx"> /* GL_ANGLE_texture_compression_dxt3 */
</span><del>-#ifndef GL_ANGLE_texture_compression_dxt3
</del><ins>+#ifndef GL_ANGLE_texture_compression_dxt3 
</ins><span class="cx"> #define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE                      0x83F2
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /* GL_ANGLE_texture_compression_dxt5 */
</span><del>-#ifndef GL_ANGLE_texture_compression_dxt5
</del><ins>+#ifndef GL_ANGLE_texture_compression_dxt5 
</ins><span class="cx"> #define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE                      0x83F3
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-/* GL_ANGLE_translated_shader_source */
-#ifndef GL_ANGLE_translated_shader_source
-#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE                0x93A0
-#endif
-
</del><span class="cx"> /* GL_ANGLE_texture_usage */
</span><del>-#ifndef GL_ANGLE_texture_usage
</del><ins>+#ifndef GL_ANGLE_texture_usage 
</ins><span class="cx"> #define GL_TEXTURE_USAGE_ANGLE                                  0x93A2
</span><span class="cx"> #define GL_FRAMEBUFFER_ATTACHMENT_ANGLE                         0x93A3
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-/* GL_ANGLE_instanced_arrays */
-#ifndef GL_ANGLE_instanced_arrays
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE                    0x88FE
</del><ins>+/* GL_ANGLE_translated_shader_source */
+#ifndef GL_ANGLE_translated_shader_source 
+#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE                0x93A0
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-/* GL_ANGLE_program_binary */
-#ifndef GL_ANGLE_program_binary
-#define GL_PROGRAM_BINARY_ANGLE                                 0x93A6
-#endif
-
</del><span class="cx"> /*------------------------------------------------------------------------*
</span><span class="cx">  * APPLE extension tokens
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-/* GL_APPLE_rgb_422 */
-#ifndef GL_APPLE_rgb_422
-#define GL_RGB_422_APPLE                                        0x8A1F
-#define GL_UNSIGNED_SHORT_8_8_APPLE                             0x85BA
-#define GL_UNSIGNED_SHORT_8_8_REV_APPLE                         0x85BB
-#endif
-
</del><ins>+/* GL_APPLE_copy_texture_levels */
+/* No new tokens introduced by this extension. */
+    
</ins><span class="cx"> /* GL_APPLE_framebuffer_multisample */
</span><span class="cx"> #ifndef GL_APPLE_framebuffer_multisample
</span><span class="cx"> #define GL_RENDERBUFFER_SAMPLES_APPLE                           0x8CAB
</span><span class="lines">@@ -265,6 +375,47 @@
</span><span class="cx"> #define GL_READ_FRAMEBUFFER_BINDING_APPLE                       0x8CAA
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_APPLE_rgb_422 */
+#ifndef GL_APPLE_rgb_422
+#define GL_RGB_422_APPLE                                        0x8A1F
+#define GL_UNSIGNED_SHORT_8_8_APPLE                             0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE                         0x85BB
+#endif
+
+/* GL_APPLE_sync */
+#ifndef GL_APPLE_sync
+
+#ifndef __gl3_h_
+/* These types are defined with reference to &lt;inttypes.h&gt;
+ * in the Apple extension spec, but here we use the Khronos
+ * portable types in khrplatform.h, and assume those types 
+ * are always defined.
+ * If any other extensions using these types are defined, 
+ * the typedefs must move out of this block and be shared.
+ */
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef struct __GLsync *GLsync;
+#endif
+
+#define GL_SYNC_OBJECT_APPLE                                    0x8A53
+#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE                        0x9111
+#define GL_OBJECT_TYPE_APPLE                                    0x9112
+#define GL_SYNC_CONDITION_APPLE                                 0x9113
+#define GL_SYNC_STATUS_APPLE                                    0x9114
+#define GL_SYNC_FLAGS_APPLE                                     0x9115
+#define GL_SYNC_FENCE_APPLE                                     0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE                     0x9117
+#define GL_UNSIGNALED_APPLE                                     0x9118
+#define GL_SIGNALED_APPLE                                       0x9119
+#define GL_ALREADY_SIGNALED_APPLE                               0x911A
+#define GL_TIMEOUT_EXPIRED_APPLE                                0x911B
+#define GL_CONDITION_SATISFIED_APPLE                            0x911C
+#define GL_WAIT_FAILED_APPLE                                    0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE                        0x00000001
+#define GL_TIMEOUT_IGNORED_APPLE                                0xFFFFFFFFFFFFFFFFull
+#endif
+
</ins><span class="cx"> /* GL_APPLE_texture_format_BGRA8888 */
</span><span class="cx"> #ifndef GL_APPLE_texture_format_BGRA8888
</span><span class="cx"> #define GL_BGRA_EXT                                             0x80E1
</span><span class="lines">@@ -279,6 +430,11 @@
</span><span class="cx">  * ARM extension tokens
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+/* GL_ARM_mali_program_binary */
+#ifndef GL_ARM_mali_program_binary
+#define GL_MALI_PROGRAM_BINARY_ARM                              0x8F61
+#endif
+
</ins><span class="cx"> /* GL_ARM_mali_shader_binary */
</span><span class="cx"> #ifndef GL_ARM_mali_shader_binary
</span><span class="cx"> #define GL_MALI_SHADER_BINARY_ARM                               0x8F60
</span><span class="lines">@@ -327,14 +483,34 @@
</span><span class="cx"> #define GL_STENCIL_EXT                                          0x1802
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_EXT_map_buffer_range */
+#ifndef GL_EXT_map_buffer_range
+#define GL_MAP_READ_BIT_EXT                                     0x0001
+#define GL_MAP_WRITE_BIT_EXT                                    0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT_EXT                         0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT                        0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT                           0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT_EXT                           0x0020
+#endif
+
</ins><span class="cx"> /* GL_EXT_multisampled_render_to_texture */
</span><span class="cx"> #ifndef GL_EXT_multisampled_render_to_texture
</span><span class="cx"> #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT           0x8D6C
</span><del>-#define GL_RENDERBUFFER_SAMPLES_EXT                             0x9133
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT               0x9134
-#define GL_MAX_SAMPLES_EXT                                      0x9135
</del><ins>+/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ 
+#define GL_RENDERBUFFER_SAMPLES_EXT                             0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT               0x8D56
+#define GL_MAX_SAMPLES_EXT                                      0x8D57
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_EXT_multiview_draw_buffers */
+#ifndef GL_EXT_multiview_draw_buffers
+#define GL_COLOR_ATTACHMENT_EXT                                 0x90F0
+#define GL_MULTIVIEW_EXT                                        0x90F1
+#define GL_DRAW_BUFFER_EXT                                      0x0C01
+#define GL_READ_BUFFER_EXT                                      0x0C02
+#define GL_MAX_MULTIVIEW_BUFFERS_EXT                            0x90F2
+#endif
+
</ins><span class="cx"> /* GL_EXT_multi_draw_arrays */
</span><span class="cx"> /* No new tokens introduced by this extension. */
</span><span class="cx"> 
</span><span class="lines">@@ -376,6 +552,11 @@
</span><span class="cx"> #define GL_PROGRAM_PIPELINE_BINDING_EXT                         0x825A
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_EXT_shader_framebuffer_fetch */
+#ifndef GL_EXT_shader_framebuffer_fetch
+#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT                 0x8A52
+#endif
+
</ins><span class="cx"> /* GL_EXT_shader_texture_lod */
</span><span class="cx"> /* No new tokens introduced by this extension. */
</span><span class="cx"> 
</span><span class="lines">@@ -384,6 +565,7 @@
</span><span class="cx"> #define GL_TEXTURE_COMPARE_MODE_EXT                             0x884C
</span><span class="cx"> #define GL_TEXTURE_COMPARE_FUNC_EXT                             0x884D
</span><span class="cx"> #define GL_COMPARE_REF_TO_TEXTURE_EXT                           0x884E
</span><ins>+#define GL_SAMPLER_2D_SHADOW_EXT                                0x8B62
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /* GL_EXT_sRGB */
</span><span class="lines">@@ -431,13 +613,19 @@
</span><span class="cx"> #define GL_LUMINANCE32F_EXT                                     0x8818
</span><span class="cx"> #define GL_LUMINANCE_ALPHA32F_EXT                               0x8819
</span><span class="cx"> /* reuse GL_RGBA16F_EXT */
</span><del>-#define GL_RGB16F_EXT                                           0x881B
</del><ins>+/* reuse GL_RGB16F_EXT */
</ins><span class="cx"> #define GL_ALPHA16F_EXT                                         0x881C
</span><span class="cx"> #define GL_LUMINANCE16F_EXT                                     0x881E
</span><span class="cx"> #define GL_LUMINANCE_ALPHA16F_EXT                               0x881F
</span><span class="cx"> #define GL_RGB10_A2_EXT                                         0x8059  
</span><span class="cx"> #define GL_RGB10_EXT                                            0x8052
</span><span class="cx"> #define GL_BGRA8_EXT                                            0x93A1
</span><ins>+#define GL_R8_EXT                                               0x8229
+#define GL_RG8_EXT                                              0x822B
+#define GL_R32F_EXT                                             0x822E  
+#define GL_RG32F_EXT                                            0x8230
+#define GL_R16F_EXT                                             0x822D
+#define GL_RG16F_EXT                                            0x822F
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /* GL_EXT_texture_type_2_10_10_10_REV */
</span><span class="lines">@@ -447,9 +635,9 @@
</span><span class="cx"> 
</span><span class="cx"> /* GL_EXT_unpack_subimage */
</span><span class="cx"> #ifndef GL_EXT_unpack_subimage
</span><del>-#define GL_UNPACK_ROW_LENGTH                                    0x0CF2
-#define GL_UNPACK_SKIP_ROWS                                     0x0CF3
-#define GL_UNPACK_SKIP_PIXELS                                   0x0CF4
</del><ins>+#define GL_UNPACK_ROW_LENGTH_EXT                                0x0CF2
+#define GL_UNPACK_SKIP_ROWS_EXT                                 0x0CF3
+#define GL_UNPACK_SKIP_PIXELS_EXT                               0x0CF4
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /*------------------------------------------------------------------------*
</span><span class="lines">@@ -462,6 +650,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /*------------------------------------------------------------------------*
</span><ins>+ * FJ extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_FJ_shader_binary_GCCSO */
+#ifndef GL_FJ_shader_binary_GCCSO
+#define GL_GCCSO_SHADER_BINARY_F                                0x9260
+#endif
+
+/*------------------------------------------------------------------------*
</ins><span class="cx">  * IMG extension tokens
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="lines">@@ -489,6 +686,12 @@
</span><span class="cx"> #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_IMG_texture_compression_pvrtc2 */
+#ifndef GL_IMG_texture_compression_pvrtc2
+#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG                     0x9137
+#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG                     0x9138
+#endif
+
</ins><span class="cx"> /* GL_IMG_multisampled_render_to_texture */
</span><span class="cx"> #ifndef GL_IMG_multisampled_render_to_texture
</span><span class="cx"> #define GL_RENDERBUFFER_SAMPLES_IMG                             0x9133
</span><span class="lines">@@ -594,6 +797,9 @@
</span><span class="cx"> #define GL_MAX_COLOR_ATTACHMENTS_EXT                             0x8CDF
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_NV_draw_instanced */
+/* No new tokens introduced by this extension. */
+
</ins><span class="cx"> /* GL_NV_fbo_color_attachments */
</span><span class="cx"> #ifndef GL_NV_fbo_color_attachments
</span><span class="cx"> #define GL_MAX_COLOR_ATTACHMENTS_NV                             0x8CDF
</span><span class="lines">@@ -607,6 +813,29 @@
</span><span class="cx"> #define GL_FENCE_CONDITION_NV                                   0x84F4
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_NV_framebuffer_blit */
+#ifndef GL_NV_framebuffer_blit
+#define GL_READ_FRAMEBUFFER_NV                                  0x8CA8
+#define GL_DRAW_FRAMEBUFFER_NV                                  0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_NV                          0x8CA6 
+#define GL_READ_FRAMEBUFFER_BINDING_NV                          0x8CAA
+#endif
+
+/* GL_NV_framebuffer_multisample */
+#ifndef GL_NV_framebuffer_multisample
+#define GL_RENDERBUFFER_SAMPLES_NV                              0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV                0x8D56
+#define GL_MAX_SAMPLES_NV                                       0x8D57
+#endif
+
+/* GL_NV_generate_mipmap_sRGB */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_instanced_arrays */
+#ifndef GL_NV_instanced_arrays
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV                       0x88FE
+#endif
+
</ins><span class="cx"> /* GL_NV_read_buffer */
</span><span class="cx"> #ifndef GL_NV_read_buffer
</span><span class="cx"> #define GL_READ_BUFFER_NV                                       0x0C02
</span><span class="lines">@@ -624,6 +853,36 @@
</span><span class="cx"> /* GL_NV_read_stencil */
</span><span class="cx"> /* No new tokens introduced by this extension. */
</span><span class="cx"> 
</span><ins>+/* GL_NV_shadow_samplers_array */
+#ifndef GL_NV_shadow_samplers_array
+#define GL_SAMPLER_2D_ARRAY_SHADOW_NV                           0x8DC4
+#endif                                             
+                                                   
+/* GL_NV_shadow_samplers_cube */
+#ifndef GL_NV_shadow_samplers_cube                 
+#define GL_SAMPLER_CUBE_SHADOW_NV                               0x8DC5
+#endif
+
+/* GL_NV_sRGB_formats */
+#ifndef GL_NV_sRGB_formats
+#define GL_SLUMINANCE_NV                                        0x8C46
+#define GL_SLUMINANCE_ALPHA_NV                                  0x8C44
+#define GL_SRGB8_NV                                             0x8C41
+#define GL_SLUMINANCE8_NV                                       0x8C47
+#define GL_SLUMINANCE8_ALPHA8_NV                                0x8C45
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV                         0x8C4C
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV                   0x8C4D
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV                   0x8C4E
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV                   0x8C4F
+#define GL_ETC1_SRGB8_NV                                        0x88EE
+#endif
+
+/* GL_NV_texture_border_clamp */
+#ifndef GL_NV_texture_border_clamp
+#define GL_TEXTURE_BORDER_COLOR_NV                              0x1004
+#define GL_CLAMP_TO_BORDER_NV                                   0x812D
+#endif
+
</ins><span class="cx"> /* GL_NV_texture_compression_s3tc_update */
</span><span class="cx"> /* No new tokens introduced by this extension. */
</span><span class="cx"> 
</span><span class="lines">@@ -641,6 +900,14 @@
</span><span class="cx"> #define GL_ALPHA_TEST_REF_QCOM                                  0x0BC2
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_QCOM_binning_control */
+#ifndef GL_QCOM_binning_control
+#define GL_BINNING_CONTROL_HINT_QCOM                            0x8FB0
+#define GL_CPU_OPTIMIZED_QCOM                                   0x8FB1
+#define GL_GPU_OPTIMIZED_QCOM                                   0x8FB2
+#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM                    0x8FB3
+#endif
+
</ins><span class="cx"> /* GL_QCOM_driver_control */
</span><span class="cx"> /* No new tokens introduced by this extension. */
</span><span class="cx"> 
</span><span class="lines">@@ -811,6 +1078,11 @@
</span><span class="cx"> #define GL_OES_packed_depth_stencil 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_OES_required_internalformat */
+#ifndef GL_OES_required_internalformat
+#define GL_OES_required_internalformat 1
+#endif
+
</ins><span class="cx"> /* GL_OES_rgb8_rgba8 */
</span><span class="cx"> #ifndef GL_OES_rgb8_rgba8
</span><span class="cx"> #define GL_OES_rgb8_rgba8 1
</span><span class="lines">@@ -831,6 +1103,10 @@
</span><span class="cx"> #define GL_OES_stencil4 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef GL_OES_surfaceless_context
+#define GL_OES_surfaceless_context 1
+#endif
+
</ins><span class="cx"> /* GL_OES_texture_3D */
</span><span class="cx"> #ifndef GL_OES_texture_3D
</span><span class="cx"> #define GL_OES_texture_3D 1
</span><span class="lines">@@ -901,6 +1177,43 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /*------------------------------------------------------------------------*
</span><ins>+ * KHR extension functions
+ *------------------------------------------------------------------------*/
+
+#ifndef GL_KHR_debug
+#define GL_KHR_debug 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GL_APICALL void GL_APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GL_APICALL void GL_APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam);
+GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+GL_APICALL void GL_APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+GL_APICALL void GL_APIENTRY glPopDebugGroup (void);
+GL_APICALL void GL_APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glGetPointerv (GLenum pname, void **params);
+#endif 
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);
+typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);
+typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params);
+#endif
+
+#ifndef GL_KHR_texture_compression_astc_ldr
+#define GL_KHR_texture_compression_astc_ldr 1
+#endif
+
+
+/*------------------------------------------------------------------------*
</ins><span class="cx">  * AMD extension functions
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="lines">@@ -952,6 +1265,11 @@
</span><span class="cx">  * ANGLE extension functions
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+/* GL_ANGLE_depth_texture */
+#ifndef GL_ANGLE_depth_texture
+#define GL_ANGLE_depth_texture 1
+#endif
+
</ins><span class="cx"> /* GL_ANGLE_framebuffer_blit */
</span><span class="cx"> #ifndef GL_ANGLE_framebuffer_blit
</span><span class="cx"> #define GL_ANGLE_framebuffer_blit 1
</span><span class="lines">@@ -970,56 +1288,63 @@
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef GL_ANGLE_instanced_arrays 
+#define GL_ANGLE_instanced_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor);
+#endif
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
+#endif
+
</ins><span class="cx"> /* GL_ANGLE_pack_reverse_row_order */
</span><del>-#ifndef GL_ANGLE_pack_reverse_row_order
</del><ins>+#ifndef GL_ANGLE_pack_reverse_row_order 
</ins><span class="cx"> #define GL_ANGLE_pack_reverse_row_order 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_ANGLE_program_binary */
+#ifndef GL_ANGLE_program_binary
+#define GL_ANGLE_program_binary 1
+#endif
+
</ins><span class="cx"> /* GL_ANGLE_texture_compression_dxt3 */
</span><del>-#ifndef GL_ANGLE_texture_compression_dxt3
</del><ins>+#ifndef GL_ANGLE_texture_compression_dxt3 
</ins><span class="cx"> #define GL_ANGLE_texture_compression_dxt3 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /* GL_ANGLE_texture_compression_dxt5 */
</span><del>-#ifndef GL_ANGLE_texture_compression_dxt5
</del><ins>+#ifndef GL_ANGLE_texture_compression_dxt5 
</ins><span class="cx"> #define GL_ANGLE_texture_compression_dxt5 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-/* GL_ANGLE_translated_shader_source */
-#ifndef GL_ANGLE_translated_shader_source
-#define GL_ANGLE_translated_shader_source 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
-#endif
-typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
-#endif
-
</del><span class="cx"> /* GL_ANGLE_texture_usage */
</span><del>-#ifndef GL_ANGLE_texture_usage
</del><ins>+#ifndef GL_ANGLE_texture_usage 
</ins><span class="cx"> #define GL_ANGLE_texture_usage 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-/* GL_ANGLE_instanced_arrays */
-#ifndef GL_ANGLE_instanced_arrays
-#define GL_ANGLE_instanced_arrays 1
</del><ins>+#ifndef GL_ANGLE_translated_shader_source 
+#define GL_ANGLE_translated_shader_source 1
</ins><span class="cx"> #ifdef GL_GLEXT_PROTOTYPES
</span><del>-GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor);
-GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
</del><ins>+GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
</ins><span class="cx"> #endif
</span><del>-typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
-typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
</del><ins>+typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /*------------------------------------------------------------------------*
</span><span class="cx">  * APPLE extension functions
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-/* GL_APPLE_rgb_422 */
-#ifndef GL_APPLE_rgb_422
-#define GL_APPLE_rgb_422 1
</del><ins>+/* GL_APPLE_copy_texture_levels */
+#ifndef GL_APPLE_copy_texture_levels
+#define GL_APPLE_copy_texture_levels 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
</ins><span class="cx"> #endif
</span><ins>+typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
+#endif
</ins><span class="cx"> 
</span><span class="cx"> /* GL_APPLE_framebuffer_multisample */
</span><span class="cx"> #ifndef GL_APPLE_framebuffer_multisample
</span><span class="lines">@@ -1032,6 +1357,32 @@
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_APPLE_rgb_422 */
+#ifndef GL_APPLE_rgb_422
+#define GL_APPLE_rgb_422 1
+#endif
+
+/* GL_APPLE_sync */
+#ifndef GL_APPLE_sync
+#define GL_APPLE_sync 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags);
+GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync);
+GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync);
+GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params);
+GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif
+typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
+typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
+typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
+typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
+typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif
+
</ins><span class="cx"> /* GL_APPLE_texture_format_BGRA8888 */
</span><span class="cx"> #ifndef GL_APPLE_texture_format_BGRA8888
</span><span class="cx"> #define GL_APPLE_texture_format_BGRA8888 1
</span><span class="lines">@@ -1046,6 +1397,11 @@
</span><span class="cx">  * ARM extension functions
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+/* GL_ARM_mali_program_binary */
+#ifndef GL_ARM_mali_program_binary
+#define GL_ARM_mali_program_binary 1
+#endif
+
</ins><span class="cx"> /* GL_ARM_mali_shader_binary */
</span><span class="cx"> #ifndef GL_ARM_mali_shader_binary
</span><span class="cx"> #define GL_ARM_mali_shader_binary 1
</span><span class="lines">@@ -1103,6 +1459,17 @@
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_EXT_map_buffer_range */
+#ifndef GL_EXT_map_buffer_range
+#define GL_EXT_map_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+
</ins><span class="cx"> /* GL_EXT_multisampled_render_to_texture */
</span><span class="cx"> #ifndef GL_EXT_multisampled_render_to_texture
</span><span class="cx"> #define GL_EXT_multisampled_render_to_texture 1
</span><span class="lines">@@ -1114,10 +1481,23 @@
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_EXT_multiview_draw_buffers */
+#ifndef GL_EXT_multiview_draw_buffers
+#define GL_EXT_multiview_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index);
+GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices);
+GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data);
+#endif
+typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index);
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices);
+typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data);
+#endif
+
</ins><span class="cx"> #ifndef GL_EXT_multi_draw_arrays
</span><span class="cx"> #define GL_EXT_multi_draw_arrays 1
</span><span class="cx"> #ifdef GL_GLEXT_PROTOTYPES
</span><del>-GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
</del><ins>+GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei);
</ins><span class="cx"> GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
</span><span class="cx"> #endif /* GL_GLEXT_PROTOTYPES */
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
</span><span class="lines">@@ -1232,6 +1612,11 @@
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_EXT_shader_framebuffer_fetch */
+#ifndef GL_EXT_shader_framebuffer_fetch
+#define GL_EXT_shader_framebuffer_fetch 1
+#endif
+
</ins><span class="cx"> /* GL_EXT_shader_texture_lod */
</span><span class="cx"> #ifndef GL_EXT_shader_texture_lod
</span><span class="cx"> #define GL_EXT_shader_texture_lod 1
</span><span class="lines">@@ -1306,6 +1691,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /*------------------------------------------------------------------------*
</span><ins>+ * FJ extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_FJ_shader_binary_GCCSO */
+#ifndef GL_FJ_shader_binary_GCCSO
+#define GL_FJ_shader_binary_GCCSO 1
+#endif
+
+/*------------------------------------------------------------------------*
</ins><span class="cx">  * IMG extension functions
</span><span class="cx">  *------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="lines">@@ -1329,6 +1723,11 @@
</span><span class="cx"> #define GL_IMG_texture_compression_pvrtc 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_IMG_texture_compression_pvrtc2 */
+#ifndef GL_IMG_texture_compression_pvrtc2
+#define GL_IMG_texture_compression_pvrtc2 1
+#endif
+
</ins><span class="cx"> /* GL_IMG_multisampled_render_to_texture */
</span><span class="cx"> #ifndef GL_IMG_multisampled_render_to_texture
</span><span class="cx"> #define GL_IMG_multisampled_render_to_texture 1
</span><span class="lines">@@ -1336,8 +1735,8 @@
</span><span class="cx"> GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
</span><span class="cx"> GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
</span><span class="cx"> #endif
</span><del>-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
</del><ins>+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /*------------------------------------------------------------------------*
</span><span class="lines">@@ -1369,6 +1768,7 @@
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_EXT_draw_buffers */
</ins><span class="cx"> #ifndef GL_EXT_draw_buffers
</span><span class="cx"> #define GL_EXT_draw_buffers 1
</span><span class="cx"> #ifdef GL_GLEXT_PROTOTYPES
</span><span class="lines">@@ -1377,6 +1777,17 @@
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_NV_draw_instanced */
+#ifndef GL_NV_draw_instanced
+#define GL_NV_draw_instanced 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif
+typedef void (GL_APIENTRYP PFNDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif
+
</ins><span class="cx"> /* GL_NV_fbo_color_attachments */
</span><span class="cx"> #ifndef GL_NV_fbo_color_attachments
</span><span class="cx"> #define GL_NV_fbo_color_attachments 1
</span><span class="lines">@@ -1403,6 +1814,38 @@
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_NV_framebuffer_blit */
+#ifndef GL_NV_framebuffer_blit
+#define GL_NV_framebuffer_blit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBlitFramebufferNV (int srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+typedef void (GL_APIENTRYP PFNBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+
+/* GL_NV_framebuffer_multisample */
+#ifndef GL_NV_framebuffer_multisample
+#define GL_NV_framebuffer_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+typedef void (GL_APIENTRYP PFNRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+
+/* GL_NV_generate_mipmap_sRGB */
+#ifndef GL_NV_generate_mipmap_sRGB
+#define GL_NV_generate_mipmap_sRGB 1
+#endif
+
+/* GL_NV_instanced_arrays */
+#ifndef GL_NV_instanced_arrays
+#define GL_NV_instanced_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor);
+#endif
+typedef void (GL_APIENTRYP PFNVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor);
+#endif
+
</ins><span class="cx"> /* GL_NV_read_buffer */
</span><span class="cx"> #ifndef GL_NV_read_buffer
</span><span class="cx"> #define GL_NV_read_buffer 1
</span><span class="lines">@@ -1432,6 +1875,26 @@
</span><span class="cx"> #define GL_NV_read_stencil 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_NV_shadow_samplers_array */
+#ifndef GL_NV_shadow_samplers_array
+#define GL_NV_shadow_samplers_array 1
+#endif
+
+/* GL_NV_shadow_samplers_cube */
+#ifndef GL_NV_shadow_samplers_cube
+#define GL_NV_shadow_samplers_cube 1
+#endif
+
+/* GL_NV_sRGB_formats */
+#ifndef GL_NV_sRGB_formats
+#define GL_NV_sRGB_formats 1
+#endif
+
+/* GL_NV_texture_border_clamp */
+#ifndef GL_NV_texture_border_clamp
+#define GL_NV_texture_border_clamp 1
+#endif
+
</ins><span class="cx"> /* GL_NV_texture_compression_s3tc_update */
</span><span class="cx"> #ifndef GL_NV_texture_compression_s3tc_update
</span><span class="cx"> #define GL_NV_texture_compression_s3tc_update 1
</span><span class="lines">@@ -1455,6 +1918,11 @@
</span><span class="cx"> typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* GL_QCOM_binning_control */
+#ifndef GL_QCOM_binning_control
+#define GL_QCOM_binning_control 1
+#endif
+
</ins><span class="cx"> /* GL_QCOM_driver_control */
</span><span class="cx"> #ifndef GL_QCOM_driver_control
</span><span class="cx"> #define GL_QCOM_driver_control 1
</span><span class="lines">@@ -1538,11 +2006,6 @@
</span><span class="cx"> #define GL_VIV_shader_binary 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-/* GL_ANGLE_program_binary */
-#ifndef GL_ANGLE_program_binary
-#define GL_ANGLE_program_binary 1
-#endif
-
</del><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEincludeGLES3gl3h"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,1061 @@
</span><ins>+#ifndef __gl3_h_
+#define __gl3_h_
+
+/* 
+ * gl3.h last updated on $Date: 2013-02-12 14:37:24 -0800 (Tue, 12 Feb 2013) $
+ */
+
+#include &lt;GLES3/gl3platform.h&gt;
+
+#ifdef __cplusplus
+extern &quot;C&quot; {
+#endif
+
+/*
+** Copyright (c) 2007-2013 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** &quot;Materials&quot;), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/*-------------------------------------------------------------------------
+ * Data type definitions
+ *-----------------------------------------------------------------------*/
+
+/* OpenGL ES 2.0 */
+
+typedef void             GLvoid;
+typedef char             GLchar;
+typedef unsigned int     GLenum;
+typedef unsigned char    GLboolean;
+typedef unsigned int     GLbitfield;
+typedef khronos_int8_t   GLbyte;
+typedef short            GLshort;
+typedef int              GLint;
+typedef int              GLsizei;
+typedef khronos_uint8_t  GLubyte;
+typedef unsigned short   GLushort;
+typedef unsigned int     GLuint;
+typedef khronos_float_t  GLfloat;
+typedef khronos_float_t  GLclampf;
+typedef khronos_int32_t  GLfixed;
+typedef khronos_intptr_t GLintptr;
+typedef khronos_ssize_t  GLsizeiptr;
+
+/* OpenGL ES 3.0 */
+
+typedef unsigned short   GLhalf;
+typedef khronos_int64_t  GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef struct __GLsync *GLsync;
+
+/*-------------------------------------------------------------------------
+ * Token definitions
+ *-----------------------------------------------------------------------*/
+
+/* OpenGL ES core versions */
+#define GL_ES_VERSION_3_0                                1
+#define GL_ES_VERSION_2_0                                1
+
+/* OpenGL ES 2.0 */
+
+/* ClearBufferMask */
+#define GL_DEPTH_BUFFER_BIT                              0x00000100
+#define GL_STENCIL_BUFFER_BIT                            0x00000400
+#define GL_COLOR_BUFFER_BIT                              0x00004000
+
+/* Boolean */
+#define GL_FALSE                                         0
+#define GL_TRUE                                          1
+
+/* BeginMode */
+#define GL_POINTS                                        0x0000
+#define GL_LINES                                         0x0001
+#define GL_LINE_LOOP                                     0x0002
+#define GL_LINE_STRIP                                    0x0003
+#define GL_TRIANGLES                                     0x0004
+#define GL_TRIANGLE_STRIP                                0x0005
+#define GL_TRIANGLE_FAN                                  0x0006
+
+/* BlendingFactorDest */
+#define GL_ZERO                                          0
+#define GL_ONE                                           1
+#define GL_SRC_COLOR                                     0x0300
+#define GL_ONE_MINUS_SRC_COLOR                           0x0301
+#define GL_SRC_ALPHA                                     0x0302
+#define GL_ONE_MINUS_SRC_ALPHA                           0x0303
+#define GL_DST_ALPHA                                     0x0304
+#define GL_ONE_MINUS_DST_ALPHA                           0x0305
+
+/* BlendingFactorSrc */
+/*      GL_ZERO */
+/*      GL_ONE */
+#define GL_DST_COLOR                                     0x0306
+#define GL_ONE_MINUS_DST_COLOR                           0x0307
+#define GL_SRC_ALPHA_SATURATE                            0x0308
+/*      GL_SRC_ALPHA */
+/*      GL_ONE_MINUS_SRC_ALPHA */
+/*      GL_DST_ALPHA */
+/*      GL_ONE_MINUS_DST_ALPHA */
+
+/* BlendEquationSeparate */
+#define GL_FUNC_ADD                                      0x8006
+#define GL_BLEND_EQUATION                                0x8009
+#define GL_BLEND_EQUATION_RGB                            0x8009    /* same as BLEND_EQUATION */
+#define GL_BLEND_EQUATION_ALPHA                          0x883D
+
+/* BlendSubtract */
+#define GL_FUNC_SUBTRACT                                 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT                         0x800B
+
+/* Separate Blend Functions */
+#define GL_BLEND_DST_RGB                                 0x80C8
+#define GL_BLEND_SRC_RGB                                 0x80C9
+#define GL_BLEND_DST_ALPHA                               0x80CA
+#define GL_BLEND_SRC_ALPHA                               0x80CB
+#define GL_CONSTANT_COLOR                                0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR                      0x8002
+#define GL_CONSTANT_ALPHA                                0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA                      0x8004
+#define GL_BLEND_COLOR                                   0x8005
+
+/* Buffer Objects */
+#define GL_ARRAY_BUFFER                                  0x8892
+#define GL_ELEMENT_ARRAY_BUFFER                          0x8893
+#define GL_ARRAY_BUFFER_BINDING                          0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING                  0x8895
+
+#define GL_STREAM_DRAW                                   0x88E0
+#define GL_STATIC_DRAW                                   0x88E4
+#define GL_DYNAMIC_DRAW                                  0x88E8
+
+#define GL_BUFFER_SIZE                                   0x8764
+#define GL_BUFFER_USAGE                                  0x8765
+
+#define GL_CURRENT_VERTEX_ATTRIB                         0x8626
+
+/* CullFaceMode */
+#define GL_FRONT                                         0x0404
+#define GL_BACK                                          0x0405
+#define GL_FRONT_AND_BACK                                0x0408
+
+/* DepthFunction */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* EnableCap */
+#define GL_TEXTURE_2D                                    0x0DE1
+#define GL_CULL_FACE                                     0x0B44
+#define GL_BLEND                                         0x0BE2
+#define GL_DITHER                                        0x0BD0
+#define GL_STENCIL_TEST                                  0x0B90
+#define GL_DEPTH_TEST                                    0x0B71
+#define GL_SCISSOR_TEST                                  0x0C11
+#define GL_POLYGON_OFFSET_FILL                           0x8037
+#define GL_SAMPLE_ALPHA_TO_COVERAGE                      0x809E
+#define GL_SAMPLE_COVERAGE                               0x80A0
+
+/* ErrorCode */
+#define GL_NO_ERROR                                      0
+#define GL_INVALID_ENUM                                  0x0500
+#define GL_INVALID_VALUE                                 0x0501
+#define GL_INVALID_OPERATION                             0x0502
+#define GL_OUT_OF_MEMORY                                 0x0505
+
+/* FrontFaceDirection */
+#define GL_CW                                            0x0900
+#define GL_CCW                                           0x0901
+
+/* GetPName */
+#define GL_LINE_WIDTH                                    0x0B21
+#define GL_ALIASED_POINT_SIZE_RANGE                      0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE                      0x846E
+#define GL_CULL_FACE_MODE                                0x0B45
+#define GL_FRONT_FACE                                    0x0B46
+#define GL_DEPTH_RANGE                                   0x0B70
+#define GL_DEPTH_WRITEMASK                               0x0B72
+#define GL_DEPTH_CLEAR_VALUE                             0x0B73
+#define GL_DEPTH_FUNC                                    0x0B74
+#define GL_STENCIL_CLEAR_VALUE                           0x0B91
+#define GL_STENCIL_FUNC                                  0x0B92
+#define GL_STENCIL_FAIL                                  0x0B94
+#define GL_STENCIL_PASS_DEPTH_FAIL                       0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS                       0x0B96
+#define GL_STENCIL_REF                                   0x0B97
+#define GL_STENCIL_VALUE_MASK                            0x0B93
+#define GL_STENCIL_WRITEMASK                             0x0B98
+#define GL_STENCIL_BACK_FUNC                             0x8800
+#define GL_STENCIL_BACK_FAIL                             0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL                  0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS                  0x8803
+#define GL_STENCIL_BACK_REF                              0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK                       0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK                        0x8CA5
+#define GL_VIEWPORT                                      0x0BA2
+#define GL_SCISSOR_BOX                                   0x0C10
+/*      GL_SCISSOR_TEST */
+#define GL_COLOR_CLEAR_VALUE                             0x0C22
+#define GL_COLOR_WRITEMASK                               0x0C23
+#define GL_UNPACK_ALIGNMENT                              0x0CF5
+#define GL_PACK_ALIGNMENT                                0x0D05
+#define GL_MAX_TEXTURE_SIZE                              0x0D33
+#define GL_MAX_VIEWPORT_DIMS                             0x0D3A
+#define GL_SUBPIXEL_BITS                                 0x0D50
+#define GL_RED_BITS                                      0x0D52
+#define GL_GREEN_BITS                                    0x0D53
+#define GL_BLUE_BITS                                     0x0D54
+#define GL_ALPHA_BITS                                    0x0D55
+#define GL_DEPTH_BITS                                    0x0D56
+#define GL_STENCIL_BITS                                  0x0D57
+#define GL_POLYGON_OFFSET_UNITS                          0x2A00
+/*      GL_POLYGON_OFFSET_FILL */
+#define GL_POLYGON_OFFSET_FACTOR                         0x8038
+#define GL_TEXTURE_BINDING_2D                            0x8069
+#define GL_SAMPLE_BUFFERS                                0x80A8
+#define GL_SAMPLES                                       0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE                         0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT                        0x80AB
+
+/* GetTextureParameter */
+/*      GL_TEXTURE_MAG_FILTER */
+/*      GL_TEXTURE_MIN_FILTER */
+/*      GL_TEXTURE_WRAP_S */
+/*      GL_TEXTURE_WRAP_T */
+
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS                0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS                    0x86A3
+
+/* HintMode */
+#define GL_DONT_CARE                                     0x1100
+#define GL_FASTEST                                       0x1101
+#define GL_NICEST                                        0x1102
+
+/* HintTarget */
+#define GL_GENERATE_MIPMAP_HINT                          0x8192
+
+/* DataType */
+#define GL_BYTE                                          0x1400
+#define GL_UNSIGNED_BYTE                                 0x1401
+#define GL_SHORT                                         0x1402
+#define GL_UNSIGNED_SHORT                                0x1403
+#define GL_INT                                           0x1404
+#define GL_UNSIGNED_INT                                  0x1405
+#define GL_FLOAT                                         0x1406
+#define GL_FIXED                                         0x140C
+
+/* PixelFormat */
+#define GL_DEPTH_COMPONENT                               0x1902
+#define GL_ALPHA                                         0x1906
+#define GL_RGB                                           0x1907
+#define GL_RGBA                                          0x1908
+#define GL_LUMINANCE                                     0x1909
+#define GL_LUMINANCE_ALPHA                               0x190A
+
+/* PixelType */
+/*      GL_UNSIGNED_BYTE */
+#define GL_UNSIGNED_SHORT_4_4_4_4                        0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1                        0x8034
+#define GL_UNSIGNED_SHORT_5_6_5                          0x8363
+
+/* Shaders */
+#define GL_FRAGMENT_SHADER                               0x8B30
+#define GL_VERTEX_SHADER                                 0x8B31
+#define GL_MAX_VERTEX_ATTRIBS                            0x8869
+#define GL_MAX_VERTEX_UNIFORM_VECTORS                    0x8DFB
+#define GL_MAX_VARYING_VECTORS                           0x8DFC
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS              0x8B4D
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS                0x8B4C
+#define GL_MAX_TEXTURE_IMAGE_UNITS                       0x8872
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS                  0x8DFD
+#define GL_SHADER_TYPE                                   0x8B4F
+#define GL_DELETE_STATUS                                 0x8B80
+#define GL_LINK_STATUS                                   0x8B82
+#define GL_VALIDATE_STATUS                               0x8B83
+#define GL_ATTACHED_SHADERS                              0x8B85
+#define GL_ACTIVE_UNIFORMS                               0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH                     0x8B87
+#define GL_ACTIVE_ATTRIBUTES                             0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH                   0x8B8A
+#define GL_SHADING_LANGUAGE_VERSION                      0x8B8C
+#define GL_CURRENT_PROGRAM                               0x8B8D
+
+/* StencilFunction */
+#define GL_NEVER                                         0x0200
+#define GL_LESS                                          0x0201
+#define GL_EQUAL                                         0x0202
+#define GL_LEQUAL                                        0x0203
+#define GL_GREATER                                       0x0204
+#define GL_NOTEQUAL                                      0x0205
+#define GL_GEQUAL                                        0x0206
+#define GL_ALWAYS                                        0x0207
+
+/* StencilOp */
+/*      GL_ZERO */
+#define GL_KEEP                                          0x1E00
+#define GL_REPLACE                                       0x1E01
+#define GL_INCR                                          0x1E02
+#define GL_DECR                                          0x1E03
+#define GL_INVERT                                        0x150A
+#define GL_INCR_WRAP                                     0x8507
+#define GL_DECR_WRAP                                     0x8508
+
+/* StringName */
+#define GL_VENDOR                                        0x1F00
+#define GL_RENDERER                                      0x1F01
+#define GL_VERSION                                       0x1F02
+#define GL_EXTENSIONS                                    0x1F03
+
+/* TextureMagFilter */
+#define GL_NEAREST                                       0x2600
+#define GL_LINEAR                                        0x2601
+
+/* TextureMinFilter */
+/*      GL_NEAREST */
+/*      GL_LINEAR */
+#define GL_NEAREST_MIPMAP_NEAREST                        0x2700
+#define GL_LINEAR_MIPMAP_NEAREST                         0x2701
+#define GL_NEAREST_MIPMAP_LINEAR                         0x2702
+#define GL_LINEAR_MIPMAP_LINEAR                          0x2703
+
+/* TextureParameterName */
+#define GL_TEXTURE_MAG_FILTER                            0x2800
+#define GL_TEXTURE_MIN_FILTER                            0x2801
+#define GL_TEXTURE_WRAP_S                                0x2802
+#define GL_TEXTURE_WRAP_T                                0x2803
+
+/* TextureTarget */
+/*      GL_TEXTURE_2D */
+#define GL_TEXTURE                                       0x1702
+
+#define GL_TEXTURE_CUBE_MAP                              0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP                      0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X                   0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X                   0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y                   0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y                   0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z                   0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z                   0x851A
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE                     0x851C
+
+/* TextureUnit */
+#define GL_TEXTURE0                                      0x84C0
+#define GL_TEXTURE1                                      0x84C1
+#define GL_TEXTURE2                                      0x84C2
+#define GL_TEXTURE3                                      0x84C3
+#define GL_TEXTURE4                                      0x84C4
+#define GL_TEXTURE5                                      0x84C5
+#define GL_TEXTURE6                                      0x84C6
+#define GL_TEXTURE7                                      0x84C7
+#define GL_TEXTURE8                                      0x84C8
+#define GL_TEXTURE9                                      0x84C9
+#define GL_TEXTURE10                                     0x84CA
+#define GL_TEXTURE11                                     0x84CB
+#define GL_TEXTURE12                                     0x84CC
+#define GL_TEXTURE13                                     0x84CD
+#define GL_TEXTURE14                                     0x84CE
+#define GL_TEXTURE15                                     0x84CF
+#define GL_TEXTURE16                                     0x84D0
+#define GL_TEXTURE17                                     0x84D1
+#define GL_TEXTURE18                                     0x84D2
+#define GL_TEXTURE19                                     0x84D3
+#define GL_TEXTURE20                                     0x84D4
+#define GL_TEXTURE21                                     0x84D5
+#define GL_TEXTURE22                                     0x84D6
+#define GL_TEXTURE23                                     0x84D7
+#define GL_TEXTURE24                                     0x84D8
+#define GL_TEXTURE25                                     0x84D9
+#define GL_TEXTURE26                                     0x84DA
+#define GL_TEXTURE27                                     0x84DB
+#define GL_TEXTURE28                                     0x84DC
+#define GL_TEXTURE29                                     0x84DD
+#define GL_TEXTURE30                                     0x84DE
+#define GL_TEXTURE31                                     0x84DF
+#define GL_ACTIVE_TEXTURE                                0x84E0
+
+/* TextureWrapMode */
+#define GL_REPEAT                                        0x2901
+#define GL_CLAMP_TO_EDGE                                 0x812F
+#define GL_MIRRORED_REPEAT                               0x8370
+
+/* Uniform Types */
+#define GL_FLOAT_VEC2                                    0x8B50
+#define GL_FLOAT_VEC3                                    0x8B51
+#define GL_FLOAT_VEC4                                    0x8B52
+#define GL_INT_VEC2                                      0x8B53
+#define GL_INT_VEC3                                      0x8B54
+#define GL_INT_VEC4                                      0x8B55
+#define GL_BOOL                                          0x8B56
+#define GL_BOOL_VEC2                                     0x8B57
+#define GL_BOOL_VEC3                                     0x8B58
+#define GL_BOOL_VEC4                                     0x8B59
+#define GL_FLOAT_MAT2                                    0x8B5A
+#define GL_FLOAT_MAT3                                    0x8B5B
+#define GL_FLOAT_MAT4                                    0x8B5C
+#define GL_SAMPLER_2D                                    0x8B5E
+#define GL_SAMPLER_CUBE                                  0x8B60
+
+/* Vertex Arrays */
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED                   0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE                      0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE                    0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE                      0x8625
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED                0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER                   0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING            0x889F
+
+/* Read Format */
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE                0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT              0x8B9B
+
+/* Shader Source */
+#define GL_COMPILE_STATUS                                0x8B81
+#define GL_INFO_LOG_LENGTH                               0x8B84
+#define GL_SHADER_SOURCE_LENGTH                          0x8B88
+#define GL_SHADER_COMPILER                               0x8DFA
+
+/* Shader Binary */
+#define GL_SHADER_BINARY_FORMATS                         0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS                     0x8DF9
+
+/* Shader Precision-Specified Types */
+#define GL_LOW_FLOAT                                     0x8DF0
+#define GL_MEDIUM_FLOAT                                  0x8DF1
+#define GL_HIGH_FLOAT                                    0x8DF2
+#define GL_LOW_INT                                       0x8DF3
+#define GL_MEDIUM_INT                                    0x8DF4
+#define GL_HIGH_INT                                      0x8DF5
+
+/* Framebuffer Object. */
+#define GL_FRAMEBUFFER                                   0x8D40
+#define GL_RENDERBUFFER                                  0x8D41
+
+#define GL_RGBA4                                         0x8056
+#define GL_RGB5_A1                                       0x8057
+#define GL_RGB565                                        0x8D62
+#define GL_DEPTH_COMPONENT16                             0x81A5
+#define GL_STENCIL_INDEX8                                0x8D48
+
+#define GL_RENDERBUFFER_WIDTH                            0x8D42
+#define GL_RENDERBUFFER_HEIGHT                           0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT                  0x8D44
+#define GL_RENDERBUFFER_RED_SIZE                         0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE                       0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE                        0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE                       0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE                       0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE                     0x8D55
+
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE            0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME            0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL          0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE  0x8CD3
+
+#define GL_COLOR_ATTACHMENT0                             0x8CE0
+#define GL_DEPTH_ATTACHMENT                              0x8D00
+#define GL_STENCIL_ATTACHMENT                            0x8D20
+
+#define GL_NONE                                          0
+
+#define GL_FRAMEBUFFER_COMPLETE                          0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT             0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT     0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS             0x8CD9
+#define GL_FRAMEBUFFER_UNSUPPORTED                       0x8CDD
+
+#define GL_FRAMEBUFFER_BINDING                           0x8CA6
+#define GL_RENDERBUFFER_BINDING                          0x8CA7
+#define GL_MAX_RENDERBUFFER_SIZE                         0x84E8
+
+#define GL_INVALID_FRAMEBUFFER_OPERATION                 0x0506
+
+/* OpenGL ES 3.0 */
+
+#define GL_READ_BUFFER                                   0x0C02
+#define GL_UNPACK_ROW_LENGTH                             0x0CF2
+#define GL_UNPACK_SKIP_ROWS                              0x0CF3
+#define GL_UNPACK_SKIP_PIXELS                            0x0CF4
+#define GL_PACK_ROW_LENGTH                               0x0D02
+#define GL_PACK_SKIP_ROWS                                0x0D03
+#define GL_PACK_SKIP_PIXELS                              0x0D04
+#define GL_COLOR                                         0x1800
+#define GL_DEPTH                                         0x1801
+#define GL_STENCIL                                       0x1802
+#define GL_RED                                           0x1903
+#define GL_RGB8                                          0x8051
+#define GL_RGBA8                                         0x8058
+#define GL_RGB10_A2                                      0x8059
+#define GL_TEXTURE_BINDING_3D                            0x806A
+#define GL_UNPACK_SKIP_IMAGES                            0x806D
+#define GL_UNPACK_IMAGE_HEIGHT                           0x806E
+#define GL_TEXTURE_3D                                    0x806F
+#define GL_TEXTURE_WRAP_R                                0x8072
+#define GL_MAX_3D_TEXTURE_SIZE                           0x8073
+#define GL_UNSIGNED_INT_2_10_10_10_REV                   0x8368
+#define GL_MAX_ELEMENTS_VERTICES                         0x80E8
+#define GL_MAX_ELEMENTS_INDICES                          0x80E9
+#define GL_TEXTURE_MIN_LOD                               0x813A
+#define GL_TEXTURE_MAX_LOD                               0x813B
+#define GL_TEXTURE_BASE_LEVEL                            0x813C
+#define GL_TEXTURE_MAX_LEVEL                             0x813D
+#define GL_MIN                                           0x8007
+#define GL_MAX                                           0x8008
+#define GL_DEPTH_COMPONENT24                             0x81A6
+#define GL_MAX_TEXTURE_LOD_BIAS                          0x84FD
+#define GL_TEXTURE_COMPARE_MODE                          0x884C
+#define GL_TEXTURE_COMPARE_FUNC                          0x884D
+#define GL_CURRENT_QUERY                                 0x8865
+#define GL_QUERY_RESULT                                  0x8866
+#define GL_QUERY_RESULT_AVAILABLE                        0x8867
+#define GL_BUFFER_MAPPED                                 0x88BC
+#define GL_BUFFER_MAP_POINTER                            0x88BD
+#define GL_STREAM_READ                                   0x88E1
+#define GL_STREAM_COPY                                   0x88E2
+#define GL_STATIC_READ                                   0x88E5
+#define GL_STATIC_COPY                                   0x88E6
+#define GL_DYNAMIC_READ                                  0x88E9
+#define GL_DYNAMIC_COPY                                  0x88EA
+#define GL_MAX_DRAW_BUFFERS                              0x8824
+#define GL_DRAW_BUFFER0                                  0x8825
+#define GL_DRAW_BUFFER1                                  0x8826
+#define GL_DRAW_BUFFER2                                  0x8827
+#define GL_DRAW_BUFFER3                                  0x8828
+#define GL_DRAW_BUFFER4                                  0x8829
+#define GL_DRAW_BUFFER5                                  0x882A
+#define GL_DRAW_BUFFER6                                  0x882B
+#define GL_DRAW_BUFFER7                                  0x882C
+#define GL_DRAW_BUFFER8                                  0x882D
+#define GL_DRAW_BUFFER9                                  0x882E
+#define GL_DRAW_BUFFER10                                 0x882F
+#define GL_DRAW_BUFFER11                                 0x8830
+#define GL_DRAW_BUFFER12                                 0x8831
+#define GL_DRAW_BUFFER13                                 0x8832
+#define GL_DRAW_BUFFER14                                 0x8833
+#define GL_DRAW_BUFFER15                                 0x8834
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS               0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS                 0x8B4A
+#define GL_SAMPLER_3D                                    0x8B5F
+#define GL_SAMPLER_2D_SHADOW                             0x8B62
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT               0x8B8B
+#define GL_PIXEL_PACK_BUFFER                             0x88EB
+#define GL_PIXEL_UNPACK_BUFFER                           0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING                     0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING                   0x88EF
+#define GL_FLOAT_MAT2x3                                  0x8B65
+#define GL_FLOAT_MAT2x4                                  0x8B66
+#define GL_FLOAT_MAT3x2                                  0x8B67
+#define GL_FLOAT_MAT3x4                                  0x8B68
+#define GL_FLOAT_MAT4x2                                  0x8B69
+#define GL_FLOAT_MAT4x3                                  0x8B6A
+#define GL_SRGB                                          0x8C40
+#define GL_SRGB8                                         0x8C41
+#define GL_SRGB8_ALPHA8                                  0x8C43
+#define GL_COMPARE_REF_TO_TEXTURE                        0x884E
+#define GL_MAJOR_VERSION                                 0x821B
+#define GL_MINOR_VERSION                                 0x821C
+#define GL_NUM_EXTENSIONS                                0x821D
+#define GL_RGBA32F                                       0x8814
+#define GL_RGB32F                                        0x8815
+#define GL_RGBA16F                                       0x881A
+#define GL_RGB16F                                        0x881B
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER                   0x88FD
+#define GL_MAX_ARRAY_TEXTURE_LAYERS                      0x88FF
+#define GL_MIN_PROGRAM_TEXEL_OFFSET                      0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET                      0x8905
+#define GL_MAX_VARYING_COMPONENTS                        0x8B4B
+#define GL_TEXTURE_2D_ARRAY                              0x8C1A
+#define GL_TEXTURE_BINDING_2D_ARRAY                      0x8C1D
+#define GL_R11F_G11F_B10F                                0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV                  0x8C3B
+#define GL_RGB9_E5                                       0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV                      0x8C3E
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH         0x8C76
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE                0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS    0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS                   0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START               0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE                0x8C85
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN         0x8C88
+#define GL_RASTERIZER_DISCARD                            0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS       0x8C8B
+#define GL_INTERLEAVED_ATTRIBS                           0x8C8C
+#define GL_SEPARATE_ATTRIBS                              0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER                     0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING             0x8C8F
+#define GL_RGBA32UI                                      0x8D70
+#define GL_RGB32UI                                       0x8D71
+#define GL_RGBA16UI                                      0x8D76
+#define GL_RGB16UI                                       0x8D77
+#define GL_RGBA8UI                                       0x8D7C
+#define GL_RGB8UI                                        0x8D7D
+#define GL_RGBA32I                                       0x8D82
+#define GL_RGB32I                                        0x8D83
+#define GL_RGBA16I                                       0x8D88
+#define GL_RGB16I                                        0x8D89
+#define GL_RGBA8I                                        0x8D8E
+#define GL_RGB8I                                         0x8D8F
+#define GL_RED_INTEGER                                   0x8D94
+#define GL_RGB_INTEGER                                   0x8D98
+#define GL_RGBA_INTEGER                                  0x8D99
+#define GL_SAMPLER_2D_ARRAY                              0x8DC1
+#define GL_SAMPLER_2D_ARRAY_SHADOW                       0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW                           0x8DC5
+#define GL_UNSIGNED_INT_VEC2                             0x8DC6
+#define GL_UNSIGNED_INT_VEC3                             0x8DC7
+#define GL_UNSIGNED_INT_VEC4                             0x8DC8
+#define GL_INT_SAMPLER_2D                                0x8DCA
+#define GL_INT_SAMPLER_3D                                0x8DCB
+#define GL_INT_SAMPLER_CUBE                              0x8DCC
+#define GL_INT_SAMPLER_2D_ARRAY                          0x8DCF
+#define GL_UNSIGNED_INT_SAMPLER_2D                       0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D                       0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE                     0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY                 0x8DD7
+#define GL_BUFFER_ACCESS_FLAGS                           0x911F
+#define GL_BUFFER_MAP_LENGTH                             0x9120
+#define GL_BUFFER_MAP_OFFSET                             0x9121
+#define GL_DEPTH_COMPONENT32F                            0x8CAC
+#define GL_DEPTH32F_STENCIL8                             0x8CAD
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV                0x8DAD
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING         0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE         0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE               0x8212
+#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE             0x8213
+#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE              0x8214
+#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE             0x8215
+#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE             0x8216
+#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE           0x8217
+#define GL_FRAMEBUFFER_DEFAULT                           0x8218
+#define GL_FRAMEBUFFER_UNDEFINED                         0x8219
+#define GL_DEPTH_STENCIL_ATTACHMENT                      0x821A
+#define GL_DEPTH_STENCIL                                 0x84F9
+#define GL_UNSIGNED_INT_24_8                             0x84FA
+#define GL_DEPTH24_STENCIL8                              0x88F0
+#define GL_UNSIGNED_NORMALIZED                           0x8C17
+#define GL_DRAW_FRAMEBUFFER_BINDING                      GL_FRAMEBUFFER_BINDING
+#define GL_READ_FRAMEBUFFER                              0x8CA8
+#define GL_DRAW_FRAMEBUFFER                              0x8CA9
+#define GL_READ_FRAMEBUFFER_BINDING                      0x8CAA
+#define GL_RENDERBUFFER_SAMPLES                          0x8CAB
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER          0x8CD4
+#define GL_MAX_COLOR_ATTACHMENTS                         0x8CDF
+#define GL_COLOR_ATTACHMENT1                             0x8CE1
+#define GL_COLOR_ATTACHMENT2                             0x8CE2
+#define GL_COLOR_ATTACHMENT3                             0x8CE3
+#define GL_COLOR_ATTACHMENT4                             0x8CE4
+#define GL_COLOR_ATTACHMENT5                             0x8CE5
+#define GL_COLOR_ATTACHMENT6                             0x8CE6
+#define GL_COLOR_ATTACHMENT7                             0x8CE7
+#define GL_COLOR_ATTACHMENT8                             0x8CE8
+#define GL_COLOR_ATTACHMENT9                             0x8CE9
+#define GL_COLOR_ATTACHMENT10                            0x8CEA
+#define GL_COLOR_ATTACHMENT11                            0x8CEB
+#define GL_COLOR_ATTACHMENT12                            0x8CEC
+#define GL_COLOR_ATTACHMENT13                            0x8CED
+#define GL_COLOR_ATTACHMENT14                            0x8CEE
+#define GL_COLOR_ATTACHMENT15                            0x8CEF
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE            0x8D56
+#define GL_MAX_SAMPLES                                   0x8D57
+#define GL_HALF_FLOAT                                    0x140B
+#define GL_MAP_READ_BIT                                  0x0001
+#define GL_MAP_WRITE_BIT                                 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT                      0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT                     0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT                        0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT                        0x0020
+#define GL_RG                                            0x8227
+#define GL_RG_INTEGER                                    0x8228
+#define GL_R8                                            0x8229
+#define GL_RG8                                           0x822B
+#define GL_R16F                                          0x822D
+#define GL_R32F                                          0x822E
+#define GL_RG16F                                         0x822F
+#define GL_RG32F                                         0x8230
+#define GL_R8I                                           0x8231
+#define GL_R8UI                                          0x8232
+#define GL_R16I                                          0x8233
+#define GL_R16UI                                         0x8234
+#define GL_R32I                                          0x8235
+#define GL_R32UI                                         0x8236
+#define GL_RG8I                                          0x8237
+#define GL_RG8UI                                         0x8238
+#define GL_RG16I                                         0x8239
+#define GL_RG16UI                                        0x823A
+#define GL_RG32I                                         0x823B
+#define GL_RG32UI                                        0x823C
+#define GL_VERTEX_ARRAY_BINDING                          0x85B5
+#define GL_R8_SNORM                                      0x8F94
+#define GL_RG8_SNORM                                     0x8F95
+#define GL_RGB8_SNORM                                    0x8F96
+#define GL_RGBA8_SNORM                                   0x8F97
+#define GL_SIGNED_NORMALIZED                             0x8F9C
+#define GL_PRIMITIVE_RESTART_FIXED_INDEX                 0x8D69
+#define GL_COPY_READ_BUFFER                              0x8F36
+#define GL_COPY_WRITE_BUFFER                             0x8F37
+#define GL_COPY_READ_BUFFER_BINDING                      GL_COPY_READ_BUFFER
+#define GL_COPY_WRITE_BUFFER_BINDING                     GL_COPY_WRITE_BUFFER
+#define GL_UNIFORM_BUFFER                                0x8A11
+#define GL_UNIFORM_BUFFER_BINDING                        0x8A28
+#define GL_UNIFORM_BUFFER_START                          0x8A29
+#define GL_UNIFORM_BUFFER_SIZE                           0x8A2A
+#define GL_MAX_VERTEX_UNIFORM_BLOCKS                     0x8A2B
+#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS                   0x8A2D
+#define GL_MAX_COMBINED_UNIFORM_BLOCKS                   0x8A2E
+#define GL_MAX_UNIFORM_BUFFER_BINDINGS                   0x8A2F
+#define GL_MAX_UNIFORM_BLOCK_SIZE                        0x8A30
+#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS        0x8A31
+#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS      0x8A33
+#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT               0x8A34
+#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH          0x8A35
+#define GL_ACTIVE_UNIFORM_BLOCKS                         0x8A36
+#define GL_UNIFORM_TYPE                                  0x8A37
+#define GL_UNIFORM_SIZE                                  0x8A38
+#define GL_UNIFORM_NAME_LENGTH                           0x8A39
+#define GL_UNIFORM_BLOCK_INDEX                           0x8A3A
+#define GL_UNIFORM_OFFSET                                0x8A3B
+#define GL_UNIFORM_ARRAY_STRIDE                          0x8A3C
+#define GL_UNIFORM_MATRIX_STRIDE                         0x8A3D
+#define GL_UNIFORM_IS_ROW_MAJOR                          0x8A3E
+#define GL_UNIFORM_BLOCK_BINDING                         0x8A3F
+#define GL_UNIFORM_BLOCK_DATA_SIZE                       0x8A40
+#define GL_UNIFORM_BLOCK_NAME_LENGTH                     0x8A41
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS                 0x8A42
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES          0x8A43
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER     0x8A44
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER   0x8A46
+#define GL_INVALID_INDEX                                 0xFFFFFFFFu
+#define GL_MAX_VERTEX_OUTPUT_COMPONENTS                  0x9122
+#define GL_MAX_FRAGMENT_INPUT_COMPONENTS                 0x9125
+#define GL_MAX_SERVER_WAIT_TIMEOUT                       0x9111
+#define GL_OBJECT_TYPE                                   0x9112
+#define GL_SYNC_CONDITION                                0x9113
+#define GL_SYNC_STATUS                                   0x9114
+#define GL_SYNC_FLAGS                                    0x9115
+#define GL_SYNC_FENCE                                    0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE                    0x9117
+#define GL_UNSIGNALED                                    0x9118
+#define GL_SIGNALED                                      0x9119
+#define GL_ALREADY_SIGNALED                              0x911A
+#define GL_TIMEOUT_EXPIRED                               0x911B
+#define GL_CONDITION_SATISFIED                           0x911C
+#define GL_WAIT_FAILED                                   0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT                       0x00000001
+#define GL_TIMEOUT_IGNORED                               0xFFFFFFFFFFFFFFFFull
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR                   0x88FE
+#define GL_ANY_SAMPLES_PASSED                            0x8C2F
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE               0x8D6A
+#define GL_SAMPLER_BINDING                               0x8919
+#define GL_RGB10_A2UI                                    0x906F
+#define GL_TEXTURE_SWIZZLE_R                             0x8E42
+#define GL_TEXTURE_SWIZZLE_G                             0x8E43
+#define GL_TEXTURE_SWIZZLE_B                             0x8E44
+#define GL_TEXTURE_SWIZZLE_A                             0x8E45
+#define GL_GREEN                                         0x1904
+#define GL_BLUE                                          0x1905
+#define GL_INT_2_10_10_10_REV                            0x8D9F
+#define GL_TRANSFORM_FEEDBACK                            0x8E22
+#define GL_TRANSFORM_FEEDBACK_PAUSED                     0x8E23
+#define GL_TRANSFORM_FEEDBACK_ACTIVE                     0x8E24
+#define GL_TRANSFORM_FEEDBACK_BINDING                    0x8E25
+#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT               0x8257
+#define GL_PROGRAM_BINARY_LENGTH                         0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS                    0x87FE
+#define GL_PROGRAM_BINARY_FORMATS                        0x87FF
+#define GL_COMPRESSED_R11_EAC                            0x9270
+#define GL_COMPRESSED_SIGNED_R11_EAC                     0x9271
+#define GL_COMPRESSED_RG11_EAC                           0x9272
+#define GL_COMPRESSED_SIGNED_RG11_EAC                    0x9273
+#define GL_COMPRESSED_RGB8_ETC2                          0x9274
+#define GL_COMPRESSED_SRGB8_ETC2                         0x9275
+#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2      0x9276
+#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2     0x9277
+#define GL_COMPRESSED_RGBA8_ETC2_EAC                     0x9278
+#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC              0x9279
+#define GL_TEXTURE_IMMUTABLE_FORMAT                      0x912F
+#define GL_MAX_ELEMENT_INDEX                             0x8D6B
+#define GL_NUM_SAMPLE_COUNTS                             0x9380
+#define GL_TEXTURE_IMMUTABLE_LEVELS                      0x82DF
+
+/*-------------------------------------------------------------------------
+ * Entrypoint definitions
+ *-----------------------------------------------------------------------*/
+
+/* OpenGL ES 2.0 */
+
+GL_APICALL void           GL_APIENTRY glActiveTexture (GLenum texture);
+GL_APICALL void           GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
+GL_APICALL void           GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name);
+GL_APICALL void           GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
+GL_APICALL void           GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
+GL_APICALL void           GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
+GL_APICALL void           GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
+GL_APICALL void           GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GL_APICALL void           GL_APIENTRY glBlendEquation (GLenum mode);
+GL_APICALL void           GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
+GL_APICALL void           GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
+GL_APICALL void           GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GL_APICALL void           GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
+GL_APICALL void           GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
+GL_APICALL GLenum         GL_APIENTRY glCheckFramebufferStatus (GLenum target);
+GL_APICALL void           GL_APIENTRY glClear (GLbitfield mask);
+GL_APICALL void           GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GL_APICALL void           GL_APIENTRY glClearDepthf (GLfloat depth);
+GL_APICALL void           GL_APIENTRY glClearStencil (GLint s);
+GL_APICALL void           GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GL_APICALL void           GL_APIENTRY glCompileShader (GLuint shader);
+GL_APICALL void           GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void           GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void           GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GL_APICALL void           GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL GLuint         GL_APIENTRY glCreateProgram (void);
+GL_APICALL GLuint         GL_APIENTRY glCreateShader (GLenum type);
+GL_APICALL void           GL_APIENTRY glCullFace (GLenum mode);
+GL_APICALL void           GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
+GL_APICALL void           GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
+GL_APICALL void           GL_APIENTRY glDeleteProgram (GLuint program);
+GL_APICALL void           GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
+GL_APICALL void           GL_APIENTRY glDeleteShader (GLuint shader);
+GL_APICALL void           GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
+GL_APICALL void           GL_APIENTRY glDepthFunc (GLenum func);
+GL_APICALL void           GL_APIENTRY glDepthMask (GLboolean flag);
+GL_APICALL void           GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f);
+GL_APICALL void           GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
+GL_APICALL void           GL_APIENTRY glDisable (GLenum cap);
+GL_APICALL void           GL_APIENTRY glDisableVertexAttribArray (GLuint index);
+GL_APICALL void           GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
+GL_APICALL void           GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
+GL_APICALL void           GL_APIENTRY glEnable (GLenum cap);
+GL_APICALL void           GL_APIENTRY glEnableVertexAttribArray (GLuint index);
+GL_APICALL void           GL_APIENTRY glFinish (void);
+GL_APICALL void           GL_APIENTRY glFlush (void);
+GL_APICALL void           GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GL_APICALL void           GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GL_APICALL void           GL_APIENTRY glFrontFace (GLenum mode);
+GL_APICALL void           GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
+GL_APICALL void           GL_APIENTRY glGenerateMipmap (GLenum target);
+GL_APICALL void           GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
+GL_APICALL void           GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
+GL_APICALL void           GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
+GL_APICALL void           GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+GL_APICALL void           GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+GL_APICALL void           GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+GL_APICALL GLint          GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
+GL_APICALL void           GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
+GL_APICALL void           GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL GLenum         GL_APIENTRY glGetError (void);
+GL_APICALL void           GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);
+GL_APICALL void           GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+GL_APICALL void           GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+GL_APICALL void           GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+GL_APICALL void           GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
+GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);
+GL_APICALL void           GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);
+GL_APICALL void           GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
+GL_APICALL void           GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
+GL_APICALL GLint          GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
+GL_APICALL void           GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
+GL_APICALL void           GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
+GL_APICALL void           GL_APIENTRY glHint (GLenum target, GLenum mode);
+GL_APICALL GLboolean      GL_APIENTRY glIsBuffer (GLuint buffer);
+GL_APICALL GLboolean      GL_APIENTRY glIsEnabled (GLenum cap);
+GL_APICALL GLboolean      GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
+GL_APICALL GLboolean      GL_APIENTRY glIsProgram (GLuint program);
+GL_APICALL GLboolean      GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
+GL_APICALL GLboolean      GL_APIENTRY glIsShader (GLuint shader);
+GL_APICALL GLboolean      GL_APIENTRY glIsTexture (GLuint texture);
+GL_APICALL void           GL_APIENTRY glLineWidth (GLfloat width);
+GL_APICALL void           GL_APIENTRY glLinkProgram (GLuint program);
+GL_APICALL void           GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
+GL_APICALL void           GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
+GL_APICALL void           GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
+GL_APICALL void           GL_APIENTRY glReleaseShaderCompiler (void);
+GL_APICALL void           GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void           GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert);
+GL_APICALL void           GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void           GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
+GL_APICALL void           GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
+GL_APICALL void           GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
+GL_APICALL void           GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
+GL_APICALL void           GL_APIENTRY glStencilMask (GLuint mask);
+GL_APICALL void           GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
+GL_APICALL void           GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
+GL_APICALL void           GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+GL_APICALL void           GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void           GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+GL_APICALL void           GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);
+GL_APICALL void           GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
+GL_APICALL void           GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);
+GL_APICALL void           GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void           GL_APIENTRY glUniform1f (GLint location, GLfloat x);
+GL_APICALL void           GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void           GL_APIENTRY glUniform1i (GLint location, GLint x);
+GL_APICALL void           GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void           GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
+GL_APICALL void           GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void           GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
+GL_APICALL void           GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void           GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void           GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void           GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
+GL_APICALL void           GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void           GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void           GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void           GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
+GL_APICALL void           GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void           GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glUseProgram (GLuint program);
+GL_APICALL void           GL_APIENTRY glValidateProgram (GLuint program);
+GL_APICALL void           GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
+GL_APICALL void           GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);
+GL_APICALL void           GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);
+GL_APICALL void           GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);
+GL_APICALL void           GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void           GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);
+GL_APICALL void           GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void           GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);
+GL_APICALL void           GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
+GL_APICALL void           GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+
+/* OpenGL ES 3.0 */
+
+GL_APICALL void           GL_APIENTRY glReadBuffer (GLenum mode);
+GL_APICALL void           GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices);
+GL_APICALL void           GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void           GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void           GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void           GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void           GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void           GL_APIENTRY glGenQueries (GLsizei n, GLuint* ids);
+GL_APICALL void           GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint* ids);
+GL_APICALL GLboolean      GL_APIENTRY glIsQuery (GLuint id);
+GL_APICALL void           GL_APIENTRY glBeginQuery (GLenum target, GLuint id);
+GL_APICALL void           GL_APIENTRY glEndQuery (GLenum target);
+GL_APICALL void           GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint* params);
+GL_APICALL GLboolean      GL_APIENTRY glUnmapBuffer (GLenum target);
+GL_APICALL void           GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid** params);
+GL_APICALL void           GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum* bufs);
+GL_APICALL void           GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+GL_APICALL void           GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void           GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GL_APICALL GLvoid*        GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GL_APICALL void           GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length);
+GL_APICALL void           GL_APIENTRY glBindVertexArray (GLuint array);
+GL_APICALL void           GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint* arrays);
+GL_APICALL void           GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint* arrays);
+GL_APICALL GLboolean      GL_APIENTRY glIsVertexArray (GLuint array);
+GL_APICALL void           GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint* data);
+GL_APICALL void           GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode);
+GL_APICALL void           GL_APIENTRY glEndTransformFeedback (void);
+GL_APICALL void           GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GL_APICALL void           GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer);
+GL_APICALL void           GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode);
+GL_APICALL void           GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name);
+GL_APICALL void           GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+GL_APICALL void           GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint* params);
+GL_APICALL void           GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w);
+GL_APICALL void           GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GL_APICALL void           GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint* v);
+GL_APICALL void           GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint* v);
+GL_APICALL void           GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint* params);
+GL_APICALL GLint          GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name);
+GL_APICALL void           GL_APIENTRY glUniform1ui (GLint location, GLuint v0);
+GL_APICALL void           GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1);
+GL_APICALL void           GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2);
+GL_APICALL void           GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GL_APICALL void           GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint* value);
+GL_APICALL void           GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint* value);
+GL_APICALL void           GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint* value);
+GL_APICALL void           GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint* value);
+GL_APICALL void           GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint* value);
+GL_APICALL void           GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint* value);
+GL_APICALL void           GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat* value);
+GL_APICALL void           GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+GL_APICALL const GLubyte* GL_APIENTRY glGetStringi (GLenum name, GLuint index);
+GL_APICALL void           GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+GL_APICALL void           GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices);
+GL_APICALL void           GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);
+GL_APICALL GLuint         GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar* uniformBlockName);
+GL_APICALL void           GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);
+GL_APICALL void           GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+GL_APICALL void           GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount);
+GL_APICALL void           GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount);
+GL_APICALL GLsync         GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags);
+GL_APICALL GLboolean      GL_APIENTRY glIsSync (GLsync sync);
+GL_APICALL void           GL_APIENTRY glDeleteSync (GLsync sync);
+GL_APICALL GLenum         GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void           GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void           GL_APIENTRY glGetInteger64v (GLenum pname, GLint64* params);
+GL_APICALL void           GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values);
+GL_APICALL void           GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64* data);
+GL_APICALL void           GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64* params);
+GL_APICALL void           GL_APIENTRY glGenSamplers (GLsizei count, GLuint* samplers);
+GL_APICALL void           GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint* samplers);
+GL_APICALL GLboolean      GL_APIENTRY glIsSampler (GLuint sampler);
+GL_APICALL void           GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler);
+GL_APICALL void           GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param);
+GL_APICALL void           GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint* param);
+GL_APICALL void           GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param);
+GL_APICALL void           GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat* param);
+GL_APICALL void           GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint* params);
+GL_APICALL void           GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat* params);
+GL_APICALL void           GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor);
+GL_APICALL void           GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id);
+GL_APICALL void           GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint* ids);
+GL_APICALL void           GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint* ids);
+GL_APICALL GLboolean      GL_APIENTRY glIsTransformFeedback (GLuint id);
+GL_APICALL void           GL_APIENTRY glPauseTransformFeedback (void);
+GL_APICALL void           GL_APIENTRY glResumeTransformFeedback (void);
+GL_APICALL void           GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary);
+GL_APICALL void           GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length);
+GL_APICALL void           GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value);
+GL_APICALL void           GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments);
+GL_APICALL void           GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void           GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void           GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GL_APICALL void           GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEincludeGLES3gl3exth"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3ext.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3ext.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3ext.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+#ifndef __gl3ext_h_
+#define __gl3ext_h_
+
+/* $Revision: 17809 $ on $Date:: 2012-05-14 08:03:36 -0700 #$ */
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/* OpenGL ES 3 Extensions
+ *
+ * After an OES extension's interactions with OpenGl ES 3.0 have been documented,
+ * its tokens and function definitions should be added to this file in a manner
+ * that does not conflict with gl2ext.h or gl3.h.
+ *
+ * Tokens and function definitions for extensions that have become standard
+ * features in OpenGL ES 3.0 will not be added to this file.
+ *
+ * Applications using OpenGL-ES-2-only extensions should include gl2ext.h
+ */
+
+#endif /* __gl3ext_h_ */
+
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEincludeGLES3gl3platformh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3platform.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3platform.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/include/GLES3/gl3platform.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+#ifndef __gl3platform_h_
+#define __gl3platform_h_
+
+/* $Revision: 18437 $ on $Date:: 2012-07-08 23:31:39 -0700 #$ */
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/* Platform-specific types and definitions for OpenGL ES 3.X  gl3.h
+ *
+ * Adopters may modify khrplatform.h and this file to suit their platform.
+ * You are encouraged to submit all modifications to the Khronos group so that
+ * they can be included in future versions of this file.  Please submit changes
+ * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
+ * by filing a bug against product &quot;OpenGL-ES&quot; component &quot;Registry&quot;.
+ */
+
+#include &lt;KHR/khrplatform.h&gt;
+
+#ifndef GL_APICALL
+#define GL_APICALL  KHRONOS_APICALL
+#endif
+
+#ifndef GL_APIENTRY
+#define GL_APIENTRY KHRONOS_APIENTRY
+#endif
+
+#endif /* __gl3platform_h_ */
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEincludeGLSLANGShaderLangh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -36,8 +36,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> // Version number for shader translation API.
</span><del>-// It is incremented everytime the API changes.
-#define ANGLE_SH_VERSION 112
</del><ins>+// It is incremented every time the API changes.
+#define ANGLE_SH_VERSION 123
</ins><span class="cx"> 
</span><span class="cx"> //
</span><span class="cx"> // The names of the following enums have been derived by replacing GL prefix
</span><span class="lines">@@ -88,6 +88,7 @@
</span><span class="cx"> typedef enum {
</span><span class="cx">   SH_NONE           = 0,
</span><span class="cx">   SH_INT            = 0x1404,
</span><ins>+  SH_UNSIGNED_INT   = 0x1405,
</ins><span class="cx">   SH_FLOAT          = 0x1406,
</span><span class="cx">   SH_FLOAT_VEC2     = 0x8B50,
</span><span class="cx">   SH_FLOAT_VEC3     = 0x8B51,
</span><span class="lines">@@ -95,6 +96,9 @@
</span><span class="cx">   SH_INT_VEC2       = 0x8B53,
</span><span class="cx">   SH_INT_VEC3       = 0x8B54,
</span><span class="cx">   SH_INT_VEC4       = 0x8B55,
</span><ins>+  SH_UNSIGNED_INT_VEC2 = 0x8DC6,
+  SH_UNSIGNED_INT_VEC3 = 0x8DC7,
+  SH_UNSIGNED_INT_VEC4 = 0x8DC8,
</ins><span class="cx">   SH_BOOL           = 0x8B56,
</span><span class="cx">   SH_BOOL_VEC2      = 0x8B57,
</span><span class="cx">   SH_BOOL_VEC3      = 0x8B58,
</span><span class="lines">@@ -102,10 +106,29 @@
</span><span class="cx">   SH_FLOAT_MAT2     = 0x8B5A,
</span><span class="cx">   SH_FLOAT_MAT3     = 0x8B5B,
</span><span class="cx">   SH_FLOAT_MAT4     = 0x8B5C,
</span><ins>+  SH_FLOAT_MAT2x3   = 0x8B65,
+  SH_FLOAT_MAT2x4   = 0x8B66,
+  SH_FLOAT_MAT3x2   = 0x8B67,
+  SH_FLOAT_MAT3x4   = 0x8B68,
+  SH_FLOAT_MAT4x2   = 0x8B69,
+  SH_FLOAT_MAT4x3   = 0x8B6A,
</ins><span class="cx">   SH_SAMPLER_2D     = 0x8B5E,
</span><ins>+  SH_SAMPLER_3D     = 0x8B5F,
</ins><span class="cx">   SH_SAMPLER_CUBE   = 0x8B60,
</span><span class="cx">   SH_SAMPLER_2D_RECT_ARB = 0x8B63,
</span><del>-  SH_SAMPLER_EXTERNAL_OES = 0x8D66
</del><ins>+  SH_SAMPLER_EXTERNAL_OES = 0x8D66,
+  SH_SAMPLER_2D_ARRAY   = 0x8DC1,
+  SH_INT_SAMPLER_2D     = 0x8DCA,
+  SH_INT_SAMPLER_3D     = 0x8DCB,
+  SH_INT_SAMPLER_CUBE   = 0x8DCC,
+  SH_INT_SAMPLER_2D_ARRAY = 0x8DCF,
+  SH_UNSIGNED_INT_SAMPLER_2D     = 0x8DD2,
+  SH_UNSIGNED_INT_SAMPLER_3D     = 0x8DD3,
+  SH_UNSIGNED_INT_SAMPLER_CUBE   = 0x8DD4,
+  SH_UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7,
+  SH_SAMPLER_2D_SHADOW       = 0x8B62,
+  SH_SAMPLER_CUBE_SHADOW     = 0x8DC5,
+  SH_SAMPLER_2D_ARRAY_SHADOW = 0x8DC4
</ins><span class="cx"> } ShDataType;
</span><span class="cx"> 
</span><span class="cx"> typedef enum {
</span><span class="lines">@@ -116,19 +139,24 @@
</span><span class="cx"> } ShPrecisionType;
</span><span class="cx"> 
</span><span class="cx"> typedef enum {
</span><del>-  SH_INFO_LOG_LENGTH             =  0x8B84,
-  SH_OBJECT_CODE_LENGTH          =  0x8B88,  // GL_SHADER_SOURCE_LENGTH
-  SH_ACTIVE_UNIFORMS             =  0x8B86,
-  SH_ACTIVE_UNIFORM_MAX_LENGTH   =  0x8B87,
-  SH_ACTIVE_ATTRIBUTES           =  0x8B89,
-  SH_ACTIVE_ATTRIBUTE_MAX_LENGTH =  0x8B8A,
-  SH_VARYINGS                    =  0x8BBB,
-  SH_VARYING_MAX_LENGTH          =  0x8BBC,
-  SH_MAPPED_NAME_MAX_LENGTH      =  0x6000,
-  SH_NAME_MAX_LENGTH             =  0x6001,
-  SH_HASHED_NAME_MAX_LENGTH      =  0x6002,
-  SH_HASHED_NAMES_COUNT          =  0x6003,
-  SH_ACTIVE_UNIFORMS_ARRAY       =  0x6004
</del><ins>+  SH_INFO_LOG_LENGTH                = 0x8B84,
+  SH_OBJECT_CODE_LENGTH             = 0x8B88,  // GL_SHADER_SOURCE_LENGTH
+  SH_ACTIVE_UNIFORMS                = 0x8B86,
+  SH_ACTIVE_UNIFORM_MAX_LENGTH      = 0x8B87,
+  SH_ACTIVE_ATTRIBUTES              = 0x8B89,
+  SH_ACTIVE_ATTRIBUTE_MAX_LENGTH    = 0x8B8A,
+  SH_VARYINGS                       = 0x8BBB,
+  SH_VARYING_MAX_LENGTH             = 0x8BBC,
+  SH_MAPPED_NAME_MAX_LENGTH         = 0x6000,
+  SH_NAME_MAX_LENGTH                = 0x6001,
+  SH_HASHED_NAME_MAX_LENGTH         = 0x6002,
+  SH_HASHED_NAMES_COUNT             = 0x6003,
+  SH_ACTIVE_UNIFORMS_ARRAY          = 0x6004,
+  SH_SHADER_VERSION                 = 0x6005,
+  SH_ACTIVE_INTERFACE_BLOCKS_ARRAY  = 0x6006,
+  SH_ACTIVE_OUTPUT_VARIABLES_ARRAY  = 0x6007,
+  SH_ACTIVE_ATTRIBUTES_ARRAY        = 0x6008,
+  SH_ACTIVE_VARYINGS_ARRAY          = 0x6009,
</ins><span class="cx"> } ShShaderInfo;
</span><span class="cx"> 
</span><span class="cx"> // Compile options.
</span><span class="lines">@@ -140,13 +168,17 @@
</span><span class="cx">   SH_VARIABLES               = 0x0008,
</span><span class="cx">   SH_LINE_DIRECTIVES         = 0x0010,
</span><span class="cx">   SH_SOURCE_PATH             = 0x0020,
</span><del>-  SH_MAP_LONG_VARIABLE_NAMES = 0x0040,
-  SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX = 0x0080,
</del><ins>+  SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX = 0x0040,
+  // If a sampler array index happens to be a loop index,
+  //   1) if its type is integer, unroll the loop.
+  //   2) if its type is float, fail the shader compile.
+  // This is to work around a mac driver bug.
+  SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX = 0x0080,
</ins><span class="cx"> 
</span><span class="cx">   // This is needed only as a workaround for certain OpenGL driver bugs.
</span><span class="cx">   SH_EMULATE_BUILT_IN_FUNCTIONS = 0x0100,
</span><span class="cx"> 
</span><del>-  // This is an experimental flag to enforce restrictions that aim to prevent
</del><ins>+  // This is an experimental flag to enforce restrictions that aim to prevent 
</ins><span class="cx">   // timing attacks.
</span><span class="cx">   // It generates compilation errors for shaders that could expose sensitive
</span><span class="cx">   // texture information via the timing channel.
</span><span class="lines">@@ -252,11 +284,18 @@
</span><span class="cx">     int ARB_texture_rectangle;
</span><span class="cx">     int EXT_draw_buffers;
</span><span class="cx">     int EXT_frag_depth;
</span><ins>+    int EXT_shader_texture_lod;
</ins><span class="cx"> 
</span><span class="cx">     // Set to 1 if highp precision is supported in the fragment language.
</span><span class="cx">     // Default is 0.
</span><span class="cx">     int FragmentPrecisionHigh;
</span><span class="cx"> 
</span><ins>+    // GLSL ES 3.0 constants.
+    int MaxVertexOutputVectors;
+    int MaxFragmentInputVectors;
+    int MinProgramTexelOffset;
+    int MaxProgramTexelOffset;
+
</ins><span class="cx">     // Name Hashing.
</span><span class="cx">     // Set a 64 bit hash function to enable user-defined name hashing.
</span><span class="cx">     // Default is NULL.
</span><span class="lines">@@ -280,7 +319,7 @@
</span><span class="cx"> 
</span><span class="cx"> //
</span><span class="cx"> // ShHandle held by but opaque to the driver.  It is allocated,
</span><del>-// managed, and de-allocated by the compiler. It's contents
</del><ins>+// managed, and de-allocated by the compiler. It's contents 
</ins><span class="cx"> // are defined by and used by the compiler.
</span><span class="cx"> //
</span><span class="cx"> // If handle creation fails, 0 will be returned.
</span><span class="lines">@@ -364,6 +403,7 @@
</span><span class="cx"> // SH_HASHED_NAME_MAX_LENGTH: the max length of a hashed name including the
</span><span class="cx"> //                            null termination character.
</span><span class="cx"> // SH_HASHED_NAMES_COUNT: the number of hashed names from the latest compile.
</span><ins>+// SH_SHADER_VERSION: the version of the shader language
</ins><span class="cx"> //
</span><span class="cx"> // params: Requested parameter
</span><span class="cx"> COMPILER_EXPORT void ShGetInfo(const ShHandle handle,
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrcbuild_anglegyp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/build_angle.gyp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/build_angle.gyp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/build_angle.gyp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -3,13 +3,8 @@
</span><span class="cx"> # found in the LICENSE file.
</span><span class="cx"> 
</span><span class="cx"> {
</span><del>-  'includes': [
-    'build_angle.gypi',
-  ],
</del><ins>+    'includes':
+    [
+        'angle.gypi',
+    ],
</ins><span class="cx"> }
</span><del>-
-# Local Variables:
-# tab-width:2
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=2 shiftwidth=2:
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonRefCountObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/common/RefCountObject.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/RefCountObject.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/common/RefCountObject.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -15,6 +15,7 @@
</span><span class="cx"> #include &lt;cstddef&gt;
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/debug.h&quot;
</span><span class="lines">@@ -47,7 +48,7 @@
</span><span class="cx"> 
</span><span class="cx">   public:
</span><span class="cx">     GLuint id() const { return (mObject != NULL) ? mObject-&gt;id() : 0; }
</span><del>-    bool operator ! () const { return (get() == NULL); }
</del><ins>+    bool operator!() const { return (get() == NULL); }
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     RefCountObject *mObject;
</span><span class="lines">@@ -59,7 +60,65 @@
</span><span class="cx">   public:
</span><span class="cx">     void set(ObjectType *newObject) { RefCountObjectBindingPointer::set(newObject); }
</span><span class="cx">     ObjectType *get() const { return static_cast&lt;ObjectType*&gt;(RefCountObjectBindingPointer::get()); }
</span><del>-    ObjectType *operator -&gt; () const { return get(); }
</del><ins>+    ObjectType *operator-&gt;() const { return get(); }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+template &lt;class ObjectType&gt;
+class FramebufferTextureBindingPointer : public RefCountObjectBindingPointer
+{
+public:
+    FramebufferTextureBindingPointer() : mType(GL_NONE), mMipLevel(0), mLayer(0) { }
+
+    void set(ObjectType *newObject, GLenum type, GLint mipLevel, GLint layer)
+    {
+        RefCountObjectBindingPointer::set(newObject);
+        mType = type;
+        mMipLevel = mipLevel;
+        mLayer = layer;
+    }
+
+    ObjectType *get() const { return static_cast&lt;ObjectType*&gt;(RefCountObjectBindingPointer::get()); }
+    ObjectType *operator-&gt;() const { return get(); }
+
+    GLenum type() const { return mType; }
+    GLint mipLevel() const { return mMipLevel; }
+    GLint layer() const { return mLayer; }
+
+private:
+    GLenum mType;
+    GLint mMipLevel;
+    GLint mLayer;
+};
+
+template &lt;class ObjectType&gt;
+class OffsetBindingPointer : public RefCountObjectBindingPointer
+{
+  public:
+    OffsetBindingPointer() : mOffset(0), mSize(0) { }
+
+    void set(ObjectType *newObject)
+    {
+        RefCountObjectBindingPointer::set(newObject);
+        mOffset = 0;
+        mSize = 0;
+    }
+
+    void set(ObjectType *newObject, GLintptr offset, GLsizeiptr size)
+    {
+        RefCountObjectBindingPointer::set(newObject);
+        mOffset = offset;
+        mSize = size;
+    }
+
+    GLintptr getOffset() const { return mOffset; }
+    GLsizeiptr getSize() const { return mSize; }
+
+    ObjectType *get() const { return static_cast&lt;ObjectType*&gt;(RefCountObjectBindingPointer::get()); }
+    ObjectType *operator-&gt;() const { return get(); }
+
+  private:
+    GLintptr mOffset;
+    GLsizeiptr mSize;
+};
+
</ins><span class="cx"> #endif   // COMMON_REFCOUNTOBJECT_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonangleutilsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/common/angleutils.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/angleutils.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/common/angleutils.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -56,6 +56,28 @@
</span><span class="cx">     resource = NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// Provide a less-than function for comparing structs
+// Note: struct memory must be initialized to zero, because of packing gaps
+template &lt;typename T&gt;
+inline bool StructLessThan(const T &amp;a, const T &amp;b)
+{
+    return (memcmp(&amp;a, &amp;b, sizeof(T)) &lt; 0);
+}
+
+// Provide a less-than function for comparing structs
+// Note: struct memory must be initialized to zero, because of packing gaps
+template &lt;typename T&gt;
+inline bool StructEquals(const T &amp;a, const T &amp;b)
+{
+    return (memcmp(&amp;a, &amp;b, sizeof(T)) == 0);
+}
+
+template &lt;typename T&gt;
+inline void StructZero(T *obj)
+{
+    memset(obj, 0, sizeof(T));
+}
+
</ins><span class="cx"> #if defined(_MSC_VER)
</span><span class="cx"> #define snprintf _snprintf
</span><span class="cx"> #endif
</span><span class="lines">@@ -66,5 +88,7 @@
</span><span class="cx"> 
</span><span class="cx"> #define GL_BGRA4_ANGLEX 0x6ABC
</span><span class="cx"> #define GL_BGR5_A1_ANGLEX 0x6ABD
</span><ins>+#define GL_INT_64_ANGLEX 0x6ABE
+#define GL_STRUCT_ANGLEX 0x6ABF
</ins><span class="cx"> 
</span><span class="cx"> #endif // COMMON_ANGLEUTILS_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonblocklayoutcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/common/blocklayout.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/blocklayout.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/common/blocklayout.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,305 @@
</span><ins>+//
+// Copyright (c) 2013-2014 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.
+//
+// blocklayout.cpp:
+//   Implementation for block layout classes and methods.
+//
+
+#include &quot;common/blocklayout.h&quot;
+#include &quot;common/shadervars.h&quot;
+#include &quot;common/mathutil.h&quot;
+#include &quot;common/utilities.h&quot;
+
+namespace gl
+{
+
+BlockLayoutEncoder::BlockLayoutEncoder(std::vector&lt;BlockMemberInfo&gt; *blockInfoOut)
+    : mCurrentOffset(0),
+      mBlockInfoOut(blockInfoOut)
+{
+}
+
+void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector&lt;InterfaceBlockField&gt; &amp;fields)
+{
+    for (unsigned int fieldIndex = 0; fieldIndex &lt; fields.size(); fieldIndex++)
+    {
+        const InterfaceBlockField &amp;variable = fields[fieldIndex];
+
+        if (variable.fields.size() &gt; 0)
+        {
+            const unsigned int elementCount = std::max(1u, variable.arraySize);
+
+            for (unsigned int elementIndex = 0; elementIndex &lt; elementCount; elementIndex++)
+            {
+                enterAggregateType();
+                encodeInterfaceBlockFields(variable.fields);
+                exitAggregateType();
+            }
+        }
+        else
+        {
+            encodeInterfaceBlockField(variable);
+        }
+    }
+}
+
+void BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &amp;field)
+{
+    int arrayStride;
+    int matrixStride;
+
+    ASSERT(field.fields.empty());
+    getBlockLayoutInfo(field.type, field.arraySize, field.isRowMajorMatrix, &amp;arrayStride, &amp;matrixStride);
+
+    const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, field.isRowMajorMatrix);
+
+    if (mBlockInfoOut)
+    {
+        mBlockInfoOut-&gt;push_back(memberInfo);
+    }
+
+    advanceOffset(field.type, field.arraySize, field.isRowMajorMatrix, arrayStride, matrixStride);
+}
+
+void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix)
+{
+    int arrayStride;
+    int matrixStride;
+
+    getBlockLayoutInfo(type, arraySize, isRowMajorMatrix, &amp;arrayStride, &amp;matrixStride);
+
+    const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, isRowMajorMatrix);
+
+    if (mBlockInfoOut)
+    {
+        mBlockInfoOut-&gt;push_back(memberInfo);
+    }
+
+    advanceOffset(type, arraySize, isRowMajorMatrix, arrayStride, matrixStride);
+}
+
+void BlockLayoutEncoder::nextRegister()
+{
+    mCurrentOffset = rx::roundUp&lt;size_t&gt;(mCurrentOffset, ComponentsPerRegister);
+}
+
+Std140BlockEncoder::Std140BlockEncoder(std::vector&lt;BlockMemberInfo&gt; *blockInfoOut)
+    : BlockLayoutEncoder(blockInfoOut)
+{
+}
+
+void Std140BlockEncoder::enterAggregateType()
+{
+    nextRegister();
+}
+
+void Std140BlockEncoder::exitAggregateType()
+{
+    nextRegister();
+}
+
+void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
+{
+    // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
+    ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
+
+    size_t baseAlignment = 0;
+    int matrixStride = 0;
+    int arrayStride = 0;
+
+    if (gl::IsMatrixType(type))
+    {
+        baseAlignment = ComponentsPerRegister;
+        matrixStride = ComponentsPerRegister;
+
+        if (arraySize &gt; 0)
+        {
+            const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
+            arrayStride = ComponentsPerRegister * numRegisters;
+        }
+    }
+    else if (arraySize &gt; 0)
+    {
+        baseAlignment = ComponentsPerRegister;
+        arrayStride = ComponentsPerRegister;
+    }
+    else
+    {
+        const int numComponents = gl::UniformComponentCount(type);
+        baseAlignment = (numComponents == 3 ? 4u : static_cast&lt;size_t&gt;(numComponents));
+    }
+
+    mCurrentOffset = rx::roundUp(mCurrentOffset, baseAlignment);
+
+    *matrixStrideOut = matrixStride;
+    *arrayStrideOut = arrayStride;
+}
+
+void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride)
+{
+    if (arraySize &gt; 0)
+    {
+        mCurrentOffset += arrayStride * arraySize;
+    }
+    else if (gl::IsMatrixType(type))
+    {
+        ASSERT(matrixStride == ComponentsPerRegister);
+        const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
+        mCurrentOffset += ComponentsPerRegister * numRegisters;
+    }
+    else
+    {
+        mCurrentOffset += gl::UniformComponentCount(type);
+    }
+}
+
+HLSLBlockEncoder::HLSLBlockEncoder(std::vector&lt;BlockMemberInfo&gt; *blockInfoOut)
+    : BlockLayoutEncoder(blockInfoOut)
+{
+}
+
+void HLSLBlockEncoder::enterAggregateType()
+{
+    nextRegister();
+}
+
+void HLSLBlockEncoder::exitAggregateType()
+{
+}
+
+void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
+{
+    // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
+    ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
+
+    int matrixStride = 0;
+    int arrayStride = 0;
+
+    if (gl::IsMatrixType(type))
+    {
+        nextRegister();
+        matrixStride = ComponentsPerRegister;
+
+        if (arraySize &gt; 0)
+        {
+            const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
+            arrayStride = ComponentsPerRegister * numRegisters;
+        }
+    }
+    else if (arraySize &gt; 0)
+    {
+        nextRegister();
+        arrayStride = ComponentsPerRegister;
+    }
+    else
+    {
+        int numComponents = gl::UniformComponentCount(type);
+        if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) &gt; ComponentsPerRegister)
+        {
+            nextRegister();
+        }
+    }
+
+    *matrixStrideOut = matrixStride;
+    *arrayStrideOut = arrayStride;
+}
+
+void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride)
+{
+    if (arraySize &gt; 0)
+    {
+        mCurrentOffset += arrayStride * (arraySize - 1);
+    }
+
+    if (gl::IsMatrixType(type))
+    {
+        ASSERT(matrixStride == ComponentsPerRegister);
+        const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
+        const int numComponents = gl::MatrixComponentCount(type, isRowMajorMatrix);
+        mCurrentOffset += ComponentsPerRegister * (numRegisters - 1);
+        mCurrentOffset += numComponents;
+    }
+    else
+    {
+        mCurrentOffset += gl::UniformComponentCount(type);
+    }
+}
+
+void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, HLSLBlockEncoder *encoder, const std::vector&lt;gl::BlockMemberInfo&gt; &amp;blockInfo)
+{
+    // because this method computes offsets (element indexes) instead of any total sizes,
+    // we can ignore the array size of the variable
+
+    if (variable-&gt;isStruct())
+    {
+        encoder-&gt;enterAggregateType();
+
+        for (size_t fieldIndex = 0; fieldIndex &lt; variable-&gt;fields.size(); fieldIndex++)
+        {
+            HLSLVariableGetRegisterInfo(baseRegisterIndex, &amp;variable-&gt;fields[fieldIndex], encoder, blockInfo);
+        }
+
+        encoder-&gt;exitAggregateType();
+    }
+    else
+    {
+        encoder-&gt;encodeType(variable-&gt;type, variable-&gt;arraySize, false);
+
+        const size_t registerBytes = (encoder-&gt;BytesPerComponent * encoder-&gt;ComponentsPerRegister);
+        variable-&gt;registerIndex = baseRegisterIndex + (blockInfo.back().offset / registerBytes);
+        variable-&gt;elementIndex = (blockInfo.back().offset % registerBytes) / sizeof(float);
+    }
+}
+
+void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable)
+{
+    std::vector&lt;BlockMemberInfo&gt; blockInfo;
+    HLSLBlockEncoder encoder(&amp;blockInfo);
+    HLSLVariableGetRegisterInfo(baseRegisterIndex, variable, &amp;encoder, blockInfo);
+}
+
+template &lt;class ShaderVarType&gt;
+void HLSLVariableRegisterCount(const ShaderVarType &amp;variable, HLSLBlockEncoder *encoder)
+{
+    if (variable.isStruct())
+    {
+        for (size_t arrayElement = 0; arrayElement &lt; variable.elementCount(); arrayElement++)
+        {
+            encoder-&gt;enterAggregateType();
+
+            for (size_t fieldIndex = 0; fieldIndex &lt; variable.fields.size(); fieldIndex++)
+            {
+                HLSLVariableRegisterCount(variable.fields[fieldIndex], encoder);
+            }
+
+            encoder-&gt;exitAggregateType();
+        }
+    }
+    else
+    {
+        // We operate only on varyings and uniforms, which do not have matrix layout qualifiers
+        encoder-&gt;encodeType(variable.type, variable.arraySize, false);
+    }
+}
+
+unsigned int HLSLVariableRegisterCount(const Varying &amp;variable)
+{
+    HLSLBlockEncoder encoder(NULL);
+    HLSLVariableRegisterCount(variable, &amp;encoder);
+
+    const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
+    return static_cast&lt;unsigned int&gt;(rx::roundUp&lt;size_t&gt;(encoder.getBlockSize(), registerBytes) / registerBytes);
+}
+
+unsigned int HLSLVariableRegisterCount(const Uniform &amp;variable)
+{
+    HLSLBlockEncoder encoder(NULL);
+    HLSLVariableRegisterCount(variable, &amp;encoder);
+
+    const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
+    return static_cast&lt;unsigned int&gt;(rx::roundUp&lt;size_t&gt;(encoder.getBlockSize(), registerBytes) / registerBytes);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonblocklayouth"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/common/blocklayout.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/blocklayout.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/common/blocklayout.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,97 @@
</span><ins>+//
+// Copyright (c) 2013-2014 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.
+//
+// blocklayout.h:
+//   Methods and classes related to uniform layout and packing in GLSL and HLSL.
+//
+
+#ifndef COMMON_BLOCKLAYOUT_H_
+#define COMMON_BLOCKLAYOUT_H_
+
+#include &lt;vector&gt;
+#define GL_APICALL
+#include &lt;GLES3/gl3.h&gt;
+#include &lt;GLES2/gl2.h&gt;
+#include &lt;cstddef&gt;
+
+namespace gl
+{
+
+struct ShaderVariable;
+struct InterfaceBlockField;
+struct BlockMemberInfo;
+struct Uniform;
+struct Varying;
+
+class BlockLayoutEncoder
+{
+  public:
+    BlockLayoutEncoder(std::vector&lt;BlockMemberInfo&gt; *blockInfoOut);
+
+    void encodeInterfaceBlockFields(const std::vector&lt;InterfaceBlockField&gt; &amp;fields);
+    void encodeInterfaceBlockField(const InterfaceBlockField &amp;field);
+    void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
+    size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; }
+
+    static const size_t BytesPerComponent = 4u;
+    static const unsigned int ComponentsPerRegister = 4u;
+
+  protected:
+    size_t mCurrentOffset;
+
+    void nextRegister();
+
+    virtual void enterAggregateType() = 0;
+    virtual void exitAggregateType() = 0;
+    virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) = 0;
+    virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride) = 0;
+
+  private:
+    std::vector&lt;BlockMemberInfo&gt; *mBlockInfoOut;
+};
+
+// Block layout according to the std140 block layout
+// See &quot;Standard Uniform Block Layout&quot; in Section 2.11.6 of the OpenGL ES 3.0 specification
+
+class Std140BlockEncoder : public BlockLayoutEncoder
+{
+  public:
+    Std140BlockEncoder(std::vector&lt;BlockMemberInfo&gt; *blockInfoOut);
+
+  protected:
+    virtual void enterAggregateType();
+    virtual void exitAggregateType();
+    virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
+    virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
+};
+
+// Block layout packed according to the default D3D11 register packing rules
+// See http://msdn.microsoft.com/en-us/library/windows/desktop/bb509632(v=vs.85).aspx
+
+class HLSLBlockEncoder : public BlockLayoutEncoder
+{
+  public:
+    HLSLBlockEncoder(std::vector&lt;BlockMemberInfo&gt; *blockInfoOut);
+
+    virtual void enterAggregateType();
+    virtual void exitAggregateType();
+
+  protected:
+    virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
+    virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
+};
+
+// This method assigns values to the variable's &quot;registerIndex&quot; and &quot;elementIndex&quot; fields.
+// &quot;elementIndex&quot; is only used for structures.
+void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable);
+
+// This method returns the number of used registers for a ShaderVariable. It is dependent on the HLSLBlockEncoder
+// class to count the number of used registers in a struct (which are individually packed according to the same rules).
+unsigned int HLSLVariableRegisterCount(const Varying &amp;variable);
+unsigned int HLSLVariableRegisterCount(const Uniform &amp;variable);
+
+}
+
+#endif // COMMON_BLOCKLAYOUT_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommondebugcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/common/debug.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/debug.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/common/debug.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -8,6 +8,9 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/debug.h&quot;
</span><span class="cx"> #include &lt;stdarg.h&gt;
</span><ins>+#include &lt;vector&gt;
+#include &lt;fstream&gt;
+#include &lt;cstdio&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if defined(ANGLE_ENABLE_PERF)
</span><span class="cx"> #include &lt;d3d9.h&gt;
</span><span class="lines">@@ -23,25 +26,38 @@
</span><span class="cx"> 
</span><span class="cx"> static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
</span><span class="cx"> {
</span><ins>+#if defined(ANGLE_ENABLE_PERF) || defined(ANGLE_ENABLE_TRACE)
+    static std::vector&lt;char&gt; asciiMessageBuffer(512);
+
+    // Attempt to just print to the current buffer
+    int len = vsnprintf(&amp;asciiMessageBuffer[0], asciiMessageBuffer.size(), format, vararg);
+    if (len &lt; 0 || static_cast&lt;size_t&gt;(len) &gt;= asciiMessageBuffer.size())
+    {
+        // Buffer was not large enough, calculate the required size and resize the buffer
+        len = vsnprintf(NULL, 0, format, vararg);
+        asciiMessageBuffer.resize(len + 1);
+
+        // Print again
+        vsnprintf(&amp;asciiMessageBuffer[0], asciiMessageBuffer.size(), format, vararg);
+    }
+
+    // NULL terminate the buffer to be safe
+    asciiMessageBuffer[len] = '\0';
+#endif
+
</ins><span class="cx"> #if defined(ANGLE_ENABLE_PERF)
</span><span class="cx">     if (perfActive())
</span><span class="cx">     {
</span><del>-        char message[32768];
-        int len = vsprintf_s(message, format, vararg);
-        if (len &lt; 0)
</del><ins>+        // The perf function only accepts wide strings, widen the ascii message
+        static std::wstring wideMessage;
+        if (wideMessage.capacity() &lt; asciiMessageBuffer.size())
</ins><span class="cx">         {
</span><del>-            return;
</del><ins>+            wideMessage.reserve(asciiMessageBuffer.size());
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        // There are no ASCII variants of these D3DPERF functions.
-        wchar_t wideMessage[32768];
-        for (int i = 0; i &lt; len; ++i)
-        {
-            wideMessage[i] = message[i];
-        }
-        wideMessage[len] = 0;
</del><ins>+        wideMessage.assign(asciiMessageBuffer.begin(), asciiMessageBuffer.begin() + len);
</ins><span class="cx"> 
</span><del>-        perfFunc(0, wideMessage);
</del><ins>+        perfFunc(0, wideMessage.c_str());
</ins><span class="cx">     }
</span><span class="cx"> #endif // ANGLE_ENABLE_PERF
</span><span class="cx"> 
</span><span class="lines">@@ -53,12 +69,13 @@
</span><span class="cx">     }
</span><span class="cx"> #endif // NDEBUG
</span><span class="cx"> 
</span><del>-    FILE* file = fopen(TRACE_OUTPUT_FILE, &quot;a&quot;);
</del><ins>+    static std::ofstream file(TRACE_OUTPUT_FILE, std::ofstream::app);
</ins><span class="cx">     if (file)
</span><span class="cx">     {
</span><del>-        vfprintf(file, format, vararg);
-        fclose(file);
</del><ins>+        file.write(&amp;asciiMessageBuffer[0], len);
+        file.flush();
</ins><span class="cx">     }
</span><ins>+
</ins><span class="cx"> #endif // ANGLE_ENABLE_TRACE
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommondebugh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/common/debug.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/debug.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/common/debug.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -82,10 +82,17 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> // A macro to indicate unimplemented functionality
</span><ins>+
+// Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks
+// This will allow us to test with some automated test suites (eg dEQP) without crashing
+#ifndef NOASSERT_UNIMPLEMENTED
+#define NOASSERT_UNIMPLEMENTED 0
+#endif
+
</ins><span class="cx"> #if !defined(NDEBUG)
</span><span class="cx"> #define UNIMPLEMENTED() do { \
</span><span class="cx">     FIXME(&quot;\t! Unimplemented: %s(%d)\n&quot;, __FUNCTION__, __LINE__); \
</span><del>-    assert(false); \
</del><ins>+    assert(NOASSERT_UNIMPLEMENTED); \
</ins><span class="cx">     } while(0)
</span><span class="cx"> #else
</span><span class="cx">     #define UNIMPLEMENTED() FIXME(&quot;\t! Unimplemented: %s(%d)\n&quot;, __FUNCTION__, __LINE__)
</span><span class="lines">@@ -101,9 +108,7 @@
</span><span class="cx">     #define UNREACHABLE() ERR(&quot;\t! Unreachable reached: %s(%d)\n&quot;, __FUNCTION__, __LINE__)
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-// A macro that determines whether an object has a given runtime type. MSVC uses _CPPRTTI.
-// GCC uses __GXX_RTTI, but the macro was introduced in version 4.3, so we assume that all older
-// versions support RTTI.
</del><ins>+// A macro that determines whether an object has a given runtime type.
</ins><span class="cx"> #if !defined(NDEBUG) &amp;&amp; (!defined(_MSC_VER) || defined(_CPPRTTI)) &amp;&amp; (!defined(__GNUC__) || __GNUC__ &lt; 4 || (__GNUC__ == 4 &amp;&amp; __GNUC_MINOR__ &lt; 3) || defined(__GXX_RTTI))
</span><span class="cx"> #define HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast&lt;type &gt;(obj) != NULL)
</span><span class="cx"> #else
</span><span class="lines">@@ -111,6 +116,13 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> // A macro functioning as a compile-time assert to validate constant conditions
</span><del>-#define META_ASSERT(condition) typedef int COMPILE_TIME_ASSERT_##__LINE__[static_cast&lt;bool&gt;(condition)?1:-1]
</del><ins>+#if defined(_MSC_VER) &amp;&amp; _MSC_VER &gt;= 1600
+#define META_ASSERT_MSG(condition, msg) static_assert(condition, msg)
+#else
+#define META_ASSERT_CONCAT(a, b) a ## b
+#define META_ASSERT_CONCAT2(a, b) META_ASSERT_CONCAT(a, b)
+#define META_ASSERT_MSG(condition, msg) typedef int META_ASSERT_CONCAT2(COMPILE_TIME_ASSERT_, __LINE__)[static_cast&lt;bool&gt;(condition)?1:-1]
+#endif
+#define META_ASSERT(condition) META_ASSERT_MSG(condition, &quot;compile time assertion failed.&quot;)
</ins><span class="cx"> 
</span><span class="cx"> #endif   // COMMON_DEBUG_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonevent_tracercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/common/event_tracer.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/event_tracer.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/common/event_tracer.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx"> extern &quot;C&quot; {
</span><span class="cx"> 
</span><span class="cx"> void TRACE_ENTRY SetTraceFunctionPointers(GetCategoryEnabledFlagFunc getCategoryEnabledFlag,
</span><del>-                                        AddTraceEventFunc addTraceEvent)
</del><ins>+                                          AddTraceEventFunc addTraceEvent)
</ins><span class="cx"> {
</span><span class="cx">     gl::g_getCategoryEnabledFlag = getCategoryEnabledFlag;
</span><span class="cx">     gl::g_addTraceEvent = addTraceEvent;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonmathutilcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/common/mathutil.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/mathutil.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/common/mathutil.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+//
+// 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.
+//
+
+// mathutil.cpp: Math and bit manipulation functions.
+
+#include &quot;common/mathutil.h&quot;
+#include &lt;algorithm&gt;
+#include &lt;math.h&gt;
+
+namespace gl
+{
+
+struct RGB9E5Data
+{
+    unsigned int R : 9;
+    unsigned int G : 9;
+    unsigned int B : 9;
+    unsigned int E : 5;
+};
+
+// B is the exponent bias (15)
+static const int g_sharedexp_bias = 15;
+
+// N is the number of mantissa bits per component (9)
+static const int g_sharedexp_mantissabits = 9;
+
+// Emax is the maximum allowed biased exponent value (31)
+static const int g_sharedexp_maxexponent = 31;
+
+static const float g_sharedexp_max = ((pow(2.0f, g_sharedexp_mantissabits) - 1) /
+                                       pow(2.0f, g_sharedexp_mantissabits)) *
+                                     pow(2.0f, g_sharedexp_maxexponent - g_sharedexp_bias);
+
+unsigned int convertRGBFloatsTo999E5(float red, float green, float blue)
+{
+    const float red_c = std::max&lt;float&gt;(0, std::min(g_sharedexp_max, red));
+    const float green_c = std::max&lt;float&gt;(0, std::min(g_sharedexp_max, green));
+    const float blue_c = std::max&lt;float&gt;(0, std::min(g_sharedexp_max, blue));
+
+    const float max_c = std::max&lt;float&gt;(std::max&lt;float&gt;(red_c, green_c), blue_c);
+    const float exp_p = std::max&lt;float&gt;(-g_sharedexp_bias - 1, floor(log(max_c))) + 1 + g_sharedexp_bias;
+    const int max_s = floor((max_c / (pow(2.0f, exp_p - g_sharedexp_bias - g_sharedexp_mantissabits))) + 0.5f);
+    const int exp_s = (max_s &lt; pow(2.0f, g_sharedexp_mantissabits)) ? exp_p : exp_p + 1;
+
+    RGB9E5Data output;
+    output.R = floor((red_c / (pow(2.0f, exp_s - g_sharedexp_bias - g_sharedexp_mantissabits))) + 0.5f);
+    output.G = floor((green_c / (pow(2.0f, exp_s - g_sharedexp_bias - g_sharedexp_mantissabits))) + 0.5f);
+    output.B = floor((blue_c / (pow(2.0f, exp_s - g_sharedexp_bias - g_sharedexp_mantissabits))) + 0.5f);
+    output.E = exp_s;
+
+    return *reinterpret_cast&lt;unsigned int*&gt;(&amp;output);
+}
+
+void convert999E5toRGBFloats(unsigned int input, float *red, float *green, float *blue)
+{
+    const RGB9E5Data *inputData = reinterpret_cast&lt;const RGB9E5Data*&gt;(&amp;input);
+
+    *red = inputData-&gt;R * pow(2.0f, (int)inputData-&gt;E - g_sharedexp_bias - g_sharedexp_mantissabits);
+    *green = inputData-&gt;G * pow(2.0f, (int)inputData-&gt;E - g_sharedexp_bias - g_sharedexp_mantissabits);
+    *blue = inputData-&gt;B * pow(2.0f, (int)inputData-&gt;E - g_sharedexp_bias - g_sharedexp_mantissabits);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonmathutilh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/common/mathutil.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/mathutil.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/common/mathutil.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,540 @@
</span><ins>+//
+// Copyright (c) 2002-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.
+//
+
+// mathutil.h: Math and bit manipulation functions.
+
+#ifndef LIBGLESV2_MATHUTIL_H_
+#define LIBGLESV2_MATHUTIL_H_
+
+#include &quot;common/debug.h&quot;
+
+#if defined(_WIN32)
+#include &lt;intrin.h&gt;
+#endif
+
+#include &lt;limits&gt;
+#include &lt;algorithm&gt;
+#include &lt;string.h&gt;
+
+namespace gl
+{
+
+const unsigned int Float32One = 0x3F800000;
+const unsigned short Float16One = 0x3C00;
+
+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 &amp; (x - 1)) == 0 &amp;&amp; (x != 0);
+}
+
+inline int log2(int x)
+{
+    int r = 0;
+    while ((x &gt;&gt; r) &gt; 1) r++;
+    return r;
+}
+
+inline unsigned int ceilPow2(unsigned int x)
+{
+    if (x != 0) x--;
+    x |= x &gt;&gt; 1;
+    x |= x &gt;&gt; 2;
+    x |= x &gt;&gt; 4;
+    x |= x &gt;&gt; 8;
+    x |= x &gt;&gt; 16;
+    x++;
+
+    return x;
+}
+
+inline int clampToInt(unsigned int x)
+{
+    return static_cast&lt;int&gt;(std::min(x, static_cast&lt;unsigned int&gt;(std::numeric_limits&lt;int&gt;::max())));
+}
+
+template &lt;typename DestT, typename SrcT&gt;
+inline DestT clampCast(SrcT value)
+{
+    // This assumes SrcT can properly represent DestT::min/max
+    // Unfortunately we can't use META_ASSERT without C++11 constexpr support
+    ASSERT(static_cast&lt;DestT&gt;(static_cast&lt;SrcT&gt;(std::numeric_limits&lt;DestT&gt;::min())) == std::numeric_limits&lt;DestT&gt;::min());
+    ASSERT(static_cast&lt;DestT&gt;(static_cast&lt;SrcT&gt;(std::numeric_limits&lt;DestT&gt;::max())) == std::numeric_limits&lt;DestT&gt;::max());
+
+    SrcT lo = static_cast&lt;SrcT&gt;(std::numeric_limits&lt;DestT&gt;::min());
+    SrcT hi = static_cast&lt;SrcT&gt;(std::numeric_limits&lt;DestT&gt;::max());
+    return static_cast&lt;DestT&gt;(value &gt; lo ? (value &gt; hi ? hi : value) : lo);
+}
+
+template&lt;typename T, typename MIN, typename MAX&gt;
+inline T clamp(T x, MIN min, MAX max)
+{
+    // Since NaNs fail all comparison tests, a NaN value will default to min
+    return x &gt; min ? (x &gt; max ? max : x) : min;
+}
+
+inline float clamp01(float x)
+{
+    return clamp(x, 0.0f, 1.0f);
+}
+
+template&lt;const int n&gt;
+inline unsigned int unorm(float x)
+{
+    const unsigned int max = 0xFFFFFFFF &gt;&gt; (32 - n);
+
+    if (x &gt; 1)
+    {
+        return max;
+    }
+    else if (x &lt; 0)
+    {
+        return 0;
+    }
+    else
+    {
+        return (unsigned int)(max * x + 0.5f);
+    }
+}
+
+inline bool supportsSSE2()
+{
+#if defined(_WIN32)
+    static bool checked = false;
+    static bool supports = false;
+
+    if (checked)
+    {
+        return supports;
+    }
+
+    int info[4];
+    __cpuid(info, 0);
+
+    if (info[0] &gt;= 1)
+    {
+        __cpuid(info, 1);
+
+        supports = (info[3] &gt;&gt; 26) &amp; 1;
+    }
+
+    checked = true;
+
+    return supports;
+#else
+    UNIMPLEMENTED();
+    return false;
+#endif
+}
+
+template &lt;typename destType, typename sourceType&gt;
+destType bitCast(const sourceType &amp;source)
+{
+    size_t copySize = std::min(sizeof(destType), sizeof(sourceType));
+    destType output;
+    memcpy(&amp;output, &amp;source, copySize);
+    return output;
+}
+
+inline unsigned short float32ToFloat16(float fp32)
+{
+    unsigned int fp32i = (unsigned int&amp;)fp32;
+    unsigned int sign = (fp32i &amp; 0x80000000) &gt;&gt; 16;
+    unsigned int abs = fp32i &amp; 0x7FFFFFFF;
+
+    if(abs &gt; 0x47FFEFFF)   // Infinity
+    {
+        return sign | 0x7FFF;
+    }
+    else if(abs &lt; 0x38800000)   // Denormal
+    {
+        unsigned int mantissa = (abs &amp; 0x007FFFFF) | 0x00800000;
+        int e = 113 - (abs &gt;&gt; 23);
+
+        if(e &lt; 24)
+        {
+            abs = mantissa &gt;&gt; e;
+        }
+        else
+        {
+            abs = 0;
+        }
+
+        return sign | (abs + 0x00000FFF + ((abs &gt;&gt; 13) &amp; 1)) &gt;&gt; 13;
+    }
+    else
+    {
+        return sign | (abs + 0xC8000000 + 0x00000FFF + ((abs &gt;&gt; 13) &amp; 1)) &gt;&gt; 13;
+    }
+}
+
+float float16ToFloat32(unsigned short h);
+
+unsigned int convertRGBFloatsTo999E5(float red, float green, float blue);
+void convert999E5toRGBFloats(unsigned int input, float *red, float *green, float *blue);
+
+inline unsigned short float32ToFloat11(float fp32)
+{
+    const unsigned int float32MantissaMask = 0x7FFFFF;
+    const unsigned int float32ExponentMask = 0x7F800000;
+    const unsigned int float32SignMask = 0x80000000;
+    const unsigned int float32ValueMask = ~float32SignMask;
+    const unsigned int float32ExponentFirstBit = 23;
+    const unsigned int float32ExponentBias = 127;
+
+    const unsigned short float11Max = 0x7BF;
+    const unsigned short float11MantissaMask = 0x3F;
+    const unsigned short float11ExponentMask = 0x7C0;
+    const unsigned short float11BitMask = 0x7FF;
+    const unsigned int float11ExponentBias = 14;
+
+    const unsigned int float32Maxfloat11 = 0x477E0000;
+    const unsigned int float32Minfloat11 = 0x38800000;
+
+    const unsigned int float32Bits = bitCast&lt;unsigned int&gt;(fp32);
+    const bool float32Sign = (float32Bits &amp; float32SignMask) == float32SignMask;
+
+    unsigned int float32Val = float32Bits &amp; float32ValueMask;
+
+    if ((float32Val &amp; float32ExponentMask) == float32ExponentMask)
+    {
+        // INF or NAN
+        if ((float32Val &amp; float32MantissaMask) != 0)
+        {
+            return float11ExponentMask | (((float32Val &gt;&gt; 17) | (float32Val &gt;&gt; 11) | (float32Val &gt;&gt; 6) | (float32Val)) &amp; float11MantissaMask);
+        }
+        else if (float32Sign)
+        {
+            // -INF is clamped to 0 since float11 is positive only
+            return 0;
+        }
+        else
+        {
+            return float11ExponentMask;
+        }
+    }
+    else if (float32Sign)
+    {
+        // float11 is positive only, so clamp to zero
+        return 0;
+    }
+    else if (float32Val &gt; float32Maxfloat11)
+    {
+        // The number is too large to be represented as a float11, set to max
+        return float11Max;
+    }
+    else
+    {
+        if (float32Val &lt; float32Minfloat11)
+        {
+            // The number is too small to be represented as a normalized float11
+            // Convert it to a denormalized value.
+            const unsigned int shift = (float32ExponentBias - float11ExponentBias) - (float32Val &gt;&gt; float32ExponentFirstBit);
+            float32Val = ((1 &lt;&lt; float32ExponentFirstBit) | (float32Val &amp; float32MantissaMask)) &gt;&gt; shift;
+        }
+        else
+        {
+            // Rebias the exponent to represent the value as a normalized float11
+            float32Val += 0xC8000000;
+        }
+
+        return ((float32Val + 0xFFFF + ((float32Val &gt;&gt; 17) &amp; 1)) &gt;&gt; 17) &amp; float11BitMask;
+    }
+}
+
+inline unsigned short float32ToFloat10(float fp32)
+{
+    const unsigned int float32MantissaMask = 0x7FFFFF;
+    const unsigned int float32ExponentMask = 0x7F800000;
+    const unsigned int float32SignMask = 0x80000000;
+    const unsigned int float32ValueMask = ~float32SignMask;
+    const unsigned int float32ExponentFirstBit = 23;
+    const unsigned int float32ExponentBias = 127;
+
+    const unsigned short float10Max = 0x3DF;
+    const unsigned short float10MantissaMask = 0x1F;
+    const unsigned short float10ExponentMask = 0x3E0;
+    const unsigned short float10BitMask = 0x3FF;
+    const unsigned int float10ExponentBias = 14;
+
+    const unsigned int float32Maxfloat10 = 0x477C0000;
+    const unsigned int float32Minfloat10 = 0x38800000;
+
+    const unsigned int float32Bits = bitCast&lt;unsigned int&gt;(fp32);
+    const bool float32Sign = (float32Bits &amp; float32SignMask) == float32SignMask;
+
+    unsigned int float32Val = float32Bits &amp; float32ValueMask;
+
+    if ((float32Val &amp; float32ExponentMask) == float32ExponentMask)
+    {
+        // INF or NAN
+        if ((float32Val &amp; float32MantissaMask) != 0)
+        {
+            return float10ExponentMask | (((float32Val &gt;&gt; 18) | (float32Val &gt;&gt; 13) | (float32Val &gt;&gt; 3) | (float32Val)) &amp; float10MantissaMask);
+        }
+        else if (float32Sign)
+        {
+            // -INF is clamped to 0 since float11 is positive only
+            return 0;
+        }
+        else
+        {
+            return float10ExponentMask;
+        }
+    }
+    else if (float32Sign)
+    {
+        // float10 is positive only, so clamp to zero
+        return 0;
+    }
+    else if (float32Val &gt; float32Maxfloat10)
+    {
+        // The number is too large to be represented as a float11, set to max
+        return float10Max;
+    }
+    else
+    {
+        if (float32Val &lt; float32Minfloat10)
+        {
+            // The number is too small to be represented as a normalized float11
+            // Convert it to a denormalized value.
+            const unsigned int shift = (float32ExponentBias - float10ExponentBias) - (float32Val &gt;&gt; float32ExponentFirstBit);
+            float32Val = ((1 &lt;&lt; float32ExponentFirstBit) | (float32Val &amp; float32MantissaMask)) &gt;&gt; shift;
+        }
+        else
+        {
+            // Rebias the exponent to represent the value as a normalized float11
+            float32Val += 0xC8000000;
+        }
+
+        return ((float32Val + 0x1FFFF + ((float32Val &gt;&gt; 18) &amp; 1)) &gt;&gt; 18) &amp; float10BitMask;
+    }
+}
+
+inline float float11ToFloat32(unsigned short fp11)
+{
+    unsigned short exponent = (fp11 &gt;&gt; 6) &amp; 0x1F;
+    unsigned short mantissa = fp11 &amp; 0x3F;
+
+    if (exponent == 0x1F)
+    {
+        // INF or NAN
+        return bitCast&lt;float&gt;(0x7f800000 | (mantissa &lt;&lt; 17));
+    }
+    else
+    {
+        if (exponent != 0)
+        {
+            // normalized
+        }
+        else if (mantissa != 0)
+        {
+            // The value is denormalized
+            exponent = 1;
+
+            do
+            {
+                exponent--;
+                mantissa &lt;&lt;= 1;
+            }
+            while ((mantissa &amp; 0x40) == 0);
+
+            mantissa = mantissa &amp; 0x3F;
+        }
+        else // The value is zero
+        {
+            exponent = -112;
+        }
+
+        return bitCast&lt;float&gt;(((exponent + 112) &lt;&lt; 23) | (mantissa &lt;&lt; 17));
+    }
+}
+
+inline float float10ToFloat32(unsigned short fp11)
+{
+    unsigned short exponent = (fp11 &gt;&gt; 5) &amp; 0x1F;
+    unsigned short mantissa = fp11 &amp; 0x1F;
+
+    if (exponent == 0x1F)
+    {
+        // INF or NAN
+        return bitCast&lt;float&gt;(0x7f800000 | (mantissa &lt;&lt; 17));
+    }
+    else
+    {
+        if (exponent != 0)
+        {
+            // normalized
+        }
+        else if (mantissa != 0)
+        {
+            // The value is denormalized
+            exponent = 1;
+
+            do
+            {
+                exponent--;
+                mantissa &lt;&lt;= 1;
+            }
+            while ((mantissa &amp; 0x20) == 0);
+
+            mantissa = mantissa &amp; 0x1F;
+        }
+        else // The value is zero
+        {
+            exponent = -112;
+        }
+
+        return bitCast&lt;float&gt;(((exponent + 112) &lt;&lt; 23) | (mantissa &lt;&lt; 18));
+    }
+}
+
+template &lt;typename T&gt;
+inline float normalizedToFloat(T input)
+{
+    META_ASSERT(std::numeric_limits&lt;T&gt;::is_integer);
+
+    const float inverseMax = 1.0f / std::numeric_limits&lt;T&gt;::max();
+    return input * inverseMax;
+}
+
+template &lt;unsigned int inputBitCount, typename T&gt;
+inline float normalizedToFloat(T input)
+{
+    META_ASSERT(std::numeric_limits&lt;T&gt;::is_integer);
+    META_ASSERT(inputBitCount &lt; (sizeof(T) * 8));
+
+    const float inverseMax = 1.0f / ((1 &lt;&lt; inputBitCount) - 1);
+    return input * inverseMax;
+}
+
+template &lt;typename T&gt;
+inline T floatToNormalized(float input)
+{
+    return std::numeric_limits&lt;T&gt;::max() * input + 0.5f;
+}
+
+template &lt;unsigned int outputBitCount, typename T&gt;
+inline T floatToNormalized(float input)
+{
+    META_ASSERT(outputBitCount &lt; (sizeof(T) * 8));
+    return ((1 &lt;&lt; outputBitCount) - 1) * input + 0.5f;
+}
+
+template &lt;unsigned int inputBitCount, unsigned int inputBitStart, typename T&gt;
+inline T getShiftedData(T input)
+{
+    META_ASSERT(inputBitCount + inputBitStart &lt;= (sizeof(T) * 8));
+    const T mask = (1 &lt;&lt; inputBitCount) - 1;
+    return (input &gt;&gt; inputBitStart) &amp; mask;
+}
+
+template &lt;unsigned int inputBitCount, unsigned int inputBitStart, typename T&gt;
+inline T shiftData(T input)
+{
+    META_ASSERT(inputBitCount + inputBitStart &lt;= (sizeof(T) * 8));
+    const T mask = (1 &lt;&lt; inputBitCount) - 1;
+    return (input &amp; mask) &lt;&lt; inputBitStart;
+}
+
+
+inline unsigned char average(unsigned char a, unsigned char b)
+{
+    return ((a ^ b) &gt;&gt; 1) + (a &amp; b);
+}
+
+inline signed char average(signed char a, signed char b)
+{
+    return ((short)a + (short)b) / 2;
+}
+
+inline unsigned short average(unsigned short a, unsigned short b)
+{
+    return ((a ^ b) &gt;&gt; 1) + (a &amp; b);
+}
+
+inline signed short average(signed short a, signed short b)
+{
+    return ((int)a + (int)b) / 2;
+}
+
+inline unsigned int average(unsigned int a, unsigned int b)
+{
+    return ((a ^ b) &gt;&gt; 1) + (a &amp; b);
+}
+
+inline signed int average(signed int a, signed int b)
+{
+    return (signed int)((long long)a + (long long)b) / 2;
+}
+
+inline float average(float a, float b)
+{
+    return (a + b) * 0.5f;
+}
+
+inline unsigned short averageHalfFloat(unsigned short a, unsigned short b)
+{
+    return float32ToFloat16((float16ToFloat32(a) + float16ToFloat32(b)) * 0.5f);
+}
+
+inline unsigned int averageFloat11(unsigned int a, unsigned int b)
+{
+    return float32ToFloat11((float11ToFloat32(a) + float11ToFloat32(b)) * 0.5f);
+}
+
+inline unsigned int averageFloat10(unsigned int a, unsigned int b)
+{
+    return float32ToFloat10((float10ToFloat32(a) + float10ToFloat32(b)) * 0.5f);
+}
+
+}
+
+namespace rx
+{
+
+struct Range
+{
+    Range() {}
+    Range(int lo, int hi) : start(lo), end(hi) { ASSERT(lo &lt;= hi); }
+
+    int start;
+    int end;
+};
+
+template &lt;typename T&gt;
+T roundUp(const T value, const T alignment)
+{
+    return value + alignment - 1 - (value - 1) % alignment;
+}
+
+template &lt;class T&gt;
+inline bool IsUnsignedAdditionSafe(T lhs, T rhs)
+{
+    META_ASSERT(!std::numeric_limits&lt;T&gt;::is_signed);
+    return (rhs &lt;= std::numeric_limits&lt;T&gt;::max() - lhs);
+}
+
+template &lt;class T&gt;
+inline bool IsUnsignedMultiplicationSafe(T lhs, T rhs)
+{
+    META_ASSERT(!std::numeric_limits&lt;T&gt;::is_signed);
+    return (lhs == T(0) || rhs == T(0) || (rhs &lt;= std::numeric_limits&lt;T&gt;::max() / lhs));
+}
+
+}
+
+#endif   // LIBGLESV2_MATHUTIL_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonshadervarscpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/common/shadervars.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/shadervars.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/common/shadervars.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,81 @@
</span><ins>+//
+// Copyright (c) 2013-2014 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.
+//
+// shadervars.cpp:
+//   Implementation for GL shader variable member functions.
+//
+
+#include &quot;common/shadervars.h&quot;
+
+namespace gl
+{
+
+ShaderVariable::ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
+    : type(typeIn),
+      precision(precisionIn),
+      name(nameIn),
+      arraySize(arraySizeIn)
+{
+}
+
+Uniform::Uniform(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, unsigned int registerIndexIn, unsigned int elementIndexIn)
+    : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
+      registerIndex(registerIndexIn),
+      elementIndex(elementIndexIn)
+{
+}
+
+Attribute::Attribute()
+    : ShaderVariable(GL_NONE, GL_NONE, &quot;&quot;, 0),
+      location(-1)
+{
+}
+
+Attribute::Attribute(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, int locationIn)
+    : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
+      location(locationIn)
+{
+}
+
+InterfaceBlockField::InterfaceBlockField(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, bool isRowMajorMatrix)
+    : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
+      isRowMajorMatrix(isRowMajorMatrix)
+{
+}
+
+Varying::Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn)
+    : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
+      interpolation(interpolationIn),
+      registerIndex(GL_INVALID_INDEX),
+      elementIndex(GL_INVALID_INDEX)
+{
+}
+
+void Varying::resetRegisterAssignment()
+{
+    registerIndex = GL_INVALID_INDEX;
+    elementIndex = GL_INVALID_INDEX;
+}
+
+BlockMemberInfo::BlockMemberInfo(long offset, long arrayStride, long matrixStride, bool isRowMajorMatrix)
+    : offset(offset),
+      arrayStride(arrayStride),
+      matrixStride(matrixStride),
+      isRowMajorMatrix(isRowMajorMatrix)
+{
+}
+
+const BlockMemberInfo BlockMemberInfo::defaultBlockInfo(-1, -1, -1, false);
+
+InterfaceBlock::InterfaceBlock(const char *name, unsigned int arraySize, unsigned int registerIndex)
+    : name(name),
+      arraySize(arraySize),
+      layout(BLOCKLAYOUT_SHARED),
+      registerIndex(registerIndex),
+      isRowMajorLayout(false)
+{
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonshadervarsh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/common/shadervars.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/shadervars.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/common/shadervars.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,127 @@
</span><ins>+//
+// Copyright (c) 2013-2014 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.
+//
+// shadervars.h:
+//  Types to represent GL variables (varyings, uniforms, etc)
+//
+
+#ifndef COMMON_SHADERVARIABLE_H_
+#define COMMON_SHADERVARIABLE_H_
+
+#include &lt;string&gt;
+#include &lt;vector&gt;
+#include &lt;algorithm&gt;
+
+#define GL_APICALL
+#include &lt;GLES3/gl3.h&gt;
+#include &lt;GLES2/gl2.h&gt;
+
+namespace gl
+{
+
+enum InterpolationType
+{
+    INTERPOLATION_SMOOTH,
+    INTERPOLATION_CENTROID,
+    INTERPOLATION_FLAT
+};
+
+struct ShaderVariable
+{
+    GLenum type;
+    GLenum precision;
+    std::string name;
+    unsigned int arraySize;
+
+    ShaderVariable(GLenum type, GLenum precision, const char *name, unsigned int arraySize);
+    bool isArray() const { return arraySize &gt; 0; }
+    unsigned int elementCount() const { return std::max(1u, arraySize); }
+};
+
+struct Uniform : public ShaderVariable
+{
+    unsigned long registerIndex;
+    unsigned long elementIndex;     // For struct varyings
+    std::vector&lt;Uniform&gt; fields;
+
+    Uniform(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn,
+            unsigned int registerIndexIn, unsigned int elementIndexIn);
+
+    bool isStruct() const { return !fields.empty(); }
+};
+
+struct Attribute : public ShaderVariable
+{
+    int location;
+
+    Attribute();
+    Attribute(GLenum type, GLenum precision, const char *name, unsigned int arraySize, int location);
+};
+
+struct InterfaceBlockField : public ShaderVariable
+{
+    bool isRowMajorMatrix;
+    std::vector&lt;InterfaceBlockField&gt; fields;
+
+    InterfaceBlockField(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, bool isRowMajorMatrix);
+
+    bool isStruct() const { return !fields.empty(); }
+};
+
+struct Varying : public ShaderVariable
+{
+    InterpolationType interpolation;
+    std::vector&lt;Varying&gt; fields;
+    unsigned int registerIndex;    // Assigned during link
+    unsigned int elementIndex;     // First register element for varyings, assigned during link
+    std::string structName;
+
+    Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn);
+
+    bool isStruct() const { return !fields.empty(); }
+    bool registerAssigned() const { return registerIndex != GL_INVALID_INDEX; }
+
+    void resetRegisterAssignment();
+};
+
+struct BlockMemberInfo
+{
+    BlockMemberInfo(long offset, long arrayStride, long matrixStride, bool isRowMajorMatrix);
+
+    long offset;
+    long arrayStride;
+    long matrixStride;
+    bool isRowMajorMatrix;
+
+    static const BlockMemberInfo defaultBlockInfo;
+};
+
+typedef std::vector&lt;BlockMemberInfo&gt; BlockMemberInfoArray;
+
+enum BlockLayoutType
+{
+    BLOCKLAYOUT_STANDARD,
+    BLOCKLAYOUT_PACKED,
+    BLOCKLAYOUT_SHARED
+};
+
+struct InterfaceBlock
+{
+    InterfaceBlock(const char *name, unsigned int arraySize, unsigned int registerIndex);
+
+    std::string name;
+    unsigned int arraySize;
+    size_t dataSize;
+    BlockLayoutType layout;
+    bool isRowMajorLayout;
+    std::vector&lt;InterfaceBlockField&gt; fields;
+    std::vector&lt;BlockMemberInfo&gt; blockInfo;
+
+    unsigned int registerIndex;
+};
+
+}
+
+#endif // COMMON_SHADERVARIABLE_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonutilitiescpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/common/utilities.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/utilities.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/common/utilities.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,473 @@
</span><ins>+//
+// Copyright (c) 2002-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.
+//
+
+// utilities.cpp: Conversion functions and other utility routines.
+
+#include &quot;common/utilities.h&quot;
+#include &quot;common/mathutil.h&quot;
+
+#if defined(_WIN32)
+#include &lt;windows.h&gt;
+#endif
+
+#include &lt;set&gt;
+
+namespace gl
+{
+
+int UniformComponentCount(GLenum type)
+{
+    switch (type)
+    {
+      case GL_BOOL:
+      case GL_FLOAT:
+      case GL_INT:
+      case GL_SAMPLER_2D:
+      case GL_SAMPLER_3D:
+      case GL_SAMPLER_CUBE:
+      case GL_SAMPLER_2D_ARRAY:
+      case GL_INT_SAMPLER_2D:
+      case GL_INT_SAMPLER_3D:
+      case GL_INT_SAMPLER_CUBE:
+      case GL_INT_SAMPLER_2D_ARRAY:
+      case GL_UNSIGNED_INT_SAMPLER_2D:
+      case GL_UNSIGNED_INT_SAMPLER_3D:
+      case GL_UNSIGNED_INT_SAMPLER_CUBE:
+      case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
+      case GL_SAMPLER_2D_SHADOW:
+      case GL_SAMPLER_CUBE_SHADOW:
+      case GL_SAMPLER_2D_ARRAY_SHADOW:
+      case GL_UNSIGNED_INT:
+        return 1;
+      case GL_BOOL_VEC2:
+      case GL_FLOAT_VEC2:
+      case GL_INT_VEC2:
+      case GL_UNSIGNED_INT_VEC2:
+        return 2;
+      case GL_INT_VEC3:
+      case GL_FLOAT_VEC3:
+      case GL_BOOL_VEC3:
+      case GL_UNSIGNED_INT_VEC3:
+        return 3;
+      case GL_BOOL_VEC4:
+      case GL_FLOAT_VEC4:
+      case GL_INT_VEC4:
+      case GL_UNSIGNED_INT_VEC4:
+      case GL_FLOAT_MAT2:
+        return 4;
+      case GL_FLOAT_MAT2x3:
+      case GL_FLOAT_MAT3x2:
+        return 6;
+      case GL_FLOAT_MAT2x4:
+      case GL_FLOAT_MAT4x2:
+        return 8;
+      case GL_FLOAT_MAT3:
+        return 9;
+      case GL_FLOAT_MAT3x4:
+      case GL_FLOAT_MAT4x3:
+        return 12;
+      case GL_FLOAT_MAT4:
+        return 16;
+      default:
+        UNREACHABLE();
+    }
+
+    return 0;
+}
+
+GLenum UniformComponentType(GLenum type)
+{
+    switch(type)
+    {
+      case GL_BOOL:
+      case GL_BOOL_VEC2:
+      case GL_BOOL_VEC3:
+      case GL_BOOL_VEC4:
+        return GL_BOOL;
+      case GL_FLOAT:
+      case GL_FLOAT_VEC2:
+      case GL_FLOAT_VEC3:
+      case GL_FLOAT_VEC4:
+      case GL_FLOAT_MAT2:
+      case GL_FLOAT_MAT3:
+      case GL_FLOAT_MAT4:
+      case GL_FLOAT_MAT2x3:
+      case GL_FLOAT_MAT3x2:
+      case GL_FLOAT_MAT2x4:
+      case GL_FLOAT_MAT4x2:
+      case GL_FLOAT_MAT3x4:
+      case GL_FLOAT_MAT4x3:
+        return GL_FLOAT;
+      case GL_INT:
+      case GL_SAMPLER_2D:
+      case GL_SAMPLER_3D:
+      case GL_SAMPLER_CUBE:
+      case GL_SAMPLER_2D_ARRAY:
+      case GL_INT_SAMPLER_2D:
+      case GL_INT_SAMPLER_3D:
+      case GL_INT_SAMPLER_CUBE:
+      case GL_INT_SAMPLER_2D_ARRAY:
+      case GL_UNSIGNED_INT_SAMPLER_2D:
+      case GL_UNSIGNED_INT_SAMPLER_3D:
+      case GL_UNSIGNED_INT_SAMPLER_CUBE:
+      case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
+      case GL_SAMPLER_2D_SHADOW:
+      case GL_SAMPLER_CUBE_SHADOW:
+      case GL_SAMPLER_2D_ARRAY_SHADOW:
+      case GL_INT_VEC2:
+      case GL_INT_VEC3:
+      case GL_INT_VEC4:
+        return GL_INT;
+      case GL_UNSIGNED_INT:
+      case GL_UNSIGNED_INT_VEC2:
+      case GL_UNSIGNED_INT_VEC3:
+      case GL_UNSIGNED_INT_VEC4:
+        return GL_UNSIGNED_INT;
+      default:
+        UNREACHABLE();
+    }
+
+    return GL_NONE;
+}
+
+size_t UniformComponentSize(GLenum type)
+{
+    switch(type)
+    {
+      case GL_BOOL:         return sizeof(GLint);
+      case GL_FLOAT:        return sizeof(GLfloat);
+      case GL_INT:          return sizeof(GLint);
+      case GL_UNSIGNED_INT: return sizeof(GLuint);
+      default:       UNREACHABLE();
+    }
+
+    return 0;
+}
+
+size_t UniformInternalSize(GLenum type)
+{
+    // Expanded to 4-element vectors
+    return UniformComponentSize(UniformComponentType(type)) * VariableRowCount(type) * 4;
+}
+
+size_t UniformExternalSize(GLenum type)
+{
+    return UniformComponentSize(UniformComponentType(type)) * UniformComponentCount(type);
+}
+
+GLenum UniformBoolVectorType(GLenum type)
+{
+    switch (type)
+    {
+      case GL_FLOAT:
+      case GL_INT:
+      case GL_UNSIGNED_INT:
+        return GL_BOOL;
+      case GL_FLOAT_VEC2:
+      case GL_INT_VEC2:
+      case GL_UNSIGNED_INT_VEC2:
+        return GL_BOOL_VEC2;
+      case GL_FLOAT_VEC3:
+      case GL_INT_VEC3:
+      case GL_UNSIGNED_INT_VEC3:
+        return GL_BOOL_VEC3;
+      case GL_FLOAT_VEC4:
+      case GL_INT_VEC4:
+      case GL_UNSIGNED_INT_VEC4:
+        return GL_BOOL_VEC4;
+
+      default:
+        UNREACHABLE();
+        return GL_NONE;
+    }
+}
+
+int VariableRowCount(GLenum type)
+{
+    switch (type)
+    {
+      case GL_NONE:
+      case GL_STRUCT_ANGLEX:
+        return 0;
+      case GL_BOOL:
+      case GL_FLOAT:
+      case GL_INT:
+      case GL_UNSIGNED_INT:
+      case GL_BOOL_VEC2:
+      case GL_FLOAT_VEC2:
+      case GL_INT_VEC2:
+      case GL_UNSIGNED_INT_VEC2:
+      case GL_BOOL_VEC3:
+      case GL_FLOAT_VEC3:
+      case GL_INT_VEC3:
+      case GL_UNSIGNED_INT_VEC3:
+      case GL_BOOL_VEC4:
+      case GL_FLOAT_VEC4:
+      case GL_INT_VEC4:
+      case GL_UNSIGNED_INT_VEC4:
+      case GL_SAMPLER_2D:
+      case GL_SAMPLER_3D:
+      case GL_SAMPLER_CUBE:
+      case GL_SAMPLER_2D_ARRAY:
+      case GL_INT_SAMPLER_2D:
+      case GL_INT_SAMPLER_3D:
+      case GL_INT_SAMPLER_CUBE:
+      case GL_INT_SAMPLER_2D_ARRAY:
+      case GL_UNSIGNED_INT_SAMPLER_2D:
+      case GL_UNSIGNED_INT_SAMPLER_3D:
+      case GL_UNSIGNED_INT_SAMPLER_CUBE:
+      case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
+      case GL_SAMPLER_2D_SHADOW:
+      case GL_SAMPLER_CUBE_SHADOW:
+      case GL_SAMPLER_2D_ARRAY_SHADOW:
+        return 1;
+      case GL_FLOAT_MAT2:
+      case GL_FLOAT_MAT3x2:
+      case GL_FLOAT_MAT4x2:
+        return 2;
+      case GL_FLOAT_MAT3:
+      case GL_FLOAT_MAT2x3:
+      case GL_FLOAT_MAT4x3:
+        return 3;
+      case GL_FLOAT_MAT4:
+      case GL_FLOAT_MAT2x4:
+      case GL_FLOAT_MAT3x4:
+        return 4;
+      default:
+        UNREACHABLE();
+    }
+
+    return 0;
+}
+
+int VariableColumnCount(GLenum type)
+{
+    switch (type)
+    {
+      case GL_NONE:
+      case GL_STRUCT_ANGLEX:
+        return 0;
+      case GL_BOOL:
+      case GL_FLOAT:
+      case GL_INT:
+      case GL_UNSIGNED_INT:
+      case GL_SAMPLER_2D:
+      case GL_SAMPLER_3D:
+      case GL_SAMPLER_CUBE:
+      case GL_SAMPLER_2D_ARRAY:
+      case GL_INT_SAMPLER_2D:
+      case GL_INT_SAMPLER_3D:
+      case GL_INT_SAMPLER_CUBE:
+      case GL_INT_SAMPLER_2D_ARRAY:
+      case GL_UNSIGNED_INT_SAMPLER_2D:
+      case GL_UNSIGNED_INT_SAMPLER_3D:
+      case GL_UNSIGNED_INT_SAMPLER_CUBE:
+      case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
+      case GL_SAMPLER_2D_SHADOW:
+      case GL_SAMPLER_CUBE_SHADOW:
+      case GL_SAMPLER_2D_ARRAY_SHADOW:
+        return 1;
+      case GL_BOOL_VEC2:
+      case GL_FLOAT_VEC2:
+      case GL_INT_VEC2:
+      case GL_UNSIGNED_INT_VEC2:
+      case GL_FLOAT_MAT2:
+      case GL_FLOAT_MAT2x3:
+      case GL_FLOAT_MAT2x4:
+        return 2;
+      case GL_BOOL_VEC3:
+      case GL_FLOAT_VEC3:
+      case GL_INT_VEC3:
+      case GL_UNSIGNED_INT_VEC3:
+      case GL_FLOAT_MAT3:
+      case GL_FLOAT_MAT3x2:
+      case GL_FLOAT_MAT3x4:
+        return 3;
+      case GL_BOOL_VEC4:
+      case GL_FLOAT_VEC4:
+      case GL_INT_VEC4:
+      case GL_UNSIGNED_INT_VEC4:
+      case GL_FLOAT_MAT4:
+      case GL_FLOAT_MAT4x2:
+      case GL_FLOAT_MAT4x3:
+        return 4;
+      default:
+        UNREACHABLE();
+    }
+
+    return 0;
+}
+
+bool IsSampler(GLenum type)
+{
+    switch (type)
+    {
+      case GL_SAMPLER_2D:
+      case GL_SAMPLER_3D:
+      case GL_SAMPLER_CUBE:
+      case GL_SAMPLER_2D_ARRAY:
+      case GL_INT_SAMPLER_2D:
+      case GL_INT_SAMPLER_3D:
+      case GL_INT_SAMPLER_CUBE:
+      case GL_INT_SAMPLER_2D_ARRAY:
+      case GL_UNSIGNED_INT_SAMPLER_2D:
+      case GL_UNSIGNED_INT_SAMPLER_3D:
+      case GL_UNSIGNED_INT_SAMPLER_CUBE:
+      case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
+      case GL_SAMPLER_2D_SHADOW:
+      case GL_SAMPLER_CUBE_SHADOW:
+      case GL_SAMPLER_2D_ARRAY_SHADOW:
+        return true;
+    }
+
+    return false;
+}
+
+bool IsMatrixType(GLenum type)
+{
+    return VariableRowCount(type) &gt; 1;
+}
+
+GLenum TransposeMatrixType(GLenum type)
+{
+    if (!IsMatrixType(type))
+    {
+        return type;
+    }
+
+    switch (type)
+    {
+      case GL_FLOAT_MAT2:   return GL_FLOAT_MAT2;
+      case GL_FLOAT_MAT3:   return GL_FLOAT_MAT3;
+      case GL_FLOAT_MAT4:   return GL_FLOAT_MAT4;
+      case GL_FLOAT_MAT2x3: return GL_FLOAT_MAT3x2;
+      case GL_FLOAT_MAT3x2: return GL_FLOAT_MAT2x3;
+      case GL_FLOAT_MAT2x4: return GL_FLOAT_MAT4x2;
+      case GL_FLOAT_MAT4x2: return GL_FLOAT_MAT2x4;
+      case GL_FLOAT_MAT3x4: return GL_FLOAT_MAT4x3;
+      case GL_FLOAT_MAT4x3: return GL_FLOAT_MAT3x4;
+      default: UNREACHABLE(); return GL_NONE;
+    }
+}
+
+int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix)
+{
+    ASSERT(IsMatrixType(type));
+    return isRowMajorMatrix ? VariableRowCount(type) : VariableColumnCount(type);
+}
+
+int MatrixComponentCount(GLenum type, bool isRowMajorMatrix)
+{
+    ASSERT(IsMatrixType(type));
+    return isRowMajorMatrix ? VariableColumnCount(type) : VariableRowCount(type);
+}
+
+int AttributeRegisterCount(GLenum type)
+{
+    return IsMatrixType(type) ? VariableColumnCount(type) : 1;
+}
+
+int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize)
+{
+    ASSERT(allocationSize &lt;= bitsSize);
+
+    unsigned int mask = std::numeric_limits&lt;unsigned int&gt;::max() &gt;&gt; (std::numeric_limits&lt;unsigned int&gt;::digits - allocationSize);
+
+    for (unsigned int i = 0; i &lt; bitsSize - allocationSize + 1; i++)
+    {
+        if ((*bits &amp; mask) == 0)
+        {
+            *bits |= mask;
+            return i;
+        }
+
+        mask &lt;&lt;= 1;
+    }
+
+    return -1;
+}
+
+bool IsCubemapTextureTarget(GLenum target)
+{
+    return (target &gt;= GL_TEXTURE_CUBE_MAP_POSITIVE_X &amp;&amp; target &lt;= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
+}
+
+bool IsInternalTextureTarget(GLenum target, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target);
+    }
+    else if (clientVersion == 3)
+    {
+        return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target) ||
+               target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY;
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsTriangleMode(GLenum drawMode)
+{
+    switch (drawMode)
+    {
+      case GL_TRIANGLES:
+      case GL_TRIANGLE_FAN:
+      case GL_TRIANGLE_STRIP:
+        return true;
+      case GL_POINTS:
+      case GL_LINES:
+      case GL_LINE_LOOP:
+      case GL_LINE_STRIP:
+        return false;
+      default: UNREACHABLE();
+    }
+
+    return false;
+}
+
+}
+
+std::string getTempPath()
+{
+#if defined (_WIN32)
+    char path[MAX_PATH];
+    DWORD pathLen = GetTempPathA(sizeof(path) / sizeof(path[0]), path);
+    if (pathLen == 0)
+    {
+        UNREACHABLE();
+        return std::string();
+    }
+
+    UINT unique = GetTempFileNameA(path, &quot;sh&quot;, 0, path);
+    if (unique == 0)
+    {
+        UNREACHABLE();
+        return std::string();
+    }
+
+    return path;
+#else
+    UNIMPLEMENTED();
+    return &quot;&quot;;
+#endif
+}
+
+void writeFile(const char* path, const void* content, size_t size)
+{
+    FILE* file = fopen(path, &quot;w&quot;);
+    if (!file)
+    {
+        UNREACHABLE();
+        return;
+    }
+
+    fwrite(content, sizeof(char), size, file);
+    fclose(file);
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccommonutilitiesh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/common/utilities.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/common/utilities.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/common/utilities.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+//
+// Copyright (c) 2002-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.
+//
+
+// utilities.h: Conversion functions and other utility routines.
+
+#ifndef LIBGLESV2_UTILITIES_H
+#define LIBGLESV2_UTILITIES_H
+
+#ifndef GL_APICALL
+#define GL_APICALL
+#endif
+#include &lt;GLES3/gl3.h&gt;
+#include &lt;GLES3/gl3ext.h&gt;
+#include &lt;GLES2/gl2.h&gt;
+#include &lt;GLES2/gl2ext.h&gt;
+
+#include &lt;string&gt;
+#include &lt;math.h&gt;
+
+namespace gl
+{
+
+int UniformComponentCount(GLenum type);
+GLenum UniformComponentType(GLenum type);
+size_t UniformComponentSize(GLenum type);
+size_t UniformInternalSize(GLenum type);
+size_t UniformExternalSize(GLenum type);
+GLenum UniformBoolVectorType(GLenum type);
+int VariableRowCount(GLenum type);
+int VariableColumnCount(GLenum type);
+bool IsSampler(GLenum type);
+bool IsMatrixType(GLenum type);
+GLenum TransposeMatrixType(GLenum type);
+int AttributeRegisterCount(GLenum type);
+int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix);
+int MatrixComponentCount(GLenum type, bool isRowMajorMatrix);
+
+int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
+
+bool IsCubemapTextureTarget(GLenum target);
+bool IsInternalTextureTarget(GLenum target, GLuint clientVersion);
+
+bool IsTriangleMode(GLenum drawMode);
+
+// [OpenGL ES 3.0.2] Section 2.3.1 page 14
+// Data Conversion For State-Setting Commands
+// Floating-point values are rounded to the nearest integer, instead of truncated, as done by static_cast.
+template &lt;typename outT&gt; outT iround(GLfloat value) { return static_cast&lt;outT&gt;(value &gt; 0.0f ? floor(value + 0.5f) : ceil(value - 0.5f)); }
+template &lt;typename outT&gt; outT uiround(GLfloat value) { return static_cast&lt;outT&gt;(value + 0.5f); }
+
+}
+
+std::string getTempPath();
+void writeFile(const char* path, const void* data, size_t size);
+
+#endif  // LIBGLESV2_UTILITIES_H
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilerpreprocessorDirectiveParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/DirectiveParser.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/DirectiveParser.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/DirectiveParser.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2011-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -708,7 +708,9 @@
</span><span class="cx"> 
</span><span class="cx">     enum State
</span><span class="cx">     {
</span><del>-        VERSION_NUMBER
</del><ins>+        VERSION_NUMBER,
+        VERSION_PROFILE,
+        VERSION_ENDLINE
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     bool valid = true;
</span><span class="lines">@@ -716,12 +718,12 @@
</span><span class="cx">     int state = VERSION_NUMBER;
</span><span class="cx"> 
</span><span class="cx">     mTokenizer-&gt;lex(token);
</span><del>-    while ((token-&gt;type != '\n') &amp;&amp; (token-&gt;type != Token::LAST))
</del><ins>+    while (valid &amp;&amp; (token-&gt;type != '\n') &amp;&amp; (token-&gt;type != Token::LAST))
</ins><span class="cx">     {
</span><del>-        switch (state++)
</del><ins>+        switch (state)
</ins><span class="cx">         {
</span><span class="cx">           case VERSION_NUMBER:
</span><del>-            if (valid &amp;&amp; (token-&gt;type != Token::CONST_INT))
</del><ins>+            if (token-&gt;type != Token::CONST_INT)
</ins><span class="cx">             {
</span><span class="cx">                 mDiagnostics-&gt;report(Diagnostics::PP_INVALID_VERSION_NUMBER,
</span><span class="cx">                                      token-&gt;location, token-&gt;text);
</span><span class="lines">@@ -733,26 +735,41 @@
</span><span class="cx">                                      token-&gt;location, token-&gt;text);
</span><span class="cx">                 valid = false;
</span><span class="cx">             }
</span><del>-            break;
-          default:
</del><span class="cx">             if (valid)
</span><span class="cx">             {
</span><del>-                mDiagnostics-&gt;report(Diagnostics::PP_UNEXPECTED_TOKEN,
</del><ins>+                state = (version &lt; 300) ? VERSION_ENDLINE : VERSION_PROFILE;
+            }
+            break;
+          case VERSION_PROFILE:
+            if (token-&gt;type != Token::IDENTIFIER || token-&gt;text != &quot;es&quot;)
+            {
+                mDiagnostics-&gt;report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE,
</ins><span class="cx">                                      token-&gt;location, token-&gt;text);
</span><span class="cx">                 valid = false;
</span><span class="cx">             }
</span><ins>+            state = VERSION_ENDLINE;
</ins><span class="cx">             break;
</span><ins>+          default:
+            mDiagnostics-&gt;report(Diagnostics::PP_UNEXPECTED_TOKEN,
+                                 token-&gt;location, token-&gt;text);
+            valid = false;
+            break;
</ins><span class="cx">         }
</span><ins>+
</ins><span class="cx">         mTokenizer-&gt;lex(token);
</span><span class="cx">     }
</span><del>-    if (valid &amp;&amp; (state != VERSION_NUMBER + 1))
</del><ins>+
+    if (valid &amp;&amp; (state != VERSION_ENDLINE))
</ins><span class="cx">     {
</span><span class="cx">         mDiagnostics-&gt;report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE,
</span><span class="cx">                              token-&gt;location, token-&gt;text);
</span><span class="cx">         valid = false;
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     if (valid)
</span><ins>+    {
</ins><span class="cx">         mDirectiveHandler-&gt;handleVersion(token-&gt;location, version);
</span><ins>+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DirectiveParser::parseLine(Token* token)
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilerpreprocessorExpressionParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/ExpressionParser.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/ExpressionParser.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/ExpressionParser.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,10 +1,10 @@
</span><del>-/* A Bison parser, made by GNU Bison 2.7.  */
</del><ins>+/* A Bison parser, made by GNU Bison 2.7.1.  */
</ins><span class="cx"> 
</span><span class="cx"> /* Apple Note: For the avoidance of doubt, Apple elects to distribute this file under the terms of the BSD license. */
</span><span class="cx"> 
</span><span class="cx"> /* Bison implementation for Yacc-like parsers in C
</span><span class="cx">    
</span><del>-      Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
</del><ins>+      Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
</ins><span class="cx">    
</span><span class="cx">    This program is free software: you can redistribute it and/or modify
</span><span class="cx">    it under the terms of the GNU General Public License as published by
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> #define YYBISON 1
</span><span class="cx"> 
</span><span class="cx"> /* Bison version.  */
</span><del>-#define YYBISON_VERSION &quot;2.7&quot;
</del><ins>+#define YYBISON_VERSION &quot;2.7.1&quot;
</ins><span class="cx"> 
</span><span class="cx"> /* Skeleton name.  */
</span><span class="cx"> #define YYSKELETON_NAME &quot;yacc.c&quot;
</span><span class="lines">@@ -266,6 +266,14 @@
</span><span class="cx"> # endif
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if (! defined __GNUC__ || __GNUC__ &lt; 2 \
+      || (__GNUC__ == 2 &amp;&amp; __GNUC_MINOR__ &lt; 5))
+#  define __attribute__(Spec) /* empty */
+# endif
+#endif
+
</ins><span class="cx"> /* Suppress unused-variable warnings by &quot;using&quot; E.  */
</span><span class="cx"> #if ! defined lint || defined __GNUC__
</span><span class="cx"> # define YYUSE(E) ((void) (E))
</span><span class="lines">@@ -273,6 +281,7 @@
</span><span class="cx"> # define YYUSE(E) /* empty */
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> /* Identity function, used to suppress warnings about constant conditions.  */
</span><span class="cx"> #ifndef lint
</span><span class="cx"> # define YYID(N) (N)
</span><span class="lines">@@ -503,9 +512,9 @@
</span><span class="cx"> /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
</span><span class="cx"> static const yytype_uint8 yyrline[] =
</span><span class="cx"> {
</span><del>-       0,    91,    91,    98,    99,   102,   105,   108,   111,   114,
-     117,   120,   123,   126,   129,   132,   135,   138,   141,   144,
-     157,   170,   173,   176,   179,   182,   185
</del><ins>+       0,    97,    97,   104,   105,   108,   111,   114,   117,   120,
+     123,   126,   129,   132,   135,   138,   141,   144,   147,   150,
+     163,   176,   179,   182,   185,   188,   191
</ins><span class="cx"> };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -770,11 +779,7 @@
</span><span class="cx"> # else
</span><span class="cx">   YYUSE (yyoutput);
</span><span class="cx"> # endif
</span><del>-  switch (yytype)
-    {
-      default:
-        break;
-    }
</del><ins>+  YYUSE (yytype);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1168,12 +1173,7 @@
</span><span class="cx">     yymsg = &quot;Deleting&quot;;
</span><span class="cx">   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
</span><span class="cx"> 
</span><del>-  switch (yytype)
-    {
-
-      default:
-        break;
-    }
</del><ins>+  YYUSE (yytype);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilerpreprocessorExpressionParsery"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/ExpressionParser.y (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/ExpressionParser.y        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/ExpressionParser.y        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx">             std::ostringstream stream;
</span><span class="cx">             stream &lt;&lt; $1 &lt;&lt; &quot; % &quot; &lt;&lt; $3;
</span><span class="cx">             std::string text = stream.str();
</span><del>-            context-&gt;diagnostics-&gt;report(pp::Diagnostics::DIVISION_BY_ZERO,
</del><ins>+            context-&gt;diagnostics-&gt;report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
</ins><span class="cx">                                          context-&gt;token-&gt;location,
</span><span class="cx">                                          text.c_str());
</span><span class="cx">             YYABORT;
</span><span class="lines">@@ -165,7 +165,7 @@
</span><span class="cx">             std::ostringstream stream;
</span><span class="cx">             stream &lt;&lt; $1 &lt;&lt; &quot; / &quot; &lt;&lt; $3;
</span><span class="cx">             std::string text = stream.str();
</span><del>-            context-&gt;diagnostics-&gt;report(pp::Diagnostics::DIVISION_BY_ZERO,
</del><ins>+            context-&gt;diagnostics-&gt;report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
</ins><span class="cx">                                          context-&gt;token-&gt;location,
</span><span class="cx">                                          text.c_str());
</span><span class="cx">             YYABORT;
</span><span class="lines">@@ -207,7 +207,7 @@
</span><span class="cx">         unsigned int val = 0;
</span><span class="cx">         if (!token-&gt;uValue(&amp;val))
</span><span class="cx">         {
</span><del>-            context-&gt;diagnostics-&gt;report(pp::Diagnostics::INTEGER_OVERFLOW,
</del><ins>+            context-&gt;diagnostics-&gt;report(pp::Diagnostics::PP_INTEGER_OVERFLOW,
</ins><span class="cx">                                          token-&gt;location, token-&gt;text);
</span><span class="cx">         }
</span><span class="cx">         *lvalp = static_cast&lt;YYSTYPE&gt;(val);
</span><span class="lines">@@ -248,7 +248,7 @@
</span><span class="cx"> 
</span><span class="cx"> void yyerror(Context* context, const char* reason)
</span><span class="cx"> {
</span><del>-    context-&gt;diagnostics-&gt;report(pp::Diagnostics::INVALID_EXPRESSION,
</del><ins>+    context-&gt;diagnostics-&gt;report(pp::Diagnostics::PP_INVALID_EXPRESSION,
</ins><span class="cx">                                  context-&gt;token-&gt;location,
</span><span class="cx">                                  reason);
</span><span class="cx"> }
</span><span class="lines">@@ -276,12 +276,12 @@
</span><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">       case 2:
</span><del>-        mDiagnostics-&gt;report(Diagnostics::OUT_OF_MEMORY, token-&gt;location, &quot;&quot;);
</del><ins>+        mDiagnostics-&gt;report(Diagnostics::PP_OUT_OF_MEMORY, token-&gt;location, &quot;&quot;);
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">       default:
</span><span class="cx">         assert(false);
</span><del>-        mDiagnostics-&gt;report(Diagnostics::INTERNAL_ERROR, token-&gt;location, &quot;&quot;);
</del><ins>+        mDiagnostics-&gt;report(Diagnostics::PP_INTERNAL_ERROR, token-&gt;location, &quot;&quot;);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilerpreprocessorPreprocessorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -81,11 +81,6 @@
</span><span class="cx">     mImpl-&gt;macroSet[name] = macro;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Preprocessor::setMaxTokenLength(size_t maxLength)
-{
-    mImpl-&gt;tokenizer.setMaxTokenLength(maxLength);
-}
-
</del><span class="cx"> void Preprocessor::lex(Token* token)
</span><span class="cx"> {
</span><span class="cx">     bool validToken = false;
</span><span class="lines">@@ -115,5 +110,9 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-}  // namespace pp
</del><ins>+void Preprocessor::setMaxTokenSize(size_t maxTokenSize)
+{
+    mImpl-&gt;tokenizer.setMaxTokenSize(maxTokenSize);
+}
</ins><span class="cx"> 
</span><ins>+}  // namespace pp
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilerpreprocessorPreprocessorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -37,15 +37,12 @@
</span><span class="cx">     bool init(size_t count, const char* const string[], const int length[]);
</span><span class="cx">     // Adds a pre-defined macro.
</span><span class="cx">     void predefineMacro(const char* name, int value);
</span><del>-    // Sets maximum allowed token length.
-    // If token length exceeds this limit,
-    // the token text will be truncated to the given maximum length, and
-    // TOKEN_TOO_LONG diagnostic will be generated.
-    // The maximum length defaults to 256.
-    void setMaxTokenLength(size_t maxLength);
</del><span class="cx"> 
</span><span class="cx">     void lex(Token* token);
</span><span class="cx"> 
</span><ins>+    // Set maximum preprocessor token size
+    void setMaxTokenSize(size_t maxTokenSize);
+
</ins><span class="cx">   private:
</span><span class="cx">     PP_DISALLOW_COPY_AND_ASSIGN(Preprocessor);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilerpreprocessorTokenizercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #line 16 &quot;./Tokenizer.l&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2011-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2011-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx"> #define FLEX_SCANNER
</span><span class="cx"> #define YY_FLEX_MAJOR_VERSION 2
</span><span class="cx"> #define YY_FLEX_MINOR_VERSION 5
</span><del>-#define YY_FLEX_SUBMINOR_VERSION 35
</del><ins>+#define YY_FLEX_SUBMINOR_VERSION 37
</ins><span class="cx"> #if YY_FLEX_SUBMINOR_VERSION &gt; 0
</span><span class="cx"> #define FLEX_BETA
</span><span class="cx"> #endif
</span><span class="lines">@@ -64,7 +64,6 @@
</span><span class="cx"> typedef unsigned char flex_uint8_t; 
</span><span class="cx"> typedef unsigned short int flex_uint16_t;
</span><span class="cx"> typedef unsigned int flex_uint32_t;
</span><del>-#endif /* ! C99 */
</del><span class="cx"> 
</span><span class="cx"> /* Limits of integral types. */
</span><span class="cx"> #ifndef INT8_MIN
</span><span class="lines">@@ -95,6 +94,8 @@
</span><span class="cx"> #define UINT32_MAX             (4294967295U)
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#endif /* ! C99 */
+
</ins><span class="cx"> #endif /* ! FLEXINT_H */
</span><span class="cx"> 
</span><span class="cx"> #ifdef __cplusplus
</span><span class="lines">@@ -185,6 +186,11 @@
</span><span class="cx"> typedef size_t yy_size_t;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
</ins><span class="cx"> #define EOB_ACT_CONTINUE_SCAN 0
</span><span class="cx"> #define EOB_ACT_END_OF_FILE 1
</span><span class="cx"> #define EOB_ACT_LAST_MATCH 2
</span><span class="lines">@@ -335,7 +341,7 @@
</span><span class="cx"> 
</span><span class="cx"> /* Begin user sect3 */
</span><span class="cx"> 
</span><del>-#define ppwrap(n) 1
</del><ins>+#define ppwrap(yyscanner) 1
</ins><span class="cx"> #define YY_SKIP_YYWRAP
</span><span class="cx"> 
</span><span class="cx"> typedef unsigned char YY_CHAR;
</span><span class="lines">@@ -368,17 +374,19 @@
</span><span class="cx">         flex_int32_t yy_verify;
</span><span class="cx">         flex_int32_t yy_nxt;
</span><span class="cx">         };
</span><del>-static yyconst flex_int16_t yy_accept[87] =
</del><ins>+static yyconst flex_int16_t yy_accept[98] =
</ins><span class="cx">     {   0,
</span><span class="cx">         0,    0,    0,    0,   39,   37,   34,   35,   35,   33,
</span><span class="cx">         7,   33,   33,   33,   33,   33,   33,   33,   33,    9,
</span><span class="cx">         9,   33,   33,   33,    8,   37,   33,   33,    3,    5,
</span><span class="cx">         5,    4,   34,   35,   19,   27,   20,   30,   25,   12,
</span><span class="cx">        23,   13,   24,   10,    2,    1,   26,   10,    9,   11,
</span><del>-       11,   11,   11,    9,   14,   16,   18,   17,   15,    8,
-       36,   36,   31,   21,   32,   22,    3,    5,    6,   11,
-       10,   11,    1,   10,   11,    0,   10,    9,   28,   29,
-        0,   10,   10,   10,   10,    0
</del><ins>+       11,   11,    9,   11,    9,    9,   14,   16,   18,   17,
+       15,    8,   36,   36,   31,   21,   32,   22,    3,    5,
+        6,   11,   10,   11,   10,    1,   10,   11,   10,    0,
+       10,    9,    9,    9,   28,   29,    0,   10,   10,   10,
+       10,    9,   10,   10,    9,   10,    0
+
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><span class="cx"> static yyconst flex_int32_t yy_ec[256] =
</span><span class="lines">@@ -389,14 +397,14 @@
</span><span class="cx">         1,    2,    5,    1,    6,    1,    7,    8,    1,    9,
</span><span class="cx">         9,   10,   11,    9,   12,   13,   14,   15,   16,   16,
</span><span class="cx">        16,   16,   16,   16,   16,   17,   17,    9,    9,   18,
</span><del>-       19,   20,    9,    1,   21,   21,   21,   21,   22,   21,
-       23,   23,   23,   23,   23,   23,   23,   23,   23,   23,
-       23,   23,   23,   23,   23,   23,   23,   24,   23,   23,
-        9,   25,    9,   26,   23,    1,   21,   21,   21,   21,
</del><ins>+       19,   20,    9,    1,   21,   21,   21,   21,   22,   23,
+       24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
+       24,   24,   24,   24,   25,   24,   24,   26,   24,   24,
+        9,   27,    9,   28,   24,    1,   21,   21,   21,   21,
</ins><span class="cx"> 
</span><del>-       22,   21,   23,   23,   23,   23,   23,   23,   23,   23,
-       23,   23,   23,   23,   23,   23,   23,   23,   23,   24,
-       23,   23,    9,   27,    9,    9,    1,    1,    1,    1,
</del><ins>+       22,   23,   24,   24,   24,   24,   24,   24,   24,   24,
+       24,   24,   24,   24,   24,   24,   25,   24,   24,   26,
+       24,   24,    9,   29,    9,    9,    1,    1,    1,    1,
</ins><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="lines">@@ -413,89 +421,101 @@
</span><span class="cx">         1,    1,    1,    1,    1
</span><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int32_t yy_meta[28] =
</del><ins>+static yyconst flex_int32_t yy_meta[30] =
</ins><span class="cx">     {   0,
</span><span class="cx">         1,    1,    2,    2,    1,    1,    1,    1,    1,    3,
</span><span class="cx">         1,    1,    4,    1,    5,    5,    5,    1,    1,    1,
</span><del>-        5,    5,    5,    5,    1,    1,    1
</del><ins>+        5,    5,    5,    5,    5,    5,    1,    1,    1
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int16_t yy_base[92] =
</del><ins>+static yyconst flex_int16_t yy_base[103] =
</ins><span class="cx">     {   0,
</span><del>-        0,    0,   25,   27,  162,  163,  159,  163,  152,  132,
-      163,  131,   24,  163,  116,   22,   26,   31,   30,   37,
-       40,   44,  115,   46,    0,   64,   50,   15,    0,  163,
-      124,   91,   88,  163,  163,  163,  163,  163,  163,  163,
-      163,  163,  163,   64,  163,    0,  163,   76,   54,   58,
-       79,   91,   91,    0,   56,  163,  163,  163,   32,    0,
-      163,   36,  163,  163,  163,  163,    0,  163,  163,   94,
-        0,  106,    0,    0,  113,   55,   72,  113,  163,  163,
-      116,  101,  108,  123,  126,  163,  143,   31,  148,  153,
-      155
</del><ins>+        0,    0,   27,   29,  137,  194,  133,  194,  117,  100,
+      194,   98,   26,  194,   94,   24,   28,   33,   32,   39,
+       51,   39,   80,   50,    0,   68,   25,   54,    0,  194,
+       88,   71,   80,  194,  194,  194,  194,  194,  194,  194,
+      194,  194,  194,   71,  194,    0,  194,   85,   55,   64,
+       99,  111,   53,  105,    0,   50,   55,  194,  194,  194,
+       40,    0,  194,   38,  194,  194,  194,  194,    0,  194,
+      194,  117,    0,  130,    0,    0,    0,  137,    0,   88,
+      113,    0,  131,    0,  194,  194,  143,  139,  152,  150,
+        0,   13,  153,  194,    0,  194,  194,  176,   31,  181,
</ins><span class="cx"> 
</span><ins>+      186,  188
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int16_t yy_def[92] =
</del><ins>+static yyconst flex_int16_t yy_def[103] =
</ins><span class="cx">     {   0,
</span><del>-       86,    1,   87,   87,   86,   86,   86,   86,   86,   86,
-       86,   86,   86,   86,   86,   86,   86,   86,   86,   86,
-       20,   86,   86,   86,   88,   86,   86,   86,   89,   86,
-       86,   86,   86,   86,   86,   86,   86,   86,   86,   86,
-       86,   86,   86,   86,   86,   90,   86,   86,   20,   20,
-       48,   51,   91,   21,   86,   86,   86,   86,   86,   88,
-       86,   86,   86,   86,   86,   86,   89,   86,   86,   44,
-       44,   70,   90,   48,   51,   86,   52,   91,   86,   86,
-       86,   72,   75,   86,   86,    0,   86,   86,   86,   86,
-       86
</del><ins>+       97,    1,   98,   98,   97,   97,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       20,   97,   97,   97,   99,   97,   97,   97,  100,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,  101,   97,   97,   20,   20,
+       50,   51,   51,  102,   21,   51,   97,   97,   97,   97,
+       97,   99,   97,   97,   97,   97,   97,   97,  100,   97,
+       97,   44,   44,   72,   72,  101,   48,   51,   51,   97,
+       52,   51,  102,   51,   97,   97,   97,   74,   78,   97,
+       51,   51,   97,   97,   51,   97,    0,   97,   97,   97,
</ins><span class="cx"> 
</span><ins>+       97,   97
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int16_t yy_nxt[191] =
</del><ins>+static yyconst flex_int16_t yy_nxt[224] =
</ins><span class="cx">     {   0,
</span><span class="cx">         6,    7,    8,    9,   10,   11,   12,   13,   14,   15,
</span><span class="cx">        16,   17,   18,   19,   20,   21,   21,   22,   23,   24,
</span><del>-       25,   25,   25,   25,   26,   27,   28,   30,   31,   30,
-       31,   37,   40,   65,   32,   60,   32,   42,   61,   45,
-       41,   66,   38,   46,   43,   44,   44,   44,   47,   48,
-       80,   49,   49,   50,   54,   54,   54,   51,   52,   51,
-       53,   55,   56,   51,   58,   59,   61,   62,   63,   84,
-       84,   84,   50,   50,   79,   64,   70,   51,   71,   71,
-       71,   51,   86,   86,   70,   72,   70,   70,   51,   33,
-       74,   74,   74,   51,   51,   51,   51,   75,   51,   51,
</del><ins>+       25,   25,   25,   25,   25,   25,   26,   27,   28,   30,
+       31,   30,   31,   37,   40,   62,   32,   95,   32,   42,
+       63,   45,   41,   65,   38,   46,   43,   44,   44,   44,
+       47,   48,   66,   49,   49,   50,   57,   58,   86,   51,
+       52,   51,   51,   53,   54,   55,   55,   55,   60,   61,
+       63,   64,   67,   85,   84,   56,   51,   82,   50,   50,
+       51,   33,   68,   72,   71,   73,   73,   73,   51,   51,
+       70,   72,   74,   75,   72,   72,   72,   51,   59,   77,
</ins><span class="cx"> 
</span><del>-       51,   76,   76,   51,   69,   77,   77,   77,   70,   70,
-       70,   86,   86,   51,   51,   70,   81,   81,   86,   86,
-       82,   82,   82,   81,   81,   51,   68,   83,   83,   83,
-       85,   85,   85,   57,   39,   51,   51,   84,   84,   84,
-       85,   85,   85,   29,   29,   29,   29,   29,   67,   36,
-       35,   67,   67,   73,   34,   73,   73,   73,   78,   78,
-       33,   86,    5,   86,   86,   86,   86,   86,   86,   86,
-       86,   86,   86,   86,   86,   86,   86,   86,   86,   86,
-       86,   86,   86,   86,   86,   86,   86,   86,   86,   86
</del><ins>+       77,   77,   90,   90,   90,   51,   78,   79,   51,   51,
+       51,   51,   39,   51,   51,   51,   36,   51,   35,   34,
+       51,   80,   80,   97,   97,   81,   81,   81,   51,   51,
+       51,   72,   72,   72,   33,   91,   97,   97,   72,   72,
+       87,   87,   97,   51,   88,   88,   88,   87,   87,   97,
+       97,   89,   89,   89,   51,   92,   51,   93,   93,   93,
+       97,   75,   97,   97,   90,   90,   90,   93,   93,   93,
+       97,   97,   94,   97,   79,   96,   29,   29,   29,   29,
+       29,   69,   97,   97,   69,   69,   76,   97,   76,   76,
+       76,   83,   83,    5,   97,   97,   97,   97,   97,   97,
+
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       97,   97,   97
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int16_t yy_chk[191] =
</del><ins>+static yyconst flex_int16_t yy_chk[224] =
</ins><span class="cx">     {   0,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><del>-        1,    1,    1,    1,    1,    1,    1,    3,    3,    4,
-        4,   13,   16,   28,    3,   88,    4,   17,   62,   19,
-       16,   28,   13,   19,   17,   18,   18,   18,   19,   20,
-       59,   20,   20,   20,   21,   21,   21,   20,   20,   20,
-       20,   22,   22,   21,   24,   24,   26,   26,   27,   76,
-       76,   76,   50,   50,   55,   27,   44,   49,   44,   44,
-       44,   50,   77,   77,   44,   44,   44,   44,   48,   33,
-       48,   48,   48,   51,   51,   51,   48,   48,   48,   48,
</del><ins>+        1,    1,    1,    1,    1,    1,    1,    1,    1,    3,
+        3,    4,    4,   13,   16,   99,    3,   92,    4,   17,
+       64,   19,   16,   27,   13,   19,   17,   18,   18,   18,
+       19,   20,   27,   20,   20,   20,   22,   22,   61,   20,
+       20,   20,   20,   20,   20,   21,   21,   21,   24,   24,
+       26,   26,   28,   57,   56,   21,   21,   53,   50,   50,
+       49,   33,   28,   44,   32,   44,   44,   44,   50,   50,
+       31,   44,   44,   44,   44,   44,   44,   48,   23,   48,
</ins><span class="cx"> 
</span><del>-       51,   52,   52,   53,   32,   52,   52,   52,   70,   70,
-       70,   82,   82,   53,   53,   70,   72,   72,   83,   83,
-       72,   72,   72,   75,   75,   78,   31,   75,   75,   75,
-       81,   81,   81,   23,   15,   78,   78,   84,   84,   84,
-       85,   85,   85,   87,   87,   87,   87,   87,   89,   12,
-       10,   89,   89,   90,    9,   90,   90,   90,   91,   91,
-        7,    5,   86,   86,   86,   86,   86,   86,   86,   86,
-       86,   86,   86,   86,   86,   86,   86,   86,   86,   86,
-       86,   86,   86,   86,   86,   86,   86,   86,   86,   86
</del><ins>+       48,   48,   80,   80,   80,   48,   48,   48,   48,   48,
+       48,   51,   15,   51,   51,   51,   12,   54,   10,    9,
+       51,   52,   52,   81,   81,   52,   52,   52,   54,   54,
+       54,   72,   72,   72,    7,   81,    5,    0,   72,   72,
+       74,   74,    0,   83,   74,   74,   74,   78,   78,   88,
+       88,   78,   78,   78,   83,   83,   83,   87,   87,   87,
+        0,   88,   89,   89,   90,   90,   90,   93,   93,   93,
+        0,    0,   90,    0,   89,   93,   98,   98,   98,   98,
+       98,  100,    0,    0,  100,  100,  101,    0,  101,  101,
+      101,  102,  102,   97,   97,   97,   97,   97,   97,   97,
+
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       97,   97,   97
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><span class="cx"> /* The intent behind this definition is that it'll catch
</span><span class="lines">@@ -507,7 +527,7 @@
</span><span class="cx"> #define YY_RESTORE_YY_MORE_OFFSET
</span><span class="cx"> /*
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -652,6 +672,10 @@
</span><span class="cx"> 
</span><span class="cx"> void ppset_lineno (int line_number ,yyscan_t yyscanner );
</span><span class="cx"> 
</span><ins>+int ppget_column  (yyscan_t yyscanner );
+
+void ppset_column (int column_no ,yyscan_t yyscanner );
+
</ins><span class="cx"> YYSTYPE * ppget_lval (yyscan_t yyscanner );
</span><span class="cx"> 
</span><span class="cx"> void ppset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
</span><span class="lines">@@ -702,7 +726,7 @@
</span><span class="cx"> /* This used to be an fputs(), but since the string might contain NUL's,
</span><span class="cx">  * we now use fwrite().
</span><span class="cx">  */
</span><del>-#define ECHO fwrite( yytext, yyleng, 1, yyout )
</del><ins>+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> /* Gets input and stuffs it into &quot;buf&quot;.  number of characters read, or YY_NULL,
</span><span class="lines">@@ -713,7 +737,7 @@
</span><span class="cx">         if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_is_interactive ) \
</span><span class="cx">                 { \
</span><span class="cx">                 int c = '*'; \
</span><del>-                yy_size_t n; \
</del><ins>+                size_t n; \
</ins><span class="cx">                 for ( n = 0; n &lt; max_size &amp;&amp; \
</span><span class="cx">                              (c = getc( yyin )) != EOF &amp;&amp; c != '\n'; ++n ) \
</span><span class="cx">                         buf[n] = (char) c; \
</span><span class="lines">@@ -855,13 +879,13 @@
</span><span class="cx">                         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
</span><span class="cx">                                 {
</span><span class="cx">                                 yy_current_state = (int) yy_def[yy_current_state];
</span><del>-                                if ( yy_current_state &gt;= 87 )
</del><ins>+                                if ( yy_current_state &gt;= 98 )
</ins><span class="cx">                                         yy_c = yy_meta[(unsigned int) yy_c];
</span><span class="cx">                                 }
</span><span class="cx">                         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
</span><span class="cx">                         ++yy_cp;
</span><span class="cx">                         }
</span><del>-                while ( yy_current_state != 86 );
</del><ins>+                while ( yy_current_state != 97 );
</ins><span class="cx">                 yy_cp = yyg-&gt;yy_last_accepting_cpos;
</span><span class="cx">                 yy_current_state = yyg-&gt;yy_last_accepting_state;
</span><span class="cx"> 
</span><span class="lines">@@ -1354,7 +1378,7 @@
</span><span class="cx">                         { /* Not enough room in the buffer - grow it. */
</span><span class="cx"> 
</span><span class="cx">                         /* just a shorter name for the current buffer */
</span><del>-                        YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
</del><ins>+                        YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
</ins><span class="cx"> 
</span><span class="cx">                         int yy_c_buf_p_offset =
</span><span class="cx">                                 (int) (yyg-&gt;yy_c_buf_p - b-&gt;yy_ch_buf);
</span><span class="lines">@@ -1454,7 +1478,7 @@
</span><span class="cx">                 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
</span><span class="cx">                         {
</span><span class="cx">                         yy_current_state = (int) yy_def[yy_current_state];
</span><del>-                        if ( yy_current_state &gt;= 87 )
</del><ins>+                        if ( yy_current_state &gt;= 98 )
</ins><span class="cx">                                 yy_c = yy_meta[(unsigned int) yy_c];
</span><span class="cx">                         }
</span><span class="cx">                 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
</span><span class="lines">@@ -1483,12 +1507,13 @@
</span><span class="cx">         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
</span><span class="cx">                 {
</span><span class="cx">                 yy_current_state = (int) yy_def[yy_current_state];
</span><del>-                if ( yy_current_state &gt;= 87 )
</del><ins>+                if ( yy_current_state &gt;= 98 )
</ins><span class="cx">                         yy_c = yy_meta[(unsigned int) yy_c];
</span><span class="cx">                 }
</span><span class="cx">         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
</span><del>-        yy_is_jam = (yy_current_state == 86);
</del><ins>+        yy_is_jam = (yy_current_state == 97);
</ins><span class="cx"> 
</span><ins>+        (void)yyg;
</ins><span class="cx">         return yy_is_jam ? 0 : yy_current_state;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1890,8 +1915,8 @@
</span><span class="cx"> 
</span><span class="cx"> /** Setup the input buffer state to scan the given bytes. The next call to pplex() will
</span><span class="cx">  * scan from a @e copy of @a bytes.
</span><del>- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
</del><ins>+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
</ins><span class="cx">  * @param yyscanner The scanner object.
</span><span class="cx">  * @return the newly allocated buffer state object.
</span><span class="cx">  */
</span><span class="lines">@@ -1899,7 +1924,8 @@
</span><span class="cx"> {
</span><span class="cx">         YY_BUFFER_STATE b;
</span><span class="cx">         char *buf;
</span><del>-        yy_size_t n, i;
</del><ins>+        yy_size_t n;
+        yy_size_t i;
</ins><span class="cx">     
</span><span class="cx">         /* Get memory for full buffer, including space for trailing EOB's. */
</span><span class="cx">         n = _yybytes_len + 2;
</span><span class="lines">@@ -2045,7 +2071,7 @@
</span><span class="cx"> 
</span><span class="cx">         /* lineno is only valid if an input buffer exists. */
</span><span class="cx">         if (! YY_CURRENT_BUFFER )
</span><del>-           yy_fatal_error( &quot;ppset_lineno called with no buffer&quot; , yyscanner); 
</del><ins>+           YY_FATAL_ERROR( &quot;ppset_lineno called with no buffer&quot; );
</ins><span class="cx">     
</span><span class="cx">     yylineno = line_number;
</span><span class="cx"> }
</span><span class="lines">@@ -2060,7 +2086,7 @@
</span><span class="cx"> 
</span><span class="cx">         /* column is only valid if an input buffer exists. */
</span><span class="cx">         if (! YY_CURRENT_BUFFER )
</span><del>-           yy_fatal_error( &quot;ppset_column called with no buffer&quot; , yyscanner); 
</del><ins>+           YY_FATAL_ERROR( &quot;ppset_column called with no buffer&quot; );
</ins><span class="cx">     
</span><span class="cx">     yycolumn = column_no;
</span><span class="cx"> }
</span><span class="lines">@@ -2304,7 +2330,7 @@
</span><span class="cx"> 
</span><span class="cx"> Tokenizer::Tokenizer(Diagnostics* diagnostics)
</span><span class="cx">     : mHandle(0),
</span><del>-      mMaxTokenLength(256)
</del><ins>+      mMaxTokenSize(256)
</ins><span class="cx"> {
</span><span class="cx">     mContext.diagnostics = diagnostics;
</span><span class="cx"> }
</span><span class="lines">@@ -2334,14 +2360,19 @@
</span><span class="cx">     ppset_lineno(line,mHandle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
+{
+    mMaxTokenSize = maxTokenSize;
+}
+
</ins><span class="cx"> void Tokenizer::lex(Token* token)
</span><span class="cx"> {
</span><span class="cx">     token-&gt;type = pplex(&amp;token-&gt;text,&amp;token-&gt;location,mHandle);
</span><del>-    if (token-&gt;text.size() &gt; mMaxTokenLength)
</del><ins>+    if (token-&gt;text.size() &gt; mMaxTokenSize)
</ins><span class="cx">     {
</span><span class="cx">         mContext.diagnostics-&gt;report(Diagnostics::PP_TOKEN_TOO_LONG,
</span><span class="cx">                                      token-&gt;location, token-&gt;text);
</span><del>-        token-&gt;text.erase(mMaxTokenLength);
</del><ins>+        token-&gt;text.erase(mMaxTokenSize);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     token-&gt;flags = 0;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilerpreprocessorTokenizerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -38,9 +38,9 @@
</span><span class="cx"> 
</span><span class="cx">     bool init(size_t count, const char* const string[], const int length[]);
</span><span class="cx"> 
</span><del>-    void setMaxTokenLength(size_t maxLength) { mMaxTokenLength = maxLength; }
</del><span class="cx">     void setFileNumber(int file);
</span><span class="cx">     void setLineNumber(int line);
</span><ins>+    void setMaxTokenSize(size_t maxTokenSize);
</ins><span class="cx"> 
</span><span class="cx">     virtual void lex(Token* token);
</span><span class="cx"> 
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> 
</span><span class="cx">     void* mHandle;  // Scanner handle.
</span><span class="cx">     Context mContext;  // Scanner extra.
</span><del>-    size_t mMaxTokenLength;
</del><ins>+    size_t mMaxTokenSize; // Maximum token size
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }  // namespace pp
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilerpreprocessorTokenizerl"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.l (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.l        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.l        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -14,7 +14,7 @@
</span><span class="cx"> 
</span><span class="cx"> %top{
</span><span class="cx"> //
</span><del>-// Copyright (c) 2011-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2011-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -33,6 +33,12 @@
</span><span class="cx"> #pragma GCC diagnostic ignored &quot;-Wmissing-noreturn&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored &quot;-Wunknown-pragmas&quot;
+#pragma clang diagnostic ignored &quot;-Wdeprecated-register&quot;
+#endif
+
</ins><span class="cx"> typedef std::string YYSTYPE;
</span><span class="cx"> typedef pp::SourceLocation YYLTYPE;
</span><span class="cx"> 
</span><span class="lines">@@ -78,9 +84,9 @@
</span><span class="cx"> IDENTIFIER  [_a-zA-Z][_a-zA-Z0-9]*
</span><span class="cx"> PUNCTUATOR  [][&lt;&gt;(){}.+-/*%^|&amp;~=!:;,?]
</span><span class="cx"> 
</span><del>-DECIMAL_CONSTANT      [1-9][0-9]*
-OCTAL_CONSTANT        0[0-7]*
-HEXADECIMAL_CONSTANT  0[xX][0-9a-fA-F]+
</del><ins>+DECIMAL_CONSTANT      [1-9][0-9]*[uU]?
+OCTAL_CONSTANT        0[0-7]*[uU]?
+HEXADECIMAL_CONSTANT  0[xX][0-9a-fA-F]+[uU]?
</ins><span class="cx"> 
</span><span class="cx"> DIGIT                [0-9]
</span><span class="cx"> EXPONENT_PART        [eE][+-]?{DIGIT}+
</span><span class="lines">@@ -114,12 +120,12 @@
</span><span class="cx">     return pp::Token::IDENTIFIER;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-{DECIMAL_CONSTANT}|{OCTAL_CONSTANT}|{HEXADECIMAL_CONSTANT} {
</del><ins>+({DECIMAL_CONSTANT}[uU]?)|({OCTAL_CONSTANT}[uU]?)|({HEXADECIMAL_CONSTANT}[uU]?) {
</ins><span class="cx">     yylval-&gt;assign(yytext, yyleng);
</span><span class="cx">     return pp::Token::CONST_INT;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-({DIGIT}+{EXPONENT_PART})|({FRACTIONAL_CONSTANT}{EXPONENT_PART}?) {
</del><ins>+({DIGIT}+{EXPONENT_PART}[fF]?)|({FRACTIONAL_CONSTANT}{EXPONENT_PART}?[fF]?) {
</ins><span class="cx">     yylval-&gt;assign(yytext, yyleng);
</span><span class="cx">     return pp::Token::CONST_FLOAT;
</span><span class="cx"> }
</span><span class="lines">@@ -256,7 +262,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (YY_START == COMMENT)
</span><span class="cx">     {
</span><del>-        yyextra-&gt;diagnostics-&gt;report(pp::Diagnostics::EOF_IN_COMMENT,
</del><ins>+        yyextra-&gt;diagnostics-&gt;report(pp::Diagnostics::PP_EOF_IN_COMMENT,
</ins><span class="cx">                                      pp::SourceLocation(yyfileno, yylineno),
</span><span class="cx">                                      &quot;&quot;);
</span><span class="cx">     }
</span><span class="lines">@@ -265,11 +271,13 @@
</span><span class="cx"> 
</span><span class="cx"> %%
</span><span class="cx"> 
</span><ins>+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
</ins><span class="cx"> namespace pp {
</span><span class="cx"> 
</span><del>-Tokenizer::Tokenizer(Diagnostics* diagnostics)
-    : mHandle(0),
-      mMaxTokenLength(256)
</del><ins>+Tokenizer::Tokenizer(Diagnostics* diagnostics) : mHandle(0)
</ins><span class="cx"> {
</span><span class="cx">     mContext.diagnostics = diagnostics;
</span><span class="cx"> }
</span><span class="lines">@@ -299,14 +307,19 @@
</span><span class="cx">     yyset_lineno(line, mHandle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
+{
+    mMaxTokenSize = maxTokenSize;
+}
+
</ins><span class="cx"> void Tokenizer::lex(Token* token)
</span><span class="cx"> {
</span><span class="cx">     token-&gt;type = yylex(&amp;token-&gt;text, &amp;token-&gt;location, mHandle);
</span><del>-    if (token-&gt;text.size() &gt; mMaxTokenLength)
</del><ins>+    if (token-&gt;text.size() &gt; mMaxTokenSize)
</ins><span class="cx">     {
</span><del>-        mContext.diagnostics-&gt;report(Diagnostics::TOKEN_TOO_LONG,
</del><ins>+        mContext.diagnostics-&gt;report(Diagnostics::PP_TOKEN_TOO_LONG,
</ins><span class="cx">                                      token-&gt;location, token-&gt;text);
</span><del>-        token-&gt;text.erase(mMaxTokenLength);
</del><ins>+        token-&gt;text.erase(mMaxTokenSize);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     token-&gt;flags = 0;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslator64bitlexersafetypatch"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/64bit-lexer-safety.patch (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/64bit-lexer-safety.patch                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/64bit-lexer-safety.patch        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,177 @@
</span><ins>+--- a/src/compiler/glslang_lex.cpp
++++ b/src/compiler/glslang_lex.cpp
+@@ -68,6 +68,7 @@ typedef int16_t flex_int16_t;
+ typedef uint16_t flex_uint16_t;
+ typedef int32_t flex_int32_t;
+ typedef uint32_t flex_uint32_t;
++typedef uint64_t flex_uint64_t;
+ #else
+ typedef signed char flex_int8_t;
+ typedef short int flex_int16_t;
+@@ -191,6 +192,11 @@ typedef void* yyscan_t;
+ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+ #endif

++#ifndef YY_TYPEDEF_YY_SIZE_T
++#define YY_TYPEDEF_YY_SIZE_T
++typedef size_t yy_size_t;
++#endif
++
+ #define EOB_ACT_CONTINUE_SCAN 0
+ #define EOB_ACT_END_OF_FILE 1
+ #define EOB_ACT_LAST_MATCH 2
+@@ -204,7 +210,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+      */
+     #define  YY_LESS_LINENO(n) \
+             do { \
+-                int yyl;\
++                yy_size_t yyl;\
+                 for ( yyl = n; yyl &lt; yyleng; ++yyl )\
+                     if ( yytext[yyl] == '\n' )\
+                         --yylineno;\
+@@ -226,11 +232,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;

+ #define unput(c) yyunput( c, yyg-&gt;yytext_ptr , yyscanner )

+-#ifndef YY_TYPEDEF_YY_SIZE_T
+-#define YY_TYPEDEF_YY_SIZE_T
+-typedef size_t yy_size_t;
+-#endif
+-
+ #ifndef YY_STRUCT_YY_BUFFER_STATE
+ #define YY_STRUCT_YY_BUFFER_STATE
+ struct yy_buffer_state
+@@ -248,7 +249,7 @@ struct yy_buffer_state
+         /* Number of characters read into yy_ch_buf, not including EOB
+          * characters.
+          */
+-        int yy_n_chars;
++        yy_size_t yy_n_chars;

+         /* Whether we &quot;own&quot; the buffer - i.e., we know we created it,
+          * and can realloc() it to grow it, and should free() it to
+@@ -327,7 +328,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );

+ YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+ YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
++YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );

+ void *yyalloc (yy_size_t ,yyscan_t yyscanner );
+ void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
+@@ -378,7 +379,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
+  */
+ #define YY_DO_BEFORE_ACTION \
+         yyg-&gt;yytext_ptr = yy_bp; \
+-        yyleng = (size_t) (yy_cp - yy_bp); \
++        yyleng = (yy_size_t) (yy_cp - yy_bp); \
+         yyg-&gt;yy_hold_char = *yy_cp; \
+         *yy_cp = '\0'; \
+         yyg-&gt;yy_c_buf_p = yy_cp;
+@@ -1035,8 +1036,8 @@ struct yyguts_t
+     size_t yy_buffer_stack_max; /**&lt; capacity of stack. */
+     YY_BUFFER_STATE * yy_buffer_stack; /**&lt; Stack as an array. */
+     char yy_hold_char;
+-    int yy_n_chars;
+-    int yyleng_r;
++    yy_size_t yy_n_chars;
++    yy_size_t yyleng_r;
+     char *yy_c_buf_p;
+     int yy_init;
+     int yy_start;
+@@ -1089,7 +1090,7 @@ FILE *yyget_out (yyscan_t yyscanner );

+ void yyset_out  (FILE * out_str ,yyscan_t yyscanner );

+-int yyget_leng (yyscan_t yyscanner );
++yy_size_t yyget_leng (yyscan_t yyscanner );

+ char *yyget_text (yyscan_t yyscanner );

+@@ -1158,7 +1159,7 @@ static int input (yyscan_t yyscanner );
+         if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_is_interactive ) \
+                 { \
+                 int c = '*'; \
+-                int n; \
++                yy_size_t n; \
+                 for ( n = 0; n &lt; max_size &amp;&amp; \
+                              (c = getc( yyin )) != EOF &amp;&amp; c != '\n'; ++n ) \
+                         buf[n] = (char) c; \
+@@ -1317,7 +1318,7 @@ yy_find_action:

+                 if ( yy_act != YY_END_OF_BUFFER &amp;&amp; yy_rule_can_match_eol[yy_act] )
+                         {
+-                        int yyl;
++                        yy_size_t yyl;
+                         for ( yyl = 0; yyl &lt; yyleng; ++yyl )
+                                 if ( yytext[yyl] == '\n' )
+                                            
+@@ -2203,7 +2204,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

+         else
+                 {
+-                        int num_to_read =
++                        yy_size_t num_to_read =
+                         YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_size - number_to_move - 1;

+                 while ( num_to_read &lt;= 0 )
+@@ -2217,7 +2218,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

+                         if ( b-&gt;yy_is_our_buffer )
+                                 {
+-                                int new_size = b-&gt;yy_buf_size * 2;
++                                yy_size_t new_size = b-&gt;yy_buf_size * 2;

+                                 if ( new_size &lt;= 0 )
+                                         b-&gt;yy_buf_size += b-&gt;yy_buf_size / 8;
+@@ -2248,7 +2249,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

+                 /* Read in more data. */
+                 YY_INPUT( (&amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[number_to_move]),
+-                        yyg-&gt;yy_n_chars, (size_t) num_to_read );
++                        yyg-&gt;yy_n_chars, num_to_read );

+                 YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars = yyg-&gt;yy_n_chars;
+                 }
+@@ -2373,7 +2374,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

+                 else
+                         { /* need more input */
+-                        int offset = yyg-&gt;yy_c_buf_p - yyg-&gt;yytext_ptr;
++                        yy_size_t offset = yyg-&gt;yy_c_buf_p - yyg-&gt;yytext_ptr;
+                         ++yyg-&gt;yy_c_buf_p;

+                         switch ( yy_get_next_buffer( yyscanner ) )
+@@ -2660,7 +2661,7 @@ void yypop_buffer_state (yyscan_t yyscanner)
+  */
+ static void yyensure_buffer_stack (yyscan_t yyscanner)
+ {
+-        int num_to_alloc;
++        yy_size_t num_to_alloc;
+     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

+         if (!yyg-&gt;yy_buffer_stack) {
+@@ -2758,12 +2759,11 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+  * @param yyscanner The scanner object.
+  * @return the newly allocated buffer state object.
+  */
+-YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
++YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len , yyscan_t yyscanner)
+ {
+         YY_BUFFER_STATE b;
+         char *buf;
+-        yy_size_t n;
+-        int i;
++        yy_size_t n, i;
+     
+         /* Get memory for full buffer, including space for trailing EOB's. */
+         n = _yybytes_len + 2;
+@@ -2913,7 +2913,7 @@ FILE *yyget_out  (yyscan_t yyscanner)
+ /** Get the length of the current token.
+  * @param yyscanner The scanner object.
+  */
+-int yyget_leng  (yyscan_t yyscanner)
++yy_size_t yyget_leng  (yyscan_t yyscanner)
+ {
+     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+     return yyleng;
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorBaseTypesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BaseTypes.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BaseTypes.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BaseTypes.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -7,6 +7,8 @@
</span><span class="cx"> #ifndef _BASICTYPES_INCLUDED_
</span><span class="cx"> #define _BASICTYPES_INCLUDED_
</span><span class="cx"> 
</span><ins>+#include &lt;assert.h&gt;
+
</ins><span class="cx"> //
</span><span class="cx"> // Precision qualifiers
</span><span class="cx"> //
</span><span class="lines">@@ -23,10 +25,10 @@
</span><span class="cx"> {
</span><span class="cx">     switch(p)
</span><span class="cx">     {
</span><del>-    case EbpHigh:   return &quot;highp&quot;;   break;
-    case EbpMedium:   return &quot;mediump&quot;; break;
-    case EbpLow:    return &quot;lowp&quot;;    break;
-    default:      return &quot;mediump&quot;;   break;   // Safest fallback
</del><ins>+    case EbpHigh:                return &quot;highp&quot;;                break;
+    case EbpMedium:                return &quot;mediump&quot;;        break;
+    case EbpLow:                return &quot;lowp&quot;;                break;
+    default:                        return &quot;mediump&quot;;   break;   // Safest fallback
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -38,14 +40,34 @@
</span><span class="cx">     EbtVoid,
</span><span class="cx">     EbtFloat,
</span><span class="cx">     EbtInt,
</span><ins>+    EbtUInt,
</ins><span class="cx">     EbtBool,
</span><del>-    EbtGuardSamplerBegin,  // non type:  see implementation of IsSampler()
</del><ins>+    EbtGVec4,              // non type: represents vec4, ivec4 and uvec4
+    EbtGuardSamplerBegin,  // non type: see implementation of IsSampler()
</ins><span class="cx">     EbtSampler2D,
</span><ins>+    EbtSampler3D,
</ins><span class="cx">     EbtSamplerCube,
</span><ins>+    EbtSampler2DArray,
</ins><span class="cx">     EbtSamplerExternalOES,  // Only valid if OES_EGL_image_external exists.
</span><span class="cx">     EbtSampler2DRect,       // Only valid if GL_ARB_texture_rectangle exists.
</span><del>-    EbtGuardSamplerEnd,    // non type:  see implementation of IsSampler()
</del><ins>+    EbtISampler2D,
+    EbtISampler3D,
+    EbtISamplerCube,
+    EbtISampler2DArray,
+    EbtUSampler2D,
+    EbtUSampler3D,
+    EbtUSamplerCube,
+    EbtUSampler2DArray,
+    EbtSampler2DShadow,
+    EbtSamplerCubeShadow,
+    EbtSampler2DArrayShadow,
+    EbtGuardSamplerEnd,    // non type: see implementation of IsSampler()
+    EbtGSampler2D,         // non type: represents sampler2D, isampler2D and usampler2D
+    EbtGSampler3D,         // non type: represents sampler3D, isampler3D and usampler3D
+    EbtGSamplerCube,       // non type: represents samplerCube, isamplerCube and usamplerCube
+    EbtGSampler2DArray,    // non type: represents sampler2DArray, isampler2DArray and usampler2DArray
</ins><span class="cx">     EbtStruct,
</span><ins>+    EbtInterfaceBlock,
</ins><span class="cx">     EbtAddress,            // should be deprecated??
</span><span class="cx">     EbtInvariant          // used as a type when qualifying a previously declared variable as being invariant
</span><span class="cx"> };
</span><span class="lines">@@ -54,16 +76,31 @@
</span><span class="cx"> {
</span><span class="cx">     switch (t)
</span><span class="cx">     {
</span><del>-    case EbtVoid:              return &quot;void&quot;;              break;
-    case EbtFloat:             return &quot;float&quot;;             break;
-    case EbtInt:               return &quot;int&quot;;               break;
-    case EbtBool:              return &quot;bool&quot;;              break;
-    case EbtSampler2D:         return &quot;sampler2D&quot;;         break;
-    case EbtSamplerCube:       return &quot;samplerCube&quot;;       break;
-    case EbtSamplerExternalOES: return &quot;samplerExternalOES&quot;; break;
-    case EbtSampler2DRect:     return &quot;sampler2DRect&quot;;     break;
-    case EbtStruct:            return &quot;structure&quot;;         break;
-    default:                   return &quot;unknown type&quot;;
</del><ins>+      case EbtVoid:                 return &quot;void&quot;;                 break;
+      case EbtFloat:                return &quot;float&quot;;                break;
+      case EbtInt:                  return &quot;int&quot;;                  break;
+      case EbtUInt:                 return &quot;uint&quot;;                 break;
+      case EbtBool:                 return &quot;bool&quot;;                 break;
+      case EbtSampler2D:            return &quot;sampler2D&quot;;            break;
+      case EbtSampler3D:            return &quot;sampler3D&quot;;            break;
+      case EbtSamplerCube:          return &quot;samplerCube&quot;;          break;
+      case EbtSamplerExternalOES:   return &quot;samplerExternalOES&quot;;   break;
+      case EbtSampler2DRect:        return &quot;sampler2DRect&quot;;        break;
+      case EbtSampler2DArray:       return &quot;sampler2DArray&quot;;       break;
+      case EbtISampler2D:           return &quot;isampler2D&quot;;           break;
+      case EbtISampler3D:           return &quot;isampler3D&quot;;           break;
+      case EbtISamplerCube:         return &quot;isamplerCube&quot;;         break;
+      case EbtISampler2DArray:      return &quot;isampler2DArray&quot;;      break;
+      case EbtUSampler2D:           return &quot;usampler2D&quot;;           break;
+      case EbtUSampler3D:           return &quot;usampler3D&quot;;           break;
+      case EbtUSamplerCube:         return &quot;usamplerCube&quot;;         break;
+      case EbtUSampler2DArray:      return &quot;usampler2DArray&quot;;      break;
+      case EbtSampler2DShadow:      return &quot;sampler2DShadow&quot;;      break;
+      case EbtSamplerCubeShadow:    return &quot;samplerCubeShadow&quot;;    break;
+      case EbtSampler2DArrayShadow: return &quot;sampler2DArrayShadow&quot;; break;
+      case EbtStruct:               return &quot;structure&quot;;            break;
+      case EbtInterfaceBlock:       return &quot;interface block&quot;;      break;
+      default:                      return &quot;unknown type&quot;;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -72,6 +109,186 @@
</span><span class="cx">     return type &gt; EbtGuardSamplerBegin &amp;&amp; type &lt; EbtGuardSamplerEnd;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline bool IsIntegerSampler(TBasicType type)
+{
+    switch (type)
+    {
+      case EbtISampler2D:
+      case EbtISampler3D:
+      case EbtISamplerCube:
+      case EbtISampler2DArray:
+      case EbtUSampler2D:
+      case EbtUSampler3D:
+      case EbtUSamplerCube:
+      case EbtUSampler2DArray:
+        return true;
+      case EbtSampler2D:
+      case EbtSampler3D:
+      case EbtSamplerCube:
+      case EbtSamplerExternalOES:
+      case EbtSampler2DRect:
+      case EbtSampler2DArray:
+      case EbtSampler2DShadow:
+      case EbtSamplerCubeShadow:
+      case EbtSampler2DArrayShadow:
+        return false;
+      default:
+        assert(!IsSampler(type));
+    }
+
+    return false;
+}
+
+inline bool IsSampler2D(TBasicType type)
+{
+    switch (type)
+    {
+      case EbtSampler2D:
+      case EbtISampler2D:
+      case EbtUSampler2D:
+      case EbtSampler2DArray:
+      case EbtISampler2DArray:
+      case EbtUSampler2DArray:
+      case EbtSampler2DRect:
+      case EbtSamplerExternalOES:
+      case EbtSampler2DShadow:
+      case EbtSampler2DArrayShadow:
+        return true;
+      case EbtSampler3D:
+      case EbtISampler3D:
+      case EbtUSampler3D:
+      case EbtISamplerCube:
+      case EbtUSamplerCube:
+      case EbtSamplerCube:
+      case EbtSamplerCubeShadow:
+        return false;
+      default:
+        assert(!IsSampler(type));
+    }
+
+    return false;
+}
+
+inline bool IsSamplerCube(TBasicType type)
+{
+    switch (type)
+    {
+      case EbtSamplerCube:
+      case EbtISamplerCube:
+      case EbtUSamplerCube:
+      case EbtSamplerCubeShadow:
+        return true;
+      case EbtSampler2D:
+      case EbtSampler3D:
+      case EbtSamplerExternalOES:
+      case EbtSampler2DRect:
+      case EbtSampler2DArray:
+      case EbtISampler2D:
+      case EbtISampler3D:
+      case EbtISampler2DArray:
+      case EbtUSampler2D:
+      case EbtUSampler3D:
+      case EbtUSampler2DArray:
+      case EbtSampler2DShadow:
+      case EbtSampler2DArrayShadow:
+        return false;
+      default:
+        assert(!IsSampler(type));
+    }
+
+    return false;
+}
+
+inline bool IsSampler3D(TBasicType type)
+{
+    switch (type)
+    {
+      case EbtSampler3D:
+      case EbtISampler3D:
+      case EbtUSampler3D:
+        return true;
+      case EbtSampler2D:
+      case EbtSamplerCube:
+      case EbtSamplerExternalOES:
+      case EbtSampler2DRect:
+      case EbtSampler2DArray:
+      case EbtISampler2D:
+      case EbtISamplerCube:
+      case EbtISampler2DArray:
+      case EbtUSampler2D:
+      case EbtUSamplerCube:
+      case EbtUSampler2DArray:
+      case EbtSampler2DShadow:
+      case EbtSamplerCubeShadow:
+      case EbtSampler2DArrayShadow:
+        return false;
+      default:
+        assert(!IsSampler(type));
+    }
+
+    return false;
+}
+
+inline bool IsSamplerArray(TBasicType type)
+{
+    switch (type)
+    {
+      case EbtSampler2DArray:
+      case EbtISampler2DArray:
+      case EbtUSampler2DArray:
+      case EbtSampler2DArrayShadow:
+        return true;
+      case EbtSampler2D:
+      case EbtISampler2D:
+      case EbtUSampler2D:
+      case EbtSampler2DRect:
+      case EbtSamplerExternalOES:
+      case EbtSampler3D:
+      case EbtISampler3D:
+      case EbtUSampler3D:
+      case EbtISamplerCube:
+      case EbtUSamplerCube:
+      case EbtSamplerCube:
+      case EbtSampler2DShadow:
+      case EbtSamplerCubeShadow:
+        return false;
+      default:
+        assert(!IsSampler(type));
+    }
+
+    return false;
+}
+
+inline bool IsShadowSampler(TBasicType type)
+{
+    switch (type)
+    {
+      case EbtSampler2DShadow:
+      case EbtSamplerCubeShadow:
+      case EbtSampler2DArrayShadow:
+        return true;
+      case EbtISampler2D:
+      case EbtISampler3D:
+      case EbtISamplerCube:
+      case EbtISampler2DArray:
+      case EbtUSampler2D:
+      case EbtUSampler3D:
+      case EbtUSamplerCube:
+      case EbtUSampler2DArray:
+      case EbtSampler2D:
+      case EbtSampler3D:
+      case EbtSamplerCube:
+      case EbtSamplerExternalOES:
+      case EbtSampler2DRect:
+      case EbtSampler2DArray:
+        return false;
+      default:
+        assert(!IsSampler(type));
+    }
+
+    return false;
+}
+
</ins><span class="cx"> //
</span><span class="cx"> // Qualifiers and built-ins.  These are mainly used to see what can be read
</span><span class="cx"> // or written, and by the machine dependent translator to know which registers
</span><span class="lines">@@ -91,6 +308,11 @@
</span><span class="cx">     EvqInvariantVaryingOut,    // vertex shaders only  read/write
</span><span class="cx">     EvqUniform,       // Readonly, vertex and fragment
</span><span class="cx"> 
</span><ins>+    EvqVertexIn,      // Vertex shader input
+    EvqFragmentOut,   // Fragment shader output
+    EvqVertexOut,     // Vertex shader output
+    EvqFragmentIn,    // Fragment shader input
+
</ins><span class="cx">     // parameters
</span><span class="cx">     EvqIn,
</span><span class="cx">     EvqOut,
</span><span class="lines">@@ -111,10 +333,58 @@
</span><span class="cx">     EvqFragData,
</span><span class="cx">     EvqFragDepth,
</span><span class="cx"> 
</span><ins>+    // GLSL ES 3.0 vertex output and fragment input
+    EvqSmooth,        // Incomplete qualifier, smooth is the default
+    EvqFlat,          // Incomplete qualifier
+    EvqSmoothOut = EvqSmooth,
+    EvqFlatOut = EvqFlat,
+    EvqCentroidOut,   // Implies smooth
+    EvqSmoothIn,
+    EvqFlatIn,
+    EvqCentroidIn,    // Implies smooth
+
</ins><span class="cx">     // end of list
</span><span class="cx">     EvqLast
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum TLayoutMatrixPacking
+{
+    EmpUnspecified,
+    EmpRowMajor,
+    EmpColumnMajor
+};
+
+enum TLayoutBlockStorage
+{
+    EbsUnspecified,
+    EbsShared,
+    EbsPacked,
+    EbsStd140
+};
+
+struct TLayoutQualifier
+{
+    int location;
+    TLayoutMatrixPacking matrixPacking;
+    TLayoutBlockStorage blockStorage;
+
+    static TLayoutQualifier create()
+    {
+        TLayoutQualifier layoutQualifier;
+
+        layoutQualifier.location = -1;
+        layoutQualifier.matrixPacking = EmpUnspecified;
+        layoutQualifier.blockStorage = EbsUnspecified;
+
+        return layoutQualifier;
+    }
+
+    bool isEmpty() const
+    {
+        return location == -1 &amp;&amp; matrixPacking == EmpUnspecified &amp;&amp; blockStorage == EbsUnspecified;
+    }
+};
+
</ins><span class="cx"> //
</span><span class="cx"> // This is just for debug print out, carried along with the definitions above.
</span><span class="cx"> //
</span><span class="lines">@@ -129,9 +399,13 @@
</span><span class="cx">     case EvqAttribute:      return &quot;attribute&quot;;      break;
</span><span class="cx">     case EvqVaryingIn:      return &quot;varying&quot;;        break;
</span><span class="cx">     case EvqVaryingOut:     return &quot;varying&quot;;        break;
</span><del>-    case EvqInvariantVaryingIn: return &quot;invariant varying&quot;; break;
-    case EvqInvariantVaryingOut:return &quot;invariant varying&quot;; break;
</del><ins>+    case EvqInvariantVaryingIn: return &quot;invariant varying&quot;;        break;
+    case EvqInvariantVaryingOut:return &quot;invariant varying&quot;;        break;
</ins><span class="cx">     case EvqUniform:        return &quot;uniform&quot;;        break;
</span><ins>+    case EvqVertexIn:       return &quot;in&quot;;             break;
+    case EvqFragmentOut:    return &quot;out&quot;;            break;
+    case EvqVertexOut:      return &quot;out&quot;;            break;
+    case EvqFragmentIn:     return &quot;in&quot;;             break;
</ins><span class="cx">     case EvqIn:             return &quot;in&quot;;             break;
</span><span class="cx">     case EvqOut:            return &quot;out&quot;;            break;
</span><span class="cx">     case EvqInOut:          return &quot;inout&quot;;          break;
</span><span class="lines">@@ -140,10 +414,53 @@
</span><span class="cx">     case EvqFragCoord:      return &quot;FragCoord&quot;;      break;
</span><span class="cx">     case EvqFrontFacing:    return &quot;FrontFacing&quot;;    break;
</span><span class="cx">     case EvqFragColor:      return &quot;FragColor&quot;;      break;
</span><del>-    case EvqFragData:       return &quot;FragData&quot;;      break;
-    case EvqFragDepth:      return &quot;FragDepth&quot;;     break;
</del><ins>+    case EvqFragData:       return &quot;FragData&quot;;       break;
+    case EvqFragDepth:      return &quot;FragDepth&quot;;      break;
+    case EvqSmoothOut:      return &quot;smooth out&quot;;     break;
+    case EvqCentroidOut:    return &quot;centroid out&quot;;   break;
+    case EvqFlatOut:        return &quot;flat out&quot;;       break;
+    case EvqSmoothIn:       return &quot;smooth in&quot;;      break;
+    case EvqCentroidIn:     return &quot;centroid in&quot;;    break;
+    case EvqFlatIn:         return &quot;flat in&quot;;        break;
</ins><span class="cx">     default:                return &quot;unknown qualifier&quot;;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline const char* getMatrixPackingString(TLayoutMatrixPacking mpq)
+{
+    switch (mpq)
+    {
+    case EmpUnspecified:    return &quot;mp_unspecified&quot;;
+    case EmpRowMajor:       return &quot;row_major&quot;;
+    case EmpColumnMajor:    return &quot;column_major&quot;;
+    default:                return &quot;unknown matrix packing&quot;;
+    }
+}
+
+inline const char* getBlockStorageString(TLayoutBlockStorage bsq)
+{
+    switch (bsq)
+    {
+    case EbsUnspecified:    return &quot;bs_unspecified&quot;;
+    case EbsShared:         return &quot;shared&quot;;
+    case EbsPacked:         return &quot;packed&quot;;
+    case EbsStd140:         return &quot;std140&quot;;
+    default:                return &quot;unknown block storage&quot;;
+    }
+}
+
+inline const char* getInterpolationString(TQualifier q)
+{
+    switch(q)
+    {
+    case EvqSmoothOut:      return &quot;smooth&quot;;   break;
+    case EvqCentroidOut:    return &quot;centroid&quot;; break;
+    case EvqFlatOut:        return &quot;flat&quot;;     break;
+    case EvqSmoothIn:       return &quot;smooth&quot;;   break;
+    case EvqCentroidIn:     return &quot;centroid&quot;; break;
+    case EvqFlatIn:         return &quot;flat&quot;;     break;
+    default:                return &quot;unknown interpolation&quot;;
+    }
+}
+
</ins><span class="cx"> #endif // _BASICTYPES_INCLUDED_
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BaseTypes.h
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorBuiltInFunctionEmulatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BuiltInFunctionEmulator.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BuiltInFunctionEmulator.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BuiltInFunctionEmulator.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -327,7 +327,7 @@
</span><span class="cx"> BuiltInFunctionEmulator::IdentifyFunction(
</span><span class="cx">     TOperator op, const TType&amp; param)
</span><span class="cx"> {
</span><del>-    if (param.getNominalSize() &gt; 4)
</del><ins>+    if (param.getNominalSize() &gt; 4 || param.getSecondarySize() &gt; 4)
</ins><span class="cx">         return TFunctionUnknown;
</span><span class="cx">     unsigned int function = TFunctionUnknown;
</span><span class="cx">     switch (op) {
</span><span class="lines">@@ -356,9 +356,9 @@
</span><span class="cx"> {
</span><span class="cx">     // Right now for all the emulated functions with two parameters, the two
</span><span class="cx">     // parameters have the same type.
</span><del>-    if (param1.isVector() != param2.isVector() ||
-        param1.getNominalSize() != param2.getNominalSize() ||
-        param1.getNominalSize() &gt; 4)
</del><ins>+    if (param1.getNominalSize()     != param2.getNominalSize()   ||
+        param1.getSecondarySize()   != param2.getSecondarySize() ||
+        param1.getNominalSize() &gt; 4 || param1.getSecondarySize() &gt; 4)
</ins><span class="cx">         return TFunctionUnknown;
</span><span class="cx"> 
</span><span class="cx">     unsigned int function = TFunctionUnknown;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorBuiltInFunctionEmulatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BuiltInFunctionEmulator.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BuiltInFunctionEmulator.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/BuiltInFunctionEmulator.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -7,8 +7,6 @@
</span><span class="cx"> #ifndef COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
</span><span class="cx"> #define COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
-
</del><span class="cx"> #include &quot;compiler/translator/InfoSink.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorCodeGencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/CodeGen.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/CodeGen.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/CodeGen.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -17,14 +17,14 @@
</span><span class="cx">     ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
</span><span class="cx"> {
</span><span class="cx">     switch (output) {
</span><del>-      case SH_ESSL_OUTPUT:
</del><ins>+    case SH_ESSL_OUTPUT:
</ins><span class="cx">         return new TranslatorESSL(type, spec);
</span><del>-      case SH_GLSL_OUTPUT:
</del><ins>+    case SH_GLSL_OUTPUT:
</ins><span class="cx">         return new TranslatorGLSL(type, spec);
</span><del>-      case SH_HLSL9_OUTPUT:
-      case SH_HLSL11_OUTPUT:
</del><ins>+    case SH_HLSL9_OUTPUT:
+    case SH_HLSL11_OUTPUT:
</ins><span class="cx">         return new TranslatorHLSL(type, spec, output);
</span><del>-      default:
</del><ins>+    default:
</ins><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorCommonh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Common.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Common.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Common.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -46,8 +46,8 @@
</span><span class="cx"> typedef std::basic_ostringstream&lt;char, std::char_traits&lt;char&gt;, TStringAllocator&gt; TStringStream;
</span><span class="cx"> inline TString* NewPoolTString(const char* s)
</span><span class="cx"> {
</span><del>-  void* memory = GetGlobalPoolAllocator()-&gt;allocate(sizeof(TString));
-  return new(memory) TString(s);
</del><ins>+        void* memory = GetGlobalPoolAllocator()-&gt;allocate(sizeof(TString));
+        return new(memory) TString(s);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> //
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Common.h
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -10,12 +10,12 @@
</span><span class="cx"> #include &quot;compiler/translator/Initialize.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/InitializeParseContext.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/InitializeVariables.h&quot;
</span><del>-#include &quot;compiler/translator/MapLongVariableNames.h&quot;
</del><span class="cx"> #include &quot;compiler/translator/ParseContext.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/RenameFunction.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/ShHandle.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/UnfoldShortCircuitAST.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/ValidateLimitations.h&quot;
</span><ins>+#include &quot;compiler/translator/ValidateOutputs.h&quot;
</ins><span class="cx"> #include &quot;compiler/translator/VariablePacker.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/depgraph/DependencyGraph.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/depgraph/DependencyGraphOutput.h&quot;
</span><span class="lines">@@ -23,11 +23,25 @@
</span><span class="cx"> #include &quot;compiler/translator/timing/RestrictVertexShaderTiming.h&quot;
</span><span class="cx"> #include &quot;third_party/compiler/ArrayBoundsClamper.h&quot;
</span><span class="cx"> 
</span><del>-bool isWebGLBasedSpec(ShShaderSpec spec)
</del><ins>+bool IsWebGLBasedSpec(ShShaderSpec spec)
</ins><span class="cx"> {
</span><span class="cx">      return spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+size_t GetGlobalMaxTokenSize(ShShaderSpec spec)
+{
+    // WebGL defines a max token legnth of 256, while ES2 leaves max token
+    // size undefined. ES3 defines a max size of 1024 characters.
+    if (IsWebGLBasedSpec(spec))
+    {
+        return 256;
+    }
+    else
+    {
+        return 1024;
+    }
+}
+
</ins><span class="cx"> namespace {
</span><span class="cx"> class TScopedPoolAllocator
</span><span class="cx"> {
</span><span class="lines">@@ -89,17 +103,15 @@
</span><span class="cx">       clampingStrategy(SH_CLAMP_WITH_CLAMP_INTRINSIC),
</span><span class="cx">       builtInFunctionEmulator(type)
</span><span class="cx"> {
</span><del>-    longNameMap = LongNameMap::GetInstance();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TCompiler::~TCompiler()
</span><span class="cx"> {
</span><del>-    ASSERT(longNameMap);
-    longNameMap-&gt;Release();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool TCompiler::Init(const ShBuiltInResources&amp; resources)
</span><span class="cx"> {
</span><ins>+    shaderVersion = 100;
</ins><span class="cx">     maxUniformVectors = (shaderType == SH_VERTEX_SHADER) ?
</span><span class="cx">         resources.MaxVertexUniformVectors :
</span><span class="cx">         resources.MaxFragmentUniformVectors;
</span><span class="lines">@@ -134,7 +146,7 @@
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="cx">     // If compiling for WebGL, validate loop and indexing as well.
</span><del>-    if (isWebGLBasedSpec(shaderSpec))
</del><ins>+    if (IsWebGLBasedSpec(shaderSpec))
</ins><span class="cx">         compileOptions |= SH_VALIDATE_LOOP_INDEXING;
</span><span class="cx"> 
</span><span class="cx">     // First string is path of source file if flag is set. The actual source follows.
</span><span class="lines">@@ -161,14 +173,24 @@
</span><span class="cx">     bool success =
</span><span class="cx">         (PaParseStrings(numStrings - firstSource, &amp;shaderStrings[firstSource], NULL, &amp;parseContext) == 0) &amp;&amp;
</span><span class="cx">         (parseContext.treeRoot != NULL);
</span><ins>+
+    shaderVersion = parseContext.getShaderVersion();
+
</ins><span class="cx">     if (success)
</span><span class="cx">     {
</span><span class="cx">         TIntermNode* root = parseContext.treeRoot;
</span><span class="cx">         success = intermediate.postProcess(root);
</span><span class="cx"> 
</span><ins>+        // Disallow expressions deemed too complex.
+        if (success &amp;&amp; (compileOptions &amp; SH_LIMIT_EXPRESSION_COMPLEXITY))
+            success = limitExpressionComplexity(root);
+
</ins><span class="cx">         if (success)
</span><span class="cx">             success = detectCallDepth(root, infoSink, (compileOptions &amp; SH_LIMIT_CALL_STACK_DEPTH) != 0);
</span><span class="cx"> 
</span><ins>+        if (success &amp;&amp; shaderVersion == 300 &amp;&amp; shaderType == SH_FRAGMENT_SHADER)
+            success = validateOutputs(root);
+
</ins><span class="cx">         if (success &amp;&amp; (compileOptions &amp; SH_VALIDATE_LOOP_INDEXING))
</span><span class="cx">             success = validateLimitations(root);
</span><span class="cx"> 
</span><span class="lines">@@ -180,7 +202,21 @@
</span><span class="cx"> 
</span><span class="cx">         // Unroll for-loop markup needs to happen after validateLimitations pass.
</span><span class="cx">         if (success &amp;&amp; (compileOptions &amp; SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX))
</span><del>-            ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling(root);
</del><ins>+        {
+            ForLoopUnrollMarker marker(ForLoopUnrollMarker::kIntegerIndex);
+            root-&gt;traverse(&amp;marker);
+        }
+        if (success &amp;&amp; (compileOptions &amp; SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX))
+        {
+            ForLoopUnrollMarker marker(ForLoopUnrollMarker::kSamplerArrayIndex);
+            root-&gt;traverse(&amp;marker);
+            if (marker.samplerArrayIndexIsFloatLoopIndex())
+            {
+                infoSink.info.prefix(EPrefixError);
+                infoSink.info &lt;&lt; &quot;sampler array index is float loop index&quot;;
+                success = false;
+            }
+        }
</ins><span class="cx"> 
</span><span class="cx">         // Built-in function emulation needs to happen after validateLimitations pass.
</span><span class="cx">         if (success &amp;&amp; (compileOptions &amp; SH_EMULATE_BUILT_IN_FUNCTIONS))
</span><span class="lines">@@ -190,17 +226,6 @@
</span><span class="cx">         if (success &amp;&amp; (compileOptions &amp; SH_CLAMP_INDIRECT_ARRAY_BOUNDS))
</span><span class="cx">             arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root);
</span><span class="cx"> 
</span><del>-        // Disallow expressions deemed too complex.
-        if (success &amp;&amp; (compileOptions &amp; SH_LIMIT_EXPRESSION_COMPLEXITY))
-            success = limitExpressionComplexity(root);
-
-        // Call mapLongVariableNames() before collectAttribsUniforms() so in
-        // collectAttribsUniforms() we already have the mapped symbol names and
-        // we could composite mapped and original variable names.
-        // Also, if we hash all the names, then no need to do this for long names.
-        if (success &amp;&amp; (compileOptions &amp; SH_MAP_LONG_VARIABLE_NAMES) &amp;&amp; hashFunction == NULL)
-            mapLongVariableNames(root);
-
</del><span class="cx">         if (success &amp;&amp; shaderType == SH_VERTEX_SHADER &amp;&amp; (compileOptions &amp; SH_INIT_GL_POSITION))
</span><span class="cx">             initializeGLPosition(root);
</span><span class="cx"> 
</span><span class="lines">@@ -216,7 +241,6 @@
</span><span class="cx">             collectVariables(root);
</span><span class="cx">             if (compileOptions &amp; SH_ENFORCE_PACKING_RESTRICTIONS)
</span><span class="cx">                 success = enforcePackingRestrictions();
</span><del>-
</del><span class="cx">             if (success &amp;&amp; shaderType == SH_VERTEX_SHADER &amp;&amp;
</span><span class="cx">                 (compileOptions &amp; SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
</span><span class="cx">                 initializeVaryingsWithoutStaticUse(root);
</span><span class="lines">@@ -231,7 +255,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Cleanup memory.
</span><span class="cx">     intermediate.remove(parseContext.treeRoot);
</span><del>-
</del><ins>+    SetGlobalParseContext(NULL);
</ins><span class="cx">     return success;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -240,23 +264,25 @@
</span><span class="cx">     compileResources = resources;
</span><span class="cx"> 
</span><span class="cx">     assert(symbolTable.isEmpty());
</span><del>-    symbolTable.push();
</del><ins>+    symbolTable.push();   // COMMON_BUILTINS
+    symbolTable.push();   // ESSL1_BUILTINS
+    symbolTable.push();   // ESSL3_BUILTINS
</ins><span class="cx"> 
</span><span class="cx">     TPublicType integer;
</span><span class="cx">     integer.type = EbtInt;
</span><del>-    integer.size = 1;
-    integer.matrix = false;
</del><ins>+    integer.primarySize = 1;
+    integer.secondarySize = 1;
</ins><span class="cx">     integer.array = false;
</span><span class="cx"> 
</span><span class="cx">     TPublicType floatingPoint;
</span><span class="cx">     floatingPoint.type = EbtFloat;
</span><del>-    floatingPoint.size = 1;
-    floatingPoint.matrix = false;
</del><ins>+    floatingPoint.primarySize = 1;
+    floatingPoint.secondarySize = 1;
</ins><span class="cx">     floatingPoint.array = false;
</span><span class="cx"> 
</span><span class="cx">     TPublicType sampler;
</span><del>-    sampler.size = 1;
-    sampler.matrix = false;
</del><ins>+    sampler.primarySize = 1;
+    sampler.secondarySize = 1;
</ins><span class="cx">     sampler.array = false;
</span><span class="cx"> 
</span><span class="cx">     switch(shaderType)
</span><span class="lines">@@ -329,6 +355,13 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TCompiler::validateOutputs(TIntermNode* root)
+{
+    ValidateOutputs validateOutputs(infoSink.info, compileResources.MaxDrawBuffers);
+    root-&gt;traverse(&amp;validateOutputs);
+    return (validateOutputs.numErrors() == 0);
+}
+
</ins><span class="cx"> void TCompiler::rewriteCSSShader(TIntermNode* root)
</span><span class="cx"> {
</span><span class="cx">     RenameFunction renamer(&quot;main(&quot;, &quot;css_main(&quot;);
</span><span class="lines">@@ -356,14 +389,14 @@
</span><span class="cx"> 
</span><span class="cx">         // Output any errors first.
</span><span class="cx">         bool success = enforceFragmentShaderTimingRestrictions(graph);
</span><del>-        
</del><ins>+
</ins><span class="cx">         // Then, output the dependency graph.
</span><span class="cx">         if (outputGraph)
</span><span class="cx">         {
</span><span class="cx">             TDependencyGraphOutput output(infoSink.info);
</span><span class="cx">             output.outputAllSpanningTrees(graph);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return success;
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="lines">@@ -374,8 +407,15 @@
</span><span class="cx"> 
</span><span class="cx"> bool TCompiler::limitExpressionComplexity(TIntermNode* root)
</span><span class="cx"> {
</span><del>-    TIntermTraverser traverser;
</del><ins>+    TMaxDepthTraverser traverser(maxExpressionComplexity+1);
</ins><span class="cx">     root-&gt;traverse(&amp;traverser);
</span><ins>+
+    if (traverser.getMaxDepth() &gt; maxExpressionComplexity)
+    {
+        infoSink.info &lt;&lt; &quot;Expression too complex.&quot;;
+        return false;
+    }
+
</ins><span class="cx">     TDependencyGraph graph(root);
</span><span class="cx"> 
</span><span class="cx">     for (TFunctionCallVector::const_iterator iter = graph.beginUserDefinedFunctionCalls();
</span><span class="lines">@@ -387,11 +427,6 @@
</span><span class="cx">         samplerSymbol-&gt;traverse(&amp;graphTraverser);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (traverser.getMaxDepth() &gt; maxExpressionComplexity)
-    {
-        infoSink.info &lt;&lt; &quot;Expression too complex.&quot;;
-        return false;
-    }
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -432,7 +467,6 @@
</span><span class="cx">         infoSink.info &lt;&lt; &quot;too many varyings&quot;;
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><del>-
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -454,38 +488,36 @@
</span><span class="cx">         const TVariableInfo&amp; varying = varyings[ii];
</span><span class="cx">         if (varying.staticUse)
</span><span class="cx">             continue;
</span><del>-        unsigned char size = 0;
-        bool matrix = false;
</del><ins>+        unsigned char primarySize = 1, secondarySize = 1;
</ins><span class="cx">         switch (varying.type)
</span><span class="cx">         {
</span><span class="cx">           case SH_FLOAT:
</span><del>-            size = 1;
</del><span class="cx">             break;
</span><span class="cx">           case SH_FLOAT_VEC2:
</span><del>-            size = 2;
</del><ins>+            primarySize = 2;
</ins><span class="cx">             break;
</span><span class="cx">           case SH_FLOAT_VEC3:
</span><del>-            size = 3;
</del><ins>+            primarySize = 3;
</ins><span class="cx">             break;
</span><span class="cx">           case SH_FLOAT_VEC4:
</span><del>-            size = 4;
</del><ins>+            primarySize = 4;
</ins><span class="cx">             break;
</span><span class="cx">           case SH_FLOAT_MAT2:
</span><del>-            size = 2;
-            matrix = true;
</del><ins>+            primarySize = 2;
+            secondarySize = 2;
</ins><span class="cx">             break;
</span><span class="cx">           case SH_FLOAT_MAT3:
</span><del>-            size = 3;
-            matrix = true;
</del><ins>+            primarySize = 3;
+            secondarySize = 3;
</ins><span class="cx">             break;
</span><span class="cx">           case SH_FLOAT_MAT4:
</span><del>-            size = 4;
-            matrix = true;
</del><ins>+            primarySize = 4;
+            secondarySize = 4;
</ins><span class="cx">             break;
</span><span class="cx">           default:
</span><span class="cx">             ASSERT(false);
</span><span class="cx">         }
</span><del>-        TType type(EbtFloat, EbpUndefined, EvqVaryingOut, size, matrix, varying.isArray);
</del><ins>+        TType type(EbtFloat, EbpUndefined, EvqVaryingOut, primarySize, secondarySize, varying.isArray);
</ins><span class="cx">         TString name = varying.name.c_str();
</span><span class="cx">         if (varying.isArray)
</span><span class="cx">         {
</span><span class="lines">@@ -500,18 +532,6 @@
</span><span class="cx">     root-&gt;traverse(&amp;initializer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TCompiler::mapLongVariableNames(TIntermNode* root)
-{
-    ASSERT(longNameMap);
-    MapLongVariableNames map(longNameMap);
-    root-&gt;traverse(&amp;map);
-}
-
-int TCompiler::getMappedNameMaxLength() const
-{
-    return MAX_SHORTENED_IDENTIFIER_SIZE + 1;
-}
-
</del><span class="cx"> const TExtensionBehavior&amp; TCompiler::getExtensionBehavior() const
</span><span class="cx"> {
</span><span class="cx">     return extensionBehavior;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorConstantUnionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ConstantUnion.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ConstantUnion.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ConstantUnion.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -19,13 +19,12 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void setIConst(int i) {iConst = i; type = EbtInt; }
</span><ins>+    void setUConst(unsigned int u) { uConst = u; type = EbtUInt; }
</ins><span class="cx">     void setFConst(float f) {fConst = f; type = EbtFloat; }
</span><span class="cx">     void setBConst(bool b) {bConst = b; type = EbtBool; }
</span><span class="cx"> 
</span><del>-    int getIConst() { return iConst; }
-    float getFConst() { return fConst; }
-    bool getBConst() { return bConst; }
</del><span class="cx">     int getIConst() const { return iConst; }
</span><ins>+    unsigned int getUConst() const { return uConst; }
</ins><span class="cx">     float getFConst() const { return fConst; }
</span><span class="cx">     bool getBConst() const { return bConst; }
</span><span class="cx"> 
</span><span class="lines">@@ -34,6 +33,11 @@
</span><span class="cx">         return i == iConst;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    bool operator==(const unsigned int u) const
+    {
+        return u == uConst;
+    }
+
</ins><span class="cx">     bool operator==(const float f) const
</span><span class="cx">     {
</span><span class="cx">         return f == fConst;
</span><span class="lines">@@ -52,6 +56,8 @@
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt:
</span><span class="cx">             return constant.iConst == iConst;
</span><ins>+        case EbtUInt:
+            return constant.uConst == uConst;
</ins><span class="cx">         case EbtFloat:
</span><span class="cx">             return constant.fConst == fConst;
</span><span class="cx">         case EbtBool:
</span><span class="lines">@@ -66,6 +72,11 @@
</span><span class="cx">         return !operator==(i);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    bool operator!=(const unsigned int u) const
+    {
+        return !operator==(u);
+    }
+
</ins><span class="cx">     bool operator!=(const float f) const
</span><span class="cx">     {
</span><span class="cx">         return !operator==(f);
</span><span class="lines">@@ -87,6 +98,8 @@
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt:
</span><span class="cx">             return iConst &gt; constant.iConst;
</span><ins>+        case EbtUInt:
+            return uConst &gt; constant.uConst;
</ins><span class="cx">         case EbtFloat:
</span><span class="cx">             return fConst &gt; constant.fConst;
</span><span class="cx">         default:
</span><span class="lines">@@ -100,6 +113,8 @@
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt:
</span><span class="cx">             return iConst &lt; constant.iConst;
</span><ins>+        case EbtUInt:
+            return uConst &lt; constant.uConst;
</ins><span class="cx">         case EbtFloat:
</span><span class="cx">             return fConst &lt; constant.fConst;
</span><span class="cx">         default:
</span><span class="lines">@@ -113,6 +128,7 @@
</span><span class="cx">         assert(type == constant.type);
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
</span><ins>+        case EbtUInt: returnValue.setUConst(uConst + constant.uConst); break;
</ins><span class="cx">         case EbtFloat: returnValue.setFConst(fConst + constant.fConst); break;
</span><span class="cx">         default: assert(false &amp;&amp; &quot;Default missing&quot;);
</span><span class="cx">         }
</span><span class="lines">@@ -126,6 +142,7 @@
</span><span class="cx">         assert(type == constant.type);
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
</span><ins>+        case EbtUInt: returnValue.setUConst(uConst - constant.uConst); break;
</ins><span class="cx">         case EbtFloat: returnValue.setFConst(fConst - constant.fConst); break;
</span><span class="cx">         default: assert(false &amp;&amp; &quot;Default missing&quot;);
</span><span class="cx">         }
</span><span class="lines">@@ -139,6 +156,7 @@
</span><span class="cx">         assert(type == constant.type);
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
</span><ins>+        case EbtUInt: returnValue.setUConst(uConst * constant.uConst); break;
</ins><span class="cx">         case EbtFloat: returnValue.setFConst(fConst * constant.fConst); break; 
</span><span class="cx">         default: assert(false &amp;&amp; &quot;Default missing&quot;);
</span><span class="cx">         }
</span><span class="lines">@@ -152,6 +170,7 @@
</span><span class="cx">         assert(type == constant.type);
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
</span><ins>+        case EbtUInt: returnValue.setUConst(uConst % constant.uConst); break;
</ins><span class="cx">         default:     assert(false &amp;&amp; &quot;Default missing&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -164,6 +183,7 @@
</span><span class="cx">         assert(type == constant.type);
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt: returnValue.setIConst(iConst &gt;&gt; constant.iConst); break;
</span><ins>+        case EbtUInt: returnValue.setUConst(uConst &gt;&gt; constant.uConst); break;
</ins><span class="cx">         default:     assert(false &amp;&amp; &quot;Default missing&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -176,6 +196,7 @@
</span><span class="cx">         assert(type == constant.type);
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt: returnValue.setIConst(iConst &lt;&lt; constant.iConst); break;
</span><ins>+        case EbtUInt: returnValue.setUConst(uConst &lt;&lt; constant.uConst); break;
</ins><span class="cx">         default:     assert(false &amp;&amp; &quot;Default missing&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -188,6 +209,7 @@
</span><span class="cx">         assert(type == constant.type);
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt:  returnValue.setIConst(iConst &amp; constant.iConst); break;
</span><ins>+        case EbtUInt:  returnValue.setUConst(uConst &amp; constant.uConst); break;
</ins><span class="cx">         default:     assert(false &amp;&amp; &quot;Default missing&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -200,6 +222,7 @@
</span><span class="cx">         assert(type == constant.type);
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt:  returnValue.setIConst(iConst | constant.iConst); break;
</span><ins>+        case EbtUInt:  returnValue.setUConst(uConst | constant.uConst); break;
</ins><span class="cx">         default:     assert(false &amp;&amp; &quot;Default missing&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -212,6 +235,7 @@
</span><span class="cx">         assert(type == constant.type);
</span><span class="cx">         switch (type) {
</span><span class="cx">         case EbtInt:  returnValue.setIConst(iConst ^ constant.iConst); break;
</span><ins>+        case EbtUInt:  returnValue.setUConst(uConst ^ constant.uConst); break;
</ins><span class="cx">         default:     assert(false &amp;&amp; &quot;Default missing&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -247,6 +271,7 @@
</span><span class="cx"> 
</span><span class="cx">     union  {
</span><span class="cx">         int iConst;  // used for ivec, scalar ints
</span><ins>+        unsigned int uConst; // used for uvec, scalar uints
</ins><span class="cx">         bool bConst; // used for bvec, scalar bools
</span><span class="cx">         float fConst;   // used for vec, mat, scalar floats
</span><span class="cx">     } ;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorDetectCallDepthh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DetectCallDepth.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DetectCallDepth.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DetectCallDepth.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -7,8 +7,6 @@
</span><span class="cx"> #ifndef COMPILER_DETECT_RECURSION_H_
</span><span class="cx"> #define COMPILER_DETECT_RECURSION_H_
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
-
</del><span class="cx"> #include &lt;limits.h&gt;
</span><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/VariableInfo.h&quot;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorDiagnosticscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Diagnostics.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Diagnostics.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Diagnostics.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorDiagnosticsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Diagnostics.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Diagnostics.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Diagnostics.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorDirectiveHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DirectiveHandler.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DirectiveHandler.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DirectiveHandler.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -26,9 +26,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TDirectiveHandler::TDirectiveHandler(TExtensionBehavior&amp; extBehavior,
</span><del>-                                     TDiagnostics&amp; diagnostics)
</del><ins>+                                     TDiagnostics&amp; diagnostics,
+                                     int&amp; shaderVersion)
</ins><span class="cx">     : mExtensionBehavior(extBehavior),
</span><del>-      mDiagnostics(diagnostics)
</del><ins>+      mDiagnostics(diagnostics),
+      mShaderVersion(shaderVersion)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -148,10 +150,13 @@
</span><span class="cx"> void TDirectiveHandler::handleVersion(const pp::SourceLocation&amp; loc,
</span><span class="cx">                                       int version)
</span><span class="cx"> {
</span><del>-    static const int kVersion = 100;
-
-    if (version != kVersion)
</del><ins>+    if (version == 100 ||
+        version == 300)
</ins><span class="cx">     {
</span><ins>+        mShaderVersion = version;
+    }
+    else
+    {
</ins><span class="cx">         std::stringstream stream;
</span><span class="cx">         stream &lt;&lt; version;
</span><span class="cx">         std::string str = stream.str();
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorDirectiveHandlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DirectiveHandler.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DirectiveHandler.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/DirectiveHandler.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -17,7 +17,8 @@
</span><span class="cx"> {
</span><span class="cx">   public:
</span><span class="cx">     TDirectiveHandler(TExtensionBehavior&amp; extBehavior,
</span><del>-                      TDiagnostics&amp; diagnostics);
</del><ins>+                      TDiagnostics&amp; diagnostics,
+                      int&amp; shaderVersion);
</ins><span class="cx">     virtual ~TDirectiveHandler();
</span><span class="cx"> 
</span><span class="cx">     const TPragma&amp; pragma() const { return mPragma; }
</span><span class="lines">@@ -41,6 +42,7 @@
</span><span class="cx">     TPragma mPragma;
</span><span class="cx">     TExtensionBehavior&amp; mExtensionBehavior;
</span><span class="cx">     TDiagnostics&amp; mDiagnostics;
</span><ins>+    int&amp; mShaderVersion;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif  // COMPILER_DIRECTIVE_HANDLER_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorFlagStd140Structscpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/FlagStd140Structs.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/FlagStd140Structs.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/FlagStd140Structs.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+//
+// 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 &quot;compiler/translator/FlagStd140Structs.h&quot;
+
+namespace sh
+{
+
+bool FlagStd140Structs::visitBinary(Visit visit, TIntermBinary *binaryNode)
+{
+    if (binaryNode-&gt;getRight()-&gt;getBasicType() == EbtStruct)
+    {
+        switch (binaryNode-&gt;getOp())
+        {
+          case EOpIndexDirectInterfaceBlock:
+          case EOpIndexDirectStruct:
+            if (isInStd140InterfaceBlock(binaryNode-&gt;getLeft()))
+            {
+                mFlaggedNodes.push_back(binaryNode);
+            }
+            break;
+
+          default: break;
+        }
+        return false;
+    }
+
+    if (binaryNode-&gt;getOp() == EOpIndexDirectStruct)
+    {
+        return false;
+    }
+
+    return visit == PreVisit;
+}
+
+void FlagStd140Structs::visitSymbol(TIntermSymbol *symbol)
+{
+    if (isInStd140InterfaceBlock(symbol) &amp;&amp; symbol-&gt;getBasicType() == EbtStruct)
+    {
+        mFlaggedNodes.push_back(symbol);
+    }
+}
+
+bool FlagStd140Structs::isInStd140InterfaceBlock(TIntermTyped *node) const
+{
+    TIntermBinary *binaryNode = node-&gt;getAsBinaryNode();
+
+    if (binaryNode)
+    {
+        return isInStd140InterfaceBlock(binaryNode-&gt;getLeft());
+    }
+
+    const TType &amp;type = node-&gt;getType();
+
+    // determine if we are in the standard layout
+    const TInterfaceBlock *interfaceBlock = type.getInterfaceBlock();
+    if (interfaceBlock)
+    {
+        return (interfaceBlock-&gt;blockStorage() == EbsStd140);
+    }
+
+    return false;
+}
+
+std::vector&lt;TIntermTyped *&gt; FlagStd140ValueStructs(TIntermNode *node)
+{
+    FlagStd140Structs flaggingTraversal;
+
+    node-&gt;traverse(&amp;flaggingTraversal);
+
+    return flaggingTraversal.getFlaggedNodes();
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorFlagStd140Structsh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/FlagStd140Structs.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/FlagStd140Structs.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/FlagStd140Structs.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+//
+// 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_FLAGSTD140STRUCTS_H_
+#define COMPILER_FLAGSTD140STRUCTS_H_
+
+#include &quot;compiler/translator/intermediate.h&quot;
+
+namespace sh
+{
+
+// This class finds references to nested structs of std140 blocks that access
+// the nested struct &quot;by value&quot;, where the padding added in the translator
+// conflicts with the &quot;natural&quot; unpadded type.
+class FlagStd140Structs : public TIntermTraverser
+{
+  public:
+    const std::vector&lt;TIntermTyped *&gt; getFlaggedNodes() const { return mFlaggedNodes; }
+
+  protected:
+    virtual bool visitBinary(Visit visit, TIntermBinary *binaryNode);
+    virtual void visitSymbol(TIntermSymbol *symbol);
+
+  private:
+    bool isInStd140InterfaceBlock(TIntermTyped *node) const;
+
+    std::vector&lt;TIntermTyped *&gt; mFlaggedNodes;
+};
+
+std::vector&lt;TIntermTyped *&gt; FlagStd140ValueStructs(TIntermNode *node);
+
+}
+
+#endif // COMPILER_FLAGSTD140STRUCTS_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorForLoopUnrollcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ForLoopUnroll.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ForLoopUnroll.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ForLoopUnroll.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -6,210 +6,77 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;compiler/translator/ForLoopUnroll.h&quot;
</span><span class="cx"> 
</span><del>-namespace {
-
-class IntegerForLoopUnrollMarker : public TIntermTraverser {
-public:
-
-    virtual bool visitLoop(Visit, TIntermLoop* node)
-    {
-        // This is called after ValidateLimitations pass, so all the ASSERT
-        // should never fail.
-        // See ValidateLimitations::validateForLoopInit().
-        ASSERT(node);
-        ASSERT(node-&gt;getType() == ELoopFor);
-        ASSERT(node-&gt;getInit());
-        TIntermAggregate* decl = node-&gt;getInit()-&gt;getAsAggregate();
-        ASSERT(decl &amp;&amp; decl-&gt;getOp() == EOpDeclaration);
-        TIntermSequence&amp; declSeq = decl-&gt;getSequence();
-        ASSERT(declSeq.size() == 1);
-        TIntermBinary* declInit = declSeq[0]-&gt;getAsBinaryNode();
-        ASSERT(declInit &amp;&amp; declInit-&gt;getOp() == EOpInitialize);
-        ASSERT(declInit-&gt;getLeft());
-        TIntermSymbol* symbol = declInit-&gt;getLeft()-&gt;getAsSymbolNode();
-        ASSERT(symbol);
-        TBasicType type = symbol-&gt;getBasicType();
-        ASSERT(type == EbtInt || type == EbtFloat);
-        if (type == EbtInt)
-            node-&gt;setUnrollFlag(true);
</del><ins>+bool ForLoopUnrollMarker::visitBinary(Visit, TIntermBinary *node)
+{
+    if (mUnrollCondition != kSamplerArrayIndex)
</ins><span class="cx">         return true;
</span><del>-    }
</del><span class="cx"> 
</span><del>-};
-
-}  // anonymous namepsace
-
-void ForLoopUnroll::FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo&amp; info)
-{
-    ASSERT(node-&gt;getType() == ELoopFor);
-    ASSERT(node-&gt;getUnrollFlag());
-
-    TIntermNode* init = node-&gt;getInit();
-    ASSERT(init != NULL);
-    TIntermAggregate* decl = init-&gt;getAsAggregate();
-    ASSERT((decl != NULL) &amp;&amp; (decl-&gt;getOp() == EOpDeclaration));
-    TIntermSequence&amp; declSeq = decl-&gt;getSequence();
-    ASSERT(declSeq.size() == 1);
-    TIntermBinary* declInit = declSeq[0]-&gt;getAsBinaryNode();
-    ASSERT((declInit != NULL) &amp;&amp; (declInit-&gt;getOp() == EOpInitialize));
-    TIntermSymbol* symbol = declInit-&gt;getLeft()-&gt;getAsSymbolNode();
-    ASSERT(symbol != NULL);
-    ASSERT(symbol-&gt;getBasicType() == EbtInt);
-
-    info.id = symbol-&gt;getId();
-
-    ASSERT(declInit-&gt;getRight() != NULL);
-    TIntermConstantUnion* initNode = declInit-&gt;getRight()-&gt;getAsConstantUnion();
-    ASSERT(initNode != NULL);
-
-    info.initValue = evaluateIntConstant(initNode);
-    info.currentValue = info.initValue;
-
-    TIntermNode* cond = node-&gt;getCondition();
-    ASSERT(cond != NULL);
-    TIntermBinary* binOp = cond-&gt;getAsBinaryNode();
-    ASSERT(binOp != NULL);
-    ASSERT(binOp-&gt;getRight() != NULL);
-    ASSERT(binOp-&gt;getRight()-&gt;getAsConstantUnion() != NULL);
-
-    info.incrementValue = getLoopIncrement(node);
-    info.stopValue = evaluateIntConstant(
-        binOp-&gt;getRight()-&gt;getAsConstantUnion());
-    info.op = binOp-&gt;getOp();
-}
-
-void ForLoopUnroll::Step()
-{
-    ASSERT(mLoopIndexStack.size() &gt; 0);
-    TLoopIndexInfo&amp; info = mLoopIndexStack[mLoopIndexStack.size() - 1];
-    info.currentValue += info.incrementValue;
-}
-
-bool ForLoopUnroll::SatisfiesLoopCondition()
-{
-    ASSERT(mLoopIndexStack.size() &gt; 0);
-    TLoopIndexInfo&amp; info = mLoopIndexStack[mLoopIndexStack.size() - 1];
-    // Relational operator is one of: &gt; &gt;= &lt; &lt;= == or !=.
-    switch (info.op) {
-      case EOpEqual:
-        return (info.currentValue == info.stopValue);
-      case EOpNotEqual:
-        return (info.currentValue != info.stopValue);
-      case EOpLessThan:
-        return (info.currentValue &lt; info.stopValue);
-      case EOpGreaterThan:
-        return (info.currentValue &gt; info.stopValue);
-      case EOpLessThanEqual:
-        return (info.currentValue &lt;= info.stopValue);
-      case EOpGreaterThanEqual:
-        return (info.currentValue &gt;= info.stopValue);
</del><ins>+    // If a sampler array index is also the loop index,
+    //   1) if the index type is integer, mark the loop for unrolling;
+    //   2) if the index type if float, set a flag to later fail compile.
+    switch (node-&gt;getOp())
+    {
+      case EOpIndexIndirect:
+        if (node-&gt;getLeft() != NULL &amp;&amp; node-&gt;getRight() != NULL &amp;&amp; node-&gt;getLeft()-&gt;getAsSymbolNode())
+        {
+            TIntermSymbol *symbol = node-&gt;getLeft()-&gt;getAsSymbolNode();
+            if (IsSampler(symbol-&gt;getBasicType()) &amp;&amp; symbol-&gt;isArray() &amp;&amp; !mLoopStack.empty())
+            {
+                mVisitSamplerArrayIndexNodeInsideLoop = true;
+                node-&gt;getRight()-&gt;traverse(this);
+                mVisitSamplerArrayIndexNodeInsideLoop = false;
+                // We have already visited all the children.
+                return false;
+            }
+        }
+        break;
</ins><span class="cx">       default:
</span><del>-        UNREACHABLE();
</del><ins>+        break;
</ins><span class="cx">     }
</span><del>-    return false;
</del><ins>+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ForLoopUnroll::NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol)
</del><ins>+bool ForLoopUnrollMarker::visitLoop(Visit, TIntermLoop *node)
</ins><span class="cx"> {
</span><del>-    for (TVector&lt;TLoopIndexInfo&gt;::iterator i = mLoopIndexStack.begin();
-         i != mLoopIndexStack.end();
-         ++i) {
-        if (i-&gt;id == symbol-&gt;getId())
-            return true;
</del><ins>+    if (mUnrollCondition == kIntegerIndex)
+    {
+        // Check if loop index type is integer.
+        // This is called after ValidateLimitations pass, so all the calls
+        // should be valid. See ValidateLimitations::validateForLoopInit().
+        TIntermSequence&amp; declSeq = node-&gt;getInit()-&gt;getAsAggregate()-&gt;getSequence();
+        TIntermSymbol* symbol = declSeq[0]-&gt;getAsBinaryNode()-&gt;getLeft()-&gt;getAsSymbolNode();
+        if (symbol-&gt;getBasicType() == EbtInt)
+            node-&gt;setUnrollFlag(true);
</ins><span class="cx">     }
</span><del>-    return false;
-}
</del><span class="cx"> 
</span><del>-int ForLoopUnroll::GetLoopIndexValue(TIntermSymbol* symbol)
-{
-    for (TVector&lt;TLoopIndexInfo&gt;::iterator i = mLoopIndexStack.begin();
-         i != mLoopIndexStack.end();
-         ++i) {
-        if (i-&gt;id == symbol-&gt;getId())
-            return i-&gt;currentValue;
</del><ins>+    TIntermNode *body = node-&gt;getBody();
+    if (body != NULL)
+    {
+        mLoopStack.push(node);
+        body-&gt;traverse(this);
+        mLoopStack.pop();
</ins><span class="cx">     }
</span><del>-    UNREACHABLE();
</del><ins>+    // The loop is fully processed - no need to visit children.
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ForLoopUnroll::Push(TLoopIndexInfo&amp; info)
</del><ins>+void ForLoopUnrollMarker::visitSymbol(TIntermSymbol* symbol)
</ins><span class="cx"> {
</span><del>-    mLoopIndexStack.push_back(info);
-}
-
-void ForLoopUnroll::Pop()
-{
-    mLoopIndexStack.pop_back();
-}
-
-// static
-void ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling(
-    TIntermNode* root)
-{
-    ASSERT(root);
-
-    IntegerForLoopUnrollMarker marker;
-    root-&gt;traverse(&amp;marker);
-}
-
-int ForLoopUnroll::getLoopIncrement(TIntermLoop* node)
-{
-    TIntermNode* expr = node-&gt;getExpression();
-    ASSERT(expr != NULL);
-    // for expression has one of the following forms:
-    //     loop_index++
-    //     loop_index--
-    //     loop_index += constant_expression
-    //     loop_index -= constant_expression
-    //     ++loop_index
-    //     --loop_index
-    // The last two forms are not specified in the spec, but I am assuming
-    // its an oversight.
-    TIntermUnary* unOp = expr-&gt;getAsUnaryNode();
-    TIntermBinary* binOp = unOp ? NULL : expr-&gt;getAsBinaryNode();
-
-    TOperator op = EOpNull;
-    TIntermConstantUnion* incrementNode = NULL;
-    if (unOp != NULL) {
-        op = unOp-&gt;getOp();
-    } else if (binOp != NULL) {
-        op = binOp-&gt;getOp();
-        ASSERT(binOp-&gt;getRight() != NULL);
-        incrementNode = binOp-&gt;getRight()-&gt;getAsConstantUnion();
-        ASSERT(incrementNode != NULL);
-    }
-
-    int increment = 0;
-    // The operator is one of: ++ -- += -=.
-    switch (op) {
-        case EOpPostIncrement:
-        case EOpPreIncrement:
-            ASSERT((unOp != NULL) &amp;&amp; (binOp == NULL));
-            increment = 1;
</del><ins>+    if (!mVisitSamplerArrayIndexNodeInsideLoop)
+        return;
+    TIntermLoop *loop = mLoopStack.findLoop(symbol);
+    if (loop)
+    {
+        switch (symbol-&gt;getBasicType())
+        {
+          case EbtFloat:
+            mSamplerArrayIndexIsFloatLoopIndex = true;
</ins><span class="cx">             break;
</span><del>-        case EOpPostDecrement:
-        case EOpPreDecrement:
-            ASSERT((unOp != NULL) &amp;&amp; (binOp == NULL));
-            increment = -1;
</del><ins>+          case EbtInt:
+            loop-&gt;setUnrollFlag(true);
</ins><span class="cx">             break;
</span><del>-        case EOpAddAssign:
-            ASSERT((unOp == NULL) &amp;&amp; (binOp != NULL));
-            increment = evaluateIntConstant(incrementNode);
-            break;
-        case EOpSubAssign:
-            ASSERT((unOp == NULL) &amp;&amp; (binOp != NULL));
-            increment = - evaluateIntConstant(incrementNode);
-            break;
-        default:
-            ASSERT(false);
</del><ins>+          default:
+            UNREACHABLE();
+        }
</ins><span class="cx">     }
</span><del>-
-    return increment;
</del><span class="cx"> }
</span><del>-
-int ForLoopUnroll::evaluateIntConstant(TIntermConstantUnion* node)
-{
-    ASSERT((node != NULL) &amp;&amp; (node-&gt;getUnionArrayPointer() != NULL));
-    return node-&gt;getIConst(0);
-}
-
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorForLoopUnrollh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ForLoopUnroll.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ForLoopUnroll.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ForLoopUnroll.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -7,46 +7,44 @@
</span><span class="cx"> #ifndef COMPILER_FORLOOPUNROLL_H_
</span><span class="cx"> #define COMPILER_FORLOOPUNROLL_H_
</span><span class="cx"> 
</span><del>-#include &quot;compiler/translator/intermediate.h&quot;
</del><ins>+#include &quot;compiler/translator/LoopInfo.h&quot;
</ins><span class="cx"> 
</span><del>-struct TLoopIndexInfo {
-    int id;
-    int initValue;
-    int stopValue;
-    int incrementValue;
-    TOperator op;
-    int currentValue;
-};
</del><ins>+// This class detects for-loops that needs to be unrolled.
+// Currently we support two unroll conditions:
+//   1) kForLoopWithIntegerIndex: unroll if the index type is integer.
+//   2) kForLoopWithSamplerArrayIndex: unroll where a sampler array index
+//      is also the loop integer index, and reject and fail a compile
+//      where a sampler array index is also the loop float index.
+class ForLoopUnrollMarker : public TIntermTraverser
+{
+  public:
+    enum UnrollCondition
+    {
+        kIntegerIndex,
+        kSamplerArrayIndex
+    };
</ins><span class="cx"> 
</span><del>-class ForLoopUnroll {
-public:
-    ForLoopUnroll() { }
</del><ins>+    ForLoopUnrollMarker(UnrollCondition condition)
+        : mUnrollCondition(condition),
+          mSamplerArrayIndexIsFloatLoopIndex(false),
+          mVisitSamplerArrayIndexNodeInsideLoop(false)
+    {
+    }
</ins><span class="cx"> 
</span><del>-    void FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo&amp; info);
</del><ins>+    virtual bool visitBinary(Visit, TIntermBinary *node);
+    virtual bool visitLoop(Visit, TIntermLoop *node);
+    virtual void visitSymbol(TIntermSymbol *node);
</ins><span class="cx"> 
</span><del>-    // Update the info.currentValue for the next loop iteration.
-    void Step();
</del><ins>+    bool samplerArrayIndexIsFloatLoopIndex() const
+    {
+        return mSamplerArrayIndexIsFloatLoopIndex;
+    }
</ins><span class="cx"> 
</span><del>-    // Return false if loop condition is no longer satisfied.
-    bool SatisfiesLoopCondition();
-
-    // Check if the symbol is the index of a loop that's unrolled.
-    bool NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol);
-
-    // Return the current value of a given loop index symbol.
-    int GetLoopIndexValue(TIntermSymbol* symbol);
-
-    void Push(TLoopIndexInfo&amp; info);
-    void Pop();
-
-    static void MarkForLoopsWithIntegerIndicesForUnrolling(TIntermNode* root);
-
-private:
-    int getLoopIncrement(TIntermLoop* node);
-
-    int evaluateIntConstant(TIntermConstantUnion* node);
-
-    TVector&lt;TLoopIndexInfo&gt; mLoopIndexStack;
</del><ins>+  private:
+    UnrollCondition mUnrollCondition;
+    TLoopStack mLoopStack;
+    bool mSamplerArrayIndexIsFloatLoopIndex;
+    bool mVisitSamplerArrayIndexNodeInsideLoop;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorHashNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/HashNames.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/HashNames.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/HashNames.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -10,7 +10,6 @@
</span><span class="cx"> #include &lt;map&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
</del><span class="cx"> 
</span><span class="cx"> #define HASHED_NAME_PREFIX &quot;webgl_&quot;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorInitializecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Initialize.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Initialize.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Initialize.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,11 +1,11 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="cx"> 
</span><span class="cx"> //
</span><del>-// Create strings that declare built-in definitions, add built-ins that
</del><ins>+// Create symbols that declare built-in definitions, add built-ins that
</ins><span class="cx"> // cannot be expressed in the files, and establish mappings between 
</span><span class="cx"> // built-in functions and operators.
</span><span class="cx"> //
</span><span class="lines">@@ -16,406 +16,582 @@
</span><span class="cx"> 
</span><span class="cx"> void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &amp;resources, TSymbolTable &amp;symbolTable)
</span><span class="cx"> {
</span><del>-    TType *float1 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 1);
-    TType *float2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2);
-    TType *float3 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 3);
-    TType *float4 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 4);
</del><ins>+    TType *float1 = new TType(EbtFloat);
+    TType *float2 = new TType(EbtFloat, 2);
+    TType *float3 = new TType(EbtFloat, 3);
+    TType *float4 = new TType(EbtFloat, 4);
</ins><span class="cx"> 
</span><del>-    TType *int2 = new TType(EbtInt, EbpUndefined, EvqGlobal, 2);
-    TType *int3 = new TType(EbtInt, EbpUndefined, EvqGlobal, 3);
-    TType *int4 = new TType(EbtInt, EbpUndefined, EvqGlobal, 4);
</del><ins>+    TType *int1 = new TType(EbtInt);
+    TType *int2 = new TType(EbtInt, 2);
+    TType *int3 = new TType(EbtInt, 3);
+    TType *int4 = new TType(EbtInt, 4);
</ins><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // Angle and Trigonometric Functions.
</span><span class="cx">     //
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;radians&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;radians&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;radians&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;radians&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;radians&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;radians&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;radians&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;radians&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;degrees&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;degrees&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;degrees&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;degrees&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;degrees&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;degrees&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;degrees&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;degrees&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;sin&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;sin&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;sin&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;sin&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;sin&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;sin&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;sin&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;sin&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;cos&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;cos&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;cos&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;cos&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;cos&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;cos&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;cos&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;cos&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;tan&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;tan&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;tan&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;tan&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;tan&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;tan&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;tan&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;tan&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;asin&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;asin&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;asin&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;asin&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;asin&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;asin&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;asin&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;asin&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;acos&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;acos&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;acos&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;acos&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;acos&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;acos&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;acos&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;acos&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;atan&quot;, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;atan&quot;, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;atan&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;atan&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;atan&quot;, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;atan&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;atan&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;atan&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;atan&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;atan&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;atan&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;atan&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;atan&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;atan&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;atan&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;atan&quot;, float4);
</ins><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // Exponential Functions.
</span><span class="cx">     //
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;pow&quot;, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;pow&quot;, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;pow&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;pow&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;pow&quot;, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;pow&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;pow&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;pow&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;exp&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;exp&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;exp&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;exp&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;exp&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;exp&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;exp&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;exp&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;log&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;log&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;log&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;log&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;log&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;log&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;log&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;log&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;exp2&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;exp2&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;exp2&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;exp2&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;exp2&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;exp2&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;exp2&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;exp2&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;log2&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;log2&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;log2&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;log2&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;log2&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;log2&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;log2&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;log2&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;sqrt&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;sqrt&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;sqrt&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;sqrt&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;sqrt&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;sqrt&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;sqrt&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;sqrt&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;inversesqrt&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;inversesqrt&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;inversesqrt&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;inversesqrt&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;inversesqrt&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;inversesqrt&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;inversesqrt&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;inversesqrt&quot;, float4);
</ins><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // Common Functions.
</span><span class="cx">     //
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;abs&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;abs&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;abs&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;abs&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;abs&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;abs&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;abs&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;abs&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;sign&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;sign&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;sign&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;sign&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;sign&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;sign&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;sign&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;sign&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;floor&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;floor&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;floor&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;floor&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;floor&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;floor&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;floor&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;floor&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;ceil&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;ceil&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;ceil&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;ceil&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;ceil&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;ceil&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;ceil&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;ceil&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;fract&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;fract&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;fract&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;fract&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;fract&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;fract&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;fract&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;fract&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;mod&quot;, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;mod&quot;, float2, float1);
-    symbolTable.insertBuiltIn(float3, &quot;mod&quot;, float3, float1);
-    symbolTable.insertBuiltIn(float4, &quot;mod&quot;, float4, float1);
-    symbolTable.insertBuiltIn(float2, &quot;mod&quot;, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;mod&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;mod&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;mod&quot;, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;mod&quot;, float2, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;mod&quot;, float3, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;mod&quot;, float4, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;mod&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;mod&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;mod&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;min&quot;, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;min&quot;, float2, float1);
-    symbolTable.insertBuiltIn(float3, &quot;min&quot;, float3, float1);
-    symbolTable.insertBuiltIn(float4, &quot;min&quot;, float4, float1);
-    symbolTable.insertBuiltIn(float2, &quot;min&quot;, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;min&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;min&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;min&quot;, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;min&quot;, float2, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;min&quot;, float3, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;min&quot;, float4, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;min&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;min&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;min&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;max&quot;, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;max&quot;, float2, float1);
-    symbolTable.insertBuiltIn(float3, &quot;max&quot;, float3, float1);
-    symbolTable.insertBuiltIn(float4, &quot;max&quot;, float4, float1);
-    symbolTable.insertBuiltIn(float2, &quot;max&quot;, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;max&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;max&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;max&quot;, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;max&quot;, float2, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;max&quot;, float3, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;max&quot;, float4, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;max&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;max&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;max&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;clamp&quot;, float1, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;clamp&quot;, float2, float1, float1);
-    symbolTable.insertBuiltIn(float3, &quot;clamp&quot;, float3, float1, float1);
-    symbolTable.insertBuiltIn(float4, &quot;clamp&quot;, float4, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;clamp&quot;, float2, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;clamp&quot;, float3, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;clamp&quot;, float4, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;clamp&quot;, float1, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;clamp&quot;, float2, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;clamp&quot;, float3, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;clamp&quot;, float4, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;clamp&quot;, float2, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;clamp&quot;, float3, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;clamp&quot;, float4, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;mix&quot;, float1, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;mix&quot;, float2, float2, float1);
-    symbolTable.insertBuiltIn(float3, &quot;mix&quot;, float3, float3, float1);
-    symbolTable.insertBuiltIn(float4, &quot;mix&quot;, float4, float4, float1);
-    symbolTable.insertBuiltIn(float2, &quot;mix&quot;, float2, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;mix&quot;, float3, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;mix&quot;, float4, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;mix&quot;, float1, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;mix&quot;, float2, float2, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;mix&quot;, float3, float3, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;mix&quot;, float4, float4, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;mix&quot;, float2, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;mix&quot;, float3, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;mix&quot;, float4, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;step&quot;, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;step&quot;, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;step&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;step&quot;, float4, float4);
-    symbolTable.insertBuiltIn(float2, &quot;step&quot;, float1, float2);
-    symbolTable.insertBuiltIn(float3, &quot;step&quot;, float1, float3);
-    symbolTable.insertBuiltIn(float4, &quot;step&quot;, float1, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;step&quot;, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;step&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;step&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;step&quot;, float4, float4);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;step&quot;, float1, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;step&quot;, float1, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;step&quot;, float1, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;smoothstep&quot;, float1, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;smoothstep&quot;, float2, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;smoothstep&quot;, float3, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;smoothstep&quot;, float4, float4, float4);
-    symbolTable.insertBuiltIn(float2, &quot;smoothstep&quot;, float1, float1, float2);
-    symbolTable.insertBuiltIn(float3, &quot;smoothstep&quot;, float1, float1, float3);
-    symbolTable.insertBuiltIn(float4, &quot;smoothstep&quot;, float1, float1, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;smoothstep&quot;, float1, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;smoothstep&quot;, float2, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;smoothstep&quot;, float3, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;smoothstep&quot;, float4, float4, float4);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;smoothstep&quot;, float1, float1, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;smoothstep&quot;, float1, float1, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;smoothstep&quot;, float1, float1, float4);
</ins><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // Geometric Functions.
</span><span class="cx">     //
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;length&quot;, float1);
-    symbolTable.insertBuiltIn(float1, &quot;length&quot;, float2);
-    symbolTable.insertBuiltIn(float1, &quot;length&quot;, float3);
-    symbolTable.insertBuiltIn(float1, &quot;length&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;length&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;length&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;length&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;length&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;distance&quot;, float1, float1);
-    symbolTable.insertBuiltIn(float1, &quot;distance&quot;, float2, float2);
-    symbolTable.insertBuiltIn(float1, &quot;distance&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float1, &quot;distance&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;distance&quot;, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;distance&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;distance&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;distance&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;dot&quot;, float1, float1);
-    symbolTable.insertBuiltIn(float1, &quot;dot&quot;, float2, float2);
-    symbolTable.insertBuiltIn(float1, &quot;dot&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float1, &quot;dot&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;dot&quot;, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;dot&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;dot&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;dot&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float3, &quot;cross&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float1, &quot;normalize&quot;, float1);
-    symbolTable.insertBuiltIn(float2, &quot;normalize&quot;, float2);
-    symbolTable.insertBuiltIn(float3, &quot;normalize&quot;, float3);
-    symbolTable.insertBuiltIn(float4, &quot;normalize&quot;, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;cross&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;normalize&quot;, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;normalize&quot;, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;normalize&quot;, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;normalize&quot;, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;faceforward&quot;, float1, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;faceforward&quot;, float2, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;faceforward&quot;, float3, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;faceforward&quot;, float4, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;faceforward&quot;, float1, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;faceforward&quot;, float2, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;faceforward&quot;, float3, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;faceforward&quot;, float4, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;reflect&quot;, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;reflect&quot;, float2, float2);
-    symbolTable.insertBuiltIn(float3, &quot;reflect&quot;, float3, float3);
-    symbolTable.insertBuiltIn(float4, &quot;reflect&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;reflect&quot;, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;reflect&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;reflect&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;reflect&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(float1, &quot;refract&quot;, float1, float1, float1);
-    symbolTable.insertBuiltIn(float2, &quot;refract&quot;, float2, float2, float1);
-    symbolTable.insertBuiltIn(float3, &quot;refract&quot;, float3, float3, float1);
-    symbolTable.insertBuiltIn(float4, &quot;refract&quot;, float4, float4, float1);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, &quot;refract&quot;, float1, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, &quot;refract&quot;, float2, float2, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, &quot;refract&quot;, float3, float3, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, &quot;refract&quot;, float4, float4, float1);
</ins><span class="cx"> 
</span><del>-    TType *mat2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2, true);
-    TType *mat3 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 3, true);
-    TType *mat4 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 4, true);
</del><ins>+    TType *mat2 = new TType(EbtFloat, 2, 2);
+    TType *mat3 = new TType(EbtFloat, 3, 3);
+    TType *mat4 = new TType(EbtFloat, 4, 4);
</ins><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // Matrix Functions.
</span><span class="cx">     //
</span><del>-    symbolTable.insertBuiltIn(mat2, &quot;matrixCompMult&quot;, mat2, mat2);
-    symbolTable.insertBuiltIn(mat3, &quot;matrixCompMult&quot;, mat3, mat3);
-    symbolTable.insertBuiltIn(mat4, &quot;matrixCompMult&quot;, mat4, mat4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, mat2, &quot;matrixCompMult&quot;, mat2, mat2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, mat3, &quot;matrixCompMult&quot;, mat3, mat3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, mat4, &quot;matrixCompMult&quot;, mat4, mat4);
</ins><span class="cx"> 
</span><del>-    TType *bool1 = new TType(EbtBool, EbpUndefined, EvqGlobal, 1);
-    TType *bool2 = new TType(EbtBool, EbpUndefined, EvqGlobal, 2);
-    TType *bool3 = new TType(EbtBool, EbpUndefined, EvqGlobal, 3);
-    TType *bool4 = new TType(EbtBool, EbpUndefined, EvqGlobal, 4);
</del><ins>+    TType *bool1 = new TType(EbtBool);
+    TType *bool2 = new TType(EbtBool, 2);
+    TType *bool3 = new TType(EbtBool, 3);
+    TType *bool4 = new TType(EbtBool, 4);
</ins><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // Vector relational functions.
</span><span class="cx">     //
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;lessThan&quot;, float2, float2);
-    symbolTable.insertBuiltIn(bool3, &quot;lessThan&quot;, float3, float3);
-    symbolTable.insertBuiltIn(bool4, &quot;lessThan&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;lessThan&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;lessThan&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;lessThan&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;lessThan&quot;, int2, int2);
-    symbolTable.insertBuiltIn(bool3, &quot;lessThan&quot;, int3, int3);
-    symbolTable.insertBuiltIn(bool4, &quot;lessThan&quot;, int4, int4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;lessThan&quot;, int2, int2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;lessThan&quot;, int3, int3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;lessThan&quot;, int4, int4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;lessThanEqual&quot;, float2, float2);
-    symbolTable.insertBuiltIn(bool3, &quot;lessThanEqual&quot;, float3, float3);
-    symbolTable.insertBuiltIn(bool4, &quot;lessThanEqual&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;lessThanEqual&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;lessThanEqual&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;lessThanEqual&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;lessThanEqual&quot;, int2, int2);
-    symbolTable.insertBuiltIn(bool3, &quot;lessThanEqual&quot;, int3, int3);
-    symbolTable.insertBuiltIn(bool4, &quot;lessThanEqual&quot;, int4, int4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;lessThanEqual&quot;, int2, int2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;lessThanEqual&quot;, int3, int3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;lessThanEqual&quot;, int4, int4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;greaterThan&quot;, float2, float2);
-    symbolTable.insertBuiltIn(bool3, &quot;greaterThan&quot;, float3, float3);
-    symbolTable.insertBuiltIn(bool4, &quot;greaterThan&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;greaterThan&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;greaterThan&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;greaterThan&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;greaterThan&quot;, int2, int2);
-    symbolTable.insertBuiltIn(bool3, &quot;greaterThan&quot;, int3, int3);
-    symbolTable.insertBuiltIn(bool4, &quot;greaterThan&quot;, int4, int4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;greaterThan&quot;, int2, int2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;greaterThan&quot;, int3, int3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;greaterThan&quot;, int4, int4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;greaterThanEqual&quot;, float2, float2);
-    symbolTable.insertBuiltIn(bool3, &quot;greaterThanEqual&quot;, float3, float3);
-    symbolTable.insertBuiltIn(bool4, &quot;greaterThanEqual&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;greaterThanEqual&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;greaterThanEqual&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;greaterThanEqual&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;greaterThanEqual&quot;, int2, int2);
-    symbolTable.insertBuiltIn(bool3, &quot;greaterThanEqual&quot;, int3, int3);
-    symbolTable.insertBuiltIn(bool4, &quot;greaterThanEqual&quot;, int4, int4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;greaterThanEqual&quot;, int2, int2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;greaterThanEqual&quot;, int3, int3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;greaterThanEqual&quot;, int4, int4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;equal&quot;, float2, float2);
-    symbolTable.insertBuiltIn(bool3, &quot;equal&quot;, float3, float3);
-    symbolTable.insertBuiltIn(bool4, &quot;equal&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;equal&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;equal&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;equal&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;equal&quot;, int2, int2);
-    symbolTable.insertBuiltIn(bool3, &quot;equal&quot;, int3, int3);
-    symbolTable.insertBuiltIn(bool4, &quot;equal&quot;, int4, int4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;equal&quot;, int2, int2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;equal&quot;, int3, int3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;equal&quot;, int4, int4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;equal&quot;, bool2, bool2);
-    symbolTable.insertBuiltIn(bool3, &quot;equal&quot;, bool3, bool3);
-    symbolTable.insertBuiltIn(bool4, &quot;equal&quot;, bool4, bool4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;equal&quot;, bool2, bool2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;equal&quot;, bool3, bool3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;equal&quot;, bool4, bool4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;notEqual&quot;, float2, float2);
-    symbolTable.insertBuiltIn(bool3, &quot;notEqual&quot;, float3, float3);
-    symbolTable.insertBuiltIn(bool4, &quot;notEqual&quot;, float4, float4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;notEqual&quot;, float2, float2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;notEqual&quot;, float3, float3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;notEqual&quot;, float4, float4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;notEqual&quot;, int2, int2);
-    symbolTable.insertBuiltIn(bool3, &quot;notEqual&quot;, int3, int3);
-    symbolTable.insertBuiltIn(bool4, &quot;notEqual&quot;, int4, int4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;notEqual&quot;, int2, int2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;notEqual&quot;, int3, int3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;notEqual&quot;, int4, int4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;notEqual&quot;, bool2, bool2);
-    symbolTable.insertBuiltIn(bool3, &quot;notEqual&quot;, bool3, bool3);
-    symbolTable.insertBuiltIn(bool4, &quot;notEqual&quot;, bool4, bool4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;notEqual&quot;, bool2, bool2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;notEqual&quot;, bool3, bool3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;notEqual&quot;, bool4, bool4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool1, &quot;any&quot;, bool2);
-    symbolTable.insertBuiltIn(bool1, &quot;any&quot;, bool3);
-    symbolTable.insertBuiltIn(bool1, &quot;any&quot;, bool4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, &quot;any&quot;, bool2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, &quot;any&quot;, bool3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, &quot;any&quot;, bool4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool1, &quot;all&quot;, bool2);
-    symbolTable.insertBuiltIn(bool1, &quot;all&quot;, bool3);
-    symbolTable.insertBuiltIn(bool1, &quot;all&quot;, bool4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, &quot;all&quot;, bool2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, &quot;all&quot;, bool3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, &quot;all&quot;, bool4);
</ins><span class="cx"> 
</span><del>-    symbolTable.insertBuiltIn(bool2, &quot;not&quot;, bool2);
-    symbolTable.insertBuiltIn(bool3, &quot;not&quot;, bool3);
-    symbolTable.insertBuiltIn(bool4, &quot;not&quot;, bool4);
</del><ins>+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, &quot;not&quot;, bool2);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, &quot;not&quot;, bool3);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, &quot;not&quot;, bool4);
</ins><span class="cx"> 
</span><del>-    TType *sampler2D = new TType(EbtSampler2D, EbpUndefined, EvqGlobal, 1);
-    TType *samplerCube = new TType(EbtSamplerCube, EbpUndefined, EvqGlobal, 1);
</del><ins>+    TType *sampler2D = new TType(EbtSampler2D);
+    TType *samplerCube = new TType(EbtSamplerCube);
</ins><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // Texture Functions for GLSL ES 1.0
</span><span class="cx">     //
</span><del>-    symbolTable.insertBuiltIn(float4, &quot;texture2D&quot;, sampler2D, float2);
-    symbolTable.insertBuiltIn(float4, &quot;texture2DProj&quot;, sampler2D, float3);
-    symbolTable.insertBuiltIn(float4, &quot;texture2DProj&quot;, sampler2D, float4);
-    symbolTable.insertBuiltIn(float4, &quot;textureCube&quot;, samplerCube, float3);
</del><ins>+    symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2D&quot;, sampler2D, float2);
+    symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProj&quot;, sampler2D, float3);
+    symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProj&quot;, sampler2D, float4);
+    symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;textureCube&quot;, samplerCube, float3);
</ins><span class="cx"> 
</span><span class="cx">     if (resources.OES_EGL_image_external)
</span><span class="cx">     {
</span><del>-        TType *samplerExternalOES = new TType(EbtSamplerExternalOES, EbpUndefined, EvqGlobal, 1);
</del><ins>+        TType *samplerExternalOES = new TType(EbtSamplerExternalOES);
</ins><span class="cx"> 
</span><del>-        symbolTable.insertBuiltIn(float4, &quot;texture2D&quot;, samplerExternalOES, float2);
-        symbolTable.insertBuiltIn(float4, &quot;texture2DProj&quot;, samplerExternalOES, float3);
-        symbolTable.insertBuiltIn(float4, &quot;texture2DProj&quot;, samplerExternalOES, float4);
</del><ins>+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2D&quot;, samplerExternalOES, float2);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProj&quot;, samplerExternalOES, float3);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProj&quot;, samplerExternalOES, float4);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (resources.ARB_texture_rectangle)
</span><span class="cx">     {
</span><del>-        TType *sampler2DRect = new TType(EbtSampler2DRect, EbpUndefined, EvqGlobal, 1);
</del><ins>+        TType *sampler2DRect = new TType(EbtSampler2DRect);
</ins><span class="cx"> 
</span><del>-        symbolTable.insertBuiltIn(float4, &quot;texture2DRect&quot;, sampler2DRect, float2);
-        symbolTable.insertBuiltIn(float4, &quot;texture2DRectProj&quot;, sampler2DRect, float3);
-        symbolTable.insertBuiltIn(float4, &quot;texture2DRectProj&quot;, sampler2DRect, float4);
</del><ins>+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DRect&quot;, sampler2DRect, float2);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DRectProj&quot;, sampler2DRect, float3);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DRectProj&quot;, sampler2DRect, float4);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (resources.EXT_shader_texture_lod)
+    {
+        /* The *Grad* variants are new to both vertex and fragment shaders; the fragment
+         * shader specific pieces are added separately below.
+         */
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DGradEXT&quot;, sampler2D, float2, float2, float2);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProjGradEXT&quot;, sampler2D, float3, float2, float2);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProjGradEXT&quot;, sampler2D, float4, float2, float2);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;textureCubeGradEXT&quot;, samplerCube, float3, float3, float3);
+    }
+
</ins><span class="cx">     if (type == SH_FRAGMENT_SHADER)
</span><span class="cx">     {
</span><del>-        symbolTable.insertBuiltIn(float4, &quot;texture2D&quot;, sampler2D, float2, float1);
-        symbolTable.insertBuiltIn(float4, &quot;texture2DProj&quot;, sampler2D, float3, float1);
-        symbolTable.insertBuiltIn(float4, &quot;texture2DProj&quot;, sampler2D, float4, float1);
-        symbolTable.insertBuiltIn(float4, &quot;textureCube&quot;, samplerCube, float3, float1);
</del><ins>+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2D&quot;, sampler2D, float2, float1);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProj&quot;, sampler2D, float3, float1);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProj&quot;, sampler2D, float4, float1);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;textureCube&quot;, samplerCube, float3, float1);
</ins><span class="cx"> 
</span><span class="cx">         if (resources.OES_standard_derivatives)
</span><span class="cx">         {
</span><del>-            symbolTable.insertBuiltIn(float1, &quot;dFdx&quot;, float1);
-            symbolTable.insertBuiltIn(float2, &quot;dFdx&quot;, float2);
-            symbolTable.insertBuiltIn(float3, &quot;dFdx&quot;, float3);
-            symbolTable.insertBuiltIn(float4, &quot;dFdx&quot;, float4);
-            
-            symbolTable.insertBuiltIn(float1, &quot;dFdy&quot;, float1);
-            symbolTable.insertBuiltIn(float2, &quot;dFdy&quot;, float2);
-            symbolTable.insertBuiltIn(float3, &quot;dFdy&quot;, float3);
-            symbolTable.insertBuiltIn(float4, &quot;dFdy&quot;, float4);
</del><ins>+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, &quot;dFdx&quot;, float1);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, &quot;dFdx&quot;, float2);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, &quot;dFdx&quot;, float3);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;dFdx&quot;, float4);
</ins><span class="cx"> 
</span><del>-            symbolTable.insertBuiltIn(float1, &quot;fwidth&quot;, float1);
-            symbolTable.insertBuiltIn(float2, &quot;fwidth&quot;, float2);
-            symbolTable.insertBuiltIn(float3, &quot;fwidth&quot;, float3);
-            symbolTable.insertBuiltIn(float4, &quot;fwidth&quot;, float4);
</del><ins>+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, &quot;dFdy&quot;, float1);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, &quot;dFdy&quot;, float2);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, &quot;dFdy&quot;, float3);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;dFdy&quot;, float4);
+
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, &quot;fwidth&quot;, float1);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, &quot;fwidth&quot;, float2);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, &quot;fwidth&quot;, float3);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;fwidth&quot;, float4);
</ins><span class="cx">         }
</span><ins>+
+        if (resources.EXT_shader_texture_lod)
+        {
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DLodEXT&quot;, sampler2D, float2, float1);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProjLodEXT&quot;, sampler2D, float3, float1);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProjLodEXT&quot;, sampler2D, float4, float1);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;textureCubeLodEXT&quot;, samplerCube, float3, float1);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if(type == SH_VERTEX_SHADER)
</span><span class="cx">     {
</span><del>-        symbolTable.insertBuiltIn(float4, &quot;texture2DLod&quot;, sampler2D, float2, float1);
-        symbolTable.insertBuiltIn(float4, &quot;texture2DProjLod&quot;, sampler2D, float3, float1);
-        symbolTable.insertBuiltIn(float4, &quot;texture2DProjLod&quot;, sampler2D, float4, float1);
-        symbolTable.insertBuiltIn(float4, &quot;textureCubeLod&quot;, samplerCube, float3, float1);
</del><ins>+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DLod&quot;, sampler2D, float2, float1);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProjLod&quot;, sampler2D, float3, float1);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;texture2DProjLod&quot;, sampler2D, float4, float1);
+        symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, &quot;textureCubeLod&quot;, samplerCube, float3, float1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    TType *gvec4 = new TType(EbtGVec4);
+
+    TType *gsampler2D = new TType(EbtGSampler2D);
+    TType *gsamplerCube = new TType(EbtGSamplerCube);
+    TType *gsampler3D = new TType(EbtGSampler3D);
+    TType *gsampler2DArray = new TType(EbtGSampler2DArray);
+
</ins><span class="cx">     //
</span><ins>+    // Texture Functions for GLSL ES 3.0
+    //
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texture&quot;, gsampler2D, float2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texture&quot;, gsampler3D, float3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texture&quot;, gsamplerCube, float3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texture&quot;, gsampler2DArray, float3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProj&quot;, gsampler2D, float3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProj&quot;, gsampler2D, float4);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProj&quot;, gsampler3D, float4);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureLod&quot;, gsampler2D, float2, float1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureLod&quot;, gsampler3D, float3, float1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureLod&quot;, gsamplerCube, float3, float1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureLod&quot;, gsampler2DArray, float3, float1);
+
+    if (type == SH_FRAGMENT_SHADER)
+    {
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texture&quot;, gsampler2D, float2, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texture&quot;, gsampler3D, float3, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texture&quot;, gsamplerCube, float3, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texture&quot;, gsampler2DArray, float3, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProj&quot;, gsampler2D, float3, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProj&quot;, gsampler2D, float4, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProj&quot;, gsampler3D, float4, float1);
+    }
+
+    TType *sampler2DShadow = new TType(EbtSampler2DShadow);
+    TType *samplerCubeShadow = new TType(EbtSamplerCubeShadow);
+    TType *sampler2DArrayShadow = new TType(EbtSampler2DArrayShadow);
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;texture&quot;, sampler2DShadow, float3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;texture&quot;, samplerCubeShadow, float4);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;texture&quot;, sampler2DArrayShadow, float4);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureProj&quot;, sampler2DShadow, float4);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureLod&quot;, sampler2DShadow, float3, float1);
+
+    if (type == SH_FRAGMENT_SHADER)
+    {
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;texture&quot;, sampler2DShadow, float3, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;texture&quot;, samplerCubeShadow, float4, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureProj&quot;, sampler2DShadow, float4, float1);
+    }
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, &quot;textureSize&quot;, gsampler2D, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, &quot;textureSize&quot;, gsampler3D, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, &quot;textureSize&quot;, gsamplerCube, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, &quot;textureSize&quot;, gsampler2DArray, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, &quot;textureSize&quot;, sampler2DShadow, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, &quot;textureSize&quot;, samplerCubeShadow, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, &quot;textureSize&quot;, sampler2DArrayShadow, int1);
+
+    if(type == SH_FRAGMENT_SHADER)
+    {
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;dFdx&quot;, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, &quot;dFdx&quot;, float2);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, &quot;dFdx&quot;, float3);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, &quot;dFdx&quot;, float4);
+            
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;dFdy&quot;, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, &quot;dFdy&quot;, float2);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, &quot;dFdy&quot;, float3);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, &quot;dFdy&quot;, float4);
+
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;fwidth&quot;, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, &quot;fwidth&quot;, float2);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, &quot;fwidth&quot;, float3);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, &quot;fwidth&quot;, float4);
+    }
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureOffset&quot;, gsampler2D, float2, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureOffset&quot;, gsampler3D, float3, int3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureOffset&quot;, sampler2DShadow, float3, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureOffset&quot;, gsampler2DArray, float3, int2);
+
+    if(type == SH_FRAGMENT_SHADER)
+    {
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureOffset&quot;, gsampler2D, float2, int2, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureOffset&quot;, gsampler3D, float3, int3, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureOffset&quot;, sampler2DShadow, float3, int2, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureOffset&quot;, gsampler2DArray, float3, int2, float1);
+    }
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjOffset&quot;, gsampler2D, float3, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjOffset&quot;, gsampler2D, float4, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjOffset&quot;, gsampler3D, float4, int3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureProjOffset&quot;, sampler2DShadow, float4, int2);
+
+    if(type == SH_FRAGMENT_SHADER)
+    {
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjOffset&quot;, gsampler2D, float3, int2, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjOffset&quot;, gsampler2D, float4, int2, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjOffset&quot;, gsampler3D, float4, int3, float1);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureProjOffset&quot;, sampler2DShadow, float4, int2, float1);
+    }
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureLodOffset&quot;, gsampler2D, float2, float1, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureLodOffset&quot;, gsampler3D, float3, float1, int3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureLodOffset&quot;, sampler2DShadow, float3, float1, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureLodOffset&quot;, gsampler2DArray, float3, float1, int2);
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjLod&quot;, gsampler2D, float3, float1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjLod&quot;, gsampler2D, float4, float1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjLod&quot;, gsampler3D, float4, float1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureProjLod&quot;, sampler2DShadow, float4, float1);
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjLodOffset&quot;, gsampler2D, float3, float1, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjLodOffset&quot;, gsampler2D, float4, float1, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjLodOffset&quot;, gsampler3D, float4, float1, int3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureProjLodOffset&quot;, sampler2DShadow, float4, float1, int2);
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texelFetch&quot;, gsampler2D, int2, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texelFetch&quot;, gsampler3D, int3, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texelFetch&quot;, gsampler2DArray, int3, int1);
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texelFetchOffset&quot;, gsampler2D, int2, int1, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texelFetchOffset&quot;, gsampler3D, int3, int1, int3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;texelFetchOffset&quot;, gsampler2DArray, int3, int1, int2);
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureGrad&quot;, gsampler2D, float2, float2, float2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureGrad&quot;, gsampler3D, float3, float3, float3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureGrad&quot;, gsamplerCube, float3, float3, float3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureGrad&quot;, sampler2DShadow, float3, float2, float2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureGrad&quot;, samplerCubeShadow, float4, float3, float3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureGrad&quot;, gsampler2DArray, float3, float2, float2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureGrad&quot;, sampler2DArrayShadow, float4, float2, float2);
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureGradOffset&quot;, gsampler2D, float2, float2, float2, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureGradOffset&quot;, gsampler3D, float3, float3, float3, int3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureGradOffset&quot;, sampler2DShadow, float3, float2, float2, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureGradOffset&quot;, gsampler2DArray, float3, float2, float2, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureGradOffset&quot;, sampler2DArrayShadow, float4, float2, float2, int2);
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjGrad&quot;, gsampler2D, float3, float2, float2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjGrad&quot;, gsampler2D, float4, float2, float2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjGrad&quot;, gsampler3D, float4, float3, float3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureProjGrad&quot;, sampler2DShadow, float4, float2, float2);
+
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjGradOffset&quot;, gsampler2D, float3, float2, float2, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjGradOffset&quot;, gsampler2D, float4, float2, float2, int2);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, &quot;textureProjGradOffset&quot;, gsampler3D, float4, float3, float3, int3);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, &quot;textureProjGradOffset&quot;, sampler2DShadow, float4, float2, float2, int2);
+
+    //
</ins><span class="cx">     // Depth range in window coordinates
</span><span class="cx">     //
</span><span class="cx">     TFieldList *fields = NewPoolTFieldList();
</span><del>-    TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString(&quot;near&quot;));
-    TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString(&quot;far&quot;));
-    TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString(&quot;diff&quot;));
</del><ins>+    TSourceLoc zeroSourceLoc = {0};
+    TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString(&quot;near&quot;), zeroSourceLoc);
+    TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString(&quot;far&quot;), zeroSourceLoc);
+    TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString(&quot;diff&quot;), zeroSourceLoc);
</ins><span class="cx">     fields-&gt;push_back(near);
</span><span class="cx">     fields-&gt;push_back(far);
</span><span class="cx">     fields-&gt;push_back(diff);
</span><span class="cx">     TStructure *depthRangeStruct = new TStructure(NewPoolTString(&quot;gl_DepthRangeParameters&quot;), fields);
</span><span class="cx">     TVariable *depthRangeParameters = new TVariable(&amp;depthRangeStruct-&gt;name(), depthRangeStruct, true);
</span><del>-    symbolTable.insert(*depthRangeParameters);
</del><ins>+    symbolTable.insert(COMMON_BUILTINS, *depthRangeParameters);
</ins><span class="cx">     TVariable *depthRange = new TVariable(NewPoolTString(&quot;gl_DepthRange&quot;), TType(depthRangeStruct));
</span><span class="cx">     depthRange-&gt;setQualifier(EvqUniform);
</span><del>-    symbolTable.insert(*depthRange);
</del><ins>+    symbolTable.insert(COMMON_BUILTINS, *depthRange);
</ins><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // Implementation dependent built-in constants.
</span><span class="cx">     //
</span><del>-    symbolTable.insertConstInt(&quot;gl_MaxVertexAttribs&quot;, resources.MaxVertexAttribs);
-    symbolTable.insertConstInt(&quot;gl_MaxVertexUniformVectors&quot;, resources.MaxVertexUniformVectors);
-    symbolTable.insertConstInt(&quot;gl_MaxVaryingVectors&quot;, resources.MaxVaryingVectors);
-    symbolTable.insertConstInt(&quot;gl_MaxVertexTextureImageUnits&quot;, resources.MaxVertexTextureImageUnits);
-    symbolTable.insertConstInt(&quot;gl_MaxCombinedTextureImageUnits&quot;, resources.MaxCombinedTextureImageUnits);
-    symbolTable.insertConstInt(&quot;gl_MaxTextureImageUnits&quot;, resources.MaxTextureImageUnits);
-    symbolTable.insertConstInt(&quot;gl_MaxFragmentUniformVectors&quot;, resources.MaxFragmentUniformVectors);
</del><ins>+    symbolTable.insertConstInt(COMMON_BUILTINS, &quot;gl_MaxVertexAttribs&quot;, resources.MaxVertexAttribs);
+    symbolTable.insertConstInt(COMMON_BUILTINS, &quot;gl_MaxVertexUniformVectors&quot;, resources.MaxVertexUniformVectors);
+    symbolTable.insertConstInt(COMMON_BUILTINS, &quot;gl_MaxVertexTextureImageUnits&quot;, resources.MaxVertexTextureImageUnits);
+    symbolTable.insertConstInt(COMMON_BUILTINS, &quot;gl_MaxCombinedTextureImageUnits&quot;, resources.MaxCombinedTextureImageUnits);
+    symbolTable.insertConstInt(COMMON_BUILTINS, &quot;gl_MaxTextureImageUnits&quot;, resources.MaxTextureImageUnits);
+    symbolTable.insertConstInt(COMMON_BUILTINS, &quot;gl_MaxFragmentUniformVectors&quot;, resources.MaxFragmentUniformVectors);
</ins><span class="cx"> 
</span><ins>+    symbolTable.insertConstInt(ESSL1_BUILTINS, &quot;gl_MaxVaryingVectors&quot;, resources.MaxVaryingVectors);
+
</ins><span class="cx">     if (spec != SH_CSS_SHADERS_SPEC)
</span><span class="cx">     {
</span><del>-        symbolTable.insertConstInt(&quot;gl_MaxDrawBuffers&quot;, resources.MaxDrawBuffers);
</del><ins>+        symbolTable.insertConstInt(COMMON_BUILTINS, &quot;gl_MaxDrawBuffers&quot;, resources.MaxDrawBuffers);
</ins><span class="cx">     }
</span><ins>+
+    symbolTable.insertConstInt(ESSL3_BUILTINS, &quot;gl_MaxVertexOutputVectors&quot;, resources.MaxVertexOutputVectors);
+    symbolTable.insertConstInt(ESSL3_BUILTINS, &quot;gl_MaxFragmentInputVectors&quot;, resources.MaxFragmentInputVectors);
+    symbolTable.insertConstInt(ESSL3_BUILTINS, &quot;gl_MinProgramTexelOffset&quot;, resources.MinProgramTexelOffset);
+    symbolTable.insertConstInt(ESSL3_BUILTINS, &quot;gl_MaxProgramTexelOffset&quot;, resources.MaxProgramTexelOffset);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
</span><span class="lines">@@ -428,31 +604,31 @@
</span><span class="cx">     //
</span><span class="cx">     switch(type) {
</span><span class="cx">     case SH_FRAGMENT_SHADER:
</span><del>-        symbolTable.insert(*new TVariable(NewPoolTString(&quot;gl_FragCoord&quot;),                       TType(EbtFloat, EbpMedium, EvqFragCoord,   4)));
-        symbolTable.insert(*new TVariable(NewPoolTString(&quot;gl_FrontFacing&quot;),                     TType(EbtBool,  EbpUndefined, EvqFrontFacing, 1)));
-        symbolTable.insert(*new TVariable(NewPoolTString(&quot;gl_PointCoord&quot;),                      TType(EbtFloat, EbpMedium, EvqPointCoord,  2)));
</del><ins>+        symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString(&quot;gl_FragCoord&quot;), TType(EbtFloat, EbpMedium, EvqFragCoord,   4)));
+        symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString(&quot;gl_FrontFacing&quot;), TType(EbtBool,  EbpUndefined, EvqFrontFacing, 1)));
+        symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString(&quot;gl_PointCoord&quot;), TType(EbtFloat, EbpMedium, EvqPointCoord,  2)));
</ins><span class="cx"> 
</span><span class="cx">         //
</span><span class="cx">         // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available.
</span><span class="cx">         // Instead, css_MixColor and css_ColorMatrix are available.
</span><span class="cx">         //
</span><span class="cx">         if (spec != SH_CSS_SHADERS_SPEC) {
</span><del>-            symbolTable.insert(*new TVariable(NewPoolTString(&quot;gl_FragColor&quot;),                   TType(EbtFloat, EbpMedium, EvqFragColor,   4)));
-            symbolTable.insert(*new TVariable(NewPoolTString(&quot;gl_FragData[gl_MaxDrawBuffers]&quot;), TType(EbtFloat, EbpMedium, EvqFragData,    4)));
</del><ins>+            symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString(&quot;gl_FragColor&quot;), TType(EbtFloat, EbpMedium, EvqFragColor,   4)));
+            symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString(&quot;gl_FragData[gl_MaxDrawBuffers]&quot;), TType(EbtFloat, EbpMedium, EvqFragData,    4)));
</ins><span class="cx">             if (resources.EXT_frag_depth) {
</span><del>-                symbolTable.insert(*new TVariable(NewPoolTString(&quot;gl_FragDepthEXT&quot;),            TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1)));
-                symbolTable.relateToExtension(&quot;gl_FragDepthEXT&quot;, &quot;GL_EXT_frag_depth&quot;);
</del><ins>+                symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString(&quot;gl_FragDepthEXT&quot;), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1)));
+                symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;gl_FragDepthEXT&quot;, &quot;GL_EXT_frag_depth&quot;);
</ins><span class="cx">             }
</span><span class="cx">         } else {
</span><del>-            symbolTable.insert(*new TVariable(NewPoolTString(&quot;css_MixColor&quot;),                   TType(EbtFloat, EbpMedium, EvqGlobal,      4)));
-            symbolTable.insert(*new TVariable(NewPoolTString(&quot;css_ColorMatrix&quot;),                TType(EbtFloat, EbpMedium, EvqGlobal,      4, true)));
</del><ins>+            symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString(&quot;css_MixColor&quot;), TType(EbtFloat, EbpMedium, EvqGlobal,      4)));
+            symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString(&quot;css_ColorMatrix&quot;), TType(EbtFloat, EbpMedium, EvqGlobal,      4, 4)));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case SH_VERTEX_SHADER:
</span><del>-        symbolTable.insert(*new TVariable(NewPoolTString(&quot;gl_Position&quot;),    TType(EbtFloat, EbpHigh, EvqPosition,    4)));
-        symbolTable.insert(*new TVariable(NewPoolTString(&quot;gl_PointSize&quot;),   TType(EbtFloat, EbpMedium, EvqPointSize,   1)));
</del><ins>+        symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString(&quot;gl_Position&quot;), TType(EbtFloat, EbpHigh, EvqPosition,    4)));
+        symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString(&quot;gl_PointSize&quot;), TType(EbtFloat, EbpMedium, EvqPointSize,   1)));
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     default: assert(false &amp;&amp; &quot;Language not supported&quot;);
</span><span class="lines">@@ -464,84 +640,102 @@
</span><span class="cx">     // expected to be resolved through a library of functions, versus as
</span><span class="cx">     // operations.
</span><span class="cx">     //
</span><del>-    symbolTable.relateToOperator(&quot;matrixCompMult&quot;,   EOpMul);
</del><ins>+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;matrixCompMult&quot;,   EOpMul);
</ins><span class="cx"> 
</span><del>-    symbolTable.relateToOperator(&quot;equal&quot;,            EOpVectorEqual);
-    symbolTable.relateToOperator(&quot;notEqual&quot;,         EOpVectorNotEqual);
-    symbolTable.relateToOperator(&quot;lessThan&quot;,         EOpLessThan);
-    symbolTable.relateToOperator(&quot;greaterThan&quot;,      EOpGreaterThan);
-    symbolTable.relateToOperator(&quot;lessThanEqual&quot;,    EOpLessThanEqual);
-    symbolTable.relateToOperator(&quot;greaterThanEqual&quot;, EOpGreaterThanEqual);
</del><ins>+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;equal&quot;,            EOpVectorEqual);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;notEqual&quot;,         EOpVectorNotEqual);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;lessThan&quot;,         EOpLessThan);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;greaterThan&quot;,      EOpGreaterThan);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;lessThanEqual&quot;,    EOpLessThanEqual);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;greaterThanEqual&quot;, EOpGreaterThanEqual);
</ins><span class="cx">     
</span><del>-    symbolTable.relateToOperator(&quot;radians&quot;,      EOpRadians);
-    symbolTable.relateToOperator(&quot;degrees&quot;,      EOpDegrees);
-    symbolTable.relateToOperator(&quot;sin&quot;,          EOpSin);
-    symbolTable.relateToOperator(&quot;cos&quot;,          EOpCos);
-    symbolTable.relateToOperator(&quot;tan&quot;,          EOpTan);
-    symbolTable.relateToOperator(&quot;asin&quot;,         EOpAsin);
-    symbolTable.relateToOperator(&quot;acos&quot;,         EOpAcos);
-    symbolTable.relateToOperator(&quot;atan&quot;,         EOpAtan);
</del><ins>+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;radians&quot;,      EOpRadians);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;degrees&quot;,      EOpDegrees);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;sin&quot;,          EOpSin);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;cos&quot;,          EOpCos);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;tan&quot;,          EOpTan);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;asin&quot;,         EOpAsin);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;acos&quot;,         EOpAcos);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;atan&quot;,         EOpAtan);
</ins><span class="cx"> 
</span><del>-    symbolTable.relateToOperator(&quot;pow&quot;,          EOpPow);
-    symbolTable.relateToOperator(&quot;exp2&quot;,         EOpExp2);
-    symbolTable.relateToOperator(&quot;log&quot;,          EOpLog);
-    symbolTable.relateToOperator(&quot;exp&quot;,          EOpExp);
-    symbolTable.relateToOperator(&quot;log2&quot;,         EOpLog2);
-    symbolTable.relateToOperator(&quot;sqrt&quot;,         EOpSqrt);
-    symbolTable.relateToOperator(&quot;inversesqrt&quot;,  EOpInverseSqrt);
</del><ins>+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;pow&quot;,          EOpPow);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;exp2&quot;,         EOpExp2);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;log&quot;,          EOpLog);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;exp&quot;,          EOpExp);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;log2&quot;,         EOpLog2);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;sqrt&quot;,         EOpSqrt);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;inversesqrt&quot;,  EOpInverseSqrt);
</ins><span class="cx"> 
</span><del>-    symbolTable.relateToOperator(&quot;abs&quot;,          EOpAbs);
-    symbolTable.relateToOperator(&quot;sign&quot;,         EOpSign);
-    symbolTable.relateToOperator(&quot;floor&quot;,        EOpFloor);
-    symbolTable.relateToOperator(&quot;ceil&quot;,         EOpCeil);
-    symbolTable.relateToOperator(&quot;fract&quot;,        EOpFract);
-    symbolTable.relateToOperator(&quot;mod&quot;,          EOpMod);
-    symbolTable.relateToOperator(&quot;min&quot;,          EOpMin);
-    symbolTable.relateToOperator(&quot;max&quot;,          EOpMax);
-    symbolTable.relateToOperator(&quot;clamp&quot;,        EOpClamp);
-    symbolTable.relateToOperator(&quot;mix&quot;,          EOpMix);
-    symbolTable.relateToOperator(&quot;step&quot;,         EOpStep);
-    symbolTable.relateToOperator(&quot;smoothstep&quot;,   EOpSmoothStep);
</del><ins>+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;abs&quot;,          EOpAbs);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;sign&quot;,         EOpSign);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;floor&quot;,        EOpFloor);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;ceil&quot;,         EOpCeil);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;fract&quot;,        EOpFract);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;mod&quot;,          EOpMod);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;min&quot;,          EOpMin);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;max&quot;,          EOpMax);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;clamp&quot;,        EOpClamp);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;mix&quot;,          EOpMix);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;step&quot;,         EOpStep);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;smoothstep&quot;,   EOpSmoothStep);
</ins><span class="cx"> 
</span><del>-    symbolTable.relateToOperator(&quot;length&quot;,       EOpLength);
-    symbolTable.relateToOperator(&quot;distance&quot;,     EOpDistance);
-    symbolTable.relateToOperator(&quot;dot&quot;,          EOpDot);
-    symbolTable.relateToOperator(&quot;cross&quot;,        EOpCross);
-    symbolTable.relateToOperator(&quot;normalize&quot;,    EOpNormalize);
-    symbolTable.relateToOperator(&quot;faceforward&quot;,  EOpFaceForward);
-    symbolTable.relateToOperator(&quot;reflect&quot;,      EOpReflect);
-    symbolTable.relateToOperator(&quot;refract&quot;,      EOpRefract);
-    
-    symbolTable.relateToOperator(&quot;any&quot;,          EOpAny);
-    symbolTable.relateToOperator(&quot;all&quot;,          EOpAll);
-    symbolTable.relateToOperator(&quot;not&quot;,          EOpVectorLogicalNot);
</del><ins>+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;length&quot;,       EOpLength);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;distance&quot;,     EOpDistance);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;dot&quot;,          EOpDot);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;cross&quot;,        EOpCross);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;normalize&quot;,    EOpNormalize);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;faceforward&quot;,  EOpFaceForward);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;reflect&quot;,      EOpReflect);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;refract&quot;,      EOpRefract);
</ins><span class="cx"> 
</span><ins>+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;any&quot;,          EOpAny);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;all&quot;,          EOpAll);
+    symbolTable.relateToOperator(COMMON_BUILTINS, &quot;not&quot;,          EOpVectorLogicalNot);
+
</ins><span class="cx">     // Map language-specific operators.
</span><span class="cx">     switch(type) {
</span><span class="cx">     case SH_VERTEX_SHADER:
</span><span class="cx">         break;
</span><span class="cx">     case SH_FRAGMENT_SHADER:
</span><del>-        if (resources.OES_standard_derivatives) {
-            symbolTable.relateToOperator(&quot;dFdx&quot;,   EOpDFdx);
-            symbolTable.relateToOperator(&quot;dFdy&quot;,   EOpDFdy);
-            symbolTable.relateToOperator(&quot;fwidth&quot;, EOpFwidth);
</del><ins>+        if (resources.OES_standard_derivatives)
+        {
+            symbolTable.relateToOperator(ESSL1_BUILTINS, &quot;dFdx&quot;,   EOpDFdx);
+            symbolTable.relateToOperator(ESSL1_BUILTINS, &quot;dFdy&quot;,   EOpDFdy);
+            symbolTable.relateToOperator(ESSL1_BUILTINS, &quot;fwidth&quot;, EOpFwidth);
</ins><span class="cx"> 
</span><del>-            symbolTable.relateToExtension(&quot;dFdx&quot;, &quot;GL_OES_standard_derivatives&quot;);
-            symbolTable.relateToExtension(&quot;dFdy&quot;, &quot;GL_OES_standard_derivatives&quot;);
-            symbolTable.relateToExtension(&quot;fwidth&quot;, &quot;GL_OES_standard_derivatives&quot;);
</del><ins>+            symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;dFdx&quot;, &quot;GL_OES_standard_derivatives&quot;);
+            symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;dFdy&quot;, &quot;GL_OES_standard_derivatives&quot;);
+            symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;fwidth&quot;, &quot;GL_OES_standard_derivatives&quot;);
</ins><span class="cx">         }
</span><ins>+        if (resources.EXT_shader_texture_lod)
+        {
+            symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;texture2DLodEXT&quot;, &quot;GL_EXT_shader_texture_lod&quot;);
+            symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;texture2DProjLodEXT&quot;, &quot;GL_EXT_shader_texture_lod&quot;);
+            symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;textureCubeLodEXT&quot;, &quot;GL_EXT_shader_texture_lod&quot;);
+        }
</ins><span class="cx">         break;
</span><span class="cx">     default: break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    symbolTable.relateToOperator(ESSL3_BUILTINS, &quot;dFdx&quot;,   EOpDFdx);
+    symbolTable.relateToOperator(ESSL3_BUILTINS, &quot;dFdy&quot;,   EOpDFdy);
+    symbolTable.relateToOperator(ESSL3_BUILTINS, &quot;fwidth&quot;, EOpFwidth);
+
+    if (resources.EXT_shader_texture_lod)
+    {
+        symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;texture2DGradEXT&quot;, &quot;GL_EXT_shader_texture_lod&quot;);
+        symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;texture2DProjGradEXT&quot;, &quot;GL_EXT_shader_texture_lod&quot;);
+        symbolTable.relateToExtension(ESSL1_BUILTINS, &quot;textureCubeGradEXT&quot;, &quot;GL_EXT_shader_texture_lod&quot;);
+    }
+
</ins><span class="cx">     // Finally add resource-specific variables.
</span><span class="cx">     switch(type) {
</span><span class="cx">     case SH_FRAGMENT_SHADER:
</span><span class="cx">         if (spec != SH_CSS_SHADERS_SPEC) {
</span><span class="cx">             // Set up gl_FragData.  The array size.
</span><del>-            TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, false, true);
</del><ins>+            TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true);
</ins><span class="cx">             fragData.setArraySize(resources.MaxDrawBuffers);
</span><del>-            symbolTable.insert(*new TVariable(NewPoolTString(&quot;gl_FragData&quot;),    fragData));
</del><ins>+            symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString(&quot;gl_FragData&quot;), fragData));
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     default: break;
</span><span class="lines">@@ -561,4 +755,6 @@
</span><span class="cx">         extBehavior[&quot;GL_EXT_draw_buffers&quot;] = EBhUndefined;
</span><span class="cx">     if (resources.EXT_frag_depth)
</span><span class="cx">         extBehavior[&quot;GL_EXT_frag_depth&quot;] = EBhUndefined;
</span><ins>+    if (resources.EXT_shader_texture_lod)
+        extBehavior[&quot;GL_EXT_shader_texture_lod&quot;] = EBhUndefined;
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorIntermTraversecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/IntermTraverse.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/IntermTraverse.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/IntermTraverse.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">     //
</span><span class="cx">     if (it-&gt;preVisit)
</span><span class="cx">         visit = it-&gt;visitBinary(PreVisit, this);
</span><del>-    
</del><ins>+
</ins><span class="cx">     //
</span><span class="cx">     // Visit the children, in the right order.
</span><span class="cx">     //
</span><span class="lines">@@ -53,11 +53,11 @@
</span><span class="cx">     {
</span><span class="cx">         it-&gt;incrementDepth(this);
</span><span class="cx"> 
</span><del>-        if (it-&gt;rightToLeft) 
</del><ins>+        if (it-&gt;rightToLeft)
</ins><span class="cx">         {
</span><span class="cx">             if (right)
</span><span class="cx">                 right-&gt;traverse(it);
</span><del>-            
</del><ins>+
</ins><span class="cx">             if (it-&gt;inVisit)
</span><span class="cx">                 visit = it-&gt;visitBinary(InVisit, this);
</span><span class="cx"> 
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">         {
</span><span class="cx">             if (left)
</span><span class="cx">                 left-&gt;traverse(it);
</span><del>-            
</del><ins>+
</ins><span class="cx">             if (it-&gt;inVisit)
</span><span class="cx">                 visit = it-&gt;visitBinary(InVisit, this);
</span><span class="cx"> 
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">         operand-&gt;traverse(it);
</span><span class="cx">         it-&gt;decrementDepth();
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (visit &amp;&amp; it-&gt;postVisit)
</span><span class="cx">         it-&gt;visitUnary(PostVisit, this);
</span><span class="cx"> }
</span><span class="lines">@@ -113,10 +113,10 @@
</span><span class="cx"> void TIntermAggregate::traverse(TIntermTraverser *it)
</span><span class="cx"> {
</span><span class="cx">     bool visit = true;
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (it-&gt;preVisit)
</span><span class="cx">         visit = it-&gt;visitAggregate(PreVisit, this);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (visit)
</span><span class="cx">     {
</span><span class="cx">         it-&gt;incrementDepth(this);
</span><span class="lines">@@ -147,7 +147,7 @@
</span><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         it-&gt;decrementDepth();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -164,7 +164,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (it-&gt;preVisit)
</span><span class="cx">         visit = it-&gt;visitSelection(PreVisit, this);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (visit) {
</span><span class="cx">         it-&gt;incrementDepth(this);
</span><span class="cx">         if (it-&gt;rightToLeft) {
</span><span class="lines">@@ -196,7 +196,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (it-&gt;preVisit)
</span><span class="cx">         visit = it-&gt;visitLoop(PreVisit, this);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (visit)
</span><span class="cx">     {
</span><span class="cx">         it-&gt;incrementDepth(this);
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (it-&gt;preVisit)
</span><span class="cx">         visit = it-&gt;visitBranch(PreVisit, this);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (visit &amp;&amp; expression) {
</span><span class="cx">         it-&gt;incrementDepth(this);
</span><span class="cx">         expression-&gt;traverse(it);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorIntermediatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Intermediate.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Intermediate.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Intermediate.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -16,6 +16,7 @@
</span><span class="cx"> #include &quot;compiler/translator/localintermediate.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/QualifierAlive.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/RemoveTree.h&quot;
</span><ins>+#include &quot;compiler/translator/SymbolTable.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> bool CompareStructure(const TType&amp; leftNodeType, ConstantUnion* rightUnionArray, ConstantUnion* leftUnionArray);
</span><span class="cx"> 
</span><span class="lines">@@ -44,7 +45,8 @@
</span><span class="cx">       case EOpIndexDirect:
</span><span class="cx">       case EOpIndexIndirect: return &quot;[]&quot;;
</span><span class="cx"> 
</span><del>-      case EOpIndexDirectStruct: return &quot;.&quot;;
</del><ins>+      case EOpIndexDirectStruct:
+      case EOpIndexDirectInterfaceBlock: return &quot;.&quot;;
</ins><span class="cx">       case EOpVectorSwizzle: return &quot;.&quot;;
</span><span class="cx">       case EOpAdd: return &quot;+&quot;;
</span><span class="cx">       case EOpSub: return &quot;-&quot;;
</span><span class="lines">@@ -78,16 +80,24 @@
</span><span class="cx"> 
</span><span class="cx">       // Fall-through.
</span><span class="cx">       case EOpConvIntToBool:
</span><ins>+      case EOpConvUIntToBool:
</ins><span class="cx">       case EOpConvFloatToBool: return &quot;bool&quot;;
</span><span class="cx">  
</span><span class="cx">       // Fall-through.
</span><span class="cx">       case EOpConvBoolToFloat:
</span><ins>+      case EOpConvUIntToFloat:
</ins><span class="cx">       case EOpConvIntToFloat: return &quot;float&quot;;
</span><span class="cx">  
</span><span class="cx">       // Fall-through.
</span><span class="cx">       case EOpConvFloatToInt:
</span><ins>+      case EOpConvUIntToInt:
</ins><span class="cx">       case EOpConvBoolToInt: return &quot;int&quot;;
</span><span class="cx"> 
</span><ins>+      // Fall-through.
+      case EOpConvIntToUInt:
+      case EOpConvFloatToUInt:
+      case EOpConvBoolToUInt: return &quot;uint&quot;;
+
</ins><span class="cx">       case EOpRadians: return &quot;radians&quot;;
</span><span class="cx">       case EOpDegrees: return &quot;degrees&quot;;
</span><span class="cx">       case EOpSin: return &quot;sin&quot;;
</span><span class="lines">@@ -146,7 +156,7 @@
</span><span class="cx"> //
</span><span class="cx"> // Returns the added node.
</span><span class="cx"> //
</span><del>-TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&amp; line, TSymbolTable&amp; symbolTable)
</del><ins>+TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&amp; line)
</ins><span class="cx"> {
</span><span class="cx">     switch (op) {
</span><span class="cx">         case EOpEqual:
</span><span class="lines">@@ -212,11 +222,10 @@
</span><span class="cx">     //
</span><span class="cx">     // See if we can fold constants.
</span><span class="cx">     //
</span><del>-    TIntermTyped* typedReturnNode = 0;
</del><span class="cx">     TIntermConstantUnion *leftTempConstant = left-&gt;getAsConstantUnion();
</span><span class="cx">     TIntermConstantUnion *rightTempConstant = right-&gt;getAsConstantUnion();
</span><span class="cx">     if (leftTempConstant &amp;&amp; rightTempConstant) {
</span><del>-        typedReturnNode = leftTempConstant-&gt;fold(node-&gt;getOp(), rightTempConstant, infoSink);
</del><ins>+        TIntermTyped *typedReturnNode = leftTempConstant-&gt;fold(node-&gt;getOp(), rightTempConstant, infoSink);
</ins><span class="cx"> 
</span><span class="cx">         if (typedReturnNode)
</span><span class="cx">             return typedReturnNode;
</span><span class="lines">@@ -275,7 +284,7 @@
</span><span class="cx"> //
</span><span class="cx"> // Returns the added node.
</span><span class="cx"> //
</span><del>-TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, const TSourceLoc&amp; line, TSymbolTable&amp; symbolTable)
</del><ins>+TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, const TSourceLoc&amp; line)
</ins><span class="cx"> {
</span><span class="cx">     TIntermUnary* node;
</span><span class="cx">     TIntermTyped* child = childNode-&gt;getAsTyped();
</span><span class="lines">@@ -310,6 +319,7 @@
</span><span class="cx">     TBasicType newType = EbtVoid;
</span><span class="cx">     switch (op) {
</span><span class="cx">         case EOpConstructInt:   newType = EbtInt;   break;
</span><ins>+        case EOpConstructUInt:  newType = EbtUInt;  break;
</ins><span class="cx">         case EOpConstructBool:  newType = EbtBool;  break;
</span><span class="cx">         case EOpConstructFloat: newType = EbtFloat; break;
</span><span class="cx">         default: break;
</span><span class="lines">@@ -318,7 +328,7 @@
</span><span class="cx">     if (newType != EbtVoid) {
</span><span class="cx">         child = addConversion(op, TType(newType, child-&gt;getPrecision(), EvqTemporary,
</span><span class="cx">             child-&gt;getNominalSize(),
</span><del>-            child-&gt;isMatrix(),
</del><ins>+            child-&gt;getSecondarySize(),
</ins><span class="cx">             child-&gt;isArray()),
</span><span class="cx">             child);
</span><span class="cx">         if (child == 0)
</span><span class="lines">@@ -330,6 +340,7 @@
</span><span class="cx">     //
</span><span class="cx">     switch (op) {
</span><span class="cx">         case EOpConstructInt:
</span><ins>+        case EOpConstructUInt:
</ins><span class="cx">         case EOpConstructBool:
</span><span class="cx">         case EOpConstructFloat:
</span><span class="cx">             return child;
</span><span class="lines">@@ -411,12 +422,10 @@
</span><span class="cx">     //
</span><span class="cx">     // Does the base type allow operation?
</span><span class="cx">     //
</span><del>-    switch (node-&gt;getBasicType()) {
-        case EbtVoid:
-        case EbtSampler2D:
-        case EbtSamplerCube:
-            return 0;
-        default: break;
</del><ins>+    if (node-&gt;getBasicType() == EbtVoid ||
+        IsSampler(node-&gt;getBasicType()))
+    {
+        return 0;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     //
</span><span class="lines">@@ -452,6 +461,9 @@
</span><span class="cx">         case EOpConstructInt:
</span><span class="cx">             promoteTo = EbtInt;
</span><span class="cx">             break;
</span><ins>+        case EOpConstructUInt:
+            promoteTo = EbtUInt;
+            break;
</ins><span class="cx">         default:
</span><span class="cx">             //
</span><span class="cx">             // implicit conversions were removed from the language.
</span><span class="lines">@@ -479,8 +491,9 @@
</span><span class="cx">         switch (promoteTo) {
</span><span class="cx">             case EbtFloat:
</span><span class="cx">                 switch (node-&gt;getBasicType()) {
</span><del>-                    case EbtInt:   newOp = EOpConvIntToFloat;  break;
-                    case EbtBool:  newOp = EOpConvBoolToFloat; break;
</del><ins>+                    case EbtInt:    newOp = EOpConvIntToFloat;  break;
+                    case EbtUInt:   newOp = EOpConvFloatToUInt; break;
+                    case EbtBool:   newOp = EOpConvBoolToFloat; break;
</ins><span class="cx">                     default:
</span><span class="cx">                         infoSink.info.message(EPrefixInternalError, node-&gt;getLine(), &quot;Bad promotion node&quot;);
</span><span class="cx">                         return 0;
</span><span class="lines">@@ -488,8 +501,9 @@
</span><span class="cx">                 break;
</span><span class="cx">             case EbtBool:
</span><span class="cx">                 switch (node-&gt;getBasicType()) {
</span><del>-                    case EbtInt:   newOp = EOpConvIntToBool;   break;
-                    case EbtFloat: newOp = EOpConvFloatToBool; break;
</del><ins>+                    case EbtInt:    newOp = EOpConvIntToBool;   break;
+                    case EbtUInt:   newOp = EOpConvBoolToUInt;  break;
+                    case EbtFloat:  newOp = EOpConvFloatToBool; break;
</ins><span class="cx">                     default:
</span><span class="cx">                         infoSink.info.message(EPrefixInternalError, node-&gt;getLine(), &quot;Bad promotion node&quot;);
</span><span class="cx">                         return 0;
</span><span class="lines">@@ -497,6 +511,7 @@
</span><span class="cx">                 break;
</span><span class="cx">             case EbtInt:
</span><span class="cx">                 switch (node-&gt;getBasicType()) {
</span><ins>+                    case EbtUInt:   newOp = EOpConvUIntToInt;  break;
</ins><span class="cx">                     case EbtBool:   newOp = EOpConvBoolToInt;  break;
</span><span class="cx">                     case EbtFloat:  newOp = EOpConvFloatToInt; break;
</span><span class="cx">                     default:
</span><span class="lines">@@ -504,12 +519,22 @@
</span><span class="cx">                         return 0;
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><ins>+            case EbtUInt:
+                switch (node-&gt;getBasicType()) {
+                    case EbtInt:    newOp = EOpConvIntToUInt;   break;
+                    case EbtBool:   newOp = EOpConvBoolToUInt;  break;
+                    case EbtFloat:  newOp = EOpConvFloatToUInt; break;
+                    default:
+                        infoSink.info.message(EPrefixInternalError, node-&gt;getLine(), &quot;Bad promotion node&quot;);
+                        return 0;
+                }
+                break;
</ins><span class="cx">             default:
</span><span class="cx">                 infoSink.info.message(EPrefixInternalError, node-&gt;getLine(), &quot;Bad promotion type&quot;);
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        TType type(promoteTo, node-&gt;getPrecision(), EvqTemporary, node-&gt;getNominalSize(), node-&gt;isMatrix(), node-&gt;isArray());
</del><ins>+        TType type(promoteTo, node-&gt;getPrecision(), EvqTemporary, node-&gt;getNominalSize(), node-&gt;getSecondarySize(), node-&gt;isArray());
</ins><span class="cx">         newNode = new TIntermUnary(newOp, type);
</span><span class="cx">         newNode-&gt;setLine(node-&gt;getLine());
</span><span class="cx">         newNode-&gt;setOperand(node);
</span><span class="lines">@@ -559,6 +584,7 @@
</span><span class="cx"> 
</span><span class="cx">     TIntermAggregate* aggNode = new TIntermAggregate;
</span><span class="cx">     aggNode-&gt;getSequence().push_back(node);
</span><ins>+
</ins><span class="cx">     aggNode-&gt;setLine(line);
</span><span class="cx"> 
</span><span class="cx">     return aggNode;
</span><span class="lines">@@ -760,6 +786,26 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TIntermLoop::enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const
+{
+    if (init)
+    {
+        nodeQueue-&gt;push(init);
+    }
+    if (cond)
+    {
+        nodeQueue-&gt;push(cond);
+    }
+    if (expr)
+    {
+        nodeQueue-&gt;push(expr);
+    }
+    if (body)
+    {
+        nodeQueue-&gt;push(body);
+    }
+}
+
</ins><span class="cx"> bool TIntermBranch::replaceChildNode(
</span><span class="cx">     TIntermNode *original, TIntermNode *replacement)
</span><span class="cx"> {
</span><span class="lines">@@ -767,6 +813,14 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TIntermBranch::enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const
+{
+    if (expression)
+    {
+        nodeQueue-&gt;push(expression);
+    }
+}
+
</ins><span class="cx"> bool TIntermBinary::replaceChildNode(
</span><span class="cx">     TIntermNode *original, TIntermNode *replacement)
</span><span class="cx"> {
</span><span class="lines">@@ -775,6 +829,18 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TIntermBinary::enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const
+{
+    if (left)
+    {
+        nodeQueue-&gt;push(left);
+    }
+    if (right)
+    {
+        nodeQueue-&gt;push(right);
+    }
+}
+
</ins><span class="cx"> bool TIntermUnary::replaceChildNode(
</span><span class="cx">     TIntermNode *original, TIntermNode *replacement)
</span><span class="cx"> {
</span><span class="lines">@@ -782,6 +848,14 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TIntermUnary::enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const
+{
+    if (operand)
+    {
+        nodeQueue-&gt;push(operand);
+    }
+}
+
</ins><span class="cx"> bool TIntermAggregate::replaceChildNode(
</span><span class="cx">     TIntermNode *original, TIntermNode *replacement)
</span><span class="cx"> {
</span><span class="lines">@@ -792,6 +866,14 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TIntermAggregate::enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const
+{
+    for (size_t childIndex = 0; childIndex &lt; sequence.size(); childIndex++)
+    {
+        nodeQueue-&gt;push(sequence[childIndex]);
+    }
+}
+
</ins><span class="cx"> bool TIntermSelection::replaceChildNode(
</span><span class="cx">     TIntermNode *original, TIntermNode *replacement)
</span><span class="cx"> {
</span><span class="lines">@@ -801,6 +883,22 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TIntermSelection::enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const
+{
+    if (condition)
+    {
+        nodeQueue-&gt;push(condition);
+    }
+    if (trueBlock)
+    {
+        nodeQueue-&gt;push(trueBlock);
+    }
+    if (falseBlock)
+    {
+        nodeQueue-&gt;push(falseBlock);
+    }
+}
+
</ins><span class="cx"> //
</span><span class="cx"> // Say whether or not an operation node changes the value of a variable.
</span><span class="cx"> //
</span><span class="lines">@@ -843,6 +941,10 @@
</span><span class="cx">         case EOpConstructIVec3:
</span><span class="cx">         case EOpConstructIVec4:
</span><span class="cx">         case EOpConstructInt:
</span><ins>+        case EOpConstructUVec2:
+        case EOpConstructUVec3:
+        case EOpConstructUVec4:
+        case EOpConstructUInt:
</ins><span class="cx">         case EOpConstructBVec2:
</span><span class="cx">         case EOpConstructBVec3:
</span><span class="cx">         case EOpConstructBVec4:
</span><span class="lines">@@ -893,6 +995,36 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool validateMultiplication(TOperator op, const TType &amp;left, const TType &amp;right)
+{
+    switch (op)
+    {
+      case EOpMul:
+      case EOpMulAssign:
+        return left.getNominalSize() == right.getNominalSize() &amp;&amp; left.getSecondarySize() == right.getSecondarySize();
+      case EOpVectorTimesScalar:
+      case EOpVectorTimesScalarAssign:
+        return true;
+      case EOpVectorTimesMatrix:
+        return left.getNominalSize() == right.getRows();
+      case EOpVectorTimesMatrixAssign:
+        return left.getNominalSize() == right.getRows() &amp;&amp; left.getNominalSize() == right.getCols();
+      case EOpMatrixTimesVector:
+        return left.getCols() == right.getNominalSize();
+      case EOpMatrixTimesScalar:
+      case EOpMatrixTimesScalarAssign:
+        return true;
+      case EOpMatrixTimesMatrix:
+        return left.getCols() == right.getRows();
+      case EOpMatrixTimesMatrixAssign:
+        return left.getCols() == right.getCols() &amp;&amp; left.getRows() == right.getRows();
+
+      default:
+        UNREACHABLE();
+        return false;
+    }
+}
+
</ins><span class="cx"> //
</span><span class="cx"> // Establishes the type of the resultant operation, as well as
</span><span class="cx"> // makes the operator the correct one for the operands.
</span><span class="lines">@@ -902,7 +1034,8 @@
</span><span class="cx"> bool TIntermBinary::promote(TInfoSink&amp; infoSink)
</span><span class="cx"> {
</span><span class="cx">     // This function only handles scalars, vectors, and matrices.
</span><del>-    if (left-&gt;isArray() || right-&gt;isArray()) {
</del><ins>+    if (left-&gt;isArray() || right-&gt;isArray())
+    {
</ins><span class="cx">         infoSink.info.message(EPrefixInternalError, getLine(), &quot;Invalid operation for arrays&quot;);
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -924,17 +1057,20 @@
</span><span class="cx"> 
</span><span class="cx">     // Binary operations results in temporary variables unless both
</span><span class="cx">     // operands are const.
</span><del>-    if (left-&gt;getQualifier() != EvqConst || right-&gt;getQualifier() != EvqConst) {
</del><ins>+    if (left-&gt;getQualifier() != EvqConst || right-&gt;getQualifier() != EvqConst)
+    {
</ins><span class="cx">         getTypePointer()-&gt;setQualifier(EvqTemporary);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    int size = std::max(left-&gt;getNominalSize(), right-&gt;getNominalSize());
</del><ins>+    const int nominalSize = std::max(left-&gt;getNominalSize(), right-&gt;getNominalSize());
</ins><span class="cx"> 
</span><span class="cx">     //
</span><del>-    // All scalars. Code after this test assumes this case is removed!
</del><ins>+    // All scalars or structs. Code after this test assumes this case is removed!
</ins><span class="cx">     //
</span><del>-    if (size == 1) {
-        switch (op) {
</del><ins>+    if (nominalSize == 1)
+    {
+        switch (op)
+        {
</ins><span class="cx">             //
</span><span class="cx">             // Promote to conditional
</span><span class="cx">             //
</span><span class="lines">@@ -954,7 +1090,9 @@
</span><span class="cx">             case EOpLogicalOr:
</span><span class="cx">                 // Both operands must be of type bool.
</span><span class="cx">                 if (left-&gt;getBasicType() != EbtBool || right-&gt;getBasicType() != EbtBool)
</span><ins>+                {
</ins><span class="cx">                     return false;
</span><ins>+                }
</ins><span class="cx">                 setType(TType(EbtBool, EbpUndefined));
</span><span class="cx">                 break;
</span><span class="cx"> 
</span><span class="lines">@@ -966,80 +1104,118 @@
</span><span class="cx"> 
</span><span class="cx">     // If we reach here, at least one of the operands is vector or matrix.
</span><span class="cx">     // The other operand could be a scalar, vector, or matrix.
</span><del>-    // Are the sizes compatible?
-    //
-    if (left-&gt;getNominalSize() != right-&gt;getNominalSize()) {
-        // If the nominal size of operands do not match:
-        // One of them must be scalar.
-        if (left-&gt;getNominalSize() != 1 &amp;&amp; right-&gt;getNominalSize() != 1)
-            return false;
-        // Operator cannot be of type pure assignment.
-        if (op == EOpAssign || op == EOpInitialize)
-            return false;
-    }
-
-    //
</del><span class="cx">     // Can these two operands be combined?
</span><span class="cx">     //
</span><span class="cx">     TBasicType basicType = left-&gt;getBasicType();
</span><del>-    switch (op) {
</del><ins>+    switch (op)
+    {
</ins><span class="cx">         case EOpMul:
</span><del>-            if (!left-&gt;isMatrix() &amp;&amp; right-&gt;isMatrix()) {
</del><ins>+            if (!left-&gt;isMatrix() &amp;&amp; right-&gt;isMatrix())
+            {
</ins><span class="cx">                 if (left-&gt;isVector())
</span><ins>+                {
</ins><span class="cx">                     op = EOpVectorTimesMatrix;
</span><del>-                else {
</del><ins>+                    setType(TType(basicType, higherPrecision, EvqTemporary, right-&gt;getCols(), 1));
+                }
+                else
+                {
</ins><span class="cx">                     op = EOpMatrixTimesScalar;
</span><del>-                    setType(TType(basicType, higherPrecision, EvqTemporary, size, true));
</del><ins>+                    setType(TType(basicType, higherPrecision, EvqTemporary, right-&gt;getCols(), right-&gt;getRows()));
</ins><span class="cx">                 }
</span><del>-            } else if (left-&gt;isMatrix() &amp;&amp; !right-&gt;isMatrix()) {
-                if (right-&gt;isVector()) {
</del><ins>+            }
+            else if (left-&gt;isMatrix() &amp;&amp; !right-&gt;isMatrix())
+            {
+                if (right-&gt;isVector())
+                {
</ins><span class="cx">                     op = EOpMatrixTimesVector;
</span><del>-                    setType(TType(basicType, higherPrecision, EvqTemporary, size, false));
-                } else {
</del><ins>+                    setType(TType(basicType, higherPrecision, EvqTemporary, left-&gt;getRows(), 1));
+                }
+                else
+                {
</ins><span class="cx">                     op = EOpMatrixTimesScalar;
</span><span class="cx">                 }
</span><del>-            } else if (left-&gt;isMatrix() &amp;&amp; right-&gt;isMatrix()) {
</del><ins>+            }
+            else if (left-&gt;isMatrix() &amp;&amp; right-&gt;isMatrix())
+            {
</ins><span class="cx">                 op = EOpMatrixTimesMatrix;
</span><del>-            } else if (!left-&gt;isMatrix() &amp;&amp; !right-&gt;isMatrix()) {
-                if (left-&gt;isVector() &amp;&amp; right-&gt;isVector()) {
</del><ins>+                setType(TType(basicType, higherPrecision, EvqTemporary, right-&gt;getCols(), left-&gt;getRows()));
+            }
+            else if (!left-&gt;isMatrix() &amp;&amp; !right-&gt;isMatrix())
+            {
+                if (left-&gt;isVector() &amp;&amp; right-&gt;isVector())
+                {
</ins><span class="cx">                     // leave as component product
</span><del>-                } else if (left-&gt;isVector() || right-&gt;isVector()) {
</del><ins>+                }
+                else if (left-&gt;isVector() || right-&gt;isVector())
+                {
</ins><span class="cx">                     op = EOpVectorTimesScalar;
</span><del>-                    setType(TType(basicType, higherPrecision, EvqTemporary, size, false));
</del><ins>+                    setType(TType(basicType, higherPrecision, EvqTemporary, nominalSize, 1));
</ins><span class="cx">                 }
</span><del>-            } else {
</del><ins>+            }
+            else
+            {
</ins><span class="cx">                 infoSink.info.message(EPrefixInternalError, getLine(), &quot;Missing elses&quot;);
</span><span class="cx">                 return false;
</span><span class="cx">             }
</span><ins>+
+            if (!validateMultiplication(op, left-&gt;getType(), right-&gt;getType()))
+            {
+                return false;
+            }
</ins><span class="cx">             break;
</span><ins>+
</ins><span class="cx">         case EOpMulAssign:
</span><del>-            if (!left-&gt;isMatrix() &amp;&amp; right-&gt;isMatrix()) {
</del><ins>+            if (!left-&gt;isMatrix() &amp;&amp; right-&gt;isMatrix())
+            {
</ins><span class="cx">                 if (left-&gt;isVector())
</span><ins>+                {
</ins><span class="cx">                     op = EOpVectorTimesMatrixAssign;
</span><del>-                else {
</del><ins>+                }
+                else
+                {
</ins><span class="cx">                     return false;
</span><span class="cx">                 }
</span><del>-            } else if (left-&gt;isMatrix() &amp;&amp; !right-&gt;isMatrix()) {
-                if (right-&gt;isVector()) {
</del><ins>+            }
+            else if (left-&gt;isMatrix() &amp;&amp; !right-&gt;isMatrix())
+            {
+                if (right-&gt;isVector())
+                {
</ins><span class="cx">                     return false;
</span><del>-                } else {
</del><ins>+                }
+                else
+                {
</ins><span class="cx">                     op = EOpMatrixTimesScalarAssign;
</span><span class="cx">                 }
</span><del>-            } else if (left-&gt;isMatrix() &amp;&amp; right-&gt;isMatrix()) {
</del><ins>+            }
+            else if (left-&gt;isMatrix() &amp;&amp; right-&gt;isMatrix())
+            {
</ins><span class="cx">                 op = EOpMatrixTimesMatrixAssign;
</span><del>-            } else if (!left-&gt;isMatrix() &amp;&amp; !right-&gt;isMatrix()) {
-                if (left-&gt;isVector() &amp;&amp; right-&gt;isVector()) {
</del><ins>+                setType(TType(basicType, higherPrecision, EvqTemporary, right-&gt;getCols(), left-&gt;getRows()));
+            }
+            else if (!left-&gt;isMatrix() &amp;&amp; !right-&gt;isMatrix())
+            {
+                if (left-&gt;isVector() &amp;&amp; right-&gt;isVector())
+                {
</ins><span class="cx">                     // leave as component product
</span><del>-                } else if (left-&gt;isVector() || right-&gt;isVector()) {
</del><ins>+                }
+                else if (left-&gt;isVector() || right-&gt;isVector())
+                {
</ins><span class="cx">                     if (! left-&gt;isVector())
</span><span class="cx">                         return false;
</span><span class="cx">                     op = EOpVectorTimesScalarAssign;
</span><del>-                    setType(TType(basicType, higherPrecision, EvqTemporary, size, false));
</del><ins>+                    setType(TType(basicType, higherPrecision, EvqTemporary, left-&gt;getNominalSize(), 1));
</ins><span class="cx">                 }
</span><del>-            } else {
</del><ins>+            }
+            else
+            {
</ins><span class="cx">                 infoSink.info.message(EPrefixInternalError, getLine(), &quot;Missing elses&quot;);
</span><span class="cx">                 return false;
</span><span class="cx">             }
</span><ins>+
+            if (!validateMultiplication(op, left-&gt;getType(), right-&gt;getType()))
+            {
+                return false;
+            }
</ins><span class="cx">             break;
</span><span class="cx"> 
</span><span class="cx">         case EOpAssign:
</span><span class="lines">@@ -1050,10 +1226,28 @@
</span><span class="cx">         case EOpAddAssign:
</span><span class="cx">         case EOpSubAssign:
</span><span class="cx">         case EOpDivAssign:
</span><del>-            if ((left-&gt;isMatrix() &amp;&amp; right-&gt;isVector()) ||
-                (left-&gt;isVector() &amp;&amp; right-&gt;isMatrix()))
-                return false;
-            setType(TType(basicType, higherPrecision, EvqTemporary, size, left-&gt;isMatrix() || right-&gt;isMatrix()));
</del><ins>+            {
+                if ((left-&gt;isMatrix() &amp;&amp; right-&gt;isVector()) ||
+                    (left-&gt;isVector() &amp;&amp; right-&gt;isMatrix()))
+                    return false;
+
+                // Are the sizes compatible?
+                if (left-&gt;getNominalSize() != right-&gt;getNominalSize() || left-&gt;getSecondarySize() != right-&gt;getSecondarySize())
+                {
+                    // If the nominal size of operands do not match:
+                    // One of them must be scalar.
+                    if (!left-&gt;isScalar() &amp;&amp; !right-&gt;isScalar())
+                        return false;
+
+                    // Operator cannot be of type pure assignment.
+                    if (op == EOpAssign || op == EOpInitialize)
+                        return false;
+                }
+
+                const int secondarySize = std::max(left-&gt;getSecondarySize(), right-&gt;getSecondarySize());
+
+                setType(TType(basicType, higherPrecision, EvqTemporary, nominalSize, secondarySize));
+            }
</ins><span class="cx">             break;
</span><span class="cx"> 
</span><span class="cx">         case EOpEqual:
</span><span class="lines">@@ -1062,8 +1256,8 @@
</span><span class="cx">         case EOpGreaterThan:
</span><span class="cx">         case EOpLessThanEqual:
</span><span class="cx">         case EOpGreaterThanEqual:
</span><del>-            if ((left-&gt;isMatrix() &amp;&amp; right-&gt;isVector()) ||
-                (left-&gt;isVector() &amp;&amp; right-&gt;isMatrix()))
</del><ins>+            if ((left-&gt;getNominalSize() != right-&gt;getNominalSize()) ||
+                (left-&gt;getSecondarySize() != right-&gt;getSecondarySize()))
</ins><span class="cx">                 return false;
</span><span class="cx">             setType(TType(EbtBool, EbpUndefined));
</span><span class="cx">             break;
</span><span class="lines">@@ -1086,13 +1280,14 @@
</span><span class="cx">         size_t size = fields[j]-&gt;type()-&gt;getObjectSize();
</span><span class="cx">         for (size_t i = 0; i &lt; size; i++) {
</span><span class="cx">             if (fields[j]-&gt;type()-&gt;getBasicType() == EbtStruct) {
</span><del>-                if (!CompareStructure(*(fields[j]-&gt;type()), &amp;rightUnionArray[index], &amp;leftUnionArray[index]))
</del><ins>+                if (!CompareStructure(*fields[j]-&gt;type(), &amp;rightUnionArray[index], &amp;leftUnionArray[index]))
</ins><span class="cx">                     return false;
</span><span class="cx">             } else {
</span><span class="cx">                 if (leftUnionArray[index] != rightUnionArray[index])
</span><span class="cx">                     return false;
</span><span class="cx">                 index++;
</span><span class="cx">             }
</span><ins>+
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     return true;
</span><span class="lines">@@ -1127,24 +1322,40 @@
</span><span class="cx"> TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink&amp; infoSink)
</span><span class="cx"> {
</span><span class="cx">     ConstantUnion *unionArray = getUnionArrayPointer();
</span><ins>+
+    if (!unionArray)
+        return 0;
+
</ins><span class="cx">     size_t objectSize = getType().getObjectSize();
</span><span class="cx"> 
</span><del>-    if (constantNode) {  // binary operations
</del><ins>+    if (constantNode)
+    {
+        // binary operations
</ins><span class="cx">         TIntermConstantUnion *node = constantNode-&gt;getAsConstantUnion();
</span><span class="cx">         ConstantUnion *rightUnionArray = node-&gt;getUnionArrayPointer();
</span><span class="cx">         TType returnType = getType();
</span><span class="cx"> 
</span><ins>+        if (!rightUnionArray)
+            return 0;
+
</ins><span class="cx">         // for a case like float f = 1.2 + vec4(2,3,4,5);
</span><del>-        if (constantNode-&gt;getType().getObjectSize() == 1 &amp;&amp; objectSize &gt; 1) {
</del><ins>+        if (constantNode-&gt;getType().getObjectSize() == 1 &amp;&amp; objectSize &gt; 1)
+        {
</ins><span class="cx">             rightUnionArray = new ConstantUnion[objectSize];
</span><span class="cx">             for (size_t i = 0; i &lt; objectSize; ++i)
</span><ins>+            {
</ins><span class="cx">                 rightUnionArray[i] = *node-&gt;getUnionArrayPointer();
</span><ins>+            }
</ins><span class="cx">             returnType = getType();
</span><del>-        } else if (constantNode-&gt;getType().getObjectSize() &gt; 1 &amp;&amp; objectSize == 1) {
</del><ins>+        }
+        else if (constantNode-&gt;getType().getObjectSize() &gt; 1 &amp;&amp; objectSize == 1)
+        {
</ins><span class="cx">             // for a case like float f = vec4(2,3,4,5) + 1.2;
</span><span class="cx">             unionArray = new ConstantUnion[constantNode-&gt;getType().getObjectSize()];
</span><span class="cx">             for (size_t i = 0; i &lt; constantNode-&gt;getType().getObjectSize(); ++i)
</span><ins>+            {
</ins><span class="cx">                 unionArray[i] = *getUnionArrayPointer();
</span><ins>+            }
</ins><span class="cx">             returnType = node-&gt;getType();
</span><span class="cx">             objectSize = constantNode-&gt;getType().getObjectSize();
</span><span class="cx">         }
</span><span class="lines">@@ -1154,261 +1365,357 @@
</span><span class="cx"> 
</span><span class="cx">         bool boolNodeFlag = false;
</span><span class="cx">         switch(op) {
</span><del>-            case EOpAdd:
-                tempConstArray = new ConstantUnion[objectSize];
-                {// support MSVC++6.0
-                    for (size_t i = 0; i &lt; objectSize; i++)
-                        tempConstArray[i] = unionArray[i] + rightUnionArray[i];
-                }
-                break;
-            case EOpSub:
-                tempConstArray = new ConstantUnion[objectSize];
-                {// support MSVC++6.0
-                    for (size_t i = 0; i &lt; objectSize; i++)
-                        tempConstArray[i] = unionArray[i] - rightUnionArray[i];
-                }
-                break;
</del><ins>+          case EOpAdd:
+            tempConstArray = new ConstantUnion[objectSize];
+            {
+                for (size_t i = 0; i &lt; objectSize; i++)
+                    tempConstArray[i] = unionArray[i] + rightUnionArray[i];
+            }
+            break;
+          case EOpSub:
+            tempConstArray = new ConstantUnion[objectSize];
+            {
+                for (size_t i = 0; i &lt; objectSize; i++)
+                    tempConstArray[i] = unionArray[i] - rightUnionArray[i];
+            }
+            break;
</ins><span class="cx"> 
</span><del>-            case EOpMul:
-            case EOpVectorTimesScalar:
-            case EOpMatrixTimesScalar:
-                tempConstArray = new ConstantUnion[objectSize];
-                {// support MSVC++6.0
-                    for (size_t i = 0; i &lt; objectSize; i++)
-                        tempConstArray[i] = unionArray[i] * rightUnionArray[i];
-                }
-                break;
-            case EOpMatrixTimesMatrix:
-                if (getType().getBasicType() != EbtFloat || node-&gt;getBasicType() != EbtFloat) {
</del><ins>+          case EOpMul:
+          case EOpVectorTimesScalar:
+          case EOpMatrixTimesScalar:
+            tempConstArray = new ConstantUnion[objectSize];
+            {
+                for (size_t i = 0; i &lt; objectSize; i++)
+                    tempConstArray[i] = unionArray[i] * rightUnionArray[i];
+            }
+            break;
+
+          case EOpMatrixTimesMatrix:
+            {
+                if (getType().getBasicType() != EbtFloat || node-&gt;getBasicType() != EbtFloat)
+                {
</ins><span class="cx">                     infoSink.info.message(EPrefixInternalError, getLine(), &quot;Constant Folding cannot be done for matrix multiply&quot;);
</span><span class="cx">                     return 0;
</span><span class="cx">                 }
</span><del>-                {// support MSVC++6.0
-                    int size = getNominalSize();
-                    tempConstArray = new ConstantUnion[size*size];
-                    for (int row = 0; row &lt; size; row++) {
-                        for (int column = 0; column &lt; size; column++) {
-                            tempConstArray[size * column + row].setFConst(0.0f);
-                            for (int i = 0; i &lt; size; i++) {
-                                tempConstArray[size * column + row].setFConst(tempConstArray[size * column + row].getFConst() + unionArray[i * size + row].getFConst() * (rightUnionArray[column * size + i].getFConst()));
-                            }
</del><ins>+
+                const int leftCols = getCols();
+                const int leftRows = getRows();
+                const int rightCols = constantNode-&gt;getType().getCols();
+                const int rightRows = constantNode-&gt;getType().getRows();
+                const int resultCols = rightCols;
+                const int resultRows = leftRows;
+
+                tempConstArray = new ConstantUnion[resultCols*resultRows];
+                for (int row = 0; row &lt; resultRows; row++)
+                {
+                    for (int column = 0; column &lt; resultCols; column++)
+                    {
+                        tempConstArray[resultRows * column + row].setFConst(0.0f);
+                        for (int i = 0; i &lt; leftCols; i++)
+                        {
+                            tempConstArray[resultRows * column + row].setFConst(tempConstArray[resultRows * column + row].getFConst() + unionArray[i * leftRows + row].getFConst() * (rightUnionArray[column * rightRows + i].getFConst()));
</ins><span class="cx">                         }
</span><span class="cx">                     }
</span><span class="cx">                 }
</span><del>-                break;
-            case EOpDiv:
</del><ins>+
+                // update return type for matrix product
+                returnType.setPrimarySize(resultCols);
+                returnType.setSecondarySize(resultRows);
+            }
+            break;
+
+          case EOpDiv:
+            {
</ins><span class="cx">                 tempConstArray = new ConstantUnion[objectSize];
</span><del>-                {// support MSVC++6.0
-                    for (size_t i = 0; i &lt; objectSize; i++) {
-                        switch (getType().getBasicType()) {
-            case EbtFloat:
-                if (rightUnionArray[i] == 0.0f) {
-                    infoSink.info.message(EPrefixWarning, getLine(), &quot;Divide by zero error during constant folding&quot;);
-                    tempConstArray[i].setFConst(unionArray[i].getFConst() &lt; 0 ? -FLT_MAX : FLT_MAX);
-                } else
-                    tempConstArray[i].setFConst(unionArray[i].getFConst() / rightUnionArray[i].getFConst());
-                break;
</del><ins>+                for (size_t i = 0; i &lt; objectSize; i++)
+                {
+                    switch (getType().getBasicType())
+                    {
+                      case EbtFloat:
+                        if (rightUnionArray[i] == 0.0f)
+                        {
+                            infoSink.info.message(EPrefixWarning, getLine(), &quot;Divide by zero error during constant folding&quot;);
+                            tempConstArray[i].setFConst(unionArray[i].getFConst() &lt; 0 ? -FLT_MAX : FLT_MAX);
+                        }
+                        else
+                        {
+                            tempConstArray[i].setFConst(unionArray[i].getFConst() / rightUnionArray[i].getFConst());
+                        }
+                        break;
</ins><span class="cx"> 
</span><del>-            case EbtInt:
-                if (rightUnionArray[i] == 0) {
-                    infoSink.info.message(EPrefixWarning, getLine(), &quot;Divide by zero error during constant folding&quot;);
-                    tempConstArray[i].setIConst(INT_MAX);
-                } else
-                    tempConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst());
-                break;
-            default:
-                infoSink.info.message(EPrefixInternalError, getLine(), &quot;Constant folding cannot be done for \&quot;/\&quot;&quot;);
-                return 0;
</del><ins>+                      case EbtInt:
+                        if (rightUnionArray[i] == 0)
+                        {
+                            infoSink.info.message(EPrefixWarning, getLine(), &quot;Divide by zero error during constant folding&quot;);
+                            tempConstArray[i].setIConst(INT_MAX);
</ins><span class="cx">                         }
</span><ins>+                        else
+                        {
+                            tempConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst());
+                        }
+                        break;
+
+                      case EbtUInt:
+                        if (rightUnionArray[i] == 0)
+                        {
+                            infoSink.info.message(EPrefixWarning, getLine(), &quot;Divide by zero error during constant folding&quot;);
+                            tempConstArray[i].setUConst(UINT_MAX);
+                        }
+                        else
+                        {
+                            tempConstArray[i].setUConst(unionArray[i].getUConst() / rightUnionArray[i].getUConst());
+                        }
+                        break;
+
+                      default:
+                        infoSink.info.message(EPrefixInternalError, getLine(), &quot;Constant folding cannot be done for \&quot;/\&quot;&quot;);
+                        return 0;
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><del>-                break;
</del><ins>+            }
+            break;
</ins><span class="cx"> 
</span><del>-            case EOpMatrixTimesVector:
-                if (node-&gt;getBasicType() != EbtFloat) {
</del><ins>+          case EOpMatrixTimesVector:
+            {
+                if (node-&gt;getBasicType() != EbtFloat)
+                {
</ins><span class="cx">                     infoSink.info.message(EPrefixInternalError, getLine(), &quot;Constant Folding cannot be done for matrix times vector&quot;);
</span><span class="cx">                     return 0;
</span><span class="cx">                 }
</span><del>-                tempConstArray = new ConstantUnion[getNominalSize()];
</del><span class="cx"> 
</span><del>-                {// support MSVC++6.0
-                    for (int size = getNominalSize(), i = 0; i &lt; size; i++) {
-                        tempConstArray[i].setFConst(0.0f);
-                        for (int j = 0; j &lt; size; j++) {
-                            tempConstArray[i].setFConst(tempConstArray[i].getFConst() + ((unionArray[j*size + i].getFConst()) * rightUnionArray[j].getFConst()));
-                        }
</del><ins>+                const int matrixCols = getCols();
+                const int matrixRows = getRows();
+
+                tempConstArray = new ConstantUnion[matrixRows];
+
+                for (int matrixRow = 0; matrixRow &lt; matrixRows; matrixRow++)
+                {
+                    tempConstArray[matrixRow].setFConst(0.0f);
+                    for (int col = 0; col &lt; matrixCols; col++)
+                    {
+                        tempConstArray[matrixRow].setFConst(tempConstArray[matrixRow].getFConst() + ((unionArray[col * matrixRows + matrixRow].getFConst()) * rightUnionArray[col].getFConst()));
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                tempNode = new TIntermConstantUnion(tempConstArray, node-&gt;getType());
</del><ins>+                returnType = node-&gt;getType();
+                returnType.setPrimarySize(matrixRows);
+
+                tempNode = new TIntermConstantUnion(tempConstArray, returnType);
</ins><span class="cx">                 tempNode-&gt;setLine(getLine());
</span><span class="cx"> 
</span><span class="cx">                 return tempNode;
</span><ins>+            }
</ins><span class="cx"> 
</span><del>-            case EOpVectorTimesMatrix:
-                if (getType().getBasicType() != EbtFloat) {
</del><ins>+          case EOpVectorTimesMatrix:
+            {
+                if (getType().getBasicType() != EbtFloat)
+                {
</ins><span class="cx">                     infoSink.info.message(EPrefixInternalError, getLine(), &quot;Constant Folding cannot be done for vector times matrix&quot;);
</span><span class="cx">                     return 0;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                tempConstArray = new ConstantUnion[getNominalSize()];
-                {// support MSVC++6.0
-                    for (int size = getNominalSize(), i = 0; i &lt; size; i++) {
-                        tempConstArray[i].setFConst(0.0f);
-                        for (int j = 0; j &lt; size; j++) {
-                            tempConstArray[i].setFConst(tempConstArray[i].getFConst() + ((unionArray[j].getFConst()) * rightUnionArray[i*size + j].getFConst()));
-                        }
</del><ins>+                const int matrixCols = constantNode-&gt;getType().getCols();
+                const int matrixRows = constantNode-&gt;getType().getRows();
+
+                tempConstArray = new ConstantUnion[matrixCols];
+
+                for (int matrixCol = 0; matrixCol &lt; matrixCols; matrixCol++)
+                {
+                    tempConstArray[matrixCol].setFConst(0.0f);
+                    for (int matrixRow = 0; matrixRow &lt; matrixRows; matrixRow++)
+                    {
+                        tempConstArray[matrixCol].setFConst(tempConstArray[matrixCol].getFConst() + ((unionArray[matrixRow].getFConst()) * rightUnionArray[matrixCol * matrixRows + matrixRow].getFConst()));
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><del>-                break;
</del><span class="cx"> 
</span><del>-            case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
</del><ins>+                returnType.setPrimarySize(matrixCols);
+            }
+            break;
+
+          case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
+            {
</ins><span class="cx">                 tempConstArray = new ConstantUnion[objectSize];
</span><del>-                {// support MSVC++6.0
-                    for (size_t i = 0; i &lt; objectSize; i++)
-                        tempConstArray[i] = unionArray[i] &amp;&amp; rightUnionArray[i];
</del><ins>+                for (size_t i = 0; i &lt; objectSize; i++)
+                {
+                    tempConstArray[i] = unionArray[i] &amp;&amp; rightUnionArray[i];
</ins><span class="cx">                 }
</span><del>-                break;
</del><ins>+            }
+            break;
</ins><span class="cx"> 
</span><del>-            case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
</del><ins>+          case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
+            {
</ins><span class="cx">                 tempConstArray = new ConstantUnion[objectSize];
</span><del>-                {// support MSVC++6.0
-                    for (size_t i = 0; i &lt; objectSize; i++)
-                        tempConstArray[i] = unionArray[i] || rightUnionArray[i];
</del><ins>+                for (size_t i = 0; i &lt; objectSize; i++)
+                {
+                    tempConstArray[i] = unionArray[i] || rightUnionArray[i];
</ins><span class="cx">                 }
</span><del>-                break;
</del><ins>+            }
+            break;
</ins><span class="cx"> 
</span><del>-            case EOpLogicalXor:
</del><ins>+          case EOpLogicalXor:
+            {
</ins><span class="cx">                 tempConstArray = new ConstantUnion[objectSize];
</span><del>-                {// support MSVC++6.0
-                    for (size_t i = 0; i &lt; objectSize; i++)
-                        switch (getType().getBasicType()) {
-            case EbtBool: tempConstArray[i].setBConst((unionArray[i] == rightUnionArray[i]) ? false : true); break;
-            default: assert(false &amp;&amp; &quot;Default missing&quot;);
</del><ins>+                for (size_t i = 0; i &lt; objectSize; i++)
+                {
+                    switch (getType().getBasicType())
+                    {
+                      case EbtBool:
+                        tempConstArray[i].setBConst((unionArray[i] == rightUnionArray[i]) ? false : true);
+                        break;
+                      default:
+                        UNREACHABLE();
+                        break;
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><del>-                break;
</del><ins>+            }
+            break;
</ins><span class="cx"> 
</span><del>-            case EOpLessThan:
</del><ins>+          case EOpLessThan:
+            assert(objectSize == 1);
+            tempConstArray = new ConstantUnion[1];
+            tempConstArray-&gt;setBConst(*unionArray &lt; *rightUnionArray);
+            returnType = TType(EbtBool, EbpUndefined, EvqConst);
+            break;
+
+          case EOpGreaterThan:
+            assert(objectSize == 1);
+            tempConstArray = new ConstantUnion[1];
+            tempConstArray-&gt;setBConst(*unionArray &gt; *rightUnionArray);
+            returnType = TType(EbtBool, EbpUndefined, EvqConst);
+            break;
+
+          case EOpLessThanEqual:
+            {
</ins><span class="cx">                 assert(objectSize == 1);
</span><ins>+                ConstantUnion constant;
+                constant.setBConst(*unionArray &gt; *rightUnionArray);
</ins><span class="cx">                 tempConstArray = new ConstantUnion[1];
</span><del>-                tempConstArray-&gt;setBConst(*unionArray &lt; *rightUnionArray);
</del><ins>+                tempConstArray-&gt;setBConst(!constant.getBConst());
</ins><span class="cx">                 returnType = TType(EbtBool, EbpUndefined, EvqConst);
</span><span class="cx">                 break;
</span><del>-            case EOpGreaterThan:
</del><ins>+            }
+
+          case EOpGreaterThanEqual:
+            {
</ins><span class="cx">                 assert(objectSize == 1);
</span><ins>+                ConstantUnion constant;
+                constant.setBConst(*unionArray &lt; *rightUnionArray);
</ins><span class="cx">                 tempConstArray = new ConstantUnion[1];
</span><del>-                tempConstArray-&gt;setBConst(*unionArray &gt; *rightUnionArray);
</del><ins>+                tempConstArray-&gt;setBConst(!constant.getBConst());
</ins><span class="cx">                 returnType = TType(EbtBool, EbpUndefined, EvqConst);
</span><span class="cx">                 break;
</span><del>-            case EOpLessThanEqual:
</del><ins>+            }
+
+          case EOpEqual:
+            if (getType().getBasicType() == EbtStruct)
+            {
+                if (!CompareStructure(node-&gt;getType(), node-&gt;getUnionArrayPointer(), unionArray))
+                    boolNodeFlag = true;
+            }
+            else
+            {
+                for (size_t i = 0; i &lt; objectSize; i++)
</ins><span class="cx">                 {
</span><del>-                    assert(objectSize == 1);
-                    ConstantUnion constant;
-                    constant.setBConst(*unionArray &gt; *rightUnionArray);
-                    tempConstArray = new ConstantUnion[1];
-                    tempConstArray-&gt;setBConst(!constant.getBConst());
-                    returnType = TType(EbtBool, EbpUndefined, EvqConst);
-                    break;
-                }
-            case EOpGreaterThanEqual:
-                {
-                    assert(objectSize == 1);
-                    ConstantUnion constant;
-                    constant.setBConst(*unionArray &lt; *rightUnionArray);
-                    tempConstArray = new ConstantUnion[1];
-                    tempConstArray-&gt;setBConst(!constant.getBConst());
-                    returnType = TType(EbtBool, EbpUndefined, EvqConst);
-                    break;
-                }
-
-            case EOpEqual:
-                if (getType().getBasicType() == EbtStruct) {
-                    if (!CompareStructure(node-&gt;getType(), node-&gt;getUnionArrayPointer(), unionArray))
</del><ins>+                    if (unionArray[i] != rightUnionArray[i])
+                    {
</ins><span class="cx">                         boolNodeFlag = true;
</span><del>-                } else {
-                    for (size_t i = 0; i &lt; objectSize; i++) {
-                        if (unionArray[i] != rightUnionArray[i]) {
-                            boolNodeFlag = true;
-                            break;  // break out of for loop
-                        }
</del><ins>+                        break;  // break out of for loop
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><ins>+            }
</ins><span class="cx"> 
</span><del>-                tempConstArray = new ConstantUnion[1];
-                if (!boolNodeFlag) {
-                    tempConstArray-&gt;setBConst(true);
-                }
-                else {
-                    tempConstArray-&gt;setBConst(false);
-                }
</del><ins>+            tempConstArray = new ConstantUnion[1];
+            if (!boolNodeFlag)
+            {
+                tempConstArray-&gt;setBConst(true);
+            }
+            else
+            {
+                tempConstArray-&gt;setBConst(false);
+            }
</ins><span class="cx"> 
</span><del>-                tempNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EbpUndefined, EvqConst));
-                tempNode-&gt;setLine(getLine());
</del><ins>+            tempNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EbpUndefined, EvqConst));
+            tempNode-&gt;setLine(getLine());
</ins><span class="cx"> 
</span><del>-                return tempNode;
</del><ins>+            return tempNode;
</ins><span class="cx"> 
</span><del>-            case EOpNotEqual:
-                if (getType().getBasicType() == EbtStruct) {
-                    if (CompareStructure(node-&gt;getType(), node-&gt;getUnionArrayPointer(), unionArray))
</del><ins>+          case EOpNotEqual:
+            if (getType().getBasicType() == EbtStruct)
+            {
+                if (CompareStructure(node-&gt;getType(), node-&gt;getUnionArrayPointer(), unionArray))
+                    boolNodeFlag = true;
+            }
+            else
+            {
+                for (size_t i = 0; i &lt; objectSize; i++)
+                {
+                    if (unionArray[i] == rightUnionArray[i])
+                    {
</ins><span class="cx">                         boolNodeFlag = true;
</span><del>-                } else {
-                    for (size_t i = 0; i &lt; objectSize; i++) {
-                        if (unionArray[i] == rightUnionArray[i]) {
-                            boolNodeFlag = true;
-                            break;  // break out of for loop
-                        }
</del><ins>+                        break;  // break out of for loop
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><ins>+            }
</ins><span class="cx"> 
</span><del>-                tempConstArray = new ConstantUnion[1];
-                if (!boolNodeFlag) {
-                    tempConstArray-&gt;setBConst(true);
-                }
-                else {
-                    tempConstArray-&gt;setBConst(false);
-                }
</del><ins>+            tempConstArray = new ConstantUnion[1];
+            if (!boolNodeFlag)
+            {
+                tempConstArray-&gt;setBConst(true);
+            }
+            else
+            {
+                tempConstArray-&gt;setBConst(false);
+            }
</ins><span class="cx"> 
</span><del>-                tempNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EbpUndefined, EvqConst));
-                tempNode-&gt;setLine(getLine());
</del><ins>+            tempNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EbpUndefined, EvqConst));
+            tempNode-&gt;setLine(getLine());
</ins><span class="cx"> 
</span><del>-                return tempNode;
</del><ins>+            return tempNode;
</ins><span class="cx"> 
</span><del>-            default:
-                infoSink.info.message(EPrefixInternalError, getLine(), &quot;Invalid operator for constant folding&quot;);
-                return 0;
</del><ins>+          default:
+            infoSink.info.message(EPrefixInternalError, getLine(), &quot;Invalid operator for constant folding&quot;);
+            return 0;
</ins><span class="cx">         }
</span><span class="cx">         tempNode = new TIntermConstantUnion(tempConstArray, returnType);
</span><span class="cx">         tempNode-&gt;setLine(getLine());
</span><span class="cx"> 
</span><span class="cx">         return tempNode;
</span><del>-    } else {
</del><ins>+    }
+    else
+    {
</ins><span class="cx">         //
</span><span class="cx">         // Do unary operations
</span><span class="cx">         //
</span><span class="cx">         TIntermConstantUnion *newNode = 0;
</span><span class="cx">         ConstantUnion* tempConstArray = new ConstantUnion[objectSize];
</span><del>-        for (size_t i = 0; i &lt; objectSize; i++) {
-            switch(op) {
-                case EOpNegative:
-                    switch (getType().getBasicType()) {
-                        case EbtFloat: tempConstArray[i].setFConst(-unionArray[i].getFConst()); break;
-                        case EbtInt:   tempConstArray[i].setIConst(-unionArray[i].getIConst()); break;
-                        default:
-                            infoSink.info.message(EPrefixInternalError, getLine(), &quot;Unary operation not folded into constant&quot;);
-                            return 0;
-                    }
-                    break;
-                case EOpLogicalNot: // this code is written for possible future use, will not get executed currently
-                    switch (getType().getBasicType()) {
-                        case EbtBool:  tempConstArray[i].setBConst(!unionArray[i].getBConst()); break;
-                        default:
-                            infoSink.info.message(EPrefixInternalError, getLine(), &quot;Unary operation not folded into constant&quot;);
-                            return 0;
-                    }
-                    break;
-                default:
</del><ins>+        for (size_t i = 0; i &lt; objectSize; i++)
+        {
+            switch(op)
+            {
+              case EOpNegative:
+                switch (getType().getBasicType())
+                {
+                  case EbtFloat: tempConstArray[i].setFConst(-unionArray[i].getFConst()); break;
+                  case EbtInt:   tempConstArray[i].setIConst(-unionArray[i].getIConst()); break;
+                  case EbtUInt:  tempConstArray[i].setUConst(static_cast&lt;unsigned int&gt;(-static_cast&lt;int&gt;(unionArray[i].getUConst()))); break;
+                  default:
+                    infoSink.info.message(EPrefixInternalError, getLine(), &quot;Unary operation not folded into constant&quot;);
</ins><span class="cx">                     return 0;
</span><ins>+                }
+                break;
+
+              case EOpLogicalNot: // this code is written for possible future use, will not get executed currently
+                switch (getType().getBasicType())
+                {
+                  case EbtBool:  tempConstArray[i].setBConst(!unionArray[i].getBConst()); break;
+                  default:
+                    infoSink.info.message(EPrefixInternalError, getLine(), &quot;Unary operation not folded into constant&quot;);
+                    return 0;
+                }
+                break;
+
+              default:
+                return 0;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         newNode = new TIntermConstantUnion(tempConstArray, getType());
</span><span class="lines">@@ -1423,7 +1730,7 @@
</span><span class="cx"> 
</span><span class="cx">     ConstantUnion *leftUnionArray = new ConstantUnion[size];
</span><span class="cx"> 
</span><del>-    for (size_t i = 0; i &lt; size; i++) {
</del><ins>+    for (size_t i=0; i &lt; size; i++) {
</ins><span class="cx"> 
</span><span class="cx">         switch (promoteTo) {
</span><span class="cx">             case EbtFloat:
</span><span class="lines">@@ -1431,6 +1738,9 @@
</span><span class="cx">                     case EbtInt:
</span><span class="cx">                         leftUnionArray[i].setFConst(static_cast&lt;float&gt;(node-&gt;getIConst(i)));
</span><span class="cx">                         break;
</span><ins>+                    case EbtUInt:
+                        leftUnionArray[i].setFConst(static_cast&lt;float&gt;(node-&gt;getUConst(i)));
+                        break;
</ins><span class="cx">                     case EbtBool:
</span><span class="cx">                         leftUnionArray[i].setFConst(static_cast&lt;float&gt;(node-&gt;getBConst(i)));
</span><span class="cx">                         break;
</span><span class="lines">@@ -1447,6 +1757,9 @@
</span><span class="cx">                     case EbtInt:
</span><span class="cx">                         leftUnionArray[i].setIConst(static_cast&lt;int&gt;(node-&gt;getIConst(i)));
</span><span class="cx">                         break;
</span><ins>+                    case EbtUInt:
+                        leftUnionArray[i].setIConst(static_cast&lt;int&gt;(node-&gt;getUConst(i)));
+                        break;
</ins><span class="cx">                     case EbtBool:
</span><span class="cx">                         leftUnionArray[i].setIConst(static_cast&lt;int&gt;(node-&gt;getBConst(i)));
</span><span class="cx">                         break;
</span><span class="lines">@@ -1458,11 +1771,33 @@
</span><span class="cx">                         return 0;
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><ins>+            case EbtUInt:
+                switch (node-&gt;getType().getBasicType()) {
+                    case EbtInt:
+                        leftUnionArray[i].setUConst(static_cast&lt;unsigned int&gt;(node-&gt;getIConst(i)));
+                        break;
+                    case EbtUInt:
+                        leftUnionArray[i].setUConst(static_cast&lt;unsigned int&gt;(node-&gt;getUConst(i)));
+                        break;
+                    case EbtBool:
+                        leftUnionArray[i].setUConst(static_cast&lt;unsigned int&gt;(node-&gt;getBConst(i)));
+                        break;
+                    case EbtFloat:
+                        leftUnionArray[i].setUConst(static_cast&lt;unsigned int&gt;(node-&gt;getFConst(i)));
+                        break;
+                    default:
+                        infoSink.info.message(EPrefixInternalError, node-&gt;getLine(), &quot;Cannot promote&quot;);
+                        return 0;
+                }
+                break;
</ins><span class="cx">             case EbtBool:
</span><span class="cx">                 switch (node-&gt;getType().getBasicType()) {
</span><span class="cx">                     case EbtInt:
</span><span class="cx">                         leftUnionArray[i].setBConst(node-&gt;getIConst(i) != 0);
</span><span class="cx">                         break;
</span><ins>+                    case EbtUInt:
+                        leftUnionArray[i].setBConst(node-&gt;getUConst(i) != 0);
+                        break;
</ins><span class="cx">                     case EbtBool:
</span><span class="cx">                         leftUnionArray[i].setBConst(node-&gt;getBConst(i));
</span><span class="cx">                         break;
</span><span class="lines">@@ -1484,7 +1819,7 @@
</span><span class="cx"> 
</span><span class="cx">     const TType&amp; t = node-&gt;getType();
</span><span class="cx"> 
</span><del>-    return addConstantUnion(leftUnionArray, TType(promoteTo, t.getPrecision(), t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node-&gt;getLine());
</del><ins>+    return addConstantUnion(leftUnionArray, TType(promoteTo, t.getPrecision(), t.getQualifier(), t.getNominalSize(), t.getSecondarySize(), t.isArray()), node-&gt;getLine());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // static
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorLoopInfocpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/LoopInfo.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/LoopInfo.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/LoopInfo.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,211 @@
</span><ins>+//
+// Copyright (c) 2002-2014 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 &quot;compiler/translator/LoopInfo.h&quot;
+
+namespace
+{
+
+int EvaluateIntConstant(TIntermConstantUnion *node)
+{
+    ASSERT(node &amp;&amp; node-&gt;getUnionArrayPointer());
+    return node-&gt;getIConst(0);
+}
+
+int GetLoopIntIncrement(TIntermLoop *node)
+{
+    TIntermNode *expr = node-&gt;getExpression();
+    // for expression has one of the following forms:
+    //     loop_index++
+    //     loop_index--
+    //     loop_index += constant_expression
+    //     loop_index -= constant_expression
+    //     ++loop_index
+    //     --loop_index
+    // The last two forms are not specified in the spec, but I am assuming
+    // its an oversight.
+    TIntermUnary *unOp = expr-&gt;getAsUnaryNode();
+    TIntermBinary *binOp = unOp ? NULL : expr-&gt;getAsBinaryNode();
+
+    TOperator op = EOpNull;
+    TIntermConstantUnion *incrementNode = NULL;
+    if (unOp)
+    {
+        op = unOp-&gt;getOp();
+    }
+    else if (binOp)
+    {
+        op = binOp-&gt;getOp();
+        ASSERT(binOp-&gt;getRight());
+        incrementNode = binOp-&gt;getRight()-&gt;getAsConstantUnion();
+        ASSERT(incrementNode);
+    }
+
+    int increment = 0;
+    // The operator is one of: ++ -- += -=.
+    switch (op)
+    {
+      case EOpPostIncrement:
+      case EOpPreIncrement:
+        ASSERT(unOp &amp;&amp; !binOp);
+        increment = 1;
+        break;
+      case EOpPostDecrement:
+      case EOpPreDecrement:
+        ASSERT(unOp &amp;&amp; !binOp);
+        increment = -1;
+        break;
+      case EOpAddAssign:
+        ASSERT(!unOp &amp;&amp; binOp);
+        increment = EvaluateIntConstant(incrementNode);
+        break;
+      case EOpSubAssign:
+        ASSERT(!unOp &amp;&amp; binOp);
+        increment = - EvaluateIntConstant(incrementNode);
+        break;
+      default:
+        UNREACHABLE();
+    }
+
+    return increment;
+}
+
+}  // namespace anonymous
+
+TLoopIndexInfo::TLoopIndexInfo()
+    : mId(-1),
+      mType(EbtVoid),
+      mInitValue(0),
+      mStopValue(0),
+      mIncrementValue(0),
+      mOp(EOpNull),
+      mCurrentValue(0)
+{
+}
+
+void TLoopIndexInfo::fillInfo(TIntermLoop *node)
+{
+    if (node == NULL)
+        return;
+
+    // Here we assume all the operations are valid, because the loop node is
+    // already validated in ValidateLimitations.
+    TIntermSequence &amp;declSeq =
+        node-&gt;getInit()-&gt;getAsAggregate()-&gt;getSequence();
+    TIntermBinary *declInit = declSeq[0]-&gt;getAsBinaryNode();
+    TIntermSymbol *symbol = declInit-&gt;getLeft()-&gt;getAsSymbolNode();
+
+    mId = symbol-&gt;getId();
+    mType = symbol-&gt;getBasicType();
+
+    if (mType == EbtInt)
+    {
+        TIntermConstantUnion* initNode = declInit-&gt;getRight()-&gt;getAsConstantUnion();
+        mInitValue = EvaluateIntConstant(initNode);
+        mCurrentValue = mInitValue;
+        mIncrementValue = GetLoopIntIncrement(node);
+
+        TIntermBinary* binOp = node-&gt;getCondition()-&gt;getAsBinaryNode();
+        mStopValue = EvaluateIntConstant(
+            binOp-&gt;getRight()-&gt;getAsConstantUnion());
+        mOp = binOp-&gt;getOp();
+    }
+}
+
+bool TLoopIndexInfo::satisfiesLoopCondition() const
+{
+    // Relational operator is one of: &gt; &gt;= &lt; &lt;= == or !=.
+    switch (mOp)
+    {
+      case EOpEqual:
+        return (mCurrentValue == mStopValue);
+      case EOpNotEqual:
+        return (mCurrentValue != mStopValue);
+      case EOpLessThan:
+        return (mCurrentValue &lt; mStopValue);
+      case EOpGreaterThan:
+        return (mCurrentValue &gt; mStopValue);
+      case EOpLessThanEqual:
+        return (mCurrentValue &lt;= mStopValue);
+      case EOpGreaterThanEqual:
+        return (mCurrentValue &gt;= mStopValue);
+      default:
+        UNREACHABLE();
+        return false;
+    }
+}
+
+TLoopInfo::TLoopInfo()
+    : loop(NULL)
+{
+}
+
+TLoopInfo::TLoopInfo(TIntermLoop *node)
+    : loop(node)
+{
+    index.fillInfo(node);
+}
+
+TIntermLoop *TLoopStack::findLoop(TIntermSymbol *symbol)
+{
+    if (!symbol)
+        return NULL;
+    for (iterator iter = begin(); iter != end(); ++iter)
+    {
+        if (iter-&gt;index.getId() == symbol-&gt;getId())
+            return iter-&gt;loop;
+    }
+    return NULL;
+}
+
+TLoopIndexInfo *TLoopStack::getIndexInfo(TIntermSymbol *symbol)
+{
+    if (!symbol)
+        return NULL;
+    for (iterator iter = begin(); iter != end(); ++iter)
+    {
+        if (iter-&gt;index.getId() == symbol-&gt;getId())
+            return &amp;(iter-&gt;index);
+    }
+    return NULL;
+}
+
+void TLoopStack::step()
+{
+    ASSERT(!empty());
+    rbegin()-&gt;index.step();
+}
+
+bool TLoopStack::satisfiesLoopCondition()
+{
+    ASSERT(!empty());
+    return rbegin()-&gt;index.satisfiesLoopCondition();
+}
+
+bool TLoopStack::needsToReplaceSymbolWithValue(TIntermSymbol *symbol)
+{
+    TIntermLoop *loop = findLoop(symbol);
+    return loop &amp;&amp; loop-&gt;getUnrollFlag();
+}
+
+int TLoopStack::getLoopIndexValue(TIntermSymbol *symbol)
+{
+    TLoopIndexInfo *info = getIndexInfo(symbol);
+    ASSERT(info);
+    return info-&gt;getCurrentValue();
+}
+
+void TLoopStack::push(TIntermLoop *loop)
+{
+    TLoopInfo info(loop);
+    push_back(info);
+}
+
+void TLoopStack::pop()
+{
+    pop_back();
+}
+
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorLoopInfoh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/LoopInfo.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/LoopInfo.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/LoopInfo.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,80 @@
</span><ins>+//
+// Copyright (c) 2002-2014 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_TRANSLATOR_LOOP_INFO_H_
+#define COMPILER_TRANSLATOR_LOOP_INFO_H_
+
+#include &quot;compiler/translator/intermediate.h&quot;
+
+class TLoopIndexInfo
+{
+  public:
+    TLoopIndexInfo();
+
+    // If type is EbtInt, fill all fields of the structure with info
+    // extracted from a loop node.
+    // If type is not EbtInt, only fill id and type.
+    void fillInfo(TIntermLoop *node);
+
+    int getId() const { return mId; }
+    void setId(int id) { mId = id; }
+    TBasicType getType() const { return mType; }
+    void setType(TBasicType type) { mType = type; }
+    int getCurrentValue() const { return mCurrentValue; }
+
+    void step() { mCurrentValue += mIncrementValue; }
+
+    // Check if the current value satisfies the loop condition.
+    bool satisfiesLoopCondition() const;
+
+  private:
+    int mId;
+    TBasicType mType;  // Either EbtInt or EbtFloat
+
+    // Below fields are only valid if the index's type is int.
+    int mInitValue;
+    int mStopValue;
+    int mIncrementValue;
+    TOperator mOp;
+    int mCurrentValue;
+};
+
+struct TLoopInfo
+{
+    TLoopIndexInfo index;
+    TIntermLoop *loop;
+
+    TLoopInfo();
+    TLoopInfo(TIntermLoop *node);
+};
+
+class TLoopStack : public TVector&lt;TLoopInfo&gt;
+{
+  public:
+    // Search loop stack for a loop whose index matches the input symbol.
+    TIntermLoop *findLoop(TIntermSymbol *symbol);
+
+    // Find the loop index info in the loop stack by the input symbol.
+    TLoopIndexInfo *getIndexInfo(TIntermSymbol *symbol);
+
+    // Update the currentValue for the next loop iteration.
+    void step();
+
+    // Return false if loop condition is no longer satisfied.
+    bool satisfiesLoopCondition();
+
+    // Check if the symbol is the index of a loop that's unrolled.
+    bool needsToReplaceSymbolWithValue(TIntermSymbol *symbol);
+
+    // Return the current value of a given loop index symbol.
+    int getLoopIndexValue(TIntermSymbol *symbol);
+
+    void push(TIntermLoop *info);
+    void pop();
+};
+
+#endif // COMPILER_TRANSLATOR_LOOP_INDEX_H_
+
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorMapLongVariableNamescpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/MapLongVariableNames.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/MapLongVariableNames.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/MapLongVariableNames.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,115 +0,0 @@
</span><del>-//
-// 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.
-//
-
-#include &quot;compiler/translator/MapLongVariableNames.h&quot;
-
-namespace {
-
-TString mapLongName(size_t id, const TString&amp; name, bool isGlobal)
-{
-    ASSERT(name.size() &gt; MAX_SHORTENED_IDENTIFIER_SIZE);
-    TStringStream stream;
-    stream &lt;&lt; &quot;webgl_&quot;;
-    if (isGlobal)
-        stream &lt;&lt; &quot;g&quot;;
-    stream &lt;&lt; id;
-    if (name[0] != '_')
-        stream &lt;&lt; &quot;_&quot;;
-    stream &lt;&lt; name.substr(0, MAX_SHORTENED_IDENTIFIER_SIZE - stream.str().size());
-    return stream.str();
-}
-
-LongNameMap* gLongNameMapInstance = NULL;
-
-}  // anonymous namespace
-
-LongNameMap::LongNameMap()
-    : refCount(0)
-{
-}
-
-LongNameMap::~LongNameMap()
-{
-}
-
-// static
-LongNameMap* LongNameMap::GetInstance()
-{
-    if (gLongNameMapInstance == NULL)
-        gLongNameMapInstance = new LongNameMap;
-    gLongNameMapInstance-&gt;refCount++;
-    return gLongNameMapInstance;
-}
-
-void LongNameMap::Release()
-{
-    ASSERT(gLongNameMapInstance == this);
-    ASSERT(refCount &gt; 0);
-    refCount--;
-    if (refCount == 0) {
-        delete gLongNameMapInstance;
-        gLongNameMapInstance = NULL;
-    }
-}
-
-const char* LongNameMap::Find(const char* originalName) const
-{
-    std::map&lt;std::string, std::string&gt;::const_iterator it = mLongNameMap.find(
-        originalName);
-    if (it != mLongNameMap.end())
-        return (*it).second.c_str();
-    return NULL;
-}
-
-void LongNameMap::Insert(const char* originalName, const char* mappedName)
-{
-    mLongNameMap.insert(std::map&lt;std::string, std::string&gt;::value_type(
-        originalName, mappedName));
-}
-
-size_t LongNameMap::Size() const
-{
-    return mLongNameMap.size();
-}
-
-MapLongVariableNames::MapLongVariableNames(LongNameMap* globalMap)
-{
-    ASSERT(globalMap);
-    mGlobalMap = globalMap;
-}
-
-void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol)
-{
-    ASSERT(symbol != NULL);
-    if (symbol-&gt;getSymbol().size() &gt; MAX_SHORTENED_IDENTIFIER_SIZE) {
-        switch (symbol-&gt;getQualifier()) {
-          case EvqVaryingIn:
-          case EvqVaryingOut:
-          case EvqInvariantVaryingIn:
-          case EvqInvariantVaryingOut:
-          case EvqUniform:
-            symbol-&gt;setSymbol(
-                mapGlobalLongName(symbol-&gt;getSymbol()));
-            break;
-          default:
-            symbol-&gt;setSymbol(
-                mapLongName(symbol-&gt;getId(), symbol-&gt;getSymbol(), false));
-            break;
-        };
-    }
-}
-
-TString MapLongVariableNames::mapGlobalLongName(const TString&amp; name)
-{
-    ASSERT(mGlobalMap);
-    const char* mappedName = mGlobalMap-&gt;Find(name.c_str());
-    if (mappedName != NULL)
-        return mappedName;
-    size_t id = mGlobalMap-&gt;Size();
-    TString rt = mapLongName(id, name, true);
-    mGlobalMap-&gt;Insert(name.c_str(), rt.c_str());
-    return rt;
-}
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorMapLongVariableNamesh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/MapLongVariableNames.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/MapLongVariableNames.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/MapLongVariableNames.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,58 +0,0 @@
</span><del>-//
-// 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.
-//
-
-#ifndef COMPILER_MAP_LONG_VARIABLE_NAMES_H_
-#define COMPILER_MAP_LONG_VARIABLE_NAMES_H_
-
-#include &quot;GLSLANG/ShaderLang.h&quot;
-
-#include &quot;compiler/translator/intermediate.h&quot;
-#include &quot;compiler/translator/VariableInfo.h&quot;
-
-// This size does not include '\0' in the end.
-#define MAX_SHORTENED_IDENTIFIER_SIZE 32
-
-// This is a ref-counted singleton. GetInstance() returns a pointer to the
-// singleton, and after use, call Release(). GetInstance() and Release() should
-// be paired.
-class LongNameMap {
-public:
-    static LongNameMap* GetInstance();
-    void Release();
-
-    // Return the mapped name if &lt;originalName, mappedName&gt; is in the map;
-    // otherwise, return NULL.
-    const char* Find(const char* originalName) const;
-
-    // Insert a pair into the map.
-    void Insert(const char* originalName, const char* mappedName);
-
-    // Return the number of entries in the map.
-    size_t Size() const;
-
-private:
-    LongNameMap();
-    ~LongNameMap();
-
-    size_t refCount;
-    std::map&lt;std::string, std::string&gt; mLongNameMap;
-};
-
-// Traverses intermediate tree to map attributes and uniforms names that are
-// longer than MAX_SHORTENED_IDENTIFIER_SIZE to MAX_SHORTENED_IDENTIFIER_SIZE.
-class MapLongVariableNames : public TIntermTraverser {
-public:
-    MapLongVariableNames(LongNameMap* globalMap);
-
-    virtual void visitSymbol(TIntermSymbol*);
-
-private:
-    TString mapGlobalLongName(const TString&amp; name);
-
-    LongNameMap* mGlobalMap;
-};
-
-#endif  // COMPILER_MAP_LONG_VARIABLE_NAMES_H_
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorOutputESSLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputESSL.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputESSL.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputESSL.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -10,8 +10,9 @@
</span><span class="cx">                          ShArrayIndexClampingStrategy clampingStrategy,
</span><span class="cx">                          ShHashFunction64 hashFunction,
</span><span class="cx">                          NameMap&amp; nameMap,
</span><del>-                         TSymbolTable&amp; symbolTable)
-    : TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable)
</del><ins>+                         TSymbolTable&amp; symbolTable,
+                         int shaderVersion)
+    : TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable, shaderVersion)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorOutputESSLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputESSL.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputESSL.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputESSL.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -16,7 +16,8 @@
</span><span class="cx">                 ShArrayIndexClampingStrategy clampingStrategy,
</span><span class="cx">                 ShHashFunction64 hashFunction,
</span><span class="cx">                 NameMap&amp; nameMap,
</span><del>-                TSymbolTable&amp; symbolTable);
</del><ins>+                TSymbolTable&amp; symbolTable,
+                int shaderVersion);
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     virtual bool writeVariablePrecision(TPrecision precision);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorOutputGLSLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSL.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSL.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSL.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -10,8 +10,9 @@
</span><span class="cx">                          ShArrayIndexClampingStrategy clampingStrategy,
</span><span class="cx">                          ShHashFunction64 hashFunction,
</span><span class="cx">                          NameMap&amp; nameMap,
</span><del>-                         TSymbolTable&amp; symbolTable)
-    : TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable)
</del><ins>+                         TSymbolTable&amp; symbolTable,
+                         int shaderVersion)
+    : TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable, shaderVersion)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -33,3 +34,24 @@
</span><span class="cx">         TOutputGLSLBase::visitSymbol(node);
</span><span class="cx">     }
</span><span class="cx"> }
</span><ins>+
+TString TOutputGLSL::translateTextureFunction(TString&amp; name)
+{
+    static const char *simpleRename[] = {
+        &quot;texture2DLodEXT&quot;, &quot;texture2DLod&quot;,
+        &quot;texture2DProjLodEXT&quot;, &quot;texture2DProjLod&quot;,
+        &quot;textureCubeLodEXT&quot;, &quot;textureCubeLod&quot;,
+        &quot;texture2DGradEXT&quot;, &quot;texture2DGradARB&quot;,
+        &quot;texture2DProjGradEXT&quot;, &quot;texture2DProjGradARB&quot;,
+        &quot;textureCubeGradEXT&quot;, &quot;textureCubeGradARB&quot;,
+        NULL, NULL
+    };
+
+    for (int i = 0; simpleRename[i] != NULL; i += 2) {
+        if (name == simpleRename[i]) {
+            return simpleRename[i+1];
+        }
+    }
+
+    return name;
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorOutputGLSLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSL.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSL.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSL.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -16,11 +16,13 @@
</span><span class="cx">                 ShArrayIndexClampingStrategy clampingStrategy,
</span><span class="cx">                 ShHashFunction64 hashFunction,
</span><span class="cx">                 NameMap&amp; nameMap,
</span><del>-                TSymbolTable&amp; symbolTable);
</del><ins>+                TSymbolTable&amp; symbolTable,
+                int shaderVersion);
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     virtual bool writeVariablePrecision(TPrecision);
</span><span class="cx">     virtual void visitSymbol(TIntermSymbol* node);
</span><ins>+    virtual TString translateTextureFunction(TString&amp; name);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif  // CROSSCOMPILERGLSL_OUTPUTGLSL_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorOutputGLSLBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSLBase.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSLBase.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSLBase.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -43,14 +43,16 @@
</span><span class="cx">                                  ShArrayIndexClampingStrategy clampingStrategy,
</span><span class="cx">                                  ShHashFunction64 hashFunction,
</span><span class="cx">                                  NameMap&amp; nameMap,
</span><del>-                                 TSymbolTable&amp; symbolTable)
</del><ins>+                                 TSymbolTable&amp; symbolTable,
+                                 int shaderVersion)
</ins><span class="cx">     : TIntermTraverser(true, true, true),
</span><span class="cx">       mObjSink(objSink),
</span><span class="cx">       mDeclaringVariables(false),
</span><span class="cx">       mClampingStrategy(clampingStrategy),
</span><span class="cx">       mHashFunction(hashFunction),
</span><span class="cx">       mNameMap(nameMap),
</span><del>-      mSymbolTable(symbolTable)
</del><ins>+      mSymbolTable(symbolTable),
+      mShaderVersion(shaderVersion)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -159,8 +161,8 @@
</span><span class="cx"> void TOutputGLSLBase::visitSymbol(TIntermSymbol* node)
</span><span class="cx"> {
</span><span class="cx">     TInfoSinkBase&amp; out = objSink();
</span><del>-    if (mLoopUnroll.NeedsToReplaceSymbolWithValue(node))
-        out &lt;&lt; mLoopUnroll.GetLoopIndexValue(node);
</del><ins>+    if (mLoopUnrollStack.needsToReplaceSymbolWithValue(node))
+        out &lt;&lt; mLoopUnrollStack.getLoopIndexValue(node);
</ins><span class="cx">     else
</span><span class="cx">         out &lt;&lt; hashVariableName(node-&gt;getSymbol());
</span><span class="cx"> 
</span><span class="lines">@@ -256,7 +258,7 @@
</span><span class="cx">                 const TField* field = structure-&gt;fields()[index-&gt;getIConst(0)];
</span><span class="cx"> 
</span><span class="cx">                 TString fieldName = field-&gt;name();
</span><del>-                if (!mSymbolTable.findBuiltIn(structure-&gt;name()))
</del><ins>+                if (!mSymbolTable.findBuiltIn(structure-&gt;name(), mShaderVersion))
</ins><span class="cx">                     fieldName = hashName(fieldName);
</span><span class="cx"> 
</span><span class="cx">                 out &lt;&lt; fieldName;
</span><span class="lines">@@ -643,7 +645,8 @@
</span><span class="cx">     TLoopType loopType = node-&gt;getType();
</span><span class="cx">     if (loopType == ELoopFor)  // for loop
</span><span class="cx">     {
</span><del>-        if (!node-&gt;getUnrollFlag()) {
</del><ins>+        if (!node-&gt;getUnrollFlag())
+        {
</ins><span class="cx">             out &lt;&lt; &quot;for (&quot;;
</span><span class="cx">             if (node-&gt;getInit())
</span><span class="cx">                 node-&gt;getInit()-&gt;traverse(this);
</span><span class="lines">@@ -657,6 +660,18 @@
</span><span class="cx">                 node-&gt;getExpression()-&gt;traverse(this);
</span><span class="cx">             out &lt;&lt; &quot;)\n&quot;;
</span><span class="cx">         }
</span><ins>+        else
+        {
+            // Need to put a one-iteration loop here to handle break.
+            TIntermSequence &amp;declSeq =
+                node-&gt;getInit()-&gt;getAsAggregate()-&gt;getSequence();
+            TIntermSymbol *indexSymbol =
+                declSeq[0]-&gt;getAsBinaryNode()-&gt;getLeft()-&gt;getAsSymbolNode();
+            TString name = hashVariableName(indexSymbol-&gt;getSymbol());
+            out &lt;&lt; &quot;for (int &quot; &lt;&lt; name &lt;&lt; &quot; = 0; &quot;
+                &lt;&lt; name &lt;&lt; &quot; &lt; 1; &quot;
+                &lt;&lt; &quot;++&quot; &lt;&lt; name &lt;&lt; &quot;)\n&quot;;
+        }
</ins><span class="cx">     }
</span><span class="cx">     else if (loopType == ELoopWhile)  // while loop
</span><span class="cx">     {
</span><span class="lines">@@ -674,15 +689,15 @@
</span><span class="cx">     // Loop body.
</span><span class="cx">     if (node-&gt;getUnrollFlag())
</span><span class="cx">     {
</span><del>-        TLoopIndexInfo indexInfo;
-        mLoopUnroll.FillLoopIndexInfo(node, indexInfo);
-        mLoopUnroll.Push(indexInfo);
-        while (mLoopUnroll.SatisfiesLoopCondition())
</del><ins>+        out &lt;&lt; &quot;{\n&quot;;
+        mLoopUnrollStack.push(node);
+        while (mLoopUnrollStack.satisfiesLoopCondition())
</ins><span class="cx">         {
</span><span class="cx">             visitCodeBlock(node-&gt;getBody());
</span><del>-            mLoopUnroll.Step();
</del><ins>+            mLoopUnrollStack.step();
</ins><span class="cx">         }
</span><del>-        mLoopUnroll.Pop();
</del><ins>+        mLoopUnrollStack.pop();
+        out &lt;&lt; &quot;}\n&quot;;
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="lines">@@ -777,7 +792,7 @@
</span><span class="cx"> 
</span><span class="cx"> TString TOutputGLSLBase::hashVariableName(const TString&amp; name)
</span><span class="cx"> {
</span><del>-    if (mSymbolTable.findBuiltIn(name) != NULL)
</del><ins>+    if (mSymbolTable.findBuiltIn(name, mShaderVersion) != NULL)
</ins><span class="cx">         return name;
</span><span class="cx">     return hashName(name);
</span><span class="cx"> }
</span><span class="lines">@@ -785,8 +800,10 @@
</span><span class="cx"> TString TOutputGLSLBase::hashFunctionName(const TString&amp; mangled_name)
</span><span class="cx"> {
</span><span class="cx">     TString name = TFunction::unmangleName(mangled_name);
</span><del>-    if (mSymbolTable.findBuiltIn(mangled_name) != NULL || name == &quot;main&quot;)
-        return name;
</del><ins>+    if (mSymbolTable.findBuiltIn(mangled_name, mShaderVersion) != NULL || name == &quot;main&quot;)
+    {
+        return translateTextureFunction(name);
+    }
</ins><span class="cx">     return hashName(name);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorOutputGLSLBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSLBase.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSLBase.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputGLSLBase.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -9,8 +9,8 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;set&gt;
</span><span class="cx"> 
</span><del>-#include &quot;compiler/translator/ForLoopUnroll.h&quot;
</del><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><ins>+#include &quot;compiler/translator/LoopInfo.h&quot;
</ins><span class="cx"> #include &quot;compiler/translator/ParseContext.h&quot;
</span><span class="cx"> 
</span><span class="cx"> class TOutputGLSLBase : public TIntermTraverser
</span><span class="lines">@@ -20,7 +20,8 @@
</span><span class="cx">                     ShArrayIndexClampingStrategy clampingStrategy,
</span><span class="cx">                     ShHashFunction64 hashFunction,
</span><span class="cx">                     NameMap&amp; nameMap,
</span><del>-                    TSymbolTable&amp; symbolTable);
</del><ins>+                    TSymbolTable&amp; symbolTable,
+                    int shaderVersion);
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     TInfoSinkBase&amp; objSink() { return mObjSink; }
</span><span class="lines">@@ -50,6 +51,8 @@
</span><span class="cx">     TString hashVariableName(const TString&amp; name);
</span><span class="cx">     // Same as hashName(), but without hashing built-in functions.
</span><span class="cx">     TString hashFunctionName(const TString&amp; mangled_name);
</span><ins>+    // Used to translate function names for differences between ESSL and GLSL
+    virtual TString translateTextureFunction(TString&amp; name) { return name; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     bool structDeclared(const TStructure* structure) const;
</span><span class="lines">@@ -64,7 +67,8 @@
</span><span class="cx">     typedef std::set&lt;TString&gt; DeclaredStructs;
</span><span class="cx">     DeclaredStructs mDeclaredStructs;
</span><span class="cx"> 
</span><del>-    ForLoopUnroll mLoopUnroll;
</del><ins>+    // Stack of loops that need to be unrolled.
+    TLoopStack mLoopUnrollStack;
</ins><span class="cx"> 
</span><span class="cx">     ShArrayIndexClampingStrategy mClampingStrategy;
</span><span class="cx"> 
</span><span class="lines">@@ -74,6 +78,8 @@
</span><span class="cx">     NameMap&amp; mNameMap;
</span><span class="cx"> 
</span><span class="cx">     TSymbolTable&amp; mSymbolTable;
</span><ins>+
+    const int mShaderVersion;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif  // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorOutputHLSLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputHLSL.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputHLSL.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputHLSL.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -7,11 +7,14 @@
</span><span class="cx"> #include &quot;compiler/translator/OutputHLSL.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><ins>+#include &quot;common/utilities.h&quot;
+#include &quot;common/blocklayout.h&quot;
</ins><span class="cx"> #include &quot;compiler/translator/compilerdebug.h&quot;
</span><ins>+#include &quot;compiler/translator/InfoSink.h&quot;
</ins><span class="cx"> #include &quot;compiler/translator/DetectDiscontinuity.h&quot;
</span><del>-#include &quot;compiler/translator/InfoSink.h&quot;
</del><span class="cx"> #include &quot;compiler/translator/SearchSymbol.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/UnfoldShortCircuit.h&quot;
</span><ins>+#include &quot;compiler/translator/FlagStd140Structs.h&quot;
</ins><span class="cx"> #include &quot;compiler/translator/NodeSearch.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/RewriteElseBlocks.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -22,27 +25,88 @@
</span><span class="cx"> namespace sh
</span><span class="cx"> {
</span><span class="cx"> 
</span><ins>+TString OutputHLSL::TextureFunction::name() const
+{
+    TString name = &quot;gl_texture&quot;;
+
+    if (IsSampler2D(sampler))
+    {
+        name += &quot;2D&quot;;
+    }
+    else if (IsSampler3D(sampler))
+    {
+        name += &quot;3D&quot;;
+    }
+    else if (IsSamplerCube(sampler))
+    {
+        name += &quot;Cube&quot;;
+    }
+    else UNREACHABLE();
+
+    if (proj)
+    {
+        name += &quot;Proj&quot;;
+    }
+
+    if (offset)
+    {
+        name += &quot;Offset&quot;;
+    }
+
+    switch(method)
+    {
+      case IMPLICIT:                  break;
+      case BIAS:                      break;   // Extra parameter makes the signature unique
+      case LOD:      name += &quot;Lod&quot;;   break;
+      case LOD0:     name += &quot;Lod0&quot;;  break;
+      case LOD0BIAS: name += &quot;Lod0&quot;;  break;   // Extra parameter makes the signature unique
+      case SIZE:     name += &quot;Size&quot;;  break;
+      case FETCH:    name += &quot;Fetch&quot;; break;
+      case GRAD:     name += &quot;Grad&quot;;  break;
+      default: UNREACHABLE();
+    }
+
+    return name + &quot;(&quot;;
+}
+
+const char *RegisterPrefix(const TType &amp;type)
+{
+    if (IsSampler(type.getBasicType()))
+    {
+        return &quot;s&quot;;
+    }
+    else
+    {
+        return &quot;c&quot;;
+    }
+}
+
+bool OutputHLSL::TextureFunction::operator&lt;(const TextureFunction &amp;rhs) const
+{
+    if (sampler &lt; rhs.sampler) return true;
+    if (sampler &gt; rhs.sampler) return false;
+
+    if (coords &lt; rhs.coords)   return true;
+    if (coords &gt; rhs.coords)   return false;
+
+    if (!proj &amp;&amp; rhs.proj)     return true;
+    if (proj &amp;&amp; !rhs.proj)     return false;
+
+    if (!offset &amp;&amp; rhs.offset) return true;
+    if (offset &amp;&amp; !rhs.offset) return false;
+
+    if (method &lt; rhs.method)   return true;
+    if (method &gt; rhs.method)   return false;
+
+    return false;
+}
+
</ins><span class="cx"> OutputHLSL::OutputHLSL(TParseContext &amp;context, const ShBuiltInResources&amp; resources, ShShaderOutput outputType)
</span><span class="cx">     : TIntermTraverser(true, true, true), mContext(context), mOutputType(outputType)
</span><span class="cx"> {
</span><span class="cx">     mUnfoldShortCircuit = new UnfoldShortCircuit(context, this);
</span><span class="cx">     mInsideFunction = false;
</span><span class="cx"> 
</span><del>-    mUsesTexture2D = false;
-    mUsesTexture2D_bias = false;
-    mUsesTexture2DProj = false;
-    mUsesTexture2DProj_bias = false;
-    mUsesTexture2DProjLod = false;
-    mUsesTexture2DLod = false;
-    mUsesTextureCube = false;
-    mUsesTextureCube_bias = false;
-    mUsesTextureCubeLod = false;
-    mUsesTexture2DLod0 = false;
-    mUsesTexture2DLod0_bias = false;
-    mUsesTexture2DProjLod0 = false;
-    mUsesTexture2DProjLod0_bias = false;
-    mUsesTextureCubeLod0 = false;
-    mUsesTextureCubeLod0_bias = false;
</del><span class="cx">     mUsesFragColor = false;
</span><span class="cx">     mUsesFragData = false;
</span><span class="cx">     mUsesDepthRange = false;
</span><span class="lines">@@ -68,6 +132,7 @@
</span><span class="cx">     mUsesAtan2_3 = false;
</span><span class="cx">     mUsesAtan2_4 = false;
</span><span class="cx">     mUsesDiscardRewriting = false;
</span><ins>+    mUsesNestedBreak = false;
</ins><span class="cx"> 
</span><span class="cx">     mNumRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1;
</span><span class="cx"> 
</span><span class="lines">@@ -78,6 +143,7 @@
</span><span class="cx">     mContainsLoopDiscontinuity = false;
</span><span class="cx">     mOutputLod0Function = false;
</span><span class="cx">     mInsideDiscontinuousLoop = false;
</span><ins>+    mNestedLoopDepth = 0;
</ins><span class="cx"> 
</span><span class="cx">     mExcessiveLoopIndex = NULL;
</span><span class="cx"> 
</span><span class="lines">@@ -98,6 +164,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     mSamplerRegister = 0;
</span><ins>+    mInterfaceBlockRegister = 2; // Reserve registers for the default uniform block and driver constants
+    mPaddingCounter = 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> OutputHLSL::~OutputHLSL()
</span><span class="lines">@@ -108,6 +176,8 @@
</span><span class="cx"> void OutputHLSL::output()
</span><span class="cx"> {
</span><span class="cx">     mContainsLoopDiscontinuity = mContext.shaderType == SH_FRAGMENT_SHADER &amp;&amp; containsLoopDiscontinuity(mContext.treeRoot);
</span><ins>+    const std::vector&lt;TIntermTyped*&gt; &amp;flaggedStructs = FlagStd140ValueStructs(mContext.treeRoot);
+    makeFlaggedStructMaps(flaggedStructs);
</ins><span class="cx"> 
</span><span class="cx">     // Work around D3D9 bug that would manifest in vertex shaders with selection blocks which
</span><span class="cx">     // use a vertex attribute as a condition, and some related computation in the else block.
</span><span class="lines">@@ -123,72 +193,472 @@
</span><span class="cx">     mContext.infoSink().obj &lt;&lt; mBody.c_str();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void OutputHLSL::makeFlaggedStructMaps(const std::vector&lt;TIntermTyped *&gt; &amp;flaggedStructs)
+{
+    for (unsigned int structIndex = 0; structIndex &lt; flaggedStructs.size(); structIndex++)
+    {
+        TIntermTyped *flaggedNode = flaggedStructs[structIndex];
+
+        // This will mark the necessary block elements as referenced
+        flaggedNode-&gt;traverse(this);
+        TString structName(mBody.c_str());
+        mBody.erase();
+
+        mFlaggedStructOriginalNames[flaggedNode] = structName;
+
+        for (size_t pos = structName.find('.'); pos != std::string::npos; pos = structName.find('.'))
+        {
+            structName.erase(pos, 1);
+        }
+
+        mFlaggedStructMappedNames[flaggedNode] = &quot;map&quot; + structName;
+    }
+}
+
</ins><span class="cx"> TInfoSinkBase &amp;OutputHLSL::getBodyStream()
</span><span class="cx"> {
</span><span class="cx">     return mBody;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-const ActiveUniforms &amp;OutputHLSL::getUniforms()
</del><ins>+const std::vector&lt;gl::Uniform&gt; &amp;OutputHLSL::getUniforms()
</ins><span class="cx"> {
</span><span class="cx">     return mActiveUniforms;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const std::vector&lt;gl::InterfaceBlock&gt; &amp;OutputHLSL::getInterfaceBlocks() const
+{
+    return mActiveInterfaceBlocks;
+}
+
+const std::vector&lt;gl::Attribute&gt; &amp;OutputHLSL::getOutputVariables() const
+{
+    return mActiveOutputVariables;
+}
+
+const std::vector&lt;gl::Attribute&gt; &amp;OutputHLSL::getAttributes() const
+{
+    return mActiveAttributes;
+}
+
+const std::vector&lt;gl::Varying&gt; &amp;OutputHLSL::getVaryings() const
+{
+    return mActiveVaryings;
+}
+
</ins><span class="cx"> int OutputHLSL::vectorSize(const TType &amp;type) const
</span><span class="cx"> {
</span><del>-    int elementSize = type.isMatrix() ? type.getNominalSize() : 1;
</del><ins>+    int elementSize = type.isMatrix() ? type.getCols() : 1;
</ins><span class="cx">     int arraySize = type.isArray() ? type.getArraySize() : 1;
</span><span class="cx"> 
</span><span class="cx">     return elementSize * arraySize;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void OutputHLSL::header()
</del><ins>+TString OutputHLSL::interfaceBlockFieldString(const TInterfaceBlock &amp;interfaceBlock, const TField &amp;field)
</ins><span class="cx"> {
</span><del>-    ShShaderType shaderType = mContext.shaderType;
-    TInfoSinkBase &amp;out = mHeader;
</del><ins>+    if (interfaceBlock.hasInstanceName())
+    {
+        return interfaceBlock.name() + &quot;.&quot; + field.name();
+    }
+    else
+    {
+        return field.name();
+    }
+}
</ins><span class="cx"> 
</span><del>-    for (StructDeclarations::iterator structDeclaration = mStructDeclarations.begin(); structDeclaration != mStructDeclarations.end(); structDeclaration++)
</del><ins>+TString OutputHLSL::decoratePrivate(const TString &amp;privateText)
+{
+    return &quot;dx_&quot; + privateText;
+}
+
+TString OutputHLSL::interfaceBlockStructNameString(const TInterfaceBlock &amp;interfaceBlock)
+{
+    return decoratePrivate(interfaceBlock.name()) + &quot;_type&quot;;
+}
+
+TString OutputHLSL::interfaceBlockInstanceString(const TInterfaceBlock&amp; interfaceBlock, unsigned int arrayIndex)
+{
+    if (!interfaceBlock.hasInstanceName())
</ins><span class="cx">     {
</span><del>-        out &lt;&lt; *structDeclaration;
</del><ins>+        return &quot;&quot;;
</ins><span class="cx">     }
</span><ins>+    else if (interfaceBlock.isArray())
+    {
+        return decoratePrivate(interfaceBlock.instanceName()) + &quot;_&quot; + str(arrayIndex);
+    }
+    else
+    {
+        return decorate(interfaceBlock.instanceName());
+    }
+}
</ins><span class="cx"> 
</span><del>-    for (Constructors::iterator constructor = mConstructors.begin(); constructor != mConstructors.end(); constructor++)
</del><ins>+TString OutputHLSL::interfaceBlockFieldTypeString(const TField &amp;field, TLayoutBlockStorage blockStorage)
+{
+    const TType &amp;fieldType = *field.type();
+    const TLayoutMatrixPacking matrixPacking = fieldType.getLayoutQualifier().matrixPacking;
+    ASSERT(matrixPacking != EmpUnspecified);
+
+    if (fieldType.isMatrix())
</ins><span class="cx">     {
</span><del>-        out &lt;&lt; *constructor;
</del><ins>+        // Use HLSL row-major packing for GLSL column-major matrices
+        const TString &amp;matrixPackString = (matrixPacking == EmpRowMajor ? &quot;column_major&quot; : &quot;row_major&quot;);
+        return matrixPackString + &quot; &quot; + typeString(fieldType);
</ins><span class="cx">     }
</span><ins>+    else if (fieldType.getStruct())
+    {
+        // Use HLSL row-major packing for GLSL column-major matrices
+        return structureTypeName(*fieldType.getStruct(), matrixPacking == EmpColumnMajor, blockStorage == EbsStd140);
+    }
+    else
+    {
+        return typeString(fieldType);
+    }
+}
</ins><span class="cx"> 
</span><ins>+TString OutputHLSL::interfaceBlockFieldString(const TInterfaceBlock &amp;interfaceBlock, TLayoutBlockStorage blockStorage)
+{
+    TString hlsl;
+
+    int elementIndex = 0;
+
+    for (unsigned int typeIndex = 0; typeIndex &lt; interfaceBlock.fields().size(); typeIndex++)
+    {
+        const TField &amp;field = *interfaceBlock.fields()[typeIndex];
+        const TType &amp;fieldType = *field.type();
+
+        if (blockStorage == EbsStd140)
+        {
+            // 2 and 3 component vector types in some cases need pre-padding
+            hlsl += std140PrePaddingString(fieldType, &amp;elementIndex);
+        }
+
+        hlsl += &quot;    &quot; + interfaceBlockFieldTypeString(field, blockStorage) +
+                &quot; &quot; + decorate(field.name()) + arrayString(fieldType) + &quot;;\n&quot;;
+
+        // must pad out after matrices and arrays, where HLSL usually allows itself room to pack stuff
+        if (blockStorage == EbsStd140)
+        {
+            const bool useHLSLRowMajorPacking = (fieldType.getLayoutQualifier().matrixPacking == EmpColumnMajor);
+            hlsl += std140PostPaddingString(fieldType, useHLSLRowMajorPacking);
+        }
+    }
+
+    return hlsl;
+}
+
+TString OutputHLSL::interfaceBlockStructString(const TInterfaceBlock &amp;interfaceBlock)
+{
+    const TLayoutBlockStorage blockStorage = interfaceBlock.blockStorage();
+
+    return &quot;struct &quot; + interfaceBlockStructNameString(interfaceBlock) + &quot;\n&quot;
+           &quot;{\n&quot; +
+           interfaceBlockFieldString(interfaceBlock, blockStorage) +
+           &quot;};\n\n&quot;;
+}
+
+TString OutputHLSL::interfaceBlockString(const TInterfaceBlock &amp;interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex)
+{
+    const TString &amp;arrayIndexString =  (arrayIndex != GL_INVALID_INDEX ? decorate(str(arrayIndex)) : &quot;&quot;);
+    const TString &amp;blockName = interfaceBlock.name() + arrayIndexString;
+    TString hlsl;
+
+    hlsl += &quot;cbuffer &quot; + blockName + &quot; : register(b&quot; + str(registerIndex) + &quot;)\n&quot;
+            &quot;{\n&quot;;
+
+    if (interfaceBlock.hasInstanceName())
+    {
+        hlsl += &quot;    &quot; + interfaceBlockStructNameString(interfaceBlock) + &quot; &quot; + interfaceBlockInstanceString(interfaceBlock, arrayIndex) + &quot;;\n&quot;;
+    }
+    else
+    {
+        const TLayoutBlockStorage blockStorage = interfaceBlock.blockStorage();
+        hlsl += interfaceBlockFieldString(interfaceBlock, blockStorage);
+    }
+
+    hlsl += &quot;};\n\n&quot;;
+
+    return hlsl;
+}
+
+TString OutputHLSL::std140PrePaddingString(const TType &amp;type, int *elementIndex)
+{
+    if (type.getBasicType() == EbtStruct || type.isMatrix() || type.isArray())
+    {
+        // no padding needed, HLSL will align the field to a new register
+        *elementIndex = 0;
+        return &quot;&quot;;
+    }
+
+    const GLenum glType = glVariableType(type);
+    const int numComponents = gl::UniformComponentCount(glType);
+
+    if (numComponents &gt;= 4)
+    {
+        // no padding needed, HLSL will align the field to a new register
+        *elementIndex = 0;
+        return &quot;&quot;;
+    }
+
+    if (*elementIndex + numComponents &gt; 4)
+    {
+        // no padding needed, HLSL will align the field to a new register
+        *elementIndex = numComponents;
+        return &quot;&quot;;
+    }
+
+    TString padding;
+
+    const int alignment = numComponents == 3 ? 4 : numComponents;
+    const int paddingOffset = (*elementIndex % alignment);
+
+    if (paddingOffset != 0)
+    {
+        // padding is neccessary
+        for (int paddingIndex = paddingOffset; paddingIndex &lt; alignment; paddingIndex++)
+        {
+            padding += &quot;    float pad_&quot; + str(mPaddingCounter++) + &quot;;\n&quot;;
+        }
+
+        *elementIndex += (alignment - paddingOffset);
+    }
+
+    *elementIndex += numComponents;
+    *elementIndex %= 4;
+
+    return padding;
+}
+
+TString OutputHLSL::std140PostPaddingString(const TType &amp;type, bool useHLSLRowMajorPacking)
+{
+    if (!type.isMatrix() &amp;&amp; !type.isArray() &amp;&amp; type.getBasicType() != EbtStruct)
+    {
+        return &quot;&quot;;
+    }
+
+    int numComponents = 0;
+
+    if (type.isMatrix())
+    {
+        // This method can also be called from structureString, which does not use layout qualifiers.
+        // Thus, use the method parameter for determining the matrix packing.
+        //
+        // Note HLSL row major packing corresponds to GL API column-major, and vice-versa, since we
+        // wish to always transpose GL matrices to play well with HLSL's matrix array indexing.
+        //
+        const bool isRowMajorMatrix = !useHLSLRowMajorPacking;
+        const GLenum glType = glVariableType(type);
+        numComponents = gl::MatrixComponentCount(glType, isRowMajorMatrix);
+    }
+    else if (type.getStruct())
+    {
+        const TString &amp;structName = structureTypeName(*type.getStruct(), useHLSLRowMajorPacking, true);
+        numComponents = mStd140StructElementIndexes[structName];
+
+        if (numComponents == 0)
+        {
+            return &quot;&quot;;
+        }
+    }
+    else
+    {
+        const GLenum glType = glVariableType(type);
+        numComponents = gl::UniformComponentCount(glType);
+    }
+
+    TString padding;
+    for (int paddingOffset = numComponents; paddingOffset &lt; 4; paddingOffset++)
+    {
+        padding += &quot;    float pad_&quot; + str(mPaddingCounter++) + &quot;;\n&quot;;
+    }
+    return padding;
+}
+
+// Use the same layout for packed and shared
+void setBlockLayout(gl::InterfaceBlock *interfaceBlock, gl::BlockLayoutType newLayout)
+{
+    interfaceBlock-&gt;layout = newLayout;
+    interfaceBlock-&gt;blockInfo.clear();
+
+    switch (newLayout)
+    {
+      case gl::BLOCKLAYOUT_SHARED:
+      case gl::BLOCKLAYOUT_PACKED:
+        {
+            gl::HLSLBlockEncoder hlslEncoder(&amp;interfaceBlock-&gt;blockInfo);
+            hlslEncoder.encodeInterfaceBlockFields(interfaceBlock-&gt;fields);
+            interfaceBlock-&gt;dataSize = hlslEncoder.getBlockSize();
+        }
+        break;
+
+      case gl::BLOCKLAYOUT_STANDARD:
+        {
+            gl::Std140BlockEncoder stdEncoder(&amp;interfaceBlock-&gt;blockInfo);
+            stdEncoder.encodeInterfaceBlockFields(interfaceBlock-&gt;fields);
+            interfaceBlock-&gt;dataSize = stdEncoder.getBlockSize();
+        }
+        break;
+
+      default:
+        UNREACHABLE();
+        break;
+    }
+}
+
+gl::BlockLayoutType convertBlockLayoutType(TLayoutBlockStorage blockStorage)
+{
+    switch (blockStorage)
+    {
+      case EbsPacked: return gl::BLOCKLAYOUT_PACKED;
+      case EbsShared: return gl::BLOCKLAYOUT_SHARED;
+      case EbsStd140: return gl::BLOCKLAYOUT_STANDARD;
+      default: UNREACHABLE(); return gl::BLOCKLAYOUT_SHARED;
+    }
+}
+
+TString OutputHLSL::structInitializerString(int indent, const TStructure &amp;structure, const TString &amp;rhsStructName)
+{
+    TString init;
+
+    TString preIndentString;
+    TString fullIndentString;
+
+    for (int spaces = 0; spaces &lt; (indent * 4); spaces++)
+    {
+        preIndentString += ' ';
+    }
+
+    for (int spaces = 0; spaces &lt; ((indent+1) * 4); spaces++)
+    {
+        fullIndentString += ' ';
+    }
+
+    init += preIndentString + &quot;{\n&quot;;
+
+    const TFieldList &amp;fields = structure.fields();
+    for (unsigned int fieldIndex = 0; fieldIndex &lt; fields.size(); fieldIndex++)
+    {
+        const TField &amp;field = *fields[fieldIndex];
+        const TString &amp;fieldName = rhsStructName + &quot;.&quot; + decorate(field.name());
+        const TType &amp;fieldType = *field.type();
+
+        if (fieldType.getStruct())
+        {
+            init += structInitializerString(indent + 1, *fieldType.getStruct(), fieldName);
+        }
+        else
+        {
+            init += fullIndentString + fieldName + &quot;,\n&quot;;
+        }
+    }
+
+    init += preIndentString + &quot;}&quot; + (indent == 0 ? &quot;;&quot; : &quot;,&quot;) + &quot;\n&quot;;
+
+    return init;
+}
+
+void OutputHLSL::header()
+{
+    TInfoSinkBase &amp;out = mHeader;
+
</ins><span class="cx">     TString uniforms;
</span><ins>+    TString interfaceBlocks;
</ins><span class="cx">     TString varyings;
</span><span class="cx">     TString attributes;
</span><ins>+    TString flaggedStructs;
</ins><span class="cx"> 
</span><del>-    for (ReferencedSymbols::const_iterator uniform = mReferencedUniforms.begin(); uniform != mReferencedUniforms.end(); uniform++)
</del><ins>+    for (ReferencedSymbols::const_iterator uniformIt = mReferencedUniforms.begin(); uniformIt != mReferencedUniforms.end(); uniformIt++)
</ins><span class="cx">     {
</span><del>-        const TType &amp;type = uniform-&gt;second-&gt;getType();
-        const TString &amp;name = uniform-&gt;second-&gt;getSymbol();
</del><ins>+        const TIntermSymbol &amp;uniform = *uniformIt-&gt;second;
+        const TType &amp;type = uniform.getType();
+        const TString &amp;name = uniform.getSymbol();
</ins><span class="cx"> 
</span><ins>+        int registerIndex = declareUniformAndAssignRegister(type, name);
+
</ins><span class="cx">         if (mOutputType == SH_HLSL11_OUTPUT &amp;&amp; IsSampler(type.getBasicType()))   // Also declare the texture
</span><span class="cx">         {
</span><del>-            int index = samplerRegister(mReferencedUniforms[name]);
</del><ins>+            uniforms += &quot;uniform &quot; + samplerString(type) + &quot; sampler_&quot; + decorateUniform(name, type) + arrayString(type) + 
+                        &quot; : register(s&quot; + str(registerIndex) + &quot;);\n&quot;;
</ins><span class="cx"> 
</span><del>-            uniforms += &quot;uniform SamplerState sampler_&quot; + decorateUniform(name, type) + arrayString(type) + 
-                        &quot; : register(s&quot; + str(index) + &quot;);\n&quot;;
</del><ins>+            uniforms += &quot;uniform &quot; + textureString(type) + &quot; texture_&quot; + decorateUniform(name, type) + arrayString(type) +
+                        &quot; : register(t&quot; + str(registerIndex) + &quot;);\n&quot;;
+        }
+        else
+        {
+            const TStructure *structure = type.getStruct();
+            const TString &amp;typeName = (structure ? structureTypeName(*structure, false, false) : typeString(type));
</ins><span class="cx"> 
</span><del>-            uniforms += &quot;uniform &quot; + textureString(type) + &quot; texture_&quot; + decorateUniform(name, type) + arrayString(type) + 
-                        &quot; : register(t&quot; + str(index) + &quot;);\n&quot;;
</del><ins>+            const TString &amp;registerString = TString(&quot;register(&quot;) + RegisterPrefix(type) + str(registerIndex) + &quot;)&quot;;
+
+            uniforms += &quot;uniform &quot; + typeName + &quot; &quot; + decorateUniform(name, type) + arrayString(type) + &quot; : &quot; + registerString + &quot;;\n&quot;;
</ins><span class="cx">         }
</span><ins>+    }
+
+    for (ReferencedSymbols::const_iterator interfaceBlockIt = mReferencedInterfaceBlocks.begin(); interfaceBlockIt != mReferencedInterfaceBlocks.end(); interfaceBlockIt++)
+    {
+        const TType &amp;nodeType = interfaceBlockIt-&gt;second-&gt;getType();
+        const TInterfaceBlock &amp;interfaceBlock = *nodeType.getInterfaceBlock();
+        const TFieldList &amp;fieldList = interfaceBlock.fields();
+
+        unsigned int arraySize = static_cast&lt;unsigned int&gt;(interfaceBlock.arraySize());
+        gl::InterfaceBlock activeBlock(interfaceBlock.name().c_str(), arraySize, mInterfaceBlockRegister);
+        for (unsigned int typeIndex = 0; typeIndex &lt; fieldList.size(); typeIndex++)
+        {
+            const TField &amp;field = *fieldList[typeIndex];
+            const TString &amp;fullUniformName = interfaceBlockFieldString(interfaceBlock, field);
+            declareInterfaceBlockField(*field.type(), fullUniformName, activeBlock.fields);
+        }
+
+        mInterfaceBlockRegister += std::max(1u, arraySize);
+
+        gl::BlockLayoutType blockLayoutType = convertBlockLayoutType(interfaceBlock.blockStorage());
+        setBlockLayout(&amp;activeBlock, blockLayoutType);
+
+        if (interfaceBlock.matrixPacking() == EmpRowMajor)
+        {
+            activeBlock.isRowMajorLayout = true;
+        }
+
+        mActiveInterfaceBlocks.push_back(activeBlock);
+
+        if (interfaceBlock.hasInstanceName())
+        {
+            interfaceBlocks += interfaceBlockStructString(interfaceBlock);
+        }
+
+        if (arraySize &gt; 0)
+        {
+            for (unsigned int arrayIndex = 0; arrayIndex &lt; arraySize; arrayIndex++)
+            {
+                interfaceBlocks += interfaceBlockString(interfaceBlock, activeBlock.registerIndex + arrayIndex, arrayIndex);
+            }
+        }
</ins><span class="cx">         else
</span><span class="cx">         {
</span><del>-            uniforms += &quot;uniform &quot; + typeString(type) + &quot; &quot; + decorateUniform(name, type) + arrayString(type) + 
-                        &quot; : register(&quot; + registerString(mReferencedUniforms[name]) + &quot;);\n&quot;;
</del><ins>+            interfaceBlocks += interfaceBlockString(interfaceBlock, activeBlock.registerIndex, GL_INVALID_INDEX);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    for (std::map&lt;TIntermTyped*, TString&gt;::const_iterator flaggedStructIt = mFlaggedStructMappedNames.begin(); flaggedStructIt != mFlaggedStructMappedNames.end(); flaggedStructIt++)
+    {
+        TIntermTyped *structNode = flaggedStructIt-&gt;first;
+        const TString &amp;mappedName = flaggedStructIt-&gt;second;
+        const TStructure &amp;structure = *structNode-&gt;getType().getStruct();
+        const TString &amp;originalName = mFlaggedStructOriginalNames[structNode];
+
+        flaggedStructs += &quot;static &quot; + decorate(structure.name()) + &quot; &quot; + mappedName + &quot; =\n&quot;;
+        flaggedStructs += structInitializerString(0, structure, originalName);
+        flaggedStructs += &quot;\n&quot;;
+    }
+
</ins><span class="cx">     for (ReferencedSymbols::const_iterator varying = mReferencedVaryings.begin(); varying != mReferencedVaryings.end(); varying++)
</span><span class="cx">     {
</span><span class="cx">         const TType &amp;type = varying-&gt;second-&gt;getType();
</span><span class="cx">         const TString &amp;name = varying-&gt;second-&gt;getSymbol();
</span><span class="cx"> 
</span><span class="cx">         // Program linking depends on this exact format
</span><del>-        varyings += &quot;static &quot; + typeString(type) + &quot; &quot; + decorate(name) + arrayString(type) + &quot; = &quot; + initializer(type) + &quot;;\n&quot;;
</del><ins>+        varyings += &quot;static &quot; + interpolationString(type.getQualifier()) + &quot; &quot; + typeString(type) + &quot; &quot; +
+                    decorate(name) + arrayString(type) + &quot; = &quot; + initializer(type) + &quot;;\n&quot;;
+
+        declareVaryingToList(type, type.getQualifier(), name, mActiveVaryings);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (ReferencedSymbols::const_iterator attribute = mReferencedAttributes.begin(); attribute != mReferencedAttributes.end(); attribute++)
</span><span class="lines">@@ -197,36 +667,76 @@
</span><span class="cx">         const TString &amp;name = attribute-&gt;second-&gt;getSymbol();
</span><span class="cx"> 
</span><span class="cx">         attributes += &quot;static &quot; + typeString(type) + &quot; &quot; + decorate(name) + arrayString(type) + &quot; = &quot; + initializer(type) + &quot;;\n&quot;;
</span><ins>+
+        gl::Attribute attributeVar(glVariableType(type), glVariablePrecision(type), name.c_str(),
+                               (unsigned int)type.getArraySize(), type.getLayoutQualifier().location);
+        mActiveAttributes.push_back(attributeVar);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    for (StructDeclarations::iterator structDeclaration = mStructDeclarations.begin(); structDeclaration != mStructDeclarations.end(); structDeclaration++)
+    {
+        out &lt;&lt; *structDeclaration;
+    }
+
+    for (Constructors::iterator constructor = mConstructors.begin(); constructor != mConstructors.end(); constructor++)
+    {
+        out &lt;&lt; *constructor;
+    }
+
</ins><span class="cx">     if (mUsesDiscardRewriting)
</span><span class="cx">     {
</span><span class="cx">         out &lt;&lt; &quot;#define ANGLE_USES_DISCARD_REWRITING&quot; &lt;&lt; &quot;\n&quot;;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (shaderType == SH_FRAGMENT_SHADER)
</del><ins>+    if (mUsesNestedBreak)
</ins><span class="cx">     {
</span><ins>+        out &lt;&lt; &quot;#define ANGLE_USES_NESTED_BREAK&quot; &lt;&lt; &quot;\n&quot;;
+    }
+
+    if (mContext.shaderType == SH_FRAGMENT_SHADER)
+    {
</ins><span class="cx">         TExtensionBehavior::const_iterator iter = mContext.extensionBehavior().find(&quot;GL_EXT_draw_buffers&quot;);
</span><span class="cx">         const bool usingMRTExtension = (iter != mContext.extensionBehavior().end() &amp;&amp; (iter-&gt;second == EBhEnable || iter-&gt;second == EBhRequire));
</span><span class="cx"> 
</span><del>-        const unsigned int numColorValues = usingMRTExtension ? mNumRenderTargets : 1;
-
</del><span class="cx">         out &lt;&lt; &quot;// Varyings\n&quot;;
</span><span class="cx">         out &lt;&lt;  varyings;
</span><del>-        out &lt;&lt; &quot;\n&quot;
-               &quot;static float4 gl_Color[&quot; &lt;&lt; numColorValues &lt;&lt; &quot;] =\n&quot;
-               &quot;{\n&quot;;
-        for (unsigned int i = 0; i &lt; numColorValues; i++)
</del><ins>+        out &lt;&lt; &quot;\n&quot;;
+
+        if (mContext.getShaderVersion() &gt;= 300)
</ins><span class="cx">         {
</span><del>-            out &lt;&lt; &quot;    float4(0, 0, 0, 0)&quot;;
-            if (i + 1 != numColorValues)
</del><ins>+            for (ReferencedSymbols::const_iterator outputVariableIt = mReferencedOutputVariables.begin(); outputVariableIt != mReferencedOutputVariables.end(); outputVariableIt++)
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;,&quot;;
</del><ins>+                const TString &amp;variableName = outputVariableIt-&gt;first;
+                const TType &amp;variableType = outputVariableIt-&gt;second-&gt;getType();
+                const TLayoutQualifier &amp;layoutQualifier = variableType.getLayoutQualifier();
+
+                out &lt;&lt; &quot;static &quot; + typeString(variableType) + &quot; out_&quot; + variableName + arrayString(variableType) +
+                       &quot; = &quot; + initializer(variableType) + &quot;;\n&quot;;
+
+                gl::Attribute outputVar(glVariableType(variableType), glVariablePrecision(variableType), variableName.c_str(),
+                                    (unsigned int)variableType.getArraySize(), layoutQualifier.location);
+                mActiveOutputVariables.push_back(outputVar);
</ins><span class="cx">             }
</span><del>-            out &lt;&lt; &quot;\n&quot;;
</del><span class="cx">         }
</span><del>-        out &lt;&lt; &quot;};\n&quot;;
</del><ins>+        else
+        {
+            const unsigned int numColorValues = usingMRTExtension ? mNumRenderTargets : 1;
</ins><span class="cx"> 
</span><ins>+            out &lt;&lt; &quot;static float4 gl_Color[&quot; &lt;&lt; numColorValues &lt;&lt; &quot;] =\n&quot;
+                   &quot;{\n&quot;;
+            for (unsigned int i = 0; i &lt; numColorValues; i++)
+            {
+                out &lt;&lt; &quot;    float4(0, 0, 0, 0)&quot;;
+                if (i + 1 != numColorValues)
+                {
+                    out &lt;&lt; &quot;,&quot;;
+                }
+                out &lt;&lt; &quot;\n&quot;;
+            }
+
+            out &lt;&lt; &quot;};\n&quot;;
+        }
+
</ins><span class="cx">         if (mUsesFragDepth)
</span><span class="cx">         {
</span><span class="cx">             out &lt;&lt; &quot;static float gl_Depth = 0.0;\n&quot;;
</span><span class="lines">@@ -311,300 +821,20 @@
</span><span class="cx">         out &lt;&lt;  uniforms;
</span><span class="cx">         out &lt;&lt; &quot;\n&quot;;
</span><span class="cx"> 
</span><del>-        if (mUsesTexture2D)
</del><ins>+        if (!interfaceBlocks.empty())
</ins><span class="cx">         {
</span><del>-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2D(sampler2D s, float2 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2D(s, t);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2D(Texture2D t, SamplerState s, float2 uv)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.Sample(s, uv);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
</del><ins>+            out &lt;&lt; interfaceBlocks;
+            out &lt;&lt; &quot;\n&quot;;
</ins><span class="cx"> 
</span><del>-        if (mUsesTexture2D_bias)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
</del><ins>+            if (!flaggedStructs.empty())
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_texture2D(sampler2D s, float2 t, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dbias(s, float4(t.x, t.y, 0, bias));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+                out &lt;&lt; &quot;// Std140 Structures accessed by value\n&quot;;
+                out &lt;&lt; &quot;\n&quot;;
+                out &lt;&lt; flaggedStructs;
+                out &lt;&lt; &quot;\n&quot;;
</ins><span class="cx">             }
</span><del>-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2D(Texture2D t, SamplerState s, float2 uv, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleBias(s, uv, bias);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
</del><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (mUsesTexture2DProj)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DProj(sampler2D s, float3 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dproj(s, float4(t.x, t.y, 0, t.z));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProj(sampler2D s, float4 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dproj(s, t);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.Sample(s, float2(uvw.x / uvw.z, uvw.y / uvw.z));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.Sample(s, float2(uvw.x / uvw.w, uvw.y / uvw.w));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
-        if (mUsesTexture2DProj_bias)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DProj(sampler2D s, float3 t, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dbias(s, float4(t.x / t.z, t.y / t.z, 0, bias));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProj(sampler2D s, float4 t, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dbias(s, float4(t.x / t.w, t.y / t.w, 0, bias));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleBias(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), bias);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleBias(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), bias);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
-        if (mUsesTextureCube)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_textureCube(samplerCUBE s, float3 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return texCUBE(s, t);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_textureCube(TextureCube t, SamplerState s, float3 uvw)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.Sample(s, uvw);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
-        if (mUsesTextureCube_bias)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_textureCube(samplerCUBE s, float3 t, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return texCUBEbias(s, float4(t.x, t.y, t.z, bias));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_textureCube(TextureCube t, SamplerState s, float3 uvw, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleBias(s, uvw, bias);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
-        // These *Lod0 intrinsics are not available in GL fragment shaders.
-        // They are used to sample using discontinuous texture coordinates.
-        if (mUsesTexture2DLod0)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DLod0(sampler2D s, float2 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DLod0(Texture2D t, SamplerState s, float2 uv)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, uv, 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
-        if (mUsesTexture2DLod0_bias)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DLod0(sampler2D s, float2 t, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DLod0(Texture2D t, SamplerState s, float2 uv, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, uv, 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
-        if (mUsesTexture2DProjLod0)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DProjLod0(sampler2D s, float3 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProjLod(sampler2D s, float4 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DProjLod0(Texture2D t, SamplerState s, float3 uvw)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProjLod0(Texture2D t, SamplerState s, float4 uvw)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
-        if (mUsesTexture2DProjLod0_bias)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DProjLod0_bias(sampler2D s, float3 t, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProjLod_bias(sampler2D s, float4 t, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_texture2DProjLod_bias(Texture2D t, SamplerState s, float3 uvw, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProjLod_bias(Texture2D t, SamplerState s, float4 uvw, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
-        if (mUsesTextureCubeLod0)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_textureCubeLod0(samplerCUBE s, float3 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_textureCubeLod0(TextureCube t, SamplerState s, float3 uvw)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, uvw, 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
-        if (mUsesTextureCubeLod0_bias)
-        {
-            if (mOutputType == SH_HLSL9_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_textureCubeLod0(samplerCUBE s, float3 t, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else if (mOutputType == SH_HLSL11_OUTPUT)
-            {
-                out &lt;&lt; &quot;float4 gl_textureCubeLod0(TextureCube t, SamplerState s, float3 uvw, float bias)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, uvw, 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
-            }
-            else UNREACHABLE();
-        }
-
</del><span class="cx">         if (usingMRTExtension &amp;&amp; mNumRenderTargets &gt; 1)
</span><span class="cx">         {
</span><span class="cx">             out &lt;&lt; &quot;#define GL_USES_MRT\n&quot;;
</span><span class="lines">@@ -679,151 +909,639 @@
</span><span class="cx">         out &lt;&lt; uniforms;
</span><span class="cx">         out &lt;&lt; &quot;\n&quot;;
</span><span class="cx">         
</span><del>-        if (mUsesTexture2D)
</del><ins>+        if (!interfaceBlocks.empty())
</ins><span class="cx">         {
</span><del>-            if (mOutputType == SH_HLSL9_OUTPUT)
</del><ins>+            out &lt;&lt; interfaceBlocks;
+            out &lt;&lt; &quot;\n&quot;;
+
+            if (!flaggedStructs.empty())
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_texture2D(sampler2D s, float2 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+                out &lt;&lt; &quot;// Std140 Structures accessed by value\n&quot;;
+                out &lt;&lt; &quot;\n&quot;;
+                out &lt;&lt; flaggedStructs;
+                out &lt;&lt; &quot;\n&quot;;
</ins><span class="cx">             }
</span><del>-            else if (mOutputType == SH_HLSL11_OUTPUT)
</del><ins>+        }
+    }
+
+    for (TextureFunctionSet::const_iterator textureFunction = mUsesTexture.begin(); textureFunction != mUsesTexture.end(); textureFunction++)
+    {
+        // Return type
+        if (textureFunction-&gt;method == TextureFunction::SIZE)
+        {
+            switch(textureFunction-&gt;sampler)
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_texture2D(Texture2D t, SamplerState s, float2 uv)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, uv, 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+              case EbtSampler2D:            out &lt;&lt; &quot;int2 &quot;; break;
+              case EbtSampler3D:            out &lt;&lt; &quot;int3 &quot;; break;
+              case EbtSamplerCube:          out &lt;&lt; &quot;int2 &quot;; break;
+              case EbtSampler2DArray:       out &lt;&lt; &quot;int3 &quot;; break;
+              case EbtISampler2D:           out &lt;&lt; &quot;int2 &quot;; break;
+              case EbtISampler3D:           out &lt;&lt; &quot;int3 &quot;; break;
+              case EbtISamplerCube:         out &lt;&lt; &quot;int2 &quot;; break;
+              case EbtISampler2DArray:      out &lt;&lt; &quot;int3 &quot;; break;
+              case EbtUSampler2D:           out &lt;&lt; &quot;int2 &quot;; break;
+              case EbtUSampler3D:           out &lt;&lt; &quot;int3 &quot;; break;
+              case EbtUSamplerCube:         out &lt;&lt; &quot;int2 &quot;; break;
+              case EbtUSampler2DArray:      out &lt;&lt; &quot;int3 &quot;; break;
+              case EbtSampler2DShadow:      out &lt;&lt; &quot;int2 &quot;; break;
+              case EbtSamplerCubeShadow:    out &lt;&lt; &quot;int2 &quot;; break;
+              case EbtSampler2DArrayShadow: out &lt;&lt; &quot;int3 &quot;; break;
+              default: UNREACHABLE();
</ins><span class="cx">             }
</span><del>-            else UNREACHABLE();
</del><span class="cx">         }
</span><ins>+        else   // Sampling function
+        {
+            switch(textureFunction-&gt;sampler)
+            {
+              case EbtSampler2D:            out &lt;&lt; &quot;float4 &quot;; break;
+              case EbtSampler3D:            out &lt;&lt; &quot;float4 &quot;; break;
+              case EbtSamplerCube:          out &lt;&lt; &quot;float4 &quot;; break;
+              case EbtSampler2DArray:       out &lt;&lt; &quot;float4 &quot;; break;
+              case EbtISampler2D:           out &lt;&lt; &quot;int4 &quot;;   break;
+              case EbtISampler3D:           out &lt;&lt; &quot;int4 &quot;;   break;
+              case EbtISamplerCube:         out &lt;&lt; &quot;int4 &quot;;   break;
+              case EbtISampler2DArray:      out &lt;&lt; &quot;int4 &quot;;   break;
+              case EbtUSampler2D:           out &lt;&lt; &quot;uint4 &quot;;  break;
+              case EbtUSampler3D:           out &lt;&lt; &quot;uint4 &quot;;  break;
+              case EbtUSamplerCube:         out &lt;&lt; &quot;uint4 &quot;;  break;
+              case EbtUSampler2DArray:      out &lt;&lt; &quot;uint4 &quot;;  break;
+              case EbtSampler2DShadow:      out &lt;&lt; &quot;float &quot;;  break;
+              case EbtSamplerCubeShadow:    out &lt;&lt; &quot;float &quot;;  break;
+              case EbtSampler2DArrayShadow: out &lt;&lt; &quot;float &quot;;  break;
+              default: UNREACHABLE();
+            }
+        }
</ins><span class="cx"> 
</span><del>-        if (mUsesTexture2DLod)
</del><ins>+        // Function name
+        out &lt;&lt; textureFunction-&gt;name();
+
+        // Argument list
+        int hlslCoords = 4;
+
+        if (mOutputType == SH_HLSL9_OUTPUT)
</ins><span class="cx">         {
</span><del>-            if (mOutputType == SH_HLSL9_OUTPUT)
</del><ins>+            switch(textureFunction-&gt;sampler)
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_texture2DLod(sampler2D s, float2 t, float lod)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x, t.y, 0, lod));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+              case EbtSampler2D:   out &lt;&lt; &quot;sampler2D s&quot;;   hlslCoords = 2; break;
+              case EbtSamplerCube: out &lt;&lt; &quot;samplerCUBE s&quot;; hlslCoords = 3; break;
+              default: UNREACHABLE();
</ins><span class="cx">             }
</span><del>-            else if (mOutputType == SH_HLSL11_OUTPUT)
</del><ins>+
+            switch(textureFunction-&gt;method)
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_texture2DLod(Texture2D t, SamplerState s, float2 uv, float lod)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, uv, lod);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+              case TextureFunction::IMPLICIT:                 break;
+              case TextureFunction::BIAS:     hlslCoords = 4; break;
+              case TextureFunction::LOD:      hlslCoords = 4; break;
+              case TextureFunction::LOD0:     hlslCoords = 4; break;
+              case TextureFunction::LOD0BIAS: hlslCoords = 4; break;
+              default: UNREACHABLE();
</ins><span class="cx">             }
</span><del>-            else UNREACHABLE();
</del><span class="cx">         }
</span><ins>+        else if (mOutputType == SH_HLSL11_OUTPUT)
+        {
+            switch(textureFunction-&gt;sampler)
+            {
+              case EbtSampler2D:            out &lt;&lt; &quot;Texture2D x, SamplerState s&quot;;                hlslCoords = 2; break;
+              case EbtSampler3D:            out &lt;&lt; &quot;Texture3D x, SamplerState s&quot;;                hlslCoords = 3; break;
+              case EbtSamplerCube:          out &lt;&lt; &quot;TextureCube x, SamplerState s&quot;;              hlslCoords = 3; break;
+              case EbtSampler2DArray:       out &lt;&lt; &quot;Texture2DArray x, SamplerState s&quot;;           hlslCoords = 3; break;
+              case EbtISampler2D:           out &lt;&lt; &quot;Texture2D&lt;int4&gt; x, SamplerState s&quot;;          hlslCoords = 2; break;
+              case EbtISampler3D:           out &lt;&lt; &quot;Texture3D&lt;int4&gt; x, SamplerState s&quot;;          hlslCoords = 3; break;
+              case EbtISamplerCube:         out &lt;&lt; &quot;Texture2DArray&lt;int4&gt; x, SamplerState s&quot;;     hlslCoords = 3; break;
+              case EbtISampler2DArray:      out &lt;&lt; &quot;Texture2DArray&lt;int4&gt; x, SamplerState s&quot;;     hlslCoords = 3; break;
+              case EbtUSampler2D:           out &lt;&lt; &quot;Texture2D&lt;uint4&gt; x, SamplerState s&quot;;         hlslCoords = 2; break;
+              case EbtUSampler3D:           out &lt;&lt; &quot;Texture3D&lt;uint4&gt; x, SamplerState s&quot;;         hlslCoords = 3; break;
+              case EbtUSamplerCube:         out &lt;&lt; &quot;Texture2DArray&lt;uint4&gt; x, SamplerState s&quot;;    hlslCoords = 3; break;
+              case EbtUSampler2DArray:      out &lt;&lt; &quot;Texture2DArray&lt;uint4&gt; x, SamplerState s&quot;;    hlslCoords = 3; break;
+              case EbtSampler2DShadow:      out &lt;&lt; &quot;Texture2D x, SamplerComparisonState s&quot;;      hlslCoords = 2; break;
+              case EbtSamplerCubeShadow:    out &lt;&lt; &quot;TextureCube x, SamplerComparisonState s&quot;;    hlslCoords = 3; break;
+              case EbtSampler2DArrayShadow: out &lt;&lt; &quot;Texture2DArray x, SamplerComparisonState s&quot;; hlslCoords = 3; break;
+              default: UNREACHABLE();
+            }
+        }
+        else UNREACHABLE();
</ins><span class="cx"> 
</span><del>-        if (mUsesTexture2DProj)
</del><ins>+        if (textureFunction-&gt;method == TextureFunction::FETCH)   // Integer coordinates
</ins><span class="cx">         {
</span><del>-            if (mOutputType == SH_HLSL9_OUTPUT)
</del><ins>+            switch(textureFunction-&gt;coords)
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_texture2DProj(sampler2D s, float3 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProj(sampler2D s, float4 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+              case 2: out &lt;&lt; &quot;, int2 t&quot;; break;
+              case 3: out &lt;&lt; &quot;, int3 t&quot;; break;
+              default: UNREACHABLE();
</ins><span class="cx">             }
</span><del>-            else if (mOutputType == SH_HLSL11_OUTPUT)
</del><ins>+        }
+        else   // Floating-point coordinates (except textureSize)
+        {
+            switch(textureFunction-&gt;coords)
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+              case 1: out &lt;&lt; &quot;, int lod&quot;;  break;   // textureSize()
+              case 2: out &lt;&lt; &quot;, float2 t&quot;; break;
+              case 3: out &lt;&lt; &quot;, float3 t&quot;; break;
+              case 4: out &lt;&lt; &quot;, float4 t&quot;; break;
+              default: UNREACHABLE();
</ins><span class="cx">             }
</span><del>-            else UNREACHABLE();
</del><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (mUsesTexture2DProjLod)
</del><ins>+        if (textureFunction-&gt;method == TextureFunction::GRAD)
</ins><span class="cx">         {
</span><del>-            if (mOutputType == SH_HLSL9_OUTPUT)
</del><ins>+            switch(textureFunction-&gt;sampler)
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_texture2DProjLod(sampler2D s, float3 t, float lod)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, lod));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProjLod(sampler2D s, float4 t, float lod)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, lod));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+              case EbtSampler2D:
+              case EbtISampler2D:
+              case EbtUSampler2D:
+              case EbtSampler2DArray:
+              case EbtISampler2DArray:
+              case EbtUSampler2DArray:
+              case EbtSampler2DShadow:
+              case EbtSampler2DArrayShadow:
+                out &lt;&lt; &quot;, float2 ddx, float2 ddy&quot;;
+                break;
+              case EbtSampler3D:
+              case EbtISampler3D:
+              case EbtUSampler3D:
+              case EbtSamplerCube:
+              case EbtISamplerCube:
+              case EbtUSamplerCube:
+              case EbtSamplerCubeShadow:
+                out &lt;&lt; &quot;, float3 ddx, float3 ddy&quot;;
+                break;
+              default: UNREACHABLE();
</ins><span class="cx">             }
</span><del>-            else if (mOutputType == SH_HLSL11_OUTPUT)
</del><ins>+        }
+
+        switch(textureFunction-&gt;method)
+        {
+          case TextureFunction::IMPLICIT:                        break;
+          case TextureFunction::BIAS:                            break;   // Comes after the offset parameter
+          case TextureFunction::LOD:      out &lt;&lt; &quot;, float lod&quot;;  break;
+          case TextureFunction::LOD0:                            break;
+          case TextureFunction::LOD0BIAS:                        break;   // Comes after the offset parameter
+          case TextureFunction::SIZE:                            break;
+          case TextureFunction::FETCH:    out &lt;&lt; &quot;, int mip&quot;;    break;
+          case TextureFunction::GRAD:                            break;
+          default: UNREACHABLE();
+        }
+
+        if (textureFunction-&gt;offset)
+        {
+            switch(textureFunction-&gt;sampler)
</ins><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_texture2DProjLod(Texture2D t, SamplerState s, float3 uvw, float lod)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), lod);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;
-                       &quot;float4 gl_texture2DProjLod(Texture2D t, SamplerState s, float4 uvw, float lod)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), lod);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+              case EbtSampler2D:            out &lt;&lt; &quot;, int2 offset&quot;; break;
+              case EbtSampler3D:            out &lt;&lt; &quot;, int3 offset&quot;; break;
+              case EbtSampler2DArray:       out &lt;&lt; &quot;, int2 offset&quot;; break;
+              case EbtISampler2D:           out &lt;&lt; &quot;, int2 offset&quot;; break;
+              case EbtISampler3D:           out &lt;&lt; &quot;, int3 offset&quot;; break;
+              case EbtISampler2DArray:      out &lt;&lt; &quot;, int2 offset&quot;; break;
+              case EbtUSampler2D:           out &lt;&lt; &quot;, int2 offset&quot;; break;
+              case EbtUSampler3D:           out &lt;&lt; &quot;, int3 offset&quot;; break;
+              case EbtUSampler2DArray:      out &lt;&lt; &quot;, int2 offset&quot;; break;
+              case EbtSampler2DShadow:      out &lt;&lt; &quot;, int2 offset&quot;; break;
+              case EbtSampler2DArrayShadow: out &lt;&lt; &quot;, int2 offset&quot;; break;
+              default: UNREACHABLE();
</ins><span class="cx">             }
</span><ins>+        }
+
+        if (textureFunction-&gt;method == TextureFunction::BIAS ||
+            textureFunction-&gt;method == TextureFunction::LOD0BIAS)
+        {
+            out &lt;&lt; &quot;, float bias&quot;;
+        }
+
+        out &lt;&lt; &quot;)\n&quot;
+               &quot;{\n&quot;;
+
+        if (textureFunction-&gt;method == TextureFunction::SIZE)
+        {
+            if (IsSampler2D(textureFunction-&gt;sampler) || IsSamplerCube(textureFunction-&gt;sampler))
+            {
+                if (IsSamplerArray(textureFunction-&gt;sampler))
+                {
+                    out &lt;&lt; &quot;    uint width; uint height; uint layers; uint numberOfLevels;\n&quot;
+                           &quot;    x.GetDimensions(lod, width, height, layers, numberOfLevels);\n&quot;;
+                }
+                else
+                {
+                    out &lt;&lt; &quot;    uint width; uint height; uint numberOfLevels;\n&quot;
+                           &quot;    x.GetDimensions(lod, width, height, numberOfLevels);\n&quot;;
+                }
+            }
+            else if (IsSampler3D(textureFunction-&gt;sampler))
+            {
+                out &lt;&lt; &quot;    uint width; uint height; uint depth; uint numberOfLevels;\n&quot;
+                       &quot;    x.GetDimensions(lod, width, height, depth, numberOfLevels);\n&quot;;
+            }
</ins><span class="cx">             else UNREACHABLE();
</span><ins>+
+            switch(textureFunction-&gt;sampler)
+            {
+              case EbtSampler2D:            out &lt;&lt; &quot;    return int2(width, height);&quot;;         break;
+              case EbtSampler3D:            out &lt;&lt; &quot;    return int3(width, height, depth);&quot;;  break;
+              case EbtSamplerCube:          out &lt;&lt; &quot;    return int2(width, height);&quot;;         break;
+              case EbtSampler2DArray:       out &lt;&lt; &quot;    return int3(width, height, layers);&quot;; break;
+              case EbtISampler2D:           out &lt;&lt; &quot;    return int2(width, height);&quot;;         break;
+              case EbtISampler3D:           out &lt;&lt; &quot;    return int3(width, height, depth);&quot;;  break;
+              case EbtISamplerCube:         out &lt;&lt; &quot;    return int2(width, height);&quot;;         break;
+              case EbtISampler2DArray:      out &lt;&lt; &quot;    return int3(width, height, layers);&quot;; break;
+              case EbtUSampler2D:           out &lt;&lt; &quot;    return int2(width, height);&quot;;         break;
+              case EbtUSampler3D:           out &lt;&lt; &quot;    return int3(width, height, depth);&quot;;  break;
+              case EbtUSamplerCube:         out &lt;&lt; &quot;    return int2(width, height);&quot;;         break;
+              case EbtUSampler2DArray:      out &lt;&lt; &quot;    return int3(width, height, layers);&quot;; break;
+              case EbtSampler2DShadow:      out &lt;&lt; &quot;    return int2(width, height);&quot;;         break;
+              case EbtSamplerCubeShadow:    out &lt;&lt; &quot;    return int2(width, height);&quot;;         break;
+              case EbtSampler2DArrayShadow: out &lt;&lt; &quot;    return int3(width, height, layers);&quot;; break;
+              default: UNREACHABLE();
+            }
</ins><span class="cx">         }
</span><ins>+        else
+        {
+            if (IsIntegerSampler(textureFunction-&gt;sampler) &amp;&amp; IsSamplerCube(textureFunction-&gt;sampler))
+            {
+                out &lt;&lt; &quot;    float width; float height; float layers; float levels;\n&quot;;
</ins><span class="cx"> 
</span><del>-        if (mUsesTextureCube)
-        {
</del><ins>+                out &lt;&lt; &quot;    uint mip = 0;\n&quot;;
+
+                out &lt;&lt; &quot;    x.GetDimensions(mip, width, height, layers, levels);\n&quot;;
+
+                out &lt;&lt; &quot;    bool xMajor = abs(t.x) &gt; abs(t.y) &amp;&amp; abs(t.x) &gt; abs(t.z);\n&quot;;
+                out &lt;&lt; &quot;    bool yMajor = abs(t.y) &gt; abs(t.z) &amp;&amp; abs(t.y) &gt; abs(t.x);\n&quot;;
+                out &lt;&lt; &quot;    bool zMajor = abs(t.z) &gt; abs(t.x) &amp;&amp; abs(t.z) &gt; abs(t.y);\n&quot;;
+                out &lt;&lt; &quot;    bool negative = (xMajor &amp;&amp; t.x &lt; 0.0f) || (yMajor &amp;&amp; t.y &lt; 0.0f) || (zMajor &amp;&amp; t.z &lt; 0.0f);\n&quot;;
+
+                // FACE_POSITIVE_X = 000b
+                // FACE_NEGATIVE_X = 001b
+                // FACE_POSITIVE_Y = 010b
+                // FACE_NEGATIVE_Y = 011b
+                // FACE_POSITIVE_Z = 100b
+                // FACE_NEGATIVE_Z = 101b
+                out &lt;&lt; &quot;    int face = (int)negative + (int)yMajor * 2 + (int)zMajor * 4;\n&quot;;
+
+                out &lt;&lt; &quot;    float u = xMajor ? -t.z : (yMajor &amp;&amp; t.y &lt; 0.0f ? -t.x : t.x);\n&quot;;
+                out &lt;&lt; &quot;    float v = yMajor ? t.z : (negative ? t.y : -t.y);\n&quot;;
+                out &lt;&lt; &quot;    float m = xMajor ? t.x : (yMajor ? t.y : t.z);\n&quot;;
+
+                out &lt;&lt; &quot;    t.x = (u * 0.5f / m) + 0.5f;\n&quot;;
+                out &lt;&lt; &quot;    t.y = (v * 0.5f / m) + 0.5f;\n&quot;;
+            }
+            else if (IsIntegerSampler(textureFunction-&gt;sampler) &amp;&amp;
+                     textureFunction-&gt;method != TextureFunction::FETCH)
+            {
+                if (IsSampler2D(textureFunction-&gt;sampler))
+                {
+                    if (IsSamplerArray(textureFunction-&gt;sampler))
+                    {
+                        out &lt;&lt; &quot;    float width; float height; float layers; float levels;\n&quot;;
+
+                        if (textureFunction-&gt;method == TextureFunction::LOD0)
+                        {
+                            out &lt;&lt; &quot;    uint mip = 0;\n&quot;;
+                        }
+                        else if (textureFunction-&gt;method == TextureFunction::LOD0BIAS)
+                        {
+                            out &lt;&lt; &quot;    uint mip = bias;\n&quot;;
+                        }
+                        else
+                        {
+                            if (textureFunction-&gt;method == TextureFunction::IMPLICIT ||
+                                textureFunction-&gt;method == TextureFunction::BIAS)
+                            {
+                                out &lt;&lt; &quot;    x.GetDimensions(0, width, height, layers, levels);\n&quot;
+                                       &quot;    float2 tSized = float2(t.x * width, t.y * height);\n&quot;
+                                       &quot;    float dx = length(ddx(tSized));\n&quot;
+                                       &quot;    float dy = length(ddy(tSized));\n&quot;
+                                       &quot;    float lod = log2(max(dx, dy));\n&quot;;
+
+                                if (textureFunction-&gt;method == TextureFunction::BIAS)
+                                {
+                                    out &lt;&lt; &quot;    lod += bias;\n&quot;;
+                                }
+                            }
+                            else if (textureFunction-&gt;method == TextureFunction::GRAD)
+                            {
+                                out &lt;&lt; &quot;    x.GetDimensions(0, width, height, layers, levels);\n&quot;
+                                       &quot;    float lod = log2(max(length(ddx), length(ddy)));\n&quot;;
+                            }
+
+                            out &lt;&lt; &quot;    uint mip = uint(min(max(round(lod), 0), levels - 1));\n&quot;;
+                        }
+
+                        out &lt;&lt; &quot;    x.GetDimensions(mip, width, height, layers, levels);\n&quot;;
+                    }
+                    else
+                    {
+                        out &lt;&lt; &quot;    float width; float height; float levels;\n&quot;;
+
+                        if (textureFunction-&gt;method == TextureFunction::LOD0)
+                        {
+                            out &lt;&lt; &quot;    uint mip = 0;\n&quot;;
+                        }
+                        else if (textureFunction-&gt;method == TextureFunction::LOD0BIAS)
+                        {
+                            out &lt;&lt; &quot;    uint mip = bias;\n&quot;;
+                        }
+                        else
+                        {
+                            if (textureFunction-&gt;method == TextureFunction::IMPLICIT ||
+                                textureFunction-&gt;method == TextureFunction::BIAS)
+                            {
+                                out &lt;&lt; &quot;    x.GetDimensions(0, width, height, levels);\n&quot;
+                                       &quot;    float2 tSized = float2(t.x * width, t.y * height);\n&quot;
+                                       &quot;    float dx = length(ddx(tSized));\n&quot;
+                                       &quot;    float dy = length(ddy(tSized));\n&quot;
+                                       &quot;    float lod = log2(max(dx, dy));\n&quot;;
+
+                                if (textureFunction-&gt;method == TextureFunction::BIAS)
+                                {
+                                    out &lt;&lt; &quot;    lod += bias;\n&quot;;
+                                }
+                            }
+                            else if (textureFunction-&gt;method == TextureFunction::LOD)
+                            {
+                                out &lt;&lt; &quot;    x.GetDimensions(0, width, height, levels);\n&quot;;
+                            }
+                            else if (textureFunction-&gt;method == TextureFunction::GRAD)
+                            {
+                                out &lt;&lt; &quot;    x.GetDimensions(0, width, height, levels);\n&quot;
+                                       &quot;    float lod = log2(max(length(ddx), length(ddy)));\n&quot;;
+                            }
+
+                            out &lt;&lt; &quot;    uint mip = uint(min(max(round(lod), 0), levels - 1));\n&quot;;
+                        }
+
+                        out &lt;&lt; &quot;    x.GetDimensions(mip, width, height, levels);\n&quot;;
+                    }
+                }
+                else if (IsSampler3D(textureFunction-&gt;sampler))
+                {
+                    out &lt;&lt; &quot;    float width; float height; float depth; float levels;\n&quot;;
+
+                    if (textureFunction-&gt;method == TextureFunction::LOD0)
+                    {
+                        out &lt;&lt; &quot;    uint mip = 0;\n&quot;;
+                    }
+                    else if (textureFunction-&gt;method == TextureFunction::LOD0BIAS)
+                    {
+                        out &lt;&lt; &quot;    uint mip = bias;\n&quot;;
+                    }
+                    else
+                    {
+                        if (textureFunction-&gt;method == TextureFunction::IMPLICIT ||
+                            textureFunction-&gt;method == TextureFunction::BIAS)
+                        {
+                            out &lt;&lt; &quot;    x.GetDimensions(0, width, height, depth, levels);\n&quot;
+                                   &quot;    float3 tSized = float3(t.x * width, t.y * height, t.z * depth);\n&quot;
+                                   &quot;    float dx = length(ddx(tSized));\n&quot;
+                                   &quot;    float dy = length(ddy(tSized));\n&quot;
+                                   &quot;    float lod = log2(max(dx, dy));\n&quot;;
+
+                            if (textureFunction-&gt;method == TextureFunction::BIAS)
+                            {
+                                out &lt;&lt; &quot;    lod += bias;\n&quot;;
+                            }
+                        }
+                        else if (textureFunction-&gt;method == TextureFunction::GRAD)
+                        {
+                            out &lt;&lt; &quot;    x.GetDimensions(0, width, height, depth, levels);\n&quot;
+                                   &quot;    float lod = log2(max(length(ddx), length(ddy)));\n&quot;;
+                        }
+
+                        out &lt;&lt; &quot;    uint mip = uint(min(max(round(lod), 0), levels - 1));\n&quot;;
+                    }
+
+                    out &lt;&lt; &quot;    x.GetDimensions(mip, width, height, depth, levels);\n&quot;;
+                }
+                else UNREACHABLE();
+            }
+
+            out &lt;&lt; &quot;    return &quot;;
+
+            // HLSL intrinsic
</ins><span class="cx">             if (mOutputType == SH_HLSL9_OUTPUT)
</span><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_textureCube(samplerCUBE s, float3 t)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+                switch(textureFunction-&gt;sampler)
+                {
+                  case EbtSampler2D:   out &lt;&lt; &quot;tex2D&quot;;   break;
+                  case EbtSamplerCube: out &lt;&lt; &quot;texCUBE&quot;; break;
+                  default: UNREACHABLE();
+                }
+
+                switch(textureFunction-&gt;method)
+                {
+                  case TextureFunction::IMPLICIT: out &lt;&lt; &quot;(s, &quot;;     break;
+                  case TextureFunction::BIAS:     out &lt;&lt; &quot;bias(s, &quot;; break;
+                  case TextureFunction::LOD:      out &lt;&lt; &quot;lod(s, &quot;;  break;
+                  case TextureFunction::LOD0:     out &lt;&lt; &quot;lod(s, &quot;;  break;
+                  case TextureFunction::LOD0BIAS: out &lt;&lt; &quot;lod(s, &quot;;  break;
+                  default: UNREACHABLE();
+                }
</ins><span class="cx">             }
</span><span class="cx">             else if (mOutputType == SH_HLSL11_OUTPUT)
</span><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_textureCube(TextureCube t, SamplerState s, float3 uvw)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, uvw, 0);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+                if (textureFunction-&gt;method == TextureFunction::GRAD)
+                {
+                    if (IsIntegerSampler(textureFunction-&gt;sampler))
+                    {
+                        out &lt;&lt; &quot;x.Load(&quot;;
+                    }
+                    else if (IsShadowSampler(textureFunction-&gt;sampler))
+                    {
+                        out &lt;&lt; &quot;x.SampleCmpLevelZero(s, &quot;;
+                    }
+                    else
+                    {
+                        out &lt;&lt; &quot;x.SampleGrad(s, &quot;;
+                    }
+                }
+                else if (IsIntegerSampler(textureFunction-&gt;sampler) ||
+                         textureFunction-&gt;method == TextureFunction::FETCH)
+                {
+                    out &lt;&lt; &quot;x.Load(&quot;;
+                }
+                else if (IsShadowSampler(textureFunction-&gt;sampler))
+                {
+                    out &lt;&lt; &quot;x.SampleCmp(s, &quot;;
+                }
+                else
+                {
+                    switch(textureFunction-&gt;method)
+                    {
+                      case TextureFunction::IMPLICIT: out &lt;&lt; &quot;x.Sample(s, &quot;;      break;
+                      case TextureFunction::BIAS:     out &lt;&lt; &quot;x.SampleBias(s, &quot;;  break;
+                      case TextureFunction::LOD:      out &lt;&lt; &quot;x.SampleLevel(s, &quot;; break;
+                      case TextureFunction::LOD0:     out &lt;&lt; &quot;x.SampleLevel(s, &quot;; break;
+                      case TextureFunction::LOD0BIAS: out &lt;&lt; &quot;x.SampleLevel(s, &quot;; break;
+                      default: UNREACHABLE();
+                    }
+                }
</ins><span class="cx">             }
</span><span class="cx">             else UNREACHABLE();
</span><del>-        }
</del><span class="cx"> 
</span><del>-        if (mUsesTextureCubeLod)
-        {
</del><ins>+            // Integer sampling requires integer addresses
+            TString addressx = &quot;&quot;;
+            TString addressy = &quot;&quot;;
+            TString addressz = &quot;&quot;;
+            TString close = &quot;&quot;;
+
+            if (IsIntegerSampler(textureFunction-&gt;sampler) ||
+                textureFunction-&gt;method == TextureFunction::FETCH)
+            {
+                switch(hlslCoords)
+                {
+                  case 2: out &lt;&lt; &quot;int3(&quot;; break;
+                  case 3: out &lt;&lt; &quot;int4(&quot;; break;
+                  default: UNREACHABLE();
+                }
+            
+                // Convert from normalized floating-point to integer
+                if (textureFunction-&gt;method != TextureFunction::FETCH)
+                {
+                    addressx = &quot;int(floor(width * frac((&quot;;
+                    addressy = &quot;int(floor(height * frac((&quot;;
+
+                    if (IsSamplerArray(textureFunction-&gt;sampler))
+                    {
+                        addressz = &quot;int(max(0, min(layers - 1, floor(0.5 + &quot;;
+                    }
+                    else if (IsSamplerCube(textureFunction-&gt;sampler))
+                    {
+                        addressz = &quot;((((&quot;;
+                    }
+                    else
+                    {
+                        addressz = &quot;int(floor(depth * frac((&quot;;
+                    }
+
+                    close = &quot;))))&quot;;
+                }
+            }
+            else
+            {
+                switch(hlslCoords)
+                {
+                  case 2: out &lt;&lt; &quot;float2(&quot;; break;
+                  case 3: out &lt;&lt; &quot;float3(&quot;; break;
+                  case 4: out &lt;&lt; &quot;float4(&quot;; break;
+                  default: UNREACHABLE();
+                }
+            }
+
+            TString proj = &quot;&quot;;   // Only used for projected textures
+        
+            if (textureFunction-&gt;proj)
+            {
+                switch(textureFunction-&gt;coords)
+                {
+                  case 3: proj = &quot; / t.z&quot;; break;
+                  case 4: proj = &quot; / t.w&quot;; break;
+                  default: UNREACHABLE();
+                }
+            }
+
+            out &lt;&lt; addressx + (&quot;t.x&quot; + proj) + close + &quot;, &quot; + addressy + (&quot;t.y&quot; + proj) + close;
+
</ins><span class="cx">             if (mOutputType == SH_HLSL9_OUTPUT)
</span><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_textureCubeLod(samplerCUBE s, float3 t, float lod)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return texCUBElod(s, float4(t.x, t.y, t.z, lod));\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+                if (hlslCoords &gt;= 3)
+                {
+                    if (textureFunction-&gt;coords &lt; 3)
+                    {
+                        out &lt;&lt; &quot;, 0&quot;;
+                    }
+                    else
+                    {
+                        out &lt;&lt; &quot;, t.z&quot; + proj;
+                    }
+                }
+
+                if (hlslCoords == 4)
+                {
+                    switch(textureFunction-&gt;method)
+                    {
+                      case TextureFunction::BIAS:     out &lt;&lt; &quot;, bias&quot;; break;
+                      case TextureFunction::LOD:      out &lt;&lt; &quot;, lod&quot;;  break;
+                      case TextureFunction::LOD0:     out &lt;&lt; &quot;, 0&quot;;    break;
+                      case TextureFunction::LOD0BIAS: out &lt;&lt; &quot;, bias&quot;; break;
+                      default: UNREACHABLE();
+                    }
+                }
+
+                out &lt;&lt; &quot;));\n&quot;;
</ins><span class="cx">             }
</span><span class="cx">             else if (mOutputType == SH_HLSL11_OUTPUT)
</span><span class="cx">             {
</span><del>-                out &lt;&lt; &quot;float4 gl_textureCubeLod(TextureCube t, SamplerState s, float3 uvw, float lod)\n&quot;
-                       &quot;{\n&quot;
-                       &quot;    return t.SampleLevel(s, uvw, lod);\n&quot;
-                       &quot;}\n&quot;
-                       &quot;\n&quot;;
</del><ins>+                if (hlslCoords &gt;= 3)
+                {
+                    if (IsIntegerSampler(textureFunction-&gt;sampler) &amp;&amp; IsSamplerCube(textureFunction-&gt;sampler))
+                    {
+                        out &lt;&lt; &quot;, face&quot;;
+                    }
+                    else
+                    {
+                        out &lt;&lt; &quot;, &quot; + addressz + (&quot;t.z&quot; + proj) + close;
+                    }
+                }
+
+                if (textureFunction-&gt;method == TextureFunction::GRAD)
+                {
+                    if (IsIntegerSampler(textureFunction-&gt;sampler))
+                    {
+                        out &lt;&lt; &quot;, mip)&quot;;
+                    }
+                    else if (IsShadowSampler(textureFunction-&gt;sampler))
+                    {
+                        // Compare value
+                        switch(textureFunction-&gt;coords)
+                        {
+                          case 3: out &lt;&lt; &quot;), t.z&quot;; break;
+                          case 4: out &lt;&lt; &quot;), t.w&quot;; break;
+                          default: UNREACHABLE();
+                        }
+                    }
+                    else
+                    {
+                        out &lt;&lt; &quot;), ddx, ddy&quot;;
+                    }
+                }
+                else if (IsIntegerSampler(textureFunction-&gt;sampler) ||
+                         textureFunction-&gt;method == TextureFunction::FETCH)
+                {
+                    out &lt;&lt; &quot;, mip)&quot;;
+                }
+                else if (IsShadowSampler(textureFunction-&gt;sampler))
+                {
+                    // Compare value
+                    switch(textureFunction-&gt;coords)
+                    {
+                      case 3: out &lt;&lt; &quot;), t.z&quot;; break;
+                      case 4: out &lt;&lt; &quot;), t.w&quot;; break;
+                      default: UNREACHABLE();
+                    }
+                }
+                else
+                {
+                    switch(textureFunction-&gt;method)
+                    {
+                      case TextureFunction::IMPLICIT: out &lt;&lt; &quot;)&quot;;       break;
+                      case TextureFunction::BIAS:     out &lt;&lt; &quot;), bias&quot;; break;
+                      case TextureFunction::LOD:      out &lt;&lt; &quot;), lod&quot;;  break;
+                      case TextureFunction::LOD0:     out &lt;&lt; &quot;), 0&quot;;    break;
+                      case TextureFunction::LOD0BIAS: out &lt;&lt; &quot;), bias&quot;; break;
+                      default: UNREACHABLE();
+                    }
+                }
+
+                if (textureFunction-&gt;offset)
+                {
+                    out &lt;&lt; &quot;, offset&quot;;
+                }
+
+                out &lt;&lt; &quot;);&quot;;
</ins><span class="cx">             }
</span><span class="cx">             else UNREACHABLE();
</span><span class="cx">         }
</span><ins>+
+        out &lt;&lt; &quot;\n&quot;
+               &quot;}\n&quot;
+               &quot;\n&quot;;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (mUsesFragCoord)
</span><span class="lines">@@ -1039,67 +1757,90 @@
</span><span class="cx"> {
</span><span class="cx">     TInfoSinkBase &amp;out = mBody;
</span><span class="cx"> 
</span><ins>+    // Handle accessing std140 structs by value
+    if (mFlaggedStructMappedNames.count(node) &gt; 0)
+    {
+        out &lt;&lt; mFlaggedStructMappedNames[node];
+        return;
+    }
+
</ins><span class="cx">     TString name = node-&gt;getSymbol();
</span><span class="cx"> 
</span><del>-    if (name == &quot;gl_FragColor&quot;)
</del><ins>+    if (name == &quot;gl_DepthRange&quot;)
</ins><span class="cx">     {
</span><del>-        out &lt;&lt; &quot;gl_Color[0]&quot;;
-        mUsesFragColor = true;
-    }
-    else if (name == &quot;gl_FragData&quot;)
-    {
-        out &lt;&lt; &quot;gl_Color&quot;;
-        mUsesFragData = true;
-    }
-    else if (name == &quot;gl_DepthRange&quot;)
-    {
</del><span class="cx">         mUsesDepthRange = true;
</span><span class="cx">         out &lt;&lt; name;
</span><span class="cx">     }
</span><del>-    else if (name == &quot;gl_FragCoord&quot;)
-    {
-        mUsesFragCoord = true;
-        out &lt;&lt; name;
-    }
-    else if (name == &quot;gl_PointCoord&quot;)
-    {
-        mUsesPointCoord = true;
-        out &lt;&lt; name;
-    }
-    else if (name == &quot;gl_FrontFacing&quot;)
-    {
-        mUsesFrontFacing = true;
-        out &lt;&lt; name;
-    }
-    else if (name == &quot;gl_PointSize&quot;)
-    {
-        mUsesPointSize = true;
-        out &lt;&lt; name;
-    }
-    else if (name == &quot;gl_FragDepthEXT&quot;)
-    {
-        mUsesFragDepth = true;
-        out &lt;&lt; &quot;gl_Depth&quot;;
-    }
</del><span class="cx">     else
</span><span class="cx">     {
</span><span class="cx">         TQualifier qualifier = node-&gt;getQualifier();
</span><span class="cx"> 
</span><span class="cx">         if (qualifier == EvqUniform)
</span><span class="cx">         {
</span><del>-            mReferencedUniforms[name] = node;
-            out &lt;&lt; decorateUniform(name, node-&gt;getType());
</del><ins>+            const TType&amp; nodeType = node-&gt;getType();
+            const TInterfaceBlock* interfaceBlock = nodeType.getInterfaceBlock();
+
+            if (interfaceBlock)
+            {
+                mReferencedInterfaceBlocks[interfaceBlock-&gt;name()] = node;
+            }
+            else
+            {
+                mReferencedUniforms[name] = node;
+            }
+
+            out &lt;&lt; decorateUniform(name, nodeType);
</ins><span class="cx">         }
</span><del>-        else if (qualifier == EvqAttribute)
</del><ins>+        else if (qualifier == EvqAttribute || qualifier == EvqVertexIn)
</ins><span class="cx">         {
</span><span class="cx">             mReferencedAttributes[name] = node;
</span><span class="cx">             out &lt;&lt; decorate(name);
</span><span class="cx">         }
</span><del>-        else if (qualifier == EvqVaryingOut || qualifier == EvqInvariantVaryingOut || qualifier == EvqVaryingIn || qualifier == EvqInvariantVaryingIn)
</del><ins>+        else if (isVarying(qualifier))
</ins><span class="cx">         {
</span><span class="cx">             mReferencedVaryings[name] = node;
</span><span class="cx">             out &lt;&lt; decorate(name);
</span><span class="cx">         }
</span><ins>+        else if (qualifier == EvqFragmentOut)
+        {
+            mReferencedOutputVariables[name] = node;
+            out &lt;&lt; &quot;out_&quot; &lt;&lt; name;
+        }
+        else if (qualifier == EvqFragColor)
+        {
+            out &lt;&lt; &quot;gl_Color[0]&quot;;
+            mUsesFragColor = true;
+        }
+        else if (qualifier == EvqFragData)
+        {
+            out &lt;&lt; &quot;gl_Color&quot;;
+            mUsesFragData = true;
+        }
+        else if (qualifier == EvqFragCoord)
+        {
+            mUsesFragCoord = true;
+            out &lt;&lt; name;
+        }
+        else if (qualifier == EvqPointCoord)
+        {
+            mUsesPointCoord = true;
+            out &lt;&lt; name;
+        }
+        else if (qualifier == EvqFrontFacing)
+        {
+            mUsesFrontFacing = true;
+            out &lt;&lt; name;
+        }
+        else if (qualifier == EvqPointSize)
+        {
+            mUsesPointSize = true;
+            out &lt;&lt; name;
+        }
+        else if (name == &quot;gl_FragDepthEXT&quot;)
+        {
+            mUsesFragDepth = true;
+            out &lt;&lt; &quot;gl_Depth&quot;;
+        }
</ins><span class="cx">         else if (qualifier == EvqInternal)
</span><span class="cx">         {
</span><span class="cx">             out &lt;&lt; name;
</span><span class="lines">@@ -1115,6 +1856,13 @@
</span><span class="cx"> {
</span><span class="cx">     TInfoSinkBase &amp;out = mBody;
</span><span class="cx"> 
</span><ins>+    // Handle accessing std140 structs by value
+    if (mFlaggedStructMappedNames.count(node) &gt; 0)
+    {
+        out &lt;&lt; mFlaggedStructMappedNames[node];
+        return false;
+    }
+
</ins><span class="cx">     switch (node-&gt;getOp())
</span><span class="cx">     {
</span><span class="cx">       case EOpAssign:                  outputTriplet(visit, &quot;(&quot;, &quot; = &quot;, &quot;)&quot;);           break;
</span><span class="lines">@@ -1189,19 +1937,55 @@
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">       case EOpDivAssign:               outputTriplet(visit, &quot;(&quot;, &quot; /= &quot;, &quot;)&quot;);          break;
</span><del>-      case EOpIndexDirect:             outputTriplet(visit, &quot;&quot;, &quot;[&quot;, &quot;]&quot;);              break;
-      case EOpIndexIndirect:           outputTriplet(visit, &quot;&quot;, &quot;[&quot;, &quot;]&quot;);              break;
</del><ins>+      case EOpIndexDirect:
+        {
+            const TType&amp; leftType = node-&gt;getLeft()-&gt;getType();
+            if (leftType.isInterfaceBlock())
+            {
+                if (visit == PreVisit)
+                {
+                    TInterfaceBlock* interfaceBlock = leftType.getInterfaceBlock();
+                    const int arrayIndex = node-&gt;getRight()-&gt;getAsConstantUnion()-&gt;getIConst(0);
+
+                    mReferencedInterfaceBlocks[interfaceBlock-&gt;instanceName()] = node-&gt;getLeft()-&gt;getAsSymbolNode();
+                    out &lt;&lt; interfaceBlockInstanceString(*interfaceBlock, arrayIndex);
+
+                    return false;
+                }
+            }
+            else
+            {
+                outputTriplet(visit, &quot;&quot;, &quot;[&quot;, &quot;]&quot;);
+            }
+        }
+        break;
+      case EOpIndexIndirect:
+        // We do not currently support indirect references to interface blocks
+        ASSERT(node-&gt;getLeft()-&gt;getBasicType() != EbtInterfaceBlock);
+        outputTriplet(visit, &quot;&quot;, &quot;[&quot;, &quot;]&quot;);
+        break;
</ins><span class="cx">       case EOpIndexDirectStruct:
</span><span class="cx">         if (visit == InVisit)
</span><span class="cx">         {
</span><span class="cx">             const TStructure* structure = node-&gt;getLeft()-&gt;getType().getStruct();
</span><span class="cx">             const TIntermConstantUnion* index = node-&gt;getRight()-&gt;getAsConstantUnion();
</span><span class="cx">             const TField* field = structure-&gt;fields()[index-&gt;getIConst(0)];
</span><del>-            out &lt;&lt; &quot;.&quot; + decorateField(field-&gt;name(), node-&gt;getLeft()-&gt;getType());
</del><ins>+            out &lt;&lt; &quot;.&quot; + decorateField(field-&gt;name(), *structure);
</ins><span class="cx"> 
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx">         break;
</span><ins>+      case EOpIndexDirectInterfaceBlock:
+        if (visit == InVisit)
+        {
+            const TInterfaceBlock* interfaceBlock = node-&gt;getLeft()-&gt;getType().getInterfaceBlock();
+            const TIntermConstantUnion* index = node-&gt;getRight()-&gt;getAsConstantUnion();
+            const TField* field = interfaceBlock-&gt;fields()[index-&gt;getIConst(0)];
+            out &lt;&lt; &quot;.&quot; + decorate(field-&gt;name());
+
+            return false;
+        }
+        break;
</ins><span class="cx">       case EOpVectorSwizzle:
</span><span class="cx">         if (visit == InVisit)
</span><span class="cx">         {
</span><span class="lines">@@ -1266,16 +2050,17 @@
</span><span class="cx">                 out &lt;&lt; &quot;!(&quot;;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            const TFieldList &amp;fields = node-&gt;getLeft()-&gt;getType().getStruct()-&gt;fields();
</del><ins>+            const TStructure &amp;structure = *node-&gt;getLeft()-&gt;getType().getStruct();
+            const TFieldList &amp;fields = structure.fields();
</ins><span class="cx"> 
</span><span class="cx">             for (size_t i = 0; i &lt; fields.size(); i++)
</span><span class="cx">             {
</span><span class="cx">                 const TField *field = fields[i];
</span><span class="cx"> 
</span><span class="cx">                 node-&gt;getLeft()-&gt;traverse(this);
</span><del>-                out &lt;&lt; &quot;.&quot; + decorateField(field-&gt;name(), node-&gt;getLeft()-&gt;getType()) + &quot; == &quot;;
</del><ins>+                out &lt;&lt; &quot;.&quot; + decorateField(field-&gt;name(), structure) + &quot; == &quot;;
</ins><span class="cx">                 node-&gt;getRight()-&gt;traverse(this);
</span><del>-                out &lt;&lt; &quot;.&quot; + decorateField(field-&gt;name(), node-&gt;getLeft()-&gt;getType());
</del><ins>+                out &lt;&lt; &quot;.&quot; + decorateField(field-&gt;name(), structure);
</ins><span class="cx"> 
</span><span class="cx">                 if (i &lt; fields.size() - 1)
</span><span class="cx">                 {
</span><span class="lines">@@ -1354,6 +2139,7 @@
</span><span class="cx">       case EOpPreIncrement:     outputTriplet(visit, &quot;(++&quot;, &quot;&quot;, &quot;)&quot;); break;
</span><span class="cx">       case EOpPreDecrement:     outputTriplet(visit, &quot;(--&quot;, &quot;&quot;, &quot;)&quot;); break;
</span><span class="cx">       case EOpConvIntToBool:
</span><ins>+      case EOpConvUIntToBool:
</ins><span class="cx">       case EOpConvFloatToBool:
</span><span class="cx">         switch (node-&gt;getOperand()-&gt;getType().getNominalSize())
</span><span class="cx">         {
</span><span class="lines">@@ -1366,6 +2152,7 @@
</span><span class="cx">         break;
</span><span class="cx">       case EOpConvBoolToFloat:
</span><span class="cx">       case EOpConvIntToFloat:
</span><ins>+      case EOpConvUIntToFloat:
</ins><span class="cx">         switch (node-&gt;getOperand()-&gt;getType().getNominalSize())
</span><span class="cx">         {
</span><span class="cx">           case 1:    outputTriplet(visit, &quot;float(&quot;, &quot;&quot;, &quot;)&quot;);  break;
</span><span class="lines">@@ -1377,6 +2164,7 @@
</span><span class="cx">         break;
</span><span class="cx">       case EOpConvFloatToInt:
</span><span class="cx">       case EOpConvBoolToInt:
</span><ins>+      case EOpConvUIntToInt:
</ins><span class="cx">         switch (node-&gt;getOperand()-&gt;getType().getNominalSize())
</span><span class="cx">         {
</span><span class="cx">           case 1:    outputTriplet(visit, &quot;int(&quot;, &quot;&quot;, &quot;)&quot;);  break;
</span><span class="lines">@@ -1386,6 +2174,18 @@
</span><span class="cx">           default: UNREACHABLE();
</span><span class="cx">         }
</span><span class="cx">         break;
</span><ins>+      case EOpConvFloatToUInt:
+      case EOpConvBoolToUInt:
+      case EOpConvIntToUInt:
+        switch (node-&gt;getOperand()-&gt;getType().getNominalSize())
+        {
+          case 1:    outputTriplet(visit, &quot;uint(&quot;, &quot;&quot;, &quot;)&quot;);  break;
+          case 2:    outputTriplet(visit, &quot;uint2(&quot;, &quot;&quot;, &quot;)&quot;);  break;
+          case 3:    outputTriplet(visit, &quot;uint3(&quot;, &quot;&quot;, &quot;)&quot;);  break;
+          case 4:    outputTriplet(visit, &quot;uint4(&quot;, &quot;&quot;, &quot;)&quot;);  break;
+          default: UNREACHABLE();
+        }
+        break;
</ins><span class="cx">       case EOpRadians:          outputTriplet(visit, &quot;radians(&quot;, &quot;&quot;, &quot;)&quot;);   break;
</span><span class="cx">       case EOpDegrees:          outputTriplet(visit, &quot;degrees(&quot;, &quot;&quot;, &quot;)&quot;);   break;
</span><span class="cx">       case EOpSin:              outputTriplet(visit, &quot;sin(&quot;, &quot;&quot;, &quot;)&quot;);       break;
</span><span class="lines">@@ -1538,7 +2338,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 else UNREACHABLE();
</span><span class="cx">             }
</span><del>-            else if (variable &amp;&amp; (variable-&gt;getQualifier() == EvqVaryingOut || variable-&gt;getQualifier() == EvqInvariantVaryingOut))
</del><ins>+            else if (variable &amp;&amp; isVaryingOut(variable-&gt;getQualifier()))
</ins><span class="cx">             {
</span><span class="cx">                 for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++)
</span><span class="cx">                 {
</span><span class="lines">@@ -1668,6 +2468,7 @@
</span><span class="cx">         {
</span><span class="cx">             TString name = TFunction::unmangleName(node-&gt;getName());
</span><span class="cx">             bool lod0 = mInsideDiscontinuousLoop || mOutputLod0Function;
</span><ins>+            TIntermSequence &amp;arguments = node-&gt;getSequence();
</ins><span class="cx"> 
</span><span class="cx">             if (node-&gt;isUserDefined())
</span><span class="cx">             {
</span><span class="lines">@@ -1675,134 +2476,124 @@
</span><span class="cx">             }
</span><span class="cx">             else
</span><span class="cx">             {
</span><del>-                if (name == &quot;texture2D&quot;)
-                {
-                    if (!lod0)
-                    {
-                        if (node-&gt;getSequence().size() == 2)
-                        {
-                            mUsesTexture2D = true;
-                        }
-                        else if (node-&gt;getSequence().size() == 3)
-                        {
-                            mUsesTexture2D_bias = true;
-                        }
-                        else UNREACHABLE();
</del><ins>+                TBasicType samplerType = arguments[0]-&gt;getAsTyped()-&gt;getType().getBasicType();
</ins><span class="cx"> 
</span><del>-                        out &lt;&lt; &quot;gl_texture2D(&quot;;
-                    }
-                    else
-                    {
-                        if (node-&gt;getSequence().size() == 2)
-                        {
-                            mUsesTexture2DLod0 = true;
-                        }
-                        else if (node-&gt;getSequence().size() == 3)
-                        {
-                            mUsesTexture2DLod0_bias = true;
-                        }
-                        else UNREACHABLE();
</del><ins>+                TextureFunction textureFunction;
+                textureFunction.sampler = samplerType;
+                textureFunction.coords = arguments[1]-&gt;getAsTyped()-&gt;getNominalSize();
+                textureFunction.method = TextureFunction::IMPLICIT;
+                textureFunction.proj = false;
+                textureFunction.offset = false;
</ins><span class="cx"> 
</span><del>-                        out &lt;&lt; &quot;gl_texture2DLod0(&quot;;
-                    }
</del><ins>+                if (name == &quot;texture2D&quot; || name == &quot;textureCube&quot; || name == &quot;texture&quot;)
+                {
+                    textureFunction.method = TextureFunction::IMPLICIT;
</ins><span class="cx">                 }
</span><del>-                else if (name == &quot;texture2DProj&quot;)
</del><ins>+                else if (name == &quot;texture2DProj&quot; || name == &quot;textureProj&quot;)
</ins><span class="cx">                 {
</span><del>-                    if (!lod0)
-                    {
-                        if (node-&gt;getSequence().size() == 2)
-                        {
-                            mUsesTexture2DProj = true;
-                        }
-                        else if (node-&gt;getSequence().size() == 3)
-                        {
-                            mUsesTexture2DProj_bias = true;
-                        }
-                        else UNREACHABLE();
</del><ins>+                    textureFunction.method = TextureFunction::IMPLICIT;
+                    textureFunction.proj = true;
+                }
+                else if (name == &quot;texture2DLod&quot; || name == &quot;textureCubeLod&quot; || name == &quot;textureLod&quot; ||
+                         name == &quot;texture2DLodEXT&quot; || name == &quot;textureCubeLodEXT&quot;)
+                {
+                    textureFunction.method = TextureFunction::LOD;
+                }
+                else if (name == &quot;texture2DProjLod&quot; || name == &quot;textureProjLod&quot; || name == &quot;texture2DProjLodEXT&quot;)
+                {
+                    textureFunction.method = TextureFunction::LOD;
+                    textureFunction.proj = true;
+                }
+                else if (name == &quot;textureSize&quot;)
+                {
+                    textureFunction.method = TextureFunction::SIZE;
+                }
+                else if (name == &quot;textureOffset&quot;)
+                {
+                    textureFunction.method = TextureFunction::IMPLICIT;
+                    textureFunction.offset = true;
+                }
+                else if (name == &quot;textureProjOffset&quot;)
+                {
+                    textureFunction.method = TextureFunction::IMPLICIT;
+                    textureFunction.offset = true;
+                    textureFunction.proj = true;
+                }
+                else if (name == &quot;textureLodOffset&quot;)
+                {
+                    textureFunction.method = TextureFunction::LOD;
+                    textureFunction.offset = true;
+                }
+                else if (name == &quot;textureProjLodOffset&quot;)
+                {
+                    textureFunction.method = TextureFunction::LOD;
+                    textureFunction.proj = true;
+                    textureFunction.offset = true;
+                }
+                else if (name == &quot;texelFetch&quot;)
+                {
+                    textureFunction.method = TextureFunction::FETCH;
+                }
+                else if (name == &quot;texelFetchOffset&quot;)
+                {
+                    textureFunction.method = TextureFunction::FETCH;
+                    textureFunction.offset = true;
+                }
+                else if (name == &quot;textureGrad&quot; || name == &quot;texture2DGradEXT&quot;)
+                {
+                    textureFunction.method = TextureFunction::GRAD;
+                }
+                else if (name == &quot;textureGradOffset&quot;)
+                {
+                    textureFunction.method = TextureFunction::GRAD;
+                    textureFunction.offset = true;
+                }
+                else if (name == &quot;textureProjGrad&quot; || name == &quot;texture2DProjGradEXT&quot; || name == &quot;textureCubeGradEXT&quot;)
+                {
+                    textureFunction.method = TextureFunction::GRAD;
+                    textureFunction.proj = true;
+                }
+                else if (name == &quot;textureProjGradOffset&quot;)
+                {
+                    textureFunction.method = TextureFunction::GRAD;
+                    textureFunction.proj = true;
+                    textureFunction.offset = true;
+                }
+                else UNREACHABLE();
</ins><span class="cx"> 
</span><del>-                        out &lt;&lt; &quot;gl_texture2DProj(&quot;;
-                    }
-                    else
</del><ins>+                if (textureFunction.method == TextureFunction::IMPLICIT)   // Could require lod 0 or have a bias argument
+                {
+                    unsigned int mandatoryArgumentCount = 2;   // All functions have sampler and coordinate arguments
+
+                    if (textureFunction.offset)
</ins><span class="cx">                     {
</span><del>-                        if (node-&gt;getSequence().size() == 2)
-                        {
-                            mUsesTexture2DProjLod0 = true;
-                        }
-                        else if (node-&gt;getSequence().size() == 3)
-                        {
-                            mUsesTexture2DProjLod0_bias = true;
-                        }
-                        else UNREACHABLE();
-
-                        out &lt;&lt; &quot;gl_texture2DProjLod0(&quot;;
</del><ins>+                        mandatoryArgumentCount++;
</ins><span class="cx">                     }
</span><del>-                }
-                else if (name == &quot;textureCube&quot;)
-                {
-                    if (!lod0)
-                    {
-                        if (node-&gt;getSequence().size() == 2)
-                        {
-                            mUsesTextureCube = true;
-                        }
-                        else if (node-&gt;getSequence().size() == 3)
-                        {
-                            mUsesTextureCube_bias = true;
-                        }
-                        else UNREACHABLE();
</del><span class="cx"> 
</span><del>-                        out &lt;&lt; &quot;gl_textureCube(&quot;;
-                    }
-                    else
</del><ins>+                    bool bias = (arguments.size() &gt; mandatoryArgumentCount);   // Bias argument is optional
+
+                    if (lod0 || mContext.shaderType == SH_VERTEX_SHADER)
</ins><span class="cx">                     {
</span><del>-                        if (node-&gt;getSequence().size() == 2)
</del><ins>+                        if (bias)
</ins><span class="cx">                         {
</span><del>-                            mUsesTextureCubeLod0 = true;
</del><ins>+                            textureFunction.method = TextureFunction::LOD0BIAS;
</ins><span class="cx">                         }
</span><del>-                        else if (node-&gt;getSequence().size() == 3)
</del><ins>+                        else
</ins><span class="cx">                         {
</span><del>-                            mUsesTextureCubeLod0_bias = true;
</del><ins>+                            textureFunction.method = TextureFunction::LOD0;
</ins><span class="cx">                         }
</span><del>-                        else UNREACHABLE();
-
-                        out &lt;&lt; &quot;gl_textureCubeLod0(&quot;;
</del><span class="cx">                     }
</span><del>-                }
-                else if (name == &quot;texture2DLod&quot;)
-                {
-                    if (node-&gt;getSequence().size() == 3)
</del><ins>+                    else if (bias)
</ins><span class="cx">                     {
</span><del>-                        mUsesTexture2DLod = true;
</del><ins>+                        textureFunction.method = TextureFunction::BIAS;
</ins><span class="cx">                     }
</span><del>-                    else UNREACHABLE();
-
-                    out &lt;&lt; &quot;gl_texture2DLod(&quot;;
</del><span class="cx">                 }
</span><del>-                else if (name == &quot;texture2DProjLod&quot;)
-                {
-                    if (node-&gt;getSequence().size() == 3)
-                    {
-                        mUsesTexture2DProjLod = true;
-                    }
-                    else UNREACHABLE();
</del><span class="cx"> 
</span><del>-                    out &lt;&lt; &quot;gl_texture2DProjLod(&quot;;
-                }
-                else if (name == &quot;textureCubeLod&quot;)
-                {
-                    if (node-&gt;getSequence().size() == 3)
-                    {
-                        mUsesTextureCubeLod = true;
-                    }
-                    else UNREACHABLE();
</del><ins>+                mUsesTexture.insert(textureFunction);
</ins><span class="cx"> 
</span><del>-                    out &lt;&lt; &quot;gl_textureCubeLod(&quot;;
-                }
-                else UNREACHABLE();
</del><ins>+                out &lt;&lt; textureFunction.name();
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            TIntermSequence &amp;arguments = node-&gt;getSequence();
-
</del><span class="cx">             for (TIntermSequence::iterator arg = arguments.begin(); arg != arguments.end(); arg++)
</span><span class="cx">             {
</span><span class="cx">                 if (mOutputType == SH_HLSL11_OUTPUT &amp;&amp; IsSampler((*arg)-&gt;getAsTyped()-&gt;getBasicType()))
</span><span class="lines">@@ -1874,6 +2665,22 @@
</span><span class="cx">         addConstructor(node-&gt;getType(), &quot;ivec4&quot;, &amp;node-&gt;getSequence());
</span><span class="cx">         outputTriplet(visit, &quot;ivec4(&quot;, &quot;, &quot;, &quot;)&quot;);
</span><span class="cx">         break;
</span><ins>+      case EOpConstructUInt:
+        addConstructor(node-&gt;getType(), &quot;uvec1&quot;, &amp;node-&gt;getSequence());
+        outputTriplet(visit, &quot;uvec1(&quot;, &quot;&quot;, &quot;)&quot;);
+        break;
+      case EOpConstructUVec2:
+        addConstructor(node-&gt;getType(), &quot;uvec2&quot;, &amp;node-&gt;getSequence());
+        outputTriplet(visit, &quot;uvec2(&quot;, &quot;, &quot;, &quot;)&quot;);
+        break;
+      case EOpConstructUVec3:
+        addConstructor(node-&gt;getType(), &quot;uvec3&quot;, &amp;node-&gt;getSequence());
+        outputTriplet(visit, &quot;uvec3(&quot;, &quot;, &quot;, &quot;)&quot;);
+        break;
+      case EOpConstructUVec4:
+        addConstructor(node-&gt;getType(), &quot;uvec4&quot;, &amp;node-&gt;getSequence());
+        outputTriplet(visit, &quot;uvec4(&quot;, &quot;, &quot;, &quot;)&quot;);
+        break;
</ins><span class="cx">       case EOpConstructMat2:
</span><span class="cx">         addConstructor(node-&gt;getType(), &quot;mat2&quot;, &amp;node-&gt;getSequence());
</span><span class="cx">         outputTriplet(visit, &quot;mat2(&quot;, &quot;, &quot;, &quot;)&quot;);
</span><span class="lines">@@ -1899,8 +2706,9 @@
</span><span class="cx">       case EOpMod:
</span><span class="cx">         {
</span><span class="cx">             // We need to look at the number of components in both arguments
</span><del>-            switch (node-&gt;getSequence()[0]-&gt;getAsTyped()-&gt;getNominalSize() * 10
-                     + node-&gt;getSequence()[1]-&gt;getAsTyped()-&gt;getNominalSize())
</del><ins>+            const int modValue = node-&gt;getSequence()[0]-&gt;getAsTyped()-&gt;getNominalSize() * 10
+                               + node-&gt;getSequence()[1]-&gt;getAsTyped()-&gt;getNominalSize();
+            switch (modValue)
</ins><span class="cx">             {
</span><span class="cx">               case 11: mUsesMod1 = true; break;
</span><span class="cx">               case 22: mUsesMod2v = true; break;
</span><span class="lines">@@ -2028,6 +2836,8 @@
</span><span class="cx"> 
</span><span class="cx"> bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node)
</span><span class="cx"> {
</span><ins>+    mNestedLoopDepth++;
+
</ins><span class="cx">     bool wasDiscontinuous = mInsideDiscontinuousLoop;
</span><span class="cx"> 
</span><span class="cx">     if (mContainsLoopDiscontinuity &amp;&amp; !mInsideDiscontinuousLoop)
</span><span class="lines">@@ -2039,6 +2849,9 @@
</span><span class="cx">     {
</span><span class="cx">         if (handleExcessiveLoop(node))
</span><span class="cx">         {
</span><ins>+            mInsideDiscontinuousLoop = wasDiscontinuous;
+            mNestedLoopDepth--;
+
</ins><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2102,6 +2915,7 @@
</span><span class="cx">     out &lt;&lt; &quot;}\n&quot;;
</span><span class="cx"> 
</span><span class="cx">     mInsideDiscontinuousLoop = wasDiscontinuous;
</span><ins>+    mNestedLoopDepth--;
</ins><span class="cx"> 
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="lines">@@ -2118,6 +2932,11 @@
</span><span class="cx">       case EOpBreak:
</span><span class="cx">         if (visit == PreVisit)
</span><span class="cx">         {
</span><ins>+            if (mNestedLoopDepth &gt; 1)
+            {
+                mUsesNestedBreak = true;
+            }
+
</ins><span class="cx">             if (mExcessiveLoopIndex)
</span><span class="cx">             {
</span><span class="cx">                 out &lt;&lt; &quot;{Break&quot;;
</span><span class="lines">@@ -2230,7 +3049,7 @@
</span><span class="cx"> 
</span><span class="cx">                     if (symbol &amp;&amp; constant)
</span><span class="cx">                     {
</span><del>-                        if (constant-&gt;getBasicType() == EbtInt &amp;&amp; constant-&gt;getNominalSize() == 1)
</del><ins>+                        if (constant-&gt;getBasicType() == EbtInt &amp;&amp; constant-&gt;isScalar())
</ins><span class="cx">                         {
</span><span class="cx">                             index = symbol;
</span><span class="cx">                             initial = constant-&gt;getIConst(0);
</span><span class="lines">@@ -2252,7 +3071,7 @@
</span><span class="cx"> 
</span><span class="cx">             if (constant)
</span><span class="cx">             {
</span><del>-                if (constant-&gt;getBasicType() == EbtInt &amp;&amp; constant-&gt;getNominalSize() == 1)
</del><ins>+                if (constant-&gt;getBasicType() == EbtInt &amp;&amp; constant-&gt;isScalar())
</ins><span class="cx">                 {
</span><span class="cx">                     comparator = test-&gt;getOp();
</span><span class="cx">                     limit = constant-&gt;getIConst(0);
</span><span class="lines">@@ -2274,7 +3093,7 @@
</span><span class="cx"> 
</span><span class="cx">             if (constant)
</span><span class="cx">             {
</span><del>-                if (constant-&gt;getBasicType() == EbtInt &amp;&amp; constant-&gt;getNominalSize() == 1)
</del><ins>+                if (constant-&gt;getBasicType() == EbtInt &amp;&amp; constant-&gt;isScalar())
</ins><span class="cx">                 {
</span><span class="cx">                     int value = constant-&gt;getIConst(0);
</span><span class="cx"> 
</span><span class="lines">@@ -2450,13 +3269,35 @@
</span><span class="cx"> 
</span><span class="cx">     if (mOutputType == SH_HLSL11_OUTPUT &amp;&amp; IsSampler(type.getBasicType()))
</span><span class="cx">     {
</span><del>-       return qualifierString(qualifier) + &quot; &quot; + textureString(type) + &quot; texture_&quot; + name + arrayString(type) + &quot;, &quot; +
-              qualifierString(qualifier) + &quot; SamplerState sampler_&quot; + name + arrayString(type);
</del><ins>+        return qualifierString(qualifier) + &quot; &quot; + textureString(type) + &quot; texture_&quot; + name + arrayString(type) + &quot;, &quot; +
+               qualifierString(qualifier) + &quot; &quot; + samplerString(type) + &quot; sampler_&quot; + name + arrayString(type);        
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return qualifierString(qualifier) + &quot; &quot; + typeString(type) + &quot; &quot; + name + arrayString(type);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TString OutputHLSL::interpolationString(TQualifier qualifier)
+{
+    switch(qualifier)
+    {
+      case EvqVaryingIn:           return &quot;&quot;;
+      case EvqFragmentIn:          return &quot;&quot;;
+      case EvqInvariantVaryingIn:  return &quot;&quot;;
+      case EvqSmoothIn:            return &quot;linear&quot;;
+      case EvqFlatIn:              return &quot;nointerpolation&quot;;
+      case EvqCentroidIn:          return &quot;centroid&quot;;
+      case EvqVaryingOut:          return &quot;&quot;;
+      case EvqVertexOut:           return &quot;&quot;;
+      case EvqInvariantVaryingOut: return &quot;&quot;;
+      case EvqSmoothOut:           return &quot;linear&quot;;
+      case EvqFlatOut:             return &quot;nointerpolation&quot;;
+      case EvqCentroidOut:         return &quot;centroid&quot;;
+      default: UNREACHABLE();
+    }
+
+    return &quot;&quot;;
+}
+
</ins><span class="cx"> TString OutputHLSL::qualifierString(TQualifier qualifier)
</span><span class="cx"> {
</span><span class="cx">     switch(qualifier)
</span><span class="lines">@@ -2473,40 +3314,24 @@
</span><span class="cx"> 
</span><span class="cx"> TString OutputHLSL::typeString(const TType &amp;type)
</span><span class="cx"> {
</span><del>-    if (type.getBasicType() == EbtStruct)
</del><ins>+    const TStructure* structure = type.getStruct();
+    if (structure)
</ins><span class="cx">     {
</span><del>-        const TString&amp; typeName = type.getStruct()-&gt;name();
</del><ins>+        const TString&amp; typeName = structure-&gt;name();
</ins><span class="cx">         if (typeName != &quot;&quot;)
</span><span class="cx">         {
</span><span class="cx">             return structLookup(typeName);
</span><span class="cx">         }
</span><span class="cx">         else   // Nameless structure, define in place
</span><span class="cx">         {
</span><del>-            const TFieldList &amp;fields = type.getStruct()-&gt;fields();
-
-            TString string = &quot;struct\n&quot;
-                             &quot;{\n&quot;;
-
-            for (unsigned int i = 0; i &lt; fields.size(); i++)
-            {
-                const TField *field = fields[i];
-
-                string += &quot;    &quot; + typeString(*field-&gt;type()) + &quot; &quot; + decorate(field-&gt;name()) + arrayString(*field-&gt;type()) + &quot;;\n&quot;;
-            }
-
-            string += &quot;} &quot;;
-
-            return string;
</del><ins>+            return structureString(*structure, false, false);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     else if (type.isMatrix())
</span><span class="cx">     {
</span><del>-        switch (type.getNominalSize())
-        {
-          case 2: return &quot;float2x2&quot;;
-          case 3: return &quot;float3x3&quot;;
-          case 4: return &quot;float4x4&quot;;
-        }
</del><ins>+        int cols = type.getCols();
+        int rows = type.getRows();
+        return &quot;float&quot; + str(cols) + &quot;x&quot; + str(rows);
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="lines">@@ -2528,6 +3353,14 @@
</span><span class="cx">               case 3: return &quot;int3&quot;;
</span><span class="cx">               case 4: return &quot;int4&quot;;
</span><span class="cx">             }
</span><ins>+          case EbtUInt:
+            switch (type.getNominalSize())
+            {
+              case 1: return &quot;uint&quot;;
+              case 2: return &quot;uint2&quot;;
+              case 3: return &quot;uint3&quot;;
+              case 4: return &quot;uint4&quot;;
+            }
</ins><span class="cx">           case EbtBool:
</span><span class="cx">             switch (type.getNominalSize())
</span><span class="cx">             {
</span><span class="lines">@@ -2539,8 +3372,15 @@
</span><span class="cx">           case EbtVoid:
</span><span class="cx">             return &quot;void&quot;;
</span><span class="cx">           case EbtSampler2D:
</span><ins>+          case EbtISampler2D:
+          case EbtUSampler2D:
+          case EbtSampler2DArray:
+          case EbtISampler2DArray:
+          case EbtUSampler2DArray:
</ins><span class="cx">             return &quot;sampler2D&quot;;
</span><span class="cx">           case EbtSamplerCube:
</span><ins>+          case EbtISamplerCube:
+          case EbtUSamplerCube:
</ins><span class="cx">             return &quot;samplerCUBE&quot;;
</span><span class="cx">           case EbtSamplerExternalOES:
</span><span class="cx">             return &quot;sampler2D&quot;;
</span><span class="lines">@@ -2557,20 +3397,40 @@
</span><span class="cx"> {
</span><span class="cx">     switch (type.getBasicType())
</span><span class="cx">     {
</span><del>-      case EbtSampler2D:
-        return &quot;Texture2D&quot;;
-      case EbtSamplerCube:
-        return &quot;TextureCube&quot;;
-      case EbtSamplerExternalOES:
-        return &quot;Texture2D&quot;;
-      default:
-        break;
</del><ins>+      case EbtSampler2D:            return &quot;Texture2D&quot;;
+      case EbtSamplerCube:          return &quot;TextureCube&quot;;
+      case EbtSamplerExternalOES:   return &quot;Texture2D&quot;;
+      case EbtSampler2DArray:       return &quot;Texture2DArray&quot;;
+      case EbtSampler3D:            return &quot;Texture3D&quot;;
+      case EbtISampler2D:           return &quot;Texture2D&lt;int4&gt;&quot;;
+      case EbtISampler3D:           return &quot;Texture3D&lt;int4&gt;&quot;;
+      case EbtISamplerCube:         return &quot;Texture2DArray&lt;int4&gt;&quot;;
+      case EbtISampler2DArray:      return &quot;Texture2DArray&lt;int4&gt;&quot;;
+      case EbtUSampler2D:           return &quot;Texture2D&lt;uint4&gt;&quot;;
+      case EbtUSampler3D:           return &quot;Texture3D&lt;uint4&gt;&quot;;
+      case EbtUSamplerCube:         return &quot;Texture2DArray&lt;uint4&gt;&quot;;
+      case EbtUSampler2DArray:      return &quot;Texture2DArray&lt;uint4&gt;&quot;;
+      case EbtSampler2DShadow:      return &quot;Texture2D&quot;;
+      case EbtSamplerCubeShadow:    return &quot;TextureCube&quot;;
+      case EbtSampler2DArrayShadow: return &quot;Texture2DArray&quot;;
+      default: UNREACHABLE();
</ins><span class="cx">     }
</span><del>-
-    UNREACHABLE();
</del><ins>+    
</ins><span class="cx">     return &quot;&lt;unknown texture type&gt;&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TString OutputHLSL::samplerString(const TType &amp;type)
+{
+    if (IsShadowSampler(type.getBasicType()))
+    {
+        return &quot;SamplerComparisonState&quot;;
+    }
+    else
+    {
+        return &quot;SamplerState&quot;;
+    }
+}
+
</ins><span class="cx"> TString OutputHLSL::arrayString(const TType &amp;type)
</span><span class="cx"> {
</span><span class="cx">     if (!type.isArray())
</span><span class="lines">@@ -2599,6 +3459,77 @@
</span><span class="cx">     return &quot;{&quot; + string + &quot;}&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TString OutputHLSL::structureString(const TStructure &amp;structure, bool useHLSLRowMajorPacking, bool useStd140Packing)
+{
+    const TFieldList &amp;fields = structure.fields();
+    const bool isNameless = (structure.name() == &quot;&quot;);
+    const TString &amp;structName = structureTypeName(structure, useHLSLRowMajorPacking, useStd140Packing);
+    const TString declareString = (isNameless ? &quot;struct&quot; : &quot;struct &quot; + structName);
+
+    TString string;
+    string += declareString + &quot;\n&quot;
+              &quot;{\n&quot;;
+
+    int elementIndex = 0;
+
+    for (unsigned int i = 0; i &lt; fields.size(); i++)
+    {
+        const TField &amp;field = *fields[i];
+        const TType &amp;fieldType = *field.type();
+        const TStructure *fieldStruct = fieldType.getStruct();
+        const TString &amp;fieldTypeString = fieldStruct ? structureTypeName(*fieldStruct, useHLSLRowMajorPacking, useStd140Packing) : typeString(fieldType);
+
+        if (useStd140Packing)
+        {
+            string += std140PrePaddingString(*field.type(), &amp;elementIndex);
+        }
+
+        string += &quot;    &quot; + fieldTypeString + &quot; &quot; + decorateField(field.name(), structure) + arrayString(fieldType) + &quot;;\n&quot;;
+
+        if (useStd140Packing)
+        {
+            string += std140PostPaddingString(*field.type(), useHLSLRowMajorPacking);
+        }
+    }
+
+    // Nameless structs do not finish with a semicolon and newline, to leave room for an instance variable
+    string += (isNameless ? &quot;} &quot; : &quot;};\n&quot;);
+
+    // Add remaining element index to the global map, for use with nested structs in standard layouts
+    if (useStd140Packing)
+    {
+        mStd140StructElementIndexes[structName] = elementIndex;
+    }
+
+    return string;
+}
+
+TString OutputHLSL::structureTypeName(const TStructure &amp;structure, bool useHLSLRowMajorPacking, bool useStd140Packing)
+{
+    if (structure.name() == &quot;&quot;)
+    {
+        return &quot;&quot;;
+    }
+
+    TString prefix = &quot;&quot;;
+
+    // Structs packed with row-major matrices in HLSL are prefixed with &quot;rm&quot;
+    // GLSL column-major maps to HLSL row-major, and the converse is true
+
+    if (useStd140Packing)
+    {
+        prefix += &quot;std&quot;;
+    }
+
+    if (useHLSLRowMajorPacking)
+    {
+        if (prefix != &quot;&quot;) prefix += &quot;_&quot;;
+        prefix += &quot;rm&quot;;
+    }
+
+    return prefix + structLookup(structure.name());
+}
+
</ins><span class="cx"> void OutputHLSL::addConstructor(const TType &amp;type, const TString &amp;name, const TIntermSequence *parameters)
</span><span class="cx"> {
</span><span class="cx">     if (name == &quot;&quot;)
</span><span class="lines">@@ -2621,30 +3552,32 @@
</span><span class="cx">     typedef std::vector&lt;TType&gt; ParameterArray;
</span><span class="cx">     ParameterArray ctorParameters;
</span><span class="cx"> 
</span><del>-    if (type.getStruct())
</del><ins>+    const TStructure* structure = type.getStruct();
+    if (structure)
</ins><span class="cx">     {
</span><span class="cx">         mStructNames.insert(decorate(name));
</span><span class="cx"> 
</span><del>-        TString structure;
-        structure += &quot;struct &quot; + decorate(name) + &quot;\n&quot;
-                     &quot;{\n&quot;;
</del><ins>+        const TString &amp;structString = structureString(*structure, false, false);
</ins><span class="cx"> 
</span><del>-        const TFieldList &amp;fields = type.getStruct()-&gt;fields();
-
-        for (unsigned int i = 0; i &lt; fields.size(); i++)
</del><ins>+        if (std::find(mStructDeclarations.begin(), mStructDeclarations.end(), structString) == mStructDeclarations.end())
</ins><span class="cx">         {
</span><del>-            const TField *field = fields[i];
</del><ins>+            // Add row-major packed struct for interface blocks
+            TString rowMajorString = &quot;#pragma pack_matrix(row_major)\n&quot; +
+                                     structureString(*structure, true, false) +
+                                     &quot;#pragma pack_matrix(column_major)\n&quot;;
</ins><span class="cx"> 
</span><del>-            structure += &quot;    &quot; + typeString(*field-&gt;type()) + &quot; &quot; + decorateField(field-&gt;name(), type) + arrayString(*field-&gt;type()) + &quot;;\n&quot;;
-        }
</del><ins>+            TString std140String = structureString(*structure, false, true);
+            TString std140RowMajorString = &quot;#pragma pack_matrix(row_major)\n&quot; +
+                                           structureString(*structure, true, true) +
+                                           &quot;#pragma pack_matrix(column_major)\n&quot;;
</ins><span class="cx"> 
</span><del>-        structure += &quot;};\n&quot;;
-
-        if (std::find(mStructDeclarations.begin(), mStructDeclarations.end(), structure) == mStructDeclarations.end())
-        {
-            mStructDeclarations.push_back(structure);
</del><ins>+            mStructDeclarations.push_back(structString);
+            mStructDeclarations.push_back(rowMajorString);
+            mStructDeclarations.push_back(std140String);
+            mStructDeclarations.push_back(std140RowMajorString);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        const TFieldList &amp;fields = structure-&gt;fields();
</ins><span class="cx">         for (unsigned int i = 0; i &lt; fields.size(); i++)
</span><span class="cx">         {
</span><span class="cx">             ctorParameters.push_back(*fields[i]-&gt;type());
</span><span class="lines">@@ -2696,18 +3629,19 @@
</span><span class="cx"> 
</span><span class="cx">     if (ctorType.isMatrix() &amp;&amp; ctorParameters.size() == 1)
</span><span class="cx">     {
</span><del>-        int dim = ctorType.getNominalSize();
</del><ins>+        int rows = ctorType.getRows();
+        int cols = ctorType.getCols();
</ins><span class="cx">         const TType &amp;parameter = ctorParameters[0];
</span><span class="cx"> 
</span><span class="cx">         if (parameter.isScalar())
</span><span class="cx">         {
</span><del>-            for (int row = 0; row &lt; dim; row++)
</del><ins>+            for (int row = 0; row &lt; rows; row++)
</ins><span class="cx">             {
</span><del>-                for (int col = 0; col &lt; dim; col++)
</del><ins>+                for (int col = 0; col &lt; cols; col++)
</ins><span class="cx">                 {
</span><span class="cx">                     constructor += TString((row == col) ? &quot;x0&quot; : &quot;0.0&quot;);
</span><span class="cx">                     
</span><del>-                    if (row &lt; dim - 1 || col &lt; dim - 1)
</del><ins>+                    if (row &lt; rows - 1 || col &lt; cols - 1)
</ins><span class="cx">                     {
</span><span class="cx">                         constructor += &quot;, &quot;;
</span><span class="cx">                     }
</span><span class="lines">@@ -2716,11 +3650,11 @@
</span><span class="cx">         }
</span><span class="cx">         else if (parameter.isMatrix())
</span><span class="cx">         {
</span><del>-            for (int row = 0; row &lt; dim; row++)
</del><ins>+            for (int row = 0; row &lt; rows; row++)
</ins><span class="cx">             {
</span><del>-                for (int col = 0; col &lt; dim; col++)
</del><ins>+                for (int col = 0; col &lt; cols; col++)
</ins><span class="cx">                 {
</span><del>-                    if (row &lt; parameter.getNominalSize() &amp;&amp; col &lt; parameter.getNominalSize())
</del><ins>+                    if (row &lt; parameter.getRows() &amp;&amp; col &lt; parameter.getCols())
</ins><span class="cx">                     {
</span><span class="cx">                         constructor += TString(&quot;x0&quot;) + &quot;[&quot; + str(row) + &quot;]&quot; + &quot;[&quot; + str(col) + &quot;]&quot;;
</span><span class="cx">                     }
</span><span class="lines">@@ -2729,7 +3663,7 @@
</span><span class="cx">                         constructor += TString((row == col) ? &quot;1.0&quot; : &quot;0.0&quot;);
</span><span class="cx">                     }
</span><span class="cx"> 
</span><del>-                    if (row &lt; dim - 1 || col &lt; dim - 1)
</del><ins>+                    if (row &lt; rows - 1 || col &lt; cols - 1)
</ins><span class="cx">                     {
</span><span class="cx">                         constructor += &quot;, &quot;;
</span><span class="cx">                     }
</span><span class="lines">@@ -2753,8 +3687,7 @@
</span><span class="cx"> 
</span><span class="cx">             if (parameter.isScalar())
</span><span class="cx">             {
</span><del>-                ASSERT(parameterSize &lt;= remainingComponents);
-                remainingComponents -= parameterSize;
</del><ins>+                remainingComponents -= parameter.getObjectSize();
</ins><span class="cx">             }
</span><span class="cx">             else if (parameter.isVector())
</span><span class="cx">             {
</span><span class="lines">@@ -2818,11 +3751,12 @@
</span><span class="cx"> {
</span><span class="cx">     TInfoSinkBase &amp;out = mBody;
</span><span class="cx"> 
</span><del>-    if (type.getBasicType() == EbtStruct)
</del><ins>+    const TStructure* structure = type.getStruct();
+    if (structure)
</ins><span class="cx">     {
</span><del>-        out &lt;&lt; structLookup(type.getStruct()-&gt;name()) + &quot;_ctor(&quot;;
</del><ins>+        out &lt;&lt; structLookup(structure-&gt;name()) + &quot;_ctor(&quot;;
</ins><span class="cx">         
</span><del>-        const TFieldList &amp;fields = type.getStruct()-&gt;fields();
</del><ins>+        const TFieldList&amp; fields = structure-&gt;fields();
</ins><span class="cx"> 
</span><span class="cx">         for (size_t i = 0; i &lt; fields.size(); i++)
</span><span class="cx">         {
</span><span class="lines">@@ -2854,6 +3788,7 @@
</span><span class="cx">             {
</span><span class="cx">               case EbtFloat: out &lt;&lt; std::min(FLT_MAX, std::max(-FLT_MAX, constUnion-&gt;getFConst())); break;
</span><span class="cx">               case EbtInt:   out &lt;&lt; constUnion-&gt;getIConst(); break;
</span><ins>+              case EbtUInt:  out &lt;&lt; constUnion-&gt;getUConst(); break;
</ins><span class="cx">               case EbtBool:  out &lt;&lt; constUnion-&gt;getBConst(); break;
</span><span class="cx">               default: UNREACHABLE();
</span><span class="cx">             }
</span><span class="lines">@@ -2935,9 +3870,9 @@
</span><span class="cx">     return decorate(string);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TString OutputHLSL::decorateField(const TString &amp;string, const TType &amp;structure)
</del><ins>+TString OutputHLSL::decorateField(const TString &amp;string, const TStructure &amp;structure)
</ins><span class="cx"> {
</span><del>-    if (structure.getStruct()-&gt;name().compare(0, 3, &quot;gl_&quot;) != 0)
</del><ins>+    if (structure.name().compare(0, 3, &quot;gl_&quot;) != 0)
</ins><span class="cx">     {
</span><span class="cx">         return decorate(string);
</span><span class="cx">     }
</span><span class="lines">@@ -2945,86 +3880,144 @@
</span><span class="cx">     return string;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TString OutputHLSL::registerString(TIntermSymbol *operand)
</del><ins>+void OutputHLSL::declareInterfaceBlockField(const TType &amp;type, const TString &amp;name, std::vector&lt;gl::InterfaceBlockField&gt;&amp; output)
</ins><span class="cx"> {
</span><del>-    ASSERT(operand-&gt;getQualifier() == EvqUniform);
</del><ins>+    const TStructure *structure = type.getStruct();
</ins><span class="cx"> 
</span><del>-    if (IsSampler(operand-&gt;getBasicType()))
</del><ins>+    if (!structure)
</ins><span class="cx">     {
</span><del>-        return &quot;s&quot; + str(samplerRegister(operand));
</del><ins>+        const bool isRowMajorMatrix = (type.isMatrix() &amp;&amp; type.getLayoutQualifier().matrixPacking == EmpRowMajor);
+        gl::InterfaceBlockField field(glVariableType(type), glVariablePrecision(type), name.c_str(),
+                                      (unsigned int)type.getArraySize(), isRowMajorMatrix);
+        output.push_back(field);
+   }
+    else
+    {
+        gl::InterfaceBlockField structField(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), false);
+
+        const TFieldList &amp;fields = structure-&gt;fields();
+
+        for (size_t fieldIndex = 0; fieldIndex &lt; fields.size(); fieldIndex++)
+        {
+            TField *field = fields[fieldIndex];
+            TType *fieldType = field-&gt;type();
+
+            // make sure to copy matrix packing information
+            fieldType-&gt;setLayoutQualifier(type.getLayoutQualifier());
+
+            declareInterfaceBlockField(*fieldType, field-&gt;name(), structField.fields);
+        }
+
+        output.push_back(structField);
</ins><span class="cx">     }
</span><del>-
-    return &quot;c&quot; + str(uniformRegister(operand));
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-int OutputHLSL::samplerRegister(TIntermSymbol *sampler)
</del><ins>+gl::Uniform OutputHLSL::declareUniformToList(const TType &amp;type, const TString &amp;name, int registerIndex, std::vector&lt;gl::Uniform&gt;&amp; output)
</ins><span class="cx"> {
</span><del>-    const TType &amp;type = sampler-&gt;getType();
-    ASSERT(IsSampler(type.getBasicType()));
</del><ins>+    const TStructure *structure = type.getStruct();
</ins><span class="cx"> 
</span><del>-    int index = mSamplerRegister;
-    mSamplerRegister += sampler-&gt;totalRegisterCount();
</del><ins>+    if (!structure)
+    {
+        gl::Uniform uniform(glVariableType(type), glVariablePrecision(type), name.c_str(),
+                            (unsigned int)type.getArraySize(), (unsigned int)registerIndex, 0);
+        output.push_back(uniform);
</ins><span class="cx"> 
</span><del>-    declareUniform(type, sampler-&gt;getSymbol(), index);
</del><ins>+        return uniform;
+   }
+    else
+    {
+        gl::Uniform structUniform(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(),
+                                  (unsigned int)registerIndex, GL_INVALID_INDEX);
</ins><span class="cx"> 
</span><del>-    return index;
</del><ins>+        const TFieldList &amp;fields = structure-&gt;fields();
+
+        for (size_t fieldIndex = 0; fieldIndex &lt; fields.size(); fieldIndex++)
+        {
+            TField *field = fields[fieldIndex];
+            TType *fieldType = field-&gt;type();
+
+            declareUniformToList(*fieldType, field-&gt;name(), GL_INVALID_INDEX, structUniform.fields);
+        }
+
+        // assign register offset information -- this will override the information in any sub-structures.
+        HLSLVariableGetRegisterInfo(registerIndex, &amp;structUniform);
+
+        output.push_back(structUniform);
+
+        return structUniform;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int OutputHLSL::uniformRegister(TIntermSymbol *uniform)
</del><ins>+gl::InterpolationType getInterpolationType(TQualifier qualifier)
</ins><span class="cx"> {
</span><del>-    const TType &amp;type = uniform-&gt;getType();
-    ASSERT(!IsSampler(type.getBasicType()));
</del><ins>+    switch (qualifier)
+    {
+      case EvqFlatIn:
+      case EvqFlatOut:
+        return gl::INTERPOLATION_FLAT;
</ins><span class="cx"> 
</span><del>-    int index = mUniformRegister;
-    mUniformRegister += uniform-&gt;totalRegisterCount();
</del><ins>+      case EvqSmoothIn:
+      case EvqSmoothOut:
+      case EvqVertexOut:
+      case EvqFragmentIn:
+      case EvqVaryingIn:
+      case EvqVaryingOut:
+        return gl::INTERPOLATION_SMOOTH;
</ins><span class="cx"> 
</span><del>-    declareUniform(type, uniform-&gt;getSymbol(), index);
</del><ins>+      case EvqCentroidIn:
+      case EvqCentroidOut:
+        return gl::INTERPOLATION_CENTROID;
</ins><span class="cx"> 
</span><del>-    return index;
</del><ins>+      default: UNREACHABLE();
+        return gl::INTERPOLATION_SMOOTH;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void OutputHLSL::declareUniform(const TType &amp;type, const TString &amp;name, int index)
</del><ins>+void OutputHLSL::declareVaryingToList(const TType &amp;type, TQualifier baseTypeQualifier, const TString &amp;name, std::vector&lt;gl::Varying&gt;&amp; fieldsOut)
</ins><span class="cx"> {
</span><del>-    TStructure *structure = type.getStruct();
</del><ins>+    const TStructure *structure = type.getStruct();
</ins><span class="cx"> 
</span><ins>+    gl::InterpolationType interpolation = getInterpolationType(baseTypeQualifier);
</ins><span class="cx">     if (!structure)
</span><span class="cx">     {
</span><del>-        mActiveUniforms.push_back(Uniform(glVariableType(type), glVariablePrecision(type), name.c_str(), type.getArraySize(), index));
</del><ins>+        gl::Varying varying(glVariableType(type), glVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), interpolation);
+        fieldsOut.push_back(varying);
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><ins>+        gl::Varying structVarying(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), interpolation);
</ins><span class="cx">         const TFieldList &amp;fields = structure-&gt;fields();
</span><span class="cx"> 
</span><del>-        if (type.isArray())
</del><ins>+        structVarying.structName = structure-&gt;name().c_str();
+
+        for (size_t fieldIndex = 0; fieldIndex &lt; fields.size(); fieldIndex++)
</ins><span class="cx">         {
</span><del>-            int elementIndex = index;
-
-            for (int i = 0; i &lt; type.getArraySize(); i++)
-            {
-                for (size_t j = 0; j &lt; fields.size(); j++)
-                {
-                    const TType &amp;fieldType = *fields[j]-&gt;type();
-                    const TString uniformName = name + &quot;[&quot; + str(i) + &quot;].&quot; + fields[j]-&gt;name();
-                    declareUniform(fieldType, uniformName, elementIndex);
-                    elementIndex += fieldType.totalRegisterCount();
-                }
-            }
</del><ins>+            const TField &amp;field = *fields[fieldIndex];
+            declareVaryingToList(*field.type(), baseTypeQualifier, field.name(), structVarying.fields);
</ins><span class="cx">         }
</span><del>-        else
-        {
-            int fieldIndex = index;
</del><span class="cx"> 
</span><del>-            for (size_t i = 0; i &lt; fields.size(); i++)
-            {
-                const TType &amp;fieldType = *fields[i]-&gt;type();
-                const TString uniformName = name + &quot;.&quot; + fields[i]-&gt;name();
-                declareUniform(fieldType, uniformName, fieldIndex);
-                fieldIndex += fieldType.totalRegisterCount();
-            }
-        }
</del><ins>+        fieldsOut.push_back(structVarying);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int OutputHLSL::declareUniformAndAssignRegister(const TType &amp;type, const TString &amp;name)
+{
+    int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister);
+
+    const gl::Uniform &amp;uniform = declareUniformToList(type, name, registerIndex, mActiveUniforms);
+
+    if (IsSampler(type.getBasicType()))
+    {
+        mSamplerRegister += gl::HLSLVariableRegisterCount(uniform);
+    }
+    else
+    {
+        mUniformRegister += gl::HLSLVariableRegisterCount(uniform);
+    }
+
+    return registerIndex;
+}
+
</ins><span class="cx"> GLenum OutputHLSL::glVariableType(const TType &amp;type)
</span><span class="cx"> {
</span><span class="cx">     if (type.getBasicType() == EbtFloat)
</span><span class="lines">@@ -3045,11 +4038,35 @@
</span><span class="cx">         }
</span><span class="cx">         else if (type.isMatrix())
</span><span class="cx">         {
</span><del>-            switch(type.getNominalSize())
</del><ins>+            switch (type.getCols())
</ins><span class="cx">             {
</span><del>-              case 2: return GL_FLOAT_MAT2;
-              case 3: return GL_FLOAT_MAT3;
-              case 4: return GL_FLOAT_MAT4;
</del><ins>+              case 2:
+                switch(type.getRows())
+                {
+                  case 2: return GL_FLOAT_MAT2;
+                  case 3: return GL_FLOAT_MAT2x3;
+                  case 4: return GL_FLOAT_MAT2x4;
+                  default: UNREACHABLE();
+                }
+
+              case 3:
+                switch(type.getRows())
+                {
+                  case 2: return GL_FLOAT_MAT3x2;
+                  case 3: return GL_FLOAT_MAT3;
+                  case 4: return GL_FLOAT_MAT3x4;
+                  default: UNREACHABLE();
+                }
+
+              case 4:
+                switch(type.getRows())
+                {
+                  case 2: return GL_FLOAT_MAT4x2;
+                  case 3: return GL_FLOAT_MAT4x3;
+                  case 4: return GL_FLOAT_MAT4;
+                  default: UNREACHABLE();
+                }
+
</ins><span class="cx">               default: UNREACHABLE();
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -3073,6 +4090,24 @@
</span><span class="cx">         }
</span><span class="cx">         else UNREACHABLE();
</span><span class="cx">     }
</span><ins>+    else if (type.getBasicType() == EbtUInt)
+    {
+        if (type.isScalar())
+        {
+            return GL_UNSIGNED_INT;
+        }
+        else if (type.isVector())
+        {
+            switch(type.getNominalSize())
+            {
+              case 2: return GL_UNSIGNED_INT_VEC2;
+              case 3: return GL_UNSIGNED_INT_VEC3;
+              case 4: return GL_UNSIGNED_INT_VEC4;
+              default: UNREACHABLE();
+            }
+        }
+        else UNREACHABLE();
+    }
</ins><span class="cx">     else if (type.getBasicType() == EbtBool)
</span><span class="cx">     {
</span><span class="cx">         if (type.isScalar())
</span><span class="lines">@@ -3091,15 +4126,26 @@
</span><span class="cx">         }
</span><span class="cx">         else UNREACHABLE();
</span><span class="cx">     }
</span><del>-    else if (type.getBasicType() == EbtSampler2D)
</del><ins>+
+    switch(type.getBasicType())
</ins><span class="cx">     {
</span><del>-        return GL_SAMPLER_2D;
</del><ins>+      case EbtSampler2D:            return GL_SAMPLER_2D;
+      case EbtSampler3D:            return GL_SAMPLER_3D;
+      case EbtSamplerCube:          return GL_SAMPLER_CUBE;
+      case EbtSampler2DArray:       return GL_SAMPLER_2D_ARRAY;
+      case EbtISampler2D:           return GL_INT_SAMPLER_2D;
+      case EbtISampler3D:           return GL_INT_SAMPLER_3D;
+      case EbtISamplerCube:         return GL_INT_SAMPLER_CUBE;
+      case EbtISampler2DArray:      return GL_INT_SAMPLER_2D_ARRAY;
+      case EbtUSampler2D:           return GL_UNSIGNED_INT_SAMPLER_2D;
+      case EbtUSampler3D:           return GL_UNSIGNED_INT_SAMPLER_3D;
+      case EbtUSamplerCube:         return GL_UNSIGNED_INT_SAMPLER_CUBE;
+      case EbtUSampler2DArray:      return GL_UNSIGNED_INT_SAMPLER_2D_ARRAY;
+      case EbtSampler2DShadow:      return GL_SAMPLER_2D_SHADOW;
+      case EbtSamplerCubeShadow:    return GL_SAMPLER_CUBE_SHADOW;
+      case EbtSampler2DArrayShadow: return GL_SAMPLER_2D_ARRAY_SHADOW;
+      default: UNREACHABLE();
</ins><span class="cx">     }
</span><del>-    else if (type.getBasicType() == EbtSamplerCube)
-    {
-        return GL_SAMPLER_CUBE;
-    }
-    else UNREACHABLE();
</del><span class="cx"> 
</span><span class="cx">     return GL_NONE;
</span><span class="cx"> }
</span><span class="lines">@@ -3118,7 +4164,7 @@
</span><span class="cx">           default: UNREACHABLE();
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else if (type.getBasicType() == EbtInt)
</del><ins>+    else if (type.getBasicType() == EbtInt || type.getBasicType() == EbtUInt)
</ins><span class="cx">     {
</span><span class="cx">         switch (type.getPrecision())
</span><span class="cx">         {
</span><span class="lines">@@ -3135,4 +4181,45 @@
</span><span class="cx">     return GL_NONE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool OutputHLSL::isVaryingOut(TQualifier qualifier)
+{
+    switch(qualifier)
+    {
+      case EvqVaryingOut:
+      case EvqInvariantVaryingOut:
+      case EvqSmoothOut:
+      case EvqFlatOut:
+      case EvqCentroidOut:
+      case EvqVertexOut:
+        return true;
+
+      default: break;
+    }
+
+    return false;
</ins><span class="cx"> }
</span><ins>+
+bool OutputHLSL::isVaryingIn(TQualifier qualifier)
+{
+    switch(qualifier)
+    {
+      case EvqVaryingIn:
+      case EvqInvariantVaryingIn:
+      case EvqSmoothIn:
+      case EvqFlatIn:
+      case EvqCentroidIn:
+      case EvqFragmentIn:
+        return true;
+
+      default: break;
+    }
+
+    return false;
+}
+
+bool OutputHLSL::isVarying(TQualifier qualifier)
+{
+    return isVaryingIn(qualifier) || isVaryingOut(qualifier);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorOutputHLSLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputHLSL.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputHLSL.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/OutputHLSL.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -12,11 +12,12 @@
</span><span class="cx"> #include &lt;map&gt;
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/ParseContext.h&quot;
</span><del>-#include &quot;compiler/translator/Uniform.h&quot;
</del><ins>+#include &quot;common/shadervars.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace sh
</span><span class="cx"> {
</span><span class="lines">@@ -31,16 +32,24 @@
</span><span class="cx">     void output();
</span><span class="cx"> 
</span><span class="cx">     TInfoSinkBase &amp;getBodyStream();
</span><del>-    const ActiveUniforms &amp;getUniforms();
</del><ins>+    const std::vector&lt;gl::Uniform&gt; &amp;getUniforms();
+    const std::vector&lt;gl::InterfaceBlock&gt; &amp;getInterfaceBlocks() const;
+    const std::vector&lt;gl::Attribute&gt; &amp;getOutputVariables() const;
+    const std::vector&lt;gl::Attribute&gt; &amp;getAttributes() const;
+    const std::vector&lt;gl::Varying&gt; &amp;getVaryings() const;
</ins><span class="cx"> 
</span><span class="cx">     TString typeString(const TType &amp;type);
</span><span class="cx">     TString textureString(const TType &amp;type);
</span><ins>+    TString samplerString(const TType &amp;type);
+    TString interpolationString(TQualifier qualifier);
+    TString structureString(const TStructure &amp;structure, bool useHLSLRowMajorPacking, bool useStd140Packing);
+    TString structureTypeName(const TStructure &amp;structure, bool useHLSLRowMajorPacking, bool useStd140Packing);
</ins><span class="cx">     static TString qualifierString(TQualifier qualifier);
</span><span class="cx">     static TString arrayString(const TType &amp;type);
</span><span class="cx">     static TString initializer(const TType &amp;type);
</span><span class="cx">     static TString decorate(const TString &amp;string);                      // Prepends an underscore to avoid naming clashes
</span><span class="cx">     static TString decorateUniform(const TString &amp;string, const TType &amp;type);
</span><del>-    static TString decorateField(const TString &amp;string, const TType &amp;structure);
</del><ins>+    static TString decorateField(const TString &amp;string, const TStructure &amp;structure);
</ins><span class="cx"> 
</span><span class="cx">   protected:
</span><span class="cx">     void header();
</span><span class="lines">@@ -82,25 +91,40 @@
</span><span class="cx"> 
</span><span class="cx">     typedef std::map&lt;TString, TIntermSymbol*&gt; ReferencedSymbols;
</span><span class="cx">     ReferencedSymbols mReferencedUniforms;
</span><ins>+    ReferencedSymbols mReferencedInterfaceBlocks;
</ins><span class="cx">     ReferencedSymbols mReferencedAttributes;
</span><span class="cx">     ReferencedSymbols mReferencedVaryings;
</span><ins>+    ReferencedSymbols mReferencedOutputVariables;
</ins><span class="cx"> 
</span><ins>+    struct TextureFunction
+    {
+        enum Method
+        {
+            IMPLICIT,   // Mipmap LOD determined implicitly (standard lookup)
+            BIAS,
+            LOD,
+            LOD0,
+            LOD0BIAS,
+            SIZE,   // textureSize()
+            FETCH,
+            GRAD
+        };
+
+        TBasicType sampler;
+        int coords;
+        bool proj;
+        bool offset;
+        Method method;
+
+        TString name() const;
+
+        bool operator&lt;(const TextureFunction &amp;rhs) const;
+    };
+
+    typedef std::set&lt;TextureFunction&gt; TextureFunctionSet;
+
</ins><span class="cx">     // Parameters determining what goes in the header output
</span><del>-    bool mUsesTexture2D;
-    bool mUsesTexture2D_bias;
-    bool mUsesTexture2DLod;
-    bool mUsesTexture2DProj;
-    bool mUsesTexture2DProj_bias;
-    bool mUsesTexture2DProjLod;
-    bool mUsesTextureCube;
-    bool mUsesTextureCube_bias;
-    bool mUsesTextureCubeLod;
-    bool mUsesTexture2DLod0;
-    bool mUsesTexture2DLod0_bias;
-    bool mUsesTexture2DProjLod0;
-    bool mUsesTexture2DProjLod0_bias;
-    bool mUsesTextureCubeLod0;
-    bool mUsesTextureCubeLod0_bias;
</del><ins>+    TextureFunctionSet mUsesTexture;
</ins><span class="cx">     bool mUsesFragColor;
</span><span class="cx">     bool mUsesFragData;
</span><span class="cx">     bool mUsesDepthRange;
</span><span class="lines">@@ -126,6 +150,7 @@
</span><span class="cx">     bool mUsesAtan2_3;
</span><span class="cx">     bool mUsesAtan2_4;
</span><span class="cx">     bool mUsesDiscardRewriting;
</span><ins>+    bool mUsesNestedBreak;
</ins><span class="cx"> 
</span><span class="cx">     int mNumRenderTargets;
</span><span class="cx"> 
</span><span class="lines">@@ -147,20 +172,54 @@
</span><span class="cx">     bool mContainsLoopDiscontinuity;
</span><span class="cx">     bool mOutputLod0Function;
</span><span class="cx">     bool mInsideDiscontinuousLoop;
</span><ins>+    int mNestedLoopDepth;
</ins><span class="cx"> 
</span><span class="cx">     TIntermSymbol *mExcessiveLoopIndex;
</span><span class="cx"> 
</span><span class="cx">     int mUniformRegister;
</span><ins>+    int mInterfaceBlockRegister;
</ins><span class="cx">     int mSamplerRegister;
</span><ins>+    int mPaddingCounter;
</ins><span class="cx"> 
</span><span class="cx">     TString registerString(TIntermSymbol *operand);
</span><span class="cx">     int samplerRegister(TIntermSymbol *sampler);
</span><span class="cx">     int uniformRegister(TIntermSymbol *uniform);
</span><ins>+    void declareInterfaceBlockField(const TType &amp;type, const TString &amp;name, std::vector&lt;gl::InterfaceBlockField&gt;&amp; output);
+    gl::Uniform declareUniformToList(const TType &amp;type, const TString &amp;name, int registerIndex, std::vector&lt;gl::Uniform&gt;&amp; output);
</ins><span class="cx">     void declareUniform(const TType &amp;type, const TString &amp;name, int index);
</span><ins>+    void declareVaryingToList(const TType &amp;type, TQualifier baseTypeQualifier, const TString &amp;name, std::vector&lt;gl::Varying&gt;&amp; fieldsOut);
+
+    // Returns the uniform's register index
+    int declareUniformAndAssignRegister(const TType &amp;type, const TString &amp;name);
+
+    TString interfaceBlockFieldString(const TInterfaceBlock &amp;interfaceBlock, const TField &amp;field);
+    TString decoratePrivate(const TString &amp;privateText);
+    TString interfaceBlockStructNameString(const TInterfaceBlock &amp;interfaceBlockType);
+    TString interfaceBlockInstanceString(const TInterfaceBlock&amp; interfaceBlock, unsigned int arrayIndex);
+    TString interfaceBlockFieldTypeString(const TField &amp;field, TLayoutBlockStorage blockStorage);
+    TString interfaceBlockFieldString(const TInterfaceBlock &amp;interfaceBlock, TLayoutBlockStorage blockStorage);
+    TString interfaceBlockStructString(const TInterfaceBlock &amp;interfaceBlock);
+    TString interfaceBlockString(const TInterfaceBlock &amp;interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex);
+    TString std140PrePaddingString(const TType &amp;type, int *elementIndex);
+    TString std140PostPaddingString(const TType &amp;type, bool useHLSLRowMajorPacking);
+    TString structInitializerString(int indent, const TStructure &amp;structure, const TString &amp;rhsStructName);
+    
</ins><span class="cx">     static GLenum glVariableType(const TType &amp;type);
</span><span class="cx">     static GLenum glVariablePrecision(const TType &amp;type);
</span><ins>+    static bool isVaryingIn(TQualifier qualifier);
+    static bool isVaryingOut(TQualifier qualifier);
+    static bool isVarying(TQualifier qualifier);
</ins><span class="cx"> 
</span><del>-    ActiveUniforms mActiveUniforms;
</del><ins>+    std::vector&lt;gl::Uniform&gt; mActiveUniforms;
+    std::vector&lt;gl::InterfaceBlock&gt; mActiveInterfaceBlocks;
+    std::vector&lt;gl::Attribute&gt; mActiveOutputVariables;
+    std::vector&lt;gl::Attribute&gt; mActiveAttributes;
+    std::vector&lt;gl::Varying&gt; mActiveVaryings;
+    std::map&lt;TString, int&gt; mStd140StructElementIndexes;
+    std::map&lt;TIntermTyped*, TString&gt; mFlaggedStructMappedNames;
+    std::map&lt;TIntermTyped*, TString&gt; mFlaggedStructOriginalNames;
+
+    void makeFlaggedStructMaps(const std::vector&lt;TIntermTyped *&gt; &amp;flaggedStructs);
</ins><span class="cx"> };
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorParseContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ParseContext.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ParseContext.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ParseContext.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -115,7 +115,7 @@
</span><span class="cx"> // Look at a '.' field selector string and change it into offsets
</span><span class="cx"> // for a matrix.
</span><span class="cx"> //
</span><del>-bool TParseContext::parseMatrixFields(const TString&amp; compString, int matSize, TMatrixFields&amp; fields, const TSourceLoc&amp; line)
</del><ins>+bool TParseContext::parseMatrixFields(const TString&amp; compString, int matCols, int matRows, TMatrixFields&amp; fields, const TSourceLoc&amp; line)
</ins><span class="cx"> {
</span><span class="cx">     fields.wholeRow = false;
</span><span class="cx">     fields.wholeCol = false;
</span><span class="lines">@@ -151,7 +151,7 @@
</span><span class="cx">         fields.col = compString[1] - '0';
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (fields.row &gt;= matSize || fields.col &gt;= matSize) {
</del><ins>+    if (fields.row &gt;= matRows || fields.col &gt;= matCols) {
</ins><span class="cx">         error(line, &quot;matrix field selection out of range&quot;, compString.c_str());
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -277,6 +277,7 @@
</span><span class="cx">         case EOpIndexDirect:
</span><span class="cx">         case EOpIndexIndirect:
</span><span class="cx">         case EOpIndexDirectStruct:
</span><ins>+        case EOpIndexDirectInterfaceBlock:
</ins><span class="cx">             return lValueErrorCheck(line, op, binaryNode-&gt;getLeft());
</span><span class="cx">         case EOpVectorSwizzle:
</span><span class="cx">             errorReturn = lValueErrorCheck(line, op, binaryNode-&gt;getLeft());
</span><span class="lines">@@ -317,6 +318,8 @@
</span><span class="cx">     case EvqConst:          message = &quot;can't modify a const&quot;;        break;
</span><span class="cx">     case EvqConstReadOnly:  message = &quot;can't modify a const&quot;;        break;
</span><span class="cx">     case EvqAttribute:      message = &quot;can't modify an attribute&quot;;   break;
</span><ins>+    case EvqFragmentIn:     message = &quot;can't modify an input&quot;;       break;
+    case EvqVertexIn:       message = &quot;can't modify an input&quot;;       break;
</ins><span class="cx">     case EvqUniform:        message = &quot;can't modify a uniform&quot;;      break;
</span><span class="cx">     case EvqVaryingIn:      message = &quot;can't modify a varying&quot;;      break;
</span><span class="cx">     case EvqFragCoord:      message = &quot;can't modify gl_FragCoord&quot;;   break;
</span><span class="lines">@@ -327,17 +330,12 @@
</span><span class="cx">         //
</span><span class="cx">         // Type that can't be written to?
</span><span class="cx">         //
</span><del>-        switch (node-&gt;getBasicType()) {
-        case EbtSampler2D:
-        case EbtSamplerCube:
-            message = &quot;can't modify a sampler&quot;;
-            break;
-        case EbtVoid:
</del><ins>+        if (node-&gt;getBasicType() == EbtVoid) {
</ins><span class="cx">             message = &quot;can't modify void&quot;;
</span><del>-            break;
-        default: 
-            break;
</del><span class="cx">         }
</span><ins>+        if (IsSampler(node-&gt;getBasicType())) {
+            message = &quot;can't modify a sampler&quot;;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (message == 0 &amp;&amp; binaryNode == 0 &amp;&amp; symNode == 0) {
</span><span class="lines">@@ -396,7 +394,7 @@
</span><span class="cx"> //
</span><span class="cx"> bool TParseContext::integerErrorCheck(TIntermTyped* node, const char* token)
</span><span class="cx"> {
</span><del>-    if (node-&gt;getBasicType() == EbtInt &amp;&amp; node-&gt;getNominalSize() == 1)
</del><ins>+    if (node-&gt;isScalarInt())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     error(node-&gt;getLine(), &quot;integer expression required&quot;, token);
</span><span class="lines">@@ -437,7 +435,7 @@
</span><span class="cx">             error(line, reservedErrMsg, &quot;gl_&quot;);
</span><span class="cx">             return true;
</span><span class="cx">         }
</span><del>-        if (isWebGLBasedSpec(shaderSpec)) {
</del><ins>+        if (IsWebGLBasedSpec(shaderSpec)) {
</ins><span class="cx">             if (identifier.compare(0, 6, &quot;webgl_&quot;) == 0) {
</span><span class="cx">                 error(line, reservedErrMsg, &quot;webgl_&quot;);
</span><span class="cx">                 return true;
</span><span class="lines">@@ -599,7 +597,7 @@
</span><span class="cx"> //
</span><span class="cx"> bool TParseContext::boolErrorCheck(const TSourceLoc&amp; line, const TPublicType&amp; pType)
</span><span class="cx"> {
</span><del>-    if (pType.type != EbtBool || pType.array || pType.matrix || (pType.size &gt; 1)) {
</del><ins>+    if (pType.type != EbtBool || pType.isAggregate()) {
</ins><span class="cx">         error(line, &quot;boolean expression expected&quot;, &quot;&quot;);
</span><span class="cx">         return true;
</span><span class="cx">     } 
</span><span class="lines">@@ -628,11 +626,20 @@
</span><span class="cx"> 
</span><span class="cx"> bool TParseContext::structQualifierErrorCheck(const TSourceLoc&amp; line, const TPublicType&amp; pType)
</span><span class="cx"> {
</span><del>-    if ((pType.qualifier == EvqVaryingIn || pType.qualifier == EvqVaryingOut || pType.qualifier == EvqAttribute) &amp;&amp;
-        pType.type == EbtStruct) {
-        error(line, &quot;cannot be used with a structure&quot;, getQualifierString(pType.qualifier));
-        
-        return true;
</del><ins>+    switch (pType.qualifier)
+    {
+      case EvqVaryingIn:
+      case EvqVaryingOut:
+      case EvqAttribute:
+      case EvqVertexIn:
+      case EvqFragmentOut:
+        if (pType.type == EbtStruct)
+        {
+            error(line, &quot;cannot be used with a structure&quot;, getQualifierString(pType.qualifier));
+            return true;
+        }
+
+      default: break;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (pType.qualifier != EvqUniform &amp;&amp; samplerErrorCheck(line, pType, &quot;samplers must be uniform&quot;))
</span><span class="lines">@@ -641,6 +648,17 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TParseContext::locationDeclaratorListCheck(const TSourceLoc&amp; line, const TPublicType &amp;pType)
+{
+    if (pType.layoutQualifier.location != -1)
+    {
+        error(line, &quot;location must only be specified for a single input or output variable&quot;, &quot;location&quot;);
+        return true;
+    }
+
+    return false;
+}
+
</ins><span class="cx"> bool TParseContext::parameterSamplerErrorCheck(const TSourceLoc&amp; line, TQualifier qualifier, const TType&amp; type)
</span><span class="cx"> {
</span><span class="cx">     if ((qualifier == EvqOut || qualifier == EvqInOut) &amp;&amp; 
</span><span class="lines">@@ -657,7 +675,7 @@
</span><span class="cx">     if (IsSampler(type.getBasicType()))
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    if (type.getBasicType() == EbtStruct) {
</del><ins>+    if (type.getBasicType() == EbtStruct || type.isInterfaceBlock()) {
</ins><span class="cx">         const TFieldList&amp; fields = type.getStruct()-&gt;fields();
</span><span class="cx">         for (unsigned int i = 0; i &lt; fields.size(); ++i) {
</span><span class="cx">             if (containsSampler(*fields[i]-&gt;type()))
</span><span class="lines">@@ -676,19 +694,37 @@
</span><span class="cx"> bool TParseContext::arraySizeErrorCheck(const TSourceLoc&amp; line, TIntermTyped* expr, int&amp; size)
</span><span class="cx"> {
</span><span class="cx">     TIntermConstantUnion* constant = expr-&gt;getAsConstantUnion();
</span><del>-    if (constant == 0 || constant-&gt;getBasicType() != EbtInt) {
</del><ins>+
+    if (constant == 0 || !constant-&gt;isScalarInt())
+    {
</ins><span class="cx">         error(line, &quot;array size must be a constant integer expression&quot;, &quot;&quot;);
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    size = constant-&gt;getIConst(0);
</del><ins>+    if (constant-&gt;getBasicType() == EbtUInt)
+    {
+        unsigned int uintSize = constant-&gt;getUConst(0);
+        if (uintSize &gt; static_cast&lt;unsigned int&gt;(std::numeric_limits&lt;int&gt;::max()))
+        {
+            error(line, &quot;array size too large&quot;, &quot;&quot;);
+            size = 1;
+            return true;
+        }
</ins><span class="cx"> 
</span><del>-    if (size &lt;= 0) {
-        error(line, &quot;array size must be a positive integer&quot;, &quot;&quot;);
-        size = 1;
-        return true;
</del><ins>+        size = static_cast&lt;int&gt;(uintSize);
</ins><span class="cx">     }
</span><ins>+    else
+    {
+        size = constant-&gt;getIConst(0);
</ins><span class="cx"> 
</span><ins>+        if (size &lt;= 0)
+        {
+            error(line, &quot;array size must be a positive integer&quot;, &quot;&quot;);
+            size = 1;
+            return true;
+        }
+    }
+
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -699,7 +735,7 @@
</span><span class="cx"> //
</span><span class="cx"> bool TParseContext::arrayQualifierErrorCheck(const TSourceLoc&amp; line, TPublicType type)
</span><span class="cx"> {
</span><del>-    if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqConst)) {
</del><ins>+    if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqVertexIn) || (type.qualifier == EvqConst)) {
</ins><span class="cx">         error(line, &quot;cannot declare arrays of this qualifier&quot;, TType(type).getCompleteString().c_str());
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -733,7 +769,7 @@
</span><span class="cx"> //
</span><span class="cx"> // Returns true if there was an error.
</span><span class="cx"> //
</span><del>-bool TParseContext::arrayErrorCheck(const TSourceLoc&amp; line, TString&amp; identifier, TPublicType type, TVariable*&amp; variable)
</del><ins>+bool TParseContext::arrayErrorCheck(const TSourceLoc&amp; line, const TString&amp; identifier, const TPublicType &amp;type, TVariable*&amp; variable)
</ins><span class="cx"> {
</span><span class="cx">     //
</span><span class="cx">     // Don't check for reserved word use until after we know it's not in the symbol table,
</span><span class="lines">@@ -742,7 +778,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool builtIn = false; 
</span><span class="cx">     bool sameScope = false;
</span><del>-    TSymbol* symbol = symbolTable.find(identifier, &amp;builtIn, &amp;sameScope);
</del><ins>+    TSymbol* symbol = symbolTable.find(identifier, 0, &amp;builtIn, &amp;sameScope);
</ins><span class="cx">     if (symbol == 0 || !sameScope) {
</span><span class="cx">         if (reservedErrorCheck(line, identifier))
</span><span class="cx">             return true;
</span><span class="lines">@@ -752,7 +788,7 @@
</span><span class="cx">         if (type.arraySize)
</span><span class="cx">             variable-&gt;getType().setArraySize(type.arraySize);
</span><span class="cx"> 
</span><del>-        if (! symbolTable.insert(*variable)) {
</del><ins>+        if (! symbolTable.declare(*variable)) {
</ins><span class="cx">             delete variable;
</span><span class="cx">             error(line, &quot;INTERNAL ERROR inserting new symbol&quot;, identifier.c_str());
</span><span class="cx">             return true;
</span><span class="lines">@@ -793,7 +829,7 @@
</span><span class="cx"> //
</span><span class="cx"> // Returns true if there was an error.
</span><span class="cx"> //
</span><del>-bool TParseContext::nonInitConstErrorCheck(const TSourceLoc&amp; line, TString&amp; identifier, TPublicType&amp; type, bool array)
</del><ins>+bool TParseContext::nonInitConstErrorCheck(const TSourceLoc&amp; line, const TString&amp; identifier, TPublicType&amp; type, bool array)
</ins><span class="cx"> {
</span><span class="cx">     if (type.qualifier == EvqConst)
</span><span class="cx">     {
</span><span class="lines">@@ -825,14 +861,14 @@
</span><span class="cx"> //
</span><span class="cx"> // Returns true if there was an error.
</span><span class="cx"> //
</span><del>-bool TParseContext::nonInitErrorCheck(const TSourceLoc&amp; line, TString&amp; identifier, TPublicType&amp; type, TVariable*&amp; variable)
</del><ins>+bool TParseContext::nonInitErrorCheck(const TSourceLoc&amp; line, const TString&amp; identifier, const TPublicType&amp; type, TVariable*&amp; variable)
</ins><span class="cx"> {
</span><span class="cx">     if (reservedErrorCheck(line, identifier))
</span><span class="cx">         recover();
</span><span class="cx"> 
</span><span class="cx">     variable = new TVariable(&amp;identifier, TType(type));
</span><span class="cx"> 
</span><del>-    if (! symbolTable.insert(*variable)) {
</del><ins>+    if (! symbolTable.declare(*variable)) {
</ins><span class="cx">         error(line, &quot;redefinition&quot;, variable-&gt;getName().c_str());
</span><span class="cx">         delete variable;
</span><span class="cx">         variable = 0;
</span><span class="lines">@@ -885,6 +921,45 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TParseContext::singleDeclarationErrorCheck(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier)
+{
+    if (structQualifierErrorCheck(identifierLocation, publicType))
+        return true;
+
+    // check for layout qualifier issues
+    const TLayoutQualifier layoutQualifier = publicType.layoutQualifier;
+
+    if (layoutQualifier.matrixPacking != EmpUnspecified)
+    {
+        error(identifierLocation, &quot;layout qualifier&quot;, getMatrixPackingString(layoutQualifier.matrixPacking), &quot;only valid for interface blocks&quot;);
+        return true;
+    }
+
+    if (layoutQualifier.blockStorage != EbsUnspecified)
+    {
+        error(identifierLocation, &quot;layout qualifier&quot;, getBlockStorageString(layoutQualifier.blockStorage), &quot;only valid for interface blocks&quot;);
+        return true;
+    }
+
+    if (publicType.qualifier != EvqVertexIn &amp;&amp; publicType.qualifier != EvqFragmentOut &amp;&amp; layoutLocationErrorCheck(identifierLocation, publicType.layoutQualifier))
+    {
+        return true;
+    }
+
+    return false;
+}
+
+bool TParseContext::layoutLocationErrorCheck(const TSourceLoc&amp; location, const TLayoutQualifier &amp;layoutQualifier)
+{
+    if (layoutQualifier.location != -1)
+    {
+        error(location, &quot;invalid layout qualifier:&quot;, &quot;location&quot;, &quot;only valid on program inputs and outputs&quot;);
+        return true;
+    }
+
+    return false;
+}
+
</ins><span class="cx"> bool TParseContext::supportsExtension(const char* extension)
</span><span class="cx"> {
</span><span class="cx">     const TExtensionBehavior&amp; extbehavior = extensionBehavior();
</span><span class="lines">@@ -905,6 +980,22 @@
</span><span class="cx">     return (iter-&gt;second == EBhEnable || iter-&gt;second == EBhRequire);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TParseContext::handleExtensionDirective(const TSourceLoc&amp; loc, const char* extName, const char* behavior)
+{
+    pp::SourceLocation srcLoc;
+    srcLoc.file = loc.first_file;
+    srcLoc.line = loc.first_line;
+    directiveHandler.handleExtension(srcLoc, extName, behavior);
+}
+
+void TParseContext::handlePragmaDirective(const TSourceLoc&amp; loc, const char* name, const char* value)
+{
+    pp::SourceLocation srcLoc;
+    srcLoc.file = loc.first_file;
+    srcLoc.line = loc.first_line;
+    directiveHandler.handlePragma(srcLoc, name, value);
+}
+
</ins><span class="cx"> /////////////////////////////////////////////////////////////////////////////////
</span><span class="cx"> //
</span><span class="cx"> // Non-Errors.
</span><span class="lines">@@ -916,14 +1007,14 @@
</span><span class="cx"> //
</span><span class="cx"> // Return the function symbol if found, otherwise 0.
</span><span class="cx"> //
</span><del>-const TFunction* TParseContext::findFunction(const TSourceLoc&amp; line, TFunction* call, bool *builtIn)
</del><ins>+const TFunction* TParseContext::findFunction(const TSourceLoc&amp; line, TFunction* call, int shaderVersion, bool *builtIn)
</ins><span class="cx"> {
</span><span class="cx">     // First find by unmangled name to check whether the function name has been
</span><span class="cx">     // hidden by a variable name or struct typename.
</span><span class="cx">     // If a function is found, check for one with a matching argument list.
</span><del>-    const TSymbol* symbol = symbolTable.find(call-&gt;getName(), builtIn);
</del><ins>+    const TSymbol* symbol = symbolTable.find(call-&gt;getName(), shaderVersion, builtIn);
</ins><span class="cx">     if (symbol == 0 || symbol-&gt;isFunction()) {
</span><del>-        symbol = symbolTable.find(call-&gt;getMangledName(), builtIn);
</del><ins>+        symbol = symbolTable.find(call-&gt;getMangledName(), shaderVersion, builtIn);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (symbol == 0) {
</span><span class="lines">@@ -943,7 +1034,7 @@
</span><span class="cx"> // Initializers show up in several places in the grammar.  Have one set of
</span><span class="cx"> // code to handle them here.
</span><span class="cx"> //
</span><del>-bool TParseContext::executeInitializer(const TSourceLoc&amp; line, TString&amp; identifier, TPublicType&amp; pType, 
</del><ins>+bool TParseContext::executeInitializer(const TSourceLoc&amp; line, const TString&amp; identifier, TPublicType&amp; pType, 
</ins><span class="cx">                                        TIntermTyped* initializer, TIntermNode*&amp; intermNode, TVariable* variable)
</span><span class="cx"> {
</span><span class="cx">     TType type = TType(pType);
</span><span class="lines">@@ -959,7 +1050,7 @@
</span><span class="cx">         // add variable to symbol table
</span><span class="cx">         //
</span><span class="cx">         variable = new TVariable(&amp;identifier, type);
</span><del>-        if (! symbolTable.insert(*variable)) {
</del><ins>+        if (! symbolTable.declare(*variable)) {
</ins><span class="cx">             error(line, &quot;redefinition&quot;, variable-&gt;getName().c_str());
</span><span class="cx">             return true;
</span><span class="cx">             // don't delete variable, it's used by error recovery, and the pool 
</span><span class="lines">@@ -997,7 +1088,7 @@
</span><span class="cx">         if (initializer-&gt;getAsConstantUnion()) { 
</span><span class="cx">             variable-&gt;shareConstPointer(initializer-&gt;getAsConstantUnion()-&gt;getUnionArrayPointer());
</span><span class="cx">         } else if (initializer-&gt;getAsSymbolNode()) {
</span><del>-            const TSymbol* symbol = symbolTable.find(initializer-&gt;getAsSymbolNode()-&gt;getSymbol());
</del><ins>+            const TSymbol* symbol = symbolTable.find(initializer-&gt;getAsSymbolNode()-&gt;getSymbol(), 0);
</ins><span class="cx">             const TVariable* tVar = static_cast&lt;const TVariable*&gt;(symbol);
</span><span class="cx"> 
</span><span class="cx">             ConstantUnion* constArray = tVar-&gt;getConstPointer();
</span><span class="lines">@@ -1044,6 +1135,381 @@
</span><span class="cx">     return allConstant;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TPublicType TParseContext::addFullySpecifiedType(TQualifier qualifier, TLayoutQualifier layoutQualifier, const TPublicType&amp; typeSpecifier)
+{
+    TPublicType returnType = typeSpecifier;
+    returnType.qualifier = qualifier;
+    returnType.layoutQualifier = layoutQualifier;
+
+    if (typeSpecifier.array)
+    {
+        error(typeSpecifier.line, &quot;not supported&quot;, &quot;first-class array&quot;);
+        recover();
+        returnType.setArray(false);
+    }
+
+    if (shaderVersion &lt; 300)
+    {
+        if (qualifier == EvqAttribute &amp;&amp; (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt))
+        {
+            error(typeSpecifier.line, &quot;cannot be bool or int&quot;, getQualifierString(qualifier));
+            recover();
+        }
+
+        if ((qualifier == EvqVaryingIn || qualifier == EvqVaryingOut) &amp;&amp;
+            (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt))
+        {
+            error(typeSpecifier.line, &quot;cannot be bool or int&quot;, getQualifierString(qualifier));
+            recover();
+        }
+    }
+    else
+    {
+        switch (qualifier)
+        {
+          case EvqSmoothIn:
+          case EvqSmoothOut:
+          case EvqVertexOut:
+          case EvqFragmentIn:
+          case EvqCentroidOut:
+          case EvqCentroidIn:
+            if (typeSpecifier.type == EbtBool)
+            {
+                error(typeSpecifier.line, &quot;cannot be bool&quot;, getQualifierString(qualifier));
+                recover();
+            }
+            if (typeSpecifier.type == EbtInt || typeSpecifier.type == EbtUInt)
+            {
+                error(typeSpecifier.line, &quot;must use 'flat' interpolation here&quot;, getQualifierString(qualifier));
+                recover();
+            }
+            break;
+
+          case EvqVertexIn:
+          case EvqFragmentOut:
+          case EvqFlatIn:
+          case EvqFlatOut:
+            if (typeSpecifier.type == EbtBool)
+            {
+                error(typeSpecifier.line, &quot;cannot be bool&quot;, getQualifierString(qualifier));
+                recover();
+            }
+            break;
+
+          default: break;
+        }
+    }
+
+    return returnType;
+}
+
+TIntermAggregate* TParseContext::parseSingleDeclaration(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier)
+{
+    TIntermSymbol* symbol = intermediate.addSymbol(0, identifier, TType(publicType), identifierLocation);
+    TIntermAggregate* aggregate = intermediate.makeAggregate(symbol, identifierLocation);
+
+    if (identifier != &quot;&quot;)
+    {
+        if (singleDeclarationErrorCheck(publicType, identifierLocation, identifier))
+            recover();
+
+        // this error check can mutate the type
+        if (nonInitConstErrorCheck(identifierLocation, identifier, publicType, false))
+            recover();
+
+        TVariable* variable = 0;
+
+        if (nonInitErrorCheck(identifierLocation, identifier, publicType, variable))
+            recover();
+
+        if (variable &amp;&amp; symbol)
+        {
+            symbol-&gt;setId(variable-&gt;getUniqueId());
+        }
+    }
+
+    return aggregate;
+}
+
+TIntermAggregate* TParseContext::parseSingleArrayDeclaration(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier, const TSourceLoc&amp; indexLocation, TIntermTyped *indexExpression)
+{
+    if (singleDeclarationErrorCheck(publicType, identifierLocation, identifier))
+        recover();
+
+    // this error check can mutate the type
+    if (nonInitConstErrorCheck(identifierLocation, identifier, publicType, true))
+        recover();
+
+    if (arrayTypeErrorCheck(indexLocation, publicType) || arrayQualifierErrorCheck(indexLocation, publicType))
+    {
+        recover();
+    }
+
+    TPublicType arrayType = publicType;
+
+    int size;
+    if (arraySizeErrorCheck(identifierLocation, indexExpression, size))
+    {
+        recover();
+    }
+    else
+    {
+        arrayType.setArray(true, size);
+    }
+
+    TIntermSymbol* symbol = intermediate.addSymbol(0, identifier, TType(arrayType), identifierLocation);
+    TIntermAggregate* aggregate = intermediate.makeAggregate(symbol, identifierLocation);
+    TVariable* variable = 0;
+
+    if (arrayErrorCheck(identifierLocation, identifier, arrayType, variable))
+        recover();
+
+    if (variable &amp;&amp; symbol)
+    {
+        symbol-&gt;setId(variable-&gt;getUniqueId());
+    }
+
+    return aggregate;
+}
+
+TIntermAggregate* TParseContext::parseSingleInitDeclaration(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier, const TSourceLoc&amp; initLocation, TIntermTyped *initializer)
+{
+    if (singleDeclarationErrorCheck(publicType, identifierLocation, identifier))
+        recover();
+
+    TIntermNode* intermNode;
+    if (!executeInitializer(identifierLocation, identifier, publicType, initializer, intermNode))
+    {
+        //
+        // Build intermediate representation
+        //
+        return intermNode ? intermediate.makeAggregate(intermNode, initLocation) : NULL;
+    }
+    else
+    {
+        recover();
+        return NULL;
+    }
+}
+
+TIntermAggregate* TParseContext::parseDeclarator(TPublicType &amp;publicType, TIntermAggregate *aggregateDeclaration, TSymbol *identifierSymbol, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier)
+{
+    if (publicType.type == EbtInvariant &amp;&amp; !identifierSymbol)
+    {
+        error(identifierLocation, &quot;undeclared identifier declared as invariant&quot;, identifier.c_str());
+        recover();
+    }
+
+    TIntermSymbol* symbol = intermediate.addSymbol(0, identifier, TType(publicType), identifierLocation);
+    TIntermAggregate* intermAggregate = intermediate.growAggregate(aggregateDeclaration, symbol, identifierLocation);
+
+    if (structQualifierErrorCheck(identifierLocation, publicType))
+        recover();
+
+    if (locationDeclaratorListCheck(identifierLocation, publicType))
+        recover();
+
+    if (nonInitConstErrorCheck(identifierLocation, identifier, publicType, false))
+        recover();
+
+    TVariable* variable = 0;
+    if (nonInitErrorCheck(identifierLocation, identifier, publicType, variable))
+        recover();
+    if (symbol &amp;&amp; variable)
+        symbol-&gt;setId(variable-&gt;getUniqueId());
+
+    return intermAggregate;
+}
+
+TIntermAggregate* TParseContext::parseArrayDeclarator(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier, const TSourceLoc&amp; arrayLocation, TIntermNode *declaratorList, TIntermTyped *indexExpression)
+{
+    if (structQualifierErrorCheck(identifierLocation, publicType))
+        recover();
+
+    if (locationDeclaratorListCheck(identifierLocation, publicType))
+        recover();
+
+    if (nonInitConstErrorCheck(identifierLocation, identifier, publicType, true))
+        recover();
+
+    if (arrayTypeErrorCheck(arrayLocation, publicType) || arrayQualifierErrorCheck(arrayLocation, publicType))
+    {
+        recover();
+    }
+    else if (indexExpression)
+    {
+        int size;
+        if (arraySizeErrorCheck(arrayLocation, indexExpression, size))
+            recover();
+        TPublicType arrayType(publicType);
+        arrayType.setArray(true, size);
+        TVariable* variable = NULL;
+        if (arrayErrorCheck(arrayLocation, identifier, arrayType, variable))
+            recover();
+        TType type = TType(arrayType);
+        type.setArraySize(size);
+
+        return intermediate.growAggregate(declaratorList, intermediate.addSymbol(variable ? variable-&gt;getUniqueId() : 0, identifier, type, identifierLocation), identifierLocation);
+    }
+    else
+    {
+        TPublicType arrayType(publicType);
+        arrayType.setArray(true);
+        TVariable* variable = NULL;
+        if (arrayErrorCheck(arrayLocation, identifier, arrayType, variable))
+            recover();
+    }
+
+    return NULL;
+}
+
+TIntermAggregate* TParseContext::parseInitDeclarator(TPublicType &amp;publicType, TIntermAggregate *declaratorList, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier, const TSourceLoc&amp; initLocation, TIntermTyped *initializer)
+{
+    if (structQualifierErrorCheck(identifierLocation, publicType))
+        recover();
+
+    if (locationDeclaratorListCheck(identifierLocation, publicType))
+        recover();
+
+    TIntermNode* intermNode;
+    if (!executeInitializer(identifierLocation, identifier, publicType, initializer, intermNode))
+    {
+        //
+        // build the intermediate representation
+        //
+        if (intermNode)
+        {
+            return intermediate.growAggregate(declaratorList, intermNode, initLocation);
+        }
+        else
+        {
+            return declaratorList;
+        }
+    }
+    else
+    {
+        recover();
+        return NULL;
+    }
+}
+
+void TParseContext::parseGlobalLayoutQualifier(const TPublicType &amp;typeQualifier)
+{
+    if (typeQualifier.qualifier != EvqUniform)
+    {
+        error(typeQualifier.line, &quot;invalid qualifier:&quot;, getQualifierString(typeQualifier.qualifier), &quot;global layout must be uniform&quot;);
+        recover();
+        return;
+    }
+
+    const TLayoutQualifier layoutQualifier = typeQualifier.layoutQualifier;
+    ASSERT(!layoutQualifier.isEmpty());
+
+    if (shaderVersion &lt; 300)
+    {
+        error(typeQualifier.line, &quot;layout qualifiers supported in GLSL ES 3.00 only&quot;, &quot;layout&quot;);
+        recover();
+        return;
+    }
+
+    if (layoutLocationErrorCheck(typeQualifier.line, typeQualifier.layoutQualifier))
+    {
+        recover();
+        return;
+    }
+
+    if (layoutQualifier.matrixPacking != EmpUnspecified)
+    {
+        defaultMatrixPacking = layoutQualifier.matrixPacking;
+    }
+
+    if (layoutQualifier.blockStorage != EbsUnspecified)
+    {
+        defaultBlockStorage = layoutQualifier.blockStorage;
+    }
+}
+
+TFunction *TParseContext::addConstructorFunc(TPublicType publicType)
+{
+    TOperator op = EOpNull;
+    if (publicType.userDef)
+    {
+        op = EOpConstructStruct;
+    }
+    else
+    {
+        switch (publicType.type)
+        {
+          case EbtFloat:
+            if (publicType.isMatrix())
+            {
+                // TODO: non-square matrices
+                switch(publicType.getCols())
+                {
+                  case 2: op = EOpConstructMat2;  break;
+                  case 3: op = EOpConstructMat3;  break;
+                  case 4: op = EOpConstructMat4;  break;
+                }
+            }
+            else
+            {
+                switch(publicType.getNominalSize())
+                {
+                  case 1: op = EOpConstructFloat; break;
+                  case 2: op = EOpConstructVec2;  break;
+                  case 3: op = EOpConstructVec3;  break;
+                  case 4: op = EOpConstructVec4;  break;
+                }
+            }
+            break;
+
+          case EbtInt:
+            switch(publicType.getNominalSize())
+            {
+              case 1: op = EOpConstructInt;   break;
+              case 2: op = EOpConstructIVec2; break;
+              case 3: op = EOpConstructIVec3; break;
+              case 4: op = EOpConstructIVec4; break;
+            }
+            break;
+
+          case EbtUInt:
+            switch(publicType.getNominalSize())
+            {
+              case 1: op = EOpConstructUInt;  break;
+              case 2: op = EOpConstructUVec2; break;
+              case 3: op = EOpConstructUVec3; break;
+              case 4: op = EOpConstructUVec4; break;
+            }
+            break;
+
+          case EbtBool:
+            switch(publicType.getNominalSize())
+            {
+                case 1: op = EOpConstructBool;  break;
+                case 2: op = EOpConstructBVec2; break;
+                case 3: op = EOpConstructBVec3; break;
+                case 4: op = EOpConstructBVec4; break;
+            }
+            break;
+
+          default: break;
+        }
+
+        if (op == EOpNull)
+        {
+            error(publicType.line, &quot;cannot construct this type&quot;, getBasicString(publicType.type));
+            recover();
+            publicType.type = EbtFloat;
+            op = EOpConstructFloat;
+        }
+    }
+
+    TString tempString;
+    TType type(publicType);
+    return new TFunction(&amp;tempString, type, op);
+}
+
</ins><span class="cx"> // This function is used to test for the correctness of the parameters passed to various constructor functions
</span><span class="cx"> // and also convert them to the right datatype if it is allowed and required. 
</span><span class="cx"> //
</span><span class="lines">@@ -1056,9 +1522,9 @@
</span><span class="cx"> 
</span><span class="cx">     TIntermAggregate* aggrNode = node-&gt;getAsAggregate();
</span><span class="cx">     
</span><del>-    TFieldList::const_iterator memberFields;
</del><ins>+    TFieldList::const_iterator memberTypes;
</ins><span class="cx">     if (op == EOpConstructStruct)
</span><del>-        memberFields = type-&gt;getStruct()-&gt;fields().begin();
</del><ins>+        memberTypes = type-&gt;getStruct()-&gt;fields().begin();
</ins><span class="cx">     
</span><span class="cx">     TType elementType = *type;
</span><span class="cx">     if (type-&gt;isArray())
</span><span class="lines">@@ -1080,7 +1546,7 @@
</span><span class="cx">         if (type-&gt;isArray())
</span><span class="cx">             newNode = constructStruct(node, &amp;elementType, 1, node-&gt;getLine(), false);
</span><span class="cx">         else if (op == EOpConstructStruct)
</span><del>-            newNode = constructStruct(node, (*memberFields)-&gt;type(), 1, node-&gt;getLine(), false);
</del><ins>+            newNode = constructStruct(node, (*memberTypes)-&gt;type(), 1, node-&gt;getLine(), false);
</ins><span class="cx">         else
</span><span class="cx">             newNode = constructBuiltIn(type, op, node, node-&gt;getLine(), false);
</span><span class="cx"> 
</span><span class="lines">@@ -1111,7 +1577,7 @@
</span><span class="cx">         if (type-&gt;isArray())
</span><span class="cx">             newNode = constructStruct(*p, &amp;elementType, paramCount+1, node-&gt;getLine(), true);
</span><span class="cx">         else if (op == EOpConstructStruct)
</span><del>-            newNode = constructStruct(*p, memberFields[paramCount]-&gt;type(), paramCount+1, node-&gt;getLine(), true);
</del><ins>+            newNode = constructStruct(*p, (memberTypes[paramCount])-&gt;type(), paramCount+1, node-&gt;getLine(), true);
</ins><span class="cx">         else
</span><span class="cx">             newNode = constructBuiltIn(type, op, *p, node-&gt;getLine(), true);
</span><span class="cx">         
</span><span class="lines">@@ -1136,10 +1602,10 @@
</span><span class="cx">         bool returnVal = false;
</span><span class="cx">         ConstantUnion* unionArray = new ConstantUnion[type.getObjectSize()];
</span><span class="cx">         if (aggrNode-&gt;getSequence().size() == 1)  {
</span><del>-            returnVal = intermediate.parseConstTree(aggrNode-&gt;getLine(), aggrNode, unionArray, aggrNode-&gt;getOp(), symbolTable,  type, true);
</del><ins>+            returnVal = intermediate.parseConstTree(aggrNode-&gt;getLine(), aggrNode, unionArray, aggrNode-&gt;getOp(), type, true);
</ins><span class="cx">         }
</span><span class="cx">         else {
</span><del>-            returnVal = intermediate.parseConstTree(aggrNode-&gt;getLine(), aggrNode, unionArray, aggrNode-&gt;getOp(), symbolTable,  type);
</del><ins>+            returnVal = intermediate.parseConstTree(aggrNode-&gt;getLine(), aggrNode, unionArray, aggrNode-&gt;getOp(), type);
</ins><span class="cx">         }
</span><span class="cx">         if (returnVal)
</span><span class="cx">             return 0;
</span><span class="lines">@@ -1183,6 +1649,13 @@
</span><span class="cx">         basicOp = EOpConstructInt;
</span><span class="cx">         break;
</span><span class="cx"> 
</span><ins>+    case EOpConstructUVec2:
+    case EOpConstructUVec3:
+    case EOpConstructUVec4:
+    case EOpConstructUInt:
+        basicOp = EOpConstructUInt;
+        break;
+
</ins><span class="cx">     case EOpConstructBVec2:
</span><span class="cx">     case EOpConstructBVec3:
</span><span class="cx">     case EOpConstructBVec4:
</span><span class="lines">@@ -1196,7 +1669,7 @@
</span><span class="cx"> 
</span><span class="cx">         return 0;
</span><span class="cx">     }
</span><del>-    newNode = intermediate.addUnaryMath(basicOp, node, node-&gt;getLine(), symbolTable);
</del><ins>+    newNode = intermediate.addUnaryMath(basicOp, node, node-&gt;getLine());
</ins><span class="cx">     if (newNode == 0) {
</span><span class="cx">         error(line, &quot;can't convert&quot;, &quot;constructor&quot;);
</span><span class="cx">         return 0;
</span><span class="lines">@@ -1295,7 +1768,7 @@
</span><span class="cx">     TIntermTyped* typedNode;
</span><span class="cx">     TIntermConstantUnion* tempConstantNode = node-&gt;getAsConstantUnion();
</span><span class="cx"> 
</span><del>-    if (index &gt;= node-&gt;getType().getNominalSize()) {
</del><ins>+    if (index &gt;= node-&gt;getType().getCols()) {
</ins><span class="cx">         std::stringstream extraInfoStream;
</span><span class="cx">         extraInfoStream &lt;&lt; &quot;matrix field selection out of range '&quot; &lt;&lt; index &lt;&lt; &quot;'&quot;;
</span><span class="cx">         std::string extraInfo = extraInfoStream.str();
</span><span class="lines">@@ -1306,7 +1779,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (tempConstantNode) {
</span><span class="cx">          ConstantUnion* unionArray = tempConstantNode-&gt;getUnionArrayPointer();
</span><del>-         int size = tempConstantNode-&gt;getType().getNominalSize();
</del><ins>+         int size = tempConstantNode-&gt;getType().getCols();
</ins><span class="cx">          typedNode = intermediate.addConstantUnion(&amp;unionArray[size*index], tempConstantNode-&gt;getType(), line);
</span><span class="cx">     } else {
</span><span class="cx">         error(line, &quot;Cannot offset into the matrix&quot;, &quot;Error&quot;);
</span><span class="lines">@@ -1342,9 +1815,9 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (tempConstantNode) {
</span><del>-         size_t arrayElementSize = arrayElementType.getObjectSize();
-         ConstantUnion* unionArray = tempConstantNode-&gt;getUnionArrayPointer();
-         typedNode = intermediate.addConstantUnion(&amp;unionArray[arrayElementSize * index], tempConstantNode-&gt;getType(), line);
</del><ins>+        size_t arrayElementSize = arrayElementType.getObjectSize();
+        ConstantUnion* unionArray = tempConstantNode-&gt;getUnionArrayPointer();
+        typedNode = intermediate.addConstantUnion(&amp;unionArray[arrayElementSize * index], tempConstantNode-&gt;getType(), line);
</ins><span class="cx">     } else {
</span><span class="cx">         error(line, &quot;Cannot offset into the array&quot;, &quot;Error&quot;);
</span><span class="cx">         recover();
</span><span class="lines">@@ -1361,11 +1834,11 @@
</span><span class="cx"> // If there is an embedded/nested struct, it appropriately calls addConstStructNested or addConstStructFromAggr
</span><span class="cx"> // function and returns the parse-tree with the values of the embedded/nested struct.
</span><span class="cx"> //
</span><del>-TIntermTyped* TParseContext::addConstStruct(TString&amp; identifier, TIntermTyped* node, const TSourceLoc&amp; line)
</del><ins>+TIntermTyped* TParseContext::addConstStruct(const TString &amp;identifier, TIntermTyped *node, const TSourceLoc&amp; line)
</ins><span class="cx"> {
</span><span class="cx">     const TFieldList&amp; fields = node-&gt;getType().getStruct()-&gt;fields();
</span><ins>+    size_t instanceSize = 0;
</ins><span class="cx"> 
</span><del>-    size_t instanceSize = 0;
</del><span class="cx">     for (size_t index = 0; index &lt; fields.size(); ++index) {
</span><span class="cx">         if (fields[index]-&gt;name() == identifier) {
</span><span class="cx">             break;
</span><span class="lines">@@ -1374,8 +1847,8 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    TIntermTyped* typedNode = 0;
-    TIntermConstantUnion* tempConstantNode = node-&gt;getAsConstantUnion();
</del><ins>+    TIntermTyped *typedNode;
+    TIntermConstantUnion *tempConstantNode = node-&gt;getAsConstantUnion();
</ins><span class="cx">     if (tempConstantNode) {
</span><span class="cx">          ConstantUnion* constArray = tempConstantNode-&gt;getUnionArrayPointer();
</span><span class="cx"> 
</span><span class="lines">@@ -1390,6 +1863,146 @@
</span><span class="cx">     return typedNode;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+//
+// Interface/uniform blocks
+//
+TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType&amp; typeQualifier, const TSourceLoc&amp; nameLine, const TString&amp; blockName, TFieldList* fieldList, 
+                                                   const TString* instanceName, const TSourceLoc&amp; instanceLine, TIntermTyped* arrayIndex, const TSourceLoc&amp; arrayIndexLine)
+{
+    if (reservedErrorCheck(nameLine, blockName))
+        recover();
+
+    if (typeQualifier.qualifier != EvqUniform)
+    {
+        error(typeQualifier.line, &quot;invalid qualifier:&quot;, getQualifierString(typeQualifier.qualifier), &quot;interface blocks must be uniform&quot;);
+        recover();
+    }
+
+    TLayoutQualifier blockLayoutQualifier = typeQualifier.layoutQualifier;
+    if (layoutLocationErrorCheck(typeQualifier.line, blockLayoutQualifier))
+    {
+        recover();
+    }
+
+    if (blockLayoutQualifier.matrixPacking == EmpUnspecified)
+    {
+        blockLayoutQualifier.matrixPacking = defaultMatrixPacking;
+    }
+
+    if (blockLayoutQualifier.blockStorage == EbsUnspecified)
+    {
+        blockLayoutQualifier.blockStorage = defaultBlockStorage;
+    }
+
+    TSymbol* blockNameSymbol = new TInterfaceBlockName(&amp;blockName);
+    if (!symbolTable.declare(*blockNameSymbol)) {
+        error(nameLine, &quot;redefinition&quot;, blockName.c_str(), &quot;interface block name&quot;);
+        recover();
+    }
+
+    // check for sampler types and apply layout qualifiers
+    for (size_t memberIndex = 0; memberIndex &lt; fieldList-&gt;size(); ++memberIndex) {
+        TField* field = (*fieldList)[memberIndex];
+        TType* fieldType = field-&gt;type();
+        if (IsSampler(fieldType-&gt;getBasicType())) {
+            error(field-&gt;line(), &quot;unsupported type&quot;, fieldType-&gt;getBasicString(), &quot;sampler types are not allowed in interface blocks&quot;);
+            recover();
+        }
+
+        const TQualifier qualifier = fieldType-&gt;getQualifier();
+        switch (qualifier)
+        {
+          case EvqGlobal:
+          case EvqUniform:
+            break;
+          default:
+            error(field-&gt;line(), &quot;invalid qualifier on interface block member&quot;, getQualifierString(qualifier));
+            recover();
+            break;
+        }
+
+        // check layout qualifiers
+        TLayoutQualifier fieldLayoutQualifier = fieldType-&gt;getLayoutQualifier();
+        if (layoutLocationErrorCheck(field-&gt;line(), fieldLayoutQualifier))
+        {
+            recover();
+        }
+
+        if (fieldLayoutQualifier.blockStorage != EbsUnspecified)
+        {
+            error(field-&gt;line(), &quot;invalid layout qualifier:&quot;, getBlockStorageString(fieldLayoutQualifier.blockStorage), &quot;cannot be used here&quot;);
+            recover();
+        }
+
+        if (fieldLayoutQualifier.matrixPacking == EmpUnspecified)
+        {
+            fieldLayoutQualifier.matrixPacking = blockLayoutQualifier.matrixPacking;
+        }
+        else if (!fieldType-&gt;isMatrix())
+        {
+            error(field-&gt;line(), &quot;invalid layout qualifier:&quot;, getMatrixPackingString(fieldLayoutQualifier.matrixPacking), &quot;can only be used on matrix types&quot;);
+            recover();
+        }
+
+        fieldType-&gt;setLayoutQualifier(fieldLayoutQualifier);
+    }
+
+    // add array index
+    int arraySize = 0;
+    if (arrayIndex != NULL)
+    {
+        if (arraySizeErrorCheck(arrayIndexLine, arrayIndex, arraySize))
+            recover();
+    }
+
+    TInterfaceBlock* interfaceBlock = new TInterfaceBlock(&amp;blockName, fieldList, instanceName, arraySize, blockLayoutQualifier);
+    TType interfaceBlockType(interfaceBlock, typeQualifier.qualifier, blockLayoutQualifier, arraySize);
+
+    TString symbolName = &quot;&quot;;
+    int symbolId = 0;
+
+    if (!instanceName)
+    {
+        // define symbols for the members of the interface block
+        for (size_t memberIndex = 0; memberIndex &lt; fieldList-&gt;size(); ++memberIndex)
+        {
+            TField* field = (*fieldList)[memberIndex];
+            TType* fieldType = field-&gt;type();
+
+            // set parent pointer of the field variable
+            fieldType-&gt;setInterfaceBlock(interfaceBlock);
+
+            TVariable* fieldVariable = new TVariable(&amp;field-&gt;name(), *fieldType);
+            fieldVariable-&gt;setQualifier(typeQualifier.qualifier);
+
+            if (!symbolTable.declare(*fieldVariable)) {
+                error(field-&gt;line(), &quot;redefinition&quot;, field-&gt;name().c_str(), &quot;interface block member name&quot;);
+                recover();
+            }
+        }
+    }
+    else
+    {
+        // add a symbol for this interface block
+        TVariable* instanceTypeDef = new TVariable(instanceName, interfaceBlockType, false);
+        instanceTypeDef-&gt;setQualifier(typeQualifier.qualifier);
+
+        if (!symbolTable.declare(*instanceTypeDef)) {
+            error(instanceLine, &quot;redefinition&quot;, instanceName-&gt;c_str(), &quot;interface block instance name&quot;);
+            recover();
+        }
+
+        symbolId = instanceTypeDef-&gt;getUniqueId();
+        symbolName = instanceTypeDef-&gt;getName();
+    }
+
+    TIntermAggregate *aggregate = intermediate.makeAggregate(intermediate.addSymbol(symbolId, symbolName, interfaceBlockType, typeQualifier.line), nameLine);
+    aggregate-&gt;setOp(EOpDeclaration);
+
+    exitStructDeclaration();
+    return aggregate;
+}
+
</ins><span class="cx"> bool TParseContext::enterStructDeclaration(const TSourceLoc&amp; line, const TString&amp; identifier)
</span><span class="cx"> {
</span><span class="cx">     ++structNestingLevel;
</span><span class="lines">@@ -1418,7 +2031,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool TParseContext::structNestingErrorCheck(const TSourceLoc&amp; line, const TField&amp; field)
</span><span class="cx"> {
</span><del>-    if (!isWebGLBasedSpec(shaderSpec)) {
</del><ins>+    if (!IsWebGLBasedSpec(shaderSpec)) {
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1531,6 +2144,17 @@
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><ins>+        if (baseExpression-&gt;isInterfaceBlock())
+        {
+            error(location, &quot;&quot;, &quot;[&quot;, &quot;array indexes for interface blocks arrays must be constant integral expressions&quot;);
+            recover();
+        }
+        else if (baseExpression-&gt;getQualifier() == EvqFragmentOut)
+        {
+            error(location, &quot;&quot;, &quot;[&quot;, &quot;array indexes for fragment outputs must be constant integral expressions&quot;);
+            recover();
+        }
+
</ins><span class="cx">         indexedExpression = intermediate.addIndex(EOpIndexIndirect, baseExpression, indexExpression, location);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1548,9 +2172,14 @@
</span><span class="cx">             TType copyOfType(baseType.getStruct());
</span><span class="cx">             indexedExpression-&gt;setType(copyOfType);
</span><span class="cx">         }
</span><ins>+        else if (baseType.isInterfaceBlock())
+        {
+            TType copyOfType(baseType.getInterfaceBlock(), baseType.getQualifier(), baseType.getLayoutQualifier(), 0);
+            indexedExpression-&gt;setType(copyOfType);
+        }
</ins><span class="cx">         else
</span><span class="cx">         {
</span><del>-            indexedExpression-&gt;setType(TType(baseExpression-&gt;getBasicType(), baseExpression-&gt;getPrecision(), EvqTemporary, baseExpression-&gt;getNominalSize(), baseExpression-&gt;isMatrix()));
</del><ins>+            indexedExpression-&gt;setType(TType(baseExpression-&gt;getBasicType(), baseExpression-&gt;getPrecision(), EvqTemporary, baseExpression-&gt;getNominalSize(), baseExpression-&gt;getSecondarySize()));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (baseExpression-&gt;getType().getQualifier() == EvqConst)
</span><span class="lines">@@ -1561,7 +2190,7 @@
</span><span class="cx">     else if (baseExpression-&gt;isMatrix())
</span><span class="cx">     {
</span><span class="cx">         TQualifier qualifier = baseExpression-&gt;getType().getQualifier() == EvqConst ? EvqConst : EvqTemporary;
</span><del>-        indexedExpression-&gt;setType(TType(baseExpression-&gt;getBasicType(), baseExpression-&gt;getPrecision(), qualifier, baseExpression-&gt;getNominalSize()));
</del><ins>+        indexedExpression-&gt;setType(TType(baseExpression-&gt;getBasicType(), baseExpression-&gt;getPrecision(), qualifier, baseExpression-&gt;getRows()));
</ins><span class="cx">     }
</span><span class="cx">     else if (baseExpression-&gt;isVector())
</span><span class="cx">     {
</span><span class="lines">@@ -1576,6 +2205,406 @@
</span><span class="cx">     return indexedExpression;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpression, const TSourceLoc&amp; dotLocation, const TString &amp;fieldString, const TSourceLoc&amp; fieldLocation)
+{
+    TIntermTyped *indexedExpression = NULL;
+
+    if (baseExpression-&gt;isArray())
+    {
+        error(fieldLocation, &quot;cannot apply dot operator to an array&quot;, &quot;.&quot;);
+        recover();
+    }
+
+    if (baseExpression-&gt;isVector())
+    {
+        TVectorFields fields;
+        if (!parseVectorFields(fieldString, baseExpression-&gt;getNominalSize(), fields, fieldLocation))
+        {
+            fields.num = 1;
+            fields.offsets[0] = 0;
+            recover();
+        }
+
+        if (baseExpression-&gt;getType().getQualifier() == EvqConst)
+        {
+            // constant folding for vector fields
+            indexedExpression = addConstVectorNode(fields, baseExpression, fieldLocation);
+            if (indexedExpression == 0)
+            {
+                recover();
+                indexedExpression = baseExpression;
+            }
+            else
+            {
+                indexedExpression-&gt;setType(TType(baseExpression-&gt;getBasicType(), baseExpression-&gt;getPrecision(), EvqConst, (int) (fieldString).size()));
+            }
+        }
+        else
+        {
+            TString vectorString = fieldString;
+            TIntermTyped* index = intermediate.addSwizzle(fields, fieldLocation);
+            indexedExpression = intermediate.addIndex(EOpVectorSwizzle, baseExpression, index, dotLocation);
+            indexedExpression-&gt;setType(TType(baseExpression-&gt;getBasicType(), baseExpression-&gt;getPrecision(), EvqTemporary, (int) vectorString.size()));
+        }
+    }
+    else if (baseExpression-&gt;isMatrix())
+    {
+        TMatrixFields fields;
+        if (!parseMatrixFields(fieldString, baseExpression-&gt;getCols(), baseExpression-&gt;getRows(), fields, fieldLocation))
+        {
+            fields.wholeRow = false;
+            fields.wholeCol = false;
+            fields.row = 0;
+            fields.col = 0;
+            recover();
+        }
+
+        if (fields.wholeRow || fields.wholeCol)
+        {
+            error(dotLocation, &quot; non-scalar fields not implemented yet&quot;, &quot;.&quot;);
+            recover();
+            ConstantUnion *unionArray = new ConstantUnion[1];
+            unionArray-&gt;setIConst(0);
+            TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation);
+            indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
+            indexedExpression-&gt;setType(TType(baseExpression-&gt;getBasicType(), baseExpression-&gt;getPrecision(),EvqTemporary, baseExpression-&gt;getCols(), baseExpression-&gt;getRows()));
+        }
+        else
+        {
+            ConstantUnion *unionArray = new ConstantUnion[1];
+            unionArray-&gt;setIConst(fields.col * baseExpression-&gt;getRows() + fields.row);
+            TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation);
+            indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
+            indexedExpression-&gt;setType(TType(baseExpression-&gt;getBasicType(), baseExpression-&gt;getPrecision()));
+        }
+    }
+    else if (baseExpression-&gt;getBasicType() == EbtStruct)
+    {
+        bool fieldFound = false;
+        const TFieldList&amp; fields = baseExpression-&gt;getType().getStruct()-&gt;fields();
+        if (fields.empty())
+        {
+            error(dotLocation, &quot;structure has no fields&quot;, &quot;Internal Error&quot;);
+            recover();
+            indexedExpression = baseExpression;
+        }
+        else
+        {
+            unsigned int i;
+            for (i = 0; i &lt; fields.size(); ++i)
+            {
+                if (fields[i]-&gt;name() == fieldString)
+                {
+                    fieldFound = true;
+                    break;
+                }
+            }
+            if (fieldFound)
+            {
+                if (baseExpression-&gt;getType().getQualifier() == EvqConst)
+                {
+                    indexedExpression = addConstStruct(fieldString, baseExpression, dotLocation);
+                    if (indexedExpression == 0)
+                    {
+                        recover();
+                        indexedExpression = baseExpression;
+                    }
+                    else
+                    {
+                        indexedExpression-&gt;setType(*fields[i]-&gt;type());
+                        // change the qualifier of the return type, not of the structure field
+                        // as the structure definition is shared between various structures.
+                        indexedExpression-&gt;getTypePointer()-&gt;setQualifier(EvqConst);
+                    }
+                }
+                else
+                {
+                    ConstantUnion *unionArray = new ConstantUnion[1];
+                    unionArray-&gt;setIConst(i);
+                    TIntermTyped* index = intermediate.addConstantUnion(unionArray, *fields[i]-&gt;type(), fieldLocation);
+                    indexedExpression = intermediate.addIndex(EOpIndexDirectStruct, baseExpression, index, dotLocation);
+                    indexedExpression-&gt;setType(*fields[i]-&gt;type());
+                }
+            }
+            else
+            {
+                error(dotLocation, &quot; no such field in structure&quot;, fieldString.c_str());
+                recover();
+                indexedExpression = baseExpression;
+            }
+        }
+    }
+    else if (baseExpression-&gt;isInterfaceBlock())
+    {
+        bool fieldFound = false;
+        const TFieldList&amp; fields = baseExpression-&gt;getType().getInterfaceBlock()-&gt;fields();
+        if (fields.empty())
+        {
+            error(dotLocation, &quot;interface block has no fields&quot;, &quot;Internal Error&quot;);
+            recover();
+            indexedExpression = baseExpression;
+        }
+        else
+        {
+            unsigned int i;
+            for (i = 0; i &lt; fields.size(); ++i)
+            {
+                if (fields[i]-&gt;name() == fieldString)
+                {
+                    fieldFound = true;
+                    break;
+                }
+            }
+            if (fieldFound)
+            {
+                ConstantUnion *unionArray = new ConstantUnion[1];
+                unionArray-&gt;setIConst(i);
+                TIntermTyped* index = intermediate.addConstantUnion(unionArray, *fields[i]-&gt;type(), fieldLocation);
+                indexedExpression = intermediate.addIndex(EOpIndexDirectInterfaceBlock, baseExpression, index, dotLocation);
+                indexedExpression-&gt;setType(*fields[i]-&gt;type());
+            }
+            else
+            {
+                error(dotLocation, &quot; no such field in interface block&quot;, fieldString.c_str());
+                recover();
+                indexedExpression = baseExpression;
+            }
+        }
+    }
+    else
+    {
+        if (shaderVersion &lt; 300)
+        {
+            error(dotLocation, &quot; field selection requires structure, vector, or matrix on left hand side&quot;, fieldString.c_str());
+        }
+        else
+        {
+            error(dotLocation, &quot; field selection requires structure, vector, matrix, or interface block on left hand side&quot;, fieldString.c_str());
+        }
+        recover();
+        indexedExpression = baseExpression;
+    }
+
+    return indexedExpression;
+}
+
+TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &amp;qualifierType, const TSourceLoc&amp; qualifierTypeLine)
+{
+    TLayoutQualifier qualifier;
+
+    qualifier.location = -1;
+    qualifier.matrixPacking = EmpUnspecified;
+    qualifier.blockStorage = EbsUnspecified;
+
+    if (qualifierType == &quot;shared&quot;)
+    {
+        qualifier.blockStorage = EbsShared;
+    }
+    else if (qualifierType == &quot;packed&quot;)
+    {
+        qualifier.blockStorage = EbsPacked;
+    }
+    else if (qualifierType == &quot;std140&quot;)
+    {
+        qualifier.blockStorage = EbsStd140;
+    }
+    else if (qualifierType == &quot;row_major&quot;)
+    {
+        qualifier.matrixPacking = EmpRowMajor;
+    }
+    else if (qualifierType == &quot;column_major&quot;)
+    {
+        qualifier.matrixPacking = EmpColumnMajor;
+    }
+    else if (qualifierType == &quot;location&quot;)
+    {
+        error(qualifierTypeLine, &quot;invalid layout qualifier&quot;, qualifierType.c_str(), &quot;location requires an argument&quot;);
+        recover();
+    }
+    else
+    {
+        error(qualifierTypeLine, &quot;invalid layout qualifier&quot;, qualifierType.c_str());
+        recover();
+    }
+
+    return qualifier;
+}
+
+TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &amp;qualifierType, const TSourceLoc&amp; qualifierTypeLine, const TString &amp;intValueString, int intValue, const TSourceLoc&amp; intValueLine)
+{
+    TLayoutQualifier qualifier;
+
+    qualifier.location = -1;
+    qualifier.matrixPacking = EmpUnspecified;
+    qualifier.blockStorage = EbsUnspecified;
+
+    if (qualifierType != &quot;location&quot;)
+    {
+        error(qualifierTypeLine, &quot;invalid layout qualifier&quot;, qualifierType.c_str(), &quot;only location may have arguments&quot;);
+        recover();
+    }
+    else
+    {
+        // must check that location is non-negative
+        if (intValue &lt; 0)
+        {
+            error(intValueLine, &quot;out of range:&quot;, intValueString.c_str(), &quot;location must be non-negative&quot;);
+            recover();
+        }
+        else
+        {
+            qualifier.location = intValue;
+        }
+    }
+
+    return qualifier;
+}
+
+TLayoutQualifier TParseContext::joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier)
+{
+    TLayoutQualifier joinedQualifier = leftQualifier;
+
+    if (rightQualifier.location != -1)
+    {
+        joinedQualifier.location = rightQualifier.location;
+    }
+    if (rightQualifier.matrixPacking != EmpUnspecified)
+    {
+        joinedQualifier.matrixPacking = rightQualifier.matrixPacking;
+    }
+    if (rightQualifier.blockStorage != EbsUnspecified)
+    {
+        joinedQualifier.blockStorage = rightQualifier.blockStorage;
+    }
+
+    return joinedQualifier;
+}
+
+TPublicType TParseContext::joinInterpolationQualifiers(const TSourceLoc &amp;interpolationLoc, TQualifier interpolationQualifier,
+                                                       const TSourceLoc &amp;storageLoc, TQualifier storageQualifier)
+{
+    TQualifier mergedQualifier = EvqSmoothIn;
+
+    if (storageQualifier == EvqFragmentIn) {
+        if (interpolationQualifier == EvqSmooth)
+            mergedQualifier = EvqSmoothIn;
+        else if (interpolationQualifier == EvqFlat)
+            mergedQualifier = EvqFlatIn;
+        else UNREACHABLE();
+    }
+    else if (storageQualifier == EvqCentroidIn) {
+        if (interpolationQualifier == EvqSmooth)
+            mergedQualifier = EvqCentroidIn;
+        else if (interpolationQualifier == EvqFlat)
+            mergedQualifier = EvqFlatIn;
+        else UNREACHABLE();
+    }
+    else if (storageQualifier == EvqVertexOut) {
+        if (interpolationQualifier == EvqSmooth)
+            mergedQualifier = EvqSmoothOut;
+        else if (interpolationQualifier == EvqFlat)
+            mergedQualifier = EvqFlatOut;
+        else UNREACHABLE();
+    }
+    else if (storageQualifier == EvqCentroidOut) {
+        if (interpolationQualifier == EvqSmooth)
+            mergedQualifier = EvqCentroidOut;
+        else if (interpolationQualifier == EvqFlat)
+            mergedQualifier = EvqFlatOut;
+        else UNREACHABLE();
+    }
+    else {
+        error(interpolationLoc, &quot;interpolation qualifier requires a fragment 'in' or vertex 'out' storage qualifier&quot;, getInterpolationString(interpolationQualifier));
+        recover();
+
+        mergedQualifier = storageQualifier;
+    }
+
+    TPublicType type;
+    type.setBasic(EbtVoid, mergedQualifier, storageLoc);
+    return type;
+}
+
+TFieldList *TParseContext::addStructDeclaratorList(const TPublicType&amp; typeSpecifier, TFieldList *fieldList)
+{
+    if (voidErrorCheck(typeSpecifier.line, (*fieldList)[0]-&gt;name(), typeSpecifier)) {
+        recover();
+    }
+
+    for (unsigned int i = 0; i &lt; fieldList-&gt;size(); ++i) {
+        //
+        // Careful not to replace already known aspects of type, like array-ness
+        //
+        TType* type = (*fieldList)[i]-&gt;type();
+        type-&gt;setBasicType(typeSpecifier.type);
+        type-&gt;setPrimarySize(typeSpecifier.primarySize);
+        type-&gt;setSecondarySize(typeSpecifier.secondarySize);
+        type-&gt;setPrecision(typeSpecifier.precision);
+        type-&gt;setQualifier(typeSpecifier.qualifier);
+        type-&gt;setLayoutQualifier(typeSpecifier.layoutQualifier);
+
+        // don't allow arrays of arrays
+        if (type-&gt;isArray()) {
+            if (arrayTypeErrorCheck(typeSpecifier.line, typeSpecifier))
+                recover();
+        }
+        if (typeSpecifier.array)
+            type-&gt;setArraySize(typeSpecifier.arraySize);
+        if (typeSpecifier.userDef) {
+            type-&gt;setStruct(typeSpecifier.userDef-&gt;getStruct());
+        }
+
+        if (structNestingErrorCheck(typeSpecifier.line, *(*fieldList)[i])) {
+            recover();
+        }
+    }
+
+    return fieldList;
+}
+
+TPublicType TParseContext::addStructure(const TSourceLoc&amp; structLine, const TSourceLoc&amp; nameLine, const TString *structName, TFieldList* fieldList)
+{
+    TStructure* structure = new TStructure(structName, fieldList);
+    TType* structureType = new TType(structure);
+
+    if (!structName-&gt;empty())
+    {
+        if (reservedErrorCheck(nameLine, *structName))
+        {
+            recover();
+        }
+        TVariable* userTypeDef = new TVariable(structName, *structureType, true);
+        if (!symbolTable.declare(*userTypeDef)) {
+            error(nameLine, &quot;redefinition&quot;, structName-&gt;c_str(), &quot;struct&quot;);
+            recover();
+        }
+    }
+
+    // ensure we do not specify any storage qualifiers on the struct members
+    for (unsigned int typeListIndex = 0; typeListIndex &lt; fieldList-&gt;size(); typeListIndex++)
+    {
+        const TField &amp;field = *(*fieldList)[typeListIndex];
+        const TQualifier qualifier = field.type()-&gt;getQualifier();
+        switch (qualifier)
+        {
+          case EvqGlobal:
+          case EvqTemporary:
+            break;
+          default:
+            error(field.line(), &quot;invalid qualifier on struct member&quot;, getQualifierString(qualifier));
+            recover();
+            break;
+        }
+    }
+
+    TPublicType publicType;
+    publicType.setBasic(EbtStruct, EvqTemporary, structLine);
+    publicType.userDef = structureType;
+    exitStructDeclaration();
+
+    return publicType;
+}
+
</ins><span class="cx"> //
</span><span class="cx"> // Parse an array of strings using yyparse.
</span><span class="cx"> //
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorParseContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ParseContext.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ParseContext.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ParseContext.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -9,9 +9,9 @@
</span><span class="cx"> #include &quot;compiler/translator/Diagnostics.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/DirectiveHandler.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/localintermediate.h&quot;
</span><del>-#include &quot;compiler/preprocessor/Preprocessor.h&quot;
</del><span class="cx"> #include &quot;compiler/translator/ShHandle.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/SymbolTable.h&quot;
</span><ins>+#include &quot;compiler/preprocessor/Preprocessor.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> struct TMatrixFields {
</span><span class="cx">     bool wholeRow;
</span><span class="lines">@@ -38,14 +38,18 @@
</span><span class="cx">             currentFunctionType(NULL),
</span><span class="cx">             functionReturnsValue(false),
</span><span class="cx">             checksPrecisionErrors(checksPrecErrors),
</span><ins>+            defaultMatrixPacking(EmpColumnMajor),
+            defaultBlockStorage(EbsShared),
</ins><span class="cx">             diagnostics(is),
</span><del>-            directiveHandler(ext, diagnostics),
</del><ins>+            shaderVersion(100),
+            directiveHandler(ext, diagnostics, shaderVersion),
</ins><span class="cx">             preprocessor(&amp;diagnostics, &amp;directiveHandler),
</span><span class="cx">             scanner(NULL) {  }
</span><span class="cx">     TIntermediate&amp; intermediate; // to hold and build a parse tree
</span><span class="cx">     TSymbolTable&amp; symbolTable;   // symbol table that goes with the language currently being parsed
</span><span class="cx">     ShShaderType shaderType;              // vertex or fragment language (future: pack or unpack)
</span><span class="cx">     ShShaderSpec shaderSpec;              // The language specification compiler conforms to - GLES2 or WebGL.
</span><ins>+    int shaderVersion;
</ins><span class="cx">     int compileOptions;
</span><span class="cx">     const char* sourcePath;      // Path of source file or NULL.
</span><span class="cx">     TIntermNode* treeRoot;       // root of parse tree being created
</span><span class="lines">@@ -55,12 +59,15 @@
</span><span class="cx">     bool functionReturnsValue;   // true if a non-void function has a return
</span><span class="cx">     bool checksPrecisionErrors;  // true if an error will be generated when a variable is declared without precision, explicit or implicit.
</span><span class="cx">     bool fragmentPrecisionHigh;  // true if highp precision is supported in the fragment language.
</span><ins>+    TLayoutMatrixPacking defaultMatrixPacking;
+    TLayoutBlockStorage defaultBlockStorage;
</ins><span class="cx">     TString HashErrMsg;
</span><span class="cx">     TDiagnostics diagnostics;
</span><span class="cx">     TDirectiveHandler directiveHandler;
</span><span class="cx">     pp::Preprocessor preprocessor;
</span><span class="cx">     void* scanner;
</span><span class="cx"> 
</span><ins>+    int getShaderVersion() const { return shaderVersion; }
</ins><span class="cx">     int numErrors() const { return diagnostics.numErrors(); }
</span><span class="cx">     TInfoSink&amp; infoSink() { return diagnostics.infoSink(); }
</span><span class="cx">     void error(const TSourceLoc&amp; loc, const char *reason, const char* token,
</span><span class="lines">@@ -71,7 +78,7 @@
</span><span class="cx">     void recover();
</span><span class="cx"> 
</span><span class="cx">     bool parseVectorFields(const TString&amp;, int vecSize, TVectorFields&amp;, const TSourceLoc&amp; line);
</span><del>-    bool parseMatrixFields(const TString&amp;, int matSize, TMatrixFields&amp;, const TSourceLoc&amp; line);
</del><ins>+    bool parseMatrixFields(const TString&amp;, int matCols, int matRows, TMatrixFields&amp;, const TSourceLoc&amp; line);
</ins><span class="cx"> 
</span><span class="cx">     bool reservedErrorCheck(const TSourceLoc&amp; line, const TString&amp; identifier);
</span><span class="cx">     void assignError(const TSourceLoc&amp; line, const char* op, TString left, TString right);
</span><span class="lines">@@ -86,29 +93,44 @@
</span><span class="cx">     bool arraySizeErrorCheck(const TSourceLoc&amp; line, TIntermTyped* expr, int&amp; size);
</span><span class="cx">     bool arrayQualifierErrorCheck(const TSourceLoc&amp; line, TPublicType type);
</span><span class="cx">     bool arrayTypeErrorCheck(const TSourceLoc&amp; line, TPublicType type);
</span><del>-    bool arrayErrorCheck(const TSourceLoc&amp; line, TString&amp; identifier, TPublicType type, TVariable*&amp; variable);
</del><ins>+    bool arrayErrorCheck(const TSourceLoc&amp; line, const TString&amp; identifier, const TPublicType &amp;type, TVariable*&amp; variable);
</ins><span class="cx">     bool voidErrorCheck(const TSourceLoc&amp;, const TString&amp;, const TPublicType&amp;);
</span><span class="cx">     bool boolErrorCheck(const TSourceLoc&amp;, const TIntermTyped*);
</span><span class="cx">     bool boolErrorCheck(const TSourceLoc&amp;, const TPublicType&amp;);
</span><span class="cx">     bool samplerErrorCheck(const TSourceLoc&amp; line, const TPublicType&amp; pType, const char* reason);
</span><span class="cx">     bool structQualifierErrorCheck(const TSourceLoc&amp; line, const TPublicType&amp; pType);
</span><ins>+    bool locationDeclaratorListCheck(const TSourceLoc&amp; line, const TPublicType &amp;pType);
</ins><span class="cx">     bool parameterSamplerErrorCheck(const TSourceLoc&amp; line, TQualifier qualifier, const TType&amp; type);
</span><del>-    bool nonInitConstErrorCheck(const TSourceLoc&amp; line, TString&amp; identifier, TPublicType&amp; type, bool array);
-    bool nonInitErrorCheck(const TSourceLoc&amp; line, TString&amp; identifier, TPublicType&amp; type, TVariable*&amp; variable);
</del><ins>+    bool nonInitConstErrorCheck(const TSourceLoc&amp; line, const TString&amp; identifier, TPublicType&amp; type, bool array);
+    bool nonInitErrorCheck(const TSourceLoc&amp; line, const TString&amp; identifier, const TPublicType&amp; type, TVariable*&amp; variable);
</ins><span class="cx">     bool paramErrorCheck(const TSourceLoc&amp; line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
</span><span class="cx">     bool extensionErrorCheck(const TSourceLoc&amp; line, const TString&amp;);
</span><ins>+    bool singleDeclarationErrorCheck(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier);
+    bool layoutLocationErrorCheck(const TSourceLoc&amp; location, const TLayoutQualifier &amp;layoutQualifier);
</ins><span class="cx"> 
</span><span class="cx">     const TPragma&amp; pragma() const { return directiveHandler.pragma(); }
</span><span class="cx">     const TExtensionBehavior&amp; extensionBehavior() const { return directiveHandler.extensionBehavior(); }
</span><span class="cx">     bool supportsExtension(const char* extension);
</span><span class="cx">     bool isExtensionEnabled(const char* extension) const;
</span><ins>+    void handleExtensionDirective(const TSourceLoc&amp; loc, const char* extName, const char* behavior);
+    void handlePragmaDirective(const TSourceLoc&amp; loc, const char* name, const char* value);
</ins><span class="cx"> 
</span><span class="cx">     bool containsSampler(TType&amp; type);
</span><span class="cx">     bool areAllChildConst(TIntermAggregate* aggrNode);
</span><del>-    const TFunction* findFunction(const TSourceLoc&amp; line, TFunction* pfnCall, bool *builtIn = 0);
-    bool executeInitializer(const TSourceLoc&amp; line, TString&amp; identifier, TPublicType&amp; pType,
</del><ins>+    const TFunction* findFunction(const TSourceLoc&amp; line, TFunction* pfnCall, int shaderVersion, bool *builtIn = 0);
+    bool executeInitializer(const TSourceLoc&amp; line, const TString&amp; identifier, TPublicType&amp; pType,
</ins><span class="cx">                             TIntermTyped* initializer, TIntermNode*&amp; intermNode, TVariable* variable = 0);
</span><span class="cx"> 
</span><ins>+    TPublicType addFullySpecifiedType(TQualifier qualifier, const TPublicType&amp; typeSpecifier);
+    TPublicType addFullySpecifiedType(TQualifier qualifier, TLayoutQualifier layoutQualifier, const TPublicType&amp; typeSpecifier);
+    TIntermAggregate* parseSingleDeclaration(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier);
+    TIntermAggregate* parseSingleArrayDeclaration(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier, const TSourceLoc&amp; indexLocation, TIntermTyped *indexExpression);
+    TIntermAggregate* parseSingleInitDeclaration(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier, const TSourceLoc&amp; initLocation, TIntermTyped *initializer);
+    TIntermAggregate* parseDeclarator(TPublicType &amp;publicType, TIntermAggregate *aggregateDeclaration, TSymbol *identifierSymbol, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier);
+    TIntermAggregate* parseArrayDeclarator(TPublicType &amp;publicType, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier, const TSourceLoc&amp; arrayLocation, TIntermNode *declaratorList, TIntermTyped *indexExpression);
+    TIntermAggregate* parseInitDeclarator(TPublicType &amp;publicType, TIntermAggregate *declaratorList, const TSourceLoc&amp; identifierLocation, const TString &amp;identifier, const TSourceLoc&amp; initLocation, TIntermTyped *initializer);
+    void parseGlobalLayoutQualifier(const TPublicType &amp;typeQualifier);
+    TFunction *addConstructorFunc(TPublicType publicType);
</ins><span class="cx">     TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, const TSourceLoc&amp;);
</span><span class="cx">     TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType&amp; type);
</span><span class="cx">     TIntermTyped* constructStruct(TIntermNode*, TType*, int, const TSourceLoc&amp;, bool subset);
</span><span class="lines">@@ -116,9 +138,22 @@
</span><span class="cx">     TIntermTyped* addConstVectorNode(TVectorFields&amp;, TIntermTyped*, const TSourceLoc&amp;);
</span><span class="cx">     TIntermTyped* addConstMatrixNode(int , TIntermTyped*, const TSourceLoc&amp;);
</span><span class="cx">     TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc&amp; line);
</span><del>-    TIntermTyped* addConstStruct(TString&amp; , TIntermTyped*, const TSourceLoc&amp;);
</del><ins>+    TIntermTyped* addConstStruct(const TString &amp;identifier, TIntermTyped *node, const TSourceLoc&amp; line);
</ins><span class="cx">     TIntermTyped* addIndexExpression(TIntermTyped *baseExpression, const TSourceLoc&amp; location, TIntermTyped *indexExpression);
</span><ins>+    TIntermTyped* addFieldSelectionExpression(TIntermTyped *baseExpression, const TSourceLoc&amp; dotLocation, const TString &amp;fieldString, const TSourceLoc&amp; fieldLocation);
</ins><span class="cx"> 
</span><ins>+    TFieldList *addStructDeclaratorList(const TPublicType&amp; typeSpecifier, TFieldList *fieldList);
+    TPublicType addStructure(const TSourceLoc&amp; structLine, const TSourceLoc&amp; nameLine, const TString *structName, TFieldList* fieldList);
+
+    TIntermAggregate* addInterfaceBlock(const TPublicType&amp; typeQualifier, const TSourceLoc&amp; nameLine, const TString&amp; blockName, TFieldList* fieldList, 
+                                        const TString* instanceName, const TSourceLoc&amp; instanceLine, TIntermTyped* arrayIndex, const TSourceLoc&amp; arrayIndexLine);
+
+    TLayoutQualifier parseLayoutQualifier(const TString &amp;qualifierType, const TSourceLoc&amp; qualifierTypeLine);
+    TLayoutQualifier parseLayoutQualifier(const TString &amp;qualifierType, const TSourceLoc&amp; qualifierTypeLine, const TString &amp;intValueString, int intValue, const TSourceLoc&amp; intValueLine);
+    TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier);
+    TPublicType joinInterpolationQualifiers(const TSourceLoc &amp;interpolationLoc, TQualifier interpolationQualifier,
+                                            const TSourceLoc &amp;storageLoc, TQualifier storageQualifier);
+
</ins><span class="cx">     // Performs an error check for embedded struct declarations.
</span><span class="cx">     // Returns true if an error was raised due to the declaration of
</span><span class="cx">     // this struct.
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorQualifierAlivecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/QualifierAlive.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/QualifierAlive.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/QualifierAlive.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool wasFound() { return found; }
</del><ins>+        bool wasFound() { return found; }
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     bool found;
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/QualifierAlive.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorRemoveTreecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/RemoveTree.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/RemoveTree.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/RemoveTree.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -8,70 +8,22 @@
</span><span class="cx"> #include &quot;compiler/translator/RemoveTree.h&quot;
</span><span class="cx"> 
</span><span class="cx"> //
</span><del>-// Code to recursively delete the intermediate tree.
</del><ins>+// Code to delete the intermediate tree.
</ins><span class="cx"> //
</span><del>-
-class RemoveTree : public TIntermTraverser
</del><ins>+void RemoveAllTreeNodes(TIntermNode* root)
</ins><span class="cx"> {
</span><del>-public:
-    RemoveTree() : TIntermTraverser(false, false, true)
-    {
-    }
</del><ins>+    std::queue&lt;TIntermNode*&gt; nodeQueue;
</ins><span class="cx"> 
</span><del>-protected:
-    void visitSymbol(TIntermSymbol*);
-    void visitConstantUnion(TIntermConstantUnion*);
-    bool visitBinary(Visit visit, TIntermBinary*);
-    bool visitUnary(Visit visit, TIntermUnary*);
-    bool visitSelection(Visit visit, TIntermSelection*);
-    bool visitAggregate(Visit visit, TIntermAggregate*);
-};
</del><ins>+    nodeQueue.push(root);
</ins><span class="cx"> 
</span><del>-void RemoveTree::visitSymbol(TIntermSymbol* node)
-{
-    delete node;
-}
</del><ins>+    while (!nodeQueue.empty())
+    {
+        TIntermNode *node = nodeQueue.front();
+        nodeQueue.pop();
</ins><span class="cx"> 
</span><del>-bool RemoveTree::visitBinary(Visit visit, TIntermBinary* node)
-{
-    delete node;
</del><ins>+        node-&gt;enqueueChildren(&amp;nodeQueue);
</ins><span class="cx"> 
</span><del>-    return true;
</del><ins>+        delete node;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RemoveTree::visitUnary(Visit visit, TIntermUnary* node)
-{
-    delete node;
-
-    return true;
-}
-
-bool RemoveTree::visitAggregate(Visit visit, TIntermAggregate* node)
-{
-    delete node;
-
-    return true;
-}
-
-bool RemoveTree::visitSelection(Visit visit, TIntermSelection* node)
-{
-    delete node;
-
-    return true;
-}
-
-void RemoveTree::visitConstantUnion(TIntermConstantUnion* node)
-{
-    delete node;
-}
-
-//
-// Entry point.
-//
-void RemoveAllTreeNodes(TIntermNode* root)
-{
-    RemoveTree it;
-
-    root-&gt;traverse(&amp;it);
-}
-
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorShHandleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShHandle.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShHandle.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShHandle.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -14,8 +14,6 @@
</span><span class="cx"> // This should not be included by driver code.
</span><span class="cx"> //
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
-
</del><span class="cx"> #include &quot;compiler/translator/BuiltInFunctionEmulator.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/ExtensionBehavior.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/HashNames.h&quot;
</span><span class="lines">@@ -24,7 +22,6 @@
</span><span class="cx"> #include &quot;compiler/translator/VariableInfo.h&quot;
</span><span class="cx"> #include &quot;third_party/compiler/ArrayBoundsClamper.h&quot;
</span><span class="cx"> 
</span><del>-class LongNameMap;
</del><span class="cx"> class TCompiler;
</span><span class="cx"> class TDependencyGraph;
</span><span class="cx"> class TranslatorHLSL;
</span><span class="lines">@@ -33,7 +30,7 @@
</span><span class="cx"> // Helper function to identify specs that are based on the WebGL spec,
</span><span class="cx"> // like the CSS Shaders spec.
</span><span class="cx"> //
</span><del>-bool isWebGLBasedSpec(ShShaderSpec spec);
</del><ins>+bool IsWebGLBasedSpec(ShShaderSpec spec);
</ins><span class="cx"> 
</span><span class="cx"> //
</span><span class="cx"> // The base class used to back handles returned to the driver.
</span><span class="lines">@@ -67,25 +64,27 @@
</span><span class="cx">                  int compileOptions);
</span><span class="cx"> 
</span><span class="cx">     // Get results of the last compilation.
</span><ins>+    int getShaderVersion() const { return shaderVersion; }
</ins><span class="cx">     TInfoSink&amp; getInfoSink() { return infoSink; }
</span><span class="cx">     const TVariableInfoList&amp; getAttribs() const { return attribs; }
</span><span class="cx">     const TVariableInfoList&amp; getUniforms() const { return uniforms; }
</span><span class="cx">     const TVariableInfoList&amp; getVaryings() const { return varyings; }
</span><del>-    int getMappedNameMaxLength() const;
</del><span class="cx"> 
</span><span class="cx">     ShHashFunction64 getHashFunction() const { return hashFunction; }
</span><span class="cx">     NameMap&amp; getNameMap() { return nameMap; }
</span><span class="cx">     TSymbolTable&amp; getSymbolTable() { return symbolTable; }
</span><ins>+    ShShaderSpec getShaderSpec() const { return shaderSpec; }
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     ShShaderType getShaderType() const { return shaderType; }
</span><del>-    ShShaderSpec getShaderSpec() const { return shaderSpec; }
</del><span class="cx">     // Initialize symbol-table with built-in symbols.
</span><span class="cx">     bool InitBuiltInSymbolTable(const ShBuiltInResources&amp; resources);
</span><span class="cx">     // Clears the results from the previous compilation.
</span><span class="cx">     void clearResults();
</span><span class="cx">     // Return true if function recursion is detected or call depth exceeded.
</span><span class="cx">     bool detectCallDepth(TIntermNode* root, TInfoSink&amp; infoSink, bool limitCallStackDepth);
</span><ins>+    // Returns true if a program has no conflicting or missing fragment outputs
+    bool validateOutputs(TIntermNode* root);
</ins><span class="cx">     // Rewrites a shader's intermediate tree according to the CSS Shaders spec.
</span><span class="cx">     void rewriteCSSShader(TIntermNode* root);
</span><span class="cx">     // Returns true if the given shader does not exceed the minimum
</span><span class="lines">@@ -93,12 +92,10 @@
</span><span class="cx">     bool validateLimitations(TIntermNode* root);
</span><span class="cx">     // Collect info for all attribs, uniforms, varyings.
</span><span class="cx">     void collectVariables(TIntermNode* root);
</span><del>-    // Map long variable names into shorter ones.
-    void mapLongVariableNames(TIntermNode* root);
</del><span class="cx">     // Translate to object code.
</span><span class="cx">     virtual void translate(TIntermNode* root) = 0;
</span><span class="cx">     // Returns true if, after applying the packing rules in the GLSL 1.017 spec
</span><del>-    // Appendix A, section 7, the shader does not use too many uniforms.
</del><ins>+    // Appendix A, section 7, the shader does not use too many uniforms or varyings.
</ins><span class="cx">     bool enforcePackingRestrictions();
</span><span class="cx">     // Insert statements to initialize varyings without static use in the beginning
</span><span class="cx">     // of main(). It is to work around a Mac driver where such varyings in a vertex
</span><span class="lines">@@ -117,7 +114,7 @@
</span><span class="cx">     // Returns true if the shader does not use sampler dependent values to affect control 
</span><span class="cx">     // flow or in operations whose time can depend on the input values.
</span><span class="cx">     bool enforceFragmentShaderTimingRestrictions(const TDependencyGraph&amp; graph);
</span><del>-    // Return true if the maximum expression complexity below the limit.
</del><ins>+    // Return true if the maximum expression complexity is below the limit.
</ins><span class="cx">     bool limitExpressionComplexity(TIntermNode* root);
</span><span class="cx">     // Get built-in extensions with default behavior.
</span><span class="cx">     const TExtensionBehavior&amp; getExtensionBehavior() const;
</span><span class="lines">@@ -151,14 +148,12 @@
</span><span class="cx">     BuiltInFunctionEmulator builtInFunctionEmulator;
</span><span class="cx"> 
</span><span class="cx">     // Results of compilation.
</span><ins>+    int shaderVersion;
</ins><span class="cx">     TInfoSink infoSink;  // Output sink.
</span><span class="cx">     TVariableInfoList attribs;  // Active attributes in the compiled shader.
</span><span class="cx">     TVariableInfoList uniforms;  // Active uniforms in the compiled shader.
</span><span class="cx">     TVariableInfoList varyings;  // Varyings in the compiled shader.
</span><span class="cx"> 
</span><del>-    // Cached copy of the ref-counted singleton.
-    LongNameMap* longNameMap;
-
</del><span class="cx">     // name hashing.
</span><span class="cx">     ShHashFunction64 hashFunction;
</span><span class="cx">     NameMap nameMap;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorShaderLangcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShaderLang.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShaderLang.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShaderLang.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -12,11 +12,13 @@
</span><span class="cx"> #include &quot;GLSLANG/ShaderLang.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;compiler/translator/InitializeDll.h&quot;
</span><del>-#include &quot;compiler/preprocessor/length_limits.h&quot;
</del><ins>+#include &quot;compiler/translator/length_limits.h&quot;
</ins><span class="cx"> #include &quot;compiler/translator/ShHandle.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/TranslatorHLSL.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/VariablePacker.h&quot;
</span><span class="cx"> 
</span><ins>+static bool isInitialized = false;
+
</ins><span class="cx"> //
</span><span class="cx"> // This is the platform independent interface between an OGL driver
</span><span class="cx"> // and the shading language compiler.
</span><span class="lines">@@ -49,8 +51,11 @@
</span><span class="cx"> //
</span><span class="cx"> int ShInitialize()
</span><span class="cx"> {
</span><del>-    static const bool kInitialized = InitProcess();
-    return kInitialized ? 1 : 0;
</del><ins>+    if (!isInitialized)
+    {
+        isInitialized = InitProcess();
+    }
+    return isInitialized ? 1 : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> //
</span><span class="lines">@@ -59,6 +64,7 @@
</span><span class="cx"> int ShFinalize()
</span><span class="cx"> {
</span><span class="cx">     DetachProcess();
</span><ins>+    isInitialized = false;
</ins><span class="cx">     return 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -83,10 +89,17 @@
</span><span class="cx">     resources-&gt;ARB_texture_rectangle = 0;
</span><span class="cx">     resources-&gt;EXT_draw_buffers = 0;
</span><span class="cx">     resources-&gt;EXT_frag_depth = 0;
</span><ins>+    resources-&gt;EXT_shader_texture_lod = 0;
</ins><span class="cx"> 
</span><span class="cx">     // Disable highp precision in fragment shader by default.
</span><span class="cx">     resources-&gt;FragmentPrecisionHigh = 0;
</span><span class="cx"> 
</span><ins>+    // GLSL ES 3.0 constants.
+    resources-&gt;MaxVertexOutputVectors = 16;
+    resources-&gt;MaxFragmentInputVectors = 15;
+    resources-&gt;MinProgramTexelOffset = -8;
+    resources-&gt;MaxProgramTexelOffset = 7;
+
</ins><span class="cx">     // Disable name hashing by default.
</span><span class="cx">     resources-&gt;HashFunction = NULL;
</span><span class="cx"> 
</span><span class="lines">@@ -174,27 +187,27 @@
</span><span class="cx">         *params = compiler-&gt;getUniforms().size();
</span><span class="cx">         break;
</span><span class="cx">     case SH_ACTIVE_UNIFORM_MAX_LENGTH:
</span><del>-        *params = 1 +  MAX_SYMBOL_NAME_LEN;
</del><ins>+        *params = 1 + GetGlobalMaxTokenSize(compiler-&gt;getShaderSpec());
</ins><span class="cx">         break;
</span><span class="cx">     case SH_ACTIVE_ATTRIBUTES:
</span><span class="cx">         *params = compiler-&gt;getAttribs().size();
</span><span class="cx">         break;
</span><span class="cx">     case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH:
</span><del>-        *params = 1 + MAX_SYMBOL_NAME_LEN;
</del><ins>+        *params = 1 + GetGlobalMaxTokenSize(compiler-&gt;getShaderSpec());
</ins><span class="cx">         break;
</span><span class="cx">     case SH_VARYINGS:
</span><span class="cx">         *params = compiler-&gt;getVaryings().size();
</span><span class="cx">         break;
</span><span class="cx">     case SH_VARYING_MAX_LENGTH:
</span><del>-        *params = 1 + MAX_SYMBOL_NAME_LEN;
</del><ins>+        *params = 1 + GetGlobalMaxTokenSize(compiler-&gt;getShaderSpec());
</ins><span class="cx">         break;
</span><span class="cx">     case SH_MAPPED_NAME_MAX_LENGTH:
</span><span class="cx">         // Use longer length than MAX_SHORTENED_IDENTIFIER_SIZE to
</span><span class="cx">         // handle array and struct dereferences.
</span><del>-        *params = 1 + MAX_SYMBOL_NAME_LEN;
</del><ins>+        *params = 1 + GetGlobalMaxTokenSize(compiler-&gt;getShaderSpec());
</ins><span class="cx">         break;
</span><span class="cx">     case SH_NAME_MAX_LENGTH:
</span><del>-        *params = 1 + MAX_SYMBOL_NAME_LEN;
</del><ins>+        *params = 1 + GetGlobalMaxTokenSize(compiler-&gt;getShaderSpec());
</ins><span class="cx">         break;
</span><span class="cx">     case SH_HASHED_NAME_MAX_LENGTH:
</span><span class="cx">         if (compiler-&gt;getHashFunction() == NULL) {
</span><span class="lines">@@ -203,12 +216,16 @@
</span><span class="cx">             // 64 bits hashing output requires 16 bytes for hex 
</span><span class="cx">             // representation.
</span><span class="cx">             const char HashedNamePrefix[] = HASHED_NAME_PREFIX;
</span><ins>+            (void)HashedNamePrefix;
</ins><span class="cx">             *params = 16 + sizeof(HashedNamePrefix);
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case SH_HASHED_NAMES_COUNT:
</span><span class="cx">         *params = compiler-&gt;getNameMap().size();
</span><span class="cx">         break;
</span><ins>+    case SH_SHADER_VERSION:
+        *params = compiler-&gt;getShaderVersion();
+        break;
</ins><span class="cx">     default: UNREACHABLE();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -306,14 +323,14 @@
</span><span class="cx">     // This size must match that queried by
</span><span class="cx">     // SH_ACTIVE_UNIFORM_MAX_LENGTH, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, SH_VARYING_MAX_LENGTH
</span><span class="cx">     // in ShGetInfo, below.
</span><del>-    size_t variableLength = 1 + MAX_SYMBOL_NAME_LEN;
</del><ins>+    size_t variableLength = 1 + GetGlobalMaxTokenSize(compiler-&gt;getShaderSpec());
</ins><span class="cx">     ASSERT(checkVariableMaxLengths(handle, variableLength));
</span><span class="cx">     strncpy(name, varInfo.name.c_str(), variableLength);
</span><span class="cx">     name[variableLength - 1] = 0;
</span><span class="cx">     if (mappedName) {
</span><span class="cx">         // This size must match that queried by
</span><span class="cx">         // SH_MAPPED_NAME_MAX_LENGTH in ShGetInfo, below.
</span><del>-        size_t maxMappedNameLength = 1 + MAX_SYMBOL_NAME_LEN;
</del><ins>+        size_t maxMappedNameLength = 1 + GetGlobalMaxTokenSize(compiler-&gt;getShaderSpec());
</ins><span class="cx">         ASSERT(checkMappedNameMaxLength(handle, maxMappedNameLength));
</span><span class="cx">         strncpy(mappedName, varInfo.mappedName.c_str(), maxMappedNameLength);
</span><span class="cx">         mappedName[maxMappedNameLength - 1] = 0;
</span><span class="lines">@@ -377,6 +394,18 @@
</span><span class="cx">     case SH_ACTIVE_UNIFORMS_ARRAY:
</span><span class="cx">         *params = (void*)&amp;translator-&gt;getUniforms();
</span><span class="cx">         break;
</span><ins>+    case SH_ACTIVE_INTERFACE_BLOCKS_ARRAY:
+        *params = (void*)&amp;translator-&gt;getInterfaceBlocks();
+        break;
+    case SH_ACTIVE_OUTPUT_VARIABLES_ARRAY:
+        *params = (void*)&amp;translator-&gt;getOutputVariables();
+        break;
+    case SH_ACTIVE_ATTRIBUTES_ARRAY:
+        *params = (void*)&amp;translator-&gt;getAttributes();
+        break;
+    case SH_ACTIVE_VARYINGS_ARRAY:
+        *params = (void*)&amp;translator-&gt;getVaryings();
+        break;
</ins><span class="cx">     default: UNREACHABLE();
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorSymbolTablecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/SymbolTable.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/SymbolTable.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/SymbolTable.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -19,11 +19,15 @@
</span><span class="cx"> #include &lt;algorithm&gt;
</span><span class="cx"> #include &lt;climits&gt;
</span><span class="cx"> 
</span><ins>+int TSymbolTableLevel::uniqueId = 0;
+
</ins><span class="cx"> TType::TType(const TPublicType &amp;p) :
</span><del>-            type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize), structure(0)
</del><ins>+            type(p.type), precision(p.precision), qualifier(p.qualifier), primarySize(p.primarySize), secondarySize(p.secondarySize), array(p.array), layoutQualifier(p.layoutQualifier), arraySize(p.arraySize),
+            interfaceBlock(0), structure(0)
</ins><span class="cx"> {
</span><del>-    if (p.userDef)
</del><ins>+    if (p.userDef) {
</ins><span class="cx">         structure = p.userDef-&gt;getStruct();
</span><ins>+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> //
</span><span class="lines">@@ -37,17 +41,45 @@
</span><span class="cx">     else if (isVector())
</span><span class="cx">         mangledName += 'v';
</span><span class="cx"> 
</span><del>-    switch (type) {
-    case EbtFloat:       mangledName += 'f';      break;
-    case EbtInt:         mangledName += 'i';      break;
-    case EbtBool:        mangledName += 'b';      break;
-    case EbtSampler2D:   mangledName += &quot;s2&quot;;     break;
-    case EbtSamplerCube: mangledName += &quot;sC&quot;;     break;
-    case EbtStruct:      mangledName += structure-&gt;mangledName(); break;
-    default:             break;
</del><ins>+    switch (type)
+    {
+      case EbtFloat:                mangledName += 'f';      break;
+      case EbtInt:                  mangledName += 'i';      break;
+      case EbtUInt:                 mangledName += 'u';      break;
+      case EbtBool:                 mangledName += 'b';      break;
+      case EbtSampler2D:            mangledName += &quot;s2&quot;;     break;
+      case EbtSampler3D:            mangledName += &quot;s3&quot;;     break;
+      case EbtSamplerCube:          mangledName += &quot;sC&quot;;     break;
+      case EbtSampler2DArray:       mangledName += &quot;s2a&quot;;    break;
+      case EbtSamplerExternalOES:   mangledName += &quot;sext&quot;;   break;
+      case EbtSampler2DRect:        mangledName += &quot;s2r&quot;;    break;
+      case EbtISampler2D:           mangledName += &quot;is2&quot;;    break;
+      case EbtISampler3D:           mangledName += &quot;is3&quot;;    break;
+      case EbtISamplerCube:         mangledName += &quot;isC&quot;;    break;
+      case EbtISampler2DArray:      mangledName += &quot;is2a&quot;;   break;
+      case EbtUSampler2D:           mangledName += &quot;us2&quot;;    break;
+      case EbtUSampler3D:           mangledName += &quot;us3&quot;;    break;
+      case EbtUSamplerCube:         mangledName += &quot;usC&quot;;    break;
+      case EbtUSampler2DArray:      mangledName += &quot;us2a&quot;;   break;
+      case EbtSampler2DShadow:      mangledName += &quot;s2s&quot;;    break;
+      case EbtSamplerCubeShadow:    mangledName += &quot;sCs&quot;;    break;
+      case EbtSampler2DArrayShadow: mangledName += &quot;s2as&quot;;   break;
+      case EbtStruct:               mangledName += structure-&gt;mangledName(); break;
+      case EbtInterfaceBlock:       mangledName += interfaceBlock-&gt;mangledName(); break;
+      default:                      UNREACHABLE();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mangledName += static_cast&lt;char&gt;('0' + getNominalSize());
</del><ins>+    if (isMatrix())
+    {
+        mangledName += static_cast&lt;char&gt;('0' + getCols());
+        mangledName += static_cast&lt;char&gt;('x');
+        mangledName += static_cast&lt;char&gt;('0' + getRows());
+    }
+    else
+    {
+        mangledName += static_cast&lt;char&gt;('0' + getNominalSize());
+    }
+
</ins><span class="cx">     if (isArray()) {
</span><span class="cx">         char buf[20];
</span><span class="cx">         snprintf(buf, sizeof(buf), &quot;%d&quot;, arraySize);
</span><span class="lines">@@ -60,14 +92,12 @@
</span><span class="cx"> 
</span><span class="cx"> size_t TType::getObjectSize() const
</span><span class="cx"> {
</span><del>-    size_t totalSize = 0;
</del><ins>+    size_t totalSize;
</ins><span class="cx"> 
</span><span class="cx">     if (getBasicType() == EbtStruct)
</span><span class="cx">         totalSize = structure-&gt;objectSize();
</span><del>-    else if (matrix)
-        totalSize = size * size;
</del><span class="cx">     else
</span><del>-        totalSize = size;
</del><ins>+        totalSize = primarySize * secondarySize;
</ins><span class="cx"> 
</span><span class="cx">     if (isArray()) {
</span><span class="cx">         size_t arraySize = getArraySize();
</span><span class="lines">@@ -90,9 +120,9 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TString TStructure::buildMangledName() const
</del><ins>+TString TFieldListCollection::buildMangledName() const
</ins><span class="cx"> {
</span><del>-    TString mangledName(&quot;struct-&quot;);
</del><ins>+    TString mangledName(mangledNamePrefix());
</ins><span class="cx">     mangledName += *mName;
</span><span class="cx">     for (size_t i = 0; i &lt; mFields-&gt;size(); ++i) {
</span><span class="cx">         mangledName += '-';
</span><span class="lines">@@ -101,7 +131,7 @@
</span><span class="cx">     return mangledName;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-size_t TStructure::calculateObjectSize() const
</del><ins>+size_t TFieldListCollection::calculateObjectSize() const
</ins><span class="cx"> {
</span><span class="cx">     size_t size = 0;
</span><span class="cx">     for (size_t i = 0; i &lt; mFields-&gt;size(); ++i) {
</span><span class="lines">@@ -124,39 +154,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> //
</span><del>-// Dump functions.
-//
-
-void TVariable::dump(TInfoSink&amp; infoSink) const
-{
-    infoSink.debug &lt;&lt; getName().c_str() &lt;&lt; &quot;: &quot; &lt;&lt; type.getQualifierString() &lt;&lt; &quot; &quot; &lt;&lt; type.getPrecisionString() &lt;&lt; &quot; &quot; &lt;&lt; type.getBasicString();
-    if (type.isArray()) {
-        infoSink.debug &lt;&lt; &quot;[0]&quot;;
-    }
-    infoSink.debug &lt;&lt; &quot;\n&quot;;
-}
-
-void TFunction::dump(TInfoSink &amp;infoSink) const
-{
-    infoSink.debug &lt;&lt; getName().c_str() &lt;&lt; &quot;: &quot; &lt;&lt;  returnType.getBasicString() &lt;&lt; &quot; &quot; &lt;&lt; getMangledName().c_str() &lt;&lt; &quot;\n&quot;;
-}
-
-void TSymbolTableLevel::dump(TInfoSink &amp;infoSink) const
-{
-    tLevel::const_iterator it;
-    for (it = level.begin(); it != level.end(); ++it)
-        (*it).second-&gt;dump(infoSink);
-}
-
-void TSymbolTable::dump(TInfoSink &amp;infoSink) const
-{
-    for (int level = currentLevel(); level &gt;= 0; --level) {
-        infoSink.debug &lt;&lt; &quot;LEVEL &quot; &lt;&lt; level &lt;&lt; &quot;\n&quot;;
-        table[level]-&gt;dump(infoSink);
-    }
-}
-
-//
</del><span class="cx"> // Functions have buried pointers to delete.
</span><span class="cx"> //
</span><span class="cx"> TFunction::~TFunction()
</span><span class="lines">@@ -202,15 +199,58 @@
</span><span class="cx"> {
</span><span class="cx">     for (tLevel::iterator it = level.begin(); it != level.end(); ++it) {
</span><span class="cx">         TSymbol* symbol = it-&gt;second;
</span><del>-        if (symbol-&gt;getName() == name)
</del><ins>+        if (symbol-&gt;getName() == name) {
</ins><span class="cx">             symbol-&gt;relateToExtension(ext);
</span><ins>+        }
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TSymbol::TSymbol(const TSymbol&amp; copyOf)
+{
+    name = NewPoolTString(copyOf.name-&gt;c_str());
+    uniqueId = copyOf.uniqueId;
+}
+
+TSymbol *TSymbolTable::find(const TString &amp;name, int shaderVersion, bool *builtIn, bool *sameScope)
+{
+    int level = currentLevel();
+    TSymbol *symbol;
+
+    do
+    {
+        if (level == ESSL3_BUILTINS &amp;&amp; shaderVersion != 300) level--;
+        if (level == ESSL1_BUILTINS &amp;&amp; shaderVersion != 100) level--;
+
+        symbol = table[level]-&gt;find(name);
+    }
+    while (symbol == 0 &amp;&amp; --level &gt;= 0);
+
+    if (builtIn)
+        *builtIn = (level &lt;= LAST_BUILTIN_LEVEL);
+    if (sameScope)
+        *sameScope = (level == currentLevel());
+
+    return symbol;
+}
+
+TSymbol *TSymbolTable::findBuiltIn(const TString &amp;name, int shaderVersion)
+{
+    for (int level = LAST_BUILTIN_LEVEL; level &gt;= 0; level--)
+    {
+        if (level == ESSL3_BUILTINS &amp;&amp; shaderVersion != 300) level--;
+        if (level == ESSL1_BUILTINS &amp;&amp; shaderVersion != 100) level--;
+
+        TSymbol *symbol = table[level]-&gt;find(name);
+
+        if (symbol)
+            return symbol;
+    }
+
+    return 0;
+}
+
</ins><span class="cx"> TSymbolTable::~TSymbolTable()
</span><span class="cx"> {
</span><del>-    for (size_t i = 0; i &lt; table.size(); ++i)
-        delete table[i];
-    for (size_t i = 0; i &lt; precisionStack.size(); ++i)
-        delete precisionStack[i];
</del><ins>+    while (table.size() &gt; 0)
+        pop();
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorSymbolTableh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/SymbolTable.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/SymbolTable.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/SymbolTable.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -51,7 +51,6 @@
</span><span class="cx">     virtual bool isVariable() const { return false; }
</span><span class="cx">     void setUniqueId(int id) { uniqueId = id; }
</span><span class="cx">     int getUniqueId() const { return uniqueId; }
</span><del>-    virtual void dump(TInfoSink &amp;infoSink) const = 0;
</del><span class="cx">     void relateToExtension(const TString&amp; ext) { extension = ext; }
</span><span class="cx">     const TString&amp; getExtension() const { return extension; }
</span><span class="cx"> 
</span><span class="lines">@@ -83,8 +82,6 @@
</span><span class="cx">     bool isUserType() const { return userType; }
</span><span class="cx">     void setQualifier(TQualifier qualifier) { type.setQualifier(qualifier); }
</span><span class="cx"> 
</span><del>-    virtual void dump(TInfoSink &amp;infoSink) const;
-
</del><span class="cx">     ConstantUnion* getConstPointer()
</span><span class="cx">     { 
</span><span class="cx">         if (!unionArray)
</span><span class="lines">@@ -120,7 +117,7 @@
</span><span class="cx"> //
</span><span class="cx"> struct TParameter {
</span><span class="cx">     TString *name;
</span><del>-    TType* type;
</del><ins>+    TType *type;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> //
</span><span class="lines">@@ -166,8 +163,6 @@
</span><span class="cx">     size_t getParamCount() const { return parameters.size(); }  
</span><span class="cx">     const TParameter&amp; getParam(size_t i) const { return parameters[i]; }
</span><span class="cx"> 
</span><del>-    virtual void dump(TInfoSink &amp;infoSink) const;
-
</del><span class="cx"> private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TFunction);
</span><span class="cx"> 
</span><span class="lines">@@ -179,7 +174,19 @@
</span><span class="cx">     bool defined;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+//
+// Interface block name sub-symbol
+//
+class TInterfaceBlockName : public TSymbol
+{
+public:
+    TInterfaceBlockName(const TString *name)
+        : TSymbol(name)
+    {}
</ins><span class="cx"> 
</span><ins>+    virtual ~TInterfaceBlockName() {}
+};
+
</ins><span class="cx"> class TSymbolTableLevel {
</span><span class="cx"> public:
</span><span class="cx">     typedef TMap&lt;TString, TSymbol*&gt; tLevel;
</span><span class="lines">@@ -192,6 +199,8 @@
</span><span class="cx"> 
</span><span class="cx">     bool insert(const TString &amp;name, TSymbol &amp;symbol)
</span><span class="cx">     {
</span><ins>+        symbol.setUniqueId(++uniqueId);
+
</ins><span class="cx">         //
</span><span class="cx">         // returning true means symbol was added to the table
</span><span class="cx">         //
</span><span class="lines">@@ -214,27 +223,26 @@
</span><span class="cx">             return (*it).second;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    const_iterator begin() const
-    {
-        return level.begin();
-    }
-
-    const_iterator end() const
-    {
-        return level.end();
-    }
-
</del><span class="cx">     void relateToOperator(const char* name, TOperator op);
</span><span class="cx">     void relateToExtension(const char* name, const TString&amp; ext);
</span><del>-    void dump(TInfoSink &amp;infoSink) const;
</del><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     tLevel level;
</span><ins>+    static int uniqueId;     // for unique identification in code generation
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum ESymbolLevel
+{
+    COMMON_BUILTINS = 0,
+    ESSL1_BUILTINS = 1,
+    ESSL3_BUILTINS = 2,
+    LAST_BUILTIN_LEVEL = ESSL3_BUILTINS,
+    GLOBAL_LEVEL = 3
+};
+
</ins><span class="cx"> class TSymbolTable {
</span><span class="cx"> public:
</span><del>-    TSymbolTable() : uniqueId(0)
</del><ins>+    TSymbolTable()
</ins><span class="cx">     {
</span><span class="cx">         //
</span><span class="cx">         // The symbol table cannot be used until push() is called, but
</span><span class="lines">@@ -242,6 +250,7 @@
</span><span class="cx">         // that the symbol table has not been preloaded with built-ins.
</span><span class="cx">         //
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     ~TSymbolTable();
</span><span class="cx"> 
</span><span class="cx">     //
</span><span class="lines">@@ -249,9 +258,9 @@
</span><span class="cx">     // 'push' calls, so that built-ins are at level 0 and the shader
</span><span class="cx">     // globals are at level 1.
</span><span class="cx">     //
</span><del>-    bool isEmpty() { return table.size() == 0; }
-    bool atBuiltInLevel() { return table.size() == 1; }
-    bool atGlobalLevel() { return table.size() &lt;= 2; }
</del><ins>+    bool isEmpty() { return table.empty(); }
+    bool atBuiltInLevel() { return currentLevel() &lt;= LAST_BUILTIN_LEVEL; }
+    bool atGlobalLevel() { return currentLevel() &lt;= GLOBAL_LEVEL; }
</ins><span class="cx">     void push()
</span><span class="cx">     {
</span><span class="cx">         table.push_back(new TSymbolTableLevel);
</span><span class="lines">@@ -267,79 +276,110 @@
</span><span class="cx">         precisionStack.pop_back();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool insert(TSymbol&amp; symbol)
</del><ins>+    bool declare(TSymbol &amp;symbol)
</ins><span class="cx">     {
</span><del>-        symbol.setUniqueId(++uniqueId);
-        return table[currentLevel()]-&gt;insert(symbol);
</del><ins>+        return insert(currentLevel(), symbol);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool insertConstInt(const char *name, int value)
</del><ins>+    bool insert(ESymbolLevel level, TSymbol &amp;symbol)
</ins><span class="cx">     {
</span><ins>+        return table[level]-&gt;insert(symbol);
+    }
+
+    bool insertConstInt(ESymbolLevel level, const char *name, int value)
+    {
</ins><span class="cx">         TVariable *constant = new TVariable(NewPoolTString(name), TType(EbtInt, EbpUndefined, EvqConst, 1));
</span><span class="cx">         constant-&gt;getConstPointer()-&gt;setIConst(value);
</span><del>-        return insert(*constant);
</del><ins>+        return insert(level, *constant);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool insertBuiltIn(TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0)
</del><ins>+    void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0, TType *ptype5 = 0)
</ins><span class="cx">     {
</span><ins>+        if (ptype1-&gt;getBasicType() == EbtGSampler2D)
+        {
+            bool gvec4 = (rvalue-&gt;getBasicType() == EbtGVec4);
+            insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2D), ptype2, ptype3, ptype4, ptype5);
+            insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2D), ptype2, ptype3, ptype4, ptype5);
+            insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2D), ptype2, ptype3, ptype4, ptype5);
+            return;
+        }
+        else if (ptype1-&gt;getBasicType() == EbtGSampler3D)
+        {
+            bool gvec4 = (rvalue-&gt;getBasicType() == EbtGVec4);
+            insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler3D), ptype2, ptype3, ptype4, ptype5);
+            insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler3D), ptype2, ptype3, ptype4, ptype5);
+            insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler3D), ptype2, ptype3, ptype4, ptype5);
+            return;
+        }
+        else if (ptype1-&gt;getBasicType() == EbtGSamplerCube)
+        {
+            bool gvec4 = (rvalue-&gt;getBasicType() == EbtGVec4);
+            insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSamplerCube), ptype2, ptype3, ptype4, ptype5);
+            insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISamplerCube), ptype2, ptype3, ptype4, ptype5);
+            insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSamplerCube), ptype2, ptype3, ptype4, ptype5);
+            return;
+        }
+        else if (ptype1-&gt;getBasicType() == EbtGSampler2DArray)
+        {
+            bool gvec4 = (rvalue-&gt;getBasicType() == EbtGVec4);
+            insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2DArray), ptype2, ptype3, ptype4, ptype5);
+            insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2DArray), ptype2, ptype3, ptype4, ptype5);
+            insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2DArray), ptype2, ptype3, ptype4, ptype5);
+            return;
+        }
+
</ins><span class="cx">         TFunction *function = new TFunction(NewPoolTString(name), *rvalue);
</span><span class="cx"> 
</span><span class="cx">         TParameter param1 = {NULL, ptype1};
</span><span class="cx">         function-&gt;addParameter(param1);
</span><span class="cx"> 
</span><del>-        if(ptype2)
</del><ins>+        if (ptype2)
</ins><span class="cx">         {
</span><span class="cx">             TParameter param2 = {NULL, ptype2};
</span><span class="cx">             function-&gt;addParameter(param2);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if(ptype3)
</del><ins>+        if (ptype3)
</ins><span class="cx">         {
</span><span class="cx">             TParameter param3 = {NULL, ptype3};
</span><span class="cx">             function-&gt;addParameter(param3);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return insert(*function);
-    }
</del><ins>+        if (ptype4)
+        {
+            TParameter param4 = {NULL, ptype4};
+            function-&gt;addParameter(param4);
+        }
</ins><span class="cx"> 
</span><del>-    TSymbol* find(const TString&amp; name, bool* builtIn = 0, bool *sameScope = 0) 
-    {
-        int level = currentLevel();
-        TSymbol* symbol;
-        do {
-            symbol = table[level]-&gt;find(name);
-            --level;
-        } while (symbol == 0 &amp;&amp; level &gt;= 0);
-        level++;
-        if (builtIn)
-            *builtIn = level == 0;
-        if (sameScope)
-            *sameScope = level == currentLevel();
-        return symbol;
-    }
</del><ins>+        if (ptype5)
+        {
+            TParameter param5 = {NULL, ptype5};
+            function-&gt;addParameter(param5);
+        }
</ins><span class="cx"> 
</span><del>-    TSymbol* findBuiltIn(const TString &amp;name)
-    {
-        return table[0]-&gt;find(name);
</del><ins>+        insert(level, *function);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    TSymbolTableLevel* getOuterLevel() {
-        assert(table.size() &gt;= 2);
</del><ins>+    TSymbol *find(const TString &amp;name, int shaderVersion, bool *builtIn = NULL, bool *sameScope = NULL);
+    TSymbol *findBuiltIn(const TString &amp;name, int shaderVersion);
+    
+    TSymbolTableLevel *getOuterLevel() {
+        assert(currentLevel() &gt;= 1);
</ins><span class="cx">         return table[currentLevel() - 1];
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void relateToOperator(const char* name, TOperator op) {
-        table[0]-&gt;relateToOperator(name, op);
</del><ins>+    void relateToOperator(ESymbolLevel level, const char* name, TOperator op) {
+        table[level]-&gt;relateToOperator(name, op);
</ins><span class="cx">     }
</span><del>-    void relateToExtension(const char* name, const TString&amp; ext) {
-        table[0]-&gt;relateToExtension(name, ext);
</del><ins>+    void relateToExtension(ESymbolLevel level, const char* name, const TString&amp; ext) {
+        table[level]-&gt;relateToExtension(name, ext);
</ins><span class="cx">     }
</span><span class="cx">     void dump(TInfoSink &amp;infoSink) const;
</span><span class="cx"> 
</span><span class="cx">     bool setDefaultPrecision(const TPublicType&amp; type, TPrecision prec) {
</span><span class="cx">         if (!supportsPrecision(type.type))
</span><span class="cx">             return false;
</span><del>-        if (type.size != 1 || type.matrix || type.array)
</del><ins>+        if (type.isAggregate())
</ins><span class="cx">             return false; // Not allowed to set for aggregate types
</span><span class="cx">         int indexOfLastElement = static_cast&lt;int&gt;(precisionStack.size()) - 1;
</span><span class="cx">         (*precisionStack[indexOfLastElement])[type.type] = prec; // Uses map operator [], overwrites the current value
</span><span class="lines">@@ -347,15 +387,20 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Searches down the precisionStack for a precision qualifier for the specified TBasicType
</span><del>-    TPrecision getDefaultPrecision(TBasicType type) {
</del><ins>+    TPrecision getDefaultPrecision( TBasicType type){
+
</ins><span class="cx">         if (!supportsPrecision(type))
</span><span class="cx">             return EbpUndefined;
</span><ins>+
+        // unsigned integers use the same precision as signed
+        TBasicType baseType = (type == EbtUInt) ? EbtInt : type;
+
</ins><span class="cx">         int level = static_cast&lt;int&gt;(precisionStack.size()) - 1;
</span><span class="cx">         assert(level &gt;= 0); // Just to be safe. Should not happen.
</span><span class="cx">         PrecisionStackLevel::iterator it;
</span><span class="cx">         TPrecision prec = EbpUndefined; // If we dont find anything we return this. Should we error check this?
</span><span class="cx">         while (level &gt;= 0) {
</span><del>-            it = precisionStack[level]-&gt;find(type);
</del><ins>+            it = precisionStack[level]-&gt;find(baseType);
</ins><span class="cx">             if (it != precisionStack[level]-&gt;end()) {
</span><span class="cx">                 prec = (*it).second;
</span><span class="cx">                 break;
</span><span class="lines">@@ -366,17 +411,16 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    int currentLevel() const { return static_cast&lt;int&gt;(table.size()) - 1; }
</del><ins>+    ESymbolLevel currentLevel() const { return static_cast&lt;ESymbolLevel&gt;(table.size() - 1); }
</ins><span class="cx"> 
</span><span class="cx">     bool supportsPrecision(TBasicType type) {
</span><span class="cx">       // Only supports precision for int, float, and sampler types.
</span><del>-      return type == EbtFloat || type == EbtInt || IsSampler(type);
</del><ins>+      return type == EbtFloat || type == EbtInt || type == EbtUInt || IsSampler(type);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    int uniqueId;     // for unique identification in code generation
</del><span class="cx">     std::vector&lt;TSymbolTableLevel*&gt; table;
</span><span class="cx">     typedef TMap&lt;TBasicType, TPrecision&gt; PrecisionStackLevel;
</span><del>-    std::vector&lt;PrecisionStackLevel*&gt; precisionStack;
</del><ins>+    std::vector&lt; PrecisionStackLevel*&gt; precisionStack;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif // _SYMBOL_TABLE_INCLUDED_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorESSLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorESSL.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorESSL.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorESSL.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx">     getArrayBoundsClamper().OutputClampingFunctionDefinition(sink);
</span><span class="cx"> 
</span><span class="cx">     // Write translated shader.
</span><del>-    TOutputESSL outputESSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable());
</del><ins>+    TOutputESSL outputESSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion());
</ins><span class="cx">     root-&gt;traverse(&amp;outputESSL);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorGLSLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorGLSL.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorGLSL.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorGLSL.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -31,6 +31,9 @@
</span><span class="cx">     // Write GLSL version.
</span><span class="cx">     writeVersion(getShaderType(), root, sink);
</span><span class="cx"> 
</span><ins>+    // Write extension behaviour as needed
+    writeExtensionBehavior();
+
</ins><span class="cx">     // Write emulated built-in functions if needed.
</span><span class="cx">     getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
</span><span class="cx">         sink, false);
</span><span class="lines">@@ -39,6 +42,23 @@
</span><span class="cx">     getArrayBoundsClamper().OutputClampingFunctionDefinition(sink);
</span><span class="cx"> 
</span><span class="cx">     // Write translated shader.
</span><del>-    TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable());
</del><ins>+    TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion());
</ins><span class="cx">     root-&gt;traverse(&amp;outputGLSL);
</span><span class="cx"> }
</span><ins>+
+void TranslatorGLSL::writeExtensionBehavior() {
+    TInfoSinkBase&amp; sink = getInfoSink().obj;
+    const TExtensionBehavior&amp; extensionBehavior = getExtensionBehavior();
+    for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
+         iter != extensionBehavior.end(); ++iter) {
+        if (iter-&gt;second == EBhUndefined)
+            continue;
+
+        // For GLSL output, we don't need to emit most extensions explicitly,
+        // but some we need to translate.
+        if (iter-&gt;first == &quot;GL_EXT_shader_texture_lod&quot;) {
+            sink &lt;&lt; &quot;#extension GL_ARB_shader_texture_lod : &quot;
+                 &lt;&lt; getBehaviorString(iter-&gt;second) &lt;&lt; &quot;\n&quot;;
+        }
+    }
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorGLSLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorGLSL.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorGLSL.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorGLSL.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -15,6 +15,9 @@
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     virtual void translate(TIntermNode* root);
</span><ins>+
+private:
+    void writeExtensionBehavior();
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif  // COMPILER_TRANSLATORGLSL_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorHLSLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorHLSL.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorHLSL.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorHLSL.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -20,5 +20,10 @@
</span><span class="cx">     sh::OutputHLSL outputHLSL(parseContext, getResources(), mOutputType);
</span><span class="cx"> 
</span><span class="cx">     outputHLSL.output();
</span><del>-    mActiveUniforms = outputHLSL.getUniforms();
</del><ins>+
+    mActiveUniforms         = outputHLSL.getUniforms();
+    mActiveInterfaceBlocks  = outputHLSL.getInterfaceBlocks();
+    mActiveOutputVariables  = outputHLSL.getOutputVariables();
+    mActiveAttributes       = outputHLSL.getAttributes();
+    mActiveVaryings         = outputHLSL.getVaryings();
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorTranslatorHLSLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorHLSL.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorHLSL.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorHLSL.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -8,19 +8,27 @@
</span><span class="cx"> #define COMPILER_TRANSLATORHLSL_H_
</span><span class="cx"> 
</span><span class="cx"> #include &quot;compiler/translator/ShHandle.h&quot;
</span><del>-#include &quot;compiler/translator/Uniform.h&quot;
</del><ins>+#include &quot;common/shadervars.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> class TranslatorHLSL : public TCompiler {
</span><span class="cx"> public:
</span><span class="cx">     TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
</span><span class="cx"> 
</span><span class="cx">     virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
</span><del>-    const sh::ActiveUniforms &amp;getUniforms() { return mActiveUniforms; }
</del><ins>+    const std::vector&lt;gl::Uniform&gt; &amp;getUniforms() { return mActiveUniforms; }
+    const std::vector&lt;gl::InterfaceBlock&gt; &amp;getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
+    const std::vector&lt;gl::Attribute&gt; &amp;getOutputVariables() { return mActiveOutputVariables; }
+    const std::vector&lt;gl::Attribute&gt; &amp;getAttributes() { return mActiveAttributes; }
+    const std::vector&lt;gl::Varying&gt; &amp;getVaryings() { return mActiveVaryings; }
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     virtual void translate(TIntermNode* root);
</span><span class="cx"> 
</span><del>-    sh::ActiveUniforms mActiveUniforms;
</del><ins>+    std::vector&lt;gl::Uniform&gt; mActiveUniforms;
+    std::vector&lt;gl::InterfaceBlock&gt; mActiveInterfaceBlocks;
+    std::vector&lt;gl::Attribute&gt; mActiveOutputVariables;
+    std::vector&lt;gl::Attribute&gt; mActiveAttributes;
+    std::vector&lt;gl::Varying&gt; mActiveVaryings;
</ins><span class="cx">     ShShaderOutput mOutputType;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorTypesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Types.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Types.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Types.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> {
</span><span class="cx"> public:
</span><span class="cx">     POOL_ALLOCATOR_NEW_DELETE();
</span><del>-    TField(TType* type, TString* name) : mType(type), mName(name) {}
</del><ins>+    TField(TType* type, TString* name, const TSourceLoc&amp; line) : mType(type), mName(name), mLine(line) {}
</ins><span class="cx"> 
</span><span class="cx">     // TODO(alokp): We should only return const type.
</span><span class="cx">     // Fix it by tweaking grammar.
</span><span class="lines">@@ -28,11 +28,13 @@
</span><span class="cx">     const TType* type() const { return mType; }
</span><span class="cx"> 
</span><span class="cx">     const TString&amp; name() const { return *mName; }
</span><ins>+    const TSourceLoc&amp; line() const { return mLine; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TField);
</span><span class="cx">     TType* mType;
</span><span class="cx">     TString* mName;
</span><ins>+    TSourceLoc mLine;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef TVector&lt;TField*&gt; TFieldList;
</span><span class="lines">@@ -42,17 +44,9 @@
</span><span class="cx">     return new(memory) TFieldList;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-class TStructure
</del><ins>+class TFieldListCollection
</ins><span class="cx"> {
</span><span class="cx"> public:
</span><del>-    POOL_ALLOCATOR_NEW_DELETE();
-    TStructure(TString* name, TFieldList* fields)
-        : mName(name),
-          mFields(fields),
-          mObjectSize(0),
-          mDeepestNesting(0) {
-    }
-
</del><span class="cx">     const TString&amp; name() const { return *mName; }
</span><span class="cx">     const TFieldList&amp; fields() const { return *mFields; }
</span><span class="cx"> 
</span><span class="lines">@@ -66,6 +60,34 @@
</span><span class="cx">             mObjectSize = calculateObjectSize();
</span><span class="cx">         return mObjectSize;
</span><span class="cx">     };
</span><ins>+
+protected:
+    TFieldListCollection(const TString* name, TFieldList* fields)
+        : mName(name),
+          mFields(fields),
+          mObjectSize(0) {
+    }
+    TString buildMangledName() const;
+    size_t calculateObjectSize() const;
+    virtual TString mangledNamePrefix() const = 0;
+
+    const TString* mName;
+    TFieldList* mFields;
+
+    mutable TString mMangledName;
+    mutable size_t mObjectSize;
+};
+
+// May also represent interface blocks
+class TStructure : public TFieldListCollection
+{
+public:
+    POOL_ALLOCATOR_NEW_DELETE();
+    TStructure(const TString* name, TFieldList* fields)
+        : TFieldListCollection(name, fields),
+          mDeepestNesting(0) {
+    }
+
</ins><span class="cx">     int deepestNesting() const {
</span><span class="cx">         if (mDeepestNesting == 0)
</span><span class="cx">             mDeepestNesting = calculateDeepestNesting();
</span><span class="lines">@@ -75,18 +97,41 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TStructure);
</span><del>-    TString buildMangledName() const;
-    size_t calculateObjectSize() const;
</del><ins>+    virtual TString mangledNamePrefix() const { return &quot;struct-&quot;; }
</ins><span class="cx">     int calculateDeepestNesting() const;
</span><span class="cx"> 
</span><del>-    TString* mName;
-    TFieldList* mFields;
-
-    mutable TString mMangledName;
-    mutable size_t mObjectSize;
</del><span class="cx">     mutable int mDeepestNesting;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class TInterfaceBlock : public TFieldListCollection
+{
+public:
+    POOL_ALLOCATOR_NEW_DELETE();
+    TInterfaceBlock(const TString* name, TFieldList* fields, const TString* instanceName, int arraySize, const TLayoutQualifier&amp; layoutQualifier)
+        : TFieldListCollection(name, fields),
+          mInstanceName(instanceName),
+          mArraySize(arraySize),
+          mBlockStorage(layoutQualifier.blockStorage),
+          mMatrixPacking(layoutQualifier.matrixPacking) {
+    }
+
+    const TString&amp; instanceName() const { return *mInstanceName; }
+    bool hasInstanceName() const { return mInstanceName != NULL; }
+    bool isArray() const { return mArraySize &gt; 0; }
+    int arraySize() const { return mArraySize; }
+    TLayoutBlockStorage blockStorage() const { return mBlockStorage; }
+    TLayoutMatrixPacking matrixPacking() const { return mMatrixPacking; }
+
+private:
+    DISALLOW_COPY_AND_ASSIGN(TInterfaceBlock);
+    virtual TString mangledNamePrefix() const { return &quot;iblock-&quot;; }
+
+    const TString* mInstanceName; // for interface block instance names
+    int mArraySize; // 0 if not an array
+    TLayoutBlockStorage mBlockStorage;
+    TLayoutMatrixPacking mMatrixPacking;
+};
+
</ins><span class="cx"> //
</span><span class="cx"> // Base class for things that have a type.
</span><span class="cx"> //
</span><span class="lines">@@ -95,15 +140,27 @@
</span><span class="cx"> public:
</span><span class="cx">     POOL_ALLOCATOR_NEW_DELETE();
</span><span class="cx">     TType() {}
</span><del>-    TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, unsigned char s = 1, bool m = false, bool a = false) :
-            type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0), structure(0)
</del><ins>+    TType(TBasicType t, unsigned char ps = 1, unsigned char ss = 1) :
+            type(t), precision(EbpUndefined), qualifier(EvqGlobal), layoutQualifier(TLayoutQualifier::create()), primarySize(ps), secondarySize(ss), array(false), arraySize(0),
+            interfaceBlock(0), structure(0)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><ins>+    TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, unsigned char ps = 1, unsigned char ss = 1, bool a = false) :
+            type(t), precision(p), qualifier(q), layoutQualifier(TLayoutQualifier::create()), primarySize(ps), secondarySize(ss), array(a), arraySize(0),
+            interfaceBlock(0), structure(0)
+    {
+    }
</ins><span class="cx">     explicit TType(const TPublicType &amp;p);
</span><span class="cx">     TType(TStructure* userDef, TPrecision p = EbpUndefined) :
</span><del>-            type(EbtStruct), precision(p), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0), structure(userDef)
</del><ins>+            type(EbtStruct), precision(p), qualifier(EvqTemporary), layoutQualifier(TLayoutQualifier::create()), primarySize(1), secondarySize(1), array(false), arraySize(0),
+            interfaceBlock(0), structure(userDef)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><ins>+    TType(TInterfaceBlock* interfaceBlockIn, TQualifier qualifierIn, TLayoutQualifier layoutQualifierIn, int arraySizeIn) :
+            type(EbtInterfaceBlock), precision(EbpUndefined), qualifier(qualifierIn), layoutQualifier(layoutQualifierIn), primarySize(1), secondarySize(1), array(arraySizeIn &gt; 0), arraySize(arraySizeIn),
+            interfaceBlock(interfaceBlockIn), structure(0)
+    {
+    }
</ins><span class="cx"> 
</span><span class="cx">     TBasicType getBasicType() const { return type; }
</span><span class="cx">     void setBasicType(TBasicType t) { type = t; }
</span><span class="lines">@@ -114,81 +171,56 @@
</span><span class="cx">     TQualifier getQualifier() const { return qualifier; }
</span><span class="cx">     void setQualifier(TQualifier q) { qualifier = q; }
</span><span class="cx"> 
</span><del>-    // One-dimensional size of single instance type
-    int getNominalSize() const { return size; }
-    void setNominalSize(unsigned char s) { size = s; }
</del><ins>+    TLayoutQualifier getLayoutQualifier() const { return layoutQualifier; }
+    void setLayoutQualifier(TLayoutQualifier lq) { layoutQualifier = lq; }
+
+    int getNominalSize() const { return primarySize; }
+    int getSecondarySize() const { return secondarySize; }
+    int getCols() const { ASSERT(isMatrix()); return primarySize; }
+    int getRows() const { ASSERT(isMatrix()); return secondarySize; }
+    void setPrimarySize(unsigned char ps) { primarySize = ps; }
+    void setSecondarySize(unsigned char ss) { secondarySize = ss; }
+
</ins><span class="cx">     // Full size of single instance of type
</span><span class="cx">     size_t getObjectSize() const;
</span><span class="cx"> 
</span><del>-    int elementRegisterCount() const
-    {
-        if (structure)
-        {
-            const TFieldList &amp;fields = getStruct()-&gt;fields();
-            int registerCount = 0;
-
-            for (size_t i = 0; i &lt; fields.size(); i++)
-            {
-                registerCount += fields[i]-&gt;type()-&gt;totalRegisterCount();
-            }
-
-            return registerCount;
-        }
-        else if (isMatrix())
-        {
-            return getNominalSize();
-        }
-        else
-        {
-            return 1;
-        }
-    }
-
-    int totalRegisterCount() const
-    {
-        if (array)
-        {
-            return arraySize * elementRegisterCount();
-        }
-        else
-        {
-            return elementRegisterCount();
-        }
-    }
-
-    bool isMatrix() const { return matrix ? true : false; }
-    void setMatrix(bool m) { matrix = m; }
-
</del><ins>+    bool isMatrix() const { return primarySize &gt; 1 &amp;&amp; secondarySize &gt; 1; }
</ins><span class="cx">     bool isArray() const  { return array ? true : false; }
</span><span class="cx">     int getArraySize() const { return arraySize; }
</span><span class="cx">     void setArraySize(int s) { array = true; arraySize = s; }
</span><span class="cx">     void clearArrayness() { array = false; arraySize = 0; }
</span><span class="cx"> 
</span><del>-    bool isVector() const { return size &gt; 1 &amp;&amp; !matrix; }
-    bool isScalar() const { return size == 1 &amp;&amp; !matrix &amp;&amp; !structure; }
</del><ins>+    TInterfaceBlock* getInterfaceBlock() const { return interfaceBlock; }
+    void setInterfaceBlock(TInterfaceBlock* interfaceBlockIn) { interfaceBlock = interfaceBlockIn; }
+    bool isInterfaceBlock() const { return type == EbtInterfaceBlock; }
</ins><span class="cx"> 
</span><ins>+    bool isVector() const { return primarySize &gt; 1 &amp;&amp; secondarySize == 1; }
+    bool isScalar() const { return primarySize == 1 &amp;&amp; secondarySize == 1 &amp;&amp; !structure; }
+    bool isScalarInt() const { return isScalar() &amp;&amp; (type == EbtInt || type == EbtUInt); }
+
</ins><span class="cx">     TStructure* getStruct() const { return structure; }
</span><span class="cx">     void setStruct(TStructure* s) { structure = s; }
</span><span class="cx"> 
</span><del>-    const TString&amp; getMangledName() const {
</del><ins>+    const TString&amp; getMangledName() {
</ins><span class="cx">         if (mangled.empty()) {
</span><span class="cx">             mangled = buildMangledName();
</span><span class="cx">             mangled += ';';
</span><span class="cx">         }
</span><ins>+
</ins><span class="cx">         return mangled;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool sameElementType(const TType&amp; right) const {
</span><del>-        return      type == right.type   &amp;&amp;
-                    size == right.size   &amp;&amp;
-                  matrix == right.matrix &amp;&amp;
</del><ins>+        return      type == right.type          &amp;&amp;
+             primarySize == right.primarySize   &amp;&amp;
+           secondarySize == right.secondarySize &amp;&amp;
</ins><span class="cx">                structure == right.structure;
</span><span class="cx">     }
</span><span class="cx">     bool operator==(const TType&amp; right) const {
</span><del>-        return      type == right.type   &amp;&amp;
-                    size == right.size   &amp;&amp;
-                  matrix == right.matrix &amp;&amp;
-                   array == right.array  &amp;&amp; (!array || arraySize == right.arraySize) &amp;&amp;
</del><ins>+        return      type == right.type          &amp;&amp;
+             primarySize == right.primarySize   &amp;&amp;
+           secondarySize == right.secondarySize &amp;&amp;
+                   array == right.array &amp;&amp; (!array || arraySize == right.arraySize) &amp;&amp;
</ins><span class="cx">                structure == right.structure;
</span><span class="cx">         // don't check the qualifier, it's not ever what's being sought after
</span><span class="cx">     }
</span><span class="lines">@@ -197,8 +229,8 @@
</span><span class="cx">     }
</span><span class="cx">     bool operator&lt;(const TType&amp; right) const {
</span><span class="cx">         if (type != right.type) return type &lt; right.type;
</span><del>-        if (size != right.size) return size &lt; right.size;
-        if (matrix != right.matrix) return matrix &lt; right.matrix;
</del><ins>+        if (primarySize != right.primarySize) return primarySize &lt; right.primarySize;
+        if (secondarySize != right.secondarySize) return secondarySize &lt; right.secondarySize;
</ins><span class="cx">         if (array != right.array) return array &lt; right.array;
</span><span class="cx">         if (arraySize != right.arraySize) return arraySize &lt; right.arraySize;
</span><span class="cx">         if (structure != right.structure) return structure &lt; right.structure;
</span><span class="lines">@@ -231,19 +263,26 @@
</span><span class="cx">         return structure ? structure-&gt;containsArrays() : false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-private:
</del><ins>+protected:
</ins><span class="cx">     TString buildMangledName() const;
</span><ins>+    size_t getStructSize() const;
+    void computeDeepestStructNesting();
</ins><span class="cx"> 
</span><span class="cx">     TBasicType type;
</span><span class="cx">     TPrecision precision;
</span><span class="cx">     TQualifier qualifier;
</span><del>-    unsigned char size;
-    bool matrix;
</del><ins>+    TLayoutQualifier layoutQualifier;
+    unsigned char primarySize; // size of vector or cols matrix
+    unsigned char secondarySize; // rows of a matrix
</ins><span class="cx">     bool array;
</span><span class="cx">     int arraySize;
</span><span class="cx"> 
</span><del>-    TStructure* structure;      // 0 unless this is a struct
</del><ins>+    // 0 unless this is an interface block, or interface block member variable
+    TInterfaceBlock* interfaceBlock;
</ins><span class="cx"> 
</span><ins>+    // 0 unless this is a struct
+    TStructure* structure;
+
</ins><span class="cx">     mutable TString mangled;
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -259,10 +298,11 @@
</span><span class="cx"> struct TPublicType
</span><span class="cx"> {
</span><span class="cx">     TBasicType type;
</span><ins>+    TLayoutQualifier layoutQualifier;
</ins><span class="cx">     TQualifier qualifier;
</span><span class="cx">     TPrecision precision;
</span><del>-    unsigned char size;          // size of vector or matrix, not size of array
-    bool matrix;
</del><ins>+    unsigned char primarySize;          // size of vector or cols of matrix
+    unsigned char secondarySize;        // rows of matrix
</ins><span class="cx">     bool array;
</span><span class="cx">     int arraySize;
</span><span class="cx">     TType* userDef;
</span><span class="lines">@@ -271,22 +311,29 @@
</span><span class="cx">     void setBasic(TBasicType bt, TQualifier q, const TSourceLoc&amp; ln)
</span><span class="cx">     {
</span><span class="cx">         type = bt;
</span><ins>+        layoutQualifier = TLayoutQualifier::create();
</ins><span class="cx">         qualifier = q;
</span><span class="cx">         precision = EbpUndefined;
</span><del>-        size = 1;
-        matrix = false;
</del><ins>+        primarySize = 1;
+        secondarySize = 1;
</ins><span class="cx">         array = false;
</span><span class="cx">         arraySize = 0;
</span><span class="cx">         userDef = 0;
</span><span class="cx">         line = ln;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void setAggregate(unsigned char s, bool m = false)
</del><ins>+    void setAggregate(unsigned char size)
</ins><span class="cx">     {
</span><del>-        size = s;
-        matrix = m;
</del><ins>+        primarySize = size;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void setMatrix(unsigned char c, unsigned char r)
+    {
+        ASSERT(c &gt; 1 &amp;&amp; r &gt; 1 &amp;&amp; c &lt;= 4 &amp;&amp; r &lt;= 4);
+        primarySize = c;
+        secondarySize = r;
+    }
+
</ins><span class="cx">     void setArray(bool a, int s = 0)
</span><span class="cx">     {
</span><span class="cx">         array = a;
</span><span class="lines">@@ -302,6 +349,38 @@
</span><span class="cx"> 
</span><span class="cx">         return userDef-&gt;isStructureContainingArrays();
</span><span class="cx">     }
</span><ins>+
+    bool isMatrix() const
+    {
+        return primarySize &gt; 1 &amp;&amp; secondarySize &gt; 1;
+    }
+
+    bool isVector() const
+    {
+        return primarySize &gt; 1 &amp;&amp; secondarySize == 1;
+    }
+
+    int getCols() const
+    {
+        ASSERT(isMatrix());
+        return primarySize;
+    }
+
+    int getRows() const
+    {
+        ASSERT(isMatrix());
+        return secondarySize;
+    }
+
+    int getNominalSize() const
+    {
+        return primarySize;
+    }
+
+    bool isAggregate() const
+    {
+        return array || isMatrix() || isVector();
+    }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif // _TYPES_INCLUDED_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorUnfoldShortCircuitASTcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/UnfoldShortCircuitAST.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/UnfoldShortCircuitAST.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/UnfoldShortCircuitAST.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">         // In AST traversing, a parent is visited before its children.
</span><span class="cx">         // After we replace a node, if an immediate child is to
</span><span class="cx">         // be replaced, we need to make sure we don't update the replaced
</span><del>-    // node; instead, we update the replacement node.
</del><ins>+        // node; instead, we update the replacement node.
</ins><span class="cx">         for (size_t jj = ii + 1; jj &lt; replacements.size(); ++jj)
</span><span class="cx">         {
</span><span class="cx">             NodeUpdateEntry&amp; entry2 = replacements[jj];
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/UnfoldShortCircuitAST.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorValidateLimitationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateLimitations.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateLimitations.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateLimitations.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -9,26 +9,9 @@
</span><span class="cx"> #include &quot;compiler/translator/InitializeParseContext.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/ParseContext.h&quot;
</span><span class="cx"> 
</span><del>-namespace {
-bool IsLoopIndex(const TIntermSymbol* symbol, const TLoopStack&amp; stack) {
-    for (TLoopStack::const_iterator i = stack.begin(); i != stack.end(); ++i) {
-        if (i-&gt;index.id == symbol-&gt;getId())
-            return true;
-    }
-    return false;
-}
</del><ins>+namespace
+{
</ins><span class="cx"> 
</span><del>-void MarkLoopForUnroll(const TIntermSymbol* symbol, TLoopStack&amp; stack) {
-    for (TLoopStack::iterator i = stack.begin(); i != stack.end(); ++i) {
-        if (i-&gt;index.id == symbol-&gt;getId()) {
-            ASSERT(i-&gt;loop != NULL);
-            i-&gt;loop-&gt;setUnrollFlag(true);
-            return;
-        }
-    }
-    UNREACHABLE();
-}
-
</del><span class="cx"> // Traverses a node to check if it represents a constant index expression.
</span><span class="cx"> // Definition:
</span><span class="cx"> // constant-index-expressions are a superset of constant-expressions.
</span><span class="lines">@@ -38,110 +21,60 @@
</span><span class="cx"> // - Constant expressions
</span><span class="cx"> // - Loop indices as defined in section 4
</span><span class="cx"> // - Expressions composed of both of the above
</span><del>-class ValidateConstIndexExpr : public TIntermTraverser {
-public:
-    ValidateConstIndexExpr(const TLoopStack&amp; stack)
</del><ins>+class ValidateConstIndexExpr : public TIntermTraverser
+{
+  public:
+    ValidateConstIndexExpr(TLoopStack&amp; stack)
</ins><span class="cx">         : mValid(true), mLoopStack(stack) {}
</span><span class="cx"> 
</span><span class="cx">     // Returns true if the parsed node represents a constant index expression.
</span><span class="cx">     bool isValid() const { return mValid; }
</span><span class="cx"> 
</span><del>-    virtual void visitSymbol(TIntermSymbol* symbol) {
</del><ins>+    virtual void visitSymbol(TIntermSymbol *symbol)
+    {
</ins><span class="cx">         // Only constants and loop indices are allowed in a
</span><span class="cx">         // constant index expression.
</span><del>-        if (mValid) {
</del><ins>+        if (mValid)
+        {
</ins><span class="cx">             mValid = (symbol-&gt;getQualifier() == EvqConst) ||
</span><del>-                     IsLoopIndex(symbol, mLoopStack);
</del><ins>+                     (mLoopStack.findLoop(symbol));
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-private:
</del><ins>+  private:
</ins><span class="cx">     bool mValid;
</span><del>-    const TLoopStack&amp; mLoopStack;
-};
-
-// Traverses a node to check if it uses a loop index.
-// If an int loop index is used in its body as a sampler array index,
-// mark the loop for unroll.
-class ValidateLoopIndexExpr : public TIntermTraverser {
-public:
-    ValidateLoopIndexExpr(TLoopStack&amp; stack)
-        : mUsesFloatLoopIndex(false),
-          mUsesIntLoopIndex(false),
-          mLoopStack(stack) {}
-
-    bool usesFloatLoopIndex() const { return mUsesFloatLoopIndex; }
-    bool usesIntLoopIndex() const { return mUsesIntLoopIndex; }
-
-    virtual void visitSymbol(TIntermSymbol* symbol) {
-        if (IsLoopIndex(symbol, mLoopStack)) {
-            switch (symbol-&gt;getBasicType()) {
-              case EbtFloat:
-                mUsesFloatLoopIndex = true;
-                break;
-              case EbtInt:
-                mUsesIntLoopIndex = true;
-                MarkLoopForUnroll(symbol, mLoopStack);
-                break;
-              default:
-                UNREACHABLE();
-            }
-        }
-    }
-
-private:
-    bool mUsesFloatLoopIndex;
-    bool mUsesIntLoopIndex;
</del><span class="cx">     TLoopStack&amp; mLoopStack;
</span><span class="cx"> };
</span><del>-}  // namespace
</del><span class="cx"> 
</span><ins>+}  // namespace anonymous
+
</ins><span class="cx"> ValidateLimitations::ValidateLimitations(ShShaderType shaderType,
</span><del>-                                         TInfoSinkBase&amp; sink)
</del><ins>+                                         TInfoSinkBase &amp;sink)
</ins><span class="cx">     : mShaderType(shaderType),
</span><span class="cx">       mSink(sink),
</span><span class="cx">       mNumErrors(0)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::visitBinary(Visit, TIntermBinary* node)
</del><ins>+bool ValidateLimitations::visitBinary(Visit, TIntermBinary *node)
</ins><span class="cx"> {
</span><span class="cx">     // Check if loop index is modified in the loop body.
</span><span class="cx">     validateOperation(node, node-&gt;getLeft());
</span><span class="cx"> 
</span><span class="cx">     // Check indexing.
</span><del>-    switch (node-&gt;getOp()) {
</del><ins>+    switch (node-&gt;getOp())
+    {
</ins><span class="cx">       case EOpIndexDirect:
</span><del>-        validateIndexing(node);
-        break;
</del><span class="cx">       case EOpIndexIndirect:
</span><del>-#if defined(__APPLE__)
-        // Loop unrolling is a work-around for a Mac Cg compiler bug where it
-        // crashes when a sampler array's index is also the loop index.
-        // Once Apple fixes this bug, we should remove the code in this CL.
-        // See http://codereview.appspot.com/4331048/.
-        if ((node-&gt;getLeft() != NULL) &amp;&amp; (node-&gt;getRight() != NULL) &amp;&amp;
-            (node-&gt;getLeft()-&gt;getAsSymbolNode())) {
-            TIntermSymbol* symbol = node-&gt;getLeft()-&gt;getAsSymbolNode();
-            if (IsSampler(symbol-&gt;getBasicType()) &amp;&amp; symbol-&gt;isArray()) {
-                ValidateLoopIndexExpr validate(mLoopStack);
-                node-&gt;getRight()-&gt;traverse(&amp;validate);
-                if (validate.usesFloatLoopIndex()) {
-                    error(node-&gt;getLine(),
-                          &quot;sampler array index is float loop index&quot;,
-                          &quot;for&quot;);
-                }
-            }
-        }
-#endif
</del><span class="cx">         validateIndexing(node);
</span><span class="cx">         break;
</span><del>-      default: break;
</del><ins>+      default:
+        break;
</ins><span class="cx">     }
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::visitUnary(Visit, TIntermUnary* node)
</del><ins>+bool ValidateLimitations::visitUnary(Visit, TIntermUnary *node)
</ins><span class="cx"> {
</span><span class="cx">     // Check if loop index is modified in the loop body.
</span><span class="cx">     validateOperation(node, node-&gt;getOperand());
</span><span class="lines">@@ -149,7 +82,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::visitAggregate(Visit, TIntermAggregate* node)
</del><ins>+bool ValidateLimitations::visitAggregate(Visit, TIntermAggregate *node)
</ins><span class="cx"> {
</span><span class="cx">     switch (node-&gt;getOp()) {
</span><span class="cx">       case EOpFunctionCall:
</span><span class="lines">@@ -161,22 +94,20 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::visitLoop(Visit, TIntermLoop* node)
</del><ins>+bool ValidateLimitations::visitLoop(Visit, TIntermLoop *node)
</ins><span class="cx"> {
</span><span class="cx">     if (!validateLoopType(node))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    TLoopInfo info;
-    memset(&amp;info, 0, sizeof(TLoopInfo));
-    info.loop = node;
-    if (!validateForLoopHeader(node, &amp;info))
</del><ins>+    if (!validateForLoopHeader(node))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    TIntermNode* body = node-&gt;getBody();
-    if (body != NULL) {
-        mLoopStack.push_back(info);
</del><ins>+    TIntermNode *body = node-&gt;getBody();
+    if (body != NULL)
+    {
+        mLoopStack.push(node);
</ins><span class="cx">         body-&gt;traverse(this);
</span><del>-        mLoopStack.pop_back();
</del><ins>+        mLoopStack.pop();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // The loop is fully processed - no need to visit children.
</span><span class="lines">@@ -184,7 +115,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ValidateLimitations::error(TSourceLoc loc,
</span><del>-                                const char *reason, const char* token)
</del><ins>+                                const char *reason, const char *token)
</ins><span class="cx"> {
</span><span class="cx">     mSink.prefix(EPrefixError);
</span><span class="cx">     mSink.location(loc);
</span><span class="lines">@@ -197,12 +128,13 @@
</span><span class="cx">     return !mLoopStack.empty();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::isLoopIndex(const TIntermSymbol* symbol) const
</del><ins>+bool ValidateLimitations::isLoopIndex(TIntermSymbol *symbol)
</ins><span class="cx"> {
</span><del>-    return IsLoopIndex(symbol, mLoopStack);
</del><ins>+    return mLoopStack.findLoop(symbol) != NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::validateLoopType(TIntermLoop* node) {
</del><ins>+bool ValidateLimitations::validateLoopType(TIntermLoop *node)
+{
</ins><span class="cx">     TLoopType type = node-&gt;getType();
</span><span class="cx">     if (type == ELoopFor)
</span><span class="cx">         return true;
</span><span class="lines">@@ -214,8 +146,7 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::validateForLoopHeader(TIntermLoop* node,
-                                                TLoopInfo* info)
</del><ins>+bool ValidateLimitations::validateForLoopHeader(TIntermLoop *node)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(node-&gt;getType() == ELoopFor);
</span><span class="cx"> 
</span><span class="lines">@@ -223,74 +154,80 @@
</span><span class="cx">     // The for statement has the form:
</span><span class="cx">     //    for ( init-declaration ; condition ; expression ) statement
</span><span class="cx">     //
</span><del>-    if (!validateForLoopInit(node, info))
</del><ins>+    int indexSymbolId = validateForLoopInit(node);
+    if (indexSymbolId &lt; 0)
</ins><span class="cx">         return false;
</span><del>-    if (!validateForLoopCond(node, info))
</del><ins>+    if (!validateForLoopCond(node, indexSymbolId))
</ins><span class="cx">         return false;
</span><del>-    if (!validateForLoopExpr(node, info))
</del><ins>+    if (!validateForLoopExpr(node, indexSymbolId))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::validateForLoopInit(TIntermLoop* node,
-                                              TLoopInfo* info)
</del><ins>+int ValidateLimitations::validateForLoopInit(TIntermLoop *node)
</ins><span class="cx"> {
</span><del>-    TIntermNode* init = node-&gt;getInit();
-    if (init == NULL) {
</del><ins>+    TIntermNode *init = node-&gt;getInit();
+    if (init == NULL)
+    {
</ins><span class="cx">         error(node-&gt;getLine(), &quot;Missing init declaration&quot;, &quot;for&quot;);
</span><del>-        return false;
</del><ins>+        return -1;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // init-declaration has the form:
</span><span class="cx">     //     type-specifier identifier = constant-expression
</span><span class="cx">     //
</span><del>-    TIntermAggregate* decl = init-&gt;getAsAggregate();
-    if ((decl == NULL) || (decl-&gt;getOp() != EOpDeclaration)) {
</del><ins>+    TIntermAggregate *decl = init-&gt;getAsAggregate();
+    if ((decl == NULL) || (decl-&gt;getOp() != EOpDeclaration))
+    {
</ins><span class="cx">         error(init-&gt;getLine(), &quot;Invalid init declaration&quot;, &quot;for&quot;);
</span><del>-        return false;
</del><ins>+        return -1;
</ins><span class="cx">     }
</span><span class="cx">     // To keep things simple do not allow declaration list.
</span><del>-    TIntermSequence&amp; declSeq = decl-&gt;getSequence();
-    if (declSeq.size() != 1) {
</del><ins>+    TIntermSequence &amp;declSeq = decl-&gt;getSequence();
+    if (declSeq.size() != 1)
+    {
</ins><span class="cx">         error(decl-&gt;getLine(), &quot;Invalid init declaration&quot;, &quot;for&quot;);
</span><del>-        return false;
</del><ins>+        return -1;
</ins><span class="cx">     }
</span><del>-    TIntermBinary* declInit = declSeq[0]-&gt;getAsBinaryNode();
-    if ((declInit == NULL) || (declInit-&gt;getOp() != EOpInitialize)) {
</del><ins>+    TIntermBinary *declInit = declSeq[0]-&gt;getAsBinaryNode();
+    if ((declInit == NULL) || (declInit-&gt;getOp() != EOpInitialize))
+    {
</ins><span class="cx">         error(decl-&gt;getLine(), &quot;Invalid init declaration&quot;, &quot;for&quot;);
</span><del>-        return false;
</del><ins>+        return -1;
</ins><span class="cx">     }
</span><del>-    TIntermSymbol* symbol = declInit-&gt;getLeft()-&gt;getAsSymbolNode();
-    if (symbol == NULL) {
</del><ins>+    TIntermSymbol *symbol = declInit-&gt;getLeft()-&gt;getAsSymbolNode();
+    if (symbol == NULL)
+    {
</ins><span class="cx">         error(declInit-&gt;getLine(), &quot;Invalid init declaration&quot;, &quot;for&quot;);
</span><del>-        return false;
</del><ins>+        return -1;
</ins><span class="cx">     }
</span><span class="cx">     // The loop index has type int or float.
</span><span class="cx">     TBasicType type = symbol-&gt;getBasicType();
</span><del>-    if ((type != EbtInt) &amp;&amp; (type != EbtFloat)) {
</del><ins>+    if ((type != EbtInt) &amp;&amp; (type != EbtUInt) &amp;&amp; (type != EbtFloat)) {
</ins><span class="cx">         error(symbol-&gt;getLine(),
</span><span class="cx">               &quot;Invalid type for loop index&quot;, getBasicString(type));
</span><del>-        return false;
</del><ins>+        return -1;
</ins><span class="cx">     }
</span><span class="cx">     // The loop index is initialized with constant expression.
</span><del>-    if (!isConstExpr(declInit-&gt;getRight())) {
</del><ins>+    if (!isConstExpr(declInit-&gt;getRight()))
+    {
</ins><span class="cx">         error(declInit-&gt;getLine(),
</span><span class="cx">               &quot;Loop index cannot be initialized with non-constant expression&quot;,
</span><span class="cx">               symbol-&gt;getSymbol().c_str());
</span><del>-        return false;
</del><ins>+        return -1;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    info-&gt;index.id = symbol-&gt;getId();
-    return true;
</del><ins>+    return symbol-&gt;getId();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::validateForLoopCond(TIntermLoop* node,
-                                              TLoopInfo* info)
</del><ins>+bool ValidateLimitations::validateForLoopCond(TIntermLoop *node,
+                                              int indexSymbolId)
</ins><span class="cx"> {
</span><del>-    TIntermNode* cond = node-&gt;getCondition();
-    if (cond == NULL) {
</del><ins>+    TIntermNode *cond = node-&gt;getCondition();
+    if (cond == NULL)
+    {
</ins><span class="cx">         error(node-&gt;getLine(), &quot;Missing condition&quot;, &quot;for&quot;);
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -298,24 +235,28 @@
</span><span class="cx">     // condition has the form:
</span><span class="cx">     //     loop_index relational_operator constant_expression
</span><span class="cx">     //
</span><del>-    TIntermBinary* binOp = cond-&gt;getAsBinaryNode();
-    if (binOp == NULL) {
</del><ins>+    TIntermBinary *binOp = cond-&gt;getAsBinaryNode();
+    if (binOp == NULL)
+    {
</ins><span class="cx">         error(node-&gt;getLine(), &quot;Invalid condition&quot;, &quot;for&quot;);
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx">     // Loop index should be to the left of relational operator.
</span><del>-    TIntermSymbol* symbol = binOp-&gt;getLeft()-&gt;getAsSymbolNode();
-    if (symbol == NULL) {
</del><ins>+    TIntermSymbol *symbol = binOp-&gt;getLeft()-&gt;getAsSymbolNode();
+    if (symbol == NULL)
+    {
</ins><span class="cx">         error(binOp-&gt;getLine(), &quot;Invalid condition&quot;, &quot;for&quot;);
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><del>-    if (symbol-&gt;getId() != info-&gt;index.id) {
</del><ins>+    if (symbol-&gt;getId() != indexSymbolId)
+    {
</ins><span class="cx">         error(symbol-&gt;getLine(),
</span><span class="cx">               &quot;Expected loop index&quot;, symbol-&gt;getSymbol().c_str());
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx">     // Relational operator is one of: &gt; &gt;= &lt; &lt;= == or !=.
</span><del>-    switch (binOp-&gt;getOp()) {
</del><ins>+    switch (binOp-&gt;getOp())
+    {
</ins><span class="cx">       case EOpEqual:
</span><span class="cx">       case EOpNotEqual:
</span><span class="cx">       case EOpLessThan:
</span><span class="lines">@@ -330,7 +271,8 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     // Loop index must be compared with a constant.
</span><del>-    if (!isConstExpr(binOp-&gt;getRight())) {
</del><ins>+    if (!isConstExpr(binOp-&gt;getRight()))
+    {
</ins><span class="cx">         error(binOp-&gt;getLine(),
</span><span class="cx">               &quot;Loop index cannot be compared with non-constant expression&quot;,
</span><span class="cx">               symbol-&gt;getSymbol().c_str());
</span><span class="lines">@@ -340,11 +282,12 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::validateForLoopExpr(TIntermLoop* node,
-                                              TLoopInfo* info)
</del><ins>+bool ValidateLimitations::validateForLoopExpr(TIntermLoop *node,
+                                              int indexSymbolId)
</ins><span class="cx"> {
</span><del>-    TIntermNode* expr = node-&gt;getExpression();
-    if (expr == NULL) {
</del><ins>+    TIntermNode *expr = node-&gt;getExpression();
+    if (expr == NULL)
+    {
</ins><span class="cx">         error(node-&gt;getLine(), &quot;Missing expression&quot;, &quot;for&quot;);
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -358,50 +301,58 @@
</span><span class="cx">     //     --loop_index
</span><span class="cx">     // The last two forms are not specified in the spec, but I am assuming
</span><span class="cx">     // its an oversight.
</span><del>-    TIntermUnary* unOp = expr-&gt;getAsUnaryNode();
-    TIntermBinary* binOp = unOp ? NULL : expr-&gt;getAsBinaryNode();
</del><ins>+    TIntermUnary *unOp = expr-&gt;getAsUnaryNode();
+    TIntermBinary *binOp = unOp ? NULL : expr-&gt;getAsBinaryNode();
</ins><span class="cx"> 
</span><span class="cx">     TOperator op = EOpNull;
</span><del>-    TIntermSymbol* symbol = NULL;
-    if (unOp != NULL) {
</del><ins>+    TIntermSymbol *symbol = NULL;
+    if (unOp != NULL)
+    {
</ins><span class="cx">         op = unOp-&gt;getOp();
</span><span class="cx">         symbol = unOp-&gt;getOperand()-&gt;getAsSymbolNode();
</span><del>-    } else if (binOp != NULL) {
</del><ins>+    }
+    else if (binOp != NULL)
+    {
</ins><span class="cx">         op = binOp-&gt;getOp();
</span><span class="cx">         symbol = binOp-&gt;getLeft()-&gt;getAsSymbolNode();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // The operand must be loop index.
</span><del>-    if (symbol == NULL) {
</del><ins>+    if (symbol == NULL)
+    {
</ins><span class="cx">         error(expr-&gt;getLine(), &quot;Invalid expression&quot;, &quot;for&quot;);
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><del>-    if (symbol-&gt;getId() != info-&gt;index.id) {
</del><ins>+    if (symbol-&gt;getId() != indexSymbolId)
+    {
</ins><span class="cx">         error(symbol-&gt;getLine(),
</span><span class="cx">               &quot;Expected loop index&quot;, symbol-&gt;getSymbol().c_str());
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // The operator is one of: ++ -- += -=.
</span><del>-    switch (op) {
-        case EOpPostIncrement:
-        case EOpPostDecrement:
-        case EOpPreIncrement:
-        case EOpPreDecrement:
-            ASSERT((unOp != NULL) &amp;&amp; (binOp == NULL));
-            break;
-        case EOpAddAssign:
-        case EOpSubAssign:
-            ASSERT((unOp == NULL) &amp;&amp; (binOp != NULL));
-            break;
-        default:
-            error(expr-&gt;getLine(), &quot;Invalid operator&quot;, getOperatorString(op));
-            return false;
</del><ins>+    switch (op)
+    {
+      case EOpPostIncrement:
+      case EOpPostDecrement:
+      case EOpPreIncrement:
+      case EOpPreDecrement:
+        ASSERT((unOp != NULL) &amp;&amp; (binOp == NULL));
+        break;
+      case EOpAddAssign:
+      case EOpSubAssign:
+        ASSERT((unOp == NULL) &amp;&amp; (binOp != NULL));
+        break;
+      default:
+        error(expr-&gt;getLine(), &quot;Invalid operator&quot;, getOperatorString(op));
+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Loop index must be incremented/decremented with a constant.
</span><del>-    if (binOp != NULL) {
-        if (!isConstExpr(binOp-&gt;getRight())) {
</del><ins>+    if (binOp != NULL)
+    {
+        if (!isConstExpr(binOp-&gt;getRight()))
+        {
</ins><span class="cx">             error(binOp-&gt;getLine(),
</span><span class="cx">                   &quot;Loop index cannot be modified by non-constant expression&quot;,
</span><span class="cx">                   symbol-&gt;getSymbol().c_str());
</span><span class="lines">@@ -412,7 +363,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::validateFunctionCall(TIntermAggregate* node)
</del><ins>+bool ValidateLimitations::validateFunctionCall(TIntermAggregate *node)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(node-&gt;getOp() == EOpFunctionCall);
</span><span class="cx"> 
</span><span class="lines">@@ -424,8 +375,9 @@
</span><span class="cx">     typedef std::vector&lt;size_t&gt; ParamIndex;
</span><span class="cx">     ParamIndex pIndex;
</span><span class="cx">     TIntermSequence&amp; params = node-&gt;getSequence();
</span><del>-    for (TIntermSequence::size_type i = 0; i &lt; params.size(); ++i) {
-        TIntermSymbol* symbol = params[i]-&gt;getAsSymbolNode();
</del><ins>+    for (TIntermSequence::size_type i = 0; i &lt; params.size(); ++i)
+    {
+        TIntermSymbol *symbol = params[i]-&gt;getAsSymbolNode();
</ins><span class="cx">         if (symbol &amp;&amp; isLoopIndex(symbol))
</span><span class="cx">             pIndex.push_back(i);
</span><span class="cx">     }
</span><span class="lines">@@ -436,14 +388,16 @@
</span><span class="cx"> 
</span><span class="cx">     bool valid = true;
</span><span class="cx">     TSymbolTable&amp; symbolTable = GetGlobalParseContext()-&gt;symbolTable;
</span><del>-    TSymbol* symbol = symbolTable.find(node-&gt;getName());
</del><ins>+    TSymbol* symbol = symbolTable.find(node-&gt;getName(), GetGlobalParseContext()-&gt;shaderVersion);
</ins><span class="cx">     ASSERT(symbol &amp;&amp; symbol-&gt;isFunction());
</span><del>-    TFunction* function = static_cast&lt;TFunction*&gt;(symbol);
</del><ins>+    TFunction *function = static_cast&lt;TFunction *&gt;(symbol);
</ins><span class="cx">     for (ParamIndex::const_iterator i = pIndex.begin();
</span><del>-         i != pIndex.end(); ++i) {
-        const TParameter&amp; param = function-&gt;getParam(*i);
</del><ins>+         i != pIndex.end(); ++i)
+    {
+        const TParameter &amp;param = function-&gt;getParam(*i);
</ins><span class="cx">         TQualifier qual = param.type-&gt;getQualifier();
</span><del>-        if ((qual == EvqOut) || (qual == EvqInOut)) {
</del><ins>+        if ((qual == EvqOut) || (qual == EvqInOut))
+        {
</ins><span class="cx">             error(params[*i]-&gt;getLine(),
</span><span class="cx">                   &quot;Loop index cannot be used as argument to a function out or inout parameter&quot;,
</span><span class="cx">                   params[*i]-&gt;getAsSymbolNode()-&gt;getSymbol().c_str());
</span><span class="lines">@@ -454,14 +408,16 @@
</span><span class="cx">     return valid;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::validateOperation(TIntermOperator* node,
-                                            TIntermNode* operand) {
</del><ins>+bool ValidateLimitations::validateOperation(TIntermOperator *node,
+                                            TIntermNode* operand)
+{
</ins><span class="cx">     // Check if loop index is modified in the loop body.
</span><span class="cx">     if (!withinLoopBody() || !node-&gt;isAssignment())
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    const TIntermSymbol* symbol = operand-&gt;getAsSymbolNode();
-    if (symbol &amp;&amp; isLoopIndex(symbol)) {
</del><ins>+    TIntermSymbol *symbol = operand-&gt;getAsSymbolNode();
+    if (symbol &amp;&amp; isLoopIndex(symbol))
+    {
</ins><span class="cx">         error(node-&gt;getLine(),
</span><span class="cx">               &quot;Loop index cannot be statically assigned to within the body of the loop&quot;,
</span><span class="cx">               symbol-&gt;getSymbol().c_str());
</span><span class="lines">@@ -469,13 +425,13 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::isConstExpr(TIntermNode* node)
</del><ins>+bool ValidateLimitations::isConstExpr(TIntermNode *node)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(node != NULL);
</span><span class="cx">     return node-&gt;getAsConstantUnion() != NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::isConstIndexExpr(TIntermNode* node)
</del><ins>+bool ValidateLimitations::isConstIndexExpr(TIntermNode *node)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(node != NULL);
</span><span class="cx"> 
</span><span class="lines">@@ -484,15 +440,15 @@
</span><span class="cx">     return validate.isValid();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ValidateLimitations::validateIndexing(TIntermBinary* node)
</del><ins>+bool ValidateLimitations::validateIndexing(TIntermBinary *node)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT((node-&gt;getOp() == EOpIndexDirect) ||
</span><span class="cx">            (node-&gt;getOp() == EOpIndexIndirect));
</span><span class="cx"> 
</span><span class="cx">     bool valid = true;
</span><del>-    TIntermTyped* index = node-&gt;getRight();
</del><ins>+    TIntermTyped *index = node-&gt;getRight();
</ins><span class="cx">     // The index expression must have integral type.
</span><del>-    if (!index-&gt;isScalar() || (index-&gt;getBasicType() != EbtInt)) {
</del><ins>+    if (!index-&gt;isScalarInt()) {
</ins><span class="cx">         error(index-&gt;getLine(),
</span><span class="cx">               &quot;Index expression must have integral type&quot;,
</span><span class="cx">               index-&gt;getCompleteString().c_str());
</span><span class="lines">@@ -500,10 +456,11 @@
</span><span class="cx">     }
</span><span class="cx">     // The index expession must be a constant-index-expression unless
</span><span class="cx">     // the operand is a uniform in a vertex shader.
</span><del>-    TIntermTyped* operand = node-&gt;getLeft();
</del><ins>+    TIntermTyped *operand = node-&gt;getLeft();
</ins><span class="cx">     bool skip = (mShaderType == SH_VERTEX_SHADER) &amp;&amp;
</span><span class="cx">                 (operand-&gt;getQualifier() == EvqUniform);
</span><del>-    if (!skip &amp;&amp; !isConstIndexExpr(index)) {
</del><ins>+    if (!skip &amp;&amp; !isConstIndexExpr(index))
+    {
</ins><span class="cx">         error(index-&gt;getLine(), &quot;Index expression must be constant&quot;, &quot;[]&quot;);
</span><span class="cx">         valid = false;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorValidateLimitationsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateLimitations.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateLimitations.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateLimitations.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -4,55 +4,51 @@
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
</del><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><ins>+#include &quot;compiler/translator/LoopInfo.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> class TInfoSinkBase;
</span><span class="cx"> 
</span><del>-struct TLoopInfo {
-    struct TIndex {
-        int id;  // symbol id.
-    } index;
-    TIntermLoop* loop;
-};
-typedef TVector&lt;TLoopInfo&gt; TLoopStack;
-
</del><span class="cx"> // Traverses intermediate tree to ensure that the shader does not exceed the
</span><span class="cx"> // minimum functionality mandated in GLSL 1.0 spec, Appendix A.
</span><del>-class ValidateLimitations : public TIntermTraverser {
-public:
-    ValidateLimitations(ShShaderType shaderType, TInfoSinkBase&amp; sink);
</del><ins>+class ValidateLimitations : public TIntermTraverser
+{
+  public:
+    ValidateLimitations(ShShaderType shaderType, TInfoSinkBase &amp;sink);
</ins><span class="cx"> 
</span><span class="cx">     int numErrors() const { return mNumErrors; }
</span><span class="cx"> 
</span><del>-    virtual bool visitBinary(Visit, TIntermBinary*);
-    virtual bool visitUnary(Visit, TIntermUnary*);
-    virtual bool visitAggregate(Visit, TIntermAggregate*);
-    virtual bool visitLoop(Visit, TIntermLoop*);
</del><ins>+    virtual bool visitBinary(Visit, TIntermBinary *);
+    virtual bool visitUnary(Visit, TIntermUnary *);
+    virtual bool visitAggregate(Visit, TIntermAggregate *);
+    virtual bool visitLoop(Visit, TIntermLoop *);
</ins><span class="cx"> 
</span><del>-private:
-    void error(TSourceLoc loc, const char *reason, const char* token);
</del><ins>+  private:
+    void error(TSourceLoc loc, const char *reason, const char *token);
</ins><span class="cx"> 
</span><span class="cx">     bool withinLoopBody() const;
</span><del>-    bool isLoopIndex(const TIntermSymbol* symbol) const;
-    bool validateLoopType(TIntermLoop* node);
-    bool validateForLoopHeader(TIntermLoop* node, TLoopInfo* info);
-    bool validateForLoopInit(TIntermLoop* node, TLoopInfo* info);
-    bool validateForLoopCond(TIntermLoop* node, TLoopInfo* info);
-    bool validateForLoopExpr(TIntermLoop* node, TLoopInfo* info);
</del><ins>+    bool isLoopIndex(TIntermSymbol *symbol);
+    bool validateLoopType(TIntermLoop *node);
+
+    bool validateForLoopHeader(TIntermLoop *node);
+    // If valid, return the index symbol id; Otherwise, return -1.
+    int validateForLoopInit(TIntermLoop *node);
+    bool validateForLoopCond(TIntermLoop *node, int indexSymbolId);
+    bool validateForLoopExpr(TIntermLoop *node, int indexSymbolId);
+
</ins><span class="cx">     // Returns true if none of the loop indices is used as the argument to
</span><span class="cx">     // the given function out or inout parameter.
</span><del>-    bool validateFunctionCall(TIntermAggregate* node);
-    bool validateOperation(TIntermOperator* node, TIntermNode* operand);
</del><ins>+    bool validateFunctionCall(TIntermAggregate *node);
+    bool validateOperation(TIntermOperator *node, TIntermNode *operand);
</ins><span class="cx"> 
</span><span class="cx">     // Returns true if indexing does not exceed the minimum functionality
</span><span class="cx">     // mandated in GLSL 1.0 spec, Appendix A, Section 5.
</span><del>-    bool isConstExpr(TIntermNode* node);
-    bool isConstIndexExpr(TIntermNode* node);
-    bool validateIndexing(TIntermBinary* node);
</del><ins>+    bool isConstExpr(TIntermNode *node);
+    bool isConstIndexExpr(TIntermNode *node);
+    bool validateIndexing(TIntermBinary *node);
</ins><span class="cx"> 
</span><span class="cx">     ShShaderType mShaderType;
</span><del>-    TInfoSinkBase&amp; mSink;
</del><ins>+    TInfoSinkBase &amp;mSink;
</ins><span class="cx">     int mNumErrors;
</span><span class="cx">     TLoopStack mLoopStack;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorValidateOutputscpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateOutputs.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateOutputs.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateOutputs.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+//
+// 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 &quot;compiler/translator/ValidateOutputs.h&quot;
+#include &quot;compiler/translator/InfoSink.h&quot;
+#include &quot;compiler/translator/InitializeParseContext.h&quot;
+#include &quot;compiler/translator/ParseContext.h&quot;
+
+ValidateOutputs::ValidateOutputs(TInfoSinkBase&amp; sink, int maxDrawBuffers)
+    : mSink(sink),
+      mMaxDrawBuffers(maxDrawBuffers),
+      mNumErrors(0),
+      mHasUnspecifiedOutputLocation(false)
+{
+}
+
+void ValidateOutputs::visitSymbol(TIntermSymbol *symbol)
+{
+    TString name = symbol-&gt;getSymbol();
+    TQualifier qualifier = symbol-&gt;getQualifier();
+
+    if (mVisitedSymbols.count(name) == 1)
+        return;
+
+    mVisitedSymbols.insert(name);
+
+    if (qualifier == EvqFragmentOut)
+    {
+        const TType &amp;type = symbol-&gt;getType();
+        const int location = type.getLayoutQualifier().location;
+
+        if (mHasUnspecifiedOutputLocation)
+        {
+            error(symbol-&gt;getLine(), &quot;must explicitly specify all locations when using multiple fragment outputs&quot;, name.c_str());
+        }
+        else if (location == -1)
+        {
+            mHasUnspecifiedOutputLocation = true;
+        }
+        else
+        {
+            OutputMap::iterator mapEntry = mOutputMap.find(location);
+            if (mapEntry == mOutputMap.end())
+            {
+                const int elementCount = type.isArray() ? type.getArraySize() : 1;
+                if (location + elementCount &gt; mMaxDrawBuffers)
+                {
+                    error(symbol-&gt;getLine(), &quot;output location must be &lt; MAX_DRAW_BUFFERS&quot;, name.c_str());
+                }
+
+                for (int elementIndex = 0; elementIndex &lt; elementCount; elementIndex++)
+                {
+                    const int offsetLocation = location + elementIndex;
+                    mOutputMap[offsetLocation] = symbol;
+                }
+            }
+            else
+            {
+                std::stringstream strstr;
+                strstr &lt;&lt; &quot;conflicting output locations with previously defined output '&quot;
+                       &lt;&lt; mapEntry-&gt;second-&gt;getSymbol() &lt;&lt; &quot;'&quot;;
+
+                error(symbol-&gt;getLine(), strstr.str().c_str(), name.c_str());
+            }
+        }
+    }
+}
+
+void ValidateOutputs::error(TSourceLoc loc, const char *reason, const char* token)
+{
+    mSink.prefix(EPrefixError);
+    mSink.location(loc);
+    mSink &lt;&lt; &quot;'&quot; &lt;&lt; token &lt;&lt; &quot;' : &quot; &lt;&lt; reason &lt;&lt; &quot;\n&quot;;
+    mNumErrors++;
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorValidateOutputsh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateOutputs.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateOutputs.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ValidateOutputs.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+//
+// 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 &quot;compiler/translator/intermediate.h&quot;
+
+#include &lt;set&gt;
+
+class TInfoSinkBase;
+
+class ValidateOutputs : public TIntermTraverser
+{
+  public:
+    ValidateOutputs(TInfoSinkBase&amp; sink, int maxDrawBuffers);
+
+    int numErrors() const { return mNumErrors; }
+
+    virtual void visitSymbol(TIntermSymbol*);
+
+  private:
+    TInfoSinkBase&amp; mSink;
+    int mMaxDrawBuffers;
+    int mNumErrors;
+    bool mHasUnspecifiedOutputLocation;
+
+    typedef std::map&lt;int, TIntermSymbol*&gt; OutputMap;
+    OutputMap mOutputMap;
+    std::set&lt;TString&gt; mVisitedSymbols;
+
+    void error(TSourceLoc loc, const char *reason, const char* token);
+};
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorVariableInfocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -21,11 +21,32 @@
</span><span class="cx">     switch (type.getBasicType()) {
</span><span class="cx">       case EbtFloat:
</span><span class="cx">           if (type.isMatrix()) {
</span><del>-              switch (type.getNominalSize()) {
-                case 2: return SH_FLOAT_MAT2;
-                case 3: return SH_FLOAT_MAT3;
-                case 4: return SH_FLOAT_MAT4;
-                default: UNREACHABLE();
</del><ins>+              switch (type.getCols())
+              {
+                case 2:
+                  switch (type.getRows())
+                  {
+                    case 2: return SH_FLOAT_MAT2;
+                    case 3: return SH_FLOAT_MAT2x3;
+                    case 4: return SH_FLOAT_MAT2x4;
+                    default: UNREACHABLE();
+                  }
+                case 3:
+                  switch (type.getRows())
+                  {
+                    case 2: return SH_FLOAT_MAT3x2;
+                    case 3: return SH_FLOAT_MAT3;
+                    case 4: return SH_FLOAT_MAT3x4;
+                    default: UNREACHABLE();
+                  }
+                case 4:
+                  switch (type.getRows())
+                  {
+                    case 2: return SH_FLOAT_MAT4x2;
+                    case 3: return SH_FLOAT_MAT4x3;
+                    case 4: return SH_FLOAT_MAT4;
+                    default: UNREACHABLE();
+                  }
</ins><span class="cx">               }
</span><span class="cx">           } else if (type.isVector()) {
</span><span class="cx">               switch (type.getNominalSize()) {
</span><span class="lines">@@ -50,6 +71,19 @@
</span><span class="cx">           } else {
</span><span class="cx">               return SH_INT;
</span><span class="cx">           }
</span><ins>+      case EbtUInt:
+          if (type.isMatrix()) {
+              UNREACHABLE();
+          } else if (type.isVector()) {
+              switch (type.getNominalSize()) {
+                case 2: return SH_UNSIGNED_INT_VEC2;
+                case 3: return SH_UNSIGNED_INT_VEC3;
+                case 4: return SH_UNSIGNED_INT_VEC4;
+                default: UNREACHABLE();
+              }
+          } else {
+              return SH_UNSIGNED_INT;
+          }
</ins><span class="cx">       case EbtBool:
</span><span class="cx">           if (type.isMatrix()) {
</span><span class="cx">               UNREACHABLE();
</span><span class="lines">@@ -64,9 +98,22 @@
</span><span class="cx">               return SH_BOOL;
</span><span class="cx">           }
</span><span class="cx">       case EbtSampler2D: return SH_SAMPLER_2D;
</span><ins>+      case EbtSampler3D: return SH_SAMPLER_3D;
</ins><span class="cx">       case EbtSamplerCube: return SH_SAMPLER_CUBE;
</span><span class="cx">       case EbtSamplerExternalOES: return SH_SAMPLER_EXTERNAL_OES;
</span><span class="cx">       case EbtSampler2DRect: return SH_SAMPLER_2D_RECT_ARB;
</span><ins>+      case EbtSampler2DArray: return SH_SAMPLER_2D_ARRAY;
+      case EbtISampler2D: return SH_INT_SAMPLER_2D;
+      case EbtISampler3D: return SH_INT_SAMPLER_3D;
+      case EbtISamplerCube: return SH_INT_SAMPLER_CUBE;
+      case EbtISampler2DArray: return SH_INT_SAMPLER_2D_ARRAY;
+      case EbtUSampler2D: return SH_UNSIGNED_INT_SAMPLER_2D;
+      case EbtUSampler3D: return SH_UNSIGNED_INT_SAMPLER_3D;
+      case EbtUSamplerCube: return SH_UNSIGNED_INT_SAMPLER_CUBE;
+      case EbtUSampler2DArray: return SH_UNSIGNED_INT_SAMPLER_2D_ARRAY;
+      case EbtSampler2DShadow: return SH_SAMPLER_2D_SHADOW;
+      case EbtSamplerCubeShadow: return SH_SAMPLER_CUBE_SHADOW;
+      case EbtSampler2DArrayShadow: return SH_SAMPLER_2D_ARRAY_SHADOW;
</ins><span class="cx">       default: UNREACHABLE();
</span><span class="cx">     }
</span><span class="cx">     return SH_NONE;
</span><span class="lines">@@ -134,7 +181,7 @@
</span><span class="cx">                                 TVariableInfoList&amp; infoList,
</span><span class="cx">                                 ShHashFunction64 hashFunction)
</span><span class="cx"> {
</span><del>-    ASSERT(type.getBasicType() == EbtStruct);
</del><ins>+    ASSERT(type.getBasicType() == EbtStruct || type.isInterfaceBlock());
</ins><span class="cx"> 
</span><span class="cx">     const TFieldList&amp; fields = type.getStruct()-&gt;fields();
</span><span class="cx">     for (size_t i = 0; i &lt; fields.size(); ++i) {
</span><span class="lines">@@ -227,7 +274,7 @@
</span><span class="cx">             info.size = 1;
</span><span class="cx">             info.precision = EbpMedium;  // Use mediump as it doesn't really matter.
</span><span class="cx">             info.staticUse = true;
</span><del>-        mVaryings.push_back(info);
</del><ins>+            mVaryings.push_back(info);
</ins><span class="cx">             mFragCoordAdded = true;
</span><span class="cx">         }
</span><span class="cx">         return;
</span><span class="lines">@@ -240,7 +287,7 @@
</span><span class="cx">             info.size = 1;
</span><span class="cx">             info.precision = EbpUndefined;
</span><span class="cx">             info.staticUse = true;
</span><del>-        mVaryings.push_back(info);
</del><ins>+            mVaryings.push_back(info);
</ins><span class="cx">             mFrontFacingAdded = true;
</span><span class="cx">         }
</span><span class="cx">         return;
</span><span class="lines">@@ -253,7 +300,7 @@
</span><span class="cx">             info.size = 1;
</span><span class="cx">             info.precision = EbpMedium;  // Use mediump as it doesn't really matter.
</span><span class="cx">             info.staticUse = true;
</span><del>-        mVaryings.push_back(info);
</del><ins>+            mVaryings.push_back(info);
</ins><span class="cx">             mPointCoordAdded = true;
</span><span class="cx">         }
</span><span class="cx">         return;
</span><span class="lines">@@ -273,12 +320,26 @@
</span><span class="cx">     case EOpDeclaration: {
</span><span class="cx">         const TIntermSequence&amp; sequence = node-&gt;getSequence();
</span><span class="cx">         TQualifier qualifier = sequence.front()-&gt;getAsTyped()-&gt;getQualifier();
</span><del>-        if (qualifier == EvqAttribute || qualifier == EvqUniform ||
</del><ins>+        if (qualifier == EvqAttribute || qualifier == EvqVertexIn || qualifier == EvqUniform ||
</ins><span class="cx">             qualifier == EvqVaryingIn || qualifier == EvqVaryingOut ||
</span><span class="cx">             qualifier == EvqInvariantVaryingIn || qualifier == EvqInvariantVaryingOut)
</span><span class="cx">         {
</span><del>-            TVariableInfoList&amp; infoList = qualifier == EvqAttribute ? mAttribs :
-                (qualifier == EvqUniform ? mUniforms : mVaryings);
</del><ins>+            TVariableInfoList *infoList = NULL;
+
+            switch (qualifier)
+            {
+              case EvqAttribute:
+              case EvqVertexIn:
+                infoList = &amp;mAttribs;
+                break;
+              case EvqUniform:
+                infoList = &amp;mUniforms;
+                break;
+              default:
+                infoList = &amp;mVaryings;
+                break;
+            }
+
</ins><span class="cx">             for (TIntermSequence::const_iterator i = sequence.begin();
</span><span class="cx">                  i != sequence.end(); ++i)
</span><span class="cx">             {
</span><span class="lines">@@ -293,11 +354,11 @@
</span><span class="cx">                 if (mHashFunction == NULL)
</span><span class="cx">                     processedSymbol = variable-&gt;getSymbol();
</span><span class="cx">                 else
</span><del>-                    processedSymbol = TIntermTraverser::hash(variable-&gt;getOriginalSymbol(), mHashFunction);
</del><ins>+                    processedSymbol = TIntermTraverser::hash(variable-&gt;getSymbol(), mHashFunction);
</ins><span class="cx">                 getVariableInfo(variable-&gt;getType(),
</span><del>-                                variable-&gt;getOriginalSymbol(),
</del><ins>+                                variable-&gt;getSymbol(),
</ins><span class="cx">                                 processedSymbol,
</span><del>-                                infoList,
</del><ins>+                                *infoList,
</ins><span class="cx">                                 mHashFunction);
</span><span class="cx">                 visitChildren = false;
</span><span class="cx">             }
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorVariableInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariableInfo.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -7,7 +7,6 @@
</span><span class="cx"> #ifndef COMPILER_VARIABLE_INFO_H_
</span><span class="cx"> #define COMPILER_VARIABLE_INFO_H_
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
</del><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><span class="cx"> 
</span><span class="cx"> // Provides information about a variable.
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorVariablePackercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariablePacker.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariablePacker.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VariablePacker.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -13,6 +13,10 @@
</span><span class="cx"> {
</span><span class="cx">     switch (type) {
</span><span class="cx">         case SH_FLOAT_MAT4:
</span><ins>+        case SH_FLOAT_MAT2x4:
+        case SH_FLOAT_MAT3x4:
+        case SH_FLOAT_MAT4x2:
+        case SH_FLOAT_MAT4x3:
</ins><span class="cx">             return 0;
</span><span class="cx">         case SH_FLOAT_MAT2:
</span><span class="cx">             return 1;
</span><span class="lines">@@ -21,6 +25,8 @@
</span><span class="cx">         case SH_BOOL_VEC4:
</span><span class="cx">             return 2;
</span><span class="cx">         case SH_FLOAT_MAT3:
</span><ins>+        case SH_FLOAT_MAT2x3:
+        case SH_FLOAT_MAT3x2:
</ins><span class="cx">             return 3;
</span><span class="cx">         case SH_FLOAT_VEC3:
</span><span class="cx">         case SH_INT_VEC3:
</span><span class="lines">@@ -50,11 +56,17 @@
</span><span class="cx">     switch (type) {
</span><span class="cx">         case SH_FLOAT_MAT4:
</span><span class="cx">         case SH_FLOAT_MAT2:
</span><ins>+        case SH_FLOAT_MAT2x4:
+        case SH_FLOAT_MAT3x4:
+        case SH_FLOAT_MAT4x2:
+        case SH_FLOAT_MAT4x3:
</ins><span class="cx">         case SH_FLOAT_VEC4:
</span><span class="cx">         case SH_INT_VEC4:
</span><span class="cx">         case SH_BOOL_VEC4:
</span><span class="cx">             return 4;
</span><span class="cx">         case SH_FLOAT_MAT3:
</span><ins>+        case SH_FLOAT_MAT2x3:
+        case SH_FLOAT_MAT3x2:
</ins><span class="cx">         case SH_FLOAT_VEC3:
</span><span class="cx">         case SH_INT_VEC3:
</span><span class="cx">         case SH_BOOL_VEC3:
</span><span class="lines">@@ -81,8 +93,14 @@
</span><span class="cx"> {
</span><span class="cx">     switch (type) {
</span><span class="cx">         case SH_FLOAT_MAT4:
</span><ins>+        case SH_FLOAT_MAT2x4:
+        case SH_FLOAT_MAT3x4:
+        case SH_FLOAT_MAT4x3:
+        case SH_FLOAT_MAT4x2:
</ins><span class="cx">             return 4;
</span><span class="cx">         case SH_FLOAT_MAT3:
</span><ins>+        case SH_FLOAT_MAT2x3:
+        case SH_FLOAT_MAT3x2:
</ins><span class="cx">             return 3;
</span><span class="cx">         case SH_FLOAT_MAT2:
</span><span class="cx">             return 2;
</span><span class="lines">@@ -197,6 +215,14 @@
</span><span class="cx">     bottomNonFullRow_ = maxRows_ - 1;
</span><span class="cx">     TVariableInfoList variables(in_variables);
</span><span class="cx"> 
</span><ins>+    // Check whether each variable fits in the available vectors.
+    for (size_t i = 0; i &lt; variables.size(); i++) {
+        const TVariableInfo&amp; variable = variables[i];
+        if (variable.size &gt; maxVectors / GetNumRows(variable.type)) {
+            return false;
+        }
+    }
+
</ins><span class="cx">     // As per GLSL 1.017 Appendix A, Section 7 variables are packed in specific
</span><span class="cx">     // order by type, then by size of array, largest first.
</span><span class="cx">     std::sort(variables.begin(), variables.end(), TVariableInfoComparer());
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorVersionGLSLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VersionGLSL.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VersionGLSL.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/VersionGLSL.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -7,7 +7,6 @@
</span><span class="cx"> #ifndef COMPILER_VERSIONGLSL_H_
</span><span class="cx"> #define COMPILER_VERSIONGLSL_H_
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
</del><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><span class="cx"> 
</span><span class="cx"> // Traverses the intermediate tree to return the minimum GLSL version
</span><span class="lines">@@ -24,6 +23,7 @@
</span><span class="cx"> //   - matrix constructors taking matrix as argument.
</span><span class="cx"> //   - array as &quot;out&quot; function parameters
</span><span class="cx"> //
</span><ins>+// TODO: ES3 equivalent versions of GLSL
</ins><span class="cx"> class TVersionGLSL : public TIntermTraverser {
</span><span class="cx"> public:
</span><span class="cx">     TVersionGLSL(ShShaderType type);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorgenerate_parsersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/generate_parser.sh (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/generate_parser.sh        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/generate_parser.sh        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -25,3 +25,4 @@
</span><span class="cx"> # Generate Parser
</span><span class="cx"> run_flex glslang
</span><span class="cx"> run_bison glslang
</span><ins>+patch --silent --forward &lt; 64bit-lexer-safety.patch
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorglslangl"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.l (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.l        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.l        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx"> 
</span><span class="cx"> %top{
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -33,6 +33,11 @@
</span><span class="cx"> #pragma warning(disable: 4505)
</span><span class="cx"> #pragma warning(disable: 4701)
</span><span class="cx"> #endif
</span><ins>+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored &quot;-Wunknown-pragmas&quot;
+#pragma clang diagnostic ignored &quot;-Wdeprecated-register&quot;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> %{
</span><span class="lines">@@ -40,7 +45,8 @@
</span><span class="cx"> #include &quot;compiler/translator/ParseContext.h&quot;
</span><span class="cx"> #include &quot;compiler/preprocessor/Token.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/util.h&quot;
</span><del>-#include &quot;compiler/translator/glslang_tab.h&quot;
</del><ins>+#include &quot;compiler/translator/length_limits.h&quot;
+#include &quot;glslang_tab.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> /* windows only pragma */
</span><span class="cx"> #ifdef _MSC_VER
</span><span class="lines">@@ -57,8 +63,13 @@
</span><span class="cx"> static yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner);
</span><span class="cx"> static int check_type(yyscan_t yyscanner);
</span><span class="cx"> static int reserved_word(yyscan_t yyscanner);
</span><ins>+static int ES2_reserved_ES3_keyword(TParseContext *context, int token);
+static int ES2_keyword_ES3_reserved(TParseContext *context, int token);
+static int ES2_ident_ES3_keyword(TParseContext *context, int token);
+static int uint_constant(TParseContext *context);
</ins><span class="cx"> static int int_constant(yyscan_t yyscanner);
</span><span class="cx"> static int float_constant(yyscan_t yyscanner);
</span><ins>+static int floatsuffix_check(TParseContext* context);
</ins><span class="cx"> %}
</span><span class="cx"> 
</span><span class="cx"> %option noyywrap nounput never-interactive
</span><span class="lines">@@ -73,16 +84,20 @@
</span><span class="cx"> 
</span><span class="cx"> %%
</span><span class="cx"> 
</span><ins>+%{
+    TParseContext* context = yyextra;
+%}
+
</ins><span class="cx"> &quot;invariant&quot;    { return INVARIANT; }
</span><span class="cx"> &quot;highp&quot;        { return HIGH_PRECISION; }
</span><span class="cx"> &quot;mediump&quot;      { return MEDIUM_PRECISION; }
</span><span class="cx"> &quot;lowp&quot;         { return LOW_PRECISION; }
</span><span class="cx"> &quot;precision&quot;    { return PRECISION; }
</span><span class="cx"> 
</span><del>-&quot;attribute&quot;    { return ATTRIBUTE; }
</del><ins>+&quot;attribute&quot;    { return ES2_keyword_ES3_reserved(context, ATTRIBUTE); }
</ins><span class="cx"> &quot;const&quot;        { return CONST_QUAL; }
</span><span class="cx"> &quot;uniform&quot;      { return UNIFORM; }
</span><del>-&quot;varying&quot;      { return VARYING; }
</del><ins>+&quot;varying&quot;      { return ES2_keyword_ES3_reserved(context, VARYING); }
</ins><span class="cx"> 
</span><span class="cx"> &quot;break&quot;        { return BREAK; }
</span><span class="cx"> &quot;continue&quot;     { return CONTINUE; }
</span><span class="lines">@@ -92,13 +107,21 @@
</span><span class="cx"> 
</span><span class="cx"> &quot;if&quot;           { return IF; }
</span><span class="cx"> &quot;else&quot;         { return ELSE; }
</span><ins>+&quot;switch&quot;       { return ES2_reserved_ES3_keyword(context, SWITCH); }
+&quot;case&quot;         { return ES2_ident_ES3_keyword(context, CASE); }
+&quot;default&quot;      { return ES2_reserved_ES3_keyword(context, DEFAULT); }
</ins><span class="cx"> 
</span><ins>+&quot;centroid&quot;     { return ES2_ident_ES3_keyword(context, CENTROID); }
+&quot;flat&quot;         { return ES2_reserved_ES3_keyword(context, FLAT); }
+&quot;smooth&quot;       { return ES2_ident_ES3_keyword(context, SMOOTH); }
+
</ins><span class="cx"> &quot;in&quot;           { return IN_QUAL; }
</span><span class="cx"> &quot;out&quot;          { return OUT_QUAL; }
</span><span class="cx"> &quot;inout&quot;        { return INOUT_QUAL; }
</span><span class="cx"> 
</span><span class="cx"> &quot;float&quot;        { return FLOAT_TYPE; }
</span><span class="cx"> &quot;int&quot;          { return INT_TYPE; }
</span><ins>+&quot;uint&quot;         { return ES2_ident_ES3_keyword(context, UINT_TYPE); }
</ins><span class="cx"> &quot;void&quot;         { return VOID_TYPE; }
</span><span class="cx"> &quot;bool&quot;         { return BOOL_TYPE; }
</span><span class="cx"> &quot;true&quot;         { yylval-&gt;lex.b = true;  return BOOLCONSTANT; }
</span><span class="lines">@@ -111,6 +134,17 @@
</span><span class="cx"> &quot;mat3&quot;         { return MATRIX3; }
</span><span class="cx"> &quot;mat4&quot;         { return MATRIX4; }
</span><span class="cx"> 
</span><ins>+&quot;mat2x2&quot;         { return ES2_ident_ES3_keyword(context, MATRIX2); }
+&quot;mat3x3&quot;         { return ES2_ident_ES3_keyword(context, MATRIX3); }
+&quot;mat4x4&quot;         { return ES2_ident_ES3_keyword(context, MATRIX4); }
+
+&quot;mat2x3&quot;         { return ES2_ident_ES3_keyword(context, MATRIX2x3); }
+&quot;mat3x2&quot;         { return ES2_ident_ES3_keyword(context, MATRIX3x2); }
+&quot;mat2x4&quot;         { return ES2_ident_ES3_keyword(context, MATRIX2x4); }
+&quot;mat4x2&quot;         { return ES2_ident_ES3_keyword(context, MATRIX4x2); }
+&quot;mat3x4&quot;         { return ES2_ident_ES3_keyword(context, MATRIX3x4); }
+&quot;mat4x3&quot;         { return ES2_ident_ES3_keyword(context, MATRIX4x3); }
+
</ins><span class="cx"> &quot;vec2&quot;         { return VEC2; }
</span><span class="cx"> &quot;vec3&quot;         { return VEC3; }
</span><span class="cx"> &quot;vec4&quot;         { return VEC4; }
</span><span class="lines">@@ -120,70 +154,160 @@
</span><span class="cx"> &quot;bvec2&quot;        { return BVEC2; }
</span><span class="cx"> &quot;bvec3&quot;        { return BVEC3; }
</span><span class="cx"> &quot;bvec4&quot;        { return BVEC4; }
</span><ins>+&quot;uvec2&quot;        { return ES2_ident_ES3_keyword(context, UVEC2); }
+&quot;uvec3&quot;        { return ES2_ident_ES3_keyword(context, UVEC3); }
+&quot;uvec4&quot;        { return ES2_ident_ES3_keyword(context, UVEC4); }
</ins><span class="cx"> 
</span><del>-&quot;sampler2D&quot;          { return SAMPLER2D; }
-&quot;samplerCube&quot;        { return SAMPLERCUBE; }
-&quot;samplerExternalOES&quot; { return SAMPLER_EXTERNAL_OES; }
-&quot;sampler2DRect&quot;      { return SAMPLER2DRECT; }
</del><ins>+&quot;sampler2D&quot;            { return SAMPLER2D; }
+&quot;samplerCube&quot;          { return SAMPLERCUBE; }
+&quot;samplerExternalOES&quot;   { return SAMPLER_EXTERNAL_OES; }
+&quot;sampler3D&quot;            { return ES2_reserved_ES3_keyword(context, SAMPLER3D); }
+&quot;sampler3DRect&quot;        { return ES2_reserved_ES3_keyword(context, SAMPLER3DRECT); }
+&quot;sampler2DRect&quot;        { return SAMPLER2DRECT; }
+&quot;sampler2DArray&quot;       { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAY); }
+&quot;isampler2D&quot;           { return ES2_ident_ES3_keyword(context, ISAMPLER2D); }
+&quot;isampler3D&quot;           { return ES2_ident_ES3_keyword(context, ISAMPLER3D); }
+&quot;isamplerCube&quot;         { return ES2_ident_ES3_keyword(context, ISAMPLERCUBE); }
+&quot;isampler2DArray&quot;      { return ES2_ident_ES3_keyword(context, ISAMPLER2DARRAY); }
+&quot;usampler2D&quot;           { return ES2_ident_ES3_keyword(context, USAMPLER2D); }
+&quot;usampler3D&quot;           { return ES2_ident_ES3_keyword(context, USAMPLER3D); }
+&quot;usamplerCube&quot;         { return ES2_ident_ES3_keyword(context, USAMPLERCUBE); }
+&quot;usampler2DArray&quot;      { return ES2_ident_ES3_keyword(context, USAMPLER2DARRAY); }
+&quot;sampler2DShadow&quot;      { return ES2_reserved_ES3_keyword(context, SAMPLER2DSHADOW); }
+&quot;samplerCubeShadow&quot;    { return ES2_ident_ES3_keyword(context, SAMPLERCUBESHADOW); }
+&quot;sampler2DArrayShadow&quot; { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAYSHADOW); }
</ins><span class="cx"> 
</span><span class="cx"> &quot;struct&quot;       { return STRUCT; }
</span><span class="cx"> 
</span><del>-&quot;asm&quot;          { return reserved_word(yyscanner); }
</del><ins>+&quot;layout&quot;  { return ES2_ident_ES3_keyword(context, LAYOUT); }
</ins><span class="cx"> 
</span><del>-&quot;class&quot;        { return reserved_word(yyscanner); }
-&quot;union&quot;        { return reserved_word(yyscanner); }
-&quot;enum&quot;         { return reserved_word(yyscanner); }
-&quot;typedef&quot;      { return reserved_word(yyscanner); }
-&quot;template&quot;     { return reserved_word(yyscanner); }
-&quot;this&quot;         { return reserved_word(yyscanner); }
-&quot;packed&quot;       { return reserved_word(yyscanner); }
</del><ins>+    /* Reserved keywords for GLSL ES 3.00 that are not reserved for GLSL ES 1.00 */
+&quot;coherent&quot;          |
+&quot;restrict&quot;          |
+&quot;readonly&quot;          |
+&quot;writeonly&quot;         |
+&quot;resource&quot;          |
+&quot;atomic_uint&quot;       |
+&quot;noperspective&quot;     |
+&quot;patch&quot;             |
+&quot;sample&quot;            |
+&quot;subroutine&quot;        |
+&quot;common&quot;            |
+&quot;partition&quot;         |
+&quot;active&quot;            |
</ins><span class="cx"> 
</span><del>-&quot;goto&quot;         { return reserved_word(yyscanner); }
-&quot;switch&quot;       { return reserved_word(yyscanner); }
-&quot;default&quot;      { return reserved_word(yyscanner); }
</del><ins>+&quot;filter&quot;            |
+&quot;image1D&quot;           |
+&quot;image2D&quot;           |
+&quot;image3D&quot;           |
+&quot;imageCube&quot;                |
+&quot;iimage1D&quot;          |
+&quot;iimage2D&quot;          |
+&quot;iimage3D&quot;          |
+&quot;iimageCube&quot;        |
+&quot;uimage1D&quot;          |
+&quot;uimage2D&quot;          |
+&quot;uimage3D&quot;          |
+&quot;uimageCube&quot;        |
+&quot;image1DArray&quot;      |
+&quot;image2DArray&quot;      |
+&quot;iimage1DArray&quot;     |
+&quot;iimage2DArray&quot;     |
+&quot;uimage1DArray&quot;     |
+&quot;uimage2DArray&quot;     |
+&quot;image1DShadow&quot;     |
+&quot;image2DShadow&quot;     |
+&quot;image1DArrayShadow&quot; |
+&quot;image2DArrayShadow&quot; |
+&quot;imageBuffer&quot;       |
+&quot;iimageBuffer&quot;      |
+&quot;uimageBuffer&quot;      |
</ins><span class="cx"> 
</span><del>-&quot;inline&quot;       { return reserved_word(yyscanner); }
-&quot;noinline&quot;     { return reserved_word(yyscanner); }
-&quot;volatile&quot;     { return reserved_word(yyscanner); }
-&quot;public&quot;       { return reserved_word(yyscanner); }
-&quot;static&quot;       { return reserved_word(yyscanner); }
-&quot;extern&quot;       { return reserved_word(yyscanner); }
-&quot;external&quot;     { return reserved_word(yyscanner); }
-&quot;interface&quot;    { return reserved_word(yyscanner); }
-&quot;flat&quot;         { return reserved_word(yyscanner); }
</del><ins>+&quot;sampler1DArray&quot;    |
+&quot;sampler1DArrayShadow&quot; |
+&quot;isampler1D&quot;        |
+&quot;isampler1DArray&quot;   |
+&quot;usampler1D&quot;        |
+&quot;usampler1DArray&quot;   |
+&quot;isampler2DRect&quot;    |
+&quot;usampler2DRect&quot;    |
+&quot;samplerBuffer&quot;     |
+&quot;isamplerBuffer&quot;    |
+&quot;usamplerBuffer&quot;    |
+&quot;sampler2DMS&quot;       |
+&quot;isampler2DMS&quot;      |
+&quot;usampler2DMS&quot;      |
+&quot;sampler2DMSArray&quot;  |
+&quot;isampler2DMSArray&quot; |
+&quot;usampler2DMSArray&quot; { 
+    if (context-&gt;shaderVersion &lt; 300) {
+                yylval-&gt;lex.string = NewPoolTString(yytext); 
+            return check_type(yyscanner); 
+        }
+        return reserved_word(yyscanner);
+}
</ins><span class="cx"> 
</span><del>-&quot;long&quot;         { return reserved_word(yyscanner); }
-&quot;short&quot;        { return reserved_word(yyscanner); }
-&quot;double&quot;       { return reserved_word(yyscanner); }
-&quot;half&quot;         { return reserved_word(yyscanner); }
-&quot;fixed&quot;        { return reserved_word(yyscanner); }
-&quot;unsigned&quot;     { return reserved_word(yyscanner); }
-&quot;superp&quot;       { return reserved_word(yyscanner); }
</del><ins>+    /* Reserved keywords in GLSL ES 1.00 that are not reserved in GLSL ES 3.00 */
+&quot;packed&quot;  {
+    if (context-&gt;shaderVersion &gt;= 300)
+    {
+        yylval-&gt;lex.string = NewPoolTString(yytext);
+        return check_type(yyscanner);
+    }
</ins><span class="cx"> 
</span><del>-&quot;input&quot;        { return reserved_word(yyscanner); }
-&quot;output&quot;       { return reserved_word(yyscanner); }
</del><ins>+    return reserved_word(yyscanner);
+}
</ins><span class="cx"> 
</span><del>-&quot;hvec2&quot;        { return reserved_word(yyscanner); }
-&quot;hvec3&quot;        { return reserved_word(yyscanner); }
-&quot;hvec4&quot;        { return reserved_word(yyscanner); }
-&quot;dvec2&quot;        { return reserved_word(yyscanner); }
-&quot;dvec3&quot;        { return reserved_word(yyscanner); }
-&quot;dvec4&quot;        { return reserved_word(yyscanner); }
-&quot;fvec2&quot;        { return reserved_word(yyscanner); }
-&quot;fvec3&quot;        { return reserved_word(yyscanner); }
-&quot;fvec4&quot;        { return reserved_word(yyscanner); }
</del><ins>+    /* Reserved keywords */
+&quot;asm&quot;          |
</ins><span class="cx"> 
</span><del>-&quot;sampler1D&quot;           { return reserved_word(yyscanner); }
-&quot;sampler3D&quot;           { return reserved_word(yyscanner); }
-&quot;sampler1DShadow&quot;     { return reserved_word(yyscanner); }
-&quot;sampler2DShadow&quot;     { return reserved_word(yyscanner); }
-&quot;sampler3DRect&quot;       { return reserved_word(yyscanner); }
-&quot;sampler2DRectShadow&quot; { return reserved_word(yyscanner); }
</del><ins>+&quot;class&quot;        |
+&quot;union&quot;        |
+&quot;enum&quot;         |
+&quot;typedef&quot;      |
+&quot;template&quot;     |
+&quot;this&quot;         |
</ins><span class="cx"> 
</span><del>-&quot;sizeof&quot;       { return reserved_word(yyscanner); }
-&quot;cast&quot;         { return reserved_word(yyscanner); }
</del><ins>+&quot;goto&quot;         |
</ins><span class="cx"> 
</span><del>-&quot;namespace&quot;    { return reserved_word(yyscanner); }
</del><ins>+&quot;inline&quot;       |
+&quot;noinline&quot;     |
+&quot;volatile&quot;     |
+&quot;public&quot;       |
+&quot;static&quot;       |
+&quot;extern&quot;       |
+&quot;external&quot;     |
+&quot;interface&quot;    |
+
+&quot;long&quot;         |
+&quot;short&quot;        |
+&quot;double&quot;       |
+&quot;half&quot;         |
+&quot;fixed&quot;        |
+&quot;unsigned&quot;     |
+&quot;superp&quot;       |
+
+&quot;input&quot;        |
+&quot;output&quot;       |
+
+&quot;hvec2&quot;        |
+&quot;hvec3&quot;        |
+&quot;hvec4&quot;        |
+&quot;dvec2&quot;        |
+&quot;dvec3&quot;        |
+&quot;dvec4&quot;        |
+&quot;fvec2&quot;        |
+&quot;fvec3&quot;        |
+&quot;fvec4&quot;        |
+
+&quot;sampler1D&quot;    |
+&quot;sampler1DShadow&quot; |
+&quot;sampler2DRectShadow&quot; |
+
+&quot;sizeof&quot;       |
+&quot;cast&quot;         |
+
+&quot;namespace&quot;    |
</ins><span class="cx"> &quot;using&quot;        { return reserved_word(yyscanner); }
</span><span class="cx"> 
</span><span class="cx"> {L}({L}|{D})*       {
</span><span class="lines">@@ -195,10 +319,18 @@
</span><span class="cx"> 0{O}+             { return int_constant(yyscanner); }
</span><span class="cx"> {D}+              { return int_constant(yyscanner); }
</span><span class="cx"> 
</span><ins>+0[xX]{H}+[uU]     { return uint_constant(context); }
+0{O}+[uU]         { return uint_constant(context); }
+{D}+[uU]          { return uint_constant(context); }
+
</ins><span class="cx"> {D}+{E}           { return float_constant(yyscanner); }
</span><span class="cx"> {D}+&quot;.&quot;{D}*({E})? { return float_constant(yyscanner); }
</span><span class="cx"> &quot;.&quot;{D}+({E})?     { return float_constant(yyscanner); }
</span><span class="cx"> 
</span><ins>+{D}+{E}[fF]           { return floatsuffix_check(context); }
+{D}+&quot;.&quot;{D}*({E})?[fF] { return floatsuffix_check(context); }
+&quot;.&quot;{D}+({E})?[fF]     { return floatsuffix_check(context); }
+
</ins><span class="cx"> &quot;+=&quot;            { return ADD_ASSIGN; }
</span><span class="cx"> &quot;-=&quot;            { return SUB_ASSIGN; }
</span><span class="cx"> &quot;*=&quot;            { return MUL_ASSIGN; }
</span><span class="lines">@@ -224,34 +356,38 @@
</span><span class="cx"> &quot;;&quot;             { return SEMICOLON; }
</span><span class="cx"> (&quot;{&quot;|&quot;&lt;%&quot;)      { return LEFT_BRACE; }
</span><span class="cx"> (&quot;}&quot;|&quot;%&gt;&quot;)      { return RIGHT_BRACE; }
</span><del>-&quot;,&quot;         { return COMMA; }
-&quot;:&quot;         { return COLON; }
-&quot;=&quot;         { return EQUAL; }
-&quot;(&quot;         { return LEFT_PAREN; }
-&quot;)&quot;         { return RIGHT_PAREN; }
-(&quot;[&quot;|&quot;&lt;:&quot;)  { return LEFT_BRACKET; }
-(&quot;]&quot;|&quot;:&gt;&quot;)  { return RIGHT_BRACKET; }
-&quot;.&quot;         { return DOT; }
-&quot;!&quot;         { return BANG; }
-&quot;-&quot;         { return DASH; }
-&quot;~&quot;         { return TILDE; }
-&quot;+&quot;         { return PLUS; }
-&quot;*&quot;         { return STAR; }
-&quot;/&quot;         { return SLASH; }
-&quot;%&quot;         { return PERCENT; }
-&quot;&lt;&quot;         { return LEFT_ANGLE; }
-&quot;&gt;&quot;         { return RIGHT_ANGLE; }
-&quot;|&quot;         { return VERTICAL_BAR; }
-&quot;^&quot;         { return CARET; }
-&quot;&amp;&quot;         { return AMPERSAND; }
-&quot;?&quot;         { return QUESTION; }
</del><ins>+&quot;,&quot;             { return COMMA; }
+&quot;:&quot;             { return COLON; }
+&quot;=&quot;             { return EQUAL; }
+&quot;(&quot;             { return LEFT_PAREN; }
+&quot;)&quot;             { return RIGHT_PAREN; }
+(&quot;[&quot;|&quot;&lt;:&quot;)      { return LEFT_BRACKET; }
+(&quot;]&quot;|&quot;:&gt;&quot;)      { return RIGHT_BRACKET; }
+&quot;.&quot;             { return DOT; }
+&quot;!&quot;             { return BANG; }
+&quot;-&quot;             { return DASH; }
+&quot;~&quot;             { return TILDE; }
+&quot;+&quot;             { return PLUS; }
+&quot;*&quot;             { return STAR; }
+&quot;/&quot;             { return SLASH; }
+&quot;%&quot;             { return PERCENT; }
+&quot;&lt;&quot;             { return LEFT_ANGLE; }
+&quot;&gt;&quot;             { return RIGHT_ANGLE; }
+&quot;|&quot;             { return VERTICAL_BAR; }
+&quot;^&quot;             { return CARET; }
+&quot;&amp;&quot;             { return AMPERSAND; }
+&quot;?&quot;             { return QUESTION; }
</ins><span class="cx"> 
</span><span class="cx"> [ \t\v\n\f\r] { }
</span><del>-&lt;&lt;EOF&gt;&gt;    { yyterminate(); }
-.          { assert(false); return 0; }
</del><ins>+&lt;&lt;EOF&gt;&gt;       { yyterminate(); }
+.             { assert(false); return 0; }
</ins><span class="cx"> 
</span><span class="cx"> %%
</span><span class="cx"> 
</span><ins>+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
</ins><span class="cx"> yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) {
</span><span class="cx">     pp::Token token;
</span><span class="cx">     yyget_extra(yyscanner)-&gt;preprocessor.lex(&amp;token);
</span><span class="lines">@@ -272,11 +408,12 @@
</span><span class="cx">     struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
</span><span class="cx">     
</span><span class="cx">     int token = IDENTIFIER;
</span><del>-    TSymbol* symbol = yyextra-&gt;symbolTable.find(yytext);
</del><ins>+    TSymbol* symbol = yyextra-&gt;symbolTable.find(yytext, yyextra-&gt;shaderVersion);
</ins><span class="cx">     if (symbol &amp;&amp; symbol-&gt;isVariable()) {
</span><span class="cx">         TVariable* variable = static_cast&lt;TVariable*&gt;(symbol);
</span><del>-        if (variable-&gt;isUserType())
</del><ins>+        if (variable-&gt;isUserType()) {
</ins><span class="cx">             token = TYPE_NAME;
</span><ins>+        }
</ins><span class="cx">     }
</span><span class="cx">     yylval-&gt;lex.symbol = symbol;
</span><span class="cx">     return token;
</span><span class="lines">@@ -290,6 +427,80 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int ES2_reserved_ES3_keyword(TParseContext *context, int token)
+{
+    yyscan_t yyscanner = (yyscan_t) context-&gt;scanner;
+
+    if (context-&gt;shaderVersion &lt; 300)
+    {
+        return reserved_word(yyscanner);
+    }
+
+    return token;
+}
+
+int ES2_keyword_ES3_reserved(TParseContext *context, int token)
+{
+    yyscan_t yyscanner = (yyscan_t) context-&gt;scanner;
+
+    if (context-&gt;shaderVersion &gt;= 300)
+    {
+        return reserved_word(yyscanner);
+    }
+
+    return token;
+}
+
+int ES2_ident_ES3_keyword(TParseContext *context, int token)
+{
+    struct yyguts_t* yyg = (struct yyguts_t*) context-&gt;scanner;
+    yyscan_t yyscanner = (yyscan_t) context-&gt;scanner;
+
+    // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name
+    if (context-&gt;shaderVersion &lt; 300)
+    {
+        yylval-&gt;lex.string = NewPoolTString(yytext);
+        return check_type(yyscanner);
+    }
+
+    return token;
+}
+
+int uint_constant(TParseContext *context)
+{
+    struct yyguts_t* yyg = (struct yyguts_t*) context-&gt;scanner;
+    yyscan_t yyscanner = (yyscan_t) context-&gt;scanner;
+
+    if (context-&gt;shaderVersion &lt; 300)
+    {
+        context-&gt;error(*yylloc, &quot;Unsigned integers are unsupported prior to GLSL ES 3.00&quot;, yytext, &quot;&quot;);
+        context-&gt;recover();
+        return 0;
+    }
+
+    if (!atoi_clamp(yytext, &amp;(yylval-&gt;lex.i)))
+        yyextra-&gt;warning(*yylloc, &quot;Integer overflow&quot;, yytext, &quot;&quot;);
+
+    return UINTCONSTANT;
+}
+
+int floatsuffix_check(TParseContext* context)
+{
+    struct yyguts_t* yyg = (struct yyguts_t*) context-&gt;scanner;
+
+    if (context-&gt;shaderVersion &lt; 300)
+    {
+        context-&gt;error(*yylloc, &quot;Floating-point suffix unsupported prior to GLSL ES 3.00&quot;, yytext);
+        context-&gt;recover();
+        return 0;
+    }
+
+    if (!atof_clamp(yytext, &amp;(yylval-&gt;lex.f)))
+        yyextra-&gt;warning(*yylloc, &quot;Float overflow&quot;, yytext, &quot;&quot;);
+
+    return(FLOATCONSTANT);
+}
+
</ins><span class="cx"> void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason) {
</span><span class="cx">     context-&gt;error(*lloc, reason, yyget_text(context-&gt;scanner));
</span><span class="cx">     context-&gt;recover();
</span><span class="lines">@@ -339,7 +550,6 @@
</span><span class="cx">     // Initialize preprocessor.
</span><span class="cx">     if (!context-&gt;preprocessor.init(count, string, length))
</span><span class="cx">         return 1;
</span><del>-    context-&gt;preprocessor.setMaxTokenLength(SH_MAX_TOKEN_LENGTH);
</del><span class="cx"> 
</span><span class="cx">     // Define extension macros.
</span><span class="cx">     const TExtensionBehavior&amp; extBehavior = context-&gt;extensionBehavior();
</span><span class="lines">@@ -350,6 +560,8 @@
</span><span class="cx">     if (context-&gt;fragmentPrecisionHigh)
</span><span class="cx">         context-&gt;preprocessor.predefineMacro(&quot;GL_FRAGMENT_PRECISION_HIGH&quot;, 1);
</span><span class="cx"> 
</span><ins>+    context-&gt;preprocessor.setMaxTokenSize(GetGlobalMaxTokenSize(context-&gt;shaderSpec));
+
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.l
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorglslangy"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.y (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.y        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang.y        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx"> 
</span><span class="cx"> %{
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -41,18 +41,16 @@
</span><span class="cx"> #define YYENABLE_NLS 0
</span><span class="cx"> 
</span><span class="cx"> #define YYLEX_PARAM context-&gt;scanner
</span><del>-%}
</del><span class="cx"> 
</span><ins>+%}
</ins><span class="cx"> %expect 1 /* One shift reduce conflict because of if | else */
</span><span class="cx"> %pure-parser
</span><span class="cx"> %parse-param {TParseContext* context}
</span><span class="cx"> %locations
</span><del>-%lex-param {YYLEX_PARAM}
</del><span class="cx"> 
</span><span class="cx"> %code requires {
</span><span class="cx"> #define YYLTYPE TSourceLoc
</span><span class="cx"> #define YYLTYPE_IS_DECLARED 1
</span><del>-#define SH_MAX_TOKEN_LENGTH 256  // WebGL spec.
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> %union {
</span><span class="lines">@@ -61,6 +59,7 @@
</span><span class="cx">             TString *string;
</span><span class="cx">             float f;
</span><span class="cx">             int i;
</span><ins>+            unsigned int u;
</ins><span class="cx">             bool b;
</span><span class="cx">         };
</span><span class="cx">         TSymbol* symbol;
</span><span class="lines">@@ -76,6 +75,7 @@
</span><span class="cx">         union {
</span><span class="cx">             TPublicType type;
</span><span class="cx">             TPrecision precision;
</span><ins>+            TLayoutQualifier layoutQualifier;
</ins><span class="cx">             TQualifier qualifier;
</span><span class="cx">             TFunction* function;
</span><span class="cx">             TParameter param;
</span><span class="lines">@@ -91,7 +91,7 @@
</span><span class="cx"> 
</span><span class="cx"> #define YYLLOC_DEFAULT(Current, Rhs, N)                      \
</span><span class="cx">   do {                                                       \
</span><del>-      if (N) {                                               \
</del><ins>+      if (YYID(N)) {                                         \
</ins><span class="cx">         (Current).first_file = YYRHSLOC(Rhs, 1).first_file;  \
</span><span class="cx">         (Current).first_line = YYRHSLOC(Rhs, 1).first_line;  \
</span><span class="cx">         (Current).last_file = YYRHSLOC(Rhs, N).last_file;    \
</span><span class="lines">@@ -118,17 +118,38 @@
</span><span class="cx">         context-&gt;recover();  \
</span><span class="cx">     }  \
</span><span class="cx"> }
</span><ins>+
+#define ES2_ONLY(S, L) {  \
+    if (context-&gt;shaderVersion != 100) {  \
+        context-&gt;error(L, &quot; supported in GLSL ES 1.00 only &quot;, S);  \
+        context-&gt;recover();  \
+    }  \
+}
+
+#define ES3_ONLY(TOKEN, LINE, REASON) {  \
+    if (context-&gt;shaderVersion != 300) {  \
+        context-&gt;error(LINE, REASON &quot; supported in GLSL ES 3.00 only &quot;, TOKEN);  \
+        context-&gt;recover();  \
+    }  \
+}
</ins><span class="cx"> %}
</span><span class="cx"> 
</span><span class="cx"> %token &lt;lex&gt; INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION
</span><del>-%token &lt;lex&gt; ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE
-%token &lt;lex&gt; BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN
-%token &lt;lex&gt; BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4
</del><ins>+%token &lt;lex&gt; ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE UINT_TYPE
+%token &lt;lex&gt; BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
+%token &lt;lex&gt; BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4 UVEC2 UVEC3 UVEC4
</ins><span class="cx"> %token &lt;lex&gt; MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING
</span><ins>+%token &lt;lex&gt; MATRIX2x3 MATRIX3x2 MATRIX2x4 MATRIX4x2 MATRIX3x4 MATRIX4x3
+%token &lt;lex&gt; CENTROID FLAT SMOOTH
</ins><span class="cx"> %token &lt;lex&gt; STRUCT VOID_TYPE WHILE
</span><del>-%token &lt;lex&gt; SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES SAMPLER2DRECT
</del><ins>+%token &lt;lex&gt; SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES SAMPLER2DRECT SAMPLER2DARRAY
+%token &lt;lex&gt; ISAMPLER2D ISAMPLER3D ISAMPLERCUBE ISAMPLER2DARRAY
+%token &lt;lex&gt; USAMPLER2D USAMPLER3D USAMPLERCUBE USAMPLER2DARRAY
+%token &lt;lex&gt; SAMPLER3D SAMPLER3DRECT SAMPLER2DSHADOW SAMPLERCUBESHADOW SAMPLER2DARRAYSHADOW
+%token &lt;lex&gt; LAYOUT
</ins><span class="cx"> 
</span><del>-%token &lt;lex&gt; IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT
</del><ins>+%token &lt;lex&gt; IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT UINTCONSTANT BOOLCONSTANT
+%token &lt;lex&gt; FIELD_SELECTION
</ins><span class="cx"> %token &lt;lex&gt; LEFT_OP RIGHT_OP
</span><span class="cx"> %token &lt;lex&gt; INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
</span><span class="cx"> %token &lt;lex&gt; AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
</span><span class="lines">@@ -161,10 +182,11 @@
</span><span class="cx"> %type &lt;interm&gt; single_declaration init_declarator_list
</span><span class="cx"> 
</span><span class="cx"> %type &lt;interm&gt; parameter_declaration parameter_declarator parameter_type_specifier
</span><del>-%type &lt;interm.qualifier&gt; parameter_qualifier
</del><ins>+%type &lt;interm.qualifier&gt; parameter_qualifier parameter_type_qualifier 
+%type &lt;interm.layoutQualifier&gt; layout_qualifier layout_qualifier_id_list layout_qualifier_id
</ins><span class="cx"> 
</span><span class="cx"> %type &lt;interm.precision&gt; precision_qualifier
</span><del>-%type &lt;interm.type&gt; type_qualifier fully_specified_type type_specifier
</del><ins>+%type &lt;interm.type&gt; type_qualifier fully_specified_type type_specifier storage_qualifier interpolation_qualifier
</ins><span class="cx"> %type &lt;interm.type&gt; type_specifier_no_prec type_specifier_nonarray
</span><span class="cx"> %type &lt;interm.type&gt; struct_specifier
</span><span class="cx"> %type &lt;interm.field&gt; struct_declarator
</span><span class="lines">@@ -174,6 +196,8 @@
</span><span class="cx"> %type &lt;interm&gt; function_call_header_with_parameters function_call_header_no_parameters function_call_generic function_prototype
</span><span class="cx"> %type &lt;interm&gt; function_call_or_method
</span><span class="cx"> 
</span><ins>+%type &lt;lex&gt; enter_struct
+
</ins><span class="cx"> %start translation_unit
</span><span class="cx"> %%
</span><span class="cx"> 
</span><span class="lines">@@ -201,7 +225,7 @@
</span><span class="cx">         {
</span><span class="cx">             variable = static_cast&lt;const TVariable*&gt;(symbol);
</span><span class="cx"> 
</span><del>-            if (context-&gt;symbolTable.findBuiltIn(variable-&gt;getName()) &amp;&amp;
</del><ins>+            if (context-&gt;symbolTable.findBuiltIn(variable-&gt;getName(), context-&gt;shaderVersion) &amp;&amp;
</ins><span class="cx">                 !variable-&gt;getExtension().empty() &amp;&amp;
</span><span class="cx">                 context-&gt;extensionErrorCheck(@1, variable-&gt;getExtension()))
</span><span class="cx">             {
</span><span class="lines">@@ -213,7 +237,7 @@
</span><span class="cx">         {
</span><span class="cx">             TType type(EbtFloat, EbpUndefined);
</span><span class="cx">             TVariable *fakeVariable = new TVariable($1.string, type);
</span><del>-            context-&gt;symbolTable.insert(*fakeVariable);
</del><ins>+            context-&gt;symbolTable.declare(*fakeVariable);
</ins><span class="cx">             variable = fakeVariable;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -245,6 +269,11 @@
</span><span class="cx">         unionArray-&gt;setIConst($1.i);
</span><span class="cx">         $$ = context-&gt;intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), @1);
</span><span class="cx">     }
</span><ins>+    | UINTCONSTANT {
+        ConstantUnion *unionArray = new ConstantUnion[1];
+        unionArray-&gt;setUConst($1.u);
+        $$ = context-&gt;intermediate.addConstantUnion(unionArray, TType(EbtUInt, EbpUndefined, EvqConst), @1);
+    }
</ins><span class="cx">     | FLOATCONSTANT {
</span><span class="cx">         ConstantUnion *unionArray = new ConstantUnion[1];
</span><span class="cx">         unionArray-&gt;setFConst($1.f);
</span><span class="lines">@@ -271,104 +300,12 @@
</span><span class="cx">         $$ = $1;
</span><span class="cx">     }
</span><span class="cx">     | postfix_expression DOT identifier {
</span><del>-        if ($1-&gt;isArray()) {
-            context-&gt;error(@3, &quot;cannot apply dot operator to an array&quot;, &quot;.&quot;);
-            context-&gt;recover();
-        }
-
-        if ($1-&gt;isVector()) {
-            TVectorFields fields;
-            if (! context-&gt;parseVectorFields(*$3.string, $1-&gt;getNominalSize(), fields, @3)) {
-                fields.num = 1;
-                fields.offsets[0] = 0;
-                context-&gt;recover();
-            }
-
-            if ($1-&gt;getType().getQualifier() == EvqConst) { // constant folding for vector fields
-                $$ = context-&gt;addConstVectorNode(fields, $1, @3);
-                if ($$ == 0) {
-                    context-&gt;recover();
-                    $$ = $1;
-                }
-                else
-                    $$-&gt;setType(TType($1-&gt;getBasicType(), $1-&gt;getPrecision(), EvqConst, (int) (*$3.string).size()));
-            } else {
-                TString vectorString = *$3.string;
-                TIntermTyped* index = context-&gt;intermediate.addSwizzle(fields, @3);
-                $$ = context-&gt;intermediate.addIndex(EOpVectorSwizzle, $1, index, @2);
-                $$-&gt;setType(TType($1-&gt;getBasicType(), $1-&gt;getPrecision(), EvqTemporary, (int) vectorString.size()));
-            }
-        } else if ($1-&gt;isMatrix()) {
-            TMatrixFields fields;
-            if (! context-&gt;parseMatrixFields(*$3.string, $1-&gt;getNominalSize(), fields, @3)) {
-                fields.wholeRow = false;
-                fields.wholeCol = false;
-                fields.row = 0;
-                fields.col = 0;
-                context-&gt;recover();
-            }
-
-            if (fields.wholeRow || fields.wholeCol) {
-                context-&gt;error(@2, &quot; non-scalar fields not implemented yet&quot;, &quot;.&quot;);
-                context-&gt;recover();
-                ConstantUnion *unionArray = new ConstantUnion[1];
-                unionArray-&gt;setIConst(0);
-                TIntermTyped* index = context-&gt;intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), @3);
-                $$ = context-&gt;intermediate.addIndex(EOpIndexDirect, $1, index, @2);
-                $$-&gt;setType(TType($1-&gt;getBasicType(), $1-&gt;getPrecision(),EvqTemporary, $1-&gt;getNominalSize()));
-            } else {
-                ConstantUnion *unionArray = new ConstantUnion[1];
-                unionArray-&gt;setIConst(fields.col * $1-&gt;getNominalSize() + fields.row);
-                TIntermTyped* index = context-&gt;intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), @3);
-                $$ = context-&gt;intermediate.addIndex(EOpIndexDirect, $1, index, @2);
-                $$-&gt;setType(TType($1-&gt;getBasicType(), $1-&gt;getPrecision()));
-            }
-        } else if ($1-&gt;getBasicType() == EbtStruct) {
-            bool fieldFound = false;
-            const TFieldList&amp; fields = $1-&gt;getType().getStruct()-&gt;fields();
-            unsigned int i;
-            for (i = 0; i &lt; fields.size(); ++i) {
-                if (fields[i]-&gt;name() == *$3.string) {
-                    fieldFound = true;
-                    break;
-                }
-            }
-            if (fieldFound) {
-                if ($1-&gt;getType().getQualifier() == EvqConst) {
-                    $$ = context-&gt;addConstStruct(*$3.string, $1, @2);
-                    if ($$ == 0) {
-                        context-&gt;recover();
-                        $$ = $1;
-                    }
-                    else {
-                        $$-&gt;setType(*fields[i]-&gt;type());
-                        // change the qualifier of the return type, not of the structure field
-                        // as the structure definition is shared between various structures.
-                        $$-&gt;getTypePointer()-&gt;setQualifier(EvqConst);
-                    }
-                } else {
-                    ConstantUnion *unionArray = new ConstantUnion[1];
-                    unionArray-&gt;setIConst(i);
-                    TIntermTyped* index = context-&gt;intermediate.addConstantUnion(unionArray, *fields[i]-&gt;type(), @3);
-                    $$ = context-&gt;intermediate.addIndex(EOpIndexDirectStruct, $1, index, @2);
-                    $$-&gt;setType(*fields[i]-&gt;type());
-                }
-            } else {
-                context-&gt;error(@2, &quot; no such field in structure&quot;, $3.string-&gt;c_str());
-                context-&gt;recover();
-                $$ = $1;
-            }
-        } else {
-            context-&gt;error(@2, &quot; field selection requires structure, vector, or matrix on left hand side&quot;, $3.string-&gt;c_str());
-            context-&gt;recover();
-            $$ = $1;
-        }
-        // don't delete $3.string, it's from the pool
</del><ins>+        $$ = context-&gt;addFieldSelectionExpression($1, @2, *$3.string, @3);
</ins><span class="cx">     }
</span><span class="cx">     | postfix_expression INC_OP {
</span><span class="cx">         if (context-&gt;lValueErrorCheck(@2, &quot;++&quot;, $1))
</span><span class="cx">             context-&gt;recover();
</span><del>-        $$ = context-&gt;intermediate.addUnaryMath(EOpPostIncrement, $1, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addUnaryMath(EOpPostIncrement, $1, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;unaryOpError(@2, &quot;++&quot;, $1-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -378,7 +315,7 @@
</span><span class="cx">     | postfix_expression DEC_OP {
</span><span class="cx">         if (context-&gt;lValueErrorCheck(@2, &quot;--&quot;, $1))
</span><span class="cx">             context-&gt;recover();
</span><del>-        $$ = context-&gt;intermediate.addUnaryMath(EOpPostDecrement, $1, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addUnaryMath(EOpPostDecrement, $1, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;unaryOpError(@2, &quot;--&quot;, $1-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -428,7 +365,7 @@
</span><span class="cx">             //
</span><span class="cx">             const TFunction* fnCandidate;
</span><span class="cx">             bool builtIn;
</span><del>-            fnCandidate = context-&gt;findFunction(@1, fnCall, &amp;builtIn);
</del><ins>+            fnCandidate = context-&gt;findFunction(@1, fnCall, context-&gt;shaderVersion, &amp;builtIn);
</ins><span class="cx">             if (fnCandidate) {
</span><span class="cx">                 //
</span><span class="cx">                 // A declared function.
</span><span class="lines">@@ -446,7 +383,7 @@
</span><span class="cx">                         //
</span><span class="cx">                         // Treat it like a built-in unary operator.
</span><span class="cx">                         //
</span><del>-                        $$ = context-&gt;intermediate.addUnaryMath(op, $1.intermNode, @1, context-&gt;symbolTable);
</del><ins>+                        $$ = context-&gt;intermediate.addUnaryMath(op, $1.intermNode, @1);
</ins><span class="cx">                         if ($$ == 0)  {
</span><span class="cx">                             std::stringstream extraInfoStream;
</span><span class="cx">                             extraInfoStream &lt;&lt; &quot;built in unary operator function.  Type: &quot; &lt;&lt; static_cast&lt;TIntermTyped*&gt;($1.intermNode)-&gt;getCompleteString();
</span><span class="lines">@@ -551,59 +488,7 @@
</span><span class="cx"> 
</span><span class="cx"> function_identifier
</span><span class="cx">     : type_specifier_nonarray {
</span><del>-        //
-        // Constructor
-        //
-        TOperator op = EOpNull;
-        if ($1.userDef) {
-            op = EOpConstructStruct;
-        } else {
-            switch ($1.type) {
-            case EbtFloat:
-                if ($1.matrix) {
-                    switch($1.size) {
-                    case 2: op = EOpConstructMat2;  break;
-                    case 3: op = EOpConstructMat3;  break;
-                    case 4: op = EOpConstructMat4;  break;
-                    }
-                } else {
-                    switch($1.size) {
-                    case 1: op = EOpConstructFloat; break;
-                    case 2: op = EOpConstructVec2;  break;
-                    case 3: op = EOpConstructVec3;  break;
-                    case 4: op = EOpConstructVec4;  break;
-                    }
-                }
-                break;
-            case EbtInt:
-                switch($1.size) {
-                case 1: op = EOpConstructInt;   break;
-                case 2: op = EOpConstructIVec2; break;
-                case 3: op = EOpConstructIVec3; break;
-                case 4: op = EOpConstructIVec4; break;
-                }
-                break;
-            case EbtBool:
-                switch($1.size) {
-                case 1: op = EOpConstructBool;  break;
-                case 2: op = EOpConstructBVec2; break;
-                case 3: op = EOpConstructBVec3; break;
-                case 4: op = EOpConstructBVec4; break;
-                }
-                break;
-            default: break;
-            }
-            if (op == EOpNull) {
-                context-&gt;error(@1, &quot;cannot construct this type&quot;, getBasicString($1.type));
-                context-&gt;recover();
-                $1.type = EbtFloat;
-                op = EOpConstructFloat;
-            }
-        }
-        TString tempString;
-        TType type($1);
-        TFunction *function = new TFunction(&amp;tempString, type, op);
-        $$ = function;
</del><ins>+        $$ = context-&gt;addConstructorFunc($1);
</ins><span class="cx">     }
</span><span class="cx">     | IDENTIFIER {
</span><span class="cx">         if (context-&gt;reservedErrorCheck(@1, *$1.string))
</span><span class="lines">@@ -621,7 +506,7 @@
</span><span class="cx">     | INC_OP unary_expression {
</span><span class="cx">         if (context-&gt;lValueErrorCheck(@1, &quot;++&quot;, $2))
</span><span class="cx">             context-&gt;recover();
</span><del>-        $$ = context-&gt;intermediate.addUnaryMath(EOpPreIncrement, $2, @1, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addUnaryMath(EOpPreIncrement, $2, @1);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;unaryOpError(@1, &quot;++&quot;, $2-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -631,7 +516,7 @@
</span><span class="cx">     | DEC_OP unary_expression {
</span><span class="cx">         if (context-&gt;lValueErrorCheck(@1, &quot;--&quot;, $2))
</span><span class="cx">             context-&gt;recover();
</span><del>-        $$ = context-&gt;intermediate.addUnaryMath(EOpPreDecrement, $2, @1, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addUnaryMath(EOpPreDecrement, $2, @1);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;unaryOpError(@1, &quot;--&quot;, $2-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -640,7 +525,7 @@
</span><span class="cx">     }
</span><span class="cx">     | unary_operator unary_expression {
</span><span class="cx">         if ($1.op != EOpNull) {
</span><del>-            $$ = context-&gt;intermediate.addUnaryMath($1.op, $2, @1, context-&gt;symbolTable);
</del><ins>+            $$ = context-&gt;intermediate.addUnaryMath($1.op, $2, @1);
</ins><span class="cx">             if ($$ == 0) {
</span><span class="cx">                 const char* errorOp = &quot;&quot;;
</span><span class="cx">                 switch($1.op) {
</span><span class="lines">@@ -668,7 +553,7 @@
</span><span class="cx"> multiplicative_expression
</span><span class="cx">     : unary_expression { $$ = $1; }
</span><span class="cx">     | multiplicative_expression STAR unary_expression {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpMul, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpMul, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;*&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -676,7 +561,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     | multiplicative_expression SLASH unary_expression {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpDiv, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpDiv, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;/&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -688,7 +573,7 @@
</span><span class="cx"> additive_expression
</span><span class="cx">     : multiplicative_expression { $$ = $1; }
</span><span class="cx">     | additive_expression PLUS multiplicative_expression {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpAdd, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpAdd, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;+&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -696,7 +581,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     | additive_expression DASH multiplicative_expression {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpSub, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpSub, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;-&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -712,7 +597,7 @@
</span><span class="cx"> relational_expression
</span><span class="cx">     : shift_expression { $$ = $1; }
</span><span class="cx">     | relational_expression LEFT_ANGLE shift_expression {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpLessThan, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpLessThan, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;&lt;&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -722,7 +607,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     | relational_expression RIGHT_ANGLE shift_expression  {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpGreaterThan, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpGreaterThan, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;&gt;&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -732,7 +617,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     | relational_expression LE_OP shift_expression  {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;&lt;=&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -742,7 +627,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     | relational_expression GE_OP shift_expression  {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;&gt;=&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -756,7 +641,7 @@
</span><span class="cx"> equality_expression
</span><span class="cx">     : relational_expression { $$ = $1; }
</span><span class="cx">     | equality_expression EQ_OP relational_expression  {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpEqual, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpEqual, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;==&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -766,7 +651,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     | equality_expression NE_OP relational_expression {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpNotEqual, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpNotEqual, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;!=&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -792,7 +677,7 @@
</span><span class="cx"> logical_and_expression
</span><span class="cx">     : inclusive_or_expression { $$ = $1; }
</span><span class="cx">     | logical_and_expression AND_OP inclusive_or_expression {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;&amp;&amp;&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -806,7 +691,7 @@
</span><span class="cx"> logical_xor_expression
</span><span class="cx">     : logical_and_expression { $$ = $1; }
</span><span class="cx">     | logical_xor_expression XOR_OP logical_and_expression  {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpLogicalXor, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpLogicalXor, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;^^&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -820,7 +705,7 @@
</span><span class="cx"> logical_or_expression
</span><span class="cx">     : logical_xor_expression { $$ = $1; }
</span><span class="cx">     | logical_or_expression OR_OP logical_xor_expression  {
</span><del>-        $$ = context-&gt;intermediate.addBinaryMath(EOpLogicalOr, $1, $3, @2, context-&gt;symbolTable);
</del><ins>+        $$ = context-&gt;intermediate.addBinaryMath(EOpLogicalOr, $1, $3, @2);
</ins><span class="cx">         if ($$ == 0) {
</span><span class="cx">             context-&gt;binaryOpError(@2, &quot;||&quot;, $1-&gt;getCompleteString(), $3-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -893,6 +778,14 @@
</span><span class="cx">     }
</span><span class="cx">     ;
</span><span class="cx"> 
</span><ins>+enter_struct
+    : IDENTIFIER LEFT_BRACE {
+        if (context-&gt;enterStructDeclaration(@1, *$1.string))
+            context-&gt;recover();
+        $$ = $1;
+    }
+    ;
+
</ins><span class="cx"> declaration
</span><span class="cx">     : function_prototype SEMICOLON   {
</span><span class="cx">         TFunction &amp;function = *($1.function);
</span><span class="lines">@@ -937,6 +830,22 @@
</span><span class="cx">         }
</span><span class="cx">         $$ = 0;
</span><span class="cx">     }
</span><ins>+    | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE SEMICOLON {
+        ES3_ONLY(getQualifierString($1.qualifier), @1, &quot;interface blocks&quot;);
+        $$ = context-&gt;addInterfaceBlock($1, @2, *$2.string, $3, NULL, @$, NULL, @$);
+    }
+    | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE IDENTIFIER SEMICOLON {
+        ES3_ONLY(getQualifierString($1.qualifier), @1, &quot;interface blocks&quot;);
+        $$ = context-&gt;addInterfaceBlock($1, @2, *$2.string, $3, $5.string, @5, NULL, @$);
+    }
+    | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET SEMICOLON {
+        ES3_ONLY(getQualifierString($1.qualifier), @1, &quot;interface blocks&quot;);
+        $$ = context-&gt;addInterfaceBlock($1, @2, *$2.string, $3, $5.string, @5, $7, @6);
+    }
+    | type_qualifier SEMICOLON {
+        context-&gt;parseGlobalLayoutQualifier($1);
+        $$ = 0;
+    }
</ins><span class="cx">     ;
</span><span class="cx"> 
</span><span class="cx"> function_prototype
</span><span class="lines">@@ -949,7 +858,7 @@
</span><span class="cx">         //
</span><span class="cx">         // Redeclarations are allowed.  But, return types and parameter qualifiers must match.
</span><span class="cx">         //
</span><del>-        TFunction* prevDec = static_cast&lt;TFunction*&gt;(context-&gt;symbolTable.find($1-&gt;getMangledName()));
</del><ins>+        TFunction* prevDec = static_cast&lt;TFunction*&gt;(context-&gt;symbolTable.find($1-&gt;getMangledName(), context-&gt;shaderVersion));
</ins><span class="cx">         if (prevDec) {
</span><span class="cx">             if (prevDec-&gt;getReturnType() != $1-&gt;getReturnType()) {
</span><span class="cx">                 context-&gt;error(@2, &quot;overloaded functions must have the same return type&quot;, $1-&gt;getReturnType().getBasicString());
</span><span class="lines">@@ -966,7 +875,7 @@
</span><span class="cx">         //
</span><span class="cx">         // Check for previously declared variables using the same name.
</span><span class="cx">         //
</span><del>-        TSymbol *prevSym = context-&gt;symbolTable.find($1-&gt;getName());
</del><ins>+        TSymbol *prevSym = context-&gt;symbolTable.find($1-&gt;getName(), context-&gt;shaderVersion);
</ins><span class="cx">         if (prevSym)
</span><span class="cx">         {
</span><span class="cx">             if (!prevSym-&gt;isFunction())
</span><span class="lines">@@ -1093,9 +1002,9 @@
</span><span class="cx">     //
</span><span class="cx">     // Type + name
</span><span class="cx">     //
</span><del>-    : type_qualifier parameter_qualifier parameter_declarator {
</del><ins>+    : parameter_type_qualifier parameter_qualifier parameter_declarator {
</ins><span class="cx">         $$ = $3;
</span><del>-        if (context-&gt;paramErrorCheck(@3, $1.qualifier, $2, $$.param.type))
</del><ins>+        if (context-&gt;paramErrorCheck(@3, $1, $2, $$.param.type))
</ins><span class="cx">             context-&gt;recover();
</span><span class="cx">     }
</span><span class="cx">     | parameter_qualifier parameter_declarator {
</span><span class="lines">@@ -1108,9 +1017,9 @@
</span><span class="cx">     //
</span><span class="cx">     // Only type
</span><span class="cx">     //
</span><del>-    | type_qualifier parameter_qualifier parameter_type_specifier {
</del><ins>+    | parameter_type_qualifier parameter_qualifier parameter_type_specifier {
</ins><span class="cx">         $$ = $3;
</span><del>-        if (context-&gt;paramErrorCheck(@3, $1.qualifier, $2, $$.param.type))
</del><ins>+        if (context-&gt;paramErrorCheck(@3, $1, $2, $$.param.type))
</ins><span class="cx">             context-&gt;recover();
</span><span class="cx">     }
</span><span class="cx">     | parameter_qualifier parameter_type_specifier {
</span><span class="lines">@@ -1149,173 +1058,46 @@
</span><span class="cx">         $$ = $1;
</span><span class="cx">     }
</span><span class="cx">     | init_declarator_list COMMA identifier {
</span><del>-        if ($1.type.type == EbtInvariant &amp;&amp; !$3.symbol)
-        {
-            context-&gt;error(@3, &quot;undeclared identifier declared as invariant&quot;, $3.string-&gt;c_str());
-            context-&gt;recover();
-        }
-
-        TIntermSymbol* symbol = context-&gt;intermediate.addSymbol(0, *$3.string, TType($1.type), @3);
-        $$.intermAggregate = context-&gt;intermediate.growAggregate($1.intermNode, symbol, @3);
-        
-        if (context-&gt;structQualifierErrorCheck(@3, $$.type))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck(@3, *$3.string, $$.type, false))
-            context-&gt;recover();
-
-        TVariable* variable = 0;
-        if (context-&gt;nonInitErrorCheck(@3, *$3.string, $$.type, variable))
-            context-&gt;recover();
-        if (symbol &amp;&amp; variable)
-            symbol-&gt;setId(variable-&gt;getUniqueId());
</del><ins>+        $$ = $1;
+        $$.intermAggregate = context-&gt;parseDeclarator($$.type, $1.intermAggregate, $3.symbol, @3, *$3.string);
</ins><span class="cx">     }
</span><span class="cx">     | init_declarator_list COMMA identifier LEFT_BRACKET RIGHT_BRACKET {
</span><del>-        if (context-&gt;structQualifierErrorCheck(@3, $1.type))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck(@3, *$3.string, $1.type, true))
-            context-&gt;recover();
-
</del><span class="cx">         $$ = $1;
</span><del>-
-        if (context-&gt;arrayTypeErrorCheck(@4, $1.type) || context-&gt;arrayQualifierErrorCheck(@4, $1.type))
-            context-&gt;recover();
-        else {
-            $1.type.setArray(true);
-            TVariable* variable;
-            if (context-&gt;arrayErrorCheck(@4, *$3.string, $1.type, variable))
-                context-&gt;recover();
-        }
</del><ins>+        context-&gt;parseArrayDeclarator($$.type, @3, *$3.string, @4, NULL, NULL);
</ins><span class="cx">     }
</span><span class="cx">     | init_declarator_list COMMA identifier LEFT_BRACKET constant_expression RIGHT_BRACKET {
</span><del>-        if (context-&gt;structQualifierErrorCheck(@3, $1.type))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck(@3, *$3.string, $1.type, true))
-            context-&gt;recover();
-
</del><span class="cx">         $$ = $1;
</span><del>-
-        if (context-&gt;arrayTypeErrorCheck(@4, $1.type) || context-&gt;arrayQualifierErrorCheck(@4, $1.type))
-            context-&gt;recover();
-        else {
-            int size;
-            if (context-&gt;arraySizeErrorCheck(@4, $5, size))
-                context-&gt;recover();
-            $1.type.setArray(true, size);
-            TVariable* variable = 0;
-            if (context-&gt;arrayErrorCheck(@4, *$3.string, $1.type, variable))
-                context-&gt;recover();
-            TType type = TType($1.type);
-            type.setArraySize(size);
-            $$.intermAggregate = context-&gt;intermediate.growAggregate($1.intermNode, context-&gt;intermediate.addSymbol(variable ? variable-&gt;getUniqueId() : 0, *$3.string, type, @3), @3);
-        }
</del><ins>+        $$.intermAggregate = context-&gt;parseArrayDeclarator($$.type, @3, *$3.string, @4, $1.intermNode, $5);
</ins><span class="cx">     }
</span><span class="cx">     | init_declarator_list COMMA identifier EQUAL initializer {
</span><del>-        if (context-&gt;structQualifierErrorCheck(@3, $1.type))
-            context-&gt;recover();
-
</del><span class="cx">         $$ = $1;
</span><del>-
-        TIntermNode* intermNode;
-        if (!context-&gt;executeInitializer(@3, *$3.string, $1.type, $5, intermNode)) {
-            //
-            // build the intermediate representation
-            //
-            if (intermNode)
-        $$.intermAggregate = context-&gt;intermediate.growAggregate($1.intermNode, intermNode, @4);
-            else
-                $$.intermAggregate = $1.intermAggregate;
-        } else {
-            context-&gt;recover();
-            $$.intermAggregate = 0;
-        }
</del><ins>+        $$.intermAggregate = context-&gt;parseInitDeclarator($$.type, $1.intermAggregate, @3, *$3.string, @4, $5);
</ins><span class="cx">     }
</span><span class="cx">     ;
</span><span class="cx"> 
</span><span class="cx"> single_declaration
</span><span class="cx">     : fully_specified_type {
</span><span class="cx">         $$.type = $1;
</span><del>-        $$.intermAggregate = context-&gt;intermediate.makeAggregate(context-&gt;intermediate.addSymbol(0, &quot;&quot;, TType($1), @1), @1);
</del><ins>+        $$.intermAggregate = context-&gt;parseSingleDeclaration($$.type, @1, &quot;&quot;);
</ins><span class="cx">     }
</span><span class="cx">     | fully_specified_type identifier {
</span><del>-        TIntermSymbol* symbol = context-&gt;intermediate.addSymbol(0, *$2.string, TType($1), @2);
-        $$.intermAggregate = context-&gt;intermediate.makeAggregate(symbol, @2);
-        
-        if (context-&gt;structQualifierErrorCheck(@2, $$.type))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck(@2, *$2.string, $$.type, false))
-            context-&gt;recover();
-            
-            $$.type = $1;
-
-        TVariable* variable = 0;
-        if (context-&gt;nonInitErrorCheck(@2, *$2.string, $$.type, variable))
-            context-&gt;recover();
-        if (variable &amp;&amp; symbol)
-            symbol-&gt;setId(variable-&gt;getUniqueId());
</del><ins>+        $$.type = $1;
+        $$.intermAggregate = context-&gt;parseSingleDeclaration($$.type, @2, *$2.string);
</ins><span class="cx">     }
</span><span class="cx">     | fully_specified_type identifier LEFT_BRACKET RIGHT_BRACKET {
</span><span class="cx">         context-&gt;error(@2, &quot;unsized array declarations not supported&quot;, $2.string-&gt;c_str());
</span><span class="cx">         context-&gt;recover();
</span><span class="cx"> 
</span><del>-        TIntermSymbol* symbol = context-&gt;intermediate.addSymbol(0, *$2.string, TType($1), @2);
-        $$.intermAggregate = context-&gt;intermediate.makeAggregate(symbol, @2);
</del><span class="cx">         $$.type = $1;
</span><ins>+        $$.intermAggregate = context-&gt;parseSingleDeclaration($$.type, @2, *$2.string);
</ins><span class="cx">     }
</span><span class="cx">     | fully_specified_type identifier LEFT_BRACKET constant_expression RIGHT_BRACKET {
</span><del>-        TType type = TType($1);
-        int size;
-        if (context-&gt;arraySizeErrorCheck(@2, $4, size))
-            context-&gt;recover();
-        type.setArraySize(size);
-        TIntermSymbol* symbol = context-&gt;intermediate.addSymbol(0, *$2.string, type, @2);
-        $$.intermAggregate = context-&gt;intermediate.makeAggregate(symbol, @2);
-        
-        if (context-&gt;structQualifierErrorCheck(@2, $1))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck(@2, *$2.string, $1, true))
-            context-&gt;recover();
-
</del><span class="cx">         $$.type = $1;
</span><del>-
-        if (context-&gt;arrayTypeErrorCheck(@3, $1) || context-&gt;arrayQualifierErrorCheck(@3, $1))
-            context-&gt;recover();
-        else {
-            int size;
-            if (context-&gt;arraySizeErrorCheck(@3, $4, size))
-                context-&gt;recover();
-
-            $1.setArray(true, size);
-            TVariable* variable = 0;
-            if (context-&gt;arrayErrorCheck(@3, *$2.string, $1, variable))
-                context-&gt;recover();
-            if (variable &amp;&amp; symbol)
-                symbol-&gt;setId(variable-&gt;getUniqueId());
-        }
</del><ins>+        $$.intermAggregate = context-&gt;parseSingleArrayDeclaration($$.type, @2, *$2.string, @3, $4);
</ins><span class="cx">     }
</span><span class="cx">     | fully_specified_type identifier EQUAL initializer {
</span><del>-        if (context-&gt;structQualifierErrorCheck(@2, $1))
-            context-&gt;recover();
-
</del><span class="cx">         $$.type = $1;
</span><del>-
-        TIntermNode* intermNode;
-        if (!context-&gt;executeInitializer(@2, *$2.string, $1, $4, intermNode)) {
-        //
-        // Build intermediate representation
-        //
-            if(intermNode)
-                $$.intermAggregate = context-&gt;intermediate.makeAggregate(intermNode, @3);
-            else
-                $$.intermAggregate = 0;
-        } else {
-            context-&gt;recover();
-            $$.intermAggregate = 0;
-        }
</del><ins>+        $$.intermAggregate = context-&gt;parseSingleInitDeclaration($$.type, @2, *$2.string, @3, $4);
</ins><span class="cx">     }
</span><span class="cx">     | INVARIANT IDENTIFIER {
</span><span class="cx">         VERTEX_ONLY(&quot;invariant declaration&quot;, @1);
</span><span class="lines">@@ -1348,38 +1130,35 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     | type_qualifier type_specifier  {
</span><del>-        if ($2.array) {
-            context-&gt;error(@2, &quot;not supported&quot;, &quot;first-class array&quot;);
-            context-&gt;recover();
-            $2.setArray(false);
-        }
</del><ins>+        $$ = context-&gt;addFullySpecifiedType($1.qualifier, $1.layoutQualifier, $2);
+    }
+    ;
</ins><span class="cx"> 
</span><del>-        if ($1.qualifier == EvqAttribute &amp;&amp;
-            ($2.type == EbtBool || $2.type == EbtInt)) {
-            context-&gt;error(@2, &quot;cannot be bool or int&quot;, getQualifierString($1.qualifier));
-            context-&gt;recover();
-        }
-        if (($1.qualifier == EvqVaryingIn || $1.qualifier == EvqVaryingOut) &amp;&amp;
-            ($2.type == EbtBool || $2.type == EbtInt)) {
-            context-&gt;error(@2, &quot;cannot be bool or int&quot;, getQualifierString($1.qualifier));
-            context-&gt;recover();
-        }
-        $$ = $2;
-        $$.qualifier = $1.qualifier;
</del><ins>+interpolation_qualifier
+    : SMOOTH {
+        $$.qualifier = EvqSmooth;
</ins><span class="cx">     }
</span><ins>+    | FLAT {
+        $$.qualifier = EvqFlat;
+    }
</ins><span class="cx">     ;
</span><span class="cx"> 
</span><del>-type_qualifier
</del><ins>+parameter_type_qualifier
</ins><span class="cx">     : CONST_QUAL {
</span><del>-        $$.setBasic(EbtVoid, EvqConst, @1);
</del><ins>+        $$ = EvqConst;
</ins><span class="cx">     }
</span><del>-    | ATTRIBUTE {
</del><ins>+    ;
+
+type_qualifier
+    : ATTRIBUTE {
</ins><span class="cx">         VERTEX_ONLY(&quot;attribute&quot;, @1);
</span><ins>+        ES2_ONLY(&quot;attribute&quot;, @1);
</ins><span class="cx">         if (context-&gt;globalErrorCheck(@1, context-&gt;symbolTable.atGlobalLevel(), &quot;attribute&quot;))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         $$.setBasic(EbtVoid, EvqAttribute, @1);
</span><span class="cx">     }
</span><span class="cx">     | VARYING {
</span><ins>+        ES2_ONLY(&quot;varying&quot;, @1);
</ins><span class="cx">         if (context-&gt;globalErrorCheck(@1, context-&gt;symbolTable.atGlobalLevel(), &quot;varying&quot;))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         if (context-&gt;shaderType == SH_VERTEX_SHADER)
</span><span class="lines">@@ -1388,6 +1167,7 @@
</span><span class="cx">             $$.setBasic(EbtVoid, EvqVaryingIn, @1);
</span><span class="cx">     }
</span><span class="cx">     | INVARIANT VARYING {
</span><ins>+        ES2_ONLY(&quot;varying&quot;, @1);
</ins><span class="cx">         if (context-&gt;globalErrorCheck(@1, context-&gt;symbolTable.atGlobalLevel(), &quot;invariant varying&quot;))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         if (context-&gt;shaderType == SH_VERTEX_SHADER)
</span><span class="lines">@@ -1395,10 +1175,68 @@
</span><span class="cx">         else
</span><span class="cx">             $$.setBasic(EbtVoid, EvqInvariantVaryingIn, @1);
</span><span class="cx">     }
</span><ins>+    | storage_qualifier {
+        if ($1.qualifier != EvqConst &amp;&amp; !context-&gt;symbolTable.atGlobalLevel()) {
+            context-&gt;error(@1, &quot;Local variables can only use the const storage qualifier.&quot;, getQualifierString($1.qualifier));
+            context-&gt;recover();
+        } else {
+            $$.setBasic(EbtVoid, $1.qualifier, @1);
+        }
+    }
+    | interpolation_qualifier storage_qualifier {
+        $$ = context-&gt;joinInterpolationQualifiers(@1, $1.qualifier, @2, $2.qualifier);
+    }
+    | interpolation_qualifier {
+        context-&gt;error(@1, &quot;interpolation qualifier requires a fragment 'in' or vertex 'out' storage qualifier&quot;, getInterpolationString($1.qualifier));
+        context-&gt;recover();
+        
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtVoid, qual, @1);
+    }
+    | layout_qualifier {
+        $$.qualifier = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.layoutQualifier = $1;
+    }
+    | layout_qualifier storage_qualifier {
+        $$.setBasic(EbtVoid, $2.qualifier, @2);
+        $$.layoutQualifier = $1;
+    }
+    ;
+
+storage_qualifier
+    : CONST_QUAL {
+        $$.qualifier = EvqConst;
+    }
+    | IN_QUAL {
+        ES3_ONLY(&quot;in&quot;, @1, &quot;storage qualifier&quot;);
+        $$.qualifier = (context-&gt;shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
+    }
+    | OUT_QUAL {
+        ES3_ONLY(&quot;out&quot;, @1, &quot;storage qualifier&quot;);
+        $$.qualifier = (context-&gt;shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
+    }
+    | CENTROID IN_QUAL {
+        ES3_ONLY(&quot;centroid in&quot;, @1, &quot;storage qualifier&quot;);
+        if (context-&gt;shaderType == SH_VERTEX_SHADER)
+        {
+            context-&gt;error(@1, &quot;invalid storage qualifier&quot;, &quot;it is an error to use 'centroid in' in the vertex shader&quot;);
+            context-&gt;recover();
+        }
+        $$.qualifier = (context-&gt;shaderType == SH_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexIn;
+    }
+    | CENTROID OUT_QUAL {
+        ES3_ONLY(&quot;centroid out&quot;, @1, &quot;storage qualifier&quot;);
+        if (context-&gt;shaderType == SH_FRAGMENT_SHADER)
+        {
+            context-&gt;error(@1, &quot;invalid storage qualifier&quot;, &quot;it is an error to use 'centroid out' in the fragment shader&quot;);
+            context-&gt;recover();
+        }
+        $$.qualifier = (context-&gt;shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentOut : EvqCentroidOut;
+    }
</ins><span class="cx">     | UNIFORM {
</span><span class="cx">         if (context-&gt;globalErrorCheck(@1, context-&gt;symbolTable.atGlobalLevel(), &quot;uniform&quot;))
</span><span class="cx">             context-&gt;recover();
</span><del>-        $$.setBasic(EbtVoid, EvqUniform, @1);
</del><ins>+        $$.qualifier = EvqUniform;
</ins><span class="cx">     }
</span><span class="cx">     ;
</span><span class="cx"> 
</span><span class="lines">@@ -1431,6 +1269,34 @@
</span><span class="cx">     }
</span><span class="cx">     ;
</span><span class="cx"> 
</span><ins>+layout_qualifier
+    : LAYOUT LEFT_PAREN layout_qualifier_id_list RIGHT_PAREN {
+        ES3_ONLY(&quot;layout&quot;, @1, &quot;qualifier&quot;);
+        $$ = $3;
+    }
+    ;
+
+layout_qualifier_id_list
+    : layout_qualifier_id {
+        $$ = $1;
+    }
+    | layout_qualifier_id_list COMMA layout_qualifier_id {
+        $$ = context-&gt;joinLayoutQualifiers($1, $3);
+    }
+    ;
+
+layout_qualifier_id
+    : IDENTIFIER {
+        $$ = context-&gt;parseLayoutQualifier(*$1.string, @1);
+    }
+    | IDENTIFIER EQUAL INTCONSTANT {
+        $$ = context-&gt;parseLayoutQualifier(*$1.string, @1, *$3.string, $3.i, @3);
+    }
+    | IDENTIFIER EQUAL UINTCONSTANT {
+        $$ = context-&gt;parseLayoutQualifier(*$1.string, @1, *$3.string, $3.i, @3);
+    }
+    ;
+
</ins><span class="cx"> type_specifier_no_prec
</span><span class="cx">     : type_specifier_nonarray {
</span><span class="cx">         $$ = $1;
</span><span class="lines">@@ -1462,6 +1328,10 @@
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="cx">         $$.setBasic(EbtInt, qual, @1);
</span><span class="cx">     }
</span><ins>+    | UINT_TYPE {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtUInt, qual, @1);
+    }
</ins><span class="cx">     | BOOL_TYPE {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="cx">         $$.setBasic(EbtBool, qual, @1);
</span><span class="lines">@@ -1511,29 +1381,126 @@
</span><span class="cx">         $$.setBasic(EbtInt, qual, @1);
</span><span class="cx">         $$.setAggregate(4);
</span><span class="cx">     }
</span><ins>+    | UVEC2 {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtUInt, qual, @1);
+        $$.setAggregate(2);
+    }
+    | UVEC3 {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtUInt, qual, @1);
+        $$.setAggregate(3);
+    }
+    | UVEC4 {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtUInt, qual, @1);
+        $$.setAggregate(4);
+    }
</ins><span class="cx">     | MATRIX2 {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="cx">         $$.setBasic(EbtFloat, qual, @1);
</span><del>-        $$.setAggregate(2, true);
</del><ins>+        $$.setMatrix(2, 2);
</ins><span class="cx">     }
</span><span class="cx">     | MATRIX3 {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="cx">         $$.setBasic(EbtFloat, qual, @1);
</span><del>-        $$.setAggregate(3, true);
</del><ins>+        $$.setMatrix(3, 3);
</ins><span class="cx">     }
</span><span class="cx">     | MATRIX4 {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="cx">         $$.setBasic(EbtFloat, qual, @1);
</span><del>-        $$.setAggregate(4, true);
</del><ins>+        $$.setMatrix(4, 4);
</ins><span class="cx">     }
</span><ins>+    | MATRIX2x3 {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtFloat, qual, @1);
+        $$.setMatrix(2, 3);
+    }
+    | MATRIX3x2 {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtFloat, qual, @1);
+        $$.setMatrix(3, 2);
+    }
+    | MATRIX2x4 {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtFloat, qual, @1);
+        $$.setMatrix(2, 4);
+    }
+    | MATRIX4x2 {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtFloat, qual, @1);
+        $$.setMatrix(4, 2);
+    }
+    | MATRIX3x4 {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtFloat, qual, @1);
+        $$.setMatrix(3, 4);
+    }
+    | MATRIX4x3 {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtFloat, qual, @1);
+        $$.setMatrix(4, 3);
+    }
</ins><span class="cx">     | SAMPLER2D {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="cx">         $$.setBasic(EbtSampler2D, qual, @1);
</span><span class="cx">     }
</span><ins>+    | SAMPLER3D {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtSampler3D, qual, @1);
+    }
</ins><span class="cx">     | SAMPLERCUBE {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="cx">         $$.setBasic(EbtSamplerCube, qual, @1);
</span><span class="cx">     }
</span><ins>+    | SAMPLER2DARRAY {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtSampler2DArray, qual, @1);
+    }
+    | ISAMPLER2D {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtISampler2D, qual, @1);
+    }
+    | ISAMPLER3D {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtISampler3D, qual, @1);
+    }
+    | ISAMPLERCUBE {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtISamplerCube, qual, @1);
+    }
+    | ISAMPLER2DARRAY {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtISampler2DArray, qual, @1);
+    }
+    | USAMPLER2D {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtUSampler2D, qual, @1);
+    }
+    | USAMPLER3D {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtUSampler3D, qual, @1);
+    }
+    | USAMPLERCUBE {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtUSamplerCube, qual, @1);
+    }
+    | USAMPLER2DARRAY {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtUSampler2DArray, qual, @1);
+    }
+    | SAMPLER2DSHADOW {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtSampler2DShadow, qual, @1);
+    }
+    | SAMPLERCUBESHADOW {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtSamplerCubeShadow, qual, @1);
+    }
+    | SAMPLER2DARRAYSHADOW {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        $$.setBasic(EbtSampler2DArrayShadow, qual, @1);
+    }
</ins><span class="cx">     | SAMPLER_EXTERNAL_OES {
</span><span class="cx">         if (!context-&gt;supportsExtension(&quot;GL_OES_EGL_image_external&quot;)) {
</span><span class="cx">             context-&gt;error(@1, &quot;unsupported type&quot;, &quot;samplerExternalOES&quot;);
</span><span class="lines">@@ -1568,24 +1535,10 @@
</span><span class="cx"> 
</span><span class="cx"> struct_specifier
</span><span class="cx">     : STRUCT identifier LEFT_BRACE { if (context-&gt;enterStructDeclaration(@2, *$2.string)) context-&gt;recover(); } struct_declaration_list RIGHT_BRACE {
</span><del>-        if (context-&gt;reservedErrorCheck(@2, *$2.string))
-            context-&gt;recover();
-
-        TType* structure = new TType(new TStructure($2.string, $5));
-        TVariable* userTypeDef = new TVariable($2.string, *structure, true);
-        if (! context-&gt;symbolTable.insert(*userTypeDef)) {
-            context-&gt;error(@2, &quot;redefinition&quot;, $2.string-&gt;c_str(), &quot;struct&quot;);
-            context-&gt;recover();
-        }
-        $$.setBasic(EbtStruct, EvqTemporary, @1);
-        $$.userDef = structure;
-        context-&gt;exitStructDeclaration();
</del><ins>+        $$ = context-&gt;addStructure(@1, @2, $2.string, $5);
</ins><span class="cx">     }
</span><span class="cx">     | STRUCT LEFT_BRACE { if (context-&gt;enterStructDeclaration(@2, *$2.string)) context-&gt;recover(); } struct_declaration_list RIGHT_BRACE {
</span><del>-        TType* structure = new TType(new TStructure(NewPoolTString(&quot;&quot;), $4));
-        $$.setBasic(EbtStruct, EvqTemporary, @1);
-        $$.userDef = structure;
-        context-&gt;exitStructDeclaration();
</del><ins>+        $$ = context-&gt;addStructure(@1, @$, NewPoolTString(&quot;&quot;), $4);
</ins><span class="cx">     }
</span><span class="cx">     ;
</span><span class="cx"> 
</span><span class="lines">@@ -1610,35 +1563,14 @@
</span><span class="cx"> 
</span><span class="cx"> struct_declaration
</span><span class="cx">     : type_specifier struct_declarator_list SEMICOLON {
</span><del>-        $$ = $2;
-
-        if (context-&gt;voidErrorCheck(@1, (*$2)[0]-&gt;name(), $1)) {
-            context-&gt;recover();
-        }
-        for (unsigned int i = 0; i &lt; $$-&gt;size(); ++i) {
-            //
-            // Careful not to replace already known aspects of type, like array-ness
-            //
-            TType* type = (*$$)[i]-&gt;type();
-            type-&gt;setBasicType($1.type);
-            type-&gt;setNominalSize($1.size);
-            type-&gt;setMatrix($1.matrix);
-            type-&gt;setPrecision($1.precision);
-
-            // don't allow arrays of arrays
-            if (type-&gt;isArray()) {
-                if (context-&gt;arrayTypeErrorCheck(@1, $1))
-                    context-&gt;recover();
-            }
-            if ($1.array)
-                type-&gt;setArraySize($1.arraySize);
-            if ($1.userDef)
-                type-&gt;setStruct($1.userDef-&gt;getStruct());
-
-            if (context-&gt;structNestingErrorCheck(@1, *(*$$)[i]))
-                context-&gt;recover();
-        }
</del><ins>+        $$ = context-&gt;addStructDeclaratorList($1, $2);
</ins><span class="cx">     }
</span><ins>+    | type_qualifier type_specifier struct_declarator_list SEMICOLON {
+        // ES3 Only, but errors should be handled elsewhere
+        $2.qualifier = $1.qualifier;
+        $2.layoutQualifier = $1.layoutQualifier;
+        $$ = context-&gt;addStructDeclaratorList($2, $3);
+    }
</ins><span class="cx">     ;
</span><span class="cx"> 
</span><span class="cx"> struct_declarator_list
</span><span class="lines">@@ -1657,19 +1589,19 @@
</span><span class="cx">             context-&gt;recover();
</span><span class="cx"> 
</span><span class="cx">         TType* type = new TType(EbtVoid, EbpUndefined);
</span><del>-        $$ = new TField(type, $1.string);
</del><ins>+        $$ = new TField(type, $1.string, @1);
</ins><span class="cx">     }
</span><span class="cx">     | identifier LEFT_BRACKET constant_expression RIGHT_BRACKET {
</span><span class="cx">         if (context-&gt;reservedErrorCheck(@1, *$1.string))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx"> 
</span><span class="cx">         TType* type = new TType(EbtVoid, EbpUndefined);
</span><del>-        int size = 0;
</del><ins>+        int size;
</ins><span class="cx">         if (context-&gt;arraySizeErrorCheck(@3, $3, size))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         type-&gt;setArraySize(size);
</span><span class="cx"> 
</span><del>-        $$ = new TField(type, $1.string);
</del><ins>+        $$ = new TField(type, $1.string, @1);
</ins><span class="cx">     }
</span><span class="cx">     ;
</span><span class="cx"> 
</span><span class="lines">@@ -1903,7 +1835,7 @@
</span><span class="cx">     : function_prototype {
</span><span class="cx">         TFunction* function = $1.function;
</span><span class="cx">         
</span><del>-        const TSymbol *builtIn = context-&gt;symbolTable.findBuiltIn(function-&gt;getMangledName());
</del><ins>+        const TSymbol *builtIn = context-&gt;symbolTable.findBuiltIn(function-&gt;getMangledName(), context-&gt;shaderVersion);
</ins><span class="cx">         
</span><span class="cx">         if (builtIn)
</span><span class="cx">         {
</span><span class="lines">@@ -1911,7 +1843,7 @@
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        TFunction* prevDec = static_cast&lt;TFunction*&gt;(context-&gt;symbolTable.find(function-&gt;getMangledName()));
</del><ins>+        TFunction* prevDec = static_cast&lt;TFunction*&gt;(context-&gt;symbolTable.find(function-&gt;getMangledName(), context-&gt;shaderVersion));
</ins><span class="cx">         //
</span><span class="cx">         // Note:  'prevDec' could be 'function' if this is the first time we've seen function
</span><span class="cx">         // as it would have just been put in the symbol table.  Otherwise, we're looking up
</span><span class="lines">@@ -1962,7 +1894,7 @@
</span><span class="cx">                 //
</span><span class="cx">                 // Insert the parameters with name in the symbol table.
</span><span class="cx">                 //
</span><del>-                if (! context-&gt;symbolTable.insert(*variable)) {
</del><ins>+                if (! context-&gt;symbolTable.declare(*variable)) {
</ins><span class="cx">                     context-&gt;error(@1, &quot;redefinition&quot;, variable-&gt;getName().c_str());
</span><span class="cx">                     context-&gt;recover();
</span><span class="cx">                     delete variable;
</span><span class="lines">@@ -1974,9 +1906,8 @@
</span><span class="cx">                 paramNodes = context-&gt;intermediate.growAggregate(
</span><span class="cx">                                                paramNodes,
</span><span class="cx">                                                context-&gt;intermediate.addSymbol(variable-&gt;getUniqueId(),
</span><del>-                                                                               variable-&gt;getName(),
-                                                                               variable-&gt;getType(),
-                                                                               @1),
</del><ins>+                                                                       variable-&gt;getName(),
+                                                                       variable-&gt;getType(), @1),
</ins><span class="cx">                                                @1);
</span><span class="cx">             } else {
</span><span class="cx">                 paramNodes = context-&gt;intermediate.growAggregate(paramNodes, context-&gt;intermediate.addSymbol(0, &quot;&quot;, *param.type, @1), @1);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorglslang_lexcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_lex.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_lex.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_lex.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #line 17 &quot;./glslang.l&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -18,7 +18,6 @@
</span><span class="cx"> #pragma warning(disable: 4505)
</span><span class="cx"> #pragma warning(disable: 4701)
</span><span class="cx"> #endif
</span><del>-
</del><span class="cx"> #if defined(__clang__)
</span><span class="cx"> #pragma clang diagnostic push
</span><span class="cx"> #pragma clang diagnostic ignored &quot;-Wunknown-pragmas&quot;
</span><span class="lines">@@ -72,6 +71,7 @@
</span><span class="cx"> typedef uint16_t flex_uint16_t;
</span><span class="cx"> typedef int32_t flex_int32_t;
</span><span class="cx"> typedef uint32_t flex_uint32_t;
</span><ins>+typedef uint64_t flex_uint64_t;
</ins><span class="cx"> #else
</span><span class="cx"> typedef signed char flex_int8_t;
</span><span class="cx"> typedef short int flex_int16_t;
</span><span class="lines">@@ -118,15 +118,15 @@
</span><span class="cx"> /* The &quot;const&quot; storage-class-modifier is valid. */
</span><span class="cx"> #define YY_USE_CONST
</span><span class="cx"> 
</span><del>-#else   /* ! __cplusplus */
</del><ins>+#else        /* ! __cplusplus */
</ins><span class="cx"> 
</span><span class="cx"> /* C99 requires __STDC__ to be defined as 1. */
</span><span class="cx"> #if defined (__STDC__)
</span><span class="cx"> 
</span><span class="cx"> #define YY_USE_CONST
</span><span class="cx"> 
</span><del>-#endif  /* defined (__STDC__) */
-#endif  /* ! __cplusplus */
</del><ins>+#endif        /* defined (__STDC__) */
+#endif        /* ! __cplusplus */
</ins><span class="cx"> 
</span><span class="cx"> #ifdef YY_USE_CONST
</span><span class="cx"> #define yyconst const
</span><span class="lines">@@ -201,6 +201,11 @@
</span><span class="cx"> typedef size_t yy_size_t;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
</ins><span class="cx"> #define EOB_ACT_CONTINUE_SCAN 0
</span><span class="cx"> #define EOB_ACT_END_OF_FILE 1
</span><span class="cx"> #define EOB_ACT_LAST_MATCH 2
</span><span class="lines">@@ -214,7 +219,7 @@
</span><span class="cx">      */
</span><span class="cx">     #define  YY_LESS_LINENO(n) \
</span><span class="cx">             do { \
</span><del>-                int yyl;\
</del><ins>+                yy_size_t yyl;\
</ins><span class="cx">                 for ( yyl = n; yyl &lt; yyleng; ++yyl )\
</span><span class="cx">                     if ( yytext[yyl] == '\n' )\
</span><span class="cx">                         --yylineno;\
</span><span class="lines">@@ -222,83 +227,83 @@
</span><span class="cx">     
</span><span class="cx"> /* Return all but the first &quot;n&quot; matched characters back to the input stream. */
</span><span class="cx"> #define yyless(n) \
</span><del>-    do \
-        { \
-        /* Undo effects of setting up yytext. */ \
</del><ins>+        do \
+                { \
+                /* Undo effects of setting up yytext. */ \
</ins><span class="cx">         int yyless_macro_arg = (n); \
</span><span class="cx">         YY_LESS_LINENO(yyless_macro_arg);\
</span><del>-        *yy_cp = yyg-&gt;yy_hold_char; \
-        YY_RESTORE_YY_MORE_OFFSET \
-        yyg-&gt;yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
-        YY_DO_BEFORE_ACTION; /* set up yytext again */ \
-        } \
-    while ( 0 )
</del><ins>+                *yy_cp = yyg-&gt;yy_hold_char; \
+                YY_RESTORE_YY_MORE_OFFSET \
+                yyg-&gt;yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+                YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+                } \
+        while ( 0 )
</ins><span class="cx"> 
</span><span class="cx"> #define unput(c) yyunput( c, yyg-&gt;yytext_ptr , yyscanner )
</span><span class="cx"> 
</span><span class="cx"> #ifndef YY_STRUCT_YY_BUFFER_STATE
</span><span class="cx"> #define YY_STRUCT_YY_BUFFER_STATE
</span><span class="cx"> struct yy_buffer_state
</span><del>-    {
-    FILE *yy_input_file;
</del><ins>+        {
+        FILE *yy_input_file;
</ins><span class="cx"> 
</span><del>-    char *yy_ch_buf;        /* input buffer */
-    char *yy_buf_pos;       /* current position in input buffer */
</del><ins>+        char *yy_ch_buf;                /* input buffer */
+        char *yy_buf_pos;                /* current position in input buffer */
</ins><span class="cx"> 
</span><del>-    /* Size of input buffer in bytes, not including room for EOB
-     * characters.
-     */
-    yy_size_t yy_buf_size;
</del><ins>+        /* Size of input buffer in bytes, not including room for EOB
+         * characters.
+         */
+        yy_size_t yy_buf_size;
</ins><span class="cx"> 
</span><del>-    /* Number of characters read into yy_ch_buf, not including EOB
-     * characters.
-     */
-    yy_size_t yy_n_chars;
</del><ins>+        /* Number of characters read into yy_ch_buf, not including EOB
+         * characters.
+         */
+        yy_size_t yy_n_chars;
</ins><span class="cx"> 
</span><del>-    /* Whether we &quot;own&quot; the buffer - i.e., we know we created it,
-     * and can realloc() it to grow it, and should free() it to
-     * delete it.
-     */
-    int yy_is_our_buffer;
</del><ins>+        /* Whether we &quot;own&quot; the buffer - i.e., we know we created it,
+         * and can realloc() it to grow it, and should free() it to
+         * delete it.
+         */
+        int yy_is_our_buffer;
</ins><span class="cx"> 
</span><del>-    /* Whether this is an &quot;interactive&quot; input source; if so, and
-     * if we're using stdio for input, then we want to use getc()
-     * instead of fread(), to make sure we stop fetching input after
-     * each newline.
-     */
-    int yy_is_interactive;
</del><ins>+        /* Whether this is an &quot;interactive&quot; input source; if so, and
+         * if we're using stdio for input, then we want to use getc()
+         * instead of fread(), to make sure we stop fetching input after
+         * each newline.
+         */
+        int yy_is_interactive;
</ins><span class="cx"> 
</span><del>-    /* Whether we're considered to be at the beginning of a line.
-     * If so, '^' rules will be active on the next match, otherwise
-     * not.
-     */
-    int yy_at_bol;
</del><ins>+        /* Whether we're considered to be at the beginning of a line.
+         * If so, '^' rules will be active on the next match, otherwise
+         * not.
+         */
+        int yy_at_bol;
</ins><span class="cx"> 
</span><span class="cx">     int yy_bs_lineno; /**&lt; The line count. */
</span><span class="cx">     int yy_bs_column; /**&lt; The column count. */
</span><span class="cx">     
</span><del>-    /* Whether to try to fill the input buffer when we reach the
-     * end of it.
-     */
-    int yy_fill_buffer;
</del><ins>+        /* Whether to try to fill the input buffer when we reach the
+         * end of it.
+         */
+        int yy_fill_buffer;
</ins><span class="cx"> 
</span><del>-    int yy_buffer_status;
</del><ins>+        int yy_buffer_status;
</ins><span class="cx"> 
</span><span class="cx"> #define YY_BUFFER_NEW 0
</span><span class="cx"> #define YY_BUFFER_NORMAL 1
</span><del>-    /* When an EOF's been seen but there's still some text to process
-     * then we mark the buffer as YY_EOF_PENDING, to indicate that we
-     * shouldn't try reading from the input source any more.  We might
-     * still have a bunch of tokens to match, though, because of
-     * possible backing-up.
-     *
-     * When we actually see the EOF, we change the status to &quot;new&quot;
-     * (via yyrestart()), so that the user can continue scanning by
-     * just pointing yyin at a new input file.
-     */
</del><ins>+        /* When an EOF's been seen but there's still some text to process
+         * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+         * shouldn't try reading from the input source any more.  We might
+         * still have a bunch of tokens to match, though, because of
+         * possible backing-up.
+         *
+         * When we actually see the EOF, we change the status to &quot;new&quot;
+         * (via yyrestart()), so that the user can continue scanning by
+         * just pointing yyin at a new input file.
+         */
</ins><span class="cx"> #define YY_BUFFER_EOF_PENDING 2
</span><span class="cx"> 
</span><del>-    };
</del><ins>+        };
</ins><span class="cx"> #endif /* !YY_STRUCT_YY_BUFFER_STATE */
</span><span class="cx"> 
</span><span class="cx"> /* We provide macros for accessing buffer states in case in the
</span><span class="lines">@@ -341,24 +346,24 @@
</span><span class="cx"> #define yy_new_buffer yy_create_buffer
</span><span class="cx"> 
</span><span class="cx"> #define yy_set_interactive(is_interactive) \
</span><del>-    { \
-    if ( ! YY_CURRENT_BUFFER ){ \
</del><ins>+        { \
+        if ( ! YY_CURRENT_BUFFER ){ \
</ins><span class="cx">         yyensure_buffer_stack (yyscanner); \
</span><del>-        YY_CURRENT_BUFFER_LVALUE =    \
</del><ins>+                YY_CURRENT_BUFFER_LVALUE =    \
</ins><span class="cx">             yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
</span><del>-    } \
-    YY_CURRENT_BUFFER_LVALUE-&gt;yy_is_interactive = is_interactive; \
-    }
</del><ins>+        } \
+        YY_CURRENT_BUFFER_LVALUE-&gt;yy_is_interactive = is_interactive; \
+        }
</ins><span class="cx"> 
</span><span class="cx"> #define yy_set_bol(at_bol) \
</span><del>-    { \
-    if ( ! YY_CURRENT_BUFFER ){\
</del><ins>+        { \
+        if ( ! YY_CURRENT_BUFFER ){\
</ins><span class="cx">         yyensure_buffer_stack (yyscanner); \
</span><del>-        YY_CURRENT_BUFFER_LVALUE =    \
</del><ins>+                YY_CURRENT_BUFFER_LVALUE =    \
</ins><span class="cx">             yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
</span><del>-    } \
-    YY_CURRENT_BUFFER_LVALUE-&gt;yy_at_bol = at_bol; \
-    }
</del><ins>+        } \
+        YY_CURRENT_BUFFER_LVALUE-&gt;yy_at_bol = at_bol; \
+        }
</ins><span class="cx"> 
</span><span class="cx"> #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE-&gt;yy_at_bol)
</span><span class="cx"> 
</span><span class="lines">@@ -382,72 +387,113 @@
</span><span class="cx">  * corresponding action - sets up yytext.
</span><span class="cx">  */
</span><span class="cx"> #define YY_DO_BEFORE_ACTION \
</span><del>-    yyg-&gt;yytext_ptr = yy_bp; \
-    yyleng = (size_t) (yy_cp - yy_bp); \
-    yyg-&gt;yy_hold_char = *yy_cp; \
-    *yy_cp = '\0'; \
-    yyg-&gt;yy_c_buf_p = yy_cp;
</del><ins>+        yyg-&gt;yytext_ptr = yy_bp; \
+        yyleng = (yy_size_t) (yy_cp - yy_bp); \
+        yyg-&gt;yy_hold_char = *yy_cp; \
+        *yy_cp = '\0'; \
+        yyg-&gt;yy_c_buf_p = yy_cp;
</ins><span class="cx"> 
</span><del>-#define YY_NUM_RULES 147
-#define YY_END_OF_BUFFER 148
</del><ins>+#define YY_NUM_RULES 237
+#define YY_END_OF_BUFFER 238
</ins><span class="cx"> /* This struct is not used in this scanner,
</span><span class="cx">    but its presence is necessary. */
</span><span class="cx"> struct yy_trans_info
</span><del>-    {
-    flex_int32_t yy_verify;
-    flex_int32_t yy_nxt;
-    };
-static yyconst flex_int16_t yy_accept[443] =
</del><ins>+        {
+        flex_int32_t yy_verify;
+        flex_int32_t yy_nxt;
+        };
+static yyconst flex_int16_t yy_accept[813] =
</ins><span class="cx">     {   0,
</span><del>-        0,    0,  148,  146,  145,  145,  132,  138,  143,  127,
-      128,  136,  135,  124,  133,  131,  137,   96,   96,  125,
-      121,  139,  126,  140,  144,   93,  129,  130,  142,   93,
-       93,   93,   93,   93,   93,   93,   93,   93,   93,   93,
-       93,   93,   93,   93,   93,   93,   93,   93,   93,  122,
-      141,  123,  134,  118,  104,  123,  112,  107,  102,  110,
-      100,  111,  101,   99,  103,   98,   95,   96,    0,    0,
-      130,  122,  129,  119,  115,  117,  116,  120,   93,  108,
-      114,   93,   93,   93,   93,   93,   93,   93,   93,   93,
-       93,   12,   93,   93,   93,   93,   93,   93,   93,   93,
</del><ins>+        0,    0,  238,  236,  235,  235,  222,  228,  233,  217,
+      218,  226,  225,  214,  223,  221,  227,  180,  180,  215,
+      211,  229,  216,  230,  234,  177,  219,  220,  232,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  212,
+      231,  213,  224,  208,  194,  213,  202,  197,  192,  200,
+      190,  201,  191,  186,  193,  185,  179,  180,    0,  183,
+        0,  220,  212,  219,  209,  205,  207,  206,  210,  177,
+      198,  204,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,   12,  177,  177,  177,  177,  177,
</ins><span class="cx"> 
</span><del>-       93,   93,   93,   93,   93,   15,   17,   93,   93,   93,
-       93,   93,   93,   93,   93,   93,   93,   93,   93,   93,
-       93,   93,   93,   93,   93,   93,   93,   93,   93,   93,
-       93,   93,   93,   93,  109,  113,    0,   98,    0,    0,
-       97,   94,  105,  106,   45,   93,   93,   93,   93,   93,
-       93,   93,   93,   93,   93,   93,   93,   93,   93,   93,
-       93,   93,   93,   13,   93,   93,   93,   93,   93,   93,
-       93,   93,   21,   93,   93,   93,   93,   93,   93,   93,
-       93,   18,   93,   93,   93,   93,   93,   93,   93,   93,
-       93,   93,   93,   93,   93,   93,   93,   93,   93,   93,
</del><ins>+      177,  177,  177,  177,  177,  177,  177,  177,   15,  177,
+      177,   23,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  199,  203,    0,  189,  185,
+        0,  188,  182,    0,  184,  178,  195,  196,  177,  136,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,   13,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,   27,  177,  177,  177,  177,  177,
</ins><span class="cx"> 
</span><del>-       93,   93,   93,   93,   93,    0,   99,    0,   98,   93,
-       23,   93,   93,   90,   93,   93,   93,   93,   93,   93,
-       93,   16,   48,   93,   93,   93,   64,   93,   93,   53,
-       68,   93,   93,   93,   93,   93,   93,   93,   93,   65,
-        4,   28,   29,   30,   93,   93,   93,   93,   93,   93,
-       93,   93,   93,   93,   93,   93,   93,   93,   93,   93,
-       51,   24,   93,   93,   93,   93,   93,   93,   31,   32,
-       33,   22,   93,   93,   93,   10,   37,   38,   39,   46,
-        7,   93,   93,   93,   93,   77,   78,   79,   93,   25,
-       69,   20,   80,   81,   82,    2,   74,   75,   76,   93,
</del><ins>+      177,  177,  177,  177,  177,  177,   24,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,    0,  186,    0,  185,  187,  181,  177,  177,  177,
+       30,  177,  177,   18,  174,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,   16,  139,  177,  177,  177,
+      177,   21,  177,  177,  143,  155,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  152,    4,
+       35,   36,   37,  177,  177,  177,  177,  177,  177,  177,
</ins><span class="cx"> 
</span><del>-       19,   72,   93,   93,   34,   35,   36,   93,   93,   93,
-       93,   93,   93,   93,   93,   93,   66,   93,   93,   93,
-       93,   93,   93,   93,   93,   47,   93,   92,   93,   93,
-       14,   93,   93,   93,   93,   67,   61,   56,   93,   93,
-       93,   93,   93,   73,   52,   93,   59,   27,   93,   89,
-       60,   44,   71,   54,   93,   93,   93,   93,   93,   93,
-       93,   93,   55,   26,   93,   93,   93,    3,   93,   93,
-       93,   93,   93,   49,    8,   93,    9,   93,   93,   11,
-       62,   93,   93,   93,   57,   93,   93,   93,   93,   93,
-       93,   50,   70,   58,    6,   63,    1,   91,    5,   83,
</del><ins>+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  142,   31,  177,
+      177,   28,  177,  177,  177,  177,  177,  177,  177,   47,
+       48,   49,   29,  177,  177,  177,  177,  177,  177,   10,
+       53,   54,   55,  177,  137,  177,  177,    7,  177,  177,
+      177,  177,  164,  165,  166,  177,   32,  177,  156,   26,
+      167,  168,  169,    2,  161,  162,  163,  177,  177,  177,
+       25,  159,  177,  177,  177,   50,   51,   52,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,   86,
+      177,  177,  177,  177,  177,  177,  177,  153,  177,  177,
</ins><span class="cx"> 
</span><del>-       40,   84,   93,   93,   93,   93,   93,   93,   93,   93,
-       93,   93,   93,   93,   41,   93,   93,   93,   93,   93,
-       93,   93,   43,   93,   87,   93,   93,   93,   93,   93,
-       85,   93,   86,   93,   93,   93,   93,   93,   93,   42,
-       88,    0
</del><ins>+      177,  177,  177,  177,  177,  177,  177,  177,  177,  138,
+      177,  177,  176,   56,   57,   58,  177,  177,   14,  177,
+       91,  177,  177,  177,  177,   89,  177,  177,  177,  154,
+      149,   92,  177,  177,  177,  177,  177,  177,  144,  177,
+      177,  177,   78,   38,   41,   43,   42,   39,   45,   44,
+       46,   40,  177,  177,  177,  177,  160,  135,  177,  177,
+      147,  177,  177,  177,   34,   87,  173,   22,  148,   77,
+      177,  158,   17,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,   19,   33,  177,
+      177,  177,  177,  177,  177,   93,   94,   95,  177,  177,
+
+      177,  177,  177,    3,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  140,  177,  177,  177,  177,
+      177,    8,  177,  177,    9,  177,  177,  177,  177,   20,
+       79,   11,  150,   97,   98,   99,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,  145,  177,
+      177,  177,   81,   83,   80,  177,  177,  177,  177,  177,
+      177,  177,  141,  101,  102,  103,  177,  177,  157,  177,
+      146,  177,  177,    6,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,   96,  151,    1,  177,  177,  177,  177,
+      177,  175,  177,   90,    5,  170,   59,   62,  177,  177,
+
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      177,   82,  177,  177,  177,  177,  100,  177,  177,  177,
+      177,  177,  120,   66,   67,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  177,   88,  177,
+      177,  177,  104,  122,   70,   71,  177,  177,   84,  177,
+      177,  177,  177,  177,  177,  177,  115,  177,  177,  177,
+      177,  177,  177,  177,  177,  177,  177,  129,  177,  177,
+      177,  177,   60,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  177,  177,  177,  116,  105,  177,  106,  177,
+      177,  177,  130,  177,  177,   68,  177,  177,  177,  177,
+
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  117,
+      177,  177,  131,  177,  177,   72,  107,  108,  177,  111,
+      177,  112,  177,  177,  177,  177,  177,   85,  177,  177,
+      177,  177,   64,  177,   63,  126,  177,  177,  109,  110,
+      177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+      124,  127,  118,  177,   65,  177,  177,  177,  177,  177,
+      177,  177,  177,  125,  128,  177,  177,  121,   69,  177,
+      177,  171,  177,  177,  177,   74,  177,  177,  123,   73,
+      177,  177,  177,  177,  177,  177,  132,  177,  177,  177,
+      177,  177,  177,  133,  177,  177,  177,   75,  177,  134,
+
+      113,  114,  177,  177,  177,   61,  177,  177,  172,  119,
+       76,    0
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><span class="cx"> static yyconst flex_int32_t yy_ec[256] =
</span><span class="lines">@@ -458,14 +504,14 @@
</span><span class="cx">         1,    2,    4,    1,    1,    1,    5,    6,    1,    7,
</span><span class="cx">         8,    9,   10,   11,   12,   13,   14,   15,   16,   17,
</span><span class="cx">        18,   19,   20,   20,   20,   21,   21,   22,   23,   24,
</span><del>-       25,   26,   27,    1,   28,   28,   29,   30,   31,   28,
-       32,   32,   32,   32,   32,   32,   32,   32,   33,   32,
-       32,   34,   35,   32,   32,   32,   32,   36,   32,   32,
-       37,    1,   38,   39,   32,    1,   40,   41,   42,   43,
</del><ins>+       25,   26,   27,    1,   28,   29,   30,   31,   32,   33,
+       34,   34,   34,   34,   34,   34,   35,   34,   36,   34,
+       34,   37,   38,   34,   39,   34,   34,   40,   34,   34,
+       41,    1,   42,   43,   44,    1,   45,   46,   47,   48,
</ins><span class="cx"> 
</span><del>-       44,   45,   46,   47,   48,   32,   49,   50,   51,   52,
-       53,   54,   32,   55,   56,   57,   58,   59,   60,   61,
-       62,   63,   64,   65,   66,   67,    1,    1,    1,    1,
</del><ins>+       49,   50,   51,   52,   53,   34,   54,   55,   56,   57,
+       58,   59,   34,   60,   61,   62,   63,   64,   65,   66,
+       67,   68,   69,   70,   71,   72,    1,    1,    1,    1,
</ins><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="lines">@@ -482,200 +528,323 @@
</span><span class="cx">         1,    1,    1,    1,    1
</span><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int32_t yy_meta[68] =
</del><ins>+static yyconst flex_int32_t yy_meta[73] =
</ins><span class="cx">     {   0,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="cx">         1,    1,    1,    1,    2,    2,    2,    2,    2,    2,
</span><del>-        2,    1,    1,    1,    1,    1,    1,    2,    2,    2,
-        2,    3,    3,    3,    3,    3,    1,    1,    1,    2,
-        2,    2,    2,    2,    2,    3,    3,    3,    3,    3,
-        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
-        3,    3,    3,    1,    1,    1,    1
</del><ins>+        2,    1,    1,    1,    1,    1,    1,    3,    3,    3,
+        3,    2,    2,    4,    4,    4,    4,    4,    4,    4,
+        1,    1,    1,    4,    3,    3,    3,    3,    2,    2,
+        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
+        4,    4,    4,    4,    4,    4,    4,    4,    1,    1,
+        1,    1
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int16_t yy_base[445] =
</del><ins>+static yyconst flex_int16_t yy_base[817] =
</ins><span class="cx">     {   0,
</span><del>-        0,    0,  587,  588,  588,  588,  561,   43,   64,  588,
-      588,  560,   61,  588,   60,   58,  559,   77,   86,  557,
-      588,  104,  557,   55,  588,    0,  588,  588,   75,   26,
-       57,   82,   83,   73,   93,  528,   97,   95,  527,   44,
-       71,  521,  104,  534,  110,  116,   35,  111,  530,  588,
-      114,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  165,  588,  172,  202,  211,  233,    0,
-      588,  588,  588,  551,  588,  588,  588,  550,    0,  588,
-      588,  523,  516,  519,  527,  526,  513,  528,  515,  521,
-      509,  506,  519,  506,  503,  503,  509,  497,  108,  502,
</del><ins>+        0,    0,  941,  942,  942,  942,  915,   48,   69,  942,
+      942,  914,   66,  942,   65,   63,  913,   82,  136,  911,
+      942,   82,  911,   60,  942,    0,  942,  942,   67,   58,
+       51,   68,   75,   61,  105,  877,  114,   79,   67,   44,
+       89,  871,  101,  884,  121,  127,  136,  143,   36,  942,
+      112,  942,  942,  942,  942,  942,  942,  942,  942,  942,
+      942,  942,  942,  158,  942,  163,  163,    0,  199,  942,
+        0,  942,  942,  942,  907,  942,  942,  942,  906,    0,
+      942,  942,  868,  873,   80,  870,  878,  877,  864,  867,
+      878,  171,  872,  860,  857,  870,  857,  854,  854,  860,
</ins><span class="cx"> 
</span><del>-      512,  498,  504,  507,  508,    0,  145,  507,  113,  493,
-      506,  497,  499,  489,  503,  500,  502,  485,  490,  487,
-      476,  157,  484,  489,  485,  487,  476,  479,  118,  484,
-      476,  488,   70,  481,  588,  588,  246,  253,  270,  219,
-      283,    0,  588,  588,    0,  473,  477,  486,  483,  467,
-      467,  119,  482,  479,  479,  477,  474,  466,  472,  459,
-      470,  456,  472,    0,  469,  457,  464,  461,  465,  458,
-      447,  446,  459,  462,  459,  454,  445,  188,  450,  453,
-      444,  441,  445,  451,  442,  433,  436,  434,  444,  430,
-      428,  441,  427,  429,  426,  437,  436,  124,  431,  426,
</del><ins>+       75,  176,  854,  864,  850,  856,  859,  860,    0,  852,
+      862,  177,  861,  856,  837,  105,  841,  854,  845,  112,
+      838,  178,  850,  852,  185,  841,  838,  827,  836,  177,
+      185,  840,  836,  838,  827,  830,  124,  145,  197,  839,
+      827,  839,  190,  832,  831,  942,  942,  239,  942,  220,
+      256,  942,  942,  263,  270,  185,  942,  942,  830,    0,
+      826,  821,  825,  834,  831,  243,  815,  815,  826,  818,
+      143,  828,  825,  825,  823,  820,  812,  818,  805,  803,
+      815,  801,  817,    0,  814,  802,  809,  806,  810,  811,
+      804,  801,  790,  789,  802,  805,  793,  801,  789,  795,
</ins><span class="cx"> 
</span><del>-      415,  258,  433,  435,  424,  290,  297,  304,  311,  425,
-        0,  423,  275,    0,  415,  413,  421,  410,  427,  416,
-      316,    0,    0,  410,  420,  420,    0,  405,  319,    0,
-        0,  407,  322,  408,  402,  401,  402,  401,  325,    0,
-        0,    0,    0,    0,  397,  398,  403,  394,  407,  402,
-      401,  393,  397,  389,  392,  396,  401,  387,  399,  390,
-        0,    0,  396,  385,  385,  390,  389,  386,    0,    0,
-        0,    0,  376,  388,  390,    0,    0,    0,    0,    0,
-        0,  378,  379,  373,  383,    0,    0,    0,  374,    0,
-        0,    0,    0,    0,    0,    0,    0,    0,    0,  381,
</del><ins>+      786,  244,  791,  794,  785,  792,  781,  785,  776,  790,
+      789,  780,  786,  235,  770,  773,  771,  781,  771,  766,
+      764,  766,  776,  762,  764,  761,  772,  771,  774,  756,
+      244,  764,  760,  758,  767,  746,  281,  764,  766,  755,
+      747,  291,  298,  306,  317,  942,  942,  744,  754,  753,
+        0,  751,  311,    0,    0,  744,  742,  742,  743,  738,
+      746,  735,  752,  741,  322,    0,    0,  735,  745,  744,
+      744,    0,  729,  325,    0,    0,  731,  328,  738,  739,
+      730,  724,  723,  724,  723,  723,  334,  718,    0,    0,
+      714,  713,  712,  714,  715,  720,  714,  710,  723,  718,
</ins><span class="cx"> 
</span><del>-        0,    0,  379,  375,    0,    0,    0,  371,  367,  372,
-      362,  375,  361,  374,  363,  370,    0,  368,  370,  354,
-      356,  362,  368,  363,  351,    0,  353,    0,  352,  355,
-        0,  344,  343,  343,  356,    0,  358,    0,  357,  356,
-      341,  354,  341,    0,    0,  344,    0,    0,  336,    0,
-        0,    0,    0,    0,  333,  344,  337,  343,  340,  335,
-      327,  339,    0,    0,  332,  339,  328,    0,  337,  334,
-      324,  329,  332,    0,    0,  332,    0,  330,  329,    0,
-        0,  328,  314,  326,    0,  317,  338,  337,  336,  307,
-      303,    0,    0,    0,    0,    0,    0,    0,    0,  328,
</del><ins>+      718,  716,  715,  709,  703,  705,  704,  708,  700,  703,
+      698,  706,  711,  699,  696,  708,  699,    0,    0,  705,
+      701,    0,  693,  693,  698,  689,  696,  337,  693,    0,
+        0,    0,    0,  683,  695,  694,  693,  694,  694,    0,
+        0,    0,    0,  681,    0,  689,  680,    0,  679,  680,
+      674,  684,    0,    0,    0,  675,    0,  671,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,  681,  341,  680,
+        0,    0,  678,  674,  671,    0,    0,    0,  663,  343,
+      346,  355,  668,  664,  669,  660,  658,  671,  656,    0,
+      656,  669,  658,  654,  660,  655,  662,    0,  660,  657,
</ins><span class="cx"> 
</span><del>-      166,  325,  316,  299,  308,  310,  306,  308,  307,  306,
-      309,  306,  256,  253,    0,  228,  238,  222,  235,  203,
-      207,  204,  212,  191,    0,  201,  165,  167,  153,  161,
-        0,  170,    0,  175,  151,  141,  100,  114,   59,    0,
-        0,  588,  359,  113
</del><ins>+      661,  645,  643,  646,  652,  658,  653,  652,  640,    0,
+      642,  643,    0,    0,    0,    0,  640,  643,    0,  637,
+        0,  650,  630,  639,  634,    0,  627,  627,  640,    0,
+      642,    0,  359,  655,  654,  653,  620,  619,    0,  636,
+      635,  630,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,  619,  632,  619,  616,    0,    0,  621,  620,
+        0,  617,  624,  623,    0,  609,    0,    0,    0,    0,
+      606,    0,    0,  605,  616,  362,  609,  615,  614,  611,
+      606,  603,  596,  596,  609,  594,  606,    0,    0,  599,
+      622,  621,  620,  587,  586,  355,  356,    0,  598,  601,
+
+      599,  588,  584,    0,  596,  593,  592,  582,  581,  571,
+      588,  574,  369,  582,  585,    0,  602,  601,  600,  567,
+      566,    0,  580,  567,    0,  577,  570,  571,  574,    0,
+        0,    0,    0,  594,  593,    0,  570,  573,  558,  565,
+      556,  563,  564,  564,  563,  549,  379,  561,    0,  562,
+      551,  550,    0,    0,    0,  575,  574,  573,  540,  539,
+      535,  543,    0,  571,  570,    0,  547,  550,    0,  386,
+        0,  528,  537,    0,  533,  532,  541,  541,  529,  543,
+      527,  541,  536,    0,    0,    0,  553,  552,  551,  518,
+      517,    0,  517,    0,    0,  362,  382,  541,  527,  530,
+
+      513,  525,  513,  512,  521,  521,  538,  537,  536,  503,
+      502,    0,  502,  503,  502,  512,    0,  515,  511,  513,
+      509,  496,  527,  377,    0,  504,  507,  499,  491,  498,
+      489,  510,  498,  494,  496,  494,  494,  493,    0,  481,
+      480,  490,    0,  510,  390,    0,  487,  490,    0,  490,
+      489,  473,  465,  473,  463,  471,    0,  468,  467,  488,
+      476,  474,  474,  458,  461,  475,  459,  490,  470,  471,
+      468,  465,  475,  452,  466,  465,  449,  448,  447,  468,
+      456,  454,  454,  435,  434,    0,  462,  434,  460,  432,
+      436,  435,  466,  446,  443,    0,  442,  445,  441,  443,
+
+      427,  424,  437,  422,  423,  430,  424,  413,  412,    0,
+      418,  417,  448,  428,  425,    0,    0,    0,  421,    0,
+      420,    0,  426,  425,  409,  406,  407,    0,  399,  407,
+      397,  403,  424,  403,    0,    0,  415,  414,    0,    0,
+      413,  412,  396,  393,  394,  408,  407,  384,  383,  389,
+        0,    0,  410,  382,  408,  400,  392,  378,   60,   89,
+      105,  143,  173,    0,    0,  216,  217,    0,    0,  222,
+      243,    0,  244,  234,  259,    0,  291,  330,    0,    0,
+      323,  311,  323,  315,  361,  362,    0,  363,  348,  389,
+      355,  358,  359,    0,  378,  380,  371,    0,  392,    0,
+
+        0,    0,  373,  374,  368,    0,  369,  370,    0,    0,
+        0,  942,  434,  437,  438,  439
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int16_t yy_def[445] =
</del><ins>+static yyconst flex_int16_t yy_def[817] =
</ins><span class="cx">     {   0,
</span><del>-      442,    1,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  443,  442,  442,  442,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  444,
-      442,  442,  442,  442,  442,  442,  442,  442,  443,  442,
-      442,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
</del><ins>+      812,    1,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  813,  812,  812,  812,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  814,  812,  815,   18,   19,  812,  812,
+      816,  812,  812,  812,  812,  812,  812,  812,  812,  813,
+      812,  812,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
</ins><span class="cx"> 
</span><del>-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  442,  442,  442,  442,  442,  442,
-      442,  444,  442,  442,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
</del><ins>+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  812,  812,  812,  812,  815,
+      812,  812,  812,  812,  812,  816,  812,  812,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
</ins><span class="cx"> 
</span><del>-      443,  443,  443,  443,  443,  442,  442,  442,  442,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
</del><ins>+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  812,  812,  812,  812,  812,  812,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
</ins><span class="cx"> 
</span><del>-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
</del><ins>+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
</ins><span class="cx"> 
</span><del>-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
-      443,    0,  442,  442
</del><ins>+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+
+      813,  813,  813,  813,  813,  813,  813,  813,  813,  813,
+      813,    0,  812,  812,  812,  812
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int16_t yy_nxt[656] =
</del><ins>+static yyconst flex_int16_t yy_nxt[1015] =
</ins><span class="cx">     {   0,
</span><span class="cx">         4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
</span><span class="cx">        14,   15,   16,   17,   18,   19,   19,   19,   19,   19,
</span><span class="cx">        19,   20,   21,   22,   23,   24,   25,   26,   26,   26,
</span><del>-       26,   26,   26,   26,   26,   26,   27,   28,   29,   30,
-       31,   32,   33,   34,   35,   36,   37,   38,   26,   39,
-       40,   41,   42,   43,   44,   45,   46,   47,   48,   49,
-       26,   26,   26,   50,   51,   52,   53,   55,   56,   57,
-       60,   62,   64,   64,   64,   64,   64,   64,   64,   77,
-       78,   82,   83,  110,   63,   61,  129,  111,   58,   66,
-      130,   67,   67,   67,   67,   67,   67,   68,   66,   80,
</del><ins>+       26,   26,   26,   26,   26,   26,   26,   26,   26,   26,
+       27,   28,   29,   26,   30,   31,   32,   33,   34,   35,
+       36,   37,   38,   26,   39,   40,   41,   42,   43,   44,
+       45,   46,   47,   48,   49,   26,   26,   26,   50,   51,
+       52,   53,   55,   56,   57,   60,   62,   64,   64,   64,
+       64,   64,   64,   64,   78,   79,   73,  144,  117,   63,
+       61,   81,  118,   58,   66,  145,   67,   67,   67,   67,
</ins><span class="cx"> 
</span><del>-       68,   68,   68,   68,   68,   68,   68,   69,   72,   84,
-      112,   85,   70,   81,  142,   86,   69,  203,  441,  204,
-       69,   87,   94,  113,   95,   73,   90,   74,   75,   69,
-       91,   88,   97,   96,   89,   92,  103,   70,  135,  106,
-       98,   93,   99,  115,  104,  100,  107,  162,  440,  119,
-      131,  101,  439,  108,  132,  105,  120,  121,  116,  125,
-      163,  117,  126,  133,  176,  198,  122,  123,  264,  124,
-      127,  438,  177,  199,  216,  217,  265,  128,  136,   64,
-       64,   64,   64,   64,   64,   64,  138,  138,  138,  138,
-      138,  138,  138,  437,  170,  137,  190,  171,  172,  406,
</del><ins>+       67,   67,   68,   74,   83,   75,   76,  777,   86,   82,
+       87,  115,   89,   69,   88,   97,   90,   98,   84,   85,
+       70,   71,   91,   93,  116,   92,   99,   94,  109,  180,
+       69,  110,   95,  119,  111,  112,  146,  161,   96,  113,
+      181,  162,  114,  778,   70,  122,  120,   71,   66,  100,
+       68,   68,   68,   68,   68,   68,   68,  101,  106,  102,
+      123,  200,  103,  124,  205,  126,  107,   69,  104,  201,
+      206,  779,  127,  128,   70,  133,  129,  108,  134,  229,
+      230,  147,  130,  131,   69,  132,  135,  141,  137,  148,
+      149,  142,  138,  136,  151,  152,  139,  231,   70,  140,
</ins><span class="cx"> 
</span><del>-      407,  173,  139,  174,  242,  243,  244,  436,  137,  435,
-      434,  191,  433,  432,   66,  139,   67,   67,   67,   67,
-       67,   67,   68,   66,  431,   68,   68,   68,   68,   68,
-       68,   68,   69,  141,  141,  141,  141,  141,  141,  141,
-      430,   69,  140,  429,  140,   69,  428,  141,  141,  141,
-      141,  141,  141,  141,   69,  206,  427,  206,  426,  425,
-      207,  207,  207,  207,  207,  207,  207,  138,  138,  138,
-      138,  138,  138,  138,  269,  270,  271,  424,  423,  208,
-      422,  208,  421,  139,  209,  209,  209,  209,  209,  209,
-      209,  277,  278,  279,  420,  419,  139,  141,  141,  141,
</del><ins>+      143,  153,  812,  260,  261,  232,  148,  149,  154,  780,
+      154,  151,  152,  155,  155,  155,  155,  155,  155,  155,
+      182,  220,  169,  247,  208,  153,  170,  171,  812,  213,
+      222,  192,  781,  183,  193,  194,  221,  209,  195,  210,
+      196,  233,  238,  223,  239,  214,  215,  247,  242,  234,
+      242,  151,  152,  243,  243,  243,  243,  243,  243,  243,
+      291,  292,  293,  782,  783,  244,  784,  244,  151,  152,
+      245,  245,  245,  245,  245,  245,  245,  155,  155,  155,
+      155,  155,  155,  155,  155,  155,  155,  155,  155,  155,
+      155,  254,  305,  323,  785,  786,  306,  330,  331,  332,
</ins><span class="cx"> 
</span><del>-      141,  141,  141,  141,  207,  207,  207,  207,  207,  207,
-      207,  207,  207,  207,  207,  207,  207,  207,  209,  209,
-      209,  209,  209,  209,  209,  209,  209,  209,  209,  209,
-      209,  209,  286,  287,  288,  293,  294,  295,  297,  298,
-      299,  305,  306,  307,  387,  388,  389,  418,  417,  416,
-      415,  414,  413,  412,  411,  410,  409,  390,  408,  391,
-       79,   79,  405,  404,  403,  402,  401,  400,  399,  398,
-      397,  396,  395,  394,  393,  392,  386,  385,  384,  383,
-      382,  381,  380,  379,  378,  377,  376,  375,  374,  373,
-      372,  371,  370,  369,  368,  367,  366,  365,  364,  363,
</del><ins>+      787,  324,  246,  788,  255,  243,  243,  243,  243,  243,
+      243,  243,  243,  243,  243,  243,  243,  243,  243,  246,
+      245,  245,  245,  245,  245,  245,  245,  341,  342,  343,
+      149,  245,  245,  245,  245,  245,  245,  245,  353,  354,
+      355,  361,  362,  363,  365,  366,  367,  149,  789,  152,
+      376,  377,  378,  414,  415,  416,  434,  435,  436,  444,
+      445,  446,  447,  448,  449,  790,  152,  791,  792,  437,
+      438,  450,  451,  452,  491,  492,  493,  517,  518,  519,
+      793,  794,  539,  541,  556,  557,  558,  494,  495,  629,
+      520,  521,  540,  542,  587,  588,  589,  559,  560,  630,
</ins><span class="cx"> 
</span><del>-      362,  361,  360,  359,  358,  357,  356,  355,  354,  353,
-      352,  351,  350,  349,  348,  347,  346,  345,  344,  343,
-      342,  341,  340,  339,  338,  337,  336,  335,  334,  333,
-      332,  331,  330,  329,  328,  327,  326,  325,  324,  323,
-      322,  321,  320,  319,  318,  317,  316,  315,  314,  313,
-      312,  311,  310,  309,  308,  304,  303,  302,  301,  300,
-      296,  292,  291,  290,  289,  285,  284,  283,  282,  281,
-      280,  276,  275,  274,  273,  272,  268,  267,  266,  263,
-      262,  261,  260,  259,  258,  257,  256,  255,  254,  253,
-      252,  251,  250,  249,  248,  247,  246,  245,  241,  240,
</del><ins>+      561,  607,  608,  609,  659,  795,  796,  590,  591,  631,
+      797,  660,  798,  661,  610,  611,  632,  679,  633,  634,
+      799,  800,  801,  802,  680,  803,  681,  804,  805,  806,
+      807,  808,  809,  810,  811,   80,   80,   80,   64,  150,
+      156,  156,  776,  775,  774,  773,  772,  771,  770,  769,
+      768,  767,  766,  765,  764,  763,  762,  761,  760,  759,
+      758,  757,  756,  755,  754,  753,  752,  751,  750,  749,
+      748,  747,  746,  745,  744,  743,  742,  741,  740,  739,
+      738,  737,  736,  735,  734,  733,  732,  731,  730,  729,
+      728,  727,  726,  725,  724,  723,  722,  721,  720,  719,
</ins><span class="cx"> 
</span><del>-      239,  238,  237,  236,  235,  234,  233,  232,  231,  230,
-      229,  228,  227,  226,  225,  224,  223,  222,  221,  220,
-      219,  218,  215,  214,  213,  212,  211,  210,  205,  202,
-      201,  200,  197,  196,  195,  194,  193,  192,  189,  188,
-      187,  186,  185,  184,  183,  182,  181,  180,  179,  178,
-      175,  169,  168,  167,  166,  165,  164,  161,  160,  159,
-      158,  157,  156,  155,  154,  153,  152,  151,  150,  149,
-      148,  147,  146,  145,  144,  143,  134,  118,  114,  109,
-      102,   76,   71,   65,   59,   54,  442,    3,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
</del><ins>+      718,  717,  716,  715,  714,  713,  712,  711,  710,  709,
+      708,  707,  706,  705,  704,  703,  702,  701,  700,  699,
+      698,  697,  696,  695,  694,  693,  692,  691,  690,  689,
+      688,  687,  686,  685,  684,  683,  682,  678,  677,  676,
+      675,  674,  673,  672,  671,  670,  669,  668,  667,  666,
+      665,  664,  663,  662,  658,  657,  656,  655,  654,  653,
+      652,  651,  650,  649,  648,  647,  646,  645,  644,  643,
+      642,  641,  640,  639,  638,  637,  636,  635,  628,  627,
+      626,  625,  624,  623,  622,  621,  620,  619,  618,  617,
+      616,  615,  614,  613,  612,  606,  605,  604,  603,  602,
</ins><span class="cx"> 
</span><del>-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442
</del><ins>+      601,  600,  599,  598,  597,  596,  595,  594,  593,  592,
+      586,  585,  584,  583,  582,  581,  580,  579,  578,  577,
+      576,  575,  574,  573,  572,  571,  570,  569,  568,  567,
+      566,  565,  564,  563,  562,  555,  554,  553,  552,  551,
+      550,  549,  548,  547,  546,  545,  544,  543,  538,  537,
+      536,  535,  534,  533,  532,  531,  530,  529,  528,  527,
+      526,  525,  524,  523,  522,  516,  515,  514,  513,  512,
+      511,  510,  509,  508,  507,  506,  505,  504,  503,  502,
+      501,  500,  499,  498,  497,  496,  490,  489,  488,  487,
+      486,  485,  484,  483,  482,  481,  480,  479,  478,  477,
+
+      476,  475,  474,  473,  472,  471,  470,  469,  468,  467,
+      466,  465,  464,  463,  462,  461,  460,  459,  458,  457,
+      456,  455,  454,  453,  443,  442,  441,  440,  439,  433,
+      432,  431,  430,  429,  428,  427,  426,  425,  424,  423,
+      422,  421,  420,  419,  418,  417,  413,  412,  411,  410,
+      409,  408,  407,  406,  405,  404,  403,  402,  401,  400,
+      399,  398,  397,  396,  395,  394,  393,  392,  391,  390,
+      389,  388,  387,  386,  385,  384,  383,  382,  381,  380,
+      379,  375,  374,  373,  372,  371,  370,  369,  368,  364,
+      360,  359,  358,  357,  356,  352,  351,  350,  349,  348,
+
+      347,  346,  345,  344,  340,  339,  338,  337,  336,  335,
+      334,  333,  329,  328,  327,  326,  325,  322,  321,  320,
+      319,  318,  317,  316,  315,  314,  313,  312,  311,  310,
+      309,  308,  307,  304,  303,  302,  301,  300,  299,  298,
+      297,  296,  295,  294,  290,  289,  288,  287,  286,  285,
+      284,  283,  282,  281,  280,  279,  278,  277,  276,  275,
+      274,  273,  272,  271,  270,  269,  268,  267,  266,  265,
+      264,  263,  262,  259,  258,  257,  256,  253,  252,  251,
+      250,  249,  248,  241,  240,  237,  236,  235,  228,  227,
+      226,  225,  224,  219,  218,  217,  216,  212,  211,  207,
+
+      204,  203,  202,  199,  198,  197,  191,  190,  189,  188,
+      187,  186,  185,  184,  179,  178,  177,  176,  175,  174,
+      173,  172,  168,  167,  166,  165,  164,  163,  160,  159,
+      158,  157,  125,  121,  105,   77,   72,   65,   59,   54,
+      812,    3,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><del>-static yyconst flex_int16_t yy_chk[656] =
</del><ins>+static yyconst flex_int16_t yy_chk[1015] =
</ins><span class="cx">     {   0,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="lines">@@ -683,76 +852,116 @@
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><span class="cx">         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
</span><del>-        1,    1,    1,    1,    1,    1,    1,    8,    8,    9,
-       13,   15,   16,   16,   16,   16,   16,   16,   16,   24,
-       24,   30,   30,   40,   15,   13,   47,   40,    9,   18,
-       47,   18,   18,   18,   18,   18,   18,   18,   19,   29,
</del><ins>+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    8,    8,    9,   13,   15,   16,   16,   16,
+       16,   16,   16,   16,   24,   24,   22,   49,   40,   15,
+       13,   29,   40,    9,   18,   49,   18,   18,   18,   18,
</ins><span class="cx"> 
</span><del>-       19,   19,   19,   19,   19,   19,   19,   18,   22,   31,
-       41,   31,   18,   29,  444,   31,   19,  133,  439,  133,
-       18,   32,   34,   41,   34,   22,   33,   22,   22,   19,
-       33,   32,   35,   34,   32,   33,   37,   18,   51,   38,
-       35,   33,   35,   43,   37,   35,   38,   99,  438,   45,
-       48,   35,  437,   38,   48,   37,   45,   45,   43,   46,
-       99,   43,   46,   48,  109,  129,   45,   45,  198,   45,
-       46,  436,  109,  129,  152,  152,  198,   46,   51,   64,
-       64,   64,   64,   64,   64,   64,   66,   66,   66,   66,
-       66,   66,   66,  435,  107,   64,  122,  107,  107,  401,
</del><ins>+       18,   18,   18,   22,   30,   22,   22,  759,   31,   29,
+       31,   39,   32,   18,   31,   34,   32,   34,   30,   30,
+       18,   18,   32,   33,   39,   32,   34,   33,   38,  101,
+       18,   38,   33,   41,   38,   38,   51,   85,   33,   38,
+      101,   85,   38,  760,   18,   43,   41,   18,   19,   35,
+       19,   19,   19,   19,   19,   19,   19,   35,   37,   35,
+       43,  116,   35,   43,  120,   45,   37,   19,   35,  116,
+      120,  761,   45,   45,   19,   46,   45,   37,   46,  137,
+      137,   51,   45,   45,   19,   45,   46,   48,   47,   64,
+       64,   48,   47,   46,   66,   66,   47,  138,   19,   47,
</ins><span class="cx"> 
</span><del>-      401,  107,   66,  107,  178,  178,  178,  434,   64,  432,
-      430,  122,  429,  428,   67,   66,   67,   67,   67,   67,
-       67,   67,   67,   68,  427,   68,   68,   68,   68,   68,
-       68,   68,   67,  140,  140,  140,  140,  140,  140,  140,
-      426,   68,   69,  424,   69,   67,  423,   69,   69,   69,
-       69,   69,   69,   69,   68,  137,  422,  137,  421,  420,
-      137,  137,  137,  137,  137,  137,  137,  138,  138,  138,
-      138,  138,  138,  138,  202,  202,  202,  419,  418,  139,
-      417,  139,  416,  138,  139,  139,  139,  139,  139,  139,
-      139,  213,  213,  213,  414,  413,  138,  141,  141,  141,
</del><ins>+       48,   67,   67,  171,  171,  138,   64,   64,   69,  762,
+       69,   66,   66,   69,   69,   69,   69,   69,   69,   69,
+      102,  130,   92,  156,  122,   67,   92,   92,   67,  125,
+      131,  112,  763,  102,  112,  112,  130,  122,  112,  122,
+      112,  139,  143,  131,  143,  125,  125,  156,  148,  139,
+      148,  150,  150,  148,  148,  148,  148,  148,  148,  148,
+      202,  202,  202,  766,  767,  151,  770,  151,  150,  150,
+      151,  151,  151,  151,  151,  151,  151,  154,  154,  154,
+      154,  154,  154,  154,  155,  155,  155,  155,  155,  155,
+      155,  166,  214,  231,  771,  773,  214,  237,  237,  237,
</ins><span class="cx"> 
</span><del>-      141,  141,  141,  141,  206,  206,  206,  206,  206,  206,
-      206,  207,  207,  207,  207,  207,  207,  207,  208,  208,
-      208,  208,  208,  208,  208,  209,  209,  209,  209,  209,
-      209,  209,  221,  221,  221,  229,  229,  229,  233,  233,
-      233,  239,  239,  239,  372,  372,  372,  412,  411,  410,
-      409,  408,  407,  406,  405,  404,  403,  372,  402,  372,
-      443,  443,  400,  391,  390,  389,  388,  387,  386,  384,
-      383,  382,  379,  378,  376,  373,  371,  370,  369,  367,
-      366,  365,  362,  361,  360,  359,  358,  357,  356,  355,
-      349,  346,  343,  342,  341,  340,  339,  337,  335,  334,
</del><ins>+      774,  231,  155,  775,  166,  242,  242,  242,  242,  242,
+      242,  242,  243,  243,  243,  243,  243,  243,  243,  155,
+      244,  244,  244,  244,  244,  244,  244,  253,  253,  253,
+      243,  245,  245,  245,  245,  245,  245,  245,  265,  265,
+      265,  274,  274,  274,  278,  278,  278,  243,  777,  245,
+      287,  287,  287,  328,  328,  328,  369,  369,  369,  380,
+      380,  380,  381,  381,  381,  778,  245,  781,  782,  369,
+      369,  382,  382,  382,  433,  433,  433,  476,  476,  476,
+      783,  784,  496,  497,  513,  513,  513,  433,  433,  596,
+      476,  476,  496,  497,  547,  547,  547,  513,  513,  596,
</ins><span class="cx"> 
</span><del>-      333,  332,  330,  329,  327,  325,  324,  323,  322,  321,
-      320,  319,  318,  316,  315,  314,  313,  312,  311,  310,
-      309,  308,  304,  303,  300,  289,  285,  284,  283,  282,
-      275,  274,  273,  268,  267,  266,  265,  264,  263,  260,
-      259,  258,  257,  256,  255,  254,  253,  252,  251,  250,
-      249,  248,  247,  246,  245,  238,  237,  236,  235,  234,
-      232,  228,  226,  225,  224,  220,  219,  218,  217,  216,
-      215,  212,  210,  205,  204,  203,  201,  200,  199,  197,
-      196,  195,  194,  193,  192,  191,  190,  189,  188,  187,
-      186,  185,  184,  183,  182,  181,  180,  179,  177,  176,
</del><ins>+      513,  570,  570,  570,  624,  785,  786,  547,  547,  597,
+      788,  624,  789,  624,  570,  570,  597,  645,  597,  597,
+      790,  791,  792,  793,  645,  795,  645,  796,  797,  799,
+      803,  804,  805,  807,  808,  813,  813,  813,  814,  815,
+      816,  816,  758,  757,  756,  755,  754,  753,  750,  749,
+      748,  747,  746,  745,  744,  743,  742,  741,  738,  737,
+      734,  733,  732,  731,  730,  729,  727,  726,  725,  724,
+      723,  721,  719,  715,  714,  713,  712,  711,  709,  708,
+      707,  706,  705,  704,  703,  702,  701,  700,  699,  698,
+      697,  695,  694,  693,  692,  691,  690,  689,  688,  687,
</ins><span class="cx"> 
</span><del>-      175,  174,  173,  172,  171,  170,  169,  168,  167,  166,
-      165,  163,  162,  161,  160,  159,  158,  157,  156,  155,
-      154,  153,  151,  150,  149,  148,  147,  146,  134,  132,
-      131,  130,  128,  127,  126,  125,  124,  123,  121,  120,
-      119,  118,  117,  116,  115,  114,  113,  112,  111,  110,
-      108,  105,  104,  103,  102,  101,  100,   98,   97,   96,
-       95,   94,   93,   92,   91,   90,   89,   88,   87,   86,
-       85,   84,   83,   82,   78,   74,   49,   44,   42,   39,
-       36,   23,   20,   17,   12,    7,    3,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
</del><ins>+      685,  684,  683,  682,  681,  680,  679,  678,  677,  676,
+      675,  674,  673,  672,  671,  670,  669,  668,  667,  666,
+      665,  664,  663,  662,  661,  660,  659,  658,  656,  655,
+      654,  653,  652,  651,  650,  648,  647,  644,  642,  641,
+      640,  638,  637,  636,  635,  634,  633,  632,  631,  630,
+      629,  628,  627,  626,  623,  622,  621,  620,  619,  618,
+      616,  615,  614,  613,  611,  610,  609,  608,  607,  606,
+      605,  604,  603,  602,  601,  600,  599,  598,  593,  591,
+      590,  589,  588,  587,  583,  582,  581,  580,  579,  578,
+      577,  576,  575,  573,  572,  568,  567,  565,  564,  562,
</ins><span class="cx"> 
</span><del>-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442,  442,  442,  442,  442,  442,
-      442,  442,  442,  442,  442
</del><ins>+      561,  560,  559,  558,  557,  556,  552,  551,  550,  548,
+      546,  545,  544,  543,  542,  541,  540,  539,  538,  537,
+      535,  534,  529,  528,  527,  526,  524,  523,  521,  520,
+      519,  518,  517,  515,  514,  512,  511,  510,  509,  508,
+      507,  506,  505,  503,  502,  501,  500,  499,  495,  494,
+      493,  492,  491,  490,  487,  486,  485,  484,  483,  482,
+      481,  480,  479,  478,  477,  475,  474,  471,  466,  464,
+      463,  462,  460,  459,  456,  455,  454,  453,  442,  441,
+      440,  438,  437,  436,  435,  434,  431,  429,  428,  427,
+      425,  424,  423,  422,  420,  418,  417,  412,  411,  409,
+
+      408,  407,  406,  405,  404,  403,  402,  401,  400,  399,
+      397,  396,  395,  394,  393,  392,  391,  389,  388,  387,
+      386,  385,  384,  383,  379,  375,  374,  373,  370,  368,
+      358,  356,  352,  351,  350,  349,  347,  346,  344,  339,
+      338,  337,  336,  335,  334,  329,  327,  326,  325,  324,
+      323,  321,  320,  317,  316,  315,  314,  313,  312,  311,
+      310,  309,  308,  307,  306,  305,  304,  303,  302,  301,
+      300,  299,  298,  297,  296,  295,  294,  293,  292,  291,
+      288,  286,  285,  284,  283,  282,  281,  280,  279,  277,
+      273,  271,  270,  269,  268,  264,  263,  262,  261,  260,
+
+      259,  258,  257,  256,  252,  250,  249,  248,  241,  240,
+      239,  238,  236,  235,  234,  233,  232,  230,  229,  228,
+      227,  226,  225,  224,  223,  222,  221,  220,  219,  218,
+      217,  216,  215,  213,  212,  211,  210,  209,  208,  207,
+      206,  205,  204,  203,  201,  200,  199,  198,  197,  196,
+      195,  194,  193,  192,  191,  190,  189,  188,  187,  186,
+      185,  183,  182,  181,  180,  179,  178,  177,  176,  175,
+      174,  173,  172,  170,  169,  168,  167,  165,  164,  163,
+      162,  161,  159,  145,  144,  142,  141,  140,  136,  135,
+      134,  133,  132,  129,  128,  127,  126,  124,  123,  121,
+
+      119,  118,  117,  115,  114,  113,  111,  110,  108,  107,
+      106,  105,  104,  103,  100,   99,   98,   97,   96,   95,
+       94,   93,   91,   90,   89,   88,   87,   86,   84,   83,
+       79,   75,   44,   42,   36,   23,   20,   17,   12,    7,
+        3,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+
+      812,  812,  812,  812,  812,  812,  812,  812,  812,  812,
+      812,  812,  812,  812
</ins><span class="cx">     } ;
</span><span class="cx"> 
</span><span class="cx"> /* Table of booleans, true if rule could match eol. */
</span><del>-static yyconst flex_int32_t yy_rule_can_match_eol[148] =
</del><ins>+static yyconst flex_int32_t yy_rule_can_match_eol[238] =
</ins><span class="cx">     {   0,
</span><span class="cx"> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
</span><span class="cx">     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
</span><span class="lines">@@ -761,7 +970,11 @@
</span><span class="cx">     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
</span><span class="cx">     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
</span><span class="cx">     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
</span><del>-    0, 0, 0, 0, 0, 1, 0, 0,     };
</del><ins>+    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, 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, 0, 1, 0, 0,     };
</ins><span class="cx"> 
</span><span class="cx"> /* The intent behind this definition is that it'll catch
</span><span class="cx">  * any uses of REJECT which flex missed.
</span><span class="lines">@@ -772,7 +985,7 @@
</span><span class="cx"> #define YY_RESTORE_YY_MORE_OFFSET
</span><span class="cx"> /*
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -789,7 +1002,8 @@
</span><span class="cx"> #include &quot;compiler/translator/ParseContext.h&quot;
</span><span class="cx"> #include &quot;compiler/preprocessor/Token.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/util.h&quot;
</span><del>-#include &quot;compiler/translator/glslang_tab.h&quot;
</del><ins>+#include &quot;compiler/translator/length_limits.h&quot;
+#include &quot;glslang_tab.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> /* windows only pragma */
</span><span class="cx"> #ifdef _MSC_VER
</span><span class="lines">@@ -806,8 +1020,13 @@
</span><span class="cx"> static yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner);
</span><span class="cx"> static int check_type(yyscan_t yyscanner);
</span><span class="cx"> static int reserved_word(yyscan_t yyscanner);
</span><ins>+static int ES2_reserved_ES3_keyword(TParseContext *context, int token);
+static int ES2_keyword_ES3_reserved(TParseContext *context, int token);
+static int ES2_ident_ES3_keyword(TParseContext *context, int token);
+static int uint_constant(TParseContext *context);
</ins><span class="cx"> static int int_constant(yyscan_t yyscanner);
</span><span class="cx"> static int float_constant(yyscan_t yyscanner);
</span><ins>+static int floatsuffix_check(TParseContext* context);
</ins><span class="cx"> 
</span><span class="cx"> #define INITIAL 0
</span><span class="cx"> 
</span><span class="lines">@@ -952,33 +1171,33 @@
</span><span class="cx">  */
</span><span class="cx"> #ifndef YY_INPUT
</span><span class="cx"> #define YY_INPUT(buf,result,max_size) \
</span><del>-    if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_is_interactive ) \
-        { \
-        int c = '*'; \
-        size_t n; \
-        for ( n = 0; n &lt; max_size &amp;&amp; \
-                 (c = getc( yyin )) != EOF &amp;&amp; c != '\n'; ++n ) \
-            buf[n] = (char) c; \
-        if ( c == '\n' ) \
-            buf[n++] = (char) c; \
-        if ( c == EOF &amp;&amp; ferror( yyin ) ) \
-            YY_FATAL_ERROR( &quot;input in flex scanner failed&quot; ); \
-        result = n; \
-        } \
-    else \
-        { \
-        errno=0; \
-        while ( (result = fread(buf, 1, max_size, yyin))==0 &amp;&amp; ferror(yyin)) \
-            { \
-            if( errno != EINTR) \
-                { \
-                YY_FATAL_ERROR( &quot;input in flex scanner failed&quot; ); \
-                break; \
-                } \
-            errno=0; \
-            clearerr(yyin); \
-            } \
-        }\
</del><ins>+        if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_is_interactive ) \
+                { \
+                int c = '*'; \
+                size_t n; \
+                for ( n = 0; n &lt; max_size &amp;&amp; \
+                             (c = getc( yyin )) != EOF &amp;&amp; c != '\n'; ++n ) \
+                        buf[n] = (char) c; \
+                if ( c == '\n' ) \
+                        buf[n++] = (char) c; \
+                if ( c == EOF &amp;&amp; ferror( yyin ) ) \
+                        YY_FATAL_ERROR( &quot;input in flex scanner failed&quot; ); \
+                result = n; \
+                } \
+        else \
+                { \
+                errno=0; \
+                while ( (result = fread(buf, 1, max_size, yyin))==0 &amp;&amp; ferror(yyin)) \
+                        { \
+                        if( errno != EINTR) \
+                                { \
+                                YY_FATAL_ERROR( &quot;input in flex scanner failed&quot; ); \
+                                break; \
+                                } \
+                        errno=0; \
+                        clearerr(yyin); \
+                        } \
+                }\
</ins><span class="cx"> \
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="lines">@@ -1029,1034 +1248,1128 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #define YY_RULE_SETUP \
</span><del>-    YY_USER_ACTION
</del><ins>+        YY_USER_ACTION
</ins><span class="cx"> 
</span><span class="cx"> /** The main scanner function which does all the work.
</span><span class="cx">  */
</span><span class="cx"> YY_DECL
</span><span class="cx"> {
</span><del>-    register yy_state_type yy_current_state;
-    register char *yy_cp, *yy_bp;
-    register int yy_act;
</del><ins>+        register yy_state_type yy_current_state;
+        register char *yy_cp, *yy_bp;
+        register int yy_act;
</ins><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><span class="cx"> 
</span><ins>+    TParseContext* context = yyextra;
+
</ins><span class="cx">     yylval = yylval_param;
</span><span class="cx"> 
</span><span class="cx">     yylloc = yylloc_param;
</span><span class="cx"> 
</span><del>-    if ( !yyg-&gt;yy_init )
-        {
-        yyg-&gt;yy_init = 1;
</del><ins>+        if ( !yyg-&gt;yy_init )
+                {
+                yyg-&gt;yy_init = 1;
</ins><span class="cx"> 
</span><span class="cx"> #ifdef YY_USER_INIT
</span><del>-        YY_USER_INIT;
</del><ins>+                YY_USER_INIT;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-        if ( ! yyg-&gt;yy_start )
-            yyg-&gt;yy_start = 1;  /* first start state */
</del><ins>+                if ( ! yyg-&gt;yy_start )
+                        yyg-&gt;yy_start = 1;        /* first start state */
</ins><span class="cx"> 
</span><del>-        if ( ! yyin )
-            yyin = stdin;
</del><ins>+                if ( ! yyin )
+                        yyin = stdin;
</ins><span class="cx"> 
</span><del>-        if ( ! yyout )
-            yyout = stdout;
</del><ins>+                if ( ! yyout )
+                        yyout = stdout;
</ins><span class="cx"> 
</span><del>-        if ( ! YY_CURRENT_BUFFER ) {
-            yyensure_buffer_stack (yyscanner);
-            YY_CURRENT_BUFFER_LVALUE =
-                yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
-        }
</del><ins>+                if ( ! YY_CURRENT_BUFFER ) {
+                        yyensure_buffer_stack (yyscanner);
+                        YY_CURRENT_BUFFER_LVALUE =
+                                yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+                }
</ins><span class="cx"> 
</span><del>-        yy_load_buffer_state(yyscanner );
-        }
</del><ins>+                yy_load_buffer_state(yyscanner );
+                }
</ins><span class="cx"> 
</span><del>-    while ( 1 )     /* loops until end-of-file is reached */
-        {
-        yy_cp = yyg-&gt;yy_c_buf_p;
</del><ins>+        while ( 1 )                /* loops until end-of-file is reached */
+                {
+                yy_cp = yyg-&gt;yy_c_buf_p;
</ins><span class="cx"> 
</span><del>-        /* Support of yytext. */
-        *yy_cp = yyg-&gt;yy_hold_char;
</del><ins>+                /* Support of yytext. */
+                *yy_cp = yyg-&gt;yy_hold_char;
</ins><span class="cx"> 
</span><del>-        /* yy_bp points to the position in yy_ch_buf of the start of
-         * the current run.
-         */
-        yy_bp = yy_cp;
</del><ins>+                /* yy_bp points to the position in yy_ch_buf of the start of
+                 * the current run.
+                 */
+                yy_bp = yy_cp;
</ins><span class="cx"> 
</span><del>-        yy_current_state = yyg-&gt;yy_start;
</del><ins>+                yy_current_state = yyg-&gt;yy_start;
</ins><span class="cx"> yy_match:
</span><del>-        do
-            {
-            register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
-            if ( yy_accept[yy_current_state] )
-                {
-                yyg-&gt;yy_last_accepting_state = yy_current_state;
-                yyg-&gt;yy_last_accepting_cpos = yy_cp;
-                }
-            while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-                {
-                yy_current_state = (int) yy_def[yy_current_state];
-                if ( yy_current_state &gt;= 443 )
-                    yy_c = yy_meta[(unsigned int) yy_c];
-                }
-            yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-            ++yy_cp;
-            }
-        while ( yy_current_state != 442 );
-        yy_cp = yyg-&gt;yy_last_accepting_cpos;
-        yy_current_state = yyg-&gt;yy_last_accepting_state;
</del><ins>+                do
+                        {
+                        register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+                        if ( yy_accept[yy_current_state] )
+                                {
+                                yyg-&gt;yy_last_accepting_state = yy_current_state;
+                                yyg-&gt;yy_last_accepting_cpos = yy_cp;
+                                }
+                        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+                                {
+                                yy_current_state = (int) yy_def[yy_current_state];
+                                if ( yy_current_state &gt;= 813 )
+                                        yy_c = yy_meta[(unsigned int) yy_c];
+                                }
+                        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+                        ++yy_cp;
+                        }
+                while ( yy_current_state != 812 );
+                yy_cp = yyg-&gt;yy_last_accepting_cpos;
+                yy_current_state = yyg-&gt;yy_last_accepting_state;
</ins><span class="cx"> 
</span><span class="cx"> yy_find_action:
</span><del>-        yy_act = yy_accept[yy_current_state];
</del><ins>+                yy_act = yy_accept[yy_current_state];
</ins><span class="cx"> 
</span><del>-        YY_DO_BEFORE_ACTION;
</del><ins>+                YY_DO_BEFORE_ACTION;
</ins><span class="cx"> 
</span><del>-        if ( yy_act != YY_END_OF_BUFFER &amp;&amp; yy_rule_can_match_eol[yy_act] )
-            {
-            yy_size_t yyl;
-            for ( yyl = 0; yyl &lt; yyleng; ++yyl )
-                if ( yytext[yyl] == '\n' )
-                       
</del><ins>+                if ( yy_act != YY_END_OF_BUFFER &amp;&amp; yy_rule_can_match_eol[yy_act] )
+                        {
+                        yy_size_t yyl;
+                        for ( yyl = 0; yyl &lt; yyleng; ++yyl )
+                                if ( yytext[yyl] == '\n' )
+                                           
</ins><span class="cx">     do{ yylineno++;
</span><span class="cx">         yycolumn=0;
</span><span class="cx">     }while(0)
</span><span class="cx"> ;
</span><del>-            }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-do_action:  /* This label is used only to access EOF actions. */
</del><ins>+do_action:        /* This label is used only to access EOF actions. */
</ins><span class="cx"> 
</span><del>-        switch ( yy_act )
-    { /* beginning of action switch */
-            case 0: /* must back up */
-            /* undo the effects of YY_DO_BEFORE_ACTION */
-            *yy_cp = yyg-&gt;yy_hold_char;
-            yy_cp = yyg-&gt;yy_last_accepting_cpos;
-            yy_current_state = yyg-&gt;yy_last_accepting_state;
-            goto yy_find_action;
</del><ins>+                switch ( yy_act )
+        { /* beginning of action switch */
+                        case 0: /* must back up */
+                        /* undo the effects of YY_DO_BEFORE_ACTION */
+                        *yy_cp = yyg-&gt;yy_hold_char;
+                        yy_cp = yyg-&gt;yy_last_accepting_cpos;
+                        yy_current_state = yyg-&gt;yy_last_accepting_state;
+                        goto yy_find_action;
</ins><span class="cx"> 
</span><span class="cx"> case 1:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return INVARIANT; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 2:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return HIGH_PRECISION; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 3:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return MEDIUM_PRECISION; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 4:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return LOW_PRECISION; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 5:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return PRECISION; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 6:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return ATTRIBUTE; }
-    YY_BREAK
</del><ins>+{ return ES2_keyword_ES3_reserved(context, ATTRIBUTE); }
+        YY_BREAK
</ins><span class="cx"> case 7:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return CONST_QUAL; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 8:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return UNIFORM; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 9:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return VARYING; }
-    YY_BREAK
</del><ins>+{ return ES2_keyword_ES3_reserved(context, VARYING); }
+        YY_BREAK
</ins><span class="cx"> case 10:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return BREAK; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 11:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return CONTINUE; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 12:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return DO; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 13:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return FOR; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 14:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return WHILE; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 15:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return IF; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 16:
</span><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return ELSE; }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case 17:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return IN_QUAL; }
-    YY_BREAK
</del><ins>+{ return ES2_reserved_ES3_keyword(context, SWITCH); }
+        YY_BREAK
</ins><span class="cx"> case 18:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return OUT_QUAL; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, CASE); }
+        YY_BREAK
</ins><span class="cx"> case 19:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return INOUT_QUAL; }
-    YY_BREAK
</del><ins>+{ return ES2_reserved_ES3_keyword(context, DEFAULT); }
+        YY_BREAK
</ins><span class="cx"> case 20:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return FLOAT_TYPE; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, CENTROID); }
+        YY_BREAK
</ins><span class="cx"> case 21:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return INT_TYPE; }
-    YY_BREAK
</del><ins>+{ return ES2_reserved_ES3_keyword(context, FLAT); }
+        YY_BREAK
</ins><span class="cx"> case 22:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return VOID_TYPE; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, SMOOTH); }
+        YY_BREAK
</ins><span class="cx"> case 23:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return BOOL_TYPE; }
-    YY_BREAK
</del><ins>+{ return IN_QUAL; }
+        YY_BREAK
</ins><span class="cx"> case 24:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ yylval-&gt;lex.b = true;  return BOOLCONSTANT; }
-    YY_BREAK
</del><ins>+{ return OUT_QUAL; }
+        YY_BREAK
</ins><span class="cx"> case 25:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ yylval-&gt;lex.b = false; return BOOLCONSTANT; }
-    YY_BREAK
</del><ins>+{ return INOUT_QUAL; }
+        YY_BREAK
</ins><span class="cx"> case 26:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return DISCARD; }
-    YY_BREAK
</del><ins>+{ return FLOAT_TYPE; }
+        YY_BREAK
</ins><span class="cx"> case 27:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return RETURN; }
-    YY_BREAK
</del><ins>+{ return INT_TYPE; }
+        YY_BREAK
</ins><span class="cx"> case 28:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return MATRIX2; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, UINT_TYPE); }
+        YY_BREAK
</ins><span class="cx"> case 29:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return MATRIX3; }
-    YY_BREAK
</del><ins>+{ return VOID_TYPE; }
+        YY_BREAK
</ins><span class="cx"> case 30:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return MATRIX4; }
-    YY_BREAK
</del><ins>+{ return BOOL_TYPE; }
+        YY_BREAK
</ins><span class="cx"> case 31:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return VEC2; }
-    YY_BREAK
</del><ins>+{ yylval-&gt;lex.b = true;  return BOOLCONSTANT; }
+        YY_BREAK
</ins><span class="cx"> case 32:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return VEC3; }
-    YY_BREAK
</del><ins>+{ yylval-&gt;lex.b = false; return BOOLCONSTANT; }
+        YY_BREAK
</ins><span class="cx"> case 33:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return VEC4; }
-    YY_BREAK
</del><ins>+{ return DISCARD; }
+        YY_BREAK
</ins><span class="cx"> case 34:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return IVEC2; }
-    YY_BREAK
</del><ins>+{ return RETURN; }
+        YY_BREAK
</ins><span class="cx"> case 35:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return IVEC3; }
-    YY_BREAK
</del><ins>+{ return MATRIX2; }
+        YY_BREAK
</ins><span class="cx"> case 36:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return IVEC4; }
-    YY_BREAK
</del><ins>+{ return MATRIX3; }
+        YY_BREAK
</ins><span class="cx"> case 37:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return BVEC2; }
-    YY_BREAK
</del><ins>+{ return MATRIX4; }
+        YY_BREAK
</ins><span class="cx"> case 38:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return BVEC3; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, MATRIX2); }
+        YY_BREAK
</ins><span class="cx"> case 39:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return BVEC4; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, MATRIX3); }
+        YY_BREAK
</ins><span class="cx"> case 40:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return SAMPLER2D; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, MATRIX4); }
+        YY_BREAK
</ins><span class="cx"> case 41:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return SAMPLERCUBE; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, MATRIX2x3); }
+        YY_BREAK
</ins><span class="cx"> case 42:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return SAMPLER_EXTERNAL_OES; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, MATRIX3x2); }
+        YY_BREAK
</ins><span class="cx"> case 43:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return SAMPLER2DRECT; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, MATRIX2x4); }
+        YY_BREAK
</ins><span class="cx"> case 44:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return STRUCT; }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, MATRIX4x2); }
+        YY_BREAK
</ins><span class="cx"> case 45:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, MATRIX3x4); }
+        YY_BREAK
</ins><span class="cx"> case 46:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, MATRIX4x3); }
+        YY_BREAK
</ins><span class="cx"> case 47:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return VEC2; }
+        YY_BREAK
</ins><span class="cx"> case 48:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return VEC3; }
+        YY_BREAK
</ins><span class="cx"> case 49:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return VEC4; }
+        YY_BREAK
</ins><span class="cx"> case 50:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return IVEC2; }
+        YY_BREAK
</ins><span class="cx"> case 51:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return IVEC3; }
+        YY_BREAK
</ins><span class="cx"> case 52:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return IVEC4; }
+        YY_BREAK
</ins><span class="cx"> case 53:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return BVEC2; }
+        YY_BREAK
</ins><span class="cx"> case 54:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return BVEC3; }
+        YY_BREAK
</ins><span class="cx"> case 55:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return BVEC4; }
+        YY_BREAK
</ins><span class="cx"> case 56:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, UVEC2); }
+        YY_BREAK
</ins><span class="cx"> case 57:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, UVEC3); }
+        YY_BREAK
</ins><span class="cx"> case 58:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, UVEC4); }
+        YY_BREAK
</ins><span class="cx"> case 59:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return SAMPLER2D; }
+        YY_BREAK
</ins><span class="cx"> case 60:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return SAMPLERCUBE; }
+        YY_BREAK
</ins><span class="cx"> case 61:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return SAMPLER_EXTERNAL_OES; }
+        YY_BREAK
</ins><span class="cx"> case 62:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_reserved_ES3_keyword(context, SAMPLER3D); }
+        YY_BREAK
</ins><span class="cx"> case 63:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_reserved_ES3_keyword(context, SAMPLER3DRECT); }
+        YY_BREAK
</ins><span class="cx"> case 64:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return SAMPLER2DRECT; }
+        YY_BREAK
</ins><span class="cx"> case 65:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, SAMPLER2DARRAY); }
+        YY_BREAK
</ins><span class="cx"> case 66:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, ISAMPLER2D); }
+        YY_BREAK
</ins><span class="cx"> case 67:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, ISAMPLER3D); }
+        YY_BREAK
</ins><span class="cx"> case 68:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, ISAMPLERCUBE); }
+        YY_BREAK
</ins><span class="cx"> case 69:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, ISAMPLER2DARRAY); }
+        YY_BREAK
</ins><span class="cx"> case 70:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, USAMPLER2D); }
+        YY_BREAK
</ins><span class="cx"> case 71:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, USAMPLER3D); }
+        YY_BREAK
</ins><span class="cx"> case 72:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, USAMPLERCUBE); }
+        YY_BREAK
</ins><span class="cx"> case 73:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, USAMPLER2DARRAY); }
+        YY_BREAK
</ins><span class="cx"> case 74:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_reserved_ES3_keyword(context, SAMPLER2DSHADOW); }
+        YY_BREAK
</ins><span class="cx"> case 75:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, SAMPLERCUBESHADOW); }
+        YY_BREAK
</ins><span class="cx"> case 76:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, SAMPLER2DARRAYSHADOW); }
+        YY_BREAK
</ins><span class="cx"> case 77:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return STRUCT; }
+        YY_BREAK
</ins><span class="cx"> case 78:
</span><span class="cx"> YY_RULE_SETUP
</span><del>-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><ins>+{ return ES2_ident_ES3_keyword(context, LAYOUT); }
+        YY_BREAK
+/* Reserved keywords for GLSL ES 3.00 that are not reserved for GLSL ES 1.00 */
</ins><span class="cx"> case 79:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 80:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 81:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 82:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 83:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 84:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 85:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 86:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 87:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 88:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 89:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 90:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 91:
</span><del>-YY_RULE_SETUP
-{ return reserved_word(yyscanner); }
-    YY_BREAK
</del><span class="cx"> case 92:
</span><ins>+case 93:
+case 94:
+case 95:
+case 96:
+case 97:
+case 98:
+case 99:
+case 100:
+case 101:
+case 102:
+case 103:
+case 104:
+case 105:
+case 106:
+case 107:
+case 108:
+case 109:
+case 110:
+case 111:
+case 112:
+case 113:
+case 114:
+case 115:
+case 116:
+case 117:
+case 118:
+case 119:
+case 120:
+case 121:
+case 122:
+case 123:
+case 124:
+case 125:
+case 126:
+case 127:
+case 128:
+case 129:
+case 130:
+case 131:
+case 132:
+case 133:
+case 134:
</ins><span class="cx"> YY_RULE_SETUP
</span><ins>+{ 
+    if (context-&gt;shaderVersion &lt; 300) {
+                yylval-&gt;lex.string = NewPoolTString(yytext); 
+            return check_type(yyscanner); 
+        }
+        return reserved_word(yyscanner);
+}
+        YY_BREAK
+/* Reserved keywords in GLSL ES 1.00 that are not reserved in GLSL ES 3.00 */
+case 135:
+YY_RULE_SETUP
+{
+    if (context-&gt;shaderVersion &gt;= 300)
+    {
+        yylval-&gt;lex.string = NewPoolTString(yytext);
+        return check_type(yyscanner);
+    }
+
+    return reserved_word(yyscanner);
+}
+        YY_BREAK
+/* Reserved keywords */
+case 136:
+case 137:
+case 138:
+case 139:
+case 140:
+case 141:
+case 142:
+case 143:
+case 144:
+case 145:
+case 146:
+case 147:
+case 148:
+case 149:
+case 150:
+case 151:
+case 152:
+case 153:
+case 154:
+case 155:
+case 156:
+case 157:
+case 158:
+case 159:
+case 160:
+case 161:
+case 162:
+case 163:
+case 164:
+case 165:
+case 166:
+case 167:
+case 168:
+case 169:
+case 170:
+case 171:
+case 172:
+case 173:
+case 174:
+case 175:
+case 176:
+YY_RULE_SETUP
</ins><span class="cx"> { return reserved_word(yyscanner); }
</span><del>-    YY_BREAK
-case 93:
</del><ins>+        YY_BREAK
+case 177:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> {
</span><span class="cx">    yylval-&gt;lex.string = NewPoolTString(yytext); 
</span><span class="cx">    return check_type(yyscanner);
</span><span class="cx"> }
</span><del>-    YY_BREAK
-case 94:
</del><ins>+        YY_BREAK
+case 178:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return int_constant(yyscanner); }
</span><del>-    YY_BREAK
-case 95:
</del><ins>+        YY_BREAK
+case 179:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return int_constant(yyscanner); }
</span><del>-    YY_BREAK
-case 96:
</del><ins>+        YY_BREAK
+case 180:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return int_constant(yyscanner); }
</span><del>-    YY_BREAK
-case 97:
</del><ins>+        YY_BREAK
+case 181:
</ins><span class="cx"> YY_RULE_SETUP
</span><ins>+{ return uint_constant(context); }
+        YY_BREAK
+case 182:
+YY_RULE_SETUP
+{ return uint_constant(context); }
+        YY_BREAK
+case 183:
+YY_RULE_SETUP
+{ return uint_constant(context); }
+        YY_BREAK
+case 184:
+YY_RULE_SETUP
</ins><span class="cx"> { return float_constant(yyscanner); }
</span><del>-    YY_BREAK
-case 98:
</del><ins>+        YY_BREAK
+case 185:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return float_constant(yyscanner); }
</span><del>-    YY_BREAK
-case 99:
</del><ins>+        YY_BREAK
+case 186:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return float_constant(yyscanner); }
</span><del>-    YY_BREAK
-case 100:
</del><ins>+        YY_BREAK
+case 187:
</ins><span class="cx"> YY_RULE_SETUP
</span><ins>+{ return floatsuffix_check(context); }
+        YY_BREAK
+case 188:
+YY_RULE_SETUP
+{ return floatsuffix_check(context); }
+        YY_BREAK
+case 189:
+YY_RULE_SETUP
+{ return floatsuffix_check(context); }
+        YY_BREAK
+case 190:
+YY_RULE_SETUP
</ins><span class="cx"> { return ADD_ASSIGN; }
</span><del>-    YY_BREAK
-case 101:
</del><ins>+        YY_BREAK
+case 191:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return SUB_ASSIGN; }
</span><del>-    YY_BREAK
-case 102:
</del><ins>+        YY_BREAK
+case 192:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return MUL_ASSIGN; }
</span><del>-    YY_BREAK
-case 103:
</del><ins>+        YY_BREAK
+case 193:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return DIV_ASSIGN; }
</span><del>-    YY_BREAK
-case 104:
</del><ins>+        YY_BREAK
+case 194:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return MOD_ASSIGN; }
</span><del>-    YY_BREAK
-case 105:
</del><ins>+        YY_BREAK
+case 195:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return LEFT_ASSIGN; }
</span><del>-    YY_BREAK
-case 106:
</del><ins>+        YY_BREAK
+case 196:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return RIGHT_ASSIGN; }
</span><del>-    YY_BREAK
-case 107:
</del><ins>+        YY_BREAK
+case 197:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return AND_ASSIGN; }
</span><del>-    YY_BREAK
-case 108:
</del><ins>+        YY_BREAK
+case 198:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return XOR_ASSIGN; }
</span><del>-    YY_BREAK
-case 109:
</del><ins>+        YY_BREAK
+case 199:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return OR_ASSIGN; }
</span><del>-    YY_BREAK
-case 110:
</del><ins>+        YY_BREAK
+case 200:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return INC_OP; }
</span><del>-    YY_BREAK
-case 111:
</del><ins>+        YY_BREAK
+case 201:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return DEC_OP; }
</span><del>-    YY_BREAK
-case 112:
</del><ins>+        YY_BREAK
+case 202:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return AND_OP; }
</span><del>-    YY_BREAK
-case 113:
</del><ins>+        YY_BREAK
+case 203:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return OR_OP; }
</span><del>-    YY_BREAK
-case 114:
</del><ins>+        YY_BREAK
+case 204:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return XOR_OP; }
</span><del>-    YY_BREAK
-case 115:
</del><ins>+        YY_BREAK
+case 205:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return LE_OP; }
</span><del>-    YY_BREAK
-case 116:
</del><ins>+        YY_BREAK
+case 206:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return GE_OP; }
</span><del>-    YY_BREAK
-case 117:
</del><ins>+        YY_BREAK
+case 207:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return EQ_OP; }
</span><del>-    YY_BREAK
-case 118:
</del><ins>+        YY_BREAK
+case 208:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return NE_OP; }
</span><del>-    YY_BREAK
-case 119:
</del><ins>+        YY_BREAK
+case 209:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return LEFT_OP; }
</span><del>-    YY_BREAK
-case 120:
</del><ins>+        YY_BREAK
+case 210:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return RIGHT_OP; }
</span><del>-    YY_BREAK
-case 121:
</del><ins>+        YY_BREAK
+case 211:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return SEMICOLON; }
</span><del>-    YY_BREAK
-case 122:
</del><ins>+        YY_BREAK
+case 212:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return LEFT_BRACE; }
</span><del>-    YY_BREAK
-case 123:
</del><ins>+        YY_BREAK
+case 213:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return RIGHT_BRACE; }
</span><del>-    YY_BREAK
-case 124:
</del><ins>+        YY_BREAK
+case 214:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return COMMA; }
</span><del>-    YY_BREAK
-case 125:
</del><ins>+        YY_BREAK
+case 215:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return COLON; }
</span><del>-    YY_BREAK
-case 126:
</del><ins>+        YY_BREAK
+case 216:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return EQUAL; }
</span><del>-    YY_BREAK
-case 127:
</del><ins>+        YY_BREAK
+case 217:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return LEFT_PAREN; }
</span><del>-    YY_BREAK
-case 128:
</del><ins>+        YY_BREAK
+case 218:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return RIGHT_PAREN; }
</span><del>-    YY_BREAK
-case 129:
</del><ins>+        YY_BREAK
+case 219:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return LEFT_BRACKET; }
</span><del>-    YY_BREAK
-case 130:
</del><ins>+        YY_BREAK
+case 220:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return RIGHT_BRACKET; }
</span><del>-    YY_BREAK
-case 131:
</del><ins>+        YY_BREAK
+case 221:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return DOT; }
</span><del>-    YY_BREAK
-case 132:
</del><ins>+        YY_BREAK
+case 222:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return BANG; }
</span><del>-    YY_BREAK
-case 133:
</del><ins>+        YY_BREAK
+case 223:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return DASH; }
</span><del>-    YY_BREAK
-case 134:
</del><ins>+        YY_BREAK
+case 224:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return TILDE; }
</span><del>-    YY_BREAK
-case 135:
</del><ins>+        YY_BREAK
+case 225:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return PLUS; }
</span><del>-    YY_BREAK
-case 136:
</del><ins>+        YY_BREAK
+case 226:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return STAR; }
</span><del>-    YY_BREAK
-case 137:
</del><ins>+        YY_BREAK
+case 227:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return SLASH; }
</span><del>-    YY_BREAK
-case 138:
</del><ins>+        YY_BREAK
+case 228:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return PERCENT; }
</span><del>-    YY_BREAK
-case 139:
</del><ins>+        YY_BREAK
+case 229:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return LEFT_ANGLE; }
</span><del>-    YY_BREAK
-case 140:
</del><ins>+        YY_BREAK
+case 230:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return RIGHT_ANGLE; }
</span><del>-    YY_BREAK
-case 141:
</del><ins>+        YY_BREAK
+case 231:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return VERTICAL_BAR; }
</span><del>-    YY_BREAK
-case 142:
</del><ins>+        YY_BREAK
+case 232:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return CARET; }
</span><del>-    YY_BREAK
-case 143:
</del><ins>+        YY_BREAK
+case 233:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return AMPERSAND; }
</span><del>-    YY_BREAK
-case 144:
</del><ins>+        YY_BREAK
+case 234:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { return QUESTION; }
</span><del>-    YY_BREAK
-case 145:
-/* rule 145 can match eol */
</del><ins>+        YY_BREAK
+case 235:
+/* rule 235 can match eol */
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { }
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> case YY_STATE_EOF(INITIAL):
</span><span class="cx"> { yyterminate(); }
</span><del>-    YY_BREAK
-case 146:
</del><ins>+        YY_BREAK
+case 236:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> { assert(false); return 0; }
</span><del>-    YY_BREAK
-case 147:
</del><ins>+        YY_BREAK
+case 237:
</ins><span class="cx"> YY_RULE_SETUP
</span><span class="cx"> ECHO;
</span><del>-    YY_BREAK
</del><ins>+        YY_BREAK
</ins><span class="cx"> 
</span><del>-    case YY_END_OF_BUFFER:
-        {
-        /* Amount of text matched not including the EOB char. */
-        int yy_amount_of_matched_text = (int) (yy_cp - yyg-&gt;yytext_ptr) - 1;
</del><ins>+        case YY_END_OF_BUFFER:
+                {
+                /* Amount of text matched not including the EOB char. */
+                int yy_amount_of_matched_text = (int) (yy_cp - yyg-&gt;yytext_ptr) - 1;
</ins><span class="cx"> 
</span><del>-        /* Undo the effects of YY_DO_BEFORE_ACTION. */
-        *yy_cp = yyg-&gt;yy_hold_char;
-        YY_RESTORE_YY_MORE_OFFSET
</del><ins>+                /* Undo the effects of YY_DO_BEFORE_ACTION. */
+                *yy_cp = yyg-&gt;yy_hold_char;
+                YY_RESTORE_YY_MORE_OFFSET
</ins><span class="cx"> 
</span><del>-        if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_buffer_status == YY_BUFFER_NEW )
-            {
-            /* We're scanning a new file or input source.  It's
-             * possible that this happened because the user
-             * just pointed yyin at a new source and called
-             * yylex().  If so, then we have to assure
-             * consistency between YY_CURRENT_BUFFER and our
-             * globals.  Here is the right place to do so, because
-             * this is the first action (other than possibly a
-             * back-up) that will match for the new input source.
-             */
-            yyg-&gt;yy_n_chars = YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars;
-            YY_CURRENT_BUFFER_LVALUE-&gt;yy_input_file = yyin;
-            YY_CURRENT_BUFFER_LVALUE-&gt;yy_buffer_status = YY_BUFFER_NORMAL;
-            }
</del><ins>+                if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_buffer_status == YY_BUFFER_NEW )
+                        {
+                        /* We're scanning a new file or input source.  It's
+                         * possible that this happened because the user
+                         * just pointed yyin at a new source and called
+                         * yylex().  If so, then we have to assure
+                         * consistency between YY_CURRENT_BUFFER and our
+                         * globals.  Here is the right place to do so, because
+                         * this is the first action (other than possibly a
+                         * back-up) that will match for the new input source.
+                         */
+                        yyg-&gt;yy_n_chars = YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars;
+                        YY_CURRENT_BUFFER_LVALUE-&gt;yy_input_file = yyin;
+                        YY_CURRENT_BUFFER_LVALUE-&gt;yy_buffer_status = YY_BUFFER_NORMAL;
+                        }
</ins><span class="cx"> 
</span><del>-        /* Note that here we test for yy_c_buf_p &quot;&lt;=&quot; to the position
-         * of the first EOB in the buffer, since yy_c_buf_p will
-         * already have been incremented past the NUL character
-         * (since all states make transitions on EOB to the
-         * end-of-buffer state).  Contrast this with the test
-         * in input().
-         */
-        if ( yyg-&gt;yy_c_buf_p &lt;= &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars] )
-            { /* This was really a NUL. */
-            yy_state_type yy_next_state;
</del><ins>+                /* Note that here we test for yy_c_buf_p &quot;&lt;=&quot; to the position
+                 * of the first EOB in the buffer, since yy_c_buf_p will
+                 * already have been incremented past the NUL character
+                 * (since all states make transitions on EOB to the
+                 * end-of-buffer state).  Contrast this with the test
+                 * in input().
+                 */
+                if ( yyg-&gt;yy_c_buf_p &lt;= &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars] )
+                        { /* This was really a NUL. */
+                        yy_state_type yy_next_state;
</ins><span class="cx"> 
</span><del>-            yyg-&gt;yy_c_buf_p = yyg-&gt;yytext_ptr + yy_amount_of_matched_text;
</del><ins>+                        yyg-&gt;yy_c_buf_p = yyg-&gt;yytext_ptr + yy_amount_of_matched_text;
</ins><span class="cx"> 
</span><del>-            yy_current_state = yy_get_previous_state( yyscanner );
</del><ins>+                        yy_current_state = yy_get_previous_state( yyscanner );
</ins><span class="cx"> 
</span><del>-            /* Okay, we're now positioned to make the NUL
-             * transition.  We couldn't have
-             * yy_get_previous_state() go ahead and do it
-             * for us because it doesn't know how to deal
-             * with the possibility of jamming (and we don't
-             * want to build jamming into it because then it
-             * will run more slowly).
-             */
</del><ins>+                        /* Okay, we're now positioned to make the NUL
+                         * transition.  We couldn't have
+                         * yy_get_previous_state() go ahead and do it
+                         * for us because it doesn't know how to deal
+                         * with the possibility of jamming (and we don't
+                         * want to build jamming into it because then it
+                         * will run more slowly).
+                         */
</ins><span class="cx"> 
</span><del>-            yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
</del><ins>+                        yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
</ins><span class="cx"> 
</span><del>-            yy_bp = yyg-&gt;yytext_ptr + YY_MORE_ADJ;
</del><ins>+                        yy_bp = yyg-&gt;yytext_ptr + YY_MORE_ADJ;
</ins><span class="cx"> 
</span><del>-            if ( yy_next_state )
-                {
-                /* Consume the NUL. */
-                yy_cp = ++yyg-&gt;yy_c_buf_p;
-                yy_current_state = yy_next_state;
-                goto yy_match;
-                }
</del><ins>+                        if ( yy_next_state )
+                                {
+                                /* Consume the NUL. */
+                                yy_cp = ++yyg-&gt;yy_c_buf_p;
+                                yy_current_state = yy_next_state;
+                                goto yy_match;
+                                }
</ins><span class="cx"> 
</span><del>-            else
-                {
-                yy_cp = yyg-&gt;yy_last_accepting_cpos;
-                yy_current_state = yyg-&gt;yy_last_accepting_state;
-                goto yy_find_action;
-                }
-            }
</del><ins>+                        else
+                                {
+                                yy_cp = yyg-&gt;yy_last_accepting_cpos;
+                                yy_current_state = yyg-&gt;yy_last_accepting_state;
+                                goto yy_find_action;
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-        else switch ( yy_get_next_buffer( yyscanner ) )
-            {
-            case EOB_ACT_END_OF_FILE:
-                {
-                yyg-&gt;yy_did_buffer_switch_on_eof = 0;
</del><ins>+                else switch ( yy_get_next_buffer( yyscanner ) )
+                        {
+                        case EOB_ACT_END_OF_FILE:
+                                {
+                                yyg-&gt;yy_did_buffer_switch_on_eof = 0;
</ins><span class="cx"> 
</span><del>-                if ( yywrap(yyscanner ) )
-                    {
-                    /* Note: because we've taken care in
-                     * yy_get_next_buffer() to have set up
-                     * yytext, we can now set up
-                     * yy_c_buf_p so that if some total
-                     * hoser (like flex itself) wants to
-                     * call the scanner after we return the
-                     * YY_NULL, it'll still work - another
-                     * YY_NULL will get returned.
-                     */
-                    yyg-&gt;yy_c_buf_p = yyg-&gt;yytext_ptr + YY_MORE_ADJ;
</del><ins>+                                if ( yywrap(yyscanner ) )
+                                        {
+                                        /* Note: because we've taken care in
+                                         * yy_get_next_buffer() to have set up
+                                         * yytext, we can now set up
+                                         * yy_c_buf_p so that if some total
+                                         * hoser (like flex itself) wants to
+                                         * call the scanner after we return the
+                                         * YY_NULL, it'll still work - another
+                                         * YY_NULL will get returned.
+                                         */
+                                        yyg-&gt;yy_c_buf_p = yyg-&gt;yytext_ptr + YY_MORE_ADJ;
</ins><span class="cx"> 
</span><del>-                    yy_act = YY_STATE_EOF(YY_START);
-                    goto do_action;
-                    }
</del><ins>+                                        yy_act = YY_STATE_EOF(YY_START);
+                                        goto do_action;
+                                        }
</ins><span class="cx"> 
</span><del>-                else
-                    {
-                    if ( ! yyg-&gt;yy_did_buffer_switch_on_eof )
-                        YY_NEW_FILE;
-                    }
-                break;
-                }
</del><ins>+                                else
+                                        {
+                                        if ( ! yyg-&gt;yy_did_buffer_switch_on_eof )
+                                                YY_NEW_FILE;
+                                        }
+                                break;
+                                }
</ins><span class="cx"> 
</span><del>-            case EOB_ACT_CONTINUE_SCAN:
-                yyg-&gt;yy_c_buf_p =
-                    yyg-&gt;yytext_ptr + yy_amount_of_matched_text;
</del><ins>+                        case EOB_ACT_CONTINUE_SCAN:
+                                yyg-&gt;yy_c_buf_p =
+                                        yyg-&gt;yytext_ptr + yy_amount_of_matched_text;
</ins><span class="cx"> 
</span><del>-                yy_current_state = yy_get_previous_state( yyscanner );
</del><ins>+                                yy_current_state = yy_get_previous_state( yyscanner );
</ins><span class="cx"> 
</span><del>-                yy_cp = yyg-&gt;yy_c_buf_p;
-                yy_bp = yyg-&gt;yytext_ptr + YY_MORE_ADJ;
-                goto yy_match;
</del><ins>+                                yy_cp = yyg-&gt;yy_c_buf_p;
+                                yy_bp = yyg-&gt;yytext_ptr + YY_MORE_ADJ;
+                                goto yy_match;
</ins><span class="cx"> 
</span><del>-            case EOB_ACT_LAST_MATCH:
-                yyg-&gt;yy_c_buf_p =
-                &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars];
</del><ins>+                        case EOB_ACT_LAST_MATCH:
+                                yyg-&gt;yy_c_buf_p =
+                                &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars];
</ins><span class="cx"> 
</span><del>-                yy_current_state = yy_get_previous_state( yyscanner );
</del><ins>+                                yy_current_state = yy_get_previous_state( yyscanner );
</ins><span class="cx"> 
</span><del>-                yy_cp = yyg-&gt;yy_c_buf_p;
-                yy_bp = yyg-&gt;yytext_ptr + YY_MORE_ADJ;
-                goto yy_find_action;
-            }
-        break;
-        }
</del><ins>+                                yy_cp = yyg-&gt;yy_c_buf_p;
+                                yy_bp = yyg-&gt;yytext_ptr + YY_MORE_ADJ;
+                                goto yy_find_action;
+                        }
+                break;
+                }
</ins><span class="cx"> 
</span><del>-    default:
-        YY_FATAL_ERROR(
-            &quot;fatal flex scanner internal error--no action found&quot; );
-    } /* end of action switch */
-        } /* end of scanning one token */
</del><ins>+        default:
+                YY_FATAL_ERROR(
+                        &quot;fatal flex scanner internal error--no action found&quot; );
+        } /* end of action switch */
+                } /* end of scanning one token */
</ins><span class="cx"> } /* end of yylex */
</span><span class="cx"> 
</span><span class="cx"> /* yy_get_next_buffer - try to read in a new buffer
</span><span class="cx">  *
</span><span class="cx">  * Returns a code representing an action:
</span><del>- *  EOB_ACT_LAST_MATCH -
- *  EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- *  EOB_ACT_END_OF_FILE - end of file
</del><ins>+ *        EOB_ACT_LAST_MATCH -
+ *        EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *        EOB_ACT_END_OF_FILE - end of file
</ins><span class="cx">  */
</span><span class="cx"> static int yy_get_next_buffer (yyscan_t yyscanner)
</span><span class="cx"> {
</span><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><del>-    register char *dest = YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf;
-    register char *source = yyg-&gt;yytext_ptr;
-    register int number_to_move, i;
-    int ret_val;
</del><ins>+        register char *dest = YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf;
+        register char *source = yyg-&gt;yytext_ptr;
+        register int number_to_move, i;
+        int ret_val;
</ins><span class="cx"> 
</span><del>-    if ( yyg-&gt;yy_c_buf_p &gt; &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars + 1] )
-        YY_FATAL_ERROR(
-        &quot;fatal flex scanner internal error--end of buffer missed&quot; );
</del><ins>+        if ( yyg-&gt;yy_c_buf_p &gt; &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars + 1] )
+                YY_FATAL_ERROR(
+                &quot;fatal flex scanner internal error--end of buffer missed&quot; );
</ins><span class="cx"> 
</span><del>-    if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_fill_buffer == 0 )
-        { /* Don't try to fill the buffer, so this is an EOF. */
-        if ( yyg-&gt;yy_c_buf_p - yyg-&gt;yytext_ptr - YY_MORE_ADJ == 1 )
-            {
-            /* We matched a single character, the EOB, so
-             * treat this as a final EOF.
-             */
-            return EOB_ACT_END_OF_FILE;
-            }
</del><ins>+        if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_fill_buffer == 0 )
+                { /* Don't try to fill the buffer, so this is an EOF. */
+                if ( yyg-&gt;yy_c_buf_p - yyg-&gt;yytext_ptr - YY_MORE_ADJ == 1 )
+                        {
+                        /* We matched a single character, the EOB, so
+                         * treat this as a final EOF.
+                         */
+                        return EOB_ACT_END_OF_FILE;
+                        }
</ins><span class="cx"> 
</span><del>-        else
-            {
-            /* We matched some text prior to the EOB, first
-             * process it.
-             */
-            return EOB_ACT_LAST_MATCH;
-            }
-        }
</del><ins>+                else
+                        {
+                        /* We matched some text prior to the EOB, first
+                         * process it.
+                         */
+                        return EOB_ACT_LAST_MATCH;
+                        }
+                }
</ins><span class="cx"> 
</span><del>-    /* Try to read more data. */
</del><ins>+        /* Try to read more data. */
</ins><span class="cx"> 
</span><del>-    /* First move last chars to start of buffer. */
-    number_to_move = (int) (yyg-&gt;yy_c_buf_p - yyg-&gt;yytext_ptr) - 1;
</del><ins>+        /* First move last chars to start of buffer. */
+        number_to_move = (int) (yyg-&gt;yy_c_buf_p - yyg-&gt;yytext_ptr) - 1;
</ins><span class="cx"> 
</span><del>-    for ( i = 0; i &lt; number_to_move; ++i )
-        *(dest++) = *(source++);
</del><ins>+        for ( i = 0; i &lt; number_to_move; ++i )
+                *(dest++) = *(source++);
</ins><span class="cx"> 
</span><del>-    if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_buffer_status == YY_BUFFER_EOF_PENDING )
-        /* don't do the read, it's not guaranteed to return an EOF,
-         * just force an EOF
-         */
-        YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars = yyg-&gt;yy_n_chars = 0;
</del><ins>+        if ( YY_CURRENT_BUFFER_LVALUE-&gt;yy_buffer_status == YY_BUFFER_EOF_PENDING )
+                /* don't do the read, it's not guaranteed to return an EOF,
+                 * just force an EOF
+                 */
+                YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars = yyg-&gt;yy_n_chars = 0;
</ins><span class="cx"> 
</span><del>-    else
-        {
-            yy_size_t num_to_read =
-            YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_size - number_to_move - 1;
</del><ins>+        else
+                {
+                        yy_size_t num_to_read =
+                        YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_size - number_to_move - 1;
</ins><span class="cx"> 
</span><del>-        while ( num_to_read &lt;= 0 )
-            { /* Not enough room in the buffer - grow it. */
</del><ins>+                while ( num_to_read &lt;= 0 )
+                        { /* Not enough room in the buffer - grow it. */
</ins><span class="cx"> 
</span><del>-            /* just a shorter name for the current buffer */
-            YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
</del><ins>+                        /* just a shorter name for the current buffer */
+                        YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
</ins><span class="cx"> 
</span><del>-            int yy_c_buf_p_offset =
-                (int) (yyg-&gt;yy_c_buf_p - b-&gt;yy_ch_buf);
</del><ins>+                        int yy_c_buf_p_offset =
+                                (int) (yyg-&gt;yy_c_buf_p - b-&gt;yy_ch_buf);
</ins><span class="cx"> 
</span><del>-            if ( b-&gt;yy_is_our_buffer )
-                {
-                yy_size_t new_size = b-&gt;yy_buf_size * 2;
</del><ins>+                        if ( b-&gt;yy_is_our_buffer )
+                                {
+                                yy_size_t new_size = b-&gt;yy_buf_size * 2;
</ins><span class="cx"> 
</span><del>-                if ( new_size &lt;= 0 )
-                    b-&gt;yy_buf_size += b-&gt;yy_buf_size / 8;
-                else
-                    b-&gt;yy_buf_size *= 2;
</del><ins>+                                if ( new_size &lt;= 0 )
+                                        b-&gt;yy_buf_size += b-&gt;yy_buf_size / 8;
+                                else
+                                        b-&gt;yy_buf_size *= 2;
</ins><span class="cx"> 
</span><del>-                b-&gt;yy_ch_buf = (char *)
-                    /* Include room in for 2 EOB chars. */
-                    yyrealloc((void *) b-&gt;yy_ch_buf,b-&gt;yy_buf_size + 2 ,yyscanner );
-                }
-            else
-                /* Can't grow it, we don't own it. */
-                b-&gt;yy_ch_buf = 0;
</del><ins>+                                b-&gt;yy_ch_buf = (char *)
+                                        /* Include room in for 2 EOB chars. */
+                                        yyrealloc((void *) b-&gt;yy_ch_buf,b-&gt;yy_buf_size + 2 ,yyscanner );
+                                }
+                        else
+                                /* Can't grow it, we don't own it. */
+                                b-&gt;yy_ch_buf = 0;
</ins><span class="cx"> 
</span><del>-            if ( ! b-&gt;yy_ch_buf )
-                YY_FATAL_ERROR(
-                &quot;fatal error - scanner input buffer overflow&quot; );
</del><ins>+                        if ( ! b-&gt;yy_ch_buf )
+                                YY_FATAL_ERROR(
+                                &quot;fatal error - scanner input buffer overflow&quot; );
</ins><span class="cx"> 
</span><del>-            yyg-&gt;yy_c_buf_p = &amp;b-&gt;yy_ch_buf[yy_c_buf_p_offset];
</del><ins>+                        yyg-&gt;yy_c_buf_p = &amp;b-&gt;yy_ch_buf[yy_c_buf_p_offset];
</ins><span class="cx"> 
</span><del>-            num_to_read = YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_size -
-                        number_to_move - 1;
</del><ins>+                        num_to_read = YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_size -
+                                                number_to_move - 1;
</ins><span class="cx"> 
</span><del>-            }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-        if ( num_to_read &gt; YY_READ_BUF_SIZE )
-            num_to_read = YY_READ_BUF_SIZE;
</del><ins>+                if ( num_to_read &gt; YY_READ_BUF_SIZE )
+                        num_to_read = YY_READ_BUF_SIZE;
</ins><span class="cx"> 
</span><del>-        /* Read in more data. */
-        YY_INPUT( (&amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[number_to_move]),
-            yyg-&gt;yy_n_chars, num_to_read );
</del><ins>+                /* Read in more data. */
+                YY_INPUT( (&amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[number_to_move]),
+                        yyg-&gt;yy_n_chars, num_to_read );
</ins><span class="cx"> 
</span><del>-        YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars = yyg-&gt;yy_n_chars;
-        }
</del><ins>+                YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars = yyg-&gt;yy_n_chars;
+                }
</ins><span class="cx"> 
</span><del>-    if ( yyg-&gt;yy_n_chars == 0 )
-        {
-        if ( number_to_move == YY_MORE_ADJ )
-            {
-            ret_val = EOB_ACT_END_OF_FILE;
-            yyrestart(yyin  ,yyscanner);
-            }
</del><ins>+        if ( yyg-&gt;yy_n_chars == 0 )
+                {
+                if ( number_to_move == YY_MORE_ADJ )
+                        {
+                        ret_val = EOB_ACT_END_OF_FILE;
+                        yyrestart(yyin  ,yyscanner);
+                        }
</ins><span class="cx"> 
</span><del>-        else
-            {
-            ret_val = EOB_ACT_LAST_MATCH;
-            YY_CURRENT_BUFFER_LVALUE-&gt;yy_buffer_status =
-                YY_BUFFER_EOF_PENDING;
-            }
-        }
</del><ins>+                else
+                        {
+                        ret_val = EOB_ACT_LAST_MATCH;
+                        YY_CURRENT_BUFFER_LVALUE-&gt;yy_buffer_status =
+                                YY_BUFFER_EOF_PENDING;
+                        }
+                }
</ins><span class="cx"> 
</span><del>-    else
-        ret_val = EOB_ACT_CONTINUE_SCAN;
</del><ins>+        else
+                ret_val = EOB_ACT_CONTINUE_SCAN;
</ins><span class="cx"> 
</span><del>-    if ((yy_size_t) (yyg-&gt;yy_n_chars + number_to_move) &gt; YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_size) {
-        /* Extend the array by 50%, plus the number we really need. */
-        yy_size_t new_size = yyg-&gt;yy_n_chars + number_to_move + (yyg-&gt;yy_n_chars &gt;&gt; 1);
-        YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf,new_size ,yyscanner );
-        if ( ! YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf )
-            YY_FATAL_ERROR( &quot;out of dynamic memory in yy_get_next_buffer()&quot; );
-    }
</del><ins>+        if ((yy_size_t) (yyg-&gt;yy_n_chars + number_to_move) &gt; YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_size) {
+                /* Extend the array by 50%, plus the number we really need. */
+                yy_size_t new_size = yyg-&gt;yy_n_chars + number_to_move + (yyg-&gt;yy_n_chars &gt;&gt; 1);
+                YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf,new_size ,yyscanner );
+                if ( ! YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf )
+                        YY_FATAL_ERROR( &quot;out of dynamic memory in yy_get_next_buffer()&quot; );
+        }
</ins><span class="cx"> 
</span><del>-    yyg-&gt;yy_n_chars += number_to_move;
-    YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars] = YY_END_OF_BUFFER_CHAR;
-    YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
</del><ins>+        yyg-&gt;yy_n_chars += number_to_move;
+        YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+        YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
</ins><span class="cx"> 
</span><del>-    yyg-&gt;yytext_ptr = &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[0];
</del><ins>+        yyg-&gt;yytext_ptr = &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[0];
</ins><span class="cx"> 
</span><del>-    return ret_val;
</del><ins>+        return ret_val;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* yy_get_previous_state - get the state just before the EOB char was reached */
</span><span class="cx"> 
</span><span class="cx">     static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    register yy_state_type yy_current_state;
-    register char *yy_cp;
</del><ins>+        register yy_state_type yy_current_state;
+        register char *yy_cp;
</ins><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><span class="cx"> 
</span><del>-    yy_current_state = yyg-&gt;yy_start;
</del><ins>+        yy_current_state = yyg-&gt;yy_start;
</ins><span class="cx"> 
</span><del>-    for ( yy_cp = yyg-&gt;yytext_ptr + YY_MORE_ADJ; yy_cp &lt; yyg-&gt;yy_c_buf_p; ++yy_cp )
-        {
-        register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
-        if ( yy_accept[yy_current_state] )
-            {
-            yyg-&gt;yy_last_accepting_state = yy_current_state;
-            yyg-&gt;yy_last_accepting_cpos = yy_cp;
-            }
-        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-            {
-            yy_current_state = (int) yy_def[yy_current_state];
-            if ( yy_current_state &gt;= 443 )
-                yy_c = yy_meta[(unsigned int) yy_c];
-            }
-        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-        }
</del><ins>+        for ( yy_cp = yyg-&gt;yytext_ptr + YY_MORE_ADJ; yy_cp &lt; yyg-&gt;yy_c_buf_p; ++yy_cp )
+                {
+                register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+                if ( yy_accept[yy_current_state] )
+                        {
+                        yyg-&gt;yy_last_accepting_state = yy_current_state;
+                        yyg-&gt;yy_last_accepting_cpos = yy_cp;
+                        }
+                while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+                        {
+                        yy_current_state = (int) yy_def[yy_current_state];
+                        if ( yy_current_state &gt;= 813 )
+                                yy_c = yy_meta[(unsigned int) yy_c];
+                        }
+                yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+                }
</ins><span class="cx"> 
</span><del>-    return yy_current_state;
</del><ins>+        return yy_current_state;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* yy_try_NUL_trans - try to make a transition on the NUL character
</span><span class="cx">  *
</span><span class="cx">  * synopsis
</span><del>- *  next_state = yy_try_NUL_trans( current_state );
</del><ins>+ *        next_state = yy_try_NUL_trans( current_state );
</ins><span class="cx">  */
</span><span class="cx">     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    register int yy_is_jam;
</del><ins>+        register int yy_is_jam;
</ins><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
</span><del>-    register char *yy_cp = yyg-&gt;yy_c_buf_p;
</del><ins>+        register char *yy_cp = yyg-&gt;yy_c_buf_p;
</ins><span class="cx"> 
</span><del>-    register YY_CHAR yy_c = 1;
-    if ( yy_accept[yy_current_state] )
-        {
-        yyg-&gt;yy_last_accepting_state = yy_current_state;
-        yyg-&gt;yy_last_accepting_cpos = yy_cp;
-        }
-    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-        {
-        yy_current_state = (int) yy_def[yy_current_state];
-        if ( yy_current_state &gt;= 443 )
-            yy_c = yy_meta[(unsigned int) yy_c];
-        }
-    yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-    yy_is_jam = (yy_current_state == 442);
</del><ins>+        register YY_CHAR yy_c = 1;
+        if ( yy_accept[yy_current_state] )
+                {
+                yyg-&gt;yy_last_accepting_state = yy_current_state;
+                yyg-&gt;yy_last_accepting_cpos = yy_cp;
+                }
+        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+                {
+                yy_current_state = (int) yy_def[yy_current_state];
+                if ( yy_current_state &gt;= 813 )
+                        yy_c = yy_meta[(unsigned int) yy_c];
+                }
+        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+        yy_is_jam = (yy_current_state == 812);
</ins><span class="cx"> 
</span><del>-    (void)yyg;
-    return yy_is_jam ? 0 : yy_current_state;
</del><ins>+        (void)yyg;
+        return yy_is_jam ? 0 : yy_current_state;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #ifndef YY_NO_INPUT
</span><span class="lines">@@ -2067,79 +2380,79 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> {
</span><del>-    int c;
</del><ins>+        int c;
</ins><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><span class="cx"> 
</span><del>-    *yyg-&gt;yy_c_buf_p = yyg-&gt;yy_hold_char;
</del><ins>+        *yyg-&gt;yy_c_buf_p = yyg-&gt;yy_hold_char;
</ins><span class="cx"> 
</span><del>-    if ( *yyg-&gt;yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
-        {
-        /* yy_c_buf_p now points to the character we want to return.
-         * If this occurs *before* the EOB characters, then it's a
-         * valid NUL; if not, then we've hit the end of the buffer.
-         */
-        if ( yyg-&gt;yy_c_buf_p &lt; &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars] )
-            /* This was really a NUL. */
-            *yyg-&gt;yy_c_buf_p = '\0';
</del><ins>+        if ( *yyg-&gt;yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+                {
+                /* yy_c_buf_p now points to the character we want to return.
+                 * If this occurs *before* the EOB characters, then it's a
+                 * valid NUL; if not, then we've hit the end of the buffer.
+                 */
+                if ( yyg-&gt;yy_c_buf_p &lt; &amp;YY_CURRENT_BUFFER_LVALUE-&gt;yy_ch_buf[yyg-&gt;yy_n_chars] )
+                        /* This was really a NUL. */
+                        *yyg-&gt;yy_c_buf_p = '\0';
</ins><span class="cx"> 
</span><del>-        else
-            { /* need more input */
-            yy_size_t offset = yyg-&gt;yy_c_buf_p - yyg-&gt;yytext_ptr;
-            ++yyg-&gt;yy_c_buf_p;
</del><ins>+                else
+                        { /* need more input */
+                        yy_size_t offset = yyg-&gt;yy_c_buf_p - yyg-&gt;yytext_ptr;
+                        ++yyg-&gt;yy_c_buf_p;
</ins><span class="cx"> 
</span><del>-            switch ( yy_get_next_buffer( yyscanner ) )
-                {
-                case EOB_ACT_LAST_MATCH:
-                    /* This happens because yy_g_n_b()
-                     * sees that we've accumulated a
-                     * token and flags that we need to
-                     * try matching the token before
-                     * proceeding.  But for input(),
-                     * there's no matching to consider.
-                     * So convert the EOB_ACT_LAST_MATCH
-                     * to EOB_ACT_END_OF_FILE.
-                     */
</del><ins>+                        switch ( yy_get_next_buffer( yyscanner ) )
+                                {
+                                case EOB_ACT_LAST_MATCH:
+                                        /* This happens because yy_g_n_b()
+                                         * sees that we've accumulated a
+                                         * token and flags that we need to
+                                         * try matching the token before
+                                         * proceeding.  But for input(),
+                                         * there's no matching to consider.
+                                         * So convert the EOB_ACT_LAST_MATCH
+                                         * to EOB_ACT_END_OF_FILE.
+                                         */
</ins><span class="cx"> 
</span><del>-                    /* Reset buffer status. */
-                    yyrestart(yyin ,yyscanner);
</del><ins>+                                        /* Reset buffer status. */
+                                        yyrestart(yyin ,yyscanner);
</ins><span class="cx"> 
</span><del>-                    /*FALLTHROUGH*/
</del><ins>+                                        /*FALLTHROUGH*/
</ins><span class="cx"> 
</span><del>-                case EOB_ACT_END_OF_FILE:
-                    {
-                    if ( yywrap(yyscanner ) )
-                        return EOF;
</del><ins>+                                case EOB_ACT_END_OF_FILE:
+                                        {
+                                        if ( yywrap(yyscanner ) )
+                                                return EOF;
</ins><span class="cx"> 
</span><del>-                    if ( ! yyg-&gt;yy_did_buffer_switch_on_eof )
-                        YY_NEW_FILE;
</del><ins>+                                        if ( ! yyg-&gt;yy_did_buffer_switch_on_eof )
+                                                YY_NEW_FILE;
</ins><span class="cx"> #ifdef __cplusplus
</span><del>-                    return yyinput(yyscanner);
</del><ins>+                                        return yyinput(yyscanner);
</ins><span class="cx"> #else
</span><del>-                    return input(yyscanner);
</del><ins>+                                        return input(yyscanner);
</ins><span class="cx"> #endif
</span><del>-                    }
</del><ins>+                                        }
</ins><span class="cx"> 
</span><del>-                case EOB_ACT_CONTINUE_SCAN:
-                    yyg-&gt;yy_c_buf_p = yyg-&gt;yytext_ptr + offset;
-                    break;
-                }
-            }
-        }
</del><ins>+                                case EOB_ACT_CONTINUE_SCAN:
+                                        yyg-&gt;yy_c_buf_p = yyg-&gt;yytext_ptr + offset;
+                                        break;
+                                }
+                        }
+                }
</ins><span class="cx"> 
</span><del>-    c = *(unsigned char *) yyg-&gt;yy_c_buf_p; /* cast for 8-bit char's */
-    *yyg-&gt;yy_c_buf_p = '\0';    /* preserve yytext */
-    yyg-&gt;yy_hold_char = *++yyg-&gt;yy_c_buf_p;
</del><ins>+        c = *(unsigned char *) yyg-&gt;yy_c_buf_p;        /* cast for 8-bit char's */
+        *yyg-&gt;yy_c_buf_p = '\0';        /* preserve yytext */
+        yyg-&gt;yy_hold_char = *++yyg-&gt;yy_c_buf_p;
</ins><span class="cx"> 
</span><del>-    if ( c == '\n' )
-           
</del><ins>+        if ( c == '\n' )
+                   
</ins><span class="cx">     do{ yylineno++;
</span><span class="cx">         yycolumn=0;
</span><span class="cx">     }while(0)
</span><span class="cx"> ;
</span><span class="cx"> 
</span><del>-    return c;
</del><ins>+        return c;
</ins><span class="cx"> }
</span><del>-#endif  /* ifndef YY_NO_INPUT */
</del><ins>+#endif        /* ifndef YY_NO_INPUT */
</ins><span class="cx"> 
</span><span class="cx"> /** Immediately switch to a different input stream.
</span><span class="cx">  * @param input_file A readable stream.
</span><span class="lines">@@ -2150,14 +2463,14 @@
</span><span class="cx"> {
</span><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><span class="cx"> 
</span><del>-    if ( ! YY_CURRENT_BUFFER ){
</del><ins>+        if ( ! YY_CURRENT_BUFFER ){
</ins><span class="cx">         yyensure_buffer_stack (yyscanner);
</span><del>-        YY_CURRENT_BUFFER_LVALUE =
</del><ins>+                YY_CURRENT_BUFFER_LVALUE =
</ins><span class="cx">             yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
</span><del>-    }
</del><ins>+        }
</ins><span class="cx"> 
</span><del>-    yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
-    yy_load_buffer_state(yyscanner );
</del><ins>+        yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
+        yy_load_buffer_state(yyscanner );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Switch to a different input buffer.
</span><span class="lines">@@ -2168,41 +2481,41 @@
</span><span class="cx"> {
</span><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><span class="cx"> 
</span><del>-    /* TODO. We should be able to replace this entire function body
-     * with
-     *      yypop_buffer_state();
-     *      yypush_buffer_state(new_buffer);
</del><ins>+        /* TODO. We should be able to replace this entire function body
+         * with
+         *                yypop_buffer_state();
+         *                yypush_buffer_state(new_buffer);
</ins><span class="cx">      */
</span><del>-    yyensure_buffer_stack (yyscanner);
-    if ( YY_CURRENT_BUFFER == new_buffer )
-        return;
</del><ins>+        yyensure_buffer_stack (yyscanner);
+        if ( YY_CURRENT_BUFFER == new_buffer )
+                return;
</ins><span class="cx"> 
</span><del>-    if ( YY_CURRENT_BUFFER )
-        {
-        /* Flush out information for old buffer. */
-        *yyg-&gt;yy_c_buf_p = yyg-&gt;yy_hold_char;
-        YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_pos = yyg-&gt;yy_c_buf_p;
-        YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars = yyg-&gt;yy_n_chars;
-        }
</del><ins>+        if ( YY_CURRENT_BUFFER )
+                {
+                /* Flush out information for old buffer. */
+                *yyg-&gt;yy_c_buf_p = yyg-&gt;yy_hold_char;
+                YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_pos = yyg-&gt;yy_c_buf_p;
+                YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars = yyg-&gt;yy_n_chars;
+                }
</ins><span class="cx"> 
</span><del>-    YY_CURRENT_BUFFER_LVALUE = new_buffer;
-    yy_load_buffer_state(yyscanner );
</del><ins>+        YY_CURRENT_BUFFER_LVALUE = new_buffer;
+        yy_load_buffer_state(yyscanner );
</ins><span class="cx"> 
</span><del>-    /* We don't actually know whether we did this switch during
-     * EOF (yywrap()) processing, but the only time this flag
-     * is looked at is after yywrap() is called, so it's safe
-     * to go ahead and always set it.
-     */
-    yyg-&gt;yy_did_buffer_switch_on_eof = 1;
</del><ins>+        /* We don't actually know whether we did this switch during
+         * EOF (yywrap()) processing, but the only time this flag
+         * is looked at is after yywrap() is called, so it's safe
+         * to go ahead and always set it.
+         */
+        yyg-&gt;yy_did_buffer_switch_on_eof = 1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void yy_load_buffer_state  (yyscan_t yyscanner)
</span><span class="cx"> {
</span><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><del>-    yyg-&gt;yy_n_chars = YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars;
-    yyg-&gt;yytext_ptr = yyg-&gt;yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_pos;
-    yyin = YY_CURRENT_BUFFER_LVALUE-&gt;yy_input_file;
-    yyg-&gt;yy_hold_char = *yyg-&gt;yy_c_buf_p;
</del><ins>+        yyg-&gt;yy_n_chars = YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars;
+        yyg-&gt;yytext_ptr = yyg-&gt;yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_pos;
+        yyin = YY_CURRENT_BUFFER_LVALUE-&gt;yy_input_file;
+        yyg-&gt;yy_hold_char = *yyg-&gt;yy_c_buf_p;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Allocate and initialize an input buffer state.
</span><span class="lines">@@ -2213,26 +2526,26 @@
</span><span class="cx">  */
</span><span class="cx">     YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    YY_BUFFER_STATE b;
</del><ins>+        YY_BUFFER_STATE b;
</ins><span class="cx">     
</span><del>-    b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
-    if ( ! b )
-        YY_FATAL_ERROR( &quot;out of dynamic memory in yy_create_buffer()&quot; );
</del><ins>+        b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+        if ( ! b )
+                YY_FATAL_ERROR( &quot;out of dynamic memory in yy_create_buffer()&quot; );
</ins><span class="cx"> 
</span><del>-    b-&gt;yy_buf_size = size;
</del><ins>+        b-&gt;yy_buf_size = size;
</ins><span class="cx"> 
</span><del>-    /* yy_ch_buf has to be 2 characters longer than the size given because
-     * we need to put in 2 end-of-buffer characters.
-     */
-    b-&gt;yy_ch_buf = (char *) yyalloc(b-&gt;yy_buf_size + 2 ,yyscanner );
-    if ( ! b-&gt;yy_ch_buf )
-        YY_FATAL_ERROR( &quot;out of dynamic memory in yy_create_buffer()&quot; );
</del><ins>+        /* yy_ch_buf has to be 2 characters longer than the size given because
+         * we need to put in 2 end-of-buffer characters.
+         */
+        b-&gt;yy_ch_buf = (char *) yyalloc(b-&gt;yy_buf_size + 2 ,yyscanner );
+        if ( ! b-&gt;yy_ch_buf )
+                YY_FATAL_ERROR( &quot;out of dynamic memory in yy_create_buffer()&quot; );
</ins><span class="cx"> 
</span><del>-    b-&gt;yy_is_our_buffer = 1;
</del><ins>+        b-&gt;yy_is_our_buffer = 1;
</ins><span class="cx"> 
</span><del>-    yy_init_buffer(b,file ,yyscanner);
</del><ins>+        yy_init_buffer(b,file ,yyscanner);
</ins><span class="cx"> 
</span><del>-    return b;
</del><ins>+        return b;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Destroy the buffer.
</span><span class="lines">@@ -2243,16 +2556,16 @@
</span><span class="cx"> {
</span><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><span class="cx"> 
</span><del>-    if ( ! b )
-        return;
</del><ins>+        if ( ! b )
+                return;
</ins><span class="cx"> 
</span><del>-    if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
-        YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
</del><ins>+        if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+                YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
</ins><span class="cx"> 
</span><del>-    if ( b-&gt;yy_is_our_buffer )
-        yyfree((void *) b-&gt;yy_ch_buf ,yyscanner );
</del><ins>+        if ( b-&gt;yy_is_our_buffer )
+                yyfree((void *) b-&gt;yy_ch_buf ,yyscanner );
</ins><span class="cx"> 
</span><del>-    yyfree((void *) b ,yyscanner );
</del><ins>+        yyfree((void *) b ,yyscanner );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* Initializes or reinitializes a buffer.
</span><span class="lines">@@ -2262,13 +2575,13 @@
</span><span class="cx">     static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
</span><span class="cx"> 
</span><span class="cx"> {
</span><del>-    int oerrno = errno;
</del><ins>+        int oerrno = errno;
</ins><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><span class="cx"> 
</span><del>-    yy_flush_buffer(b ,yyscanner);
</del><ins>+        yy_flush_buffer(b ,yyscanner);
</ins><span class="cx"> 
</span><del>-    b-&gt;yy_input_file = file;
-    b-&gt;yy_fill_buffer = 1;
</del><ins>+        b-&gt;yy_input_file = file;
+        b-&gt;yy_fill_buffer = 1;
</ins><span class="cx"> 
</span><span class="cx">     /* If b is the current buffer, then yy_init_buffer was _probably_
</span><span class="cx">      * called from yyrestart() or through yy_get_next_buffer.
</span><span class="lines">@@ -2281,7 +2594,7 @@
</span><span class="cx"> 
</span><span class="cx">         b-&gt;yy_is_interactive = 0;
</span><span class="cx">     
</span><del>-    errno = oerrno;
</del><ins>+        errno = oerrno;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
</span><span class="lines">@@ -2291,25 +2604,25 @@
</span><span class="cx">     void yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
</span><span class="cx"> {
</span><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><del>-    if ( ! b )
-        return;
</del><ins>+        if ( ! b )
+                return;
</ins><span class="cx"> 
</span><del>-    b-&gt;yy_n_chars = 0;
</del><ins>+        b-&gt;yy_n_chars = 0;
</ins><span class="cx"> 
</span><del>-    /* We always need two end-of-buffer characters.  The first causes
-     * a transition to the end-of-buffer state.  The second causes
-     * a jam in that state.
-     */
-    b-&gt;yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
-    b-&gt;yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
</del><ins>+        /* We always need two end-of-buffer characters.  The first causes
+         * a transition to the end-of-buffer state.  The second causes
+         * a jam in that state.
+         */
+        b-&gt;yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+        b-&gt;yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
</ins><span class="cx"> 
</span><del>-    b-&gt;yy_buf_pos = &amp;b-&gt;yy_ch_buf[0];
</del><ins>+        b-&gt;yy_buf_pos = &amp;b-&gt;yy_ch_buf[0];
</ins><span class="cx"> 
</span><del>-    b-&gt;yy_at_bol = 1;
-    b-&gt;yy_buffer_status = YY_BUFFER_NEW;
</del><ins>+        b-&gt;yy_at_bol = 1;
+        b-&gt;yy_buffer_status = YY_BUFFER_NEW;
</ins><span class="cx"> 
</span><del>-    if ( b == YY_CURRENT_BUFFER )
-        yy_load_buffer_state(yyscanner );
</del><ins>+        if ( b == YY_CURRENT_BUFFER )
+                yy_load_buffer_state(yyscanner );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Pushes the new state onto the stack. The new state becomes
</span><span class="lines">@@ -2321,28 +2634,28 @@
</span><span class="cx"> void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
</span><span class="cx"> {
</span><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><del>-    if (new_buffer == NULL)
-        return;
</del><ins>+        if (new_buffer == NULL)
+                return;
</ins><span class="cx"> 
</span><del>-    yyensure_buffer_stack(yyscanner);
</del><ins>+        yyensure_buffer_stack(yyscanner);
</ins><span class="cx"> 
</span><del>-    /* This block is copied from yy_switch_to_buffer. */
-    if ( YY_CURRENT_BUFFER )
-        {
-        /* Flush out information for old buffer. */
-        *yyg-&gt;yy_c_buf_p = yyg-&gt;yy_hold_char;
-        YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_pos = yyg-&gt;yy_c_buf_p;
-        YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars = yyg-&gt;yy_n_chars;
-        }
</del><ins>+        /* This block is copied from yy_switch_to_buffer. */
+        if ( YY_CURRENT_BUFFER )
+                {
+                /* Flush out information for old buffer. */
+                *yyg-&gt;yy_c_buf_p = yyg-&gt;yy_hold_char;
+                YY_CURRENT_BUFFER_LVALUE-&gt;yy_buf_pos = yyg-&gt;yy_c_buf_p;
+                YY_CURRENT_BUFFER_LVALUE-&gt;yy_n_chars = yyg-&gt;yy_n_chars;
+                }
</ins><span class="cx"> 
</span><del>-    /* Only push if top exists. Otherwise, replace top. */
-    if (YY_CURRENT_BUFFER)
-        yyg-&gt;yy_buffer_stack_top++;
-    YY_CURRENT_BUFFER_LVALUE = new_buffer;
</del><ins>+        /* Only push if top exists. Otherwise, replace top. */
+        if (YY_CURRENT_BUFFER)
+                yyg-&gt;yy_buffer_stack_top++;
+        YY_CURRENT_BUFFER_LVALUE = new_buffer;
</ins><span class="cx"> 
</span><del>-    /* copied from yy_switch_to_buffer. */
-    yy_load_buffer_state(yyscanner );
-    yyg-&gt;yy_did_buffer_switch_on_eof = 1;
</del><ins>+        /* copied from yy_switch_to_buffer. */
+        yy_load_buffer_state(yyscanner );
+        yyg-&gt;yy_did_buffer_switch_on_eof = 1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Removes and deletes the top of the stack, if present.
</span><span class="lines">@@ -2352,18 +2665,18 @@
</span><span class="cx"> void yypop_buffer_state (yyscan_t yyscanner)
</span><span class="cx"> {
</span><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><del>-    if (!YY_CURRENT_BUFFER)
-        return;
</del><ins>+        if (!YY_CURRENT_BUFFER)
+                return;
</ins><span class="cx"> 
</span><del>-    yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
-    YY_CURRENT_BUFFER_LVALUE = NULL;
-    if (yyg-&gt;yy_buffer_stack_top &gt; 0)
-        --yyg-&gt;yy_buffer_stack_top;
</del><ins>+        yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+        YY_CURRENT_BUFFER_LVALUE = NULL;
+        if (yyg-&gt;yy_buffer_stack_top &gt; 0)
+                --yyg-&gt;yy_buffer_stack_top;
</ins><span class="cx"> 
</span><del>-    if (YY_CURRENT_BUFFER) {
-        yy_load_buffer_state(yyscanner );
-        yyg-&gt;yy_did_buffer_switch_on_eof = 1;
-    }
</del><ins>+        if (YY_CURRENT_BUFFER) {
+                yy_load_buffer_state(yyscanner );
+                yyg-&gt;yy_did_buffer_switch_on_eof = 1;
+        }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* Allocates the stack if it does not exist.
</span><span class="lines">@@ -2371,46 +2684,46 @@
</span><span class="cx">  */
</span><span class="cx"> static void yyensure_buffer_stack (yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    yy_size_t num_to_alloc;
</del><ins>+        yy_size_t num_to_alloc;
</ins><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><span class="cx"> 
</span><del>-    if (!yyg-&gt;yy_buffer_stack) {
</del><ins>+        if (!yyg-&gt;yy_buffer_stack) {
</ins><span class="cx"> 
</span><del>-        /* First allocation is just for 2 elements, since we don't know if this
-         * scanner will even need a stack. We use 2 instead of 1 to avoid an
-         * immediate realloc on the next call.
</del><ins>+                /* First allocation is just for 2 elements, since we don't know if this
+                 * scanner will even need a stack. We use 2 instead of 1 to avoid an
+                 * immediate realloc on the next call.
</ins><span class="cx">          */
</span><del>-        num_to_alloc = 1;
-        yyg-&gt;yy_buffer_stack = (struct yy_buffer_state**)yyalloc
-                                (num_to_alloc * sizeof(struct yy_buffer_state*)
-                                , yyscanner);
-        if ( ! yyg-&gt;yy_buffer_stack )
-            YY_FATAL_ERROR( &quot;out of dynamic memory in yyensure_buffer_stack()&quot; );
-                                  
-        memset(yyg-&gt;yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-                
-        yyg-&gt;yy_buffer_stack_max = num_to_alloc;
-        yyg-&gt;yy_buffer_stack_top = 0;
-        return;
-    }
</del><ins>+                num_to_alloc = 1;
+                yyg-&gt;yy_buffer_stack = (struct yy_buffer_state**)yyalloc
+                                                                (num_to_alloc * sizeof(struct yy_buffer_state*)
+                                                                , yyscanner);
+                if ( ! yyg-&gt;yy_buffer_stack )
+                        YY_FATAL_ERROR( &quot;out of dynamic memory in yyensure_buffer_stack()&quot; );
+                                                                  
+                memset(yyg-&gt;yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+                                
+                yyg-&gt;yy_buffer_stack_max = num_to_alloc;
+                yyg-&gt;yy_buffer_stack_top = 0;
+                return;
+        }
</ins><span class="cx"> 
</span><del>-    if (yyg-&gt;yy_buffer_stack_top &gt;= (yyg-&gt;yy_buffer_stack_max) - 1){
</del><ins>+        if (yyg-&gt;yy_buffer_stack_top &gt;= (yyg-&gt;yy_buffer_stack_max) - 1){
</ins><span class="cx"> 
</span><del>-        /* Increase the buffer to prepare for a possible push. */
-        int grow_size = 8 /* arbitrary grow size */;
</del><ins>+                /* Increase the buffer to prepare for a possible push. */
+                int grow_size = 8 /* arbitrary grow size */;
</ins><span class="cx"> 
</span><del>-        num_to_alloc = yyg-&gt;yy_buffer_stack_max + grow_size;
-        yyg-&gt;yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
-                                (yyg-&gt;yy_buffer_stack,
-                                num_to_alloc * sizeof(struct yy_buffer_state*)
-                                , yyscanner);
-        if ( ! yyg-&gt;yy_buffer_stack )
-            YY_FATAL_ERROR( &quot;out of dynamic memory in yyensure_buffer_stack()&quot; );
</del><ins>+                num_to_alloc = yyg-&gt;yy_buffer_stack_max + grow_size;
+                yyg-&gt;yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
+                                                                (yyg-&gt;yy_buffer_stack,
+                                                                num_to_alloc * sizeof(struct yy_buffer_state*)
+                                                                , yyscanner);
+                if ( ! yyg-&gt;yy_buffer_stack )
+                        YY_FATAL_ERROR( &quot;out of dynamic memory in yyensure_buffer_stack()&quot; );
</ins><span class="cx"> 
</span><del>-        /* zero only the new slots.*/
-        memset(yyg-&gt;yy_buffer_stack + yyg-&gt;yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
-        yyg-&gt;yy_buffer_stack_max = num_to_alloc;
-    }
</del><ins>+                /* zero only the new slots.*/
+                memset(yyg-&gt;yy_buffer_stack + yyg-&gt;yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
+                yyg-&gt;yy_buffer_stack_max = num_to_alloc;
+        }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Setup the input buffer state to scan directly from a user-specified character buffer.
</span><span class="lines">@@ -2421,31 +2734,31 @@
</span><span class="cx">  */
</span><span class="cx"> YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    YY_BUFFER_STATE b;
</del><ins>+        YY_BUFFER_STATE b;
</ins><span class="cx">     
</span><del>-    if ( size &lt; 2 ||
-         base[size-2] != YY_END_OF_BUFFER_CHAR ||
-         base[size-1] != YY_END_OF_BUFFER_CHAR )
-        /* They forgot to leave room for the EOB's. */
-        return 0;
</del><ins>+        if ( size &lt; 2 ||
+             base[size-2] != YY_END_OF_BUFFER_CHAR ||
+             base[size-1] != YY_END_OF_BUFFER_CHAR )
+                /* They forgot to leave room for the EOB's. */
+                return 0;
</ins><span class="cx"> 
</span><del>-    b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
-    if ( ! b )
-        YY_FATAL_ERROR( &quot;out of dynamic memory in yy_scan_buffer()&quot; );
</del><ins>+        b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+        if ( ! b )
+                YY_FATAL_ERROR( &quot;out of dynamic memory in yy_scan_buffer()&quot; );
</ins><span class="cx"> 
</span><del>-    b-&gt;yy_buf_size = size - 2;  /* &quot;- 2&quot; to take care of EOB's */
-    b-&gt;yy_buf_pos = b-&gt;yy_ch_buf = base;
-    b-&gt;yy_is_our_buffer = 0;
-    b-&gt;yy_input_file = 0;
-    b-&gt;yy_n_chars = b-&gt;yy_buf_size;
-    b-&gt;yy_is_interactive = 0;
-    b-&gt;yy_at_bol = 1;
-    b-&gt;yy_fill_buffer = 0;
-    b-&gt;yy_buffer_status = YY_BUFFER_NEW;
</del><ins>+        b-&gt;yy_buf_size = size - 2;        /* &quot;- 2&quot; to take care of EOB's */
+        b-&gt;yy_buf_pos = b-&gt;yy_ch_buf = base;
+        b-&gt;yy_is_our_buffer = 0;
+        b-&gt;yy_input_file = 0;
+        b-&gt;yy_n_chars = b-&gt;yy_buf_size;
+        b-&gt;yy_is_interactive = 0;
+        b-&gt;yy_at_bol = 1;
+        b-&gt;yy_fill_buffer = 0;
+        b-&gt;yy_buffer_status = YY_BUFFER_NEW;
</ins><span class="cx"> 
</span><del>-    yy_switch_to_buffer(b ,yyscanner );
</del><ins>+        yy_switch_to_buffer(b ,yyscanner );
</ins><span class="cx"> 
</span><del>-    return b;
</del><ins>+        return b;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Setup the input buffer state to scan a string. The next call to yylex() will
</span><span class="lines">@@ -2459,7 +2772,7 @@
</span><span class="cx"> YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
</span><span class="cx"> {
</span><span class="cx">     
</span><del>-    return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
</del><ins>+        return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
</span><span class="lines">@@ -2471,32 +2784,32 @@
</span><span class="cx">  */
</span><span class="cx"> YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    YY_BUFFER_STATE b;
-    char *buf;
-    yy_size_t n;
-    yy_size_t i;
</del><ins>+        YY_BUFFER_STATE b;
+        char *buf;
+        yy_size_t n;
+        yy_size_t i;
</ins><span class="cx">     
</span><del>-    /* Get memory for full buffer, including space for trailing EOB's. */
-    n = _yybytes_len + 2;
-    buf = (char *) yyalloc(n ,yyscanner );
-    if ( ! buf )
-        YY_FATAL_ERROR( &quot;out of dynamic memory in yy_scan_bytes()&quot; );
</del><ins>+        /* Get memory for full buffer, including space for trailing EOB's. */
+        n = _yybytes_len + 2;
+        buf = (char *) yyalloc(n ,yyscanner );
+        if ( ! buf )
+                YY_FATAL_ERROR( &quot;out of dynamic memory in yy_scan_bytes()&quot; );
</ins><span class="cx"> 
</span><del>-    for ( i = 0; i &lt; _yybytes_len; ++i )
-        buf[i] = yybytes[i];
</del><ins>+        for ( i = 0; i &lt; _yybytes_len; ++i )
+                buf[i] = yybytes[i];
</ins><span class="cx"> 
</span><del>-    buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
</del><ins>+        buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
</ins><span class="cx"> 
</span><del>-    b = yy_scan_buffer(buf,n ,yyscanner);
-    if ( ! b )
-        YY_FATAL_ERROR( &quot;bad buffer in yy_scan_bytes()&quot; );
</del><ins>+        b = yy_scan_buffer(buf,n ,yyscanner);
+        if ( ! b )
+                YY_FATAL_ERROR( &quot;bad buffer in yy_scan_bytes()&quot; );
</ins><span class="cx"> 
</span><del>-    /* It's okay to grow etc. this buffer, and we should throw it
-     * away when we're done.
-     */
-    b-&gt;yy_is_our_buffer = 1;
</del><ins>+        /* It's okay to grow etc. this buffer, and we should throw it
+         * away when we're done.
+         */
+        b-&gt;yy_is_our_buffer = 1;
</ins><span class="cx"> 
</span><del>-    return b;
</del><ins>+        return b;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #ifndef YY_EXIT_FAILURE
</span><span class="lines">@@ -2505,26 +2818,26 @@
</span><span class="cx"> 
</span><span class="cx"> static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-        (void) fprintf( stderr, &quot;%s\n&quot;, msg );
-    exit( YY_EXIT_FAILURE );
</del><ins>+            (void) fprintf( stderr, &quot;%s\n&quot;, msg );
+        exit( YY_EXIT_FAILURE );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* Redefine yyless() so it works in section 3 code. */
</span><span class="cx"> 
</span><span class="cx"> #undef yyless
</span><span class="cx"> #define yyless(n) \
</span><del>-    do \
-        { \
-        /* Undo effects of setting up yytext. */ \
</del><ins>+        do \
+                { \
+                /* Undo effects of setting up yytext. */ \
</ins><span class="cx">         int yyless_macro_arg = (n); \
</span><span class="cx">         YY_LESS_LINENO(yyless_macro_arg);\
</span><del>-        yytext[yyleng] = yyg-&gt;yy_hold_char; \
-        yyg-&gt;yy_c_buf_p = yytext + yyless_macro_arg; \
-        yyg-&gt;yy_hold_char = *yyg-&gt;yy_c_buf_p; \
-        *yyg-&gt;yy_c_buf_p = '\0'; \
-        yyleng = yyless_macro_arg; \
-        } \
-    while ( 0 )
</del><ins>+                yytext[yyleng] = yyg-&gt;yy_hold_char; \
+                yyg-&gt;yy_c_buf_p = yytext + yyless_macro_arg; \
+                yyg-&gt;yy_hold_char = *yyg-&gt;yy_c_buf_p; \
+                *yyg-&gt;yy_c_buf_p = '\0'; \
+                yyleng = yyless_macro_arg; \
+                } \
+        while ( 0 )
</ins><span class="cx"> 
</span><span class="cx"> /* Accessor  methods (get/set functions) to struct members. */
</span><span class="cx"> 
</span><span class="lines">@@ -2743,9 +3056,9 @@
</span><span class="cx">         errno = EINVAL;
</span><span class="cx">         return 1;
</span><span class="cx">     }
</span><del>-    
</del><ins>+        
</ins><span class="cx">     *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &amp;dummy_yyguts );
</span><del>-    
</del><ins>+        
</ins><span class="cx">     if (*ptr_yy_globals == NULL){
</span><span class="cx">         errno = ENOMEM;
</span><span class="cx">         return 1;
</span><span class="lines">@@ -2799,15 +3112,15 @@
</span><span class="cx">     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
</span><span class="cx"> 
</span><span class="cx">     /* Pop the buffer stack, destroying each element. */
</span><del>-    while(YY_CURRENT_BUFFER){
-        yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
-        YY_CURRENT_BUFFER_LVALUE = NULL;
-        yypop_buffer_state(yyscanner);
-    }
</del><ins>+        while(YY_CURRENT_BUFFER){
+                yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+                YY_CURRENT_BUFFER_LVALUE = NULL;
+                yypop_buffer_state(yyscanner);
+        }
</ins><span class="cx"> 
</span><del>-    /* Destroy the stack itself. */
-    yyfree(yyg-&gt;yy_buffer_stack ,yyscanner);
-    yyg-&gt;yy_buffer_stack = NULL;
</del><ins>+        /* Destroy the stack itself. */
+        yyfree(yyg-&gt;yy_buffer_stack ,yyscanner);
+        yyg-&gt;yy_buffer_stack = NULL;
</ins><span class="cx"> 
</span><span class="cx">     /* Destroy the start condition stack. */
</span><span class="cx">         yyfree(yyg-&gt;yy_start_stack ,yyscanner );
</span><span class="lines">@@ -2830,43 +3143,43 @@
</span><span class="cx"> #ifndef yytext_ptr
</span><span class="cx"> static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    register int i;
-    for ( i = 0; i &lt; n; ++i )
-        s1[i] = s2[i];
</del><ins>+        register int i;
+        for ( i = 0; i &lt; n; ++i )
+                s1[i] = s2[i];
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #ifdef YY_NEED_STRLEN
</span><span class="cx"> static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    register int n;
-    for ( n = 0; s[n]; ++n )
-        ;
</del><ins>+        register int n;
+        for ( n = 0; s[n]; ++n )
+                
</ins><span class="cx"> 
</span><del>-    return n;
</del><ins>+        return n;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> void *yyalloc (yy_size_t  size , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    return (void *) malloc( size );
</del><ins>+        return (void *) malloc( size );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void *yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    /* The cast to (char *) in the following accommodates both
-     * implementations that use char* generic pointers, and those
-     * that use void* generic pointers.  It works with the latter
-     * because both ANSI C and C++ allow castless assignment from
-     * any pointer type to void*, and deal with argument conversions
-     * as though doing an assignment.
-     */
-    return (void *) realloc( (char *) ptr, size );
</del><ins>+        /* The cast to (char *) in the following accommodates both
+         * implementations that use char* generic pointers, and those
+         * that use void* generic pointers.  It works with the latter
+         * because both ANSI C and C++ allow castless assignment from
+         * any pointer type to void*, and deal with argument conversions
+         * as though doing an assignment.
+         */
+        return (void *) realloc( (char *) ptr, size );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void yyfree (void * ptr , yyscan_t yyscanner)
</span><span class="cx"> {
</span><del>-    free( (char *) ptr );   /* see yyrealloc() for (char *) cast */
</del><ins>+        free( (char *) ptr );        /* see yyrealloc() for (char *) cast */
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #define YYTABLES_NAME &quot;yytables&quot;
</span><span class="lines">@@ -2895,11 +3208,12 @@
</span><span class="cx">     struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
</span><span class="cx">     
</span><span class="cx">     int token = IDENTIFIER;
</span><del>-    TSymbol* symbol = yyextra-&gt;symbolTable.find(yytext);
</del><ins>+    TSymbol* symbol = yyextra-&gt;symbolTable.find(yytext, yyextra-&gt;shaderVersion);
</ins><span class="cx">     if (symbol &amp;&amp; symbol-&gt;isVariable()) {
</span><span class="cx">         TVariable* variable = static_cast&lt;TVariable*&gt;(symbol);
</span><del>-        if (variable-&gt;isUserType())
</del><ins>+        if (variable-&gt;isUserType()) {
</ins><span class="cx">             token = TYPE_NAME;
</span><ins>+        }
</ins><span class="cx">     }
</span><span class="cx">     yylval-&gt;lex.symbol = symbol;
</span><span class="cx">     return token;
</span><span class="lines">@@ -2913,6 +3227,80 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int ES2_reserved_ES3_keyword(TParseContext *context, int token)
+{
+    yyscan_t yyscanner = (yyscan_t) context-&gt;scanner;
+
+    if (context-&gt;shaderVersion &lt; 300)
+    {
+        return reserved_word(yyscanner);
+    }
+
+    return token;
+}
+
+int ES2_keyword_ES3_reserved(TParseContext *context, int token)
+{
+    yyscan_t yyscanner = (yyscan_t) context-&gt;scanner;
+
+    if (context-&gt;shaderVersion &gt;= 300)
+    {
+        return reserved_word(yyscanner);
+    }
+
+    return token;
+}
+
+int ES2_ident_ES3_keyword(TParseContext *context, int token)
+{
+    struct yyguts_t* yyg = (struct yyguts_t*) context-&gt;scanner;
+    yyscan_t yyscanner = (yyscan_t) context-&gt;scanner;
+
+    // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name
+    if (context-&gt;shaderVersion &lt; 300)
+    {
+        yylval-&gt;lex.string = NewPoolTString(yytext);
+        return check_type(yyscanner);
+    }
+
+    return token;
+}
+
+int uint_constant(TParseContext *context)
+{
+    struct yyguts_t* yyg = (struct yyguts_t*) context-&gt;scanner;
+    yyscan_t yyscanner = (yyscan_t) context-&gt;scanner;
+
+    if (context-&gt;shaderVersion &lt; 300)
+    {
+        context-&gt;error(*yylloc, &quot;Unsigned integers are unsupported prior to GLSL ES 3.00&quot;, yytext, &quot;&quot;);
+        context-&gt;recover();
+        return 0;
+    }
+
+    if (!atoi_clamp(yytext, &amp;(yylval-&gt;lex.i)))
+        yyextra-&gt;warning(*yylloc, &quot;Integer overflow&quot;, yytext, &quot;&quot;);
+
+    return UINTCONSTANT;
+}
+
+int floatsuffix_check(TParseContext* context)
+{
+    struct yyguts_t* yyg = (struct yyguts_t*) context-&gt;scanner;
+
+    if (context-&gt;shaderVersion &lt; 300)
+    {
+        context-&gt;error(*yylloc, &quot;Floating-point suffix unsupported prior to GLSL ES 3.00&quot;, yytext);
+        context-&gt;recover();
+        return 0;
+    }
+
+    if (!atof_clamp(yytext, &amp;(yylval-&gt;lex.f)))
+        yyextra-&gt;warning(*yylloc, &quot;Float overflow&quot;, yytext, &quot;&quot;);
+
+    return(FLOATCONSTANT);
+}
+
</ins><span class="cx"> void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason) {
</span><span class="cx">     context-&gt;error(*lloc, reason, yyget_text(context-&gt;scanner));
</span><span class="cx">     context-&gt;recover();
</span><span class="lines">@@ -2962,7 +3350,6 @@
</span><span class="cx">     // Initialize preprocessor.
</span><span class="cx">     if (!context-&gt;preprocessor.init(count, string, length))
</span><span class="cx">         return 1;
</span><del>-    context-&gt;preprocessor.setMaxTokenLength(SH_MAX_TOKEN_LENGTH);
</del><span class="cx"> 
</span><span class="cx">     // Define extension macros.
</span><span class="cx">     const TExtensionBehavior&amp; extBehavior = context-&gt;extensionBehavior();
</span><span class="lines">@@ -2973,6 +3360,8 @@
</span><span class="cx">     if (context-&gt;fragmentPrecisionHigh)
</span><span class="cx">         context-&gt;preprocessor.predefineMacro(&quot;GL_FRAGMENT_PRECISION_HIGH&quot;, 1);
</span><span class="cx"> 
</span><ins>+    context-&gt;preprocessor.setMaxTokenSize(GetGlobalMaxTokenSize(context-&gt;shaderSpec));
+
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_lex.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorglslang_tabcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -96,6 +96,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> # ifndef YY_NULL
</span><span class="cx"> #  if defined __cplusplus &amp;&amp; 201103L &lt;= __cplusplus
</span><span class="cx"> #   define YY_NULL nullptr
</span><span class="lines">@@ -128,7 +129,6 @@
</span><span class="cx"> 
</span><span class="cx"> #define YYLTYPE TSourceLoc
</span><span class="cx"> #define YYLTYPE_IS_DECLARED 1
</span><del>-#define SH_MAX_TOKEN_LENGTH 256  // WebGL spec.
</del><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -149,88 +149,121 @@
</span><span class="cx">      BOOL_TYPE = 265,
</span><span class="cx">      FLOAT_TYPE = 266,
</span><span class="cx">      INT_TYPE = 267,
</span><del>-     BREAK = 268,
-     CONTINUE = 269,
-     DO = 270,
-     ELSE = 271,
-     FOR = 272,
-     IF = 273,
-     DISCARD = 274,
-     RETURN = 275,
-     BVEC2 = 276,
-     BVEC3 = 277,
-     BVEC4 = 278,
-     IVEC2 = 279,
-     IVEC3 = 280,
-     IVEC4 = 281,
-     VEC2 = 282,
-     VEC3 = 283,
-     VEC4 = 284,
-     MATRIX2 = 285,
-     MATRIX3 = 286,
-     MATRIX4 = 287,
-     IN_QUAL = 288,
-     OUT_QUAL = 289,
-     INOUT_QUAL = 290,
-     UNIFORM = 291,
-     VARYING = 292,
-     STRUCT = 293,
-     VOID_TYPE = 294,
-     WHILE = 295,
-     SAMPLER2D = 296,
-     SAMPLERCUBE = 297,
-     SAMPLER_EXTERNAL_OES = 298,
-     SAMPLER2DRECT = 299,
-     IDENTIFIER = 300,
-     TYPE_NAME = 301,
-     FLOATCONSTANT = 302,
-     INTCONSTANT = 303,
-     BOOLCONSTANT = 304,
-     LEFT_OP = 305,
-     RIGHT_OP = 306,
-     INC_OP = 307,
-     DEC_OP = 308,
-     LE_OP = 309,
-     GE_OP = 310,
-     EQ_OP = 311,
-     NE_OP = 312,
-     AND_OP = 313,
-     OR_OP = 314,
-     XOR_OP = 315,
-     MUL_ASSIGN = 316,
-     DIV_ASSIGN = 317,
-     ADD_ASSIGN = 318,
-     MOD_ASSIGN = 319,
-     LEFT_ASSIGN = 320,
-     RIGHT_ASSIGN = 321,
-     AND_ASSIGN = 322,
-     XOR_ASSIGN = 323,
-     OR_ASSIGN = 324,
-     SUB_ASSIGN = 325,
-     LEFT_PAREN = 326,
-     RIGHT_PAREN = 327,
-     LEFT_BRACKET = 328,
-     RIGHT_BRACKET = 329,
-     LEFT_BRACE = 330,
-     RIGHT_BRACE = 331,
-     DOT = 332,
-     COMMA = 333,
-     COLON = 334,
-     EQUAL = 335,
-     SEMICOLON = 336,
-     BANG = 337,
-     DASH = 338,
-     TILDE = 339,
-     PLUS = 340,
-     STAR = 341,
-     SLASH = 342,
-     PERCENT = 343,
-     LEFT_ANGLE = 344,
-     RIGHT_ANGLE = 345,
-     VERTICAL_BAR = 346,
-     CARET = 347,
-     AMPERSAND = 348,
-     QUESTION = 349
</del><ins>+     UINT_TYPE = 268,
+     BREAK = 269,
+     CONTINUE = 270,
+     DO = 271,
+     ELSE = 272,
+     FOR = 273,
+     IF = 274,
+     DISCARD = 275,
+     RETURN = 276,
+     SWITCH = 277,
+     CASE = 278,
+     DEFAULT = 279,
+     BVEC2 = 280,
+     BVEC3 = 281,
+     BVEC4 = 282,
+     IVEC2 = 283,
+     IVEC3 = 284,
+     IVEC4 = 285,
+     VEC2 = 286,
+     VEC3 = 287,
+     VEC4 = 288,
+     UVEC2 = 289,
+     UVEC3 = 290,
+     UVEC4 = 291,
+     MATRIX2 = 292,
+     MATRIX3 = 293,
+     MATRIX4 = 294,
+     IN_QUAL = 295,
+     OUT_QUAL = 296,
+     INOUT_QUAL = 297,
+     UNIFORM = 298,
+     VARYING = 299,
+     MATRIX2x3 = 300,
+     MATRIX3x2 = 301,
+     MATRIX2x4 = 302,
+     MATRIX4x2 = 303,
+     MATRIX3x4 = 304,
+     MATRIX4x3 = 305,
+     CENTROID = 306,
+     FLAT = 307,
+     SMOOTH = 308,
+     STRUCT = 309,
+     VOID_TYPE = 310,
+     WHILE = 311,
+     SAMPLER2D = 312,
+     SAMPLERCUBE = 313,
+     SAMPLER_EXTERNAL_OES = 314,
+     SAMPLER2DRECT = 315,
+     SAMPLER2DARRAY = 316,
+     ISAMPLER2D = 317,
+     ISAMPLER3D = 318,
+     ISAMPLERCUBE = 319,
+     ISAMPLER2DARRAY = 320,
+     USAMPLER2D = 321,
+     USAMPLER3D = 322,
+     USAMPLERCUBE = 323,
+     USAMPLER2DARRAY = 324,
+     SAMPLER3D = 325,
+     SAMPLER3DRECT = 326,
+     SAMPLER2DSHADOW = 327,
+     SAMPLERCUBESHADOW = 328,
+     SAMPLER2DARRAYSHADOW = 329,
+     LAYOUT = 330,
+     IDENTIFIER = 331,
+     TYPE_NAME = 332,
+     FLOATCONSTANT = 333,
+     INTCONSTANT = 334,
+     UINTCONSTANT = 335,
+     BOOLCONSTANT = 336,
+     FIELD_SELECTION = 337,
+     LEFT_OP = 338,
+     RIGHT_OP = 339,
+     INC_OP = 340,
+     DEC_OP = 341,
+     LE_OP = 342,
+     GE_OP = 343,
+     EQ_OP = 344,
+     NE_OP = 345,
+     AND_OP = 346,
+     OR_OP = 347,
+     XOR_OP = 348,
+     MUL_ASSIGN = 349,
+     DIV_ASSIGN = 350,
+     ADD_ASSIGN = 351,
+     MOD_ASSIGN = 352,
+     LEFT_ASSIGN = 353,
+     RIGHT_ASSIGN = 354,
+     AND_ASSIGN = 355,
+     XOR_ASSIGN = 356,
+     OR_ASSIGN = 357,
+     SUB_ASSIGN = 358,
+     LEFT_PAREN = 359,
+     RIGHT_PAREN = 360,
+     LEFT_BRACKET = 361,
+     RIGHT_BRACKET = 362,
+     LEFT_BRACE = 363,
+     RIGHT_BRACE = 364,
+     DOT = 365,
+     COMMA = 366,
+     COLON = 367,
+     EQUAL = 368,
+     SEMICOLON = 369,
+     BANG = 370,
+     DASH = 371,
+     TILDE = 372,
+     PLUS = 373,
+     STAR = 374,
+     SLASH = 375,
+     PERCENT = 376,
+     LEFT_ANGLE = 377,
+     RIGHT_ANGLE = 378,
+     VERTICAL_BAR = 379,
+     CARET = 380,
+     AMPERSAND = 381,
+     QUESTION = 382
</ins><span class="cx">    };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -245,6 +278,7 @@
</span><span class="cx">             TString *string;
</span><span class="cx">             float f;
</span><span class="cx">             int i;
</span><ins>+            unsigned int u;
</ins><span class="cx">             bool b;
</span><span class="cx">         };
</span><span class="cx">         TSymbol* symbol;
</span><span class="lines">@@ -260,6 +294,7 @@
</span><span class="cx">         union {
</span><span class="cx">             TPublicType type;
</span><span class="cx">             TPrecision precision;
</span><ins>+            TLayoutQualifier layoutQualifier;
</ins><span class="cx">             TQualifier qualifier;
</span><span class="cx">             TFunction* function;
</span><span class="cx">             TParameter param;
</span><span class="lines">@@ -342,8 +377,22 @@
</span><span class="cx">     }  \
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#define ES2_ONLY(S, L) {  \
+    if (context-&gt;shaderVersion != 100) {  \
+        context-&gt;error(L, &quot; supported in GLSL ES 1.00 only &quot;, S);  \
+        context-&gt;recover();  \
+    }  \
+}
</ins><span class="cx"> 
</span><ins>+#define ES3_ONLY(TOKEN, LINE, REASON) {  \
+    if (context-&gt;shaderVersion != 300) {  \
+        context-&gt;error(LINE, REASON &quot; supported in GLSL ES 3.00 only &quot;, TOKEN);  \
+        context-&gt;recover();  \
+    }  \
+}
</ins><span class="cx"> 
</span><ins>+
+
</ins><span class="cx"> #ifdef short
</span><span class="cx"> # undef short
</span><span class="cx"> #endif
</span><span class="lines">@@ -484,7 +533,7 @@
</span><span class="cx"> #  endif
</span><span class="cx"> #  if (defined __cplusplus &amp;&amp; ! defined EXIT_SUCCESS \
</span><span class="cx">        &amp;&amp; ! ((defined YYMALLOC || defined malloc) \
</span><del>-         &amp;&amp; (defined YYFREE || defined free)))
</del><ins>+             &amp;&amp; (defined YYFREE || defined free)))
</ins><span class="cx"> #   include &lt;stdlib.h&gt; /* INFRINGES ON USER NAME SPACE */
</span><span class="cx"> #   ifndef EXIT_SUCCESS
</span><span class="cx"> #    define EXIT_SUCCESS 0
</span><span class="lines">@@ -510,8 +559,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if (! defined yyoverflow \
</span><span class="cx">      &amp;&amp; (! defined __cplusplus \
</span><del>-     || (defined YYLTYPE_IS_TRIVIAL &amp;&amp; YYLTYPE_IS_TRIVIAL \
-         &amp;&amp; defined YYSTYPE_IS_TRIVIAL &amp;&amp; YYSTYPE_IS_TRIVIAL)))
</del><ins>+         || (defined YYLTYPE_IS_TRIVIAL &amp;&amp; YYLTYPE_IS_TRIVIAL \
+             &amp;&amp; defined YYSTYPE_IS_TRIVIAL &amp;&amp; YYSTYPE_IS_TRIVIAL)))
</ins><span class="cx"> 
</span><span class="cx"> /* A type that is properly aligned for any stack member.  */
</span><span class="cx"> union yyalloc
</span><span class="lines">@@ -537,15 +586,15 @@
</span><span class="cx">    elements in the stack, and YYPTR gives the new location of the
</span><span class="cx">    stack.  Advance YYPTR to a properly aligned location for the next
</span><span class="cx">    stack.  */
</span><del>-# define YYSTACK_RELOCATE(Stack_alloc, Stack)               \
-    do                                  \
-      {                                 \
-    YYSIZE_T yynewbytes;                        \
-    YYCOPY (&amp;yyptr-&gt;Stack_alloc, Stack, yysize);            \
-    Stack = &amp;yyptr-&gt;Stack_alloc;                    \
-    yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
-    yyptr += yynewbytes / sizeof (*yyptr);              \
-      }                                 \
</del><ins>+# define YYSTACK_RELOCATE(Stack_alloc, Stack)                                \
+    do                                                                        \
+      {                                                                        \
+        YYSIZE_T yynewbytes;                                                \
+        YYCOPY (&amp;yyptr-&gt;Stack_alloc, Stack, yysize);                        \
+        Stack = &amp;yyptr-&gt;Stack_alloc;                                        \
+        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+        yyptr += yynewbytes / sizeof (*yyptr);                                \
+      }                                                                        \
</ins><span class="cx">     while (YYID (0))
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="lines">@@ -571,24 +620,24 @@
</span><span class="cx"> #endif /* !YYCOPY_NEEDED */
</span><span class="cx"> 
</span><span class="cx"> /* YYFINAL -- State number of the termination state.  */
</span><del>-#define YYFINAL  74
</del><ins>+#define YYFINAL  114
</ins><span class="cx"> /* YYLAST -- Last index in YYTABLE.  */
</span><del>-#define YYLAST   1490
</del><ins>+#define YYLAST   2375
</ins><span class="cx"> 
</span><span class="cx"> /* YYNTOKENS -- Number of terminals.  */
</span><del>-#define YYNTOKENS  95
</del><ins>+#define YYNTOKENS  128
</ins><span class="cx"> /* YYNNTS -- Number of nonterminals.  */
</span><del>-#define YYNNTS  84
</del><ins>+#define YYNNTS  91
</ins><span class="cx"> /* YYNRULES -- Number of rules.  */
</span><del>-#define YYNRULES  202
</del><ins>+#define YYNRULES  250
</ins><span class="cx"> /* YYNRULES -- Number of states.  */
</span><del>-#define YYNSTATES  307
</del><ins>+#define YYNSTATES  373
</ins><span class="cx"> 
</span><span class="cx"> /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
</span><span class="cx"> #define YYUNDEFTOK  2
</span><del>-#define YYMAXUTOK   349
</del><ins>+#define YYMAXUTOK   382
</ins><span class="cx"> 
</span><del>-#define YYTRANSLATE(YYX)                        \
</del><ins>+#define YYTRANSLATE(YYX)                                                \
</ins><span class="cx">   ((unsigned int) (YYX) &lt;= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
</span><span class="cx"> 
</span><span class="cx"> /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
</span><span class="lines">@@ -628,7 +677,11 @@
</span><span class="cx">       55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
</span><span class="cx">       65,    66,    67,    68,    69,    70,    71,    72,    73,    74,
</span><span class="cx">       75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
</span><del>-      85,    86,    87,    88,    89,    90,    91,    92,    93,    94
</del><ins>+      85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
+      95,    96,    97,    98,    99,   100,   101,   102,   103,   104,
+     105,   106,   107,   108,   109,   110,   111,   112,   113,   114,
+     115,   116,   117,   118,   119,   120,   121,   122,   123,   124,
+     125,   126,   127
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #if YYDEBUG
</span><span class="lines">@@ -637,115 +690,138 @@
</span><span class="cx"> static const yytype_uint16 yyprhs[] =
</span><span class="cx"> {
</span><span class="cx">        0,     0,     3,     5,     7,     9,    11,    13,    15,    17,
</span><del>-      21,    23,    28,    30,    34,    37,    40,    42,    44,    46,
-      50,    53,    56,    59,    61,    64,    68,    71,    73,    75,
-      77,    80,    83,    86,    88,    90,    92,    94,    98,   102,
-     104,   108,   112,   114,   116,   120,   124,   128,   132,   134,
-     138,   142,   144,   146,   148,   150,   154,   156,   160,   162,
-     166,   168,   174,   176,   180,   182,   184,   186,   188,   190,
-     192,   196,   198,   201,   204,   209,   212,   214,   216,   219,
-     223,   227,   230,   236,   240,   243,   247,   250,   251,   253,
-     255,   257,   259,   261,   265,   271,   278,   284,   286,   289,
-     294,   300,   305,   308,   310,   313,   315,   317,   319,   322,
-     324,   326,   329,   331,   333,   335,   337,   342,   344,   346,
-     348,   350,   352,   354,   356,   358,   360,   362,   364,   366,
-     368,   370,   372,   374,   376,   378,   380,   382,   384,   386,
-     387,   394,   395,   401,   403,   406,   410,   412,   416,   418,
-     423,   425,   427,   429,   431,   433,   435,   437,   439,   441,
-     444,   445,   446,   452,   454,   456,   457,   460,   461,   464,
-     467,   471,   473,   476,   478,   481,   487,   491,   493,   495,
-     500,   501,   508,   509,   518,   519,   527,   529,   531,   533,
-     534,   537,   541,   544,   547,   550,   554,   557,   559,   562,
-     564,   566,   567
</del><ins>+      19,    23,    25,    30,    32,    36,    39,    42,    44,    46,
+      48,    52,    55,    58,    61,    63,    66,    70,    73,    75,
+      77,    79,    82,    85,    88,    90,    92,    94,    96,   100,
+     104,   106,   110,   114,   116,   118,   122,   126,   130,   134,
+     136,   140,   144,   146,   148,   150,   152,   156,   158,   162,
+     164,   168,   170,   176,   178,   182,   184,   186,   188,   190,
+     192,   194,   198,   200,   203,   206,   209,   214,   220,   227,
+     237,   240,   243,   245,   247,   250,   254,   258,   261,   267,
+     271,   274,   278,   281,   282,   284,   286,   288,   290,   292,
+     296,   302,   309,   315,   317,   320,   325,   331,   336,   339,
+     341,   344,   346,   348,   350,   352,   354,   357,   359,   362,
+     364,   366,   369,   371,   373,   375,   378,   381,   383,   385,
+     388,   390,   392,   394,   399,   401,   405,   407,   411,   415,
+     417,   422,   424,   426,   428,   430,   432,   434,   436,   438,
+     440,   442,   444,   446,   448,   450,   452,   454,   456,   458,
+     460,   462,   464,   466,   468,   470,   472,   474,   476,   478,
+     480,   482,   484,   486,   488,   490,   492,   494,   496,   498,
+     500,   502,   504,   506,   508,   510,   512,   513,   520,   521,
+     527,   529,   532,   536,   541,   543,   547,   549,   554,   556,
+     558,   560,   562,   564,   566,   568,   570,   572,   575,   576,
+     577,   583,   585,   587,   588,   591,   592,   595,   598,   602,
+     604,   607,   609,   612,   618,   622,   624,   626,   631,   632,
+     639,   640,   649,   650,   658,   660,   662,   664,   665,   668,
+     672,   675,   678,   681,   685,   688,   690,   693,   695,   697,
+     698
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
</span><span class="cx"> static const yytype_int16 yyrhs[] =
</span><span class="cx"> {
</span><del>-     175,     0,    -1,    45,    -1,    46,    -1,    45,    -1,    97,
-      -1,    48,    -1,    47,    -1,    49,    -1,    71,   124,    72,
-      -1,    98,    -1,    99,    73,   100,    74,    -1,   101,    -1,
-      99,    77,    96,    -1,    99,    52,    -1,    99,    53,    -1,
-     124,    -1,   102,    -1,   103,    -1,    99,    77,   103,    -1,
-     105,    72,    -1,   104,    72,    -1,   106,    39,    -1,   106,
-      -1,   106,   122,    -1,   105,    78,   122,    -1,   107,    71,
-      -1,   142,    -1,    45,    -1,    99,    -1,    52,   108,    -1,
-      53,   108,    -1,   109,   108,    -1,    85,    -1,    83,    -1,
-      82,    -1,   108,    -1,   110,    86,   108,    -1,   110,    87,
-     108,    -1,   110,    -1,   111,    85,   110,    -1,   111,    83,
-     110,    -1,   111,    -1,   112,    -1,   113,    89,   112,    -1,
-     113,    90,   112,    -1,   113,    54,   112,    -1,   113,    55,
-     112,    -1,   113,    -1,   114,    56,   113,    -1,   114,    57,
-     113,    -1,   114,    -1,   115,    -1,   116,    -1,   117,    -1,
-     118,    58,   117,    -1,   118,    -1,   119,    60,   118,    -1,
-     119,    -1,   120,    59,   119,    -1,   120,    -1,   120,    94,
-     124,    79,   122,    -1,   121,    -1,   108,   123,   122,    -1,
-      80,    -1,    61,    -1,    62,    -1,    63,    -1,    70,    -1,
-     122,    -1,   124,    78,   122,    -1,   121,    -1,   127,    81,
-      -1,   135,    81,    -1,     7,   140,   141,    81,    -1,   128,
-      72,    -1,   130,    -1,   129,    -1,   130,   132,    -1,   129,
-      78,   132,    -1,   137,    45,    71,    -1,   139,    96,    -1,
-     139,    96,    73,   125,    74,    -1,   138,   133,   131,    -1,
-     133,   131,    -1,   138,   133,   134,    -1,   133,   134,    -1,
-      -1,    33,    -1,    34,    -1,    35,    -1,   139,    -1,   136,
-      -1,   135,    78,    96,    -1,   135,    78,    96,    73,    74,
-      -1,   135,    78,    96,    73,   125,    74,    -1,   135,    78,
-      96,    80,   150,    -1,   137,    -1,   137,    96,    -1,   137,
-      96,    73,    74,    -1,   137,    96,    73,   125,    74,    -1,
-     137,    96,    80,   150,    -1,     3,    45,    -1,   139,    -1,
-     138,   139,    -1,     9,    -1,     8,    -1,    37,    -1,     3,
-      37,    -1,    36,    -1,   141,    -1,   140,   141,    -1,     4,
-      -1,     5,    -1,     6,    -1,   142,    -1,   142,    73,   125,
-      74,    -1,    39,    -1,    11,    -1,    12,    -1,    10,    -1,
-      27,    -1,    28,    -1,    29,    -1,    21,    -1,    22,    -1,
-      23,    -1,    24,    -1,    25,    -1,    26,    -1,    30,    -1,
-      31,    -1,    32,    -1,    41,    -1,    42,    -1,    43,    -1,
-      44,    -1,   143,    -1,    46,    -1,    -1,    38,    96,    75,
-     144,   146,    76,    -1,    -1,    38,    75,   145,   146,    76,
-      -1,   147,    -1,   146,   147,    -1,   139,   148,    81,    -1,
-     149,    -1,   148,    78,   149,    -1,    96,    -1,    96,    73,
-     125,    74,    -1,   122,    -1,   126,    -1,   154,    -1,   153,
-      -1,   151,    -1,   163,    -1,   164,    -1,   167,    -1,   174,
-      -1,    75,    76,    -1,    -1,    -1,    75,   155,   162,   156,
-      76,    -1,   161,    -1,   153,    -1,    -1,   159,   161,    -1,
-      -1,   160,   153,    -1,    75,    76,    -1,    75,   162,    76,
-      -1,   152,    -1,   162,   152,    -1,    81,    -1,   124,    81,
-      -1,    18,    71,   124,    72,   165,    -1,   158,    16,   158,
-      -1,   158,    -1,   124,    -1,   137,    96,    80,   150,    -1,
-      -1,    40,    71,   168,   166,    72,   157,    -1,    -1,    15,
-     169,   158,    40,    71,   124,    72,    81,    -1,    -1,    17,
-      71,   170,   171,   173,    72,   157,    -1,   163,    -1,   151,
-      -1,   166,    -1,    -1,   172,    81,    -1,   172,    81,   124,
-      -1,    14,    81,    -1,    13,    81,    -1,    20,    81,    -1,
-      20,   124,    81,    -1,    19,    81,    -1,   176,    -1,   175,
-     176,    -1,   177,    -1,   126,    -1,    -1,   127,   178,   161,
-      -1
</del><ins>+     215,     0,    -1,    76,    -1,    77,    -1,    76,    -1,   130,
+      -1,    79,    -1,    80,    -1,    78,    -1,    81,    -1,   104,
+     157,   105,    -1,   131,    -1,   132,   106,   133,   107,    -1,
+     134,    -1,   132,   110,   129,    -1,   132,    85,    -1,   132,
+      86,    -1,   157,    -1,   135,    -1,   136,    -1,   132,   110,
+     136,    -1,   138,   105,    -1,   137,   105,    -1,   139,    55,
+      -1,   139,    -1,   139,   155,    -1,   138,   111,   155,    -1,
+     140,   104,    -1,   182,    -1,    76,    -1,   132,    -1,    85,
+     141,    -1,    86,   141,    -1,   142,   141,    -1,   118,    -1,
+     116,    -1,   115,    -1,   141,    -1,   143,   119,   141,    -1,
+     143,   120,   141,    -1,   143,    -1,   144,   118,   143,    -1,
+     144,   116,   143,    -1,   144,    -1,   145,    -1,   146,   122,
+     145,    -1,   146,   123,   145,    -1,   146,    87,   145,    -1,
+     146,    88,   145,    -1,   146,    -1,   147,    89,   146,    -1,
+     147,    90,   146,    -1,   147,    -1,   148,    -1,   149,    -1,
+     150,    -1,   151,    91,   150,    -1,   151,    -1,   152,    93,
+     151,    -1,   152,    -1,   153,    92,   152,    -1,   153,    -1,
+     153,   127,   157,   112,   155,    -1,   154,    -1,   141,   156,
+     155,    -1,   113,    -1,    94,    -1,    95,    -1,    96,    -1,
+     103,    -1,   155,    -1,   157,   111,   155,    -1,   154,    -1,
+      76,   108,    -1,   161,   114,    -1,   169,   114,    -1,     7,
+     177,   181,   114,    -1,   174,   159,   186,   109,   114,    -1,
+     174,   159,   186,   109,    76,   114,    -1,   174,   159,   186,
+     109,    76,   106,   158,   107,   114,    -1,   174,   114,    -1,
+     162,   105,    -1,   164,    -1,   163,    -1,   164,   166,    -1,
+     163,   111,   166,    -1,   171,    76,   104,    -1,   176,   129,
+      -1,   176,   129,   106,   158,   107,    -1,   173,   167,   165,
+      -1,   167,   165,    -1,   173,   167,   168,    -1,   167,   168,
+      -1,    -1,    40,    -1,    41,    -1,    42,    -1,   176,    -1,
+     170,    -1,   169,   111,   129,    -1,   169,   111,   129,   106,
+     107,    -1,   169,   111,   129,   106,   158,   107,    -1,   169,
+     111,   129,   113,   190,    -1,   171,    -1,   171,   129,    -1,
+     171,   129,   106,   107,    -1,   171,   129,   106,   158,   107,
+      -1,   171,   129,   113,   190,    -1,     3,    76,    -1,   176,
+      -1,   174,   176,    -1,    53,    -1,    52,    -1,     9,    -1,
+       8,    -1,    44,    -1,     3,    44,    -1,   175,    -1,   172,
+     175,    -1,   172,    -1,   178,    -1,   178,   175,    -1,     9,
+      -1,    40,    -1,    41,    -1,    51,    40,    -1,    51,    41,
+      -1,    43,    -1,   181,    -1,   177,   181,    -1,     4,    -1,
+       5,    -1,     6,    -1,    75,   104,   179,   105,    -1,   180,
+      -1,   179,   111,   180,    -1,    76,    -1,    76,   113,    79,
+      -1,    76,   113,    80,    -1,   182,    -1,   182,   106,   158,
+     107,    -1,    55,    -1,    11,    -1,    12,    -1,    13,    -1,
+      10,    -1,    31,    -1,    32,    -1,    33,    -1,    25,    -1,
+      26,    -1,    27,    -1,    28,    -1,    29,    -1,    30,    -1,
+      34,    -1,    35,    -1,    36,    -1,    37,    -1,    38,    -1,
+      39,    -1,    45,    -1,    46,    -1,    47,    -1,    48,    -1,
+      49,    -1,    50,    -1,    57,    -1,    70,    -1,    58,    -1,
+      61,    -1,    62,    -1,    63,    -1,    64,    -1,    65,    -1,
+      66,    -1,    67,    -1,    68,    -1,    69,    -1,    72,    -1,
+      73,    -1,    74,    -1,    59,    -1,    60,    -1,   183,    -1,
+      77,    -1,    -1,    54,   129,   108,   184,   186,   109,    -1,
+      -1,    54,   108,   185,   186,   109,    -1,   187,    -1,   186,
+     187,    -1,   176,   188,   114,    -1,   174,   176,   188,   114,
+      -1,   189,    -1,   188,   111,   189,    -1,   129,    -1,   129,
+     106,   158,   107,    -1,   155,    -1,   160,    -1,   194,    -1,
+     193,    -1,   191,    -1,   203,    -1,   204,    -1,   207,    -1,
+     214,    -1,   108,   109,    -1,    -1,    -1,   108,   195,   202,
+     196,   109,    -1,   201,    -1,   193,    -1,    -1,   199,   201,
+      -1,    -1,   200,   193,    -1,   108,   109,    -1,   108,   202,
+     109,    -1,   192,    -1,   202,   192,    -1,   114,    -1,   157,
+     114,    -1,    19,   104,   157,   105,   205,    -1,   198,    17,
+     198,    -1,   198,    -1,   157,    -1,   171,   129,   113,   190,
+      -1,    -1,    56,   104,   208,   206,   105,   197,    -1,    -1,
+      16,   209,   198,    56,   104,   157,   105,   114,    -1,    -1,
+      18,   104,   210,   211,   213,   105,   197,    -1,   203,    -1,
+     191,    -1,   206,    -1,    -1,   212,   114,    -1,   212,   114,
+     157,    -1,    15,   114,    -1,    14,   114,    -1,    21,   114,
+      -1,    21,   157,   114,    -1,    20,   114,    -1,   216,    -1,
+     215,   216,    -1,   217,    -1,   160,    -1,    -1,   161,   218,
+     201,    -1
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
</span><span class="cx"> static const yytype_uint16 yyrline[] =
</span><span class="cx"> {
</span><del>-       0,   180,   180,   181,   184,   239,   242,   247,   252,   257,
-     263,   266,   269,   272,   367,   377,   390,   398,   498,   501,
-     509,   512,   518,   522,   529,   535,   544,   552,   607,   617,
-     620,   630,   640,   661,   662,   663,   668,   669,   677,   688,
-     689,   697,   708,   712,   713,   723,   733,   743,   756,   757,
-     767,   780,   784,   788,   792,   793,   806,   807,   820,   821,
-     834,   835,   852,   853,   866,   867,   868,   869,   870,   874,
-     877,   888,   896,   923,   928,   942,   997,  1000,  1007,  1015,
-    1036,  1057,  1067,  1095,  1100,  1110,  1115,  1125,  1128,  1131,
-    1134,  1140,  1147,  1150,  1172,  1190,  1214,  1237,  1241,  1259,
-    1267,  1299,  1319,  1340,  1349,  1372,  1375,  1381,  1389,  1397,
-    1405,  1415,  1422,  1425,  1428,  1434,  1437,  1452,  1456,  1460,
-    1464,  1468,  1473,  1478,  1483,  1488,  1493,  1498,  1503,  1508,
-    1513,  1518,  1523,  1528,  1532,  1536,  1544,  1552,  1556,  1569,
-    1569,  1583,  1583,  1592,  1595,  1611,  1644,  1648,  1654,  1661,
-    1676,  1680,  1684,  1685,  1691,  1692,  1693,  1694,  1695,  1699,
-    1700,  1700,  1700,  1710,  1711,  1715,  1715,  1716,  1716,  1721,
-    1724,  1734,  1737,  1743,  1744,  1748,  1756,  1760,  1770,  1775,
-    1792,  1792,  1797,  1797,  1804,  1804,  1812,  1815,  1821,  1824,
-    1830,  1834,  1841,  1848,  1855,  1862,  1873,  1882,  1886,  1893,
-    1896,  1902,  1902
</del><ins>+       0,   205,   205,   206,   209,   264,   267,   272,   277,   282,
+     287,   293,   296,   299,   302,   305,   315,   328,   336,   436,
+     439,   447,   450,   456,   460,   467,   473,   482,   490,   493,
+     503,   506,   516,   526,   547,   548,   549,   554,   555,   563,
+     574,   575,   583,   594,   598,   599,   609,   619,   629,   642,
+     643,   653,   666,   670,   674,   678,   679,   692,   693,   706,
+     707,   720,   721,   738,   739,   752,   753,   754,   755,   756,
+     760,   763,   774,   782,   790,   817,   822,   833,   837,   841,
+     845,   852,   907,   910,   917,   925,   946,   967,   977,  1005,
+    1010,  1020,  1025,  1035,  1038,  1041,  1044,  1050,  1057,  1060,
+    1064,  1068,  1072,  1079,  1083,  1087,  1094,  1098,  1102,  1123,
+    1132,  1138,  1141,  1147,  1153,  1160,  1169,  1178,  1186,  1189,
+    1196,  1200,  1207,  1210,  1214,  1218,  1227,  1236,  1244,  1254,
+    1261,  1264,  1267,  1273,  1280,  1283,  1289,  1292,  1295,  1301,
+    1304,  1319,  1323,  1327,  1331,  1335,  1339,  1344,  1349,  1354,
+    1359,  1364,  1369,  1374,  1379,  1384,  1389,  1394,  1399,  1404,
+    1409,  1414,  1419,  1424,  1429,  1434,  1439,  1444,  1448,  1452,
+    1456,  1460,  1464,  1468,  1472,  1476,  1480,  1484,  1488,  1492,
+    1496,  1500,  1504,  1512,  1520,  1524,  1537,  1537,  1540,  1540,
+    1546,  1549,  1565,  1568,  1577,  1581,  1587,  1594,  1609,  1613,
+    1617,  1618,  1624,  1625,  1626,  1627,  1628,  1632,  1633,  1633,
+    1633,  1643,  1644,  1648,  1648,  1649,  1649,  1654,  1657,  1667,
+    1670,  1676,  1677,  1681,  1689,  1693,  1703,  1708,  1725,  1725,
+    1730,  1730,  1737,  1737,  1745,  1748,  1754,  1757,  1763,  1767,
+    1774,  1781,  1788,  1795,  1806,  1815,  1819,  1826,  1829,  1835,
+    1835
</ins><span class="cx"> };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -756,13 +832,20 @@
</span><span class="cx"> {
</span><span class="cx">   &quot;$end&quot;, &quot;error&quot;, &quot;$undefined&quot;, &quot;INVARIANT&quot;, &quot;HIGH_PRECISION&quot;,
</span><span class="cx">   &quot;MEDIUM_PRECISION&quot;, &quot;LOW_PRECISION&quot;, &quot;PRECISION&quot;, &quot;ATTRIBUTE&quot;,
</span><del>-  &quot;CONST_QUAL&quot;, &quot;BOOL_TYPE&quot;, &quot;FLOAT_TYPE&quot;, &quot;INT_TYPE&quot;, &quot;BREAK&quot;, &quot;CONTINUE&quot;,
-  &quot;DO&quot;, &quot;ELSE&quot;, &quot;FOR&quot;, &quot;IF&quot;, &quot;DISCARD&quot;, &quot;RETURN&quot;, &quot;BVEC2&quot;, &quot;BVEC3&quot;,
-  &quot;BVEC4&quot;, &quot;IVEC2&quot;, &quot;IVEC3&quot;, &quot;IVEC4&quot;, &quot;VEC2&quot;, &quot;VEC3&quot;, &quot;VEC4&quot;, &quot;MATRIX2&quot;,
</del><ins>+  &quot;CONST_QUAL&quot;, &quot;BOOL_TYPE&quot;, &quot;FLOAT_TYPE&quot;, &quot;INT_TYPE&quot;, &quot;UINT_TYPE&quot;,
+  &quot;BREAK&quot;, &quot;CONTINUE&quot;, &quot;DO&quot;, &quot;ELSE&quot;, &quot;FOR&quot;, &quot;IF&quot;, &quot;DISCARD&quot;, &quot;RETURN&quot;,
+  &quot;SWITCH&quot;, &quot;CASE&quot;, &quot;DEFAULT&quot;, &quot;BVEC2&quot;, &quot;BVEC3&quot;, &quot;BVEC4&quot;, &quot;IVEC2&quot;, &quot;IVEC3&quot;,
+  &quot;IVEC4&quot;, &quot;VEC2&quot;, &quot;VEC3&quot;, &quot;VEC4&quot;, &quot;UVEC2&quot;, &quot;UVEC3&quot;, &quot;UVEC4&quot;, &quot;MATRIX2&quot;,
</ins><span class="cx">   &quot;MATRIX3&quot;, &quot;MATRIX4&quot;, &quot;IN_QUAL&quot;, &quot;OUT_QUAL&quot;, &quot;INOUT_QUAL&quot;, &quot;UNIFORM&quot;,
</span><del>-  &quot;VARYING&quot;, &quot;STRUCT&quot;, &quot;VOID_TYPE&quot;, &quot;WHILE&quot;, &quot;SAMPLER2D&quot;, &quot;SAMPLERCUBE&quot;,
-  &quot;SAMPLER_EXTERNAL_OES&quot;, &quot;SAMPLER2DRECT&quot;, &quot;IDENTIFIER&quot;, &quot;TYPE_NAME&quot;,
-  &quot;FLOATCONSTANT&quot;, &quot;INTCONSTANT&quot;, &quot;BOOLCONSTANT&quot;, &quot;LEFT_OP&quot;, &quot;RIGHT_OP&quot;,
</del><ins>+  &quot;VARYING&quot;, &quot;MATRIX2x3&quot;, &quot;MATRIX3x2&quot;, &quot;MATRIX2x4&quot;, &quot;MATRIX4x2&quot;,
+  &quot;MATRIX3x4&quot;, &quot;MATRIX4x3&quot;, &quot;CENTROID&quot;, &quot;FLAT&quot;, &quot;SMOOTH&quot;, &quot;STRUCT&quot;,
+  &quot;VOID_TYPE&quot;, &quot;WHILE&quot;, &quot;SAMPLER2D&quot;, &quot;SAMPLERCUBE&quot;, &quot;SAMPLER_EXTERNAL_OES&quot;,
+  &quot;SAMPLER2DRECT&quot;, &quot;SAMPLER2DARRAY&quot;, &quot;ISAMPLER2D&quot;, &quot;ISAMPLER3D&quot;,
+  &quot;ISAMPLERCUBE&quot;, &quot;ISAMPLER2DARRAY&quot;, &quot;USAMPLER2D&quot;, &quot;USAMPLER3D&quot;,
+  &quot;USAMPLERCUBE&quot;, &quot;USAMPLER2DARRAY&quot;, &quot;SAMPLER3D&quot;, &quot;SAMPLER3DRECT&quot;,
+  &quot;SAMPLER2DSHADOW&quot;, &quot;SAMPLERCUBESHADOW&quot;, &quot;SAMPLER2DARRAYSHADOW&quot;, &quot;LAYOUT&quot;,
+  &quot;IDENTIFIER&quot;, &quot;TYPE_NAME&quot;, &quot;FLOATCONSTANT&quot;, &quot;INTCONSTANT&quot;,
+  &quot;UINTCONSTANT&quot;, &quot;BOOLCONSTANT&quot;, &quot;FIELD_SELECTION&quot;, &quot;LEFT_OP&quot;, &quot;RIGHT_OP&quot;,
</ins><span class="cx">   &quot;INC_OP&quot;, &quot;DEC_OP&quot;, &quot;LE_OP&quot;, &quot;GE_OP&quot;, &quot;EQ_OP&quot;, &quot;NE_OP&quot;, &quot;AND_OP&quot;,
</span><span class="cx">   &quot;OR_OP&quot;, &quot;XOR_OP&quot;, &quot;MUL_ASSIGN&quot;, &quot;DIV_ASSIGN&quot;, &quot;ADD_ASSIGN&quot;,
</span><span class="cx">   &quot;MOD_ASSIGN&quot;, &quot;LEFT_ASSIGN&quot;, &quot;RIGHT_ASSIGN&quot;, &quot;AND_ASSIGN&quot;, &quot;XOR_ASSIGN&quot;,
</span><span class="lines">@@ -782,12 +865,15 @@
</span><span class="cx">   &quot;logical_and_expression&quot;, &quot;logical_xor_expression&quot;,
</span><span class="cx">   &quot;logical_or_expression&quot;, &quot;conditional_expression&quot;,
</span><span class="cx">   &quot;assignment_expression&quot;, &quot;assignment_operator&quot;, &quot;expression&quot;,
</span><del>-  &quot;constant_expression&quot;, &quot;declaration&quot;, &quot;function_prototype&quot;,
-  &quot;function_declarator&quot;, &quot;function_header_with_parameters&quot;,
-  &quot;function_header&quot;, &quot;parameter_declarator&quot;, &quot;parameter_declaration&quot;,
-  &quot;parameter_qualifier&quot;, &quot;parameter_type_specifier&quot;,
-  &quot;init_declarator_list&quot;, &quot;single_declaration&quot;, &quot;fully_specified_type&quot;,
-  &quot;type_qualifier&quot;, &quot;type_specifier&quot;, &quot;precision_qualifier&quot;,
</del><ins>+  &quot;constant_expression&quot;, &quot;enter_struct&quot;, &quot;declaration&quot;,
+  &quot;function_prototype&quot;, &quot;function_declarator&quot;,
+  &quot;function_header_with_parameters&quot;, &quot;function_header&quot;,
+  &quot;parameter_declarator&quot;, &quot;parameter_declaration&quot;, &quot;parameter_qualifier&quot;,
+  &quot;parameter_type_specifier&quot;, &quot;init_declarator_list&quot;, &quot;single_declaration&quot;,
+  &quot;fully_specified_type&quot;, &quot;interpolation_qualifier&quot;,
+  &quot;parameter_type_qualifier&quot;, &quot;type_qualifier&quot;, &quot;storage_qualifier&quot;,
+  &quot;type_specifier&quot;, &quot;precision_qualifier&quot;, &quot;layout_qualifier&quot;,
+  &quot;layout_qualifier_id_list&quot;, &quot;layout_qualifier_id&quot;,
</ins><span class="cx">   &quot;type_specifier_no_prec&quot;, &quot;type_specifier_nonarray&quot;, &quot;struct_specifier&quot;,
</span><span class="cx">   &quot;$@1&quot;, &quot;$@2&quot;, &quot;struct_declaration_list&quot;, &quot;struct_declaration&quot;,
</span><span class="cx">   &quot;struct_declarator_list&quot;, &quot;struct_declarator&quot;, &quot;initializer&quot;,
</span><span class="lines">@@ -816,60 +902,73 @@
</span><span class="cx">      315,   316,   317,   318,   319,   320,   321,   322,   323,   324,
</span><span class="cx">      325,   326,   327,   328,   329,   330,   331,   332,   333,   334,
</span><span class="cx">      335,   336,   337,   338,   339,   340,   341,   342,   343,   344,
</span><del>-     345,   346,   347,   348,   349
</del><ins>+     345,   346,   347,   348,   349,   350,   351,   352,   353,   354,
+     355,   356,   357,   358,   359,   360,   361,   362,   363,   364,
+     365,   366,   367,   368,   369,   370,   371,   372,   373,   374,
+     375,   376,   377,   378,   379,   380,   381,   382
</ins><span class="cx"> };
</span><span class="cx"> # endif
</span><span class="cx"> 
</span><span class="cx"> /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
</span><span class="cx"> static const yytype_uint8 yyr1[] =
</span><span class="cx"> {
</span><del>-       0,    95,    96,    96,    97,    98,    98,    98,    98,    98,
-      99,    99,    99,    99,    99,    99,   100,   101,   102,   102,
-     103,   103,   104,   104,   105,   105,   106,   107,   107,   108,
-     108,   108,   108,   109,   109,   109,   110,   110,   110,   111,
-     111,   111,   112,   113,   113,   113,   113,   113,   114,   114,
-     114,   115,   116,   117,   118,   118,   119,   119,   120,   120,
-     121,   121,   122,   122,   123,   123,   123,   123,   123,   124,
-     124,   125,   126,   126,   126,   127,   128,   128,   129,   129,
-     130,   131,   131,   132,   132,   132,   132,   133,   133,   133,
-     133,   134,   135,   135,   135,   135,   135,   136,   136,   136,
-     136,   136,   136,   137,   137,   138,   138,   138,   138,   138,
-     139,   139,   140,   140,   140,   141,   141,   142,   142,   142,
-     142,   142,   142,   142,   142,   142,   142,   142,   142,   142,
-     142,   142,   142,   142,   142,   142,   142,   142,   142,   144,
-     143,   145,   143,   146,   146,   147,   148,   148,   149,   149,
-     150,   151,   152,   152,   153,   153,   153,   153,   153,   154,
-     155,   156,   154,   157,   157,   159,   158,   160,   158,   161,
-     161,   162,   162,   163,   163,   164,   165,   165,   166,   166,
-     168,   167,   169,   167,   170,   167,   171,   171,   172,   172,
-     173,   173,   174,   174,   174,   174,   174,   175,   175,   176,
-     176,   178,   177
</del><ins>+       0,   128,   129,   129,   130,   131,   131,   131,   131,   131,
+     131,   132,   132,   132,   132,   132,   132,   133,   134,   135,
+     135,   136,   136,   137,   137,   138,   138,   139,   140,   140,
+     141,   141,   141,   141,   142,   142,   142,   143,   143,   143,
+     144,   144,   144,   145,   146,   146,   146,   146,   146,   147,
+     147,   147,   148,   149,   150,   151,   151,   152,   152,   153,
+     153,   154,   154,   155,   155,   156,   156,   156,   156,   156,
+     157,   157,   158,   159,   160,   160,   160,   160,   160,   160,
+     160,   161,   162,   162,   163,   163,   164,   165,   165,   166,
+     166,   166,   166,   167,   167,   167,   167,   168,   169,   169,
+     169,   169,   169,   170,   170,   170,   170,   170,   170,   171,
+     171,   172,   172,   173,   174,   174,   174,   174,   174,   174,
+     174,   174,   175,   175,   175,   175,   175,   175,   176,   176,
+     177,   177,   177,   178,   179,   179,   180,   180,   180,   181,
+     181,   182,   182,   182,   182,   182,   182,   182,   182,   182,
+     182,   182,   182,   182,   182,   182,   182,   182,   182,   182,
+     182,   182,   182,   182,   182,   182,   182,   182,   182,   182,
+     182,   182,   182,   182,   182,   182,   182,   182,   182,   182,
+     182,   182,   182,   182,   182,   182,   184,   183,   185,   183,
+     186,   186,   187,   187,   188,   188,   189,   189,   190,   191,
+     192,   192,   193,   193,   193,   193,   193,   194,   195,   196,
+     194,   197,   197,   199,   198,   200,   198,   201,   201,   202,
+     202,   203,   203,   204,   205,   205,   206,   206,   208,   207,
+     209,   207,   210,   207,   211,   211,   212,   212,   213,   213,
+     214,   214,   214,   214,   214,   215,   215,   216,   216,   218,
+     217
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
</span><span class="cx"> static const yytype_uint8 yyr2[] =
</span><span class="cx"> {
</span><del>-       0,     2,     1,     1,     1,     1,     1,     1,     1,     3,
-       1,     4,     1,     3,     2,     2,     1,     1,     1,     3,
-       2,     2,     2,     1,     2,     3,     2,     1,     1,     1,
-       2,     2,     2,     1,     1,     1,     1,     3,     3,     1,
-       3,     3,     1,     1,     3,     3,     3,     3,     1,     3,
-       3,     1,     1,     1,     1,     3,     1,     3,     1,     3,
-       1,     5,     1,     3,     1,     1,     1,     1,     1,     1,
-       3,     1,     2,     2,     4,     2,     1,     1,     2,     3,
-       3,     2,     5,     3,     2,     3,     2,     0,     1,     1,
-       1,     1,     1,     3,     5,     6,     5,     1,     2,     4,
-       5,     4,     2,     1,     2,     1,     1,     1,     2,     1,
-       1,     2,     1,     1,     1,     1,     4,     1,     1,     1,
</del><ins>+       0,     2,     1,     1,     1,     1,     1,     1,     1,     1,
+       3,     1,     4,     1,     3,     2,     2,     1,     1,     1,
+       3,     2,     2,     2,     1,     2,     3,     2,     1,     1,
+       1,     2,     2,     2,     1,     1,     1,     1,     3,     3,
+       1,     3,     3,     1,     1,     3,     3,     3,     3,     1,
+       3,     3,     1,     1,     1,     1,     3,     1,     3,     1,
+       3,     1,     5,     1,     3,     1,     1,     1,     1,     1,
+       1,     3,     1,     2,     2,     2,     4,     5,     6,     9,
+       2,     2,     1,     1,     2,     3,     3,     2,     5,     3,
+       2,     3,     2,     0,     1,     1,     1,     1,     1,     3,
+       5,     6,     5,     1,     2,     4,     5,     4,     2,     1,
+       2,     1,     1,     1,     1,     1,     2,     1,     2,     1,
+       1,     2,     1,     1,     1,     2,     2,     1,     1,     2,
+       1,     1,     1,     4,     1,     3,     1,     3,     3,     1,
+       4,     1,     1,     1,     1,     1,     1,     1,     1,     1,
</ins><span class="cx">        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
</span><del>-       1,     1,     1,     1,     1,     1,     1,     1,     1,     0,
-       6,     0,     5,     1,     2,     3,     1,     3,     1,     4,
-       1,     1,     1,     1,     1,     1,     1,     1,     1,     2,
-       0,     0,     5,     1,     1,     0,     2,     0,     2,     2,
-       3,     1,     2,     1,     2,     5,     3,     1,     1,     4,
-       0,     6,     0,     8,     0,     7,     1,     1,     1,     0,
-       2,     3,     2,     2,     2,     3,     2,     1,     2,     1,
-       1,     0,     3
</del><ins>+       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
+       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
+       1,     1,     1,     1,     1,     1,     0,     6,     0,     5,
+       1,     2,     3,     4,     1,     3,     1,     4,     1,     1,
+       1,     1,     1,     1,     1,     1,     1,     2,     0,     0,
+       5,     1,     1,     0,     2,     0,     2,     2,     3,     1,
+       2,     1,     2,     5,     3,     1,     1,     4,     0,     6,
+       0,     8,     0,     7,     1,     1,     1,     0,     2,     3,
+       2,     2,     2,     3,     2,     1,     2,     1,     1,     0,
+       3
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
</span><span class="lines">@@ -877,421 +976,613 @@
</span><span class="cx">    means the default is an error.  */
</span><span class="cx"> static const yytype_uint8 yydefact[] =
</span><span class="cx"> {
</span><del>-       0,     0,   112,   113,   114,     0,   106,   105,   120,   118,
-     119,   124,   125,   126,   127,   128,   129,   121,   122,   123,
-     130,   131,   132,   109,   107,     0,   117,   133,   134,   135,
-     136,   138,   200,   201,     0,    77,    87,     0,    92,    97,
-       0,   103,     0,   110,   115,   137,     0,   197,   199,   108,
-     102,     0,     2,     3,   141,     0,    72,     0,    75,    87,
-       0,    88,    89,    90,    78,     0,    87,     0,    73,     2,
-      98,   104,   111,     0,     1,   198,     0,     0,   139,     0,
-     202,    79,    84,    86,    91,     0,    93,    80,     0,     0,
-       4,     7,     6,     8,     0,     0,     0,    35,    34,    33,
-       5,    10,    29,    12,    17,    18,     0,     0,    23,     0,
-      36,     0,    39,    42,    43,    48,    51,    52,    53,    54,
-      56,    58,    60,    71,     0,    27,    74,     0,     0,   143,
-       0,     0,     0,   182,     0,     0,     0,     0,     0,   160,
-     169,   173,    36,    62,    69,     0,   151,     0,   115,   154,
-     171,   153,   152,     0,   155,   156,   157,   158,    81,    83,
-      85,     0,     0,    99,     0,   150,   101,    30,    31,     0,
-      14,    15,     0,     0,    21,    20,     0,    22,    24,    26,
-      32,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,   116,   148,     0,   146,   142,
-     144,     0,   193,   192,   167,   184,     0,   196,   194,     0,
-     180,   159,     0,    65,    66,    67,    68,    64,     0,     0,
-     174,   170,   172,     0,    94,     0,    96,   100,     9,     0,
-      16,     2,     3,    13,    19,    25,    37,    38,    41,    40,
-      46,    47,    44,    45,    49,    50,    55,    57,    59,     0,
-       0,     0,   145,   140,     0,     0,     0,     0,     0,   195,
-       0,   161,    63,    70,     0,    95,    11,     0,     0,   147,
-       0,   166,   168,   187,   186,   189,   167,   178,     0,     0,
-       0,    82,    61,   149,     0,   188,     0,     0,   177,   175,
-       0,     0,   162,     0,   190,     0,   167,     0,   164,   181,
-     163,     0,   191,   185,   176,   179,   183
</del><ins>+       0,     0,   130,   131,   132,     0,   114,   122,   145,   142,
+     143,   144,   149,   150,   151,   152,   153,   154,   146,   147,
+     148,   155,   156,   157,   158,   159,   160,   123,   124,   127,
+     115,   161,   162,   163,   164,   165,   166,     0,   112,   111,
+       0,   141,   167,   169,   182,   183,   170,   171,   172,   173,
+     174,   175,   176,   177,   178,   168,   179,   180,   181,     0,
+     185,   248,   249,     0,    83,    93,     0,    98,   103,   119,
+       0,   117,   109,     0,   120,   128,   139,   184,     0,   245,
+     247,   116,   108,     0,   125,   126,     2,     3,   188,     0,
+       0,    74,     0,    81,    93,   113,    94,    95,    96,    84,
+       0,    93,     0,    75,     2,   104,   118,     0,    80,     0,
+     110,   129,   121,     0,     1,   246,     0,     0,   186,   136,
+       0,   134,     0,   250,    85,    90,    92,    97,     0,    99,
+      86,     0,     0,    73,     0,     0,     0,     0,   190,     4,
+       8,     6,     7,     9,     0,     0,     0,    36,    35,    34,
+       5,    11,    30,    13,    18,    19,     0,     0,    24,     0,
+      37,     0,    40,    43,    44,    49,    52,    53,    54,    55,
+      57,    59,    61,    72,     0,    28,    76,     0,     0,     0,
+     133,     0,     0,     0,   230,     0,     0,     0,     0,     0,
+     208,   217,   221,    37,    63,    70,     0,   199,     0,   139,
+     202,   219,   201,   200,     0,   203,   204,   205,   206,    87,
+      89,    91,     0,     0,   105,     0,   198,   107,     0,   196,
+       0,   194,     0,   191,    31,    32,     0,    15,    16,     0,
+       0,    22,    21,     0,    23,    25,    27,    33,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,   140,   189,     0,   137,   138,   135,   241,   240,
+     215,   232,     0,   244,   242,     0,   228,   207,     0,    66,
+      67,    68,    69,    65,     0,     0,   222,   218,   220,     0,
+     100,     0,   102,   106,     0,     0,     0,   192,     0,    77,
+      10,     0,    17,     2,     3,    14,    20,    26,    38,    39,
+      42,    41,    47,    48,    45,    46,    50,    51,    56,    58,
+      60,     0,   187,     0,     0,     0,     0,     0,   243,     0,
+     209,    64,    71,     0,   101,   193,     0,   195,     0,    78,
+      12,     0,     0,   214,   216,   235,   234,   237,   215,   226,
+       0,     0,     0,     0,    88,   197,     0,    62,     0,   236,
+       0,     0,   225,   223,     0,     0,   210,     0,     0,   238,
+       0,   215,     0,   212,   229,   211,    79,     0,   239,   233,
+     224,   227,   231
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* YYDEFGOTO[NTERM-NUM].  */
</span><span class="cx"> static const yytype_int16 yydefgoto[] =
</span><span class="cx"> {
</span><del>-      -1,   196,   100,   101,   102,   229,   103,   104,   105,   106,
-     107,   108,   109,   142,   111,   112,   113,   114,   115,   116,
-     117,   118,   119,   120,   121,   122,   143,   144,   218,   145,
-     124,   146,   147,    34,    35,    36,    82,    64,    65,    83,
-      37,    38,    39,    40,    41,    42,    43,   125,    45,   130,
-      77,   128,   129,   197,   198,   166,   149,   150,   151,   152,
-     212,   280,   299,   254,   255,   256,   300,   153,   154,   155,
-     289,   279,   156,   260,   204,   257,   275,   286,   287,   157,
-      46,    47,    48,    57
</del><ins>+      -1,   219,   150,   151,   152,   291,   153,   154,   155,   156,
+     157,   158,   159,   193,   161,   162,   163,   164,   165,   166,
+     167,   168,   169,   170,   171,   172,   194,   195,   274,   196,
+     174,   109,   197,   198,    63,    64,    65,   125,    99,   100,
+     126,    66,    67,    68,    69,   101,    70,    71,    72,    73,
+      74,   120,   121,    75,   175,    77,   178,   117,   137,   138,
+     220,   221,   217,   200,   201,   202,   203,   268,   343,   364,
+     313,   314,   315,   365,   204,   205,   206,   353,   342,   207,
+     319,   260,   316,   337,   350,   351,   208,    78,    79,    80,
+      92
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
</span><span class="cx">    STATE-NUM.  */
</span><del>-#define YYPACT_NINF -261
</del><ins>+#define YYPACT_NINF -309
</ins><span class="cx"> static const yytype_int16 yypact[] =
</span><span class="cx"> {
</span><del>-    1327,   -20,  -261,  -261,  -261,   113,  -261,  -261,  -261,  -261,
-    -261,  -261,  -261,  -261,  -261,  -261,  -261,  -261,  -261,  -261,
-    -261,  -261,  -261,  -261,  -261,   -19,  -261,  -261,  -261,  -261,
-    -261,  -261,  -261,   -61,   -40,   -28,    75,    -7,  -261,    24,
-    1370,  -261,  1444,  -261,   -11,  -261,  1283,  -261,  -261,  -261,
-    -261,  1444,  -261,  -261,  -261,     6,  -261,    54,  -261,    88,
-      62,  -261,  -261,  -261,  -261,  1370,    59,    91,  -261,    36,
-     -50,  -261,  -261,  1051,  -261,  -261,    63,  1370,  -261,   293,
-    -261,  -261,  -261,  -261,    91,  1370,   -12,  -261,   856,  1051,
-      77,  -261,  -261,  -261,  1051,  1051,  1051,  -261,  -261,  -261,
-    -261,  -261,   -14,  -261,  -261,  -261,    84,   -44,  1116,    95,
-    -261,  1051,    53,     3,  -261,   -36,    89,  -261,  -261,  -261,
-     104,   107,   -45,  -261,    96,  -261,  -261,    91,  1184,  -261,
-    1370,    92,    93,  -261,    98,   101,    94,   921,   105,   102,
-    -261,  -261,    72,  -261,  -261,     9,  -261,   -61,    42,  -261,
-    -261,  -261,  -261,   376,  -261,  -261,  -261,  -261,   106,  -261,
-    -261,   986,  1051,  -261,   103,  -261,  -261,  -261,  -261,   -41,
-    -261,  -261,  1051,  1407,  -261,  -261,  1051,   110,  -261,  -261,
-    -261,  1051,  1051,  1051,  1051,  1051,  1051,  1051,  1051,  1051,
-    1051,  1051,  1051,  1051,  1051,  -261,   109,    23,  -261,  -261,
-    -261,  1227,  -261,  -261,   111,  -261,  1051,  -261,  -261,    25,
-    -261,  -261,   459,  -261,  -261,  -261,  -261,  -261,  1051,  1051,
-    -261,  -261,  -261,  1051,  -261,   114,  -261,  -261,  -261,   115,
-     112,    77,   116,  -261,  -261,  -261,  -261,  -261,    53,    53,
-    -261,  -261,  -261,  -261,   -36,   -36,  -261,   104,   107,    76,
-    1051,    91,  -261,  -261,   145,    54,   625,   708,    -6,  -261,
-     791,   459,  -261,  -261,   117,  -261,  -261,  1051,   120,  -261,
-     124,  -261,  -261,  -261,  -261,   791,   111,   112,    91,   125,
-     122,  -261,  -261,  -261,  1051,  -261,   118,   128,   180,  -261,
-     126,   542,  -261,    -5,  1051,   542,   111,  1051,  -261,  -261,
-    -261,   123,   112,  -261,  -261,  -261,  -261
</del><ins>+    2013,   -27,  -309,  -309,  -309,   154,  -309,  -309,  -309,  -309,
+    -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,
+    -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,
+    -309,  -309,  -309,  -309,  -309,  -309,  -309,    98,  -309,  -309,
+     -40,  -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,
+    -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,   -46,
+    -309,  -309,   -42,   -23,     8,     5,   -87,  -309,    91,    14,
+    1130,  -309,  -309,  2298,    14,  -309,    -1,  -309,  1938,  -309,
+    -309,  -309,  -309,  2298,  -309,  -309,  -309,  -309,  -309,    13,
+      47,  -309,    43,  -309,    39,  -309,  -309,  -309,  -309,  -309,
+    2162,   124,    94,  -309,    51,   -14,  -309,    66,  -309,  2088,
+    -309,  -309,  -309,  1491,  -309,  -309,    62,  2088,  -309,    48,
+     -83,  -309,   358,  -309,  -309,  -309,  -309,    94,  2162,    -9,
+    -309,  1200,  1491,  -309,   148,  2162,    94,  1683,  -309,    89,
+    -309,  -309,  -309,  -309,  1491,  1491,  1491,  -309,  -309,  -309,
+    -309,  -309,    10,  -309,  -309,  -309,    92,    20,  1586,    96,
+    -309,  1491,    53,   -76,  -309,   -62,    90,  -309,  -309,  -309,
+     104,   101,   -61,  -309,    95,  -309,  -309,  1768,  2088,   103,
+    -309,    47,    82,    84,  -309,    97,    99,    93,  1298,   105,
+     102,  -309,  -309,   -10,  -309,  -309,   -13,  -309,   -42,     2,
+    -309,  -309,  -309,  -309,   474,  -309,  -309,  -309,  -309,   106,
+    -309,  -309,  1393,  1491,  -309,   107,  -309,  -309,    94,   109,
+       4,  -309,   -58,  -309,  -309,  -309,    22,  -309,  -309,  1491,
+    2230,  -309,  -309,  1491,   112,  -309,  -309,  -309,  1491,  1491,
+    1491,  1491,  1491,  1491,  1491,  1491,  1491,  1491,  1491,  1491,
+    1491,  1491,  -309,  -309,  1853,  -309,  -309,  -309,  -309,  -309,
+     100,  -309,  1491,  -309,  -309,    36,  -309,  -309,   590,  -309,
+    -309,  -309,  -309,  -309,  1491,  1491,  -309,  -309,  -309,  1491,
+    -309,   113,  -309,  -309,    42,  1491,    94,  -309,   -73,  -309,
+    -309,   115,   108,    89,   119,  -309,  -309,  -309,  -309,  -309,
+      53,    53,  -309,  -309,  -309,  -309,   -62,   -62,  -309,   104,
+     101,    73,  -309,   169,    43,   822,   938,    25,  -309,  1035,
+     590,  -309,  -309,   120,  -309,  -309,   121,  -309,  1491,  -309,
+    -309,  1491,   122,  -309,  -309,  -309,  -309,  1035,   100,   108,
+      94,  2162,   125,   123,  -309,  -309,   126,  -309,  1491,  -309,
+     117,   129,   212,  -309,   139,   706,  -309,   141,    29,  1491,
+     706,   100,  1491,  -309,  -309,  -309,  -309,   142,   108,  -309,
+    -309,  -309,  -309
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* YYPGOTO[NTERM-NUM].  */
</span><span class="cx"> static const yytype_int16 yypgoto[] =
</span><span class="cx"> {
</span><del>-    -261,   -24,  -261,  -261,  -261,  -261,  -261,  -261,    34,  -261,
-    -261,  -261,  -261,    32,  -261,   -33,  -261,   -27,   -26,  -261,
-    -261,  -261,    14,    16,    18,  -261,   -66,   -87,  -261,   -92,
-     -85,    11,    12,  -261,  -261,  -261,   141,   150,   161,   143,
-    -261,  -261,  -231,     5,   -30,   224,   -18,     0,  -261,  -261,
-    -261,   100,  -119,  -261,   -17,  -156,   -25,  -145,  -243,  -261,
-    -261,  -261,   -64,  -260,  -261,  -261,   -52,    21,   -22,  -261,
-    -261,   -39,  -261,  -261,  -261,  -261,  -261,  -261,  -261,  -261,
-    -261,   191,  -261,  -261
</del><ins>+    -309,   -39,  -309,  -309,  -309,  -309,  -309,  -309,     7,  -309,
+    -309,  -309,  -309,     1,  -309,   -54,  -309,  -101,   -57,  -309,
+    -309,  -309,     9,   -11,     3,  -309,  -110,  -126,  -309,  -138,
+    -122,  -309,    11,    16,  -309,  -309,  -309,   130,   165,   159,
+     133,  -309,  -309,  -299,  -309,  -309,  -102,   -30,   -66,   257,
+    -309,  -309,    83,    -6,     0,  -309,  -309,  -309,  -104,  -125,
+      45,   -21,  -208,   -50,  -194,  -296,  -309,  -309,  -309,   -93,
+    -308,  -309,  -309,   -90,     6,   -47,  -309,  -309,   -67,  -309,
+    -309,  -309,  -309,  -309,  -309,  -309,  -309,  -309,   193,  -309,
+    -309
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
</span><span class="cx">    positive, shift that token.  If negative, reduce the rule which
</span><span class="cx">    number is the opposite.  If YYTABLE_NINF, syntax error.  */
</span><del>-#define YYTABLE_NINF -166
</del><ins>+#define YYTABLE_NINF -214
</ins><span class="cx"> static const yytype_int16 yytable[] =
</span><span class="cx"> {
</span><del>-      44,    55,   165,   164,   169,    80,   226,   123,   222,   200,
-      71,    32,    33,   272,   193,    70,   288,    49,   185,   186,
-      56,   178,   123,    88,    72,    50,    52,    53,   175,   278,
-      89,   228,    58,    76,   176,    84,   304,   219,   170,   171,
-      44,    66,    44,    86,   278,   209,    44,   127,   298,   194,
-      59,    44,   298,   187,   188,    84,    54,    32,    33,   172,
-     158,   161,    73,   173,    66,    44,   276,   301,   162,    69,
-      53,    67,   219,   219,    68,   165,   225,    44,    60,   148,
-     230,    78,   200,     6,     7,    44,   183,   219,   184,   235,
-     220,    60,    61,    62,    63,   123,     6,     7,   127,    49,
-     127,   251,   249,   219,   252,   110,   259,    87,    61,    62,
-      63,    23,    24,   -27,   258,    73,   222,     2,     3,     4,
-     110,    61,    62,    63,    23,    24,   167,   168,    44,    79,
-      44,   262,   263,   213,   214,   215,    52,    53,   264,   181,
-     182,   305,   216,   180,   126,   189,   190,   -76,   -28,   233,
-     238,   239,   217,   148,   219,   267,   174,   123,   240,   241,
-     242,   243,   191,   244,   245,   268,   179,   192,   277,   205,
-     195,   127,   206,   202,   203,   207,   210,   227,   211,   223,
-     282,  -117,   250,   277,   123,   270,  -165,  -138,   265,   266,
-     219,   281,   293,   110,   283,   284,   296,   291,   292,   294,
-     295,    44,   302,   271,   306,   246,   297,   234,   247,    81,
-     165,   248,   148,   236,   237,   110,   110,   110,   110,   110,
-     110,   110,   110,   110,   110,   110,   159,    85,   160,    51,
-     201,   303,   273,   261,   269,   274,   285,    75,     0,     0,
</del><ins>+      76,    89,   123,   173,   110,   282,   216,   135,   226,   215,
+     278,    61,   223,   177,    95,   135,    62,    81,   288,   334,
+     340,   173,   180,     7,   102,   242,   243,   103,   181,   105,
+     352,   250,   235,   328,   127,   135,    86,    87,   340,   106,
+     240,   329,   241,   136,   112,    96,    97,    98,    95,    82,
+     265,   136,   223,   370,    27,    28,   289,    29,    90,   363,
+     244,   245,   127,   129,   363,    37,   251,   111,    88,   218,
+      76,   136,    91,    76,   254,   135,   135,   116,    76,    96,
+      97,    98,    93,    76,   269,   270,   271,   216,   209,    61,
+     281,   292,   131,   272,    62,   227,   228,   212,   275,   132,
+      76,   276,   173,   273,   213,   113,   -28,   297,   113,    76,
+     -82,   136,   136,   311,   160,   286,   229,    76,   287,    94,
+     230,   118,   199,   119,   317,   232,   278,   290,    76,   223,
+     338,   233,   160,   275,   367,    76,   275,    76,    84,    85,
+     275,   302,   303,   304,   305,   224,   225,   275,   321,   322,
+     318,   122,   135,   286,   371,   130,   325,   323,     2,     3,
+       4,   179,   237,   326,    96,    97,    98,   104,    87,   173,
+      86,    87,   238,   239,   133,   173,   176,    76,    76,   246,
+     247,   339,   255,   256,   275,   331,   300,   301,   136,   306,
+     307,   295,    81,   -29,   249,   248,   258,   231,   259,   339,
+     236,   261,   252,   262,   199,   347,   346,   263,  -213,   266,
+     358,   267,   279,   160,   283,   285,  -141,   341,   173,   275,
+     324,   368,   330,  -185,   333,   332,   348,   344,   345,   361,
+     355,   359,   356,   357,   360,   341,   216,   296,   309,   298,
+     299,   160,   160,   160,   160,   160,   160,   160,   160,   160,
+     160,   160,   362,   310,    76,   366,   372,   308,   210,   124,
+     128,   211,    83,   284,   257,   327,   335,   369,   199,   336,
+     349,   115,     0,     0,   320,   110,     0,     0,     0,     0,
+     160,     0,     0,     0,     0,     0,   160,     0,     0,     0,
</ins><span class="cx">        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
</span><del>-       0,     0,     0,     0,   290,   110,   148,   148,     0,     0,
-     148,   148,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,   148,     0,     0,     0,     0,
-       0,     0,   110,     0,     0,     0,     0,     0,     0,     0,
-       0,   148,     0,     0,     0,   148,     1,     2,     3,     4,
-       5,     6,     7,     8,     9,    10,   131,   132,   133,     0,
-     134,   135,   136,   137,    11,    12,    13,    14,    15,    16,
-      17,    18,    19,    20,    21,    22,     0,     0,     0,    23,
-      24,    25,    26,   138,    27,    28,    29,    30,    90,    31,
-      91,    92,    93,     0,     0,    94,    95,     0,     0,     0,
</del><ins>+       0,   354,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,   199,   199,     0,     0,   199,
+     199,     0,     0,     0,     0,     0,     0,     0,     0,   160,
+       0,     0,     0,     0,     0,     0,     0,   199,     0,     0,
+       0,    76,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,   199,     0,     0,     0,     0,
+     199,     1,     2,     3,     4,     5,     6,     7,     8,     9,
+      10,    11,   182,   183,   184,     0,   185,   186,   187,   188,
+       0,     0,     0,    12,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
+       0,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    40,    41,   189,    42,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,     0,
+      56,    57,    58,    59,   139,    60,   140,   141,   142,   143,
+       0,     0,     0,   144,   145,     0,     0,     0,     0,     0,
</ins><span class="cx">        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
</span><del>-       0,     0,     0,     0,    96,     0,     0,     0,   139,   140,
-       0,     0,     0,     0,   141,    97,    98,     0,    99,     1,
-       2,     3,     4,     5,     6,     7,     8,     9,    10,   131,
-     132,   133,     0,   134,   135,   136,   137,    11,    12,    13,
-      14,    15,    16,    17,    18,    19,    20,    21,    22,     0,
-       0,     0,    23,    24,    25,    26,   138,    27,    28,    29,
-      30,    90,    31,    91,    92,    93,     0,     0,    94,    95,
</del><ins>+       0,     0,   146,     0,     0,     0,   190,   191,     0,     0,
+       0,     0,   192,   147,   148,     0,   149,     1,     2,     3,
+       4,     5,     6,     7,     8,     9,    10,    11,   182,   183,
+     184,     0,   185,   186,   187,   188,     0,     0,     0,    12,
+      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
+      23,    24,    25,    26,    27,    28,     0,    29,    30,    31,
+      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
+     189,    42,    43,    44,    45,    46,    47,    48,    49,    50,
+      51,    52,    53,    54,    55,     0,    56,    57,    58,    59,
+     139,    60,   140,   141,   142,   143,     0,     0,     0,   144,
+     145,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,   146,     0,
+       0,     0,   190,   277,     0,     0,     0,     0,   192,   147,
+     148,     0,   149,     1,     2,     3,     4,     5,     6,     7,
+       8,     9,    10,    11,   182,   183,   184,     0,   185,   186,
+     187,   188,     0,     0,     0,    12,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
+      27,    28,     0,    29,    30,    31,    32,    33,    34,    35,
+      36,    37,    38,    39,    40,    41,   189,    42,    43,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,     0,    56,    57,    58,    59,   139,    60,   140,   141,
+     142,   143,     0,     0,     0,   144,   145,     0,     0,     0,
</ins><span class="cx">        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
</span><del>-       0,     0,     0,     0,     0,     0,     0,    96,     0,     0,
-       0,   139,   221,     0,     0,     0,     0,   141,    97,    98,
-       0,    99,     1,     2,     3,     4,     5,     6,     7,     8,
-       9,    10,   131,   132,   133,     0,   134,   135,   136,   137,
-      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
-      21,    22,     0,     0,     0,    23,    24,    25,    26,   138,
-      27,    28,    29,    30,    90,    31,    91,    92,    93,     0,
-       0,    94,    95,     0,     0,     0,     0,     0,     0,     0,
</del><ins>+       0,     0,     0,     0,   146,     0,     0,     0,   190,     0,
+       0,     0,     0,     0,   192,   147,   148,     0,   149,     1,
+       2,     3,     4,     5,     6,     7,     8,     9,    10,    11,
+     182,   183,   184,     0,   185,   186,   187,   188,     0,     0,
+       0,    12,    13,    14,    15,    16,    17,    18,    19,    20,
+      21,    22,    23,    24,    25,    26,    27,    28,     0,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      40,    41,   189,    42,    43,    44,    45,    46,    47,    48,
+      49,    50,    51,    52,    53,    54,    55,     0,    56,    57,
+      58,    59,   139,    60,   140,   141,   142,   143,     0,     0,
+       0,   144,   145,     0,     0,     0,     0,     0,     0,     0,
</ins><span class="cx">        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
</span><del>-      96,     0,     0,     0,   139,     0,     0,     0,     0,     0,
-     141,    97,    98,     0,    99,     1,     2,     3,     4,     5,
-       6,     7,     8,     9,    10,   131,   132,   133,     0,   134,
-     135,   136,   137,    11,    12,    13,    14,    15,    16,    17,
-      18,    19,    20,    21,    22,     0,     0,     0,    23,    24,
-      25,    26,   138,    27,    28,    29,    30,    90,    31,    91,
-      92,    93,     0,     0,    94,    95,     0,     0,     0,     0,
</del><ins>+     146,     0,     0,     0,   122,     0,     0,     0,     0,     0,
+     192,   147,   148,     0,   149,     1,     2,     3,     4,     5,
+       6,     7,     8,     9,    10,    11,   182,   183,   184,     0,
+     185,   186,   187,   188,     0,     0,     0,    12,    13,    14,
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+      25,    26,    27,    28,     0,    29,    30,    31,    32,    33,
+      34,    35,    36,    37,    38,    39,    40,    41,   189,    42,
+      43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
+      53,    54,    55,     0,    56,    57,    58,    59,   139,    60,
+     140,   141,   142,   143,     0,     0,     0,   144,   145,     0,
</ins><span class="cx">        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
</span><del>-       0,     0,     0,    96,     0,     0,     0,    79,     0,     0,
-       0,     0,     0,   141,    97,    98,     0,    99,     1,     2,
-       3,     4,     5,     6,     7,     8,     9,    10,   131,   132,
-     133,     0,   134,   135,   136,   137,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    20,    21,    22,     0,     0,
-       0,    23,    24,    25,    26,   138,    27,    28,    29,    30,
-      90,    31,    91,    92,    93,     0,     0,    94,    95,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,    96,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,   141,    97,    98,     0,
-      99,     1,     2,     3,     4,     5,     6,     7,     8,     9,
-      10,     0,     0,     0,     0,     0,     0,     0,     0,    11,
</del><ins>+       0,     0,     0,     0,     0,     0,   146,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,   192,   147,   148,     0,
+     149,     1,     2,     3,     4,     5,     6,     7,     8,     9,
+      10,    11,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,    12,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
+       0,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    40,    41,     0,    42,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,     0,
+      56,    57,    58,    59,   139,    60,   140,   141,   142,   143,
+       0,     0,     0,   144,   145,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,   134,     2,
+       3,     4,   146,     6,     7,     8,     9,    10,    11,     0,
+       0,     0,   192,   147,   148,     0,   149,     0,     0,     0,
</ins><span class="cx">       12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
</span><del>-      22,     0,     0,     0,    23,    24,    25,    26,     0,    27,
-      28,    29,    30,    90,    31,    91,    92,    93,     0,     0,
-      94,    95,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    96,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,   141,
-      97,    98,     0,    99,    60,     2,     3,     4,     0,     6,
-       7,     8,     9,    10,     0,     0,     0,     0,     0,     0,
-       0,     0,    11,    12,    13,    14,    15,    16,    17,    18,
-      19,    20,    21,    22,     0,     0,     0,    23,    24,    25,
-      26,     0,    27,    28,    29,    30,    90,    31,    91,    92,
-      93,     0,     0,    94,    95,     0,     0,     0,     0,     0,
</del><ins>+      22,    23,    24,    25,    26,    27,    28,     0,    29,    30,
+      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
+      41,     0,    42,    43,    44,    45,    46,    47,    48,    49,
+      50,    51,    52,    53,    54,    55,     0,    56,    57,    58,
+      59,   139,    60,   140,   141,   142,   143,     0,     0,     0,
+     144,   145,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     2,     3,     4,     0,     0,   146,
+       8,     9,    10,    11,     0,     0,     0,     0,     0,     0,
+     147,   148,     0,   149,     0,    12,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
+       0,     0,     0,     0,     0,    31,    32,    33,    34,    35,
+      36,     0,     0,     0,    40,    41,     0,    42,    43,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,     0,    56,    57,    58,     0,   107,    60,     0,     0,
+       8,     9,    10,    11,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,    12,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
+       0,     0,     0,     0,   108,    31,    32,    33,    34,    35,
+      36,     0,     0,     0,    40,    41,     0,    42,    43,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,     0,    56,    57,    58,     0,   139,    60,   140,   141,
+     142,   143,     0,     0,     0,   144,   145,     0,     0,     0,
</ins><span class="cx">        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
</span><del>-       0,     0,    96,     0,     0,     0,     8,     9,    10,     0,
-       0,     0,     0,    97,    98,     0,    99,    11,    12,    13,
-      14,    15,    16,    17,    18,    19,    20,    21,    22,     0,
-       0,     0,     0,     0,    25,    26,     0,    27,    28,    29,
-      30,    90,    31,    91,    92,    93,     0,     0,    94,    95,
</del><ins>+       0,     0,     0,     0,   146,     0,     0,   214,     8,     9,
+      10,    11,     0,     0,     0,   147,   148,     0,   149,     0,
+       0,     0,     0,    12,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,    25,    26,     0,     0,
+       0,     0,     0,    31,    32,    33,    34,    35,    36,     0,
+       0,     0,    40,    41,     0,    42,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,     0,
+      56,    57,    58,     0,   139,    60,   140,   141,   142,   143,
+       0,     0,     0,   144,   145,     0,     0,     0,     0,     0,
</ins><span class="cx">        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
</span><del>-       0,     0,     0,     0,     0,     0,     0,    96,     0,     0,
-     163,     8,     9,    10,     0,     0,     0,     0,    97,    98,
-       0,    99,    11,    12,    13,    14,    15,    16,    17,    18,
-      19,    20,    21,    22,     0,     0,     0,     0,     0,    25,
-      26,     0,    27,    28,    29,    30,    90,    31,    91,    92,
-      93,     0,     0,    94,    95,     0,     0,     0,     0,     0,
</del><ins>+       0,     0,   146,     8,     9,    10,    11,     0,     0,     0,
+       0,     0,   264,   147,   148,     0,   149,     0,    12,    13,
+      14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
+      24,    25,    26,     0,     0,     0,     0,     0,    31,    32,
+      33,    34,    35,    36,     0,     0,     0,    40,    41,     0,
+      42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,     0,    56,    57,    58,     0,   139,
+      60,   140,   141,   142,   143,     0,     0,     0,   144,   145,
</ins><span class="cx">        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
</span><del>-       0,     0,    96,     0,     0,     0,     8,     9,    10,     0,
-       0,     0,   208,    97,    98,     0,    99,    11,    12,    13,
-      14,    15,    16,    17,    18,    19,    20,    21,    22,     0,
-       0,     0,     0,     0,    25,    26,     0,    27,    28,    29,
-      30,    90,    31,    91,    92,    93,     0,     0,    94,    95,
</del><ins>+       0,     0,     0,     0,     0,     0,     0,   146,     0,     0,
+     280,     8,     9,    10,    11,     0,     0,     0,   147,   148,
+       0,   149,     0,     0,     0,     0,    12,    13,    14,    15,
+      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
+      26,     0,     0,     0,     0,     0,    31,    32,    33,    34,
+      35,    36,     0,     0,     0,    40,    41,     0,    42,    43,
+      44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
+      54,    55,     0,    56,    57,    58,     0,   139,    60,   140,
+     141,   142,   143,     0,     0,     0,   144,   145,     0,     0,
</ins><span class="cx">        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
</span><del>-       0,     0,     0,     0,     0,     0,     0,    96,     0,     0,
-     224,     8,     9,    10,     0,     0,     0,     0,    97,    98,
-       0,    99,    11,    12,    13,    14,    15,    16,    17,    18,
-      19,    20,    21,    22,     0,     0,     0,     0,     0,    25,
-      26,     0,    27,    28,    29,    30,    90,    31,    91,    92,
-      93,     0,     0,    94,    95,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,    96,     0,     0,     0,     8,     9,    10,     0,
-       0,     0,     0,    97,    98,     0,    99,    11,    12,    13,
-      14,    15,    16,    17,    18,    19,    20,    21,    22,     0,
-       0,     0,     0,     0,    25,   177,     0,    27,    28,    29,
-      30,    90,    31,    91,    92,    93,     0,     0,    94,    95,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,    96,     2,     3,
-       4,     0,     0,     0,     8,     9,    10,     0,    97,    98,
-       0,    99,     0,     0,     0,    11,    12,    13,    14,    15,
-      16,    17,    18,    19,    20,    21,    22,     0,     0,     0,
-       0,     0,    25,    26,     0,    27,    28,    29,    30,     0,
-      31,     2,     3,     4,     0,     0,     0,     8,     9,    10,
-       0,     0,     0,     0,     0,     0,     0,     0,    11,    12,
-      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
-     199,     0,     0,     0,     0,    25,    26,     0,    27,    28,
-      29,    30,     0,    31,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,    74,     0,     0,     1,     2,     3,     4,
-       5,     6,     7,     8,     9,    10,     0,     0,     0,     0,
-       0,     0,     0,   253,    11,    12,    13,    14,    15,    16,
-      17,    18,    19,    20,    21,    22,     0,     0,     0,    23,
-      24,    25,    26,     0,    27,    28,    29,    30,     0,    31,
-       1,     2,     3,     4,     5,     6,     7,     8,     9,    10,
-       0,     0,     0,     0,     0,     0,     0,     0,    11,    12,
-      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
-       0,     0,     0,    23,    24,    25,    26,     0,    27,    28,
-      29,    30,     0,    31,     2,     3,     4,     0,     0,     0,
-       8,     9,    10,     0,     0,     0,     0,     0,     0,     0,
-       0,    11,    12,    13,    14,    15,    16,    17,    18,    19,
-      20,    21,    22,     0,     0,     0,     0,     0,    25,    26,
-       0,    27,    28,    29,    30,     0,    31,     8,     9,    10,
-       0,     0,     0,     0,     0,     0,     0,     0,    11,    12,
-      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
-       0,     0,     0,     0,     0,    25,    26,     0,    27,    28,
-      29,    30,   231,   232,     8,     9,    10,     0,     0,     0,
-       0,     0,     0,     0,     0,    11,    12,    13,    14,    15,
-      16,    17,    18,    19,    20,    21,    22,     0,     0,     0,
-       0,     0,    25,    26,     0,    27,    28,    29,    30,     0,
-      31
</del><ins>+       0,     0,     0,     0,     0,   146,     8,     9,    10,    11,
+       0,     0,     0,     0,     0,     0,   147,   148,     0,   149,
+       0,    12,    13,    14,    15,    16,    17,    18,    19,    20,
+      21,    22,    23,    24,    25,    26,     0,     0,     0,     0,
+       0,    31,    32,    33,    34,    35,    36,     0,     0,     0,
+      40,   234,     0,    42,    43,    44,    45,    46,    47,    48,
+      49,    50,    51,    52,    53,    54,    55,     0,    56,    57,
+      58,     0,   139,    60,   140,   141,   142,   143,     0,     0,
+       0,   144,   145,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,   134,     2,     3,     4,
+     146,     6,     7,     8,     9,    10,    11,     0,     0,     0,
+       0,   147,   148,     0,   149,     0,     0,     0,    12,    13,
+      14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
+      24,    25,    26,    27,    28,     0,    29,    30,    31,    32,
+      33,    34,    35,    36,    37,    38,    39,    40,    41,     0,
+      42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,     0,    56,    57,    58,    59,     0,
+      60,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,   134,     2,     3,     4,     0,     6,     7,     8,     9,
+      10,    11,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,   222,    12,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
+       0,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    40,    41,     0,    42,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,     0,
+      56,    57,    58,    59,     0,    60,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,   134,     2,     3,     4,
+       0,     6,     7,     8,     9,    10,    11,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,   253,    12,    13,
+      14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
+      24,    25,    26,    27,    28,     0,    29,    30,    31,    32,
+      33,    34,    35,    36,    37,    38,    39,    40,    41,     0,
+      42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,     0,    56,    57,    58,    59,     0,
+      60,     0,     0,     0,     0,     0,     0,     0,   114,     0,
+       0,     1,     2,     3,     4,     5,     6,     7,     8,     9,
+      10,    11,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,   312,    12,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
+       0,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    40,    41,     0,    42,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,     0,
+      56,    57,    58,    59,     0,    60,     1,     2,     3,     4,
+       5,     6,     7,     8,     9,    10,    11,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,    12,    13,
+      14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
+      24,    25,    26,    27,    28,     0,    29,    30,    31,    32,
+      33,    34,    35,    36,    37,    38,    39,    40,    41,     0,
+      42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,     0,    56,    57,    58,    59,     0,
+      60,   134,     2,     3,     4,     0,     6,     7,     8,     9,
+      10,    11,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,    12,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
+       0,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    40,    41,     0,    42,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,     0,
+      56,    57,    58,    59,     0,    60,     2,     3,     4,     0,
+       0,     0,     8,     9,    10,    11,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,    12,    13,    14,
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+      25,    26,     0,     0,     0,     0,     0,    31,    32,    33,
+      34,    35,    36,     0,     0,     0,    40,    41,     0,    42,
+      43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
+      53,    54,    55,     0,    56,    57,    58,     0,     0,    60,
+       8,     9,    10,    11,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,    12,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
+       0,     0,     0,     0,     0,    31,    32,    33,    34,    35,
+      36,     0,     0,     0,    40,    41,     0,    42,    43,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,     0,    56,    57,    58,     0,   293,   294,     8,     9,
+      10,    11,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,    12,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,    25,    26,     0,     0,
+       0,     0,     0,    31,    32,    33,    34,    35,    36,     0,
+       0,     0,    40,    41,     0,    42,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,     0,
+      56,    57,    58,     0,     0,    60
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #define yypact_value_is_default(Yystate) \
</span><del>-  (!!((Yystate) == (-261)))
</del><ins>+  (!!((Yystate) == (-309)))
</ins><span class="cx"> 
</span><span class="cx"> #define yytable_value_is_error(Yytable_value) \
</span><span class="cx">   YYID (0)
</span><span class="cx"> 
</span><span class="cx"> static const yytype_int16 yycheck[] =
</span><span class="cx"> {
</span><del>-       0,    25,    89,    88,    96,    57,   162,    73,   153,   128,
-      40,     0,     0,   256,    59,    39,   276,    37,    54,    55,
-      81,   108,    88,    73,    42,    45,    45,    46,    72,   260,
-      80,    72,    72,    51,    78,    65,   296,    78,    52,    53,
-      40,    36,    42,    67,   275,   137,    46,    77,   291,    94,
-      78,    51,   295,    89,    90,    85,    75,    46,    46,    73,
-      84,    73,    73,    77,    59,    65,    72,    72,    80,    45,
-      46,    78,    78,    78,    81,   162,   161,    77,     3,    79,
-     172,    75,   201,     8,     9,    85,    83,    78,    85,   176,
-      81,     3,    33,    34,    35,   161,     8,     9,   128,    37,
-     130,    78,   194,    78,    81,    73,    81,    71,    33,    34,
-      35,    36,    37,    71,   206,    73,   261,     4,     5,     6,
-      88,    33,    34,    35,    36,    37,    94,    95,   128,    75,
-     130,   218,   219,    61,    62,    63,    45,    46,   223,    86,
-      87,   297,    70,   111,    81,    56,    57,    72,    71,   173,
-     183,   184,    80,   153,    78,    79,    72,   223,   185,   186,
-     187,   188,    58,   189,   190,   250,    71,    60,   260,    71,
-      74,   201,    71,    81,    81,    81,    71,    74,    76,    73,
-     267,    71,    73,   275,   250,    40,    75,    71,    74,    74,
-      78,    74,   284,   161,    74,    71,    16,    72,    76,    81,
-      72,   201,   294,   255,    81,   191,    80,   173,   192,    59,
-     297,   193,   212,   181,   182,   183,   184,   185,   186,   187,
-     188,   189,   190,   191,   192,   193,    85,    66,    85,     5,
-     130,   295,   257,   212,   251,   257,   275,    46,    -1,    -1,
</del><ins>+       0,    40,    92,   113,    70,   213,   132,   109,   146,   131,
+     204,     0,   137,   117,     9,   117,     0,    44,    76,   315,
+     319,   131,   105,     9,   111,    87,    88,   114,   111,    68,
+     338,    92,   158,   106,   100,   137,    76,    77,   337,    69,
+     116,   114,   118,   109,    74,    40,    41,    42,     9,    76,
+     188,   117,   177,   361,    40,    41,   114,    43,   104,   355,
+     122,   123,   128,   102,   360,    51,   127,    73,   108,   135,
+      70,   137,   114,    73,   178,   177,   178,    83,    78,    40,
+      41,    42,   105,    83,    94,    95,    96,   213,   127,    78,
+     212,   229,   106,   103,    78,    85,    86,   106,   111,   113,
+     100,   114,   212,   113,   113,   106,   104,   233,   106,   109,
+     105,   177,   178,   251,   113,   111,   106,   117,   114,   111,
+     110,   108,   122,    76,   262,   105,   320,   105,   128,   254,
+     105,   111,   131,   111,   105,   135,   111,   137,    40,    41,
+     111,   242,   243,   244,   245,   144,   145,   111,   274,   275,
+     114,   108,   254,   111,   362,   104,   114,   279,     4,     5,
+       6,   113,   161,   285,    40,    41,    42,    76,    77,   279,
+      76,    77,   119,   120,   108,   285,   114,   177,   178,    89,
+      90,   319,    79,    80,   111,   112,   240,   241,   254,   246,
+     247,   230,    44,   104,    93,    91,   114,   105,   114,   337,
+     104,   104,   107,   104,   204,   331,   328,   114,   108,   104,
+     348,   109,   106,   212,   107,   106,   104,   319,   328,   111,
+     107,   359,   107,   104,   314,    56,   104,   107,   107,    17,
+     105,   114,   109,   107,   105,   337,   362,   230,   249,   238,
+     239,   240,   241,   242,   243,   244,   245,   246,   247,   248,
+     249,   250,   113,   250,   254,   114,   114,   248,   128,    94,
+     101,   128,     5,   218,   181,   286,   316,   360,   268,   316,
+     337,    78,    -1,    -1,   268,   341,    -1,    -1,    -1,    -1,
+     279,    -1,    -1,    -1,    -1,    -1,   285,    -1,    -1,    -1,
</ins><span class="cx">       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</span><del>-      -1,    -1,    -1,    -1,   278,   223,   256,   257,    -1,    -1,
-     260,   261,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,   275,    -1,    -1,    -1,    -1,
-      -1,    -1,   250,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,   291,    -1,    -1,    -1,   295,     3,     4,     5,     6,
-       7,     8,     9,    10,    11,    12,    13,    14,    15,    -1,
-      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
-      27,    28,    29,    30,    31,    32,    -1,    -1,    -1,    36,
-      37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
-      47,    48,    49,    -1,    -1,    52,    53,    -1,    -1,    -1,
</del><ins>+      -1,   340,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,   315,   316,    -1,    -1,   319,
+     320,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   328,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,   337,    -1,    -1,
+      -1,   341,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,   355,    -1,    -1,    -1,    -1,
+     360,     3,     4,     5,     6,     7,     8,     9,    10,    11,
+      12,    13,    14,    15,    16,    -1,    18,    19,    20,    21,
+      -1,    -1,    -1,    25,    26,    27,    28,    29,    30,    31,
+      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
+      -1,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,    56,    57,    58,    59,    60,    61,
+      62,    63,    64,    65,    66,    67,    68,    69,    70,    -1,
+      72,    73,    74,    75,    76,    77,    78,    79,    80,    81,
+      -1,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,
</ins><span class="cx">       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</span><del>-      -1,    -1,    -1,    -1,    71,    -1,    -1,    -1,    75,    76,
-      -1,    -1,    -1,    -1,    81,    82,    83,    -1,    85,     3,
</del><ins>+      -1,    -1,   104,    -1,    -1,    -1,   108,   109,    -1,    -1,
+      -1,    -1,   114,   115,   116,    -1,   118,     3,     4,     5,
+       6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
+      16,    -1,    18,    19,    20,    21,    -1,    -1,    -1,    25,
+      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
+      36,    37,    38,    39,    40,    41,    -1,    43,    44,    45,
+      46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
+      56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
+      66,    67,    68,    69,    70,    -1,    72,    73,    74,    75,
+      76,    77,    78,    79,    80,    81,    -1,    -1,    -1,    85,
+      86,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   104,    -1,
+      -1,    -1,   108,   109,    -1,    -1,    -1,    -1,   114,   115,
+     116,    -1,   118,     3,     4,     5,     6,     7,     8,     9,
+      10,    11,    12,    13,    14,    15,    16,    -1,    18,    19,
+      20,    21,    -1,    -1,    -1,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      40,    41,    -1,    43,    44,    45,    46,    47,    48,    49,
+      50,    51,    52,    53,    54,    55,    56,    57,    58,    59,
+      60,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+      70,    -1,    72,    73,    74,    75,    76,    77,    78,    79,
+      80,    81,    -1,    -1,    -1,    85,    86,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,   104,    -1,    -1,    -1,   108,    -1,
+      -1,    -1,    -1,    -1,   114,   115,   116,    -1,   118,     3,
</ins><span class="cx">        4,     5,     6,     7,     8,     9,    10,    11,    12,    13,
</span><del>-      14,    15,    -1,    17,    18,    19,    20,    21,    22,    23,
-      24,    25,    26,    27,    28,    29,    30,    31,    32,    -1,
-      -1,    -1,    36,    37,    38,    39,    40,    41,    42,    43,
-      44,    45,    46,    47,    48,    49,    -1,    -1,    52,    53,
</del><ins>+      14,    15,    16,    -1,    18,    19,    20,    21,    -1,    -1,
+      -1,    25,    26,    27,    28,    29,    30,    31,    32,    33,
+      34,    35,    36,    37,    38,    39,    40,    41,    -1,    43,
+      44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
+      54,    55,    56,    57,    58,    59,    60,    61,    62,    63,
+      64,    65,    66,    67,    68,    69,    70,    -1,    72,    73,
+      74,    75,    76,    77,    78,    79,    80,    81,    -1,    -1,
+      -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</ins><span class="cx">       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</span><del>-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    71,    -1,    -1,
-      -1,    75,    76,    -1,    -1,    -1,    -1,    81,    82,    83,
-      -1,    85,     3,     4,     5,     6,     7,     8,     9,    10,
-      11,    12,    13,    14,    15,    -1,    17,    18,    19,    20,
-      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
-      31,    32,    -1,    -1,    -1,    36,    37,    38,    39,    40,
-      41,    42,    43,    44,    45,    46,    47,    48,    49,    -1,
-      -1,    52,    53,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</del><ins>+     104,    -1,    -1,    -1,   108,    -1,    -1,    -1,    -1,    -1,
+     114,   115,   116,    -1,   118,     3,     4,     5,     6,     7,
+       8,     9,    10,    11,    12,    13,    14,    15,    16,    -1,
+      18,    19,    20,    21,    -1,    -1,    -1,    25,    26,    27,
+      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    40,    41,    -1,    43,    44,    45,    46,    47,
+      48,    49,    50,    51,    52,    53,    54,    55,    56,    57,
+      58,    59,    60,    61,    62,    63,    64,    65,    66,    67,
+      68,    69,    70,    -1,    72,    73,    74,    75,    76,    77,
+      78,    79,    80,    81,    -1,    -1,    -1,    85,    86,    -1,
</ins><span class="cx">       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</span><del>-      71,    -1,    -1,    -1,    75,    -1,    -1,    -1,    -1,    -1,
-      81,    82,    83,    -1,    85,     3,     4,     5,     6,     7,
-       8,     9,    10,    11,    12,    13,    14,    15,    -1,    17,
-      18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
-      28,    29,    30,    31,    32,    -1,    -1,    -1,    36,    37,
-      38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
-      48,    49,    -1,    -1,    52,    53,    -1,    -1,    -1,    -1,
</del><ins>+      -1,    -1,    -1,    -1,    -1,    -1,   104,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,   114,   115,   116,    -1,
+     118,     3,     4,     5,     6,     7,     8,     9,    10,    11,
+      12,    13,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    25,    26,    27,    28,    29,    30,    31,
+      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
+      -1,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,    -1,    57,    58,    59,    60,    61,
+      62,    63,    64,    65,    66,    67,    68,    69,    70,    -1,
+      72,    73,    74,    75,    76,    77,    78,    79,    80,    81,
+      -1,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     3,     4,
+       5,     6,   104,     8,     9,    10,    11,    12,    13,    -1,
+      -1,    -1,   114,   115,   116,    -1,   118,    -1,    -1,    -1,
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+      35,    36,    37,    38,    39,    40,    41,    -1,    43,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,    -1,    57,    58,    59,    60,    61,    62,    63,    64,
+      65,    66,    67,    68,    69,    70,    -1,    72,    73,    74,
+      75,    76,    77,    78,    79,    80,    81,    -1,    -1,    -1,
+      85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,     4,     5,     6,    -1,    -1,   104,
+      10,    11,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,
+     115,   116,    -1,   118,    -1,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      -1,    -1,    -1,    -1,    -1,    45,    46,    47,    48,    49,
+      50,    -1,    -1,    -1,    54,    55,    -1,    57,    58,    59,
+      60,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+      70,    -1,    72,    73,    74,    -1,    76,    77,    -1,    -1,
+      10,    11,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      -1,    -1,    -1,    -1,   114,    45,    46,    47,    48,    49,
+      50,    -1,    -1,    -1,    54,    55,    -1,    57,    58,    59,
+      60,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+      70,    -1,    72,    73,    74,    -1,    76,    77,    78,    79,
+      80,    81,    -1,    -1,    -1,    85,    86,    -1,    -1,    -1,
</ins><span class="cx">       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</span><del>-      -1,    -1,    -1,    71,    -1,    -1,    -1,    75,    -1,    -1,
-      -1,    -1,    -1,    81,    82,    83,    -1,    85,     3,     4,
-       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    -1,    17,    18,    19,    20,    21,    22,    23,    24,
-      25,    26,    27,    28,    29,    30,    31,    32,    -1,    -1,
-      -1,    36,    37,    38,    39,    40,    41,    42,    43,    44,
-      45,    46,    47,    48,    49,    -1,    -1,    52,    53,    -1,
</del><ins>+      -1,    -1,    -1,    -1,   104,    -1,    -1,   107,    10,    11,
+      12,    13,    -1,    -1,    -1,   115,   116,    -1,   118,    -1,
+      -1,    -1,    -1,    25,    26,    27,    28,    29,    30,    31,
+      32,    33,    34,    35,    36,    37,    38,    39,    -1,    -1,
+      -1,    -1,    -1,    45,    46,    47,    48,    49,    50,    -1,
+      -1,    -1,    54,    55,    -1,    57,    58,    59,    60,    61,
+      62,    63,    64,    65,    66,    67,    68,    69,    70,    -1,
+      72,    73,    74,    -1,    76,    77,    78,    79,    80,    81,
+      -1,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,
</ins><span class="cx">       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</span><del>-      -1,    -1,    -1,    -1,    -1,    -1,    71,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    81,    82,    83,    -1,
-      85,     3,     4,     5,     6,     7,     8,     9,    10,    11,
-      12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    21,
-      22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
-      32,    -1,    -1,    -1,    36,    37,    38,    39,    -1,    41,
-      42,    43,    44,    45,    46,    47,    48,    49,    -1,    -1,
-      52,    53,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    71,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,
-      82,    83,    -1,    85,     3,     4,     5,     6,    -1,     8,
-       9,    10,    11,    12,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    21,    22,    23,    24,    25,    26,    27,    28,
-      29,    30,    31,    32,    -1,    -1,    -1,    36,    37,    38,
-      39,    -1,    41,    42,    43,    44,    45,    46,    47,    48,
-      49,    -1,    -1,    52,    53,    -1,    -1,    -1,    -1,    -1,
</del><ins>+      -1,    -1,   104,    10,    11,    12,    13,    -1,    -1,    -1,
+      -1,    -1,   114,   115,   116,    -1,   118,    -1,    25,    26,
+      27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
+      37,    38,    39,    -1,    -1,    -1,    -1,    -1,    45,    46,
+      47,    48,    49,    50,    -1,    -1,    -1,    54,    55,    -1,
+      57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
+      67,    68,    69,    70,    -1,    72,    73,    74,    -1,    76,
+      77,    78,    79,    80,    81,    -1,    -1,    -1,    85,    86,
</ins><span class="cx">       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</span><del>-      -1,    -1,    71,    -1,    -1,    -1,    10,    11,    12,    -1,
-      -1,    -1,    -1,    82,    83,    -1,    85,    21,    22,    23,
-      24,    25,    26,    27,    28,    29,    30,    31,    32,    -1,
-      -1,    -1,    -1,    -1,    38,    39,    -1,    41,    42,    43,
-      44,    45,    46,    47,    48,    49,    -1,    -1,    52,    53,
</del><ins>+      -1,    -1,    -1,    -1,    -1,    -1,    -1,   104,    -1,    -1,
+     107,    10,    11,    12,    13,    -1,    -1,    -1,   115,   116,
+      -1,   118,    -1,    -1,    -1,    -1,    25,    26,    27,    28,
+      29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
+      39,    -1,    -1,    -1,    -1,    -1,    45,    46,    47,    48,
+      49,    50,    -1,    -1,    -1,    54,    55,    -1,    57,    58,
+      59,    60,    61,    62,    63,    64,    65,    66,    67,    68,
+      69,    70,    -1,    72,    73,    74,    -1,    76,    77,    78,
+      79,    80,    81,    -1,    -1,    -1,    85,    86,    -1,    -1,
</ins><span class="cx">       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
</span><del>-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    71,    -1,    -1,
-      74,    10,    11,    12,    -1,    -1,    -1,    -1,    82,    83,
-      -1,    85,    21,    22,    23,    24,    25,    26,    27,    28,
-      29,    30,    31,    32,    -1,    -1,    -1,    -1,    -1,    38,
-      39,    -1,    41,    42,    43,    44,    45,    46,    47,    48,
-      49,    -1,    -1,    52,    53,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    71,    -1,    -1,    -1,    10,    11,    12,    -1,
-      -1,    -1,    81,    82,    83,    -1,    85,    21,    22,    23,
-      24,    25,    26,    27,    28,    29,    30,    31,    32,    -1,
-      -1,    -1,    -1,    -1,    38,    39,    -1,    41,    42,    43,
-      44,    45,    46,    47,    48,    49,    -1,    -1,    52,    53,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    71,    -1,    -1,
-      74,    10,    11,    12,    -1,    -1,    -1,    -1,    82,    83,
-      -1,    85,    21,    22,    23,    24,    25,    26,    27,    28,
-      29,    30,    31,    32,    -1,    -1,    -1,    -1,    -1,    38,
-      39,    -1,    41,    42,    43,    44,    45,    46,    47,    48,
-      49,    -1,    -1,    52,    53,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    71,    -1,    -1,    -1,    10,    11,    12,    -1,
-      -1,    -1,    -1,    82,    83,    -1,    85,    21,    22,    23,
-      24,    25,    26,    27,    28,    29,    30,    31,    32,    -1,
-      -1,    -1,    -1,    -1,    38,    39,    -1,    41,    42,    43,
-      44,    45,    46,    47,    48,    49,    -1,    -1,    52,    53,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    71,     4,     5,
-       6,    -1,    -1,    -1,    10,    11,    12,    -1,    82,    83,
-      -1,    85,    -1,    -1,    -1,    21,    22,    23,    24,    25,
-      26,    27,    28,    29,    30,    31,    32,    -1,    -1,    -1,
-      -1,    -1,    38,    39,    -1,    41,    42,    43,    44,    -1,
-      46,     4,     5,     6,    -1,    -1,    -1,    10,    11,    12,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    21,    22,
-      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
-      76,    -1,    -1,    -1,    -1,    38,    39,    -1,    41,    42,
-      43,    44,    -1,    46,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,     0,    -1,    -1,     3,     4,     5,     6,
-       7,     8,     9,    10,    11,    12,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    76,    21,    22,    23,    24,    25,    26,
-      27,    28,    29,    30,    31,    32,    -1,    -1,    -1,    36,
-      37,    38,    39,    -1,    41,    42,    43,    44,    -1,    46,
-       3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    21,    22,
-      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
-      -1,    -1,    -1,    36,    37,    38,    39,    -1,    41,    42,
-      43,    44,    -1,    46,     4,     5,     6,    -1,    -1,    -1,
-      10,    11,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    21,    22,    23,    24,    25,    26,    27,    28,    29,
-      30,    31,    32,    -1,    -1,    -1,    -1,    -1,    38,    39,
-      -1,    41,    42,    43,    44,    -1,    46,    10,    11,    12,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    21,    22,
-      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
-      -1,    -1,    -1,    -1,    -1,    38,    39,    -1,    41,    42,
-      43,    44,    45,    46,    10,    11,    12,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    21,    22,    23,    24,    25,
-      26,    27,    28,    29,    30,    31,    32,    -1,    -1,    -1,
-      -1,    -1,    38,    39,    -1,    41,    42,    43,    44,    -1,
-      46
</del><ins>+      -1,    -1,    -1,    -1,    -1,   104,    10,    11,    12,    13,
+      -1,    -1,    -1,    -1,    -1,    -1,   115,   116,    -1,   118,
+      -1,    25,    26,    27,    28,    29,    30,    31,    32,    33,
+      34,    35,    36,    37,    38,    39,    -1,    -1,    -1,    -1,
+      -1,    45,    46,    47,    48,    49,    50,    -1,    -1,    -1,
+      54,    55,    -1,    57,    58,    59,    60,    61,    62,    63,
+      64,    65,    66,    67,    68,    69,    70,    -1,    72,    73,
+      74,    -1,    76,    77,    78,    79,    80,    81,    -1,    -1,
+      -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,     3,     4,     5,     6,
+     104,     8,     9,    10,    11,    12,    13,    -1,    -1,    -1,
+      -1,   115,   116,    -1,   118,    -1,    -1,    -1,    25,    26,
+      27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
+      37,    38,    39,    40,    41,    -1,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,    -1,
+      57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
+      67,    68,    69,    70,    -1,    72,    73,    74,    75,    -1,
+      77,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,     3,     4,     5,     6,    -1,     8,     9,    10,    11,
+      12,    13,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,   109,    25,    26,    27,    28,    29,    30,    31,
+      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
+      -1,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,    -1,    57,    58,    59,    60,    61,
+      62,    63,    64,    65,    66,    67,    68,    69,    70,    -1,
+      72,    73,    74,    75,    -1,    77,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,     3,     4,     5,     6,
+      -1,     8,     9,    10,    11,    12,    13,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,   109,    25,    26,
+      27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
+      37,    38,    39,    40,    41,    -1,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,    -1,
+      57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
+      67,    68,    69,    70,    -1,    72,    73,    74,    75,    -1,
+      77,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     0,    -1,
+      -1,     3,     4,     5,     6,     7,     8,     9,    10,    11,
+      12,    13,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,   109,    25,    26,    27,    28,    29,    30,    31,
+      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
+      -1,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,    -1,    57,    58,    59,    60,    61,
+      62,    63,    64,    65,    66,    67,    68,    69,    70,    -1,
+      72,    73,    74,    75,    -1,    77,     3,     4,     5,     6,
+       7,     8,     9,    10,    11,    12,    13,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    25,    26,
+      27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
+      37,    38,    39,    40,    41,    -1,    43,    44,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,    55,    -1,
+      57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
+      67,    68,    69,    70,    -1,    72,    73,    74,    75,    -1,
+      77,     3,     4,     5,     6,    -1,     8,     9,    10,    11,
+      12,    13,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    25,    26,    27,    28,    29,    30,    31,
+      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
+      -1,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,    -1,    57,    58,    59,    60,    61,
+      62,    63,    64,    65,    66,    67,    68,    69,    70,    -1,
+      72,    73,    74,    75,    -1,    77,     4,     5,     6,    -1,
+      -1,    -1,    10,    11,    12,    13,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    25,    26,    27,
+      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    -1,    -1,    -1,    -1,    -1,    45,    46,    47,
+      48,    49,    50,    -1,    -1,    -1,    54,    55,    -1,    57,
+      58,    59,    60,    61,    62,    63,    64,    65,    66,    67,
+      68,    69,    70,    -1,    72,    73,    74,    -1,    -1,    77,
+      10,    11,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      -1,    -1,    -1,    -1,    -1,    45,    46,    47,    48,    49,
+      50,    -1,    -1,    -1,    54,    55,    -1,    57,    58,    59,
+      60,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+      70,    -1,    72,    73,    74,    -1,    76,    77,    10,    11,
+      12,    13,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    25,    26,    27,    28,    29,    30,    31,
+      32,    33,    34,    35,    36,    37,    38,    39,    -1,    -1,
+      -1,    -1,    -1,    45,    46,    47,    48,    49,    50,    -1,
+      -1,    -1,    54,    55,    -1,    57,    58,    59,    60,    61,
+      62,    63,    64,    65,    66,    67,    68,    69,    70,    -1,
+      72,    73,    74,    -1,    -1,    77
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
</span><span class="lines">@@ -1299,46 +1590,53 @@
</span><span class="cx"> static const yytype_uint8 yystos[] =
</span><span class="cx"> {
</span><span class="cx">        0,     3,     4,     5,     6,     7,     8,     9,    10,    11,
</span><del>-      12,    21,    22,    23,    24,    25,    26,    27,    28,    29,
-      30,    31,    32,    36,    37,    38,    39,    41,    42,    43,
-      44,    46,   126,   127,   128,   129,   130,   135,   136,   137,
-     138,   139,   140,   141,   142,   143,   175,   176,   177,    37,
-      45,   140,    45,    46,    75,    96,    81,   178,    72,    78,
-       3,    33,    34,    35,   132,   133,   138,    78,    81,    45,
-      96,   139,   141,    73,     0,   176,   141,   145,    75,    75,
-     161,   132,   131,   134,   139,   133,    96,    71,    73,    80,
-      45,    47,    48,    49,    52,    53,    71,    82,    83,    85,
-      97,    98,    99,   101,   102,   103,   104,   105,   106,   107,
-     108,   109,   110,   111,   112,   113,   114,   115,   116,   117,
-     118,   119,   120,   121,   125,   142,    81,   139,   146,   147,
-     144,    13,    14,    15,    17,    18,    19,    20,    40,    75,
-      76,    81,   108,   121,   122,   124,   126,   127,   142,   151,
-     152,   153,   154,   162,   163,   164,   167,   174,    96,   131,
-     134,    73,    80,    74,   125,   122,   150,   108,   108,   124,
-      52,    53,    73,    77,    72,    72,    78,    39,   122,    71,
-     108,    86,    87,    83,    85,    54,    55,    89,    90,    56,
-      57,    58,    60,    59,    94,    74,    96,   148,   149,    76,
-     147,   146,    81,    81,   169,    71,    71,    81,    81,   124,
-      71,    76,   155,    61,    62,    63,    70,    80,   123,    78,
-      81,    76,   152,    73,    74,   125,   150,    74,    72,   100,
-     124,    45,    46,    96,   103,   122,   108,   108,   110,   110,
-     112,   112,   112,   112,   113,   113,   117,   118,   119,   124,
-      73,    78,    81,    76,   158,   159,   160,   170,   124,    81,
-     168,   162,   122,   122,   125,    74,    74,    79,   125,   149,
-      40,   161,   153,   151,   163,   171,    72,   124,   137,   166,
-     156,    74,   122,    74,    71,   166,   172,   173,   158,   165,
-      96,    72,    76,   124,    81,    72,    16,    80,   153,   157,
-     161,    72,   124,   157,   158,   150,    81
</del><ins>+      12,    13,    25,    26,    27,    28,    29,    30,    31,    32,
+      33,    34,    35,    36,    37,    38,    39,    40,    41,    43,
+      44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
+      54,    55,    57,    58,    59,    60,    61,    62,    63,    64,
+      65,    66,    67,    68,    69,    70,    72,    73,    74,    75,
+      77,   160,   161,   162,   163,   164,   169,   170,   171,   172,
+     174,   175,   176,   177,   178,   181,   182,   183,   215,   216,
+     217,    44,    76,   177,    40,    41,    76,    77,   108,   129,
+     104,   114,   218,   105,   111,     9,    40,    41,    42,   166,
+     167,   173,   111,   114,    76,   129,   175,    76,   114,   159,
+     176,   181,   175,   106,     0,   216,   181,   185,   108,    76,
+     179,   180,   108,   201,   166,   165,   168,   176,   167,   129,
+     104,   106,   113,   108,     3,   174,   176,   186,   187,    76,
+      78,    79,    80,    81,    85,    86,   104,   115,   116,   118,
+     130,   131,   132,   134,   135,   136,   137,   138,   139,   140,
+     141,   142,   143,   144,   145,   146,   147,   148,   149,   150,
+     151,   152,   153,   154,   158,   182,   114,   186,   184,   113,
+     105,   111,    14,    15,    16,    18,    19,    20,    21,    56,
+     108,   109,   114,   141,   154,   155,   157,   160,   161,   182,
+     191,   192,   193,   194,   202,   203,   204,   207,   214,   129,
+     165,   168,   106,   113,   107,   158,   155,   190,   176,   129,
+     188,   189,   109,   187,   141,   141,   157,    85,    86,   106,
+     110,   105,   105,   111,    55,   155,   104,   141,   119,   120,
+     116,   118,    87,    88,   122,   123,    89,    90,    91,    93,
+      92,   127,   107,   109,   186,    79,    80,   180,   114,   114,
+     209,   104,   104,   114,   114,   157,   104,   109,   195,    94,
+      95,    96,   103,   113,   156,   111,   114,   109,   192,   106,
+     107,   158,   190,   107,   188,   106,   111,   114,    76,   114,
+     105,   133,   157,    76,    77,   129,   136,   155,   141,   141,
+     143,   143,   145,   145,   145,   145,   146,   146,   150,   151,
+     152,   157,   109,   198,   199,   200,   210,   157,   114,   208,
+     202,   155,   155,   158,   107,   114,   158,   189,   106,   114,
+     107,   112,    56,   201,   193,   191,   203,   211,   105,   157,
+     171,   174,   206,   196,   107,   107,   158,   155,   104,   206,
+     212,   213,   198,   205,   129,   105,   109,   107,   157,   114,
+     105,    17,   113,   193,   197,   201,   114,   105,   157,   197,
+     198,   190,   114
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-#define yyerrok     (yyerrstatus = 0)
-#define yyclearin   (yychar = YYEMPTY)
-#define YYEMPTY     (-2)
-#define YYEOF       0
</del><ins>+#define yyerrok                (yyerrstatus = 0)
+#define yyclearin        (yychar = YYEMPTY)
+#define YYEMPTY                (-2)
+#define YYEOF                0
</ins><span class="cx"> 
</span><del>-#define YYACCEPT    goto yyacceptlab
-#define YYABORT     goto yyabortlab
-#define YYERROR     goto yyerrorlab
</del><ins>+#define YYACCEPT        goto yyacceptlab
+#define YYABORT                goto yyabortlab
+#define YYERROR                goto yyerrorlab
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> /* Like YYERROR except do call yyerror.  This remains here temporarily
</span><span class="lines">@@ -1348,7 +1646,7 @@
</span><span class="cx">    in Bison 2.4.2's NEWS entry, where a plan to phase it out is
</span><span class="cx">    discussed.  */
</span><span class="cx"> 
</span><del>-#define YYFAIL      goto yyerrlab
</del><ins>+#define YYFAIL                goto yyerrlab
</ins><span class="cx"> #if defined YYFAIL
</span><span class="cx">   /* This is here to suppress warnings from the GCC cpp's
</span><span class="cx">      -Wunused-macros.  Normally we don't worry about that warning, but
</span><span class="lines">@@ -1371,13 +1669,13 @@
</span><span class="cx">   else                                                          \
</span><span class="cx">     {                                                           \
</span><span class="cx">       yyerror (&amp;yylloc, context, YY_(&quot;syntax error: cannot back up&quot;)); \
</span><del>-      YYERROR;                          \
-    }                               \
</del><ins>+      YYERROR;                                                        \
+    }                                                                \
</ins><span class="cx"> while (YYID (0))
</span><span class="cx"> 
</span><span class="cx"> /* Error token number */
</span><del>-#define YYTERROR    1
-#define YYERRCODE   256
</del><ins>+#define YYTERROR        1
+#define YYERRCODE        256
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
</span><span class="lines">@@ -1474,21 +1772,21 @@
</span><span class="cx"> #  define YYFPRINTF fprintf
</span><span class="cx"> # endif
</span><span class="cx"> 
</span><del>-# define YYDPRINTF(Args)            \
-do {                        \
-  if (yydebug)                  \
-    YYFPRINTF Args;             \
</del><ins>+# define YYDPRINTF(Args)                        \
+do {                                                \
+  if (yydebug)                                        \
+    YYFPRINTF Args;                                \
</ins><span class="cx"> } while (YYID (0))
</span><span class="cx"> 
</span><del>-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)            \
-do {                                      \
-  if (yydebug)                                \
-    {                                     \
-      YYFPRINTF (stderr, &quot;%s &quot;, Title);                   \
-      yy_symbol_print (stderr,                        \
-          Type, Value, Location, context); \
-      YYFPRINTF (stderr, &quot;\n&quot;);                       \
-    }                                     \
</del><ins>+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                          \
+do {                                                                          \
+  if (yydebug)                                                                  \
+    {                                                                          \
+      YYFPRINTF (stderr, &quot;%s &quot;, Title);                                          \
+      yy_symbol_print (stderr,                                                  \
+                  Type, Value, Location, context); \
+      YYFPRINTF (stderr, &quot;\n&quot;);                                                  \
+    }                                                                          \
</ins><span class="cx"> } while (YYID (0))
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1581,10 +1879,10 @@
</span><span class="cx">   YYFPRINTF (stderr, &quot;\n&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-# define YY_STACK_PRINT(Bottom, Top)                \
-do {                                \
-  if (yydebug)                          \
-    yy_stack_print ((Bottom), (Top));               \
</del><ins>+# define YY_STACK_PRINT(Bottom, Top)                                \
+do {                                                                \
+  if (yydebug)                                                        \
+    yy_stack_print ((Bottom), (Top));                                \
</ins><span class="cx"> } while (YYID (0))
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1609,21 +1907,21 @@
</span><span class="cx">   int yyi;
</span><span class="cx">   unsigned long int yylno = yyrline[yyrule];
</span><span class="cx">   YYFPRINTF (stderr, &quot;Reducing stack by rule %d (line %lu):\n&quot;,
</span><del>-         yyrule - 1, yylno);
</del><ins>+             yyrule - 1, yylno);
</ins><span class="cx">   /* The symbols being reduced.  */
</span><span class="cx">   for (yyi = 0; yyi &lt; yynrhs; yyi++)
</span><span class="cx">     {
</span><span class="cx">       YYFPRINTF (stderr, &quot;   $%d = &quot;, yyi + 1);
</span><span class="cx">       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
</span><del>-               &amp;(yyvsp[(yyi + 1) - (yynrhs)])
-               , &amp;(yylsp[(yyi + 1) - (yynrhs)])            , context);
</del><ins>+                       &amp;(yyvsp[(yyi + 1) - (yynrhs)])
+                       , &amp;(yylsp[(yyi + 1) - (yynrhs)])                       , context);
</ins><span class="cx">       YYFPRINTF (stderr, &quot;\n&quot;);
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-# define YY_REDUCE_PRINT(Rule)      \
-do {                    \
-  if (yydebug)              \
</del><ins>+# define YY_REDUCE_PRINT(Rule)                \
+do {                                        \
+  if (yydebug)                                \
</ins><span class="cx">     yy_reduce_print (yyvsp, yylsp, Rule, context); \
</span><span class="cx"> } while (YYID (0))
</span><span class="cx"> 
</span><span class="lines">@@ -1639,7 +1937,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> /* YYINITDEPTH -- initial size of the parser's stacks.  */
</span><del>-#ifndef YYINITDEPTH
</del><ins>+#ifndef        YYINITDEPTH
</ins><span class="cx"> # define YYINITDEPTH 200
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -1725,27 +2023,27 @@
</span><span class="cx">       char const *yyp = yystr;
</span><span class="cx"> 
</span><span class="cx">       for (;;)
</span><del>-    switch (*++yyp)
-      {
-      case '\'':
-      case ',':
-        goto do_not_strip_quotes;
</del><ins>+        switch (*++yyp)
+          {
+          case '\'':
+          case ',':
+            goto do_not_strip_quotes;
</ins><span class="cx"> 
</span><del>-      case '\\':
-        if (*++yyp != '\\')
-          goto do_not_strip_quotes;
-        /* Fall through.  */
-      default:
-        if (yyres)
-          yyres[yyn] = *yyp;
-        yyn++;
-        break;
</del><ins>+          case '\\':
+            if (*++yyp != '\\')
+              goto do_not_strip_quotes;
+            /* Fall through.  */
+          default:
+            if (yyres)
+              yyres[yyn] = *yyp;
+            yyn++;
+            break;
</ins><span class="cx"> 
</span><del>-      case '&quot;':
-        if (yyres)
-          yyres[yyn] = '\0';
-        return yyn;
-      }
</del><ins>+          case '&quot;':
+            if (yyres)
+              yyres[yyn] = '\0';
+            return yyn;
+          }
</ins><span class="cx">     do_not_strip_quotes: ;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2082,26 +2380,26 @@
</span><span class="cx"> 
</span><span class="cx"> #ifdef yyoverflow
</span><span class="cx">       {
</span><del>-    /* Give user a chance to reallocate the stack.  Use copies of
-       these so that the &amp;'s don't force the real ones into
-       memory.  */
-    YYSTYPE *yyvs1 = yyvs;
-    yytype_int16 *yyss1 = yyss;
-    YYLTYPE *yyls1 = yyls;
</del><ins>+        /* Give user a chance to reallocate the stack.  Use copies of
+           these so that the &amp;'s don't force the real ones into
+           memory.  */
+        YYSTYPE *yyvs1 = yyvs;
+        yytype_int16 *yyss1 = yyss;
+        YYLTYPE *yyls1 = yyls;
</ins><span class="cx"> 
</span><del>-    /* Each stack pointer address is followed by the size of the
-       data in use in that stack, in bytes.  This used to be a
-       conditional around just the two extra args, but that might
-       be undefined if yyoverflow is a macro.  */
-    yyoverflow (YY_(&quot;memory exhausted&quot;),
-            &amp;yyss1, yysize * sizeof (*yyssp),
-            &amp;yyvs1, yysize * sizeof (*yyvsp),
-            &amp;yyls1, yysize * sizeof (*yylsp),
-            &amp;yystacksize);
</del><ins>+        /* Each stack pointer address is followed by the size of the
+           data in use in that stack, in bytes.  This used to be a
+           conditional around just the two extra args, but that might
+           be undefined if yyoverflow is a macro.  */
+        yyoverflow (YY_(&quot;memory exhausted&quot;),
+                    &amp;yyss1, yysize * sizeof (*yyssp),
+                    &amp;yyvs1, yysize * sizeof (*yyvsp),
+                    &amp;yyls1, yysize * sizeof (*yylsp),
+                    &amp;yystacksize);
</ins><span class="cx"> 
</span><del>-    yyls = yyls1;
-    yyss = yyss1;
-    yyvs = yyvs1;
</del><ins>+        yyls = yyls1;
+        yyss = yyss1;
+        yyvs = yyvs1;
</ins><span class="cx">       }
</span><span class="cx"> #else /* no yyoverflow */
</span><span class="cx"> # ifndef YYSTACK_RELOCATE
</span><span class="lines">@@ -2109,23 +2407,23 @@
</span><span class="cx"> # else
</span><span class="cx">       /* Extend the stack our own way.  */
</span><span class="cx">       if (YYMAXDEPTH &lt;= yystacksize)
</span><del>-    goto yyexhaustedlab;
</del><ins>+        goto yyexhaustedlab;
</ins><span class="cx">       yystacksize *= 2;
</span><span class="cx">       if (YYMAXDEPTH &lt; yystacksize)
</span><del>-    yystacksize = YYMAXDEPTH;
</del><ins>+        yystacksize = YYMAXDEPTH;
</ins><span class="cx"> 
</span><span class="cx">       {
</span><del>-    yytype_int16 *yyss1 = yyss;
-    union yyalloc *yyptr =
-      (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
-    if (! yyptr)
-      goto yyexhaustedlab;
-    YYSTACK_RELOCATE (yyss_alloc, yyss);
-    YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-    YYSTACK_RELOCATE (yyls_alloc, yyls);
</del><ins>+        yytype_int16 *yyss1 = yyss;
+        union yyalloc *yyptr =
+          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+        if (! yyptr)
+          goto yyexhaustedlab;
+        YYSTACK_RELOCATE (yyss_alloc, yyss);
+        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+        YYSTACK_RELOCATE (yyls_alloc, yyls);
</ins><span class="cx"> #  undef YYSTACK_RELOCATE
</span><del>-    if (yyss1 != yyssa)
-      YYSTACK_FREE (yyss1);
</del><ins>+        if (yyss1 != yyssa)
+          YYSTACK_FREE (yyss1);
</ins><span class="cx">       }
</span><span class="cx"> # endif
</span><span class="cx"> #endif /* no yyoverflow */
</span><span class="lines">@@ -2135,10 +2433,10 @@
</span><span class="cx">       yylsp = yyls + yysize - 1;
</span><span class="cx"> 
</span><span class="cx">       YYDPRINTF ((stderr, &quot;Stack size increased to %lu\n&quot;,
</span><del>-          (unsigned long int) yystacksize));
</del><ins>+                  (unsigned long int) yystacksize));
</ins><span class="cx"> 
</span><span class="cx">       if (yyss + yystacksize - 1 &lt;= yyssp)
</span><del>-    YYABORT;
</del><ins>+        YYABORT;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">   YYDPRINTF ((stderr, &quot;Entering state %d\n&quot;, yystate));
</span><span class="lines">@@ -2267,7 +2565,7 @@
</span><span class="cx">         {
</span><span class="cx">             variable = static_cast&lt;const TVariable*&gt;(symbol);
</span><span class="cx"> 
</span><del>-            if (context-&gt;symbolTable.findBuiltIn(variable-&gt;getName()) &amp;&amp;
</del><ins>+            if (context-&gt;symbolTable.findBuiltIn(variable-&gt;getName(), context-&gt;shaderVersion) &amp;&amp;
</ins><span class="cx">                 !variable-&gt;getExtension().empty() &amp;&amp;
</span><span class="cx">                 context-&gt;extensionErrorCheck((yylsp[(1) - (1)]), variable-&gt;getExtension()))
</span><span class="cx">             {
</span><span class="lines">@@ -2279,7 +2577,7 @@
</span><span class="cx">         {
</span><span class="cx">             TType type(EbtFloat, EbpUndefined);
</span><span class="cx">             TVariable *fakeVariable = new TVariable((yyvsp[(1) - (1)].lex).string, type);
</span><del>-            context-&gt;symbolTable.insert(*fakeVariable);
</del><ins>+            context-&gt;symbolTable.declare(*fakeVariable);
</ins><span class="cx">             variable = fakeVariable;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -2322,12 +2620,21 @@
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         ConstantUnion *unionArray = new ConstantUnion[1];
</span><ins>+        unionArray-&gt;setUConst((yyvsp[(1) - (1)].lex).u);
+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addConstantUnion(unionArray, TType(EbtUInt, EbpUndefined, EvqConst), (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 8:
+
+    {
+        ConstantUnion *unionArray = new ConstantUnion[1];
</ins><span class="cx">         unionArray-&gt;setFConst((yyvsp[(1) - (1)].lex).f);
</span><span class="cx">         (yyval.interm.intermTypedNode) = context-&gt;intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), (yylsp[(1) - (1)]));
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 8:
</del><ins>+  case 9:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         ConstantUnion *unionArray = new ConstantUnion[1];
</span><span class="lines">@@ -2336,139 +2643,47 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 9:
</del><ins>+  case 10:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = (yyvsp[(2) - (3)].interm.intermTypedNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 10:
</del><ins>+  case 11:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 11:
</del><ins>+  case 12:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = context-&gt;addIndexExpression((yyvsp[(1) - (4)].interm.intermTypedNode), (yylsp[(2) - (4)]), (yyvsp[(3) - (4)].interm.intermTypedNode));
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 12:
</del><ins>+  case 13:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 13:
</del><ins>+  case 14:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        if ((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;isArray()) {
-            context-&gt;error((yylsp[(3) - (3)]), &quot;cannot apply dot operator to an array&quot;, &quot;.&quot;);
-            context-&gt;recover();
-        }
-
-        if ((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;isVector()) {
-            TVectorFields fields;
-            if (! context-&gt;parseVectorFields(*(yyvsp[(3) - (3)].lex).string, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getNominalSize(), fields, (yylsp[(3) - (3)]))) {
-                fields.num = 1;
-                fields.offsets[0] = 0;
-                context-&gt;recover();
-            }
-
-            if ((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getType().getQualifier() == EvqConst) { // constant folding for vector fields
-                (yyval.interm.intermTypedNode) = context-&gt;addConstVectorNode(fields, (yyvsp[(1) - (3)].interm.intermTypedNode), (yylsp[(3) - (3)]));
-                if ((yyval.interm.intermTypedNode) == 0) {
-                    context-&gt;recover();
-                    (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
-                }
-                else
-                    (yyval.interm.intermTypedNode)-&gt;setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getPrecision(), EvqConst, (int) (*(yyvsp[(3) - (3)].lex).string).size()));
-            } else {
-                TString vectorString = *(yyvsp[(3) - (3)].lex).string;
-                TIntermTyped* index = context-&gt;intermediate.addSwizzle(fields, (yylsp[(3) - (3)]));
-                (yyval.interm.intermTypedNode) = context-&gt;intermediate.addIndex(EOpVectorSwizzle, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yylsp[(2) - (3)]));
-                (yyval.interm.intermTypedNode)-&gt;setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getPrecision(), EvqTemporary, (int) vectorString.size()));
-            }
-        } else if ((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;isMatrix()) {
-            TMatrixFields fields;
-            if (! context-&gt;parseMatrixFields(*(yyvsp[(3) - (3)].lex).string, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getNominalSize(), fields, (yylsp[(3) - (3)]))) {
-                fields.wholeRow = false;
-                fields.wholeCol = false;
-                fields.row = 0;
-                fields.col = 0;
-                context-&gt;recover();
-            }
-
-            if (fields.wholeRow || fields.wholeCol) {
-                context-&gt;error((yylsp[(2) - (3)]), &quot; non-scalar fields not implemented yet&quot;, &quot;.&quot;);
-                context-&gt;recover();
-                ConstantUnion *unionArray = new ConstantUnion[1];
-                unionArray-&gt;setIConst(0);
-                TIntermTyped* index = context-&gt;intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yylsp[(3) - (3)]));
-                (yyval.interm.intermTypedNode) = context-&gt;intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yylsp[(2) - (3)]));
-                (yyval.interm.intermTypedNode)-&gt;setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getPrecision(),EvqTemporary, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getNominalSize()));
-            } else {
-                ConstantUnion *unionArray = new ConstantUnion[1];
-                unionArray-&gt;setIConst(fields.col * (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getNominalSize() + fields.row);
-                TIntermTyped* index = context-&gt;intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yylsp[(3) - (3)]));
-                (yyval.interm.intermTypedNode) = context-&gt;intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yylsp[(2) - (3)]));
-                (yyval.interm.intermTypedNode)-&gt;setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getPrecision()));
-            }
-        } else if ((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getBasicType() == EbtStruct) {
-            bool fieldFound = false;
-            const TFieldList&amp; fields = (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getType().getStruct()-&gt;fields();
-            unsigned int i;
-            for (i = 0; i &lt; fields.size(); ++i) {
-                if (fields[i]-&gt;name() == *(yyvsp[(3) - (3)].lex).string) {
-                    fieldFound = true;
-                    break;
-                }
-            }
-            if (fieldFound) {
-                if ((yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getType().getQualifier() == EvqConst) {
-                    (yyval.interm.intermTypedNode) = context-&gt;addConstStruct(*(yyvsp[(3) - (3)].lex).string, (yyvsp[(1) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
-                    if ((yyval.interm.intermTypedNode) == 0) {
-                        context-&gt;recover();
-                        (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
-                    }
-                    else {
-                        (yyval.interm.intermTypedNode)-&gt;setType(*fields[i]-&gt;type());
-                        // change the qualifier of the return type, not of the structure field
-                        // as the structure definition is shared between various structures.
-                        (yyval.interm.intermTypedNode)-&gt;getTypePointer()-&gt;setQualifier(EvqConst);
-                    }
-                } else {
-                    ConstantUnion *unionArray = new ConstantUnion[1];
-                    unionArray-&gt;setIConst(i);
-                    TIntermTyped* index = context-&gt;intermediate.addConstantUnion(unionArray, *fields[i]-&gt;type(), (yylsp[(3) - (3)]));
-                    (yyval.interm.intermTypedNode) = context-&gt;intermediate.addIndex(EOpIndexDirectStruct, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yylsp[(2) - (3)]));
-                    (yyval.interm.intermTypedNode)-&gt;setType(*fields[i]-&gt;type());
-                }
-            } else {
-                context-&gt;error((yylsp[(2) - (3)]), &quot; no such field in structure&quot;, (yyvsp[(3) - (3)].lex).string-&gt;c_str());
-                context-&gt;recover();
-                (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
-            }
-        } else {
-            context-&gt;error((yylsp[(2) - (3)]), &quot; field selection requires structure, vector, or matrix on left hand side&quot;, (yyvsp[(3) - (3)].lex).string-&gt;c_str());
-            context-&gt;recover();
-            (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
-        }
-        // don't delete $3.string, it's from the pool
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;addFieldSelectionExpression((yyvsp[(1) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), *(yyvsp[(3) - (3)].lex).string, (yylsp[(3) - (3)]));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 14:
</del><ins>+  case 15:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;lValueErrorCheck((yylsp[(2) - (2)]), &quot;++&quot;, (yyvsp[(1) - (2)].interm.intermTypedNode)))
</span><span class="cx">             context-&gt;recover();
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(EOpPostIncrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yylsp[(2) - (2)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(EOpPostIncrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yylsp[(2) - (2)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;unaryOpError((yylsp[(2) - (2)]), &quot;++&quot;, (yyvsp[(1) - (2)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2477,12 +2692,12 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 15:
</del><ins>+  case 16:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;lValueErrorCheck((yylsp[(2) - (2)]), &quot;--&quot;, (yyvsp[(1) - (2)].interm.intermTypedNode)))
</span><span class="cx">             context-&gt;recover();
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(EOpPostDecrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yylsp[(2) - (2)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(EOpPostDecrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yylsp[(2) - (2)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;unaryOpError((yylsp[(2) - (2)]), &quot;--&quot;, (yyvsp[(1) - (2)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2491,7 +2706,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 16:
</del><ins>+  case 17:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;integerErrorCheck((yyvsp[(1) - (1)].interm.intermTypedNode), &quot;[]&quot;))
</span><span class="lines">@@ -2500,7 +2715,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 17:
</del><ins>+  case 18:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TFunction* fnCall = (yyvsp[(1) - (1)].interm).function;
</span><span class="lines">@@ -2534,7 +2749,7 @@
</span><span class="cx">             //
</span><span class="cx">             const TFunction* fnCandidate;
</span><span class="cx">             bool builtIn;
</span><del>-            fnCandidate = context-&gt;findFunction((yylsp[(1) - (1)]), fnCall, &amp;builtIn);
</del><ins>+            fnCandidate = context-&gt;findFunction((yylsp[(1) - (1)]), fnCall, context-&gt;shaderVersion, &amp;builtIn);
</ins><span class="cx">             if (fnCandidate) {
</span><span class="cx">                 //
</span><span class="cx">                 // A declared function.
</span><span class="lines">@@ -2552,7 +2767,7 @@
</span><span class="cx">                         //
</span><span class="cx">                         // Treat it like a built-in unary operator.
</span><span class="cx">                         //
</span><del>-                        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(op, (yyvsp[(1) - (1)].interm).intermNode, (yylsp[(1) - (1)]), context-&gt;symbolTable);
</del><ins>+                        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(op, (yyvsp[(1) - (1)].interm).intermNode, (yylsp[(1) - (1)]));
</ins><span class="cx">                         if ((yyval.interm.intermTypedNode) == 0)  {
</span><span class="cx">                             std::stringstream extraInfoStream;
</span><span class="cx">                             extraInfoStream &lt;&lt; &quot;built in unary operator function.  Type: &quot; &lt;&lt; static_cast&lt;TIntermTyped*&gt;((yyvsp[(1) - (1)].interm).intermNode)-&gt;getCompleteString();
</span><span class="lines">@@ -2601,14 +2816,14 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 18:
</del><ins>+  case 19:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm) = (yyvsp[(1) - (1)].interm);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 19:
</del><ins>+  case 20:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         context-&gt;error((yylsp[(3) - (3)]), &quot;methods are not supported&quot;, &quot;&quot;);
</span><span class="lines">@@ -2617,21 +2832,21 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 20:
</del><ins>+  case 21:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm) = (yyvsp[(1) - (2)].interm);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 21:
</del><ins>+  case 22:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm) = (yyvsp[(1) - (2)].interm);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 22:
</del><ins>+  case 23:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm).function = (yyvsp[(1) - (2)].interm.function);
</span><span class="lines">@@ -2639,7 +2854,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 23:
</del><ins>+  case 24:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm).function = (yyvsp[(1) - (1)].interm.function);
</span><span class="lines">@@ -2647,7 +2862,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 24:
</del><ins>+  case 25:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TParameter param = { 0, new TType((yyvsp[(2) - (2)].interm.intermTypedNode)-&gt;getType()) };
</span><span class="lines">@@ -2657,7 +2872,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 25:
</del><ins>+  case 26:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TParameter param = { 0, new TType((yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getType()) };
</span><span class="lines">@@ -2667,73 +2882,21 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 26:
</del><ins>+  case 27:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.function) = (yyvsp[(1) - (2)].interm.function);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 27:
</del><ins>+  case 28:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        //
-        // Constructor
-        //
-        TOperator op = EOpNull;
-        if ((yyvsp[(1) - (1)].interm.type).userDef) {
-            op = EOpConstructStruct;
-        } else {
-            switch ((yyvsp[(1) - (1)].interm.type).type) {
-            case EbtFloat:
-                if ((yyvsp[(1) - (1)].interm.type).matrix) {
-                    switch((yyvsp[(1) - (1)].interm.type).size) {
-                    case 2: op = EOpConstructMat2;  break;
-                    case 3: op = EOpConstructMat3;  break;
-                    case 4: op = EOpConstructMat4;  break;
-                    }
-                } else {
-                    switch((yyvsp[(1) - (1)].interm.type).size) {
-                    case 1: op = EOpConstructFloat; break;
-                    case 2: op = EOpConstructVec2;  break;
-                    case 3: op = EOpConstructVec3;  break;
-                    case 4: op = EOpConstructVec4;  break;
-                    }
-                }
-                break;
-            case EbtInt:
-                switch((yyvsp[(1) - (1)].interm.type).size) {
-                case 1: op = EOpConstructInt;   break;
-                case 2: op = EOpConstructIVec2; break;
-                case 3: op = EOpConstructIVec3; break;
-                case 4: op = EOpConstructIVec4; break;
-                }
-                break;
-            case EbtBool:
-                switch((yyvsp[(1) - (1)].interm.type).size) {
-                case 1: op = EOpConstructBool;  break;
-                case 2: op = EOpConstructBVec2; break;
-                case 3: op = EOpConstructBVec3; break;
-                case 4: op = EOpConstructBVec4; break;
-                }
-                break;
-            default: break;
-            }
-            if (op == EOpNull) {
-                context-&gt;error((yylsp[(1) - (1)]), &quot;cannot construct this type&quot;, getBasicString((yyvsp[(1) - (1)].interm.type).type));
-                context-&gt;recover();
-                (yyvsp[(1) - (1)].interm.type).type = EbtFloat;
-                op = EOpConstructFloat;
-            }
-        }
-        TString tempString;
-        TType type((yyvsp[(1) - (1)].interm.type));
-        TFunction *function = new TFunction(&amp;tempString, type, op);
-        (yyval.interm.function) = function;
</del><ins>+        (yyval.interm.function) = context-&gt;addConstructorFunc((yyvsp[(1) - (1)].interm.type));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 28:
</del><ins>+  case 29:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;reservedErrorCheck((yylsp[(1) - (1)]), *(yyvsp[(1) - (1)].lex).string))
</span><span class="lines">@@ -2744,19 +2907,19 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 29:
</del><ins>+  case 30:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 30:
</del><ins>+  case 31:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;lValueErrorCheck((yylsp[(1) - (2)]), &quot;++&quot;, (yyvsp[(2) - (2)].interm.intermTypedNode)))
</span><span class="cx">             context-&gt;recover();
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(EOpPreIncrement, (yyvsp[(2) - (2)].interm.intermTypedNode), (yylsp[(1) - (2)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(EOpPreIncrement, (yyvsp[(2) - (2)].interm.intermTypedNode), (yylsp[(1) - (2)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;unaryOpError((yylsp[(1) - (2)]), &quot;++&quot;, (yyvsp[(2) - (2)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2765,12 +2928,12 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 31:
</del><ins>+  case 32:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;lValueErrorCheck((yylsp[(1) - (2)]), &quot;--&quot;, (yyvsp[(2) - (2)].interm.intermTypedNode)))
</span><span class="cx">             context-&gt;recover();
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(EOpPreDecrement, (yyvsp[(2) - (2)].interm.intermTypedNode), (yylsp[(1) - (2)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath(EOpPreDecrement, (yyvsp[(2) - (2)].interm.intermTypedNode), (yylsp[(1) - (2)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;unaryOpError((yylsp[(1) - (2)]), &quot;--&quot;, (yyvsp[(2) - (2)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2779,11 +2942,11 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 32:
</del><ins>+  case 33:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if ((yyvsp[(1) - (2)].interm).op != EOpNull) {
</span><del>-            (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath((yyvsp[(1) - (2)].interm).op, (yyvsp[(2) - (2)].interm.intermTypedNode), (yylsp[(1) - (2)]), context-&gt;symbolTable);
</del><ins>+            (yyval.interm.intermTypedNode) = context-&gt;intermediate.addUnaryMath((yyvsp[(1) - (2)].interm).op, (yyvsp[(2) - (2)].interm.intermTypedNode), (yylsp[(1) - (2)]));
</ins><span class="cx">             if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">                 const char* errorOp = &quot;&quot;;
</span><span class="cx">                 switch((yyvsp[(1) - (2)].interm).op) {
</span><span class="lines">@@ -2800,30 +2963,30 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 33:
</del><ins>+  case 34:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm).op = EOpNull; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 34:
</del><ins>+  case 35:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm).op = EOpNegative; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 35:
</del><ins>+  case 36:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm).op = EOpLogicalNot; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 36:
</del><ins>+  case 37:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 37:
</del><ins>+  case 38:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpMul, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpMul, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;*&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2832,10 +2995,10 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 38:
</del><ins>+  case 39:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpDiv, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpDiv, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;/&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2844,15 +3007,15 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 39:
</del><ins>+  case 40:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 40:
</del><ins>+  case 41:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpAdd, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpAdd, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;+&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2861,10 +3024,10 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 41:
</del><ins>+  case 42:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpSub, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpSub, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;-&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2873,20 +3036,20 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 42:
</del><ins>+  case 43:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 43:
</del><ins>+  case 44:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 44:
</del><ins>+  case 45:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLessThan, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLessThan, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;&lt;&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2897,10 +3060,10 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 45:
</del><ins>+  case 46:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpGreaterThan, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpGreaterThan, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;&gt;&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2911,10 +3074,10 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 46:
</del><ins>+  case 47:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLessThanEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLessThanEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;&lt;=&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2925,10 +3088,10 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 47:
</del><ins>+  case 48:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpGreaterThanEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpGreaterThanEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;&gt;=&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2939,15 +3102,15 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 48:
</del><ins>+  case 49:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 49:
</del><ins>+  case 50:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;==&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2958,10 +3121,10 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 50:
</del><ins>+  case 51:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpNotEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpNotEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;!=&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -2972,11 +3135,6 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 51:
-
-    { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
-    break;
-
</del><span class="cx">   case 52:
</span><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="lines">@@ -2994,8 +3152,13 @@
</span><span class="cx"> 
</span><span class="cx">   case 55:
</span><span class="cx"> 
</span><ins>+    { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
+    break;
+
+  case 56:
+
</ins><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLogicalAnd, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLogicalAnd, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;&amp;&amp;&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -3006,15 +3169,15 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 56:
</del><ins>+  case 57:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 57:
</del><ins>+  case 58:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLogicalXor, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLogicalXor, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;^^&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -3025,15 +3188,15 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 58:
</del><ins>+  case 59:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 59:
</del><ins>+  case 60:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLogicalOr, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]), context-&gt;symbolTable);
</del><ins>+        (yyval.interm.intermTypedNode) = context-&gt;intermediate.addBinaryMath(EOpLogicalOr, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</ins><span class="cx">         if ((yyval.interm.intermTypedNode) == 0) {
</span><span class="cx">             context-&gt;binaryOpError((yylsp[(2) - (3)]), &quot;||&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)-&gt;getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)-&gt;getCompleteString());
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -3044,12 +3207,12 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 60:
</del><ins>+  case 61:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 61:
</del><ins>+  case 62:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">        if (context-&gt;boolErrorCheck((yylsp[(2) - (5)]), (yyvsp[(1) - (5)].interm.intermTypedNode)))
</span><span class="lines">@@ -3067,12 +3230,12 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 62:
</del><ins>+  case 63:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 63:
</del><ins>+  case 64:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;lValueErrorCheck((yylsp[(2) - (3)]), &quot;assign&quot;, (yyvsp[(1) - (3)].interm.intermTypedNode)))
</span><span class="lines">@@ -3086,39 +3249,39 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 64:
</del><ins>+  case 65:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm).op = EOpAssign; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 65:
</del><ins>+  case 66:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm).op = EOpMulAssign; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 66:
</del><ins>+  case 67:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm).op = EOpDivAssign; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 67:
</del><ins>+  case 68:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm).op = EOpAddAssign; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 68:
</del><ins>+  case 69:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm).op = EOpSubAssign; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 69:
</del><ins>+  case 70:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 70:
</del><ins>+  case 71:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = context-&gt;intermediate.addComma((yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yylsp[(2) - (3)]));
</span><span class="lines">@@ -3130,7 +3293,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 71:
</del><ins>+  case 72:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;constErrorCheck((yyvsp[(1) - (1)].interm.intermTypedNode)))
</span><span class="lines">@@ -3139,9 +3302,18 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 72:
</del><ins>+  case 73:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><ins>+        if (context-&gt;enterStructDeclaration((yylsp[(1) - (2)]), *(yyvsp[(1) - (2)].lex).string))
+            context-&gt;recover();
+        (yyval.lex) = (yyvsp[(1) - (2)].lex);
+    }
+    break;
+
+  case 74:
+
+    {
</ins><span class="cx">         TFunction &amp;function = *((yyvsp[(1) - (2)].interm).function);
</span><span class="cx">         
</span><span class="cx">         TIntermAggregate *prototype = new TIntermAggregate;
</span><span class="lines">@@ -3170,7 +3342,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 73:
</del><ins>+  case 75:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if ((yyvsp[(1) - (2)].interm).intermAggregate)
</span><span class="lines">@@ -3179,7 +3351,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 74:
</del><ins>+  case 76:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (((yyvsp[(2) - (4)].interm.precision) == EbpHigh) &amp;&amp; (context-&gt;shaderType == SH_FRAGMENT_SHADER) &amp;&amp; !context-&gt;fragmentPrecisionHigh) {
</span><span class="lines">@@ -3194,9 +3366,41 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 75:
</del><ins>+  case 77:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><ins>+        ES3_ONLY(getQualifierString((yyvsp[(1) - (5)].interm.type).qualifier), (yylsp[(1) - (5)]), &quot;interface blocks&quot;);
+        (yyval.interm.intermNode) = context-&gt;addInterfaceBlock((yyvsp[(1) - (5)].interm.type), (yylsp[(2) - (5)]), *(yyvsp[(2) - (5)].lex).string, (yyvsp[(3) - (5)].interm.fieldList), NULL, (yyloc), NULL, (yyloc));
+    }
+    break;
+
+  case 78:
+
+    {
+        ES3_ONLY(getQualifierString((yyvsp[(1) - (6)].interm.type).qualifier), (yylsp[(1) - (6)]), &quot;interface blocks&quot;);
+        (yyval.interm.intermNode) = context-&gt;addInterfaceBlock((yyvsp[(1) - (6)].interm.type), (yylsp[(2) - (6)]), *(yyvsp[(2) - (6)].lex).string, (yyvsp[(3) - (6)].interm.fieldList), (yyvsp[(5) - (6)].lex).string, (yylsp[(5) - (6)]), NULL, (yyloc));
+    }
+    break;
+
+  case 79:
+
+    {
+        ES3_ONLY(getQualifierString((yyvsp[(1) - (9)].interm.type).qualifier), (yylsp[(1) - (9)]), &quot;interface blocks&quot;);
+        (yyval.interm.intermNode) = context-&gt;addInterfaceBlock((yyvsp[(1) - (9)].interm.type), (yylsp[(2) - (9)]), *(yyvsp[(2) - (9)].lex).string, (yyvsp[(3) - (9)].interm.fieldList), (yyvsp[(5) - (9)].lex).string, (yylsp[(5) - (9)]), (yyvsp[(7) - (9)].interm.intermTypedNode), (yylsp[(6) - (9)]));
+    }
+    break;
+
+  case 80:
+
+    {
+        context-&gt;parseGlobalLayoutQualifier((yyvsp[(1) - (2)].interm.type));
+        (yyval.interm.intermNode) = 0;
+    }
+    break;
+
+  case 81:
+
+    {
</ins><span class="cx">         //
</span><span class="cx">         // Multiple declarations of the same function are allowed.
</span><span class="cx">         //
</span><span class="lines">@@ -3205,7 +3409,7 @@
</span><span class="cx">         //
</span><span class="cx">         // Redeclarations are allowed.  But, return types and parameter qualifiers must match.
</span><span class="cx">         //
</span><del>-        TFunction* prevDec = static_cast&lt;TFunction*&gt;(context-&gt;symbolTable.find((yyvsp[(1) - (2)].interm.function)-&gt;getMangledName()));
</del><ins>+        TFunction* prevDec = static_cast&lt;TFunction*&gt;(context-&gt;symbolTable.find((yyvsp[(1) - (2)].interm.function)-&gt;getMangledName(), context-&gt;shaderVersion));
</ins><span class="cx">         if (prevDec) {
</span><span class="cx">             if (prevDec-&gt;getReturnType() != (yyvsp[(1) - (2)].interm.function)-&gt;getReturnType()) {
</span><span class="cx">                 context-&gt;error((yylsp[(2) - (2)]), &quot;overloaded functions must have the same return type&quot;, (yyvsp[(1) - (2)].interm.function)-&gt;getReturnType().getBasicString());
</span><span class="lines">@@ -3222,7 +3426,7 @@
</span><span class="cx">         //
</span><span class="cx">         // Check for previously declared variables using the same name.
</span><span class="cx">         //
</span><del>-        TSymbol *prevSym = context-&gt;symbolTable.find((yyvsp[(1) - (2)].interm.function)-&gt;getName());
</del><ins>+        TSymbol *prevSym = context-&gt;symbolTable.find((yyvsp[(1) - (2)].interm.function)-&gt;getName(), context-&gt;shaderVersion);
</ins><span class="cx">         if (prevSym)
</span><span class="cx">         {
</span><span class="cx">             if (!prevSym-&gt;isFunction())
</span><span class="lines">@@ -3250,21 +3454,21 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 76:
</del><ins>+  case 82:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.function) = (yyvsp[(1) - (1)].interm.function);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 77:
</del><ins>+  case 83:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.function) = (yyvsp[(1) - (1)].interm.function);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 78:
</del><ins>+  case 84:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         // Add the parameter
</span><span class="lines">@@ -3276,7 +3480,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 79:
</del><ins>+  case 85:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         //
</span><span class="lines">@@ -3298,7 +3502,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 80:
</del><ins>+  case 86:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if ((yyvsp[(1) - (3)].interm.type).qualifier != EvqGlobal &amp;&amp; (yyvsp[(1) - (3)].interm.type).qualifier != EvqTemporary) {
</span><span class="lines">@@ -3319,7 +3523,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 81:
</del><ins>+  case 87:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if ((yyvsp[(1) - (2)].interm.type).type == EbtVoid) {
</span><span class="lines">@@ -3333,7 +3537,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 82:
</del><ins>+  case 88:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         // Check that we can make an array out of this type
</span><span class="lines">@@ -3354,16 +3558,16 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 83:
</del><ins>+  case 89:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm) = (yyvsp[(3) - (3)].interm);
</span><del>-        if (context-&gt;paramErrorCheck((yylsp[(3) - (3)]), (yyvsp[(1) - (3)].interm.type).qualifier, (yyvsp[(2) - (3)].interm.qualifier), (yyval.interm).param.type))
</del><ins>+        if (context-&gt;paramErrorCheck((yylsp[(3) - (3)]), (yyvsp[(1) - (3)].interm.qualifier), (yyvsp[(2) - (3)].interm.qualifier), (yyval.interm).param.type))
</ins><span class="cx">             context-&gt;recover();
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 84:
</del><ins>+  case 90:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm) = (yyvsp[(2) - (2)].interm);
</span><span class="lines">@@ -3374,16 +3578,16 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 85:
</del><ins>+  case 91:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm) = (yyvsp[(3) - (3)].interm);
</span><del>-        if (context-&gt;paramErrorCheck((yylsp[(3) - (3)]), (yyvsp[(1) - (3)].interm.type).qualifier, (yyvsp[(2) - (3)].interm.qualifier), (yyval.interm).param.type))
</del><ins>+        if (context-&gt;paramErrorCheck((yylsp[(3) - (3)]), (yyvsp[(1) - (3)].interm.qualifier), (yyvsp[(2) - (3)].interm.qualifier), (yyval.interm).param.type))
</ins><span class="cx">             context-&gt;recover();
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 86:
</del><ins>+  case 92:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm) = (yyvsp[(2) - (2)].interm);
</span><span class="lines">@@ -3394,35 +3598,35 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 87:
</del><ins>+  case 93:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.qualifier) = EvqIn;
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 88:
</del><ins>+  case 94:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.qualifier) = EvqIn;
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 89:
</del><ins>+  case 95:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.qualifier) = EvqOut;
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 90:
</del><ins>+  case 96:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.qualifier) = EvqInOut;
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 91:
</del><ins>+  case 97:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TParameter param = { 0, new TType((yyvsp[(1) - (1)].interm.type)) };
</span><span class="lines">@@ -3430,216 +3634,89 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 92:
</del><ins>+  case 98:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm) = (yyvsp[(1) - (1)].interm);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 93:
</del><ins>+  case 99:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        if ((yyvsp[(1) - (3)].interm).type.type == EbtInvariant &amp;&amp; !(yyvsp[(3) - (3)].lex).symbol)
-        {
-            context-&gt;error((yylsp[(3) - (3)]), &quot;undeclared identifier declared as invariant&quot;, (yyvsp[(3) - (3)].lex).string-&gt;c_str());
-            context-&gt;recover();
-        }
-
-        TIntermSymbol* symbol = context-&gt;intermediate.addSymbol(0, *(yyvsp[(3) - (3)].lex).string, TType((yyvsp[(1) - (3)].interm).type), (yylsp[(3) - (3)]));
-        (yyval.interm).intermAggregate = context-&gt;intermediate.growAggregate((yyvsp[(1) - (3)].interm).intermNode, symbol, (yylsp[(3) - (3)]));
-        
-        if (context-&gt;structQualifierErrorCheck((yylsp[(3) - (3)]), (yyval.interm).type))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck((yylsp[(3) - (3)]), *(yyvsp[(3) - (3)].lex).string, (yyval.interm).type, false))
-            context-&gt;recover();
-
-        TVariable* variable = 0;
-        if (context-&gt;nonInitErrorCheck((yylsp[(3) - (3)]), *(yyvsp[(3) - (3)].lex).string, (yyval.interm).type, variable))
-            context-&gt;recover();
-        if (symbol &amp;&amp; variable)
-            symbol-&gt;setId(variable-&gt;getUniqueId());
</del><ins>+        (yyval.interm) = (yyvsp[(1) - (3)].interm);
+        (yyval.interm).intermAggregate = context-&gt;parseDeclarator((yyval.interm).type, (yyvsp[(1) - (3)].interm).intermAggregate, (yyvsp[(3) - (3)].lex).symbol, (yylsp[(3) - (3)]), *(yyvsp[(3) - (3)].lex).string);
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 94:
</del><ins>+  case 100:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        if (context-&gt;structQualifierErrorCheck((yylsp[(3) - (5)]), (yyvsp[(1) - (5)].interm).type))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck((yylsp[(3) - (5)]), *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type, true))
-            context-&gt;recover();
-
</del><span class="cx">         (yyval.interm) = (yyvsp[(1) - (5)].interm);
</span><del>-
-        if (context-&gt;arrayTypeErrorCheck((yylsp[(4) - (5)]), (yyvsp[(1) - (5)].interm).type) || context-&gt;arrayQualifierErrorCheck((yylsp[(4) - (5)]), (yyvsp[(1) - (5)].interm).type))
-            context-&gt;recover();
-        else {
-            (yyvsp[(1) - (5)].interm).type.setArray(true);
-            TVariable* variable;
-            if (context-&gt;arrayErrorCheck((yylsp[(4) - (5)]), *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type, variable))
-                context-&gt;recover();
-        }
</del><ins>+        context-&gt;parseArrayDeclarator((yyval.interm).type, (yylsp[(3) - (5)]), *(yyvsp[(3) - (5)].lex).string, (yylsp[(4) - (5)]), NULL, NULL);
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 95:
</del><ins>+  case 101:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        if (context-&gt;structQualifierErrorCheck((yylsp[(3) - (6)]), (yyvsp[(1) - (6)].interm).type))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck((yylsp[(3) - (6)]), *(yyvsp[(3) - (6)].lex).string, (yyvsp[(1) - (6)].interm).type, true))
-            context-&gt;recover();
-
</del><span class="cx">         (yyval.interm) = (yyvsp[(1) - (6)].interm);
</span><del>-
-        if (context-&gt;arrayTypeErrorCheck((yylsp[(4) - (6)]), (yyvsp[(1) - (6)].interm).type) || context-&gt;arrayQualifierErrorCheck((yylsp[(4) - (6)]), (yyvsp[(1) - (6)].interm).type))
-            context-&gt;recover();
-        else {
-            int size;
-            if (context-&gt;arraySizeErrorCheck((yylsp[(4) - (6)]), (yyvsp[(5) - (6)].interm.intermTypedNode), size))
-                context-&gt;recover();
-            (yyvsp[(1) - (6)].interm).type.setArray(true, size);
-            TVariable* variable = 0;
-            if (context-&gt;arrayErrorCheck((yylsp[(4) - (6)]), *(yyvsp[(3) - (6)].lex).string, (yyvsp[(1) - (6)].interm).type, variable))
-                context-&gt;recover();
-            TType type = TType((yyvsp[(1) - (6)].interm).type);
-            type.setArraySize(size);
-            (yyval.interm).intermAggregate = context-&gt;intermediate.growAggregate((yyvsp[(1) - (6)].interm).intermNode, context-&gt;intermediate.addSymbol(variable ? variable-&gt;getUniqueId() : 0, *(yyvsp[(3) - (6)].lex).string, type, (yylsp[(3) - (6)])), (yylsp[(3) - (6)]));
-        }
</del><ins>+        (yyval.interm).intermAggregate = context-&gt;parseArrayDeclarator((yyval.interm).type, (yylsp[(3) - (6)]), *(yyvsp[(3) - (6)].lex).string, (yylsp[(4) - (6)]), (yyvsp[(1) - (6)].interm).intermNode, (yyvsp[(5) - (6)].interm.intermTypedNode));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 96:
</del><ins>+  case 102:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        if (context-&gt;structQualifierErrorCheck((yylsp[(3) - (5)]), (yyvsp[(1) - (5)].interm).type))
-            context-&gt;recover();
-
</del><span class="cx">         (yyval.interm) = (yyvsp[(1) - (5)].interm);
</span><del>-
-        TIntermNode* intermNode;
-        if (!context-&gt;executeInitializer((yylsp[(3) - (5)]), *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type, (yyvsp[(5) - (5)].interm.intermTypedNode), intermNode)) {
-            //
-            // build the intermediate representation
-            //
-            if (intermNode)
-        (yyval.interm).intermAggregate = context-&gt;intermediate.growAggregate((yyvsp[(1) - (5)].interm).intermNode, intermNode, (yylsp[(4) - (5)]));
-            else
-                (yyval.interm).intermAggregate = (yyvsp[(1) - (5)].interm).intermAggregate;
-        } else {
-            context-&gt;recover();
-            (yyval.interm).intermAggregate = 0;
-        }
</del><ins>+        (yyval.interm).intermAggregate = context-&gt;parseInitDeclarator((yyval.interm).type, (yyvsp[(1) - (5)].interm).intermAggregate, (yylsp[(3) - (5)]), *(yyvsp[(3) - (5)].lex).string, (yylsp[(4) - (5)]), (yyvsp[(5) - (5)].interm.intermTypedNode));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 97:
</del><ins>+  case 103:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm).type = (yyvsp[(1) - (1)].interm.type);
</span><del>-        (yyval.interm).intermAggregate = context-&gt;intermediate.makeAggregate(context-&gt;intermediate.addSymbol(0, &quot;&quot;, TType((yyvsp[(1) - (1)].interm.type)), (yylsp[(1) - (1)])), (yylsp[(1) - (1)]));
</del><ins>+        (yyval.interm).intermAggregate = context-&gt;parseSingleDeclaration((yyval.interm).type, (yylsp[(1) - (1)]), &quot;&quot;);
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 98:
</del><ins>+  case 104:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        TIntermSymbol* symbol = context-&gt;intermediate.addSymbol(0, *(yyvsp[(2) - (2)].lex).string, TType((yyvsp[(1) - (2)].interm.type)), (yylsp[(2) - (2)]));
-        (yyval.interm).intermAggregate = context-&gt;intermediate.makeAggregate(symbol, (yylsp[(2) - (2)]));
-        
-        if (context-&gt;structQualifierErrorCheck((yylsp[(2) - (2)]), (yyval.interm).type))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck((yylsp[(2) - (2)]), *(yyvsp[(2) - (2)].lex).string, (yyval.interm).type, false))
-            context-&gt;recover();
-            
-            (yyval.interm).type = (yyvsp[(1) - (2)].interm.type);
-
-        TVariable* variable = 0;
-        if (context-&gt;nonInitErrorCheck((yylsp[(2) - (2)]), *(yyvsp[(2) - (2)].lex).string, (yyval.interm).type, variable))
-            context-&gt;recover();
-        if (variable &amp;&amp; symbol)
-            symbol-&gt;setId(variable-&gt;getUniqueId());
</del><ins>+        (yyval.interm).type = (yyvsp[(1) - (2)].interm.type);
+        (yyval.interm).intermAggregate = context-&gt;parseSingleDeclaration((yyval.interm).type, (yylsp[(2) - (2)]), *(yyvsp[(2) - (2)].lex).string);
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 99:
</del><ins>+  case 105:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         context-&gt;error((yylsp[(2) - (4)]), &quot;unsized array declarations not supported&quot;, (yyvsp[(2) - (4)].lex).string-&gt;c_str());
</span><span class="cx">         context-&gt;recover();
</span><span class="cx"> 
</span><del>-        TIntermSymbol* symbol = context-&gt;intermediate.addSymbol(0, *(yyvsp[(2) - (4)].lex).string, TType((yyvsp[(1) - (4)].interm.type)), (yylsp[(2) - (4)]));
-        (yyval.interm).intermAggregate = context-&gt;intermediate.makeAggregate(symbol, (yylsp[(2) - (4)]));
</del><span class="cx">         (yyval.interm).type = (yyvsp[(1) - (4)].interm.type);
</span><ins>+        (yyval.interm).intermAggregate = context-&gt;parseSingleDeclaration((yyval.interm).type, (yylsp[(2) - (4)]), *(yyvsp[(2) - (4)].lex).string);
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 100:
</del><ins>+  case 106:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        TType type = TType((yyvsp[(1) - (5)].interm.type));
-        int size;
-        if (context-&gt;arraySizeErrorCheck((yylsp[(2) - (5)]), (yyvsp[(4) - (5)].interm.intermTypedNode), size))
-            context-&gt;recover();
-        type.setArraySize(size);
-        TIntermSymbol* symbol = context-&gt;intermediate.addSymbol(0, *(yyvsp[(2) - (5)].lex).string, type, (yylsp[(2) - (5)]));
-        (yyval.interm).intermAggregate = context-&gt;intermediate.makeAggregate(symbol, (yylsp[(2) - (5)]));
-        
-        if (context-&gt;structQualifierErrorCheck((yylsp[(2) - (5)]), (yyvsp[(1) - (5)].interm.type)))
-            context-&gt;recover();
-
-        if (context-&gt;nonInitConstErrorCheck((yylsp[(2) - (5)]), *(yyvsp[(2) - (5)].lex).string, (yyvsp[(1) - (5)].interm.type), true))
-            context-&gt;recover();
-
</del><span class="cx">         (yyval.interm).type = (yyvsp[(1) - (5)].interm.type);
</span><del>-
-        if (context-&gt;arrayTypeErrorCheck((yylsp[(3) - (5)]), (yyvsp[(1) - (5)].interm.type)) || context-&gt;arrayQualifierErrorCheck((yylsp[(3) - (5)]), (yyvsp[(1) - (5)].interm.type)))
-            context-&gt;recover();
-        else {
-            int size;
-            if (context-&gt;arraySizeErrorCheck((yylsp[(3) - (5)]), (yyvsp[(4) - (5)].interm.intermTypedNode), size))
-                context-&gt;recover();
-
-            (yyvsp[(1) - (5)].interm.type).setArray(true, size);
-            TVariable* variable = 0;
-            if (context-&gt;arrayErrorCheck((yylsp[(3) - (5)]), *(yyvsp[(2) - (5)].lex).string, (yyvsp[(1) - (5)].interm.type), variable))
-                context-&gt;recover();
-            if (variable &amp;&amp; symbol)
-                symbol-&gt;setId(variable-&gt;getUniqueId());
-        }
</del><ins>+        (yyval.interm).intermAggregate = context-&gt;parseSingleArrayDeclaration((yyval.interm).type, (yylsp[(2) - (5)]), *(yyvsp[(2) - (5)].lex).string, (yylsp[(3) - (5)]), (yyvsp[(4) - (5)].interm.intermTypedNode));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 101:
</del><ins>+  case 107:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        if (context-&gt;structQualifierErrorCheck((yylsp[(2) - (4)]), (yyvsp[(1) - (4)].interm.type)))
-            context-&gt;recover();
-
</del><span class="cx">         (yyval.interm).type = (yyvsp[(1) - (4)].interm.type);
</span><del>-
-        TIntermNode* intermNode;
-        if (!context-&gt;executeInitializer((yylsp[(2) - (4)]), *(yyvsp[(2) - (4)].lex).string, (yyvsp[(1) - (4)].interm.type), (yyvsp[(4) - (4)].interm.intermTypedNode), intermNode)) {
-        //
-        // Build intermediate representation
-        //
-            if(intermNode)
-                (yyval.interm).intermAggregate = context-&gt;intermediate.makeAggregate(intermNode, (yylsp[(3) - (4)]));
-            else
-                (yyval.interm).intermAggregate = 0;
-        } else {
-            context-&gt;recover();
-            (yyval.interm).intermAggregate = 0;
-        }
</del><ins>+        (yyval.interm).intermAggregate = context-&gt;parseSingleInitDeclaration((yyval.interm).type, (yylsp[(2) - (4)]), *(yyvsp[(2) - (4)].lex).string, (yylsp[(3) - (4)]), (yyvsp[(4) - (4)].interm.intermTypedNode));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 102:
</del><ins>+  case 108:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         VERTEX_ONLY(&quot;invariant declaration&quot;, (yylsp[(1) - (2)]));
</span><span class="lines">@@ -3661,7 +3738,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 103:
</del><ins>+  case 109:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type);
</span><span class="lines">@@ -3674,50 +3751,49 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 104:
</del><ins>+  case 110:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        if ((yyvsp[(2) - (2)].interm.type).array) {
-            context-&gt;error((yylsp[(2) - (2)]), &quot;not supported&quot;, &quot;first-class array&quot;);
-            context-&gt;recover();
-            (yyvsp[(2) - (2)].interm.type).setArray(false);
-        }
</del><ins>+        (yyval.interm.type) = context-&gt;addFullySpecifiedType((yyvsp[(1) - (2)].interm.type).qualifier, (yyvsp[(1) - (2)].interm.type).layoutQualifier, (yyvsp[(2) - (2)].interm.type));
+    }
+    break;
</ins><span class="cx"> 
</span><del>-        if ((yyvsp[(1) - (2)].interm.type).qualifier == EvqAttribute &amp;&amp;
-            ((yyvsp[(2) - (2)].interm.type).type == EbtBool || (yyvsp[(2) - (2)].interm.type).type == EbtInt)) {
-            context-&gt;error((yylsp[(2) - (2)]), &quot;cannot be bool or int&quot;, getQualifierString((yyvsp[(1) - (2)].interm.type).qualifier));
-            context-&gt;recover();
-        }
-        if (((yyvsp[(1) - (2)].interm.type).qualifier == EvqVaryingIn || (yyvsp[(1) - (2)].interm.type).qualifier == EvqVaryingOut) &amp;&amp;
-            ((yyvsp[(2) - (2)].interm.type).type == EbtBool || (yyvsp[(2) - (2)].interm.type).type == EbtInt)) {
-            context-&gt;error((yylsp[(2) - (2)]), &quot;cannot be bool or int&quot;, getQualifierString((yyvsp[(1) - (2)].interm.type).qualifier));
-            context-&gt;recover();
-        }
-        (yyval.interm.type) = (yyvsp[(2) - (2)].interm.type);
-        (yyval.interm.type).qualifier = (yyvsp[(1) - (2)].interm.type).qualifier;
</del><ins>+  case 111:
+
+    {
+        (yyval.interm.type).qualifier = EvqSmooth;
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 105:
</del><ins>+  case 112:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.type).setBasic(EbtVoid, EvqConst, (yylsp[(1) - (1)]));
</del><ins>+        (yyval.interm.type).qualifier = EvqFlat;
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 106:
</del><ins>+  case 113:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><ins>+        (yyval.interm.qualifier) = EvqConst;
+    }
+    break;
+
+  case 114:
+
+    {
</ins><span class="cx">         VERTEX_ONLY(&quot;attribute&quot;, (yylsp[(1) - (1)]));
</span><ins>+        ES2_ONLY(&quot;attribute&quot;, (yylsp[(1) - (1)]));
</ins><span class="cx">         if (context-&gt;globalErrorCheck((yylsp[(1) - (1)]), context-&gt;symbolTable.atGlobalLevel(), &quot;attribute&quot;))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         (yyval.interm.type).setBasic(EbtVoid, EvqAttribute, (yylsp[(1) - (1)]));
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 107:
</del><ins>+  case 115:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><ins>+        ES2_ONLY(&quot;varying&quot;, (yylsp[(1) - (1)]));
</ins><span class="cx">         if (context-&gt;globalErrorCheck((yylsp[(1) - (1)]), context-&gt;symbolTable.atGlobalLevel(), &quot;varying&quot;))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         if (context-&gt;shaderType == SH_VERTEX_SHADER)
</span><span class="lines">@@ -3727,9 +3803,10 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 108:
</del><ins>+  case 116:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><ins>+        ES2_ONLY(&quot;varying&quot;, (yylsp[(1) - (2)]));
</ins><span class="cx">         if (context-&gt;globalErrorCheck((yylsp[(1) - (2)]), context-&gt;symbolTable.atGlobalLevel(), &quot;invariant varying&quot;))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         if (context-&gt;shaderType == SH_VERTEX_SHADER)
</span><span class="lines">@@ -3739,16 +3816,111 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 109:
</del><ins>+  case 117:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><ins>+        if ((yyvsp[(1) - (1)].interm.type).qualifier != EvqConst &amp;&amp; !context-&gt;symbolTable.atGlobalLevel()) {
+            context-&gt;error((yylsp[(1) - (1)]), &quot;Local variables can only use the const storage qualifier.&quot;, getQualifierString((yyvsp[(1) - (1)].interm.type).qualifier));
+            context-&gt;recover();
+        } else {
+            (yyval.interm.type).setBasic(EbtVoid, (yyvsp[(1) - (1)].interm.type).qualifier, (yylsp[(1) - (1)]));
+        }
+    }
+    break;
+
+  case 118:
+
+    {
+        (yyval.interm.type) = context-&gt;joinInterpolationQualifiers((yylsp[(1) - (2)]), (yyvsp[(1) - (2)].interm.type).qualifier, (yylsp[(2) - (2)]), (yyvsp[(2) - (2)].interm.type).qualifier);
+    }
+    break;
+
+  case 119:
+
+    {
+        context-&gt;error((yylsp[(1) - (1)]), &quot;interpolation qualifier requires a fragment 'in' or vertex 'out' storage qualifier&quot;, getInterpolationString((yyvsp[(1) - (1)].interm.type).qualifier));
+        context-&gt;recover();
+        
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtVoid, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 120:
+
+    {
+        (yyval.interm.type).qualifier = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).layoutQualifier = (yyvsp[(1) - (1)].interm.layoutQualifier);
+    }
+    break;
+
+  case 121:
+
+    {
+        (yyval.interm.type).setBasic(EbtVoid, (yyvsp[(2) - (2)].interm.type).qualifier, (yylsp[(2) - (2)]));
+        (yyval.interm.type).layoutQualifier = (yyvsp[(1) - (2)].interm.layoutQualifier);
+    }
+    break;
+
+  case 122:
+
+    {
+        (yyval.interm.type).qualifier = EvqConst;
+    }
+    break;
+
+  case 123:
+
+    {
+        ES3_ONLY(&quot;in&quot;, (yylsp[(1) - (1)]), &quot;storage qualifier&quot;);
+        (yyval.interm.type).qualifier = (context-&gt;shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
+    }
+    break;
+
+  case 124:
+
+    {
+        ES3_ONLY(&quot;out&quot;, (yylsp[(1) - (1)]), &quot;storage qualifier&quot;);
+        (yyval.interm.type).qualifier = (context-&gt;shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
+    }
+    break;
+
+  case 125:
+
+    {
+        ES3_ONLY(&quot;centroid in&quot;, (yylsp[(1) - (2)]), &quot;storage qualifier&quot;);
+        if (context-&gt;shaderType == SH_VERTEX_SHADER)
+        {
+            context-&gt;error((yylsp[(1) - (2)]), &quot;invalid storage qualifier&quot;, &quot;it is an error to use 'centroid in' in the vertex shader&quot;);
+            context-&gt;recover();
+        }
+        (yyval.interm.type).qualifier = (context-&gt;shaderType == SH_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexIn;
+    }
+    break;
+
+  case 126:
+
+    {
+        ES3_ONLY(&quot;centroid out&quot;, (yylsp[(1) - (2)]), &quot;storage qualifier&quot;);
+        if (context-&gt;shaderType == SH_FRAGMENT_SHADER)
+        {
+            context-&gt;error((yylsp[(1) - (2)]), &quot;invalid storage qualifier&quot;, &quot;it is an error to use 'centroid out' in the fragment shader&quot;);
+            context-&gt;recover();
+        }
+        (yyval.interm.type).qualifier = (context-&gt;shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentOut : EvqCentroidOut;
+    }
+    break;
+
+  case 127:
+
+    {
</ins><span class="cx">         if (context-&gt;globalErrorCheck((yylsp[(1) - (1)]), context-&gt;symbolTable.atGlobalLevel(), &quot;uniform&quot;))
</span><span class="cx">             context-&gt;recover();
</span><del>-        (yyval.interm.type).setBasic(EbtVoid, EvqUniform, (yylsp[(1) - (1)]));
</del><ins>+        (yyval.interm.type).qualifier = EvqUniform;
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 110:
</del><ins>+  case 128:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type);
</span><span class="lines">@@ -3762,7 +3934,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 111:
</del><ins>+  case 129:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.type) = (yyvsp[(2) - (2)].interm.type);
</span><span class="lines">@@ -3770,35 +3942,78 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 112:
</del><ins>+  case 130:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.precision) = EbpHigh;
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 113:
</del><ins>+  case 131:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.precision) = EbpMedium;
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 114:
</del><ins>+  case 132:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.precision) = EbpLow;
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 115:
</del><ins>+  case 133:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><ins>+        ES3_ONLY(&quot;layout&quot;, (yylsp[(1) - (4)]), &quot;qualifier&quot;);
+        (yyval.interm.layoutQualifier) = (yyvsp[(3) - (4)].interm.layoutQualifier);
+    }
+    break;
+
+  case 134:
+
+    {
+        (yyval.interm.layoutQualifier) = (yyvsp[(1) - (1)].interm.layoutQualifier);
+    }
+    break;
+
+  case 135:
+
+    {
+        (yyval.interm.layoutQualifier) = context-&gt;joinLayoutQualifiers((yyvsp[(1) - (3)].interm.layoutQualifier), (yyvsp[(3) - (3)].interm.layoutQualifier));
+    }
+    break;
+
+  case 136:
+
+    {
+        (yyval.interm.layoutQualifier) = context-&gt;parseLayoutQualifier(*(yyvsp[(1) - (1)].lex).string, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 137:
+
+    {
+        (yyval.interm.layoutQualifier) = context-&gt;parseLayoutQualifier(*(yyvsp[(1) - (3)].lex).string, (yylsp[(1) - (3)]), *(yyvsp[(3) - (3)].lex).string, (yyvsp[(3) - (3)].lex).i, (yylsp[(3) - (3)]));
+    }
+    break;
+
+  case 138:
+
+    {
+        (yyval.interm.layoutQualifier) = context-&gt;parseLayoutQualifier(*(yyvsp[(1) - (3)].lex).string, (yylsp[(1) - (3)]), *(yyvsp[(3) - (3)].lex).string, (yyvsp[(3) - (3)].lex).i, (yylsp[(3) - (3)]));
+    }
+    break;
+
+  case 139:
+
+    {
</ins><span class="cx">         (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 116:
</del><ins>+  case 140:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.type) = (yyvsp[(1) - (4)].interm.type);
</span><span class="lines">@@ -3814,7 +4029,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 117:
</del><ins>+  case 141:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3822,7 +4037,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 118:
</del><ins>+  case 142:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3830,7 +4045,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 119:
</del><ins>+  case 143:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3838,15 +4053,23 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 120:
</del><ins>+  case 144:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><ins>+        (yyval.interm.type).setBasic(EbtUInt, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 145:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</ins><span class="cx">         (yyval.interm.type).setBasic(EbtBool, qual, (yylsp[(1) - (1)]));
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 121:
</del><ins>+  case 146:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3855,7 +4078,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 122:
</del><ins>+  case 147:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3864,7 +4087,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 123:
</del><ins>+  case 148:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3873,7 +4096,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 124:
</del><ins>+  case 149:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3882,7 +4105,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 125:
</del><ins>+  case 150:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3891,7 +4114,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 126:
</del><ins>+  case 151:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3900,7 +4123,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 127:
</del><ins>+  case 152:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3909,7 +4132,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 128:
</del><ins>+  case 153:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3918,7 +4141,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 129:
</del><ins>+  case 154:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="lines">@@ -3927,52 +4150,237 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 130:
</del><ins>+  case 155:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><ins>+        (yyval.interm.type).setBasic(EbtUInt, qual, (yylsp[(1) - (1)]));
+        (yyval.interm.type).setAggregate(2);
+    }
+    break;
+
+  case 156:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtUInt, qual, (yylsp[(1) - (1)]));
+        (yyval.interm.type).setAggregate(3);
+    }
+    break;
+
+  case 157:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtUInt, qual, (yylsp[(1) - (1)]));
+        (yyval.interm.type).setAggregate(4);
+    }
+    break;
+
+  case 158:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</ins><span class="cx">         (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[(1) - (1)]));
</span><del>-        (yyval.interm.type).setAggregate(2, true);
</del><ins>+        (yyval.interm.type).setMatrix(2, 2);
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 131:
</del><ins>+  case 159:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="cx">         (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[(1) - (1)]));
</span><del>-        (yyval.interm.type).setAggregate(3, true);
</del><ins>+        (yyval.interm.type).setMatrix(3, 3);
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 132:
</del><ins>+  case 160:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><span class="cx">         (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[(1) - (1)]));
</span><del>-        (yyval.interm.type).setAggregate(4, true);
</del><ins>+        (yyval.interm.type).setMatrix(4, 4);
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 133:
</del><ins>+  case 161:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><ins>+        (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[(1) - (1)]));
+        (yyval.interm.type).setMatrix(2, 3);
+    }
+    break;
+
+  case 162:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[(1) - (1)]));
+        (yyval.interm.type).setMatrix(3, 2);
+    }
+    break;
+
+  case 163:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[(1) - (1)]));
+        (yyval.interm.type).setMatrix(2, 4);
+    }
+    break;
+
+  case 164:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[(1) - (1)]));
+        (yyval.interm.type).setMatrix(4, 2);
+    }
+    break;
+
+  case 165:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[(1) - (1)]));
+        (yyval.interm.type).setMatrix(3, 4);
+    }
+    break;
+
+  case 166:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtFloat, qual, (yylsp[(1) - (1)]));
+        (yyval.interm.type).setMatrix(4, 3);
+    }
+    break;
+
+  case 167:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</ins><span class="cx">         (yyval.interm.type).setBasic(EbtSampler2D, qual, (yylsp[(1) - (1)]));
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 134:
</del><ins>+  case 168:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</span><ins>+        (yyval.interm.type).setBasic(EbtSampler3D, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 169:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
</ins><span class="cx">         (yyval.interm.type).setBasic(EbtSamplerCube, qual, (yylsp[(1) - (1)]));
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 135:
</del><ins>+  case 170:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><ins>+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtSampler2DArray, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 171:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtISampler2D, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 172:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtISampler3D, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 173:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtISamplerCube, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 174:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtISampler2DArray, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 175:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtUSampler2D, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 176:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtUSampler3D, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 177:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtUSamplerCube, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 178:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtUSampler2DArray, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 179:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtSampler2DShadow, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 180:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtSamplerCubeShadow, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 181:
+
+    {
+        TQualifier qual = context-&gt;symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+        (yyval.interm.type).setBasic(EbtSampler2DArrayShadow, qual, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 182:
+
+    {
</ins><span class="cx">         if (!context-&gt;supportsExtension(&quot;GL_OES_EGL_image_external&quot;)) {
</span><span class="cx">             context-&gt;error((yylsp[(1) - (1)]), &quot;unsupported type&quot;, &quot;samplerExternalOES&quot;);
</span><span class="cx">             context-&gt;recover();
</span><span class="lines">@@ -3982,7 +4390,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 136:
</del><ins>+  case 183:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (!context-&gt;supportsExtension(&quot;GL_ARB_texture_rectangle&quot;)) {
</span><span class="lines">@@ -3994,7 +4402,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 137:
</del><ins>+  case 184:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type);
</span><span class="lines">@@ -4002,7 +4410,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 138:
</del><ins>+  case 185:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         //
</span><span class="lines">@@ -4016,52 +4424,38 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 139:
</del><ins>+  case 186:
</ins><span class="cx"> 
</span><span class="cx">     { if (context-&gt;enterStructDeclaration((yylsp[(2) - (3)]), *(yyvsp[(2) - (3)].lex).string)) context-&gt;recover(); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 140:
</del><ins>+  case 187:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        if (context-&gt;reservedErrorCheck((yylsp[(2) - (6)]), *(yyvsp[(2) - (6)].lex).string))
-            context-&gt;recover();
-
-        TType* structure = new TType(new TStructure((yyvsp[(2) - (6)].lex).string, (yyvsp[(5) - (6)].interm.fieldList)));
-        TVariable* userTypeDef = new TVariable((yyvsp[(2) - (6)].lex).string, *structure, true);
-        if (! context-&gt;symbolTable.insert(*userTypeDef)) {
-            context-&gt;error((yylsp[(2) - (6)]), &quot;redefinition&quot;, (yyvsp[(2) - (6)].lex).string-&gt;c_str(), &quot;struct&quot;);
-            context-&gt;recover();
-        }
-        (yyval.interm.type).setBasic(EbtStruct, EvqTemporary, (yylsp[(1) - (6)]));
-        (yyval.interm.type).userDef = structure;
-        context-&gt;exitStructDeclaration();
</del><ins>+        (yyval.interm.type) = context-&gt;addStructure((yylsp[(1) - (6)]), (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].lex).string, (yyvsp[(5) - (6)].interm.fieldList));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 141:
</del><ins>+  case 188:
</ins><span class="cx"> 
</span><span class="cx">     { if (context-&gt;enterStructDeclaration((yylsp[(2) - (2)]), *(yyvsp[(2) - (2)].lex).string)) context-&gt;recover(); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 142:
</del><ins>+  case 189:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        TType* structure = new TType(new TStructure(NewPoolTString(&quot;&quot;), (yyvsp[(4) - (5)].interm.fieldList)));
-        (yyval.interm.type).setBasic(EbtStruct, EvqTemporary, (yylsp[(1) - (5)]));
-        (yyval.interm.type).userDef = structure;
-        context-&gt;exitStructDeclaration();
</del><ins>+        (yyval.interm.type) = context-&gt;addStructure((yylsp[(1) - (5)]), (yyloc), NewPoolTString(&quot;&quot;), (yyvsp[(4) - (5)].interm.fieldList));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 143:
</del><ins>+  case 190:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.fieldList) = (yyvsp[(1) - (1)].interm.fieldList);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 144:
</del><ins>+  case 191:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.fieldList) = (yyvsp[(1) - (2)].interm.fieldList);
</span><span class="lines">@@ -4078,41 +4472,24 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 145:
</del><ins>+  case 192:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        (yyval.interm.fieldList) = (yyvsp[(2) - (3)].interm.fieldList);
</del><ins>+        (yyval.interm.fieldList) = context-&gt;addStructDeclaratorList((yyvsp[(1) - (3)].interm.type), (yyvsp[(2) - (3)].interm.fieldList));
+    }
+    break;
</ins><span class="cx"> 
</span><del>-        if (context-&gt;voidErrorCheck((yylsp[(1) - (3)]), (*(yyvsp[(2) - (3)].interm.fieldList))[0]-&gt;name(), (yyvsp[(1) - (3)].interm.type))) {
-            context-&gt;recover();
-        }
-        for (unsigned int i = 0; i &lt; (yyval.interm.fieldList)-&gt;size(); ++i) {
-            //
-            // Careful not to replace already known aspects of type, like array-ness
-            //
-            TType* type = (*(yyval.interm.fieldList))[i]-&gt;type();
-            type-&gt;setBasicType((yyvsp[(1) - (3)].interm.type).type);
-            type-&gt;setNominalSize((yyvsp[(1) - (3)].interm.type).size);
-            type-&gt;setMatrix((yyvsp[(1) - (3)].interm.type).matrix);
-            type-&gt;setPrecision((yyvsp[(1) - (3)].interm.type).precision);
</del><ins>+  case 193:
</ins><span class="cx"> 
</span><del>-            // don't allow arrays of arrays
-            if (type-&gt;isArray()) {
-                if (context-&gt;arrayTypeErrorCheck((yylsp[(1) - (3)]), (yyvsp[(1) - (3)].interm.type)))
-                    context-&gt;recover();
-            }
-            if ((yyvsp[(1) - (3)].interm.type).array)
-                type-&gt;setArraySize((yyvsp[(1) - (3)].interm.type).arraySize);
-            if ((yyvsp[(1) - (3)].interm.type).userDef)
-                type-&gt;setStruct((yyvsp[(1) - (3)].interm.type).userDef-&gt;getStruct());
-
-            if (context-&gt;structNestingErrorCheck((yylsp[(1) - (3)]), *(*(yyval.interm.fieldList))[i]))
-                context-&gt;recover();
-        }
</del><ins>+    {
+        // ES3 Only, but errors should be handled elsewhere
+        (yyvsp[(2) - (4)].interm.type).qualifier = (yyvsp[(1) - (4)].interm.type).qualifier;
+        (yyvsp[(2) - (4)].interm.type).layoutQualifier = (yyvsp[(1) - (4)].interm.type).layoutQualifier;
+        (yyval.interm.fieldList) = context-&gt;addStructDeclaratorList((yyvsp[(2) - (4)].interm.type), (yyvsp[(3) - (4)].interm.fieldList));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 146:
</del><ins>+  case 194:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.fieldList) = NewPoolTFieldList();
</span><span class="lines">@@ -4120,101 +4497,101 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 147:
</del><ins>+  case 195:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.fieldList)-&gt;push_back((yyvsp[(3) - (3)].interm.field));
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 148:
</del><ins>+  case 196:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;reservedErrorCheck((yylsp[(1) - (1)]), *(yyvsp[(1) - (1)].lex).string))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx"> 
</span><span class="cx">         TType* type = new TType(EbtVoid, EbpUndefined);
</span><del>-        (yyval.interm.field) = new TField(type, (yyvsp[(1) - (1)].lex).string);
</del><ins>+        (yyval.interm.field) = new TField(type, (yyvsp[(1) - (1)].lex).string, (yylsp[(1) - (1)]));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 149:
</del><ins>+  case 197:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;reservedErrorCheck((yylsp[(1) - (4)]), *(yyvsp[(1) - (4)].lex).string))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx"> 
</span><span class="cx">         TType* type = new TType(EbtVoid, EbpUndefined);
</span><del>-        int size = 0;
</del><ins>+        int size;
</ins><span class="cx">         if (context-&gt;arraySizeErrorCheck((yylsp[(3) - (4)]), (yyvsp[(3) - (4)].interm.intermTypedNode), size))
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         type-&gt;setArraySize(size);
</span><span class="cx"> 
</span><del>-        (yyval.interm.field) = new TField(type, (yyvsp[(1) - (4)].lex).string);
</del><ins>+        (yyval.interm.field) = new TField(type, (yyvsp[(1) - (4)].lex).string, (yylsp[(1) - (4)]));
</ins><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 150:
</del><ins>+  case 198:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 151:
</del><ins>+  case 199:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 152:
</del><ins>+  case 200:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermAggregate); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 153:
</del><ins>+  case 201:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 154:
</del><ins>+  case 202:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 155:
</del><ins>+  case 203:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 156:
</del><ins>+  case 204:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 157:
</del><ins>+  case 205:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 158:
</del><ins>+  case 206:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 159:
</del><ins>+  case 207:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermAggregate) = 0; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 160:
</del><ins>+  case 208:
</ins><span class="cx"> 
</span><span class="cx">     { context-&gt;symbolTable.push(); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 161:
</del><ins>+  case 209:
</ins><span class="cx"> 
</span><span class="cx">     { context-&gt;symbolTable.pop(); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 162:
</del><ins>+  case 210:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if ((yyvsp[(3) - (5)].interm.intermAggregate) != 0) {
</span><span class="lines">@@ -4225,44 +4602,44 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 163:
</del><ins>+  case 211:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 164:
</del><ins>+  case 212:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 165:
</del><ins>+  case 213:
</ins><span class="cx"> 
</span><span class="cx">     { context-&gt;symbolTable.push(); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 166:
</del><ins>+  case 214:
</ins><span class="cx"> 
</span><span class="cx">     { context-&gt;symbolTable.pop(); (yyval.interm.intermNode) = (yyvsp[(2) - (2)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 167:
</del><ins>+  case 215:
</ins><span class="cx"> 
</span><span class="cx">     { context-&gt;symbolTable.push(); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 168:
</del><ins>+  case 216:
</ins><span class="cx"> 
</span><span class="cx">     { context-&gt;symbolTable.pop(); (yyval.interm.intermNode) = (yyvsp[(2) - (2)].interm.intermNode); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 169:
</del><ins>+  case 217:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermNode) = 0;
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 170:
</del><ins>+  case 218:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if ((yyvsp[(2) - (3)].interm.intermAggregate)) {
</span><span class="lines">@@ -4273,31 +4650,31 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 171:
</del><ins>+  case 219:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermAggregate) = context-&gt;intermediate.makeAggregate((yyvsp[(1) - (1)].interm.intermNode), (yyloc));
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 172:
</del><ins>+  case 220:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermAggregate) = context-&gt;intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermAggregate), (yyvsp[(2) - (2)].interm.intermNode), (yyloc));
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 173:
</del><ins>+  case 221:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = 0; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 174:
</del><ins>+  case 222:
</ins><span class="cx"> 
</span><span class="cx">     { (yyval.interm.intermNode) = static_cast&lt;TIntermNode*&gt;((yyvsp[(1) - (2)].interm.intermTypedNode)); }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 175:
</del><ins>+  case 223:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;boolErrorCheck((yylsp[(1) - (5)]), (yyvsp[(3) - (5)].interm.intermTypedNode)))
</span><span class="lines">@@ -4306,7 +4683,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 176:
</del><ins>+  case 224:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.nodePair).node1 = (yyvsp[(1) - (3)].interm.intermNode);
</span><span class="lines">@@ -4314,7 +4691,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 177:
</del><ins>+  case 225:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.nodePair).node1 = (yyvsp[(1) - (1)].interm.intermNode);
</span><span class="lines">@@ -4322,7 +4699,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 178:
</del><ins>+  case 226:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode);
</span><span class="lines">@@ -4331,7 +4708,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 179:
</del><ins>+  case 227:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TIntermNode* intermNode;
</span><span class="lines">@@ -4349,12 +4726,12 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 180:
</del><ins>+  case 228:
</ins><span class="cx"> 
</span><span class="cx">     { context-&gt;symbolTable.push(); ++context-&gt;loopNestingLevel; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 181:
</del><ins>+  case 229:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         context-&gt;symbolTable.pop();
</span><span class="lines">@@ -4363,12 +4740,12 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 182:
</del><ins>+  case 230:
</ins><span class="cx"> 
</span><span class="cx">     { ++context-&gt;loopNestingLevel; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 183:
</del><ins>+  case 231:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;boolErrorCheck((yylsp[(8) - (8)]), (yyvsp[(6) - (8)].interm.intermTypedNode)))
</span><span class="lines">@@ -4379,12 +4756,12 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 184:
</del><ins>+  case 232:
</ins><span class="cx"> 
</span><span class="cx">     { context-&gt;symbolTable.push(); ++context-&gt;loopNestingLevel; }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 185:
</del><ins>+  case 233:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         context-&gt;symbolTable.pop();
</span><span class="lines">@@ -4393,35 +4770,35 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 186:
</del><ins>+  case 234:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 187:
</del><ins>+  case 235:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 188:
</del><ins>+  case 236:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 189:
</del><ins>+  case 237:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermTypedNode) = 0;
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 190:
</del><ins>+  case 238:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.nodePair).node1 = (yyvsp[(1) - (2)].interm.intermTypedNode);
</span><span class="lines">@@ -4429,7 +4806,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 191:
</del><ins>+  case 239:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.nodePair).node1 = (yyvsp[(1) - (3)].interm.intermTypedNode);
</span><span class="lines">@@ -4437,7 +4814,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 192:
</del><ins>+  case 240:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;loopNestingLevel &lt;= 0) {
</span><span class="lines">@@ -4448,7 +4825,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 193:
</del><ins>+  case 241:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         if (context-&gt;loopNestingLevel &lt;= 0) {
</span><span class="lines">@@ -4459,7 +4836,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 194:
</del><ins>+  case 242:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermNode) = context-&gt;intermediate.addBranch(EOpReturn, (yylsp[(1) - (2)]));
</span><span class="lines">@@ -4470,7 +4847,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 195:
</del><ins>+  case 243:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermNode) = context-&gt;intermediate.addBranch(EOpReturn, (yyvsp[(2) - (3)].interm.intermTypedNode), (yylsp[(1) - (3)]));
</span><span class="lines">@@ -4485,7 +4862,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 196:
</del><ins>+  case 244:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         FRAG_ONLY(&quot;discard&quot;, (yylsp[(1) - (2)]));
</span><span class="lines">@@ -4493,7 +4870,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 197:
</del><ins>+  case 245:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
</span><span class="lines">@@ -4501,7 +4878,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 198:
</del><ins>+  case 246:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermNode) = context-&gt;intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermNode), (yyvsp[(2) - (2)].interm.intermNode), (yyloc));
</span><span class="lines">@@ -4509,26 +4886,26 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 199:
</del><ins>+  case 247:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 200:
</del><ins>+  case 248:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 201:
</del><ins>+  case 249:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         TFunction* function = (yyvsp[(1) - (1)].interm).function;
</span><span class="cx">         
</span><del>-        const TSymbol *builtIn = context-&gt;symbolTable.findBuiltIn(function-&gt;getMangledName());
</del><ins>+        const TSymbol *builtIn = context-&gt;symbolTable.findBuiltIn(function-&gt;getMangledName(), context-&gt;shaderVersion);
</ins><span class="cx">         
</span><span class="cx">         if (builtIn)
</span><span class="cx">         {
</span><span class="lines">@@ -4536,7 +4913,7 @@
</span><span class="cx">             context-&gt;recover();
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        TFunction* prevDec = static_cast&lt;TFunction*&gt;(context-&gt;symbolTable.find(function-&gt;getMangledName()));
</del><ins>+        TFunction* prevDec = static_cast&lt;TFunction*&gt;(context-&gt;symbolTable.find(function-&gt;getMangledName(), context-&gt;shaderVersion));
</ins><span class="cx">         //
</span><span class="cx">         // Note:  'prevDec' could be 'function' if this is the first time we've seen function
</span><span class="cx">         // as it would have just been put in the symbol table.  Otherwise, we're looking up
</span><span class="lines">@@ -4587,7 +4964,7 @@
</span><span class="cx">                 //
</span><span class="cx">                 // Insert the parameters with name in the symbol table.
</span><span class="cx">                 //
</span><del>-                if (! context-&gt;symbolTable.insert(*variable)) {
</del><ins>+                if (! context-&gt;symbolTable.declare(*variable)) {
</ins><span class="cx">                     context-&gt;error((yylsp[(1) - (1)]), &quot;redefinition&quot;, variable-&gt;getName().c_str());
</span><span class="cx">                     context-&gt;recover();
</span><span class="cx">                     delete variable;
</span><span class="lines">@@ -4599,9 +4976,8 @@
</span><span class="cx">                 paramNodes = context-&gt;intermediate.growAggregate(
</span><span class="cx">                                                paramNodes,
</span><span class="cx">                                                context-&gt;intermediate.addSymbol(variable-&gt;getUniqueId(),
</span><del>-                                                                               variable-&gt;getName(),
-                                                                               variable-&gt;getType(),
-                                                                               (yylsp[(1) - (1)])),
</del><ins>+                                                                       variable-&gt;getName(),
+                                                                       variable-&gt;getType(), (yylsp[(1) - (1)])),
</ins><span class="cx">                                                (yylsp[(1) - (1)]));
</span><span class="cx">             } else {
</span><span class="cx">                 paramNodes = context-&gt;intermediate.growAggregate(paramNodes, context-&gt;intermediate.addSymbol(0, &quot;&quot;, *param.type, (yylsp[(1) - (1)])), (yylsp[(1) - (1)]));
</span><span class="lines">@@ -4613,7 +4989,7 @@
</span><span class="cx">     }
</span><span class="cx">     break;
</span><span class="cx"> 
</span><del>-  case 202:
</del><ins>+  case 250:
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         //?? Check that all paths return a value if return type != void ?
</span><span class="lines">@@ -4729,21 +5105,21 @@
</span><span class="cx">   if (yyerrstatus == 3)
</span><span class="cx">     {
</span><span class="cx">       /* If just tried and failed to reuse lookahead token after an
</span><del>-     error, discard it.  */
</del><ins>+         error, discard it.  */
</ins><span class="cx"> 
</span><span class="cx">       if (yychar &lt;= YYEOF)
</span><del>-    {
-      /* Return failure if at end of input.  */
-      if (yychar == YYEOF)
-        YYABORT;
-    }
</del><ins>+        {
+          /* Return failure if at end of input.  */
+          if (yychar == YYEOF)
+            YYABORT;
+        }
</ins><span class="cx">       else
</span><del>-    {
-      yydestruct (&quot;Error: discarding&quot;,
-              yytoken, &amp;yylval, &amp;yylloc, context);
-      yychar = YYEMPTY;
</del><ins>+        {
+          yydestruct (&quot;Error: discarding&quot;,
+                      yytoken, &amp;yylval, &amp;yylloc, context);
+          yychar = YYEMPTY;
+        }
</ins><span class="cx">     }
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">   /* Else will try to reuse lookahead token after shifting the error
</span><span class="cx">      token.  */
</span><span class="lines">@@ -4775,29 +5151,29 @@
</span><span class="cx"> | yyerrlab1 -- common code for both syntax error and YYERROR.  |
</span><span class="cx"> `-------------------------------------------------------------*/
</span><span class="cx"> yyerrlab1:
</span><del>-  yyerrstatus = 3;  /* Each real token shifted decrements this.  */
</del><ins>+  yyerrstatus = 3;        /* Each real token shifted decrements this.  */
</ins><span class="cx"> 
</span><span class="cx">   for (;;)
</span><span class="cx">     {
</span><span class="cx">       yyn = yypact[yystate];
</span><span class="cx">       if (!yypact_value_is_default (yyn))
</span><del>-    {
-      yyn += YYTERROR;
-      if (0 &lt;= yyn &amp;&amp; yyn &lt;= YYLAST &amp;&amp; yycheck[yyn] == YYTERROR)
-        {
-          yyn = yytable[yyn];
-          if (0 &lt; yyn)
-        break;
-        }
-    }
</del><ins>+        {
+          yyn += YYTERROR;
+          if (0 &lt;= yyn &amp;&amp; yyn &lt;= YYLAST &amp;&amp; yycheck[yyn] == YYTERROR)
+            {
+              yyn = yytable[yyn];
+              if (0 &lt; yyn)
+                break;
+            }
+        }
</ins><span class="cx"> 
</span><span class="cx">       /* Pop the current state because it cannot handle the error token.  */
</span><span class="cx">       if (yyssp == yyss)
</span><del>-    YYABORT;
</del><ins>+        YYABORT;
</ins><span class="cx"> 
</span><span class="cx">       yyerror_range[1] = *yylsp;
</span><span class="cx">       yydestruct (&quot;Error: popping&quot;,
</span><del>-          yystos[yystate], yyvsp, yylsp, context);
</del><ins>+                  yystos[yystate], yyvsp, yylsp, context);
</ins><span class="cx">       YYPOPSTACK (1);
</span><span class="cx">       yystate = *yyssp;
</span><span class="cx">       YY_STACK_PRINT (yyss, yyssp);
</span><span class="lines">@@ -4860,7 +5236,7 @@
</span><span class="cx">   while (yyssp != yyss)
</span><span class="cx">     {
</span><span class="cx">       yydestruct (&quot;Cleanup: popping&quot;,
</span><del>-          yystos[*yyssp], yyvsp, yylsp, context);
</del><ins>+                  yystos[*yyssp], yyvsp, yylsp, context);
</ins><span class="cx">       YYPOPSTACK (1);
</span><span class="cx">     }
</span><span class="cx"> #ifndef yyoverflow
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorglslang_tabh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -46,7 +46,6 @@
</span><span class="cx"> 
</span><span class="cx"> #define YYLTYPE TSourceLoc
</span><span class="cx"> #define YYLTYPE_IS_DECLARED 1
</span><del>-#define SH_MAX_TOKEN_LENGTH 256  // WebGL spec.
</del><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -67,88 +66,121 @@
</span><span class="cx">      BOOL_TYPE = 265,
</span><span class="cx">      FLOAT_TYPE = 266,
</span><span class="cx">      INT_TYPE = 267,
</span><del>-     BREAK = 268,
-     CONTINUE = 269,
-     DO = 270,
-     ELSE = 271,
-     FOR = 272,
-     IF = 273,
-     DISCARD = 274,
-     RETURN = 275,
-     BVEC2 = 276,
-     BVEC3 = 277,
-     BVEC4 = 278,
-     IVEC2 = 279,
-     IVEC3 = 280,
-     IVEC4 = 281,
-     VEC2 = 282,
-     VEC3 = 283,
-     VEC4 = 284,
-     MATRIX2 = 285,
-     MATRIX3 = 286,
-     MATRIX4 = 287,
-     IN_QUAL = 288,
-     OUT_QUAL = 289,
-     INOUT_QUAL = 290,
-     UNIFORM = 291,
-     VARYING = 292,
-     STRUCT = 293,
-     VOID_TYPE = 294,
-     WHILE = 295,
-     SAMPLER2D = 296,
-     SAMPLERCUBE = 297,
-     SAMPLER_EXTERNAL_OES = 298,
-     SAMPLER2DRECT = 299,
-     IDENTIFIER = 300,
-     TYPE_NAME = 301,
-     FLOATCONSTANT = 302,
-     INTCONSTANT = 303,
-     BOOLCONSTANT = 304,
-     LEFT_OP = 305,
-     RIGHT_OP = 306,
-     INC_OP = 307,
-     DEC_OP = 308,
-     LE_OP = 309,
-     GE_OP = 310,
-     EQ_OP = 311,
-     NE_OP = 312,
-     AND_OP = 313,
-     OR_OP = 314,
-     XOR_OP = 315,
-     MUL_ASSIGN = 316,
-     DIV_ASSIGN = 317,
-     ADD_ASSIGN = 318,
-     MOD_ASSIGN = 319,
-     LEFT_ASSIGN = 320,
-     RIGHT_ASSIGN = 321,
-     AND_ASSIGN = 322,
-     XOR_ASSIGN = 323,
-     OR_ASSIGN = 324,
-     SUB_ASSIGN = 325,
-     LEFT_PAREN = 326,
-     RIGHT_PAREN = 327,
-     LEFT_BRACKET = 328,
-     RIGHT_BRACKET = 329,
-     LEFT_BRACE = 330,
-     RIGHT_BRACE = 331,
-     DOT = 332,
-     COMMA = 333,
-     COLON = 334,
-     EQUAL = 335,
-     SEMICOLON = 336,
-     BANG = 337,
-     DASH = 338,
-     TILDE = 339,
-     PLUS = 340,
-     STAR = 341,
-     SLASH = 342,
-     PERCENT = 343,
-     LEFT_ANGLE = 344,
-     RIGHT_ANGLE = 345,
-     VERTICAL_BAR = 346,
-     CARET = 347,
-     AMPERSAND = 348,
-     QUESTION = 349
</del><ins>+     UINT_TYPE = 268,
+     BREAK = 269,
+     CONTINUE = 270,
+     DO = 271,
+     ELSE = 272,
+     FOR = 273,
+     IF = 274,
+     DISCARD = 275,
+     RETURN = 276,
+     SWITCH = 277,
+     CASE = 278,
+     DEFAULT = 279,
+     BVEC2 = 280,
+     BVEC3 = 281,
+     BVEC4 = 282,
+     IVEC2 = 283,
+     IVEC3 = 284,
+     IVEC4 = 285,
+     VEC2 = 286,
+     VEC3 = 287,
+     VEC4 = 288,
+     UVEC2 = 289,
+     UVEC3 = 290,
+     UVEC4 = 291,
+     MATRIX2 = 292,
+     MATRIX3 = 293,
+     MATRIX4 = 294,
+     IN_QUAL = 295,
+     OUT_QUAL = 296,
+     INOUT_QUAL = 297,
+     UNIFORM = 298,
+     VARYING = 299,
+     MATRIX2x3 = 300,
+     MATRIX3x2 = 301,
+     MATRIX2x4 = 302,
+     MATRIX4x2 = 303,
+     MATRIX3x4 = 304,
+     MATRIX4x3 = 305,
+     CENTROID = 306,
+     FLAT = 307,
+     SMOOTH = 308,
+     STRUCT = 309,
+     VOID_TYPE = 310,
+     WHILE = 311,
+     SAMPLER2D = 312,
+     SAMPLERCUBE = 313,
+     SAMPLER_EXTERNAL_OES = 314,
+     SAMPLER2DRECT = 315,
+     SAMPLER2DARRAY = 316,
+     ISAMPLER2D = 317,
+     ISAMPLER3D = 318,
+     ISAMPLERCUBE = 319,
+     ISAMPLER2DARRAY = 320,
+     USAMPLER2D = 321,
+     USAMPLER3D = 322,
+     USAMPLERCUBE = 323,
+     USAMPLER2DARRAY = 324,
+     SAMPLER3D = 325,
+     SAMPLER3DRECT = 326,
+     SAMPLER2DSHADOW = 327,
+     SAMPLERCUBESHADOW = 328,
+     SAMPLER2DARRAYSHADOW = 329,
+     LAYOUT = 330,
+     IDENTIFIER = 331,
+     TYPE_NAME = 332,
+     FLOATCONSTANT = 333,
+     INTCONSTANT = 334,
+     UINTCONSTANT = 335,
+     BOOLCONSTANT = 336,
+     FIELD_SELECTION = 337,
+     LEFT_OP = 338,
+     RIGHT_OP = 339,
+     INC_OP = 340,
+     DEC_OP = 341,
+     LE_OP = 342,
+     GE_OP = 343,
+     EQ_OP = 344,
+     NE_OP = 345,
+     AND_OP = 346,
+     OR_OP = 347,
+     XOR_OP = 348,
+     MUL_ASSIGN = 349,
+     DIV_ASSIGN = 350,
+     ADD_ASSIGN = 351,
+     MOD_ASSIGN = 352,
+     LEFT_ASSIGN = 353,
+     RIGHT_ASSIGN = 354,
+     AND_ASSIGN = 355,
+     XOR_ASSIGN = 356,
+     OR_ASSIGN = 357,
+     SUB_ASSIGN = 358,
+     LEFT_PAREN = 359,
+     RIGHT_PAREN = 360,
+     LEFT_BRACKET = 361,
+     RIGHT_BRACKET = 362,
+     LEFT_BRACE = 363,
+     RIGHT_BRACE = 364,
+     DOT = 365,
+     COMMA = 366,
+     COLON = 367,
+     EQUAL = 368,
+     SEMICOLON = 369,
+     BANG = 370,
+     DASH = 371,
+     TILDE = 372,
+     PLUS = 373,
+     STAR = 374,
+     SLASH = 375,
+     PERCENT = 376,
+     LEFT_ANGLE = 377,
+     RIGHT_ANGLE = 378,
+     VERTICAL_BAR = 379,
+     CARET = 380,
+     AMPERSAND = 381,
+     QUESTION = 382
</ins><span class="cx">    };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -163,6 +195,7 @@
</span><span class="cx">             TString *string;
</span><span class="cx">             float f;
</span><span class="cx">             int i;
</span><ins>+            unsigned int u;
</ins><span class="cx">             bool b;
</span><span class="cx">         };
</span><span class="cx">         TSymbol* symbol;
</span><span class="lines">@@ -178,6 +211,7 @@
</span><span class="cx">         union {
</span><span class="cx">             TPublicType type;
</span><span class="cx">             TPrecision precision;
</span><ins>+            TLayoutQualifier layoutQualifier;
</ins><span class="cx">             TQualifier qualifier;
</span><span class="cx">             TFunction* function;
</span><span class="cx">             TParameter param;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorintermOutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermOut.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermOut.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermOut.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,10 +1,11 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="cx"> 
</span><span class="cx"> #include &quot;compiler/translator/localintermediate.h&quot;
</span><ins>+#include &quot;compiler/translator/SymbolTable.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> //
</span><span class="cx"> // Two purposes:
</span><span class="lines">@@ -43,10 +44,10 @@
</span><span class="cx">         stream &lt;&lt; getQualifierString() &lt;&lt; &quot; &quot; &lt;&lt; getPrecisionString() &lt;&lt; &quot; &quot;;
</span><span class="cx">     if (array)
</span><span class="cx">         stream &lt;&lt; &quot;array[&quot; &lt;&lt; getArraySize() &lt;&lt; &quot;] of &quot;;
</span><del>-    if (matrix)
-        stream &lt;&lt; static_cast&lt;int&gt;(size) &lt;&lt; &quot;X&quot; &lt;&lt; static_cast&lt;int&gt;(size) &lt;&lt; &quot; matrix of &quot;;
-    else if (size &gt; 1)
-        stream &lt;&lt; static_cast&lt;int&gt;(size) &lt;&lt; &quot;-component vector of &quot;;
</del><ins>+    if (isMatrix())
+        stream &lt;&lt; getCols() &lt;&lt; &quot;X&quot; &lt;&lt; getRows() &lt;&lt; &quot; matrix of &quot;;
+    else if (isVector())
+        stream &lt;&lt; getNominalSize() &lt;&lt; &quot;-component vector of &quot;;
</ins><span class="cx"> 
</span><span class="cx">     stream &lt;&lt; getBasicString();
</span><span class="cx">     return stream.str();
</span><span class="lines">@@ -103,6 +104,7 @@
</span><span class="cx">         case EOpIndexDirect:   out &lt;&lt; &quot;direct index&quot;;   break;
</span><span class="cx">         case EOpIndexIndirect: out &lt;&lt; &quot;indirect index&quot;; break;
</span><span class="cx">         case EOpIndexDirectStruct:   out &lt;&lt; &quot;direct index for structure&quot;;   break;
</span><ins>+        case EOpIndexDirectInterfaceBlock: out &lt;&lt; &quot;direct index for interface block&quot;; break;
</ins><span class="cx">         case EOpVectorSwizzle: out &lt;&lt; &quot;vector swizzle&quot;; break;
</span><span class="cx"> 
</span><span class="cx">         case EOpAdd:    out &lt;&lt; &quot;add&quot;;                     break;
</span><span class="lines">@@ -152,11 +154,16 @@
</span><span class="cx">         case EOpPreDecrement:   out &lt;&lt; &quot;Pre-Decrement&quot;;        break;
</span><span class="cx"> 
</span><span class="cx">         case EOpConvIntToBool:  out &lt;&lt; &quot;Convert int to bool&quot;;  break;
</span><ins>+        case EOpConvUIntToBool: out &lt;&lt; &quot;Convert uint to bool&quot;; break;
</ins><span class="cx">         case EOpConvFloatToBool:out &lt;&lt; &quot;Convert float to bool&quot;;break;
</span><span class="cx">         case EOpConvBoolToFloat:out &lt;&lt; &quot;Convert bool to float&quot;;break;
</span><span class="cx">         case EOpConvIntToFloat: out &lt;&lt; &quot;Convert int to float&quot;; break;
</span><ins>+        case EOpConvUIntToFloat:out &lt;&lt; &quot;Convert uint to float&quot;;break;
</ins><span class="cx">         case EOpConvFloatToInt: out &lt;&lt; &quot;Convert float to int&quot;; break;
</span><span class="cx">         case EOpConvBoolToInt:  out &lt;&lt; &quot;Convert bool to int&quot;;  break;
</span><ins>+        case EOpConvIntToUInt:  out &lt;&lt; &quot;Convert int to uint&quot;;  break;
+        case EOpConvFloatToUInt:out &lt;&lt; &quot;Convert float to uint&quot;;break;
+        case EOpConvBoolToUInt: out &lt;&lt; &quot;Convert bool to uint&quot;; break;
</ins><span class="cx"> 
</span><span class="cx">         case EOpRadians:        out &lt;&lt; &quot;radians&quot;;              break;
</span><span class="cx">         case EOpDegrees:        out &lt;&lt; &quot;degrees&quot;;              break;
</span><span class="lines">@@ -182,9 +189,9 @@
</span><span class="cx"> 
</span><span class="cx">         case EOpLength:         out &lt;&lt; &quot;length&quot;;               break;
</span><span class="cx">         case EOpNormalize:      out &lt;&lt; &quot;normalize&quot;;            break;
</span><del>-            //  case EOpDPdx:           out &lt;&lt; &quot;dPdx&quot;;                 break;               
-            //  case EOpDPdy:           out &lt;&lt; &quot;dPdy&quot;;                 break;   
-            //  case EOpFwidth:         out &lt;&lt; &quot;fwidth&quot;;               break;                   
</del><ins>+            //        case EOpDPdx:           out &lt;&lt; &quot;dPdx&quot;;                 break;               
+            //        case EOpDPdy:           out &lt;&lt; &quot;dPdy&quot;;                 break;   
+            //        case EOpFwidth:         out &lt;&lt; &quot;fwidth&quot;;               break;                   
</ins><span class="cx"> 
</span><span class="cx">         case EOpAny:            out &lt;&lt; &quot;any&quot;;                  break;
</span><span class="cx">         case EOpAll:            out &lt;&lt; &quot;all&quot;;                  break;
</span><span class="lines">@@ -232,6 +239,10 @@
</span><span class="cx">         case EOpConstructIVec2: out &lt;&lt; &quot;Construct ivec2&quot;; break;
</span><span class="cx">         case EOpConstructIVec3: out &lt;&lt; &quot;Construct ivec3&quot;; break;
</span><span class="cx">         case EOpConstructIVec4: out &lt;&lt; &quot;Construct ivec4&quot;; break;
</span><ins>+        case EOpConstructUInt:  out &lt;&lt; &quot;Construct uint&quot;;  break;
+        case EOpConstructUVec2: out &lt;&lt; &quot;Construct uvec2&quot;; break;
+        case EOpConstructUVec3: out &lt;&lt; &quot;Construct uvec3&quot;; break;
+        case EOpConstructUVec4: out &lt;&lt; &quot;Construct uvec4&quot;; break;
</ins><span class="cx">         case EOpConstructMat2:  out &lt;&lt; &quot;Construct mat2&quot;;  break;
</span><span class="cx">         case EOpConstructMat3:  out &lt;&lt; &quot;Construct mat3&quot;;  break;
</span><span class="cx">         case EOpConstructMat4:  out &lt;&lt; &quot;Construct mat4&quot;;  break;
</span><span class="lines">@@ -338,6 +349,10 @@
</span><span class="cx">                 out &lt;&lt; node-&gt;getUnionArrayPointer()[i].getIConst();
</span><span class="cx">                 out &lt;&lt; &quot; (const int)\n&quot;;
</span><span class="cx">                 break;
</span><ins>+            case EbtUInt:
+                out &lt;&lt; node-&gt;getUnionArrayPointer()[i].getUConst();
+                out &lt;&lt; &quot; (const uint)\n&quot;;
+                break;
</ins><span class="cx">             default:
</span><span class="cx">                 out.message(EPrefixInternalError, node-&gt;getLine(), &quot;Unknown constant&quot;);
</span><span class="cx">                 break;
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermOut.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorintermediateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermediate.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermediate.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/intermediate.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -19,6 +19,7 @@
</span><span class="cx"> #include &quot;GLSLANG/ShaderLang.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;algorithm&gt;
</span><ins>+#include &lt;queue&gt;
</ins><span class="cx"> #include &quot;compiler/translator/Common.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/Types.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/ConstantUnion.h&quot;
</span><span class="lines">@@ -50,11 +51,17 @@
</span><span class="cx">     EOpPreDecrement,
</span><span class="cx"> 
</span><span class="cx">     EOpConvIntToBool,
</span><ins>+    EOpConvUIntToBool,
</ins><span class="cx">     EOpConvFloatToBool,
</span><span class="cx">     EOpConvBoolToFloat,
</span><span class="cx">     EOpConvIntToFloat,
</span><ins>+    EOpConvUIntToFloat,
</ins><span class="cx">     EOpConvFloatToInt,
</span><span class="cx">     EOpConvBoolToInt,
</span><ins>+    EOpConvUIntToInt,
+    EOpConvIntToUInt,
+    EOpConvFloatToUInt,
+    EOpConvBoolToUInt,
</ins><span class="cx"> 
</span><span class="cx">     //
</span><span class="cx">     // binary operations
</span><span class="lines">@@ -86,6 +93,7 @@
</span><span class="cx">     EOpIndexDirect,
</span><span class="cx">     EOpIndexIndirect,
</span><span class="cx">     EOpIndexDirectStruct,
</span><ins>+    EOpIndexDirectInterfaceBlock,
</ins><span class="cx"> 
</span><span class="cx">     EOpVectorSwizzle,
</span><span class="cx"> 
</span><span class="lines">@@ -155,6 +163,7 @@
</span><span class="cx">     //
</span><span class="cx"> 
</span><span class="cx">     EOpConstructInt,
</span><ins>+    EOpConstructUInt,
</ins><span class="cx">     EOpConstructBool,
</span><span class="cx">     EOpConstructFloat,
</span><span class="cx">     EOpConstructVec2,
</span><span class="lines">@@ -166,6 +175,9 @@
</span><span class="cx">     EOpConstructIVec2,
</span><span class="cx">     EOpConstructIVec3,
</span><span class="cx">     EOpConstructIVec4,
</span><ins>+    EOpConstructUVec2,
+    EOpConstructUVec3,
+    EOpConstructUVec4,
</ins><span class="cx">     EOpConstructMat2,
</span><span class="cx">     EOpConstructMat3,
</span><span class="cx">     EOpConstructMat4,
</span><span class="lines">@@ -232,6 +244,10 @@
</span><span class="cx">     virtual bool replaceChildNode(
</span><span class="cx">         TIntermNode *original, TIntermNode *replacement) = 0;
</span><span class="cx"> 
</span><ins>+    // For traversing a tree in no particular order, but using
+    // heap memory.
+    virtual void enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const = 0;
+
</ins><span class="cx"> protected:
</span><span class="cx">     TSourceLoc line;
</span><span class="cx"> };
</span><span class="lines">@@ -261,18 +277,21 @@
</span><span class="cx">     TBasicType getBasicType() const { return type.getBasicType(); }
</span><span class="cx">     TQualifier getQualifier() const { return type.getQualifier(); }
</span><span class="cx">     TPrecision getPrecision() const { return type.getPrecision(); }
</span><ins>+    int getCols() const { return type.getCols(); }
+    int getRows() const { return type.getRows(); }
</ins><span class="cx">     int getNominalSize() const { return type.getNominalSize(); }
</span><ins>+    int getSecondarySize() const { return type.getSecondarySize(); }
</ins><span class="cx">     
</span><ins>+    bool isInterfaceBlock() const { return type.isInterfaceBlock(); }
</ins><span class="cx">     bool isMatrix() const { return type.isMatrix(); }
</span><span class="cx">     bool isArray()  const { return type.isArray(); }
</span><span class="cx">     bool isVector() const { return type.isVector(); }
</span><span class="cx">     bool isScalar() const { return type.isScalar(); }
</span><ins>+    bool isScalarInt() const { return type.isScalarInt(); }
</ins><span class="cx">     const char* getBasicString() const { return type.getBasicString(); }
</span><span class="cx">     const char* getQualifierString() const { return type.getQualifierString(); }
</span><span class="cx">     TString getCompleteString() const { return type.getCompleteString(); }
</span><span class="cx"> 
</span><del>-    int totalRegisterCount() const { return type.totalRegisterCount(); }
-    int elementRegisterCount() const { return type.elementRegisterCount(); }
</del><span class="cx">     int getArraySize() const { return type.getArraySize(); }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="lines">@@ -314,6 +333,8 @@
</span><span class="cx">     void setUnrollFlag(bool flag) { unrollFlag = flag; }
</span><span class="cx">     bool getUnrollFlag() { return unrollFlag; }
</span><span class="cx"> 
</span><ins>+    virtual void enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     TLoopType type;
</span><span class="cx">     TIntermNode* init;  // for-loop initialization
</span><span class="lines">@@ -340,6 +361,8 @@
</span><span class="cx">     TOperator getFlowOp() { return flowOp; }
</span><span class="cx">     TIntermTyped* getExpression() { return expression; }
</span><span class="cx"> 
</span><ins>+    virtual void enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     TOperator flowOp;
</span><span class="cx">     TIntermTyped* expression;  // non-zero except for &quot;return exp;&quot; statements
</span><span class="lines">@@ -354,7 +377,7 @@
</span><span class="cx">     // per process globalpoolallocator, then it causes increased memory usage per compile
</span><span class="cx">     // it is essential to use &quot;symbol = sym&quot; to assign to symbol
</span><span class="cx">     TIntermSymbol(int i, const TString&amp; sym, const TType&amp; t) : 
</span><del>-            TIntermTyped(t), id(i)  { symbol = sym; originalSymbol = sym; } 
</del><ins>+        TIntermTyped(t), id(i)  { symbol = sym; }
</ins><span class="cx"> 
</span><span class="cx">     virtual bool hasSideEffects() const { return false; }
</span><span class="cx"> 
</span><span class="lines">@@ -362,18 +385,16 @@
</span><span class="cx">     const TString&amp; getSymbol() const { return symbol; }
</span><span class="cx"> 
</span><span class="cx">     void setId(int newId) { id = newId; }
</span><del>-    void setSymbol(const TString&amp; sym) { symbol = sym; }
</del><span class="cx"> 
</span><del>-    const TString&amp; getOriginalSymbol() const { return originalSymbol; }
-
</del><span class="cx">     virtual void traverse(TIntermTraverser*);
</span><span class="cx">     virtual TIntermSymbol* getAsSymbolNode() { return this; }
</span><span class="cx">     virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
</span><span class="cx"> 
</span><ins>+    virtual void enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const {}
+
</ins><span class="cx"> protected:
</span><span class="cx">     int id;
</span><span class="cx">     TString symbol;
</span><del>-    TString originalSymbol;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class TIntermConstantUnion : public TIntermTyped {
</span><span class="lines">@@ -385,6 +406,7 @@
</span><span class="cx">     ConstantUnion* getUnionArrayPointer() const { return unionArrayPointer; }
</span><span class="cx">     
</span><span class="cx">     int getIConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getIConst() : 0; }
</span><ins>+    unsigned int getUConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getUConst() : 0; }
</ins><span class="cx">     float getFConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getFConst() : 0.0f; }
</span><span class="cx">     bool getBConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getBConst() : false; }
</span><span class="cx"> 
</span><span class="lines">@@ -394,6 +416,8 @@
</span><span class="cx"> 
</span><span class="cx">     TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&amp;);
</span><span class="cx"> 
</span><ins>+    virtual void enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const {}
+
</ins><span class="cx"> protected:
</span><span class="cx">     ConstantUnion *unionArrayPointer;
</span><span class="cx"> };
</span><span class="lines">@@ -440,6 +464,8 @@
</span><span class="cx">     void setAddIndexClamp() { addIndexClamp = true; }
</span><span class="cx">     bool getAddIndexClamp() { return addIndexClamp; }
</span><span class="cx"> 
</span><ins>+    virtual void enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     TIntermTyped* left;
</span><span class="cx">     TIntermTyped* right;
</span><span class="lines">@@ -470,6 +496,8 @@
</span><span class="cx">     void setUseEmulatedFunction() { useEmulatedFunction = true; }
</span><span class="cx">     bool getUseEmulatedFunction() { return useEmulatedFunction; }
</span><span class="cx"> 
</span><ins>+    virtual void enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     TIntermTyped* operand;
</span><span class="cx"> 
</span><span class="lines">@@ -514,6 +542,8 @@
</span><span class="cx">     void setUseEmulatedFunction() { useEmulatedFunction = true; }
</span><span class="cx">     bool getUseEmulatedFunction() { return useEmulatedFunction; }
</span><span class="cx"> 
</span><ins>+    virtual void enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     TIntermAggregate(const TIntermAggregate&amp;); // disallow copy constructor
</span><span class="cx">     TIntermAggregate&amp; operator=(const TIntermAggregate&amp;); // disallow assignment operator
</span><span class="lines">@@ -552,6 +582,8 @@
</span><span class="cx">     TIntermNode* getFalseBlock() const { return falseBlock; }
</span><span class="cx">     TIntermSelection* getAsSelectionNode() { return this; }
</span><span class="cx"> 
</span><ins>+    virtual void enqueueChildren(std::queue&lt;TIntermNode*&gt; *nodeQueue) const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     TIntermTyped* condition;
</span><span class="cx">     TIntermNode* trueBlock;
</span><span class="lines">@@ -632,4 +664,30 @@
</span><span class="cx">     TVector&lt;TIntermNode *&gt; path;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+//
+// For traversing the tree, and computing max depth.
+// Takes a maximum depth limit to prevent stack overflow.
+//
+class TMaxDepthTraverser : public TIntermTraverser
+{
+public:
+    POOL_ALLOCATOR_NEW_DELETE();
+    TMaxDepthTraverser(int depthLimit)
+      : TIntermTraverser(true, true, false, false),
+        depthLimit(depthLimit)
+    {}
+
+    virtual bool visitBinary(Visit visit, TIntermBinary*) { return depthCheck(); }
+    virtual bool visitUnary(Visit visit, TIntermUnary*) { return depthCheck(); }
+    virtual bool visitSelection(Visit visit, TIntermSelection*) { return depthCheck(); }
+    virtual bool visitAggregate(Visit visit, TIntermAggregate*) { return depthCheck(); }
+    virtual bool visitLoop(Visit visit, TIntermLoop*) { return depthCheck(); }
+    virtual bool visitBranch(Visit visit, TIntermBranch*) { return depthCheck(); }
+
+protected:
+    int depthLimit;
+
+    bool depthCheck() const { return maxDepth &lt; depthLimit; }
+};
+
</ins><span class="cx"> #endif // __INTERMEDIATE_H
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorlength_limitsh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/length_limits.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/length_limits.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/length_limits.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+//
+// Copyright (c) 2011-2014 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
+
+#include &quot;GLSLANG/ShaderLang.h&quot;
+
+// These constants are factored out from the rest of the headers to
+// make it easier to reference them from the compiler sources.
+
+size_t GetGlobalMaxTokenSize(ShShaderSpec spec);
+
+#endif // !(defined(__LENGTH_LIMITS_H)
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorlocalintermediateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/localintermediate.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/localintermediate.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/localintermediate.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -7,9 +7,7 @@
</span><span class="cx"> #ifndef _LOCAL_INTERMEDIATE_INCLUDED_
</span><span class="cx"> #define _LOCAL_INTERMEDIATE_INCLUDED_
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
</del><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><del>-#include &quot;compiler/translator/SymbolTable.h&quot;
</del><span class="cx"> 
</span><span class="cx"> struct TVectorFields {
</span><span class="cx">     int offsets[4];
</span><span class="lines">@@ -27,10 +25,10 @@
</span><span class="cx"> 
</span><span class="cx">     TIntermSymbol* addSymbol(int Id, const TString&amp;, const TType&amp;, const TSourceLoc&amp;);
</span><span class="cx">     TIntermTyped* addConversion(TOperator, const TType&amp;, TIntermTyped*);
</span><del>-    TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&amp;, TSymbolTable&amp;);
</del><ins>+    TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&amp;);
</ins><span class="cx">     TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&amp;);
</span><span class="cx">     TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&amp;);
</span><del>-    TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, const TSourceLoc&amp;, TSymbolTable&amp;);
</del><ins>+    TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, const TSourceLoc&amp;);
</ins><span class="cx">     TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc&amp;);
</span><span class="cx">     TIntermAggregate* makeAggregate(TIntermNode* node, const TSourceLoc&amp;);
</span><span class="cx">     TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, const TSourceLoc&amp;);
</span><span class="lines">@@ -39,13 +37,13 @@
</span><span class="cx">     TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&amp;);
</span><span class="cx">     TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&amp;, const TSourceLoc&amp;);
</span><span class="cx">     TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
</span><del>-    bool parseConstTree(const TSourceLoc&amp;, TIntermNode*, ConstantUnion*, TOperator, TSymbolTable&amp;, TType, bool singleConstantParam = false);        
</del><ins>+    bool parseConstTree(const TSourceLoc&amp;, TIntermNode*, ConstantUnion*, TOperator, TType, bool singleConstantParam = false);        
</ins><span class="cx">     TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, const TSourceLoc&amp;);
</span><span class="cx">     TIntermBranch* addBranch(TOperator, const TSourceLoc&amp;);
</span><span class="cx">     TIntermBranch* addBranch(TOperator, TIntermTyped*, const TSourceLoc&amp;);
</span><span class="cx">     TIntermTyped* addSwizzle(TVectorFields&amp;, const TSourceLoc&amp;);
</span><span class="cx">     bool postProcess(TIntermNode*);
</span><del>-    void remove(TIntermNode*);
</del><ins>+        void remove(TIntermNode*);
</ins><span class="cx">     void outputTree(TIntermNode*);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/localintermediate.h
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorossource_wincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ossource_win.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ossource_win.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ossource_win.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -19,39 +19,39 @@
</span><span class="cx"> //
</span><span class="cx"> OS_TLSIndex OS_AllocTLSIndex()
</span><span class="cx"> {
</span><del>-    DWORD dwIndex = TlsAlloc();
-    if (dwIndex == TLS_OUT_OF_INDEXES) {
-        assert(0 &amp;&amp; &quot;OS_AllocTLSIndex(): Unable to allocate Thread Local Storage&quot;);
-        return OS_INVALID_TLS_INDEX;
-    }
</del><ins>+        DWORD dwIndex = TlsAlloc();
+        if (dwIndex == TLS_OUT_OF_INDEXES) {
+                assert(0 &amp;&amp; &quot;OS_AllocTLSIndex(): Unable to allocate Thread Local Storage&quot;);
+                return OS_INVALID_TLS_INDEX;
+        }
</ins><span class="cx"> 
</span><del>-    return dwIndex;
</del><ins>+        return dwIndex;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
</span><span class="cx"> {
</span><del>-    if (nIndex == OS_INVALID_TLS_INDEX) {
-        assert(0 &amp;&amp; &quot;OS_SetTLSValue(): Invalid TLS Index&quot;);
-        return false;
-    }
</del><ins>+        if (nIndex == OS_INVALID_TLS_INDEX) {
+                assert(0 &amp;&amp; &quot;OS_SetTLSValue(): Invalid TLS Index&quot;);
+                return false;
+        }
</ins><span class="cx"> 
</span><del>-    if (TlsSetValue(nIndex, lpvValue))
-        return true;
-    else
-        return false;
</del><ins>+        if (TlsSetValue(nIndex, lpvValue))
+                return true;
+        else
+                return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
</span><span class="cx"> {
</span><del>-    if (nIndex == OS_INVALID_TLS_INDEX) {
-        assert(0 &amp;&amp; &quot;OS_SetTLSValue(): Invalid TLS Index&quot;);
-        return false;
-    }
</del><ins>+        if (nIndex == OS_INVALID_TLS_INDEX) {
+                assert(0 &amp;&amp; &quot;OS_SetTLSValue(): Invalid TLS Index&quot;);
+                return false;
+        }
</ins><span class="cx"> 
</span><del>-    if (TlsFree(nIndex))
-        return true;
-    else
-        return false;
</del><ins>+        if (TlsFree(nIndex))
+                return true;
+        else
+                return false;
</ins><span class="cx"> }
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ossource_win.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorparseConstcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/parseConst.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/parseConst.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/parseConst.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx"> //
</span><span class="cx"> class TConstTraverser : public TIntermTraverser {
</span><span class="cx"> public:
</span><del>-    TConstTraverser(ConstantUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink&amp; sink, TSymbolTable&amp; symTable, TType&amp; t)
</del><ins>+    TConstTraverser(ConstantUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink&amp; sink, TType&amp; t)
</ins><span class="cx">         : error(false),
</span><span class="cx">           index(0),
</span><span class="cx">           unionArray(cUnion),
</span><span class="lines">@@ -20,10 +20,10 @@
</span><span class="cx">           constructorType(constructType),
</span><span class="cx">           singleConstantParam(singleConstParam),
</span><span class="cx">           infoSink(sink),
</span><del>-          symbolTable(symTable),
</del><span class="cx">           size(0),
</span><del>-          isMatrix(false),
-          matrixSize(0) {
</del><ins>+          isDiagonalMatrixInit(false),
+          matrixCols(0),
+          matrixRows(0) {
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool error;
</span><span class="lines">@@ -44,10 +44,10 @@
</span><span class="cx">     TOperator constructorType;
</span><span class="cx">     bool singleConstantParam;
</span><span class="cx">     TInfoSink&amp; infoSink;
</span><del>-    TSymbolTable&amp; symbolTable;
</del><span class="cx">     size_t size; // size of the constructor ( 4 for vec4)
</span><del>-    bool isMatrix;
-    size_t matrixSize; // dimension of the matrix (nominal size and not the instance size)
</del><ins>+    bool isDiagonalMatrixInit;
+    int matrixCols; // columns of the matrix
+    int matrixRows; // rows of the matrix
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> //
</span><span class="lines">@@ -118,8 +118,9 @@
</span><span class="cx">         size = node-&gt;getType().getObjectSize();
</span><span class="cx"> 
</span><span class="cx">         if (node-&gt;getType().isMatrix()) {
</span><del>-            isMatrix = true;
-            matrixSize = node-&gt;getType().getNominalSize();
</del><ins>+            isDiagonalMatrixInit = true;
+            matrixCols = node-&gt;getType().getCols();
+            matrixRows = node-&gt;getType().getRows();
</ins><span class="cx">         }
</span><span class="cx">     }       
</span><span class="cx"> 
</span><span class="lines">@@ -136,8 +137,9 @@
</span><span class="cx">         singleConstantParam = false;   
</span><span class="cx">         constructorType = EOpNull;
</span><span class="cx">         size = 0;
</span><del>-        isMatrix = false;
-        matrixSize = 0;
</del><ins>+        isDiagonalMatrixInit = false;
+        matrixCols = 0;
+        matrixRows = 0;
</ins><span class="cx">     }
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="lines">@@ -165,10 +167,10 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (!singleConstantParam) {
</span><del>-        size_t size = node-&gt;getType().getObjectSize();
</del><ins>+        size_t objectSize = node-&gt;getType().getObjectSize();
</ins><span class="cx">     
</span><span class="cx">         ConstantUnion *rightUnionArray = node-&gt;getUnionArrayPointer();
</span><del>-        for (size_t i = 0; i &lt; size; i++) {
</del><ins>+        for (size_t i=0; i &lt; objectSize; i++) {
</ins><span class="cx">             if (index &gt;= instanceSize)
</span><span class="cx">                 return;
</span><span class="cx">             leftUnionArray[index] = rightUnionArray[i];
</span><span class="lines">@@ -178,8 +180,8 @@
</span><span class="cx">     } else {
</span><span class="cx">         size_t totalSize = index + size;
</span><span class="cx">         ConstantUnion *rightUnionArray = node-&gt;getUnionArrayPointer();
</span><del>-        if (!isMatrix) {
-            size_t count = 0;
</del><ins>+        if (!isDiagonalMatrixInit) {
+            int count = 0;
</ins><span class="cx">             for (size_t i = index; i &lt; totalSize; i++) {
</span><span class="cx">                 if (i &gt;= instanceSize)
</span><span class="cx">                     return;
</span><span class="lines">@@ -191,21 +193,25 @@
</span><span class="cx">                 if (node-&gt;getType().getObjectSize() &gt; 1)
</span><span class="cx">                     count++;
</span><span class="cx">             }
</span><del>-        } else {  // for matrix constructors
-            size_t count = 0;
-            size_t element = index;
-            for (size_t i = index; i &lt; totalSize; i++) {
-                if (i &gt;= instanceSize)
-                    return;
-                if (element - i == 0 || (i - element) % (matrixSize + 1) == 0 )
-                    leftUnionArray[i] = rightUnionArray[count];
-                else 
-                    leftUnionArray[i].setFConst(0.0f);
</del><ins>+        }
+        else
+        {
+            // for matrix diagonal constructors from a single scalar
+            for (int i = 0, col = 0; col &lt; matrixCols; col++)
+            {
+                for (int row = 0; row &lt; matrixRows; row++, i++)
+                {
+                    if (col == row)
+                    {
+                        leftUnionArray[i] = rightUnionArray[0];
+                    }
+                    else
+                    {
+                        leftUnionArray[i].setFConst(0.0f);
+                    }
</ins><span class="cx"> 
</span><del>-                (index)++;
-
-                if (node-&gt;getType().getObjectSize() &gt; 1)
-                    count++;                
</del><ins>+                    (index)++;
+                }
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -230,12 +236,12 @@
</span><span class="cx"> // Individual functions can be initialized to 0 to skip processing of that
</span><span class="cx"> // type of node.  It's children will still be processed.
</span><span class="cx"> //
</span><del>-bool TIntermediate::parseConstTree(const TSourceLoc&amp; line, TIntermNode* root, ConstantUnion* unionArray, TOperator constructorType, TSymbolTable&amp; symbolTable, TType t, bool singleConstantParam)
</del><ins>+bool TIntermediate::parseConstTree(const TSourceLoc&amp; line, TIntermNode* root, ConstantUnion* unionArray, TOperator constructorType, TType t, bool singleConstantParam)
</ins><span class="cx"> {
</span><span class="cx">     if (root == 0)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    TConstTraverser it(unionArray, singleConstantParam, constructorType, infoSink, symbolTable, t);
</del><ins>+    TConstTraverser it(unionArray, singleConstantParam, constructorType, infoSink, t);
</ins><span class="cx"> 
</span><span class="cx">     root-&gt;traverse(&amp;it);
</span><span class="cx">     if (it.error)
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatortimingRestrictFragmentShaderTimingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -31,6 +31,15 @@
</span><span class="cx">     mSamplingOps.insert(&quot;texture2DRect(1;vf2;&quot;);
</span><span class="cx">     mSamplingOps.insert(&quot;texture2DRectProj(1;vf3;&quot;);
</span><span class="cx">     mSamplingOps.insert(&quot;texture2DRectProj(1;vf4;&quot;);
</span><ins>+    // Sampling ops provided by EXT_shader_texture_lod.
+    mSamplingOps.insert(&quot;texture2DLodEXT(1;vf2;f1;&quot;);
+    mSamplingOps.insert(&quot;texture2DProjLodEXT(1;vf3;f1;&quot;);
+    mSamplingOps.insert(&quot;texture2DProjLodEXT(1;vf4;f1;&quot;);
+    mSamplingOps.insert(&quot;textureCubeLodEXT(1;vf4;f1;&quot;);
+    mSamplingOps.insert(&quot;texture2DGradEXT(1;vf2;vf2;vf2;&quot;);
+    mSamplingOps.insert(&quot;texture2DProjGradEXT(1;vf3;vf2;vf2;&quot;);
+    mSamplingOps.insert(&quot;texture2DProjGradEXT(1;vf4;vf2;vf2;&quot;);
+    mSamplingOps.insert(&quot;textureCubeGradEXT(1;vf3;vf3;vf3;&quot;);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // FIXME(mvujovic): We do not know if the execution time of built-in operations like sin, pow, etc.
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatortimingRestrictFragmentShaderTimingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictFragmentShaderTiming.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictFragmentShaderTiming.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictFragmentShaderTiming.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -7,8 +7,6 @@
</span><span class="cx"> #ifndef COMPILER_TIMING_RESTRICT_FRAGMENT_SHADER_TIMING_H_
</span><span class="cx"> #define COMPILER_TIMING_RESTRICT_FRAGMENT_SHADER_TIMING_H_
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
-
</del><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/depgraph/DependencyGraph.h&quot;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatortimingRestrictVertexShaderTimingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictVertexShaderTiming.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictVertexShaderTiming.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictVertexShaderTiming.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -12,6 +12,6 @@
</span><span class="cx">         ++mNumErrors;
</span><span class="cx">         mSink.message(EPrefixError,
</span><span class="cx">                       node-&gt;getLine(),
</span><del>-                      &quot;Samplers are not permitted in vertex shaders&quot;);
</del><ins>+                      &quot;Samplers are not permitted in vertex shaders.\n&quot;);
</ins><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatortimingRestrictVertexShaderTimingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictVertexShaderTiming.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictVertexShaderTiming.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/timing/RestrictVertexShaderTiming.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -7,8 +7,6 @@
</span><span class="cx"> #ifndef COMPILER_TIMING_RESTRICT_VERTEX_SHADER_TIMING_H_
</span><span class="cx"> #define COMPILER_TIMING_RESTRICT_VERTEX_SHADER_TIMING_H_
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
-
</del><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/InfoSink.h&quot;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibEGLConfigcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libEGL/Config.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libEGL/Config.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libEGL/Config.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -13,8 +13,11 @@
</span><span class="cx"> #include &lt;algorithm&gt;
</span><span class="cx"> #include &lt;vector&gt;
</span><span class="cx"> 
</span><ins>+#include &lt;GLES3/gl3.h&gt;
+#include &lt;GLES3/gl3ext.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> #include &lt;GLES2/gl2ext.h&gt;
</span><ins>+#include &lt;EGL/eglext.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;common/debug.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -36,6 +39,13 @@
</span><span class="cx">         mBlueSize = 5;
</span><span class="cx">         mAlphaSize = 1;
</span><span class="cx">         break;
</span><ins>+      case GL_BGR5_A1_ANGLEX:
+        mBufferSize = 16;
+        mRedSize = 5;
+        mGreenSize = 5;
+        mBlueSize = 5;
+        mAlphaSize = 1;
+        break;
</ins><span class="cx">       case GL_RGBA8_OES:
</span><span class="cx">         mBufferSize = 32;
</span><span class="cx">         mRedSize = 8;
</span><span class="lines">@@ -122,6 +132,12 @@
</span><span class="cx">     mTransparentRedValue = 0;
</span><span class="cx">     mTransparentGreenValue = 0;
</span><span class="cx">     mTransparentBlueValue = 0;
</span><ins>+
+    if (desc.es3Capable)
+    {
+        mRenderableType |= EGL_OPENGL_ES3_BIT_KHR;
+        mConformant |= EGL_OPENGL_ES3_BIT_KHR;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> EGLConfig Config::getHandle() const
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibEGLDisplaycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libEGL/Display.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libEGL/Display.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libEGL/Display.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx"> #include &lt;vector&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/debug.h&quot;
</span><del>-#include &quot;libGLESv2/mathutil.h&quot;
</del><ins>+#include &quot;common/mathutil.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Context.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/SwapChain.h&quot;
</span><span class="lines">@@ -191,6 +191,10 @@
</span><span class="cx">     const Config *configuration = mConfigSet.get(config);
</span><span class="cx">     EGLint postSubBufferSupported = EGL_FALSE;
</span><span class="cx"> 
</span><ins>+    EGLint width = 0;
+    EGLint height = 0;
+    EGLint fixedSize = EGL_FALSE;
+
</ins><span class="cx">     if (attribList)
</span><span class="cx">     {
</span><span class="cx">         while (*attribList != EGL_NONE)
</span><span class="lines">@@ -211,6 +215,15 @@
</span><span class="cx">               case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
</span><span class="cx">                 postSubBufferSupported = attribList[1];
</span><span class="cx">                 break;
</span><ins>+              case EGL_WIDTH:
+                width = attribList[1];
+                break;
+              case EGL_HEIGHT:
+                height = attribList[1];
+                break;
+              case EGL_FIXED_SIZE_ANGLE:
+                fixedSize = attribList[1];
+                break;
</ins><span class="cx">               case EGL_VG_COLORSPACE:
</span><span class="cx">                 return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
</span><span class="cx">               case EGL_VG_ALPHA_FORMAT:
</span><span class="lines">@@ -223,6 +236,17 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (width &lt; 0 || height &lt; 0)
+    {
+        return error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
+    }
+
+    if (!fixedSize)
+    {
+        width = -1;
+        height = -1;
+    }
+
</ins><span class="cx">     if (hasExistingWindowSurface(window))
</span><span class="cx">     {
</span><span class="cx">         return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
</span><span class="lines">@@ -234,7 +258,7 @@
</span><span class="cx">             return EGL_NO_SURFACE;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Surface *surface = new Surface(this, configuration, window, postSubBufferSupported);
</del><ins>+    Surface *surface = new Surface(this, configuration, window, fixedSize, width, height, postSubBufferSupported);
</ins><span class="cx"> 
</span><span class="cx">     if (!surface-&gt;initialize())
</span><span class="cx">     {
</span><span class="lines">@@ -360,22 +384,29 @@
</span><span class="cx">     return success(surface);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *shareContext, bool notifyResets, bool robustAccess)
</del><ins>+EGLContext Display::createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess)
</ins><span class="cx"> {
</span><span class="cx">     if (!mRenderer)
</span><span class="cx">     {
</span><del>-        return NULL;
</del><ins>+        return EGL_NO_CONTEXT;
</ins><span class="cx">     }
</span><span class="cx">     else if (mRenderer-&gt;testDeviceLost(false))   // Lost device
</span><span class="cx">     {
</span><span class="cx">         if (!restoreLostDevice())
</span><del>-            return NULL;
</del><ins>+        {
+            return error(EGL_CONTEXT_LOST, EGL_NO_CONTEXT);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gl::Context *context = glCreateContext(shareContext, mRenderer, notifyResets, robustAccess);
</del><ins>+    if (clientVersion &gt; 2 &amp;&amp; mRenderer-&gt;getMajorShaderModel() &lt; 4)
+    {
+        return error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);
+    }
+
+    gl::Context *context = glCreateContext(clientVersion, shareContext, mRenderer, notifyResets, robustAccess);
</ins><span class="cx">     mContextSet.insert(context);
</span><span class="cx"> 
</span><del>-    return context;
</del><ins>+    return success(context);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Display::restoreLostDevice()
</span><span class="lines">@@ -487,6 +518,8 @@
</span><span class="cx"> 
</span><span class="cx">     mExtensionString += &quot;EGL_ANGLE_query_surface_pointer &quot;;
</span><span class="cx"> 
</span><ins>+    mExtensionString += &quot;EGL_ANGLE_window_fixed_size &quot;;
+
</ins><span class="cx">     if (swiftShader)
</span><span class="cx">     {
</span><span class="cx">         mExtensionString += &quot;EGL_ANGLE_software_display &quot;;
</span><span class="lines">@@ -499,9 +532,12 @@
</span><span class="cx"> 
</span><span class="cx">     if (mRenderer-&gt;getPostSubBufferSupport())
</span><span class="cx">     {
</span><del>-        mExtensionString += &quot;EGL_NV_post_sub_buffer&quot;;
</del><ins>+        mExtensionString += &quot;EGL_NV_post_sub_buffer &quot;;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // TODO: complete support for the EGL_KHR_create_context extension
+    mExtensionString += &quot;EGL_KHR_create_context &quot;;
+
</ins><span class="cx">     std::string::size_type end = mExtensionString.find_last_not_of(' ');
</span><span class="cx">     if (end != std::string::npos)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibEGLDisplayh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libEGL/Display.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libEGL/Display.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libEGL/Display.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx"> 
</span><span class="cx">     EGLSurface createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList);
</span><span class="cx">     EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList);
</span><del>-    EGLContext createContext(EGLConfig configHandle, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
</del><ins>+    EGLContext createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
</ins><span class="cx"> 
</span><span class="cx">     void destroySurface(egl::Surface *surface);
</span><span class="cx">     void destroyContext(gl::Context *context);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibEGLSurfacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libEGL/Surface.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libEGL/Surface.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libEGL/Surface.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> namespace egl
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-Surface::Surface(Display *display, const Config *config, HWND window, EGLint postSubBufferSupported) 
</del><ins>+Surface::Surface(Display *display, const Config *config, HWND window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported) 
</ins><span class="cx">     : mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported)
</span><span class="cx"> {
</span><span class="cx">     mRenderer = mDisplay-&gt;getRenderer();
</span><span class="lines">@@ -39,9 +39,10 @@
</span><span class="cx">     mRenderBuffer = EGL_BACK_BUFFER;
</span><span class="cx">     mSwapBehavior = EGL_BUFFER_PRESERVED;
</span><span class="cx">     mSwapInterval = -1;
</span><del>-    mWidth = -1;
-    mHeight = -1;
</del><ins>+    mWidth = width;
+    mHeight = height;
</ins><span class="cx">     setSwapInterval(1);
</span><ins>+    mFixedSize = fixedSize;
</ins><span class="cx"> 
</span><span class="cx">     subclassWindow();
</span><span class="cx"> }
</span><span class="lines">@@ -61,6 +62,8 @@
</span><span class="cx">     mSwapBehavior = EGL_BUFFER_PRESERVED;
</span><span class="cx">     mSwapInterval = -1;
</span><span class="cx">     setSwapInterval(1);
</span><ins>+    // This constructor is for offscreen surfaces, which are always fixed-size.
+    mFixedSize = EGL_TRUE;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Surface::~Surface()
</span><span class="lines">@@ -96,7 +99,7 @@
</span><span class="cx">     int width;
</span><span class="cx">     int height;
</span><span class="cx"> 
</span><del>-    if (mWindow)
</del><ins>+    if (!mFixedSize)
</ins><span class="cx">     {
</span><span class="cx">         RECT windowRect;
</span><span class="cx">         if (!GetClientRect(getWindowHandle(), &amp;windowRect))
</span><span class="lines">@@ -140,7 +143,7 @@
</span><span class="cx">     ASSERT(backbufferWidth &gt;= 0 &amp;&amp; backbufferHeight &gt;= 0);
</span><span class="cx">     ASSERT(mSwapChain);
</span><span class="cx"> 
</span><del>-    EGLint status = mSwapChain-&gt;resize(backbufferWidth, backbufferHeight);
</del><ins>+    EGLint status = mSwapChain-&gt;resize(std::max(1, backbufferWidth), std::max(1, backbufferHeight));
</ins><span class="cx"> 
</span><span class="cx">     if (status == EGL_CONTEXT_LOST)
</span><span class="cx">     {
</span><span class="lines">@@ -163,7 +166,7 @@
</span><span class="cx">     ASSERT(backbufferWidth &gt;= 0 &amp;&amp; backbufferHeight &gt;= 0);
</span><span class="cx">     ASSERT(mSwapChain);
</span><span class="cx"> 
</span><del>-    EGLint status = mSwapChain-&gt;reset(backbufferWidth, backbufferHeight, mSwapInterval);
</del><ins>+    EGLint status = mSwapChain-&gt;reset(std::max(1, backbufferWidth), std::max(1, backbufferHeight), mSwapInterval);
</ins><span class="cx"> 
</span><span class="cx">     if (status == EGL_CONTEXT_LOST)
</span><span class="cx">     {
</span><span class="lines">@@ -300,22 +303,23 @@
</span><span class="cx"> bool Surface::checkForOutOfDateSwapChain()
</span><span class="cx"> {
</span><span class="cx">     RECT client;
</span><del>-    if (!GetClientRect(getWindowHandle(), &amp;client))
</del><ins>+    int clientWidth = getWidth();
+    int clientHeight = getHeight();
+    bool sizeDirty = false;
+    if (!mFixedSize &amp;&amp; !IsIconic(getWindowHandle()))
</ins><span class="cx">     {
</span><del>-        ASSERT(false);
-        return false;
-    }
-
-    // Grow the buffer now, if the window has grown. We need to grow now to avoid losing information.
-    int clientWidth = client.right - client.left;
-    int clientHeight = client.bottom - client.top;
-    bool sizeDirty = clientWidth != getWidth() || clientHeight != getHeight();
-
-    if (IsIconic(getWindowHandle()))
-    {
</del><span class="cx">         // The window is automatically resized to 150x22 when it's minimized, but the swapchain shouldn't be resized
</span><span class="cx">         // because that's not a useful size to render to.
</span><del>-        sizeDirty = false;
</del><ins>+        if (!GetClientRect(getWindowHandle(), &amp;client))
+        {
+            ASSERT(false);
+            return false;
+        }
+
+        // Grow the buffer now, if the window has grown. We need to grow now to avoid losing information.
+        clientWidth = client.right - client.left;
+        clientHeight = client.bottom - client.top;
+        sizeDirty = clientWidth != getWidth() || clientHeight != getHeight();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool wasDirty = (mSwapIntervalDirty || sizeDirty);
</span><span class="lines">@@ -412,6 +416,11 @@
</span><span class="cx">     return mTexture;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+EGLint Surface::isFixedSize() const
+{
+    return mFixedSize;
+}
+
</ins><span class="cx"> EGLenum Surface::getFormat() const
</span><span class="cx"> {
</span><span class="cx">     return mConfig-&gt;mRenderTargetFormat;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibEGLSurfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libEGL/Surface.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libEGL/Surface.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libEGL/Surface.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -34,10 +34,10 @@
</span><span class="cx"> class Surface
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    Surface(Display *display, const egl::Config *config, HWND window, EGLint postSubBufferSupported);
</del><ins>+    Surface(Display *display, const egl::Config *config, HWND window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported);
</ins><span class="cx">     Surface(Display *display, const egl::Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget);
</span><span class="cx"> 
</span><del>-    ~Surface();
</del><ins>+    virtual ~Surface();
</ins><span class="cx"> 
</span><span class="cx">     bool initialize();
</span><span class="cx">     void release();
</span><span class="lines">@@ -64,6 +64,8 @@
</span><span class="cx">     virtual void setBoundTexture(gl::Texture2D *texture);
</span><span class="cx">     virtual gl::Texture2D *getBoundTexture() const;
</span><span class="cx"> 
</span><ins>+    EGLint isFixedSize() const;
+
</ins><span class="cx"> private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Surface);
</span><span class="cx"> 
</span><span class="lines">@@ -99,6 +101,7 @@
</span><span class="cx"> //  EGLenum vgColorSpace;          // Color space for OpenVG
</span><span class="cx">     EGLint mSwapInterval;
</span><span class="cx">     EGLint mPostSubBufferSupported;
</span><ins>+    EGLint mFixedSize;
</ins><span class="cx">     
</span><span class="cx">     bool mSwapIntervalDirty;
</span><span class="cx">     gl::Texture2D *mTexture;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibEGLlibEGLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libEGL/libEGL.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libEGL/libEGL.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libEGL/libEGL.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -471,6 +471,9 @@
</span><span class="cx">           case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
</span><span class="cx">             *value = eglSurface-&gt;isPostSubBufferSupported();
</span><span class="cx">             break;
</span><ins>+          case EGL_FIXED_SIZE_ANGLE:
+            *value = eglSurface-&gt;isFixedSize();
+            break;
</ins><span class="cx">           default:
</span><span class="cx">             return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
</span><span class="cx">         }
</span><span class="lines">@@ -779,7 +782,7 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        // Get the requested client version (default is 1) and check it is two.
</del><ins>+        // Get the requested client version (default is 1) and check it is 2 or 3.
</ins><span class="cx">         EGLint client_version = 1;
</span><span class="cx">         bool reset_notification = false;
</span><span class="cx">         bool robust_access = false;
</span><span class="lines">@@ -814,24 +817,32 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (client_version != 2)
</del><ins>+        if (client_version != 2 &amp;&amp; client_version != 3)
</ins><span class="cx">         {
</span><span class="cx">             return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        gl::Context *sharedContextPtr = (share_context != EGL_NO_CONTEXT ? static_cast&lt;gl::Context*&gt;(share_context) : NULL);
</del><ins>+        egl::Display *display = static_cast&lt;egl::Display*&gt;(dpy);
</ins><span class="cx"> 
</span><del>-        if (sharedContextPtr != NULL &amp;&amp; sharedContextPtr-&gt;isResetNotificationEnabled() != reset_notification)
</del><ins>+        if (share_context)
</ins><span class="cx">         {
</span><del>-            return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
-        }
</del><ins>+            gl::Context* sharedGLContext = static_cast&lt;gl::Context*&gt;(share_context);
</ins><span class="cx"> 
</span><del>-        egl::Display *display = static_cast&lt;egl::Display*&gt;(dpy);
</del><ins>+            if (sharedGLContext-&gt;isResetNotificationEnabled() != reset_notification)
+            {
+                return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
+            }
</ins><span class="cx"> 
</span><del>-        // Can not share contexts between displays
-        if (sharedContextPtr != NULL &amp;&amp; sharedContextPtr-&gt;getRenderer() != display-&gt;getRenderer())
-        {
-            return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
</del><ins>+            if (sharedGLContext-&gt;getClientVersion() != client_version)
+            {
+                return egl::error(EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
+            }
+
+            // Can not share contexts between displays
+            if (sharedGLContext-&gt;getRenderer() != display-&gt;getRenderer())
+            {
+                return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
+            }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (!validateConfig(display, config))
</span><span class="lines">@@ -839,12 +850,7 @@
</span><span class="cx">             return EGL_NO_CONTEXT;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        EGLContext context = display-&gt;createContext(config, static_cast&lt;gl::Context*&gt;(share_context), reset_notification, robust_access);
-
-        if (context)
-            return egl::success(context);
-        else
-            return egl::error(EGL_CONTEXT_LOST, EGL_NO_CONTEXT);
</del><ins>+        return display-&gt;createContext(config, client_version, static_cast&lt;gl::Context*&gt;(share_context), reset_notification, robust_access);
</ins><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Buffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -19,15 +19,21 @@
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-Buffer::Buffer(rx::Renderer *renderer, GLuint id) : RefCountObject(id)
</del><ins>+Buffer::Buffer(rx::Renderer *renderer, GLuint id)
+    : RefCountObject(id),
+      mRenderer(renderer),
+      mUsage(GL_DYNAMIC_DRAW),
+      mAccessFlags(0),
+      mMapped(GL_FALSE),
+      mMapPointer(NULL),
+      mMapOffset(0),
+      mMapLength(0),
+      mBufferStorage(NULL),
+      mStaticVertexBuffer(NULL),
+      mStaticIndexBuffer(NULL),
+      mUnmodifiedDataUse(0)
</ins><span class="cx"> {
</span><del>-    mRenderer = renderer;
-    mUsage = GL_DYNAMIC_DRAW;
-
</del><span class="cx">     mBufferStorage = renderer-&gt;createBufferStorage();
</span><del>-    mStaticVertexBuffer = NULL;
-    mStaticIndexBuffer = NULL;
-    mUnmodifiedDataUse = 0;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Buffer::~Buffer()
</span><span class="lines">@@ -58,23 +64,51 @@
</span><span class="cx"> {
</span><span class="cx">     mBufferStorage-&gt;setData(data, size, offset);
</span><span class="cx">     mIndexRangeCache.invalidateRange(offset, size);
</span><ins>+    invalidateStaticData();
+}
</ins><span class="cx"> 
</span><del>-    if ((mStaticVertexBuffer &amp;&amp; mStaticVertexBuffer-&gt;getBufferSize() != 0) || (mStaticIndexBuffer &amp;&amp; mStaticIndexBuffer-&gt;getBufferSize() != 0))
-    {
-        invalidateStaticData();
-    }
</del><ins>+void Buffer::copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size)
+{
+    mBufferStorage-&gt;copyData(source-&gt;mBufferStorage, size, sourceOffset, destOffset);
+    invalidateStaticData();
+}
</ins><span class="cx"> 
</span><del>-    mUnmodifiedDataUse = 0;
</del><ins>+GLvoid *Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access)
+{
+    ASSERT(!mMapped);
+
+    void *dataPointer = mBufferStorage-&gt;map(access);
+
+    mMapped = GL_TRUE;
+    mMapPointer = static_cast&lt;GLvoid*&gt;(static_cast&lt;GLubyte*&gt;(dataPointer) + offset);
+    mMapOffset = static_cast&lt;GLint64&gt;(offset);
+    mMapLength = static_cast&lt;GLint64&gt;(length);
+    mAccessFlags = static_cast&lt;GLint&gt;(access);
+
+    return mMapPointer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Buffer::unmap()
+{
+    ASSERT(mMapped);
+
+    mBufferStorage-&gt;unmap();
+
+    mMapped = GL_FALSE;
+    mMapPointer = NULL;
+    mMapOffset = 0;
+    mMapLength = 0;
+    mAccessFlags = 0;
+}
+
</ins><span class="cx"> rx::BufferStorage *Buffer::getStorage() const
</span><span class="cx"> {
</span><span class="cx">     return mBufferStorage;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned int Buffer::size() const
</del><ins>+GLint64 Buffer::size() const
</ins><span class="cx"> {
</span><del>-    return mBufferStorage-&gt;getSize();
</del><ins>+    return static_cast&lt;GLint64&gt;(mBufferStorage-&gt;getSize());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLenum Buffer::usage() const
</span><span class="lines">@@ -82,6 +116,37 @@
</span><span class="cx">     return mUsage;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLint Buffer::accessFlags() const
+{
+    return mAccessFlags;
+}
+
+GLboolean Buffer::mapped() const
+{
+    return mMapped;
+}
+
+GLvoid *Buffer::mapPointer() const
+{
+    return mMapPointer;
+}
+
+GLint64 Buffer::mapOffset() const
+{
+    return mMapOffset;
+}
+
+GLint64 Buffer::mapLength() const
+{
+    return mMapLength;
+}
+
+void Buffer::markTransformFeedbackUsage()
+{
+    mBufferStorage-&gt;markTransformFeedbackUsage();
+    invalidateStaticData();
+}
+
</ins><span class="cx"> rx::StaticVertexBufferInterface *Buffer::getStaticVertexBuffer()
</span><span class="cx"> {
</span><span class="cx">     return mStaticVertexBuffer;
</span><span class="lines">@@ -94,11 +159,14 @@
</span><span class="cx"> 
</span><span class="cx"> void Buffer::invalidateStaticData()
</span><span class="cx"> {
</span><del>-    delete mStaticVertexBuffer;
-    mStaticVertexBuffer = NULL;
</del><ins>+    if ((mStaticVertexBuffer &amp;&amp; mStaticVertexBuffer-&gt;getBufferSize() != 0) || (mStaticIndexBuffer &amp;&amp; mStaticIndexBuffer-&gt;getBufferSize() != 0))
+    {
+        delete mStaticVertexBuffer;
+        mStaticVertexBuffer = NULL;
</ins><span class="cx"> 
</span><del>-    delete mStaticIndexBuffer;
-    mStaticIndexBuffer = NULL;
</del><ins>+        delete mStaticIndexBuffer;
+        mStaticIndexBuffer = NULL;
+    }
</ins><span class="cx"> 
</span><span class="cx">     mUnmodifiedDataUse = 0;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Bufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -35,12 +35,22 @@
</span><span class="cx"> 
</span><span class="cx">     void bufferData(const void *data, GLsizeiptr size, GLenum usage);
</span><span class="cx">     void bufferSubData(const void *data, GLsizeiptr size, GLintptr offset);
</span><ins>+    void copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
+    GLvoid *mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access);
+    void unmap();
</ins><span class="cx"> 
</span><span class="cx">     GLenum usage() const;
</span><ins>+    GLint accessFlags() const;
+    GLboolean mapped() const;
+    GLvoid *mapPointer() const;
+    GLint64 mapOffset() const;
+    GLint64 mapLength() const;
</ins><span class="cx"> 
</span><span class="cx">     rx::BufferStorage *getStorage() const;
</span><del>-    unsigned int size() const;
</del><ins>+    GLint64 size() const;
</ins><span class="cx"> 
</span><ins>+    void markTransformFeedbackUsage();
+
</ins><span class="cx">     rx::StaticVertexBufferInterface *getStaticVertexBuffer();
</span><span class="cx">     rx::StaticIndexBufferInterface *getStaticIndexBuffer();
</span><span class="cx">     void invalidateStaticData();
</span><span class="lines">@@ -53,6 +63,11 @@
</span><span class="cx"> 
</span><span class="cx">     rx::Renderer *mRenderer;
</span><span class="cx">     GLenum mUsage;
</span><ins>+    GLint mAccessFlags;
+    GLboolean mMapped;
+    GLvoid *mMapPointer;
+    GLint64 mMapOffset;
+    GLint64 mMapLength;
</ins><span class="cx"> 
</span><span class="cx">     rx::BufferStorage *mBufferStorage;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Constantsh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Constants.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Constants.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Constants.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,34 +0,0 @@
</span><del>-//
-// 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
-};
-
-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_
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Contextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Context.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Context.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Context.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -11,7 +11,8 @@
</span><span class="cx"> #include &quot;libGLESv2/Context.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;common/utilities.h&quot;
+#include &quot;libGLESv2/formatutils.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/Buffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Fence.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Framebuffer.h&quot;
</span><span class="lines">@@ -24,6 +25,10 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/IndexDataManager.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/RenderTarget.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><ins>+#include &quot;libGLESv2/VertexArray.h&quot;
+#include &quot;libGLESv2/Sampler.h&quot;
+#include &quot;libGLESv2/validationES.h&quot;
+#include &quot;libGLESv2/TransformFeedback.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;libEGL/Surface.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -42,17 +47,20 @@
</span><span class="cx">     return strings.insert(str).first-&gt;c_str();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Context::Context(const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess) : mRenderer(renderer)
</del><ins>+Context::Context(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess) : mRenderer(renderer)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(robustAccess == false);   // Unimplemented
</span><span class="cx"> 
</span><del>-    mFenceHandleAllocator.setBaseHandle(0);
</del><ins>+    mFenceNVHandleAllocator.setBaseHandle(0);
</ins><span class="cx"> 
</span><span class="cx">     setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
</span><span class="cx"> 
</span><ins>+    mClientVersion = clientVersion;
+
</ins><span class="cx">     mState.depthClearValue = 1.0f;
</span><span class="cx">     mState.stencilClearValue = 0;
</span><span class="cx"> 
</span><ins>+    mState.rasterizer.rasterizerDiscard = false;
</ins><span class="cx">     mState.rasterizer.cullFace = false;
</span><span class="cx">     mState.rasterizer.cullMode = GL_BACK;
</span><span class="cx">     mState.rasterizer.frontFace = GL_CCW;
</span><span class="lines">@@ -122,6 +130,12 @@
</span><span class="cx">     mState.blend.colorMaskBlue = true;
</span><span class="cx">     mState.blend.colorMaskAlpha = true;
</span><span class="cx"> 
</span><ins>+    const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+    for (int attribIndex = 0; attribIndex &lt; MAX_VERTEX_ATTRIBS; attribIndex++)
+    {
+        mState.vertexAttribCurrentValues[attribIndex].setFloatValues(defaultFloatValues);
+    }
+
</ins><span class="cx">     if (shareContext != NULL)
</span><span class="cx">     {
</span><span class="cx">         mResourceManager = shareContext-&gt;mResourceManager;
</span><span class="lines">@@ -140,8 +154,16 @@
</span><span class="cx"> 
</span><span class="cx">     mTexture2DZero.set(new Texture2D(mRenderer, 0));
</span><span class="cx">     mTextureCubeMapZero.set(new TextureCubeMap(mRenderer, 0));
</span><ins>+    mTexture3DZero.set(new Texture3D(mRenderer, 0));
+    mTexture2DArrayZero.set(new Texture2DArray(mRenderer, 0));
</ins><span class="cx"> 
</span><ins>+    for (unsigned int textureUnit = 0; textureUnit &lt; ArraySize(mState.samplers); textureUnit++)
+    {
+        mState.samplers[textureUnit] = 0;
+    }
+
</ins><span class="cx">     mState.activeSampler = 0;
</span><ins>+    bindVertexArray(0);
</ins><span class="cx">     bindArrayBuffer(0);
</span><span class="cx">     bindElementArrayBuffer(0);
</span><span class="cx">     bindTextureCubeMap(0);
</span><span class="lines">@@ -150,14 +172,38 @@
</span><span class="cx">     bindDrawFramebuffer(0);
</span><span class="cx">     bindRenderbuffer(0);
</span><span class="cx"> 
</span><ins>+    mState.activeQueries[GL_ANY_SAMPLES_PASSED].set(NULL);
+    mState.activeQueries[GL_ANY_SAMPLES_PASSED_CONSERVATIVE].set(NULL);
+    mState.activeQueries[GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN].set(NULL);
+
+    bindGenericUniformBuffer(0);
+    for (int i = 0; i &lt; IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS; i++)
+    {
+        bindIndexedUniformBuffer(0, i, 0, -1);
+    }
+
+    bindGenericTransformFeedbackBuffer(0);
+    for (int i = 0; i &lt; IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
+    {
+        bindIndexedTransformFeedbackBuffer(0, i, 0, -1);
+    }
+
+    bindCopyReadBuffer(0);
+    bindCopyWriteBuffer(0);
+    bindPixelPackBuffer(0);
+    bindPixelUnpackBuffer(0);
+
+    // [OpenGL ES 3.0.2] section 2.14.1 pg 85:
+    // In the initial state, a default transform feedback object is bound and treated as
+    // a transform feedback object with a name of zero. That object is bound any time
+    // BindTransformFeedback is called with id of zero
+    mTransformFeedbackZero.set(new TransformFeedback(0));
+    bindTransformFeedback(0);
+
</ins><span class="cx">     mState.currentProgram = 0;
</span><span class="cx">     mCurrentProgramBinary.set(NULL);
</span><span class="cx"> 
</span><del>-    mState.packAlignment = 4;
-    mState.unpackAlignment = 4;
-    mState.packReverseRowOrder = false;
-
-    mExtensionString = NULL;
</del><ins>+    mCombinedExtensionsString = NULL;
</ins><span class="cx">     mRendererString = NULL;
</span><span class="cx"> 
</span><span class="cx">     mInvalidEnum = false;
</span><span class="lines">@@ -199,9 +245,9 @@
</span><span class="cx">         deleteFramebuffer(mFramebufferMap.begin()-&gt;first);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    while (!mFenceMap.empty())
</del><ins>+    while (!mFenceNVMap.empty())
</ins><span class="cx">     {
</span><del>-        deleteFence(mFenceMap.begin()-&gt;first);
</del><ins>+        deleteFenceNV(mFenceNVMap.begin()-&gt;first);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     while (!mQueryMap.empty())
</span><span class="lines">@@ -209,6 +255,17 @@
</span><span class="cx">         deleteQuery(mQueryMap.begin()-&gt;first);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    while (!mVertexArrayMap.empty())
+    {
+        deleteVertexArray(mVertexArrayMap.begin()-&gt;first);
+    }
+
+    mTransformFeedbackZero.set(NULL);
+    while (!mTransformFeedbackMap.empty())
+    {
+        deleteTransformFeedback(mTransformFeedbackMap.begin()-&gt;first);
+    }
+
</ins><span class="cx">     for (int type = 0; type &lt; TEXTURE_TYPE_COUNT; type++)
</span><span class="cx">     {
</span><span class="cx">         for (int sampler = 0; sampler &lt; IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS; sampler++)
</span><span class="lines">@@ -222,23 +279,45 @@
</span><span class="cx">         mIncompleteTextures[type].set(NULL);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (int i = 0; i &lt; MAX_VERTEX_ATTRIBS; i++)
</del><ins>+    const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+    for (int attribIndex = 0; attribIndex &lt; MAX_VERTEX_ATTRIBS; attribIndex++)
</ins><span class="cx">     {
</span><del>-        mState.vertexAttribute[i].mBoundBuffer.set(NULL);
</del><ins>+        mState.vertexAttribCurrentValues[attribIndex].setFloatValues(defaultFloatValues);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (int i = 0; i &lt; QUERY_TYPE_COUNT; i++)
-    {
-        mState.activeQuery[i].set(NULL);
-    }
-
</del><span class="cx">     mState.arrayBuffer.set(NULL);
</span><del>-    mState.elementArrayBuffer.set(NULL);
</del><span class="cx">     mState.renderbuffer.set(NULL);
</span><span class="cx"> 
</span><ins>+    mState.transformFeedback.set(NULL);
+
</ins><span class="cx">     mTexture2DZero.set(NULL);
</span><span class="cx">     mTextureCubeMapZero.set(NULL);
</span><ins>+    mTexture3DZero.set(NULL);
+    mTexture2DArrayZero.set(NULL);
</ins><span class="cx"> 
</span><ins>+    for (State::ActiveQueryMap::iterator i = mState.activeQueries.begin(); i != mState.activeQueries.end(); i++)
+    {
+        i-&gt;second.set(NULL);
+    }
+
+    mState.genericUniformBuffer.set(NULL);
+    for (int i = 0; i &lt; IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS; i++)
+    {
+        mState.uniformBuffers[i].set(NULL);
+    }
+
+    mState.genericTransformFeedbackBuffer.set(NULL);
+    for (int i = 0; i &lt; IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
+    {
+        mState.transformFeedbackBuffers[i].set(NULL);
+    }
+
+    mState.copyReadBuffer.set(NULL);
+    mState.copyWriteBuffer.set(NULL);
+
+    mState.pack.pixelBuffer.set(NULL);
+    mState.unpack.pixelBuffer.set(NULL);
+
</ins><span class="cx">     mResourceManager-&gt;release();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -253,14 +332,24 @@
</span><span class="cx">         mSupportsInstancing = mRenderer-&gt;getInstancingSupport();
</span><span class="cx"> 
</span><span class="cx">         mMaxViewportDimension = mRenderer-&gt;getMaxViewportDimension();
</span><del>-        mMaxTextureDimension = std::min(std::min(mRenderer-&gt;getMaxTextureWidth(), mRenderer-&gt;getMaxTextureHeight()),
-                                        (int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE);
-        mMaxCubeTextureDimension = std::min(mMaxTextureDimension, (int)gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE);
-        mMaxRenderbufferDimension = mMaxTextureDimension;
-        mMaxTextureLevel = log2(mMaxTextureDimension) + 1;
</del><ins>+        mMax2DTextureDimension = std::min(std::min(mRenderer-&gt;getMaxTextureWidth(), mRenderer-&gt;getMaxTextureHeight()),
+                                          (int)gl::IMPLEMENTATION_MAX_2D_TEXTURE_SIZE);
+        mMaxCubeTextureDimension = std::min(mMax2DTextureDimension, (int)gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE);
+        mMax3DTextureDimension = std::min(std::min(mMax2DTextureDimension, mRenderer-&gt;getMaxTextureDepth()),
+                                          (int)gl::IMPLEMENTATION_MAX_3D_TEXTURE_SIZE);
+        mMax2DArrayTextureLayers = mRenderer-&gt;getMaxTextureArrayLayers();
+        mMaxRenderbufferDimension = mMax2DTextureDimension;
+        mMax2DTextureLevel = log2(mMax2DTextureDimension) + 1;
+        mMaxCubeTextureLevel = log2(mMaxCubeTextureDimension) + 1;
+        mMax3DTextureLevel = log2(mMax3DTextureDimension) + 1;
+        mMax2DArrayTextureLevel = log2(mMax2DTextureDimension) + 1;
</ins><span class="cx">         mMaxTextureAnisotropy = mRenderer-&gt;getTextureMaxAnisotropy();
</span><del>-        TRACE(&quot;MaxTextureDimension=%d, MaxCubeTextureDimension=%d, MaxRenderbufferDimension=%d, MaxTextureLevel=%d, MaxTextureAnisotropy=%f&quot;,
-              mMaxTextureDimension, mMaxCubeTextureDimension, mMaxRenderbufferDimension, mMaxTextureLevel, mMaxTextureAnisotropy);
</del><ins>+        TRACE(&quot;Max2DTextureDimension=%d, MaxCubeTextureDimension=%d, Max3DTextureDimension=%d, Max2DArrayTextureLayers = %d, &quot;
+              &quot;Max2DTextureLevel=%d, MaxCubeTextureLevel=%d, Max3DTextureLevel=%d, Max2DArrayTextureLevel=%d, &quot;
+              &quot;MaxRenderbufferDimension=%d, MaxTextureAnisotropy=%f&quot;,
+              mMax2DTextureDimension, mMaxCubeTextureDimension, mMax3DTextureDimension, mMax2DArrayTextureLayers,
+              mMax2DTextureLevel, mMaxCubeTextureLevel, mMax3DTextureLevel, mMax2DArrayTextureLevel,
+              mMaxRenderbufferDimension, mMaxTextureAnisotropy);
</ins><span class="cx"> 
</span><span class="cx">         mSupportsEventQueries = mRenderer-&gt;getEventQuerySupport();
</span><span class="cx">         mSupportsOcclusionQueries = mRenderer-&gt;getOcclusionQuerySupport();
</span><span class="lines">@@ -268,13 +357,19 @@
</span><span class="cx">         mSupportsDXT1Textures = mRenderer-&gt;getDXT1TextureSupport();
</span><span class="cx">         mSupportsDXT3Textures = mRenderer-&gt;getDXT3TextureSupport();
</span><span class="cx">         mSupportsDXT5Textures = mRenderer-&gt;getDXT5TextureSupport();
</span><del>-        mSupportsFloat32Textures = mRenderer-&gt;getFloat32TextureSupport(&amp;mSupportsFloat32LinearFilter, &amp;mSupportsFloat32RenderableTextures);
-        mSupportsFloat16Textures = mRenderer-&gt;getFloat16TextureSupport(&amp;mSupportsFloat16LinearFilter, &amp;mSupportsFloat16RenderableTextures);
</del><ins>+        mSupportsFloat32Textures = mRenderer-&gt;getFloat32TextureSupport();
+        mSupportsFloat32LinearFilter = mRenderer-&gt;getFloat32TextureFilteringSupport();
+        mSupportsFloat32RenderableTextures = mRenderer-&gt;getFloat32TextureRenderingSupport();
+        mSupportsFloat16Textures = mRenderer-&gt;getFloat16TextureSupport();
+        mSupportsFloat16LinearFilter = mRenderer-&gt;getFloat16TextureFilteringSupport();
+        mSupportsFloat16RenderableTextures = mRenderer-&gt;getFloat16TextureRenderingSupport();
</ins><span class="cx">         mSupportsLuminanceTextures = mRenderer-&gt;getLuminanceTextureSupport();
</span><span class="cx">         mSupportsLuminanceAlphaTextures = mRenderer-&gt;getLuminanceAlphaTextureSupport();
</span><ins>+        mSupportsRGTextures = mRenderer-&gt;getRGTextureSupport();
</ins><span class="cx">         mSupportsDepthTextures = mRenderer-&gt;getDepthTextureSupport();
</span><span class="cx">         mSupportsTextureFilterAnisotropy = mRenderer-&gt;getTextureFilterAnisotropySupport();
</span><span class="cx">         mSupports32bitIndices = mRenderer-&gt;get32BitIndexSupport();
</span><ins>+        mSupportsPBOs = mRenderer-&gt;getPBOSupport();
</ins><span class="cx"> 
</span><span class="cx">         mNumCompressedTextureFormats = 0;
</span><span class="cx">         if (supportsDXT1Textures())
</span><span class="lines">@@ -314,6 +409,9 @@
</span><span class="cx">     Framebuffer *framebufferZero = new DefaultFramebuffer(mRenderer, colorbufferZero, depthStencilbufferZero);
</span><span class="cx"> 
</span><span class="cx">     setFramebufferZero(framebufferZero);
</span><ins>+
+    // Store the current client version in the renderer
+    mRenderer-&gt;setCurrentClientVersion(mClientVersion);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // NOTE: this function should not assume that this context is current!
</span><span class="lines">@@ -329,6 +427,44 @@
</span><span class="cx">     return mContextLost;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Context::setCap(GLenum cap, bool enabled)
+{
+    switch (cap)
+    {
+      case GL_CULL_FACE:                     setCullFace(enabled);              break;
+      case GL_POLYGON_OFFSET_FILL:           setPolygonOffsetFill(enabled);     break;
+      case GL_SAMPLE_ALPHA_TO_COVERAGE:      setSampleAlphaToCoverage(enabled); break;
+      case GL_SAMPLE_COVERAGE:               setSampleCoverage(enabled);        break;
+      case GL_SCISSOR_TEST:                  setScissorTest(enabled);           break;
+      case GL_STENCIL_TEST:                  setStencilTest(enabled);           break;
+      case GL_DEPTH_TEST:                    setDepthTest(enabled);             break;
+      case GL_BLEND:                         setBlend(enabled);                 break;
+      case GL_DITHER:                        setDither(enabled);                break;
+      case GL_PRIMITIVE_RESTART_FIXED_INDEX: UNIMPLEMENTED();                   break;
+      case GL_RASTERIZER_DISCARD:            setRasterizerDiscard(enabled);     break;
+      default:                               UNREACHABLE();
+    }
+}
+
+bool Context::getCap(GLenum cap)
+{
+    switch (cap)
+    {
+      case GL_CULL_FACE:                     return isCullFaceEnabled();
+      case GL_POLYGON_OFFSET_FILL:           return isPolygonOffsetFillEnabled();
+      case GL_SAMPLE_ALPHA_TO_COVERAGE:      return isSampleAlphaToCoverageEnabled();
+      case GL_SAMPLE_COVERAGE:               return isSampleCoverageEnabled();
+      case GL_SCISSOR_TEST:                  return isScissorTestEnabled();
+      case GL_STENCIL_TEST:                  return isStencilTestEnabled();
+      case GL_DEPTH_TEST:                    return isDepthTestEnabled();
+      case GL_BLEND:                         return isBlendEnabled();
+      case GL_DITHER:                        return isDitherEnabled();
+      case GL_PRIMITIVE_RESTART_FIXED_INDEX: UNIMPLEMENTED(); return false;
+      case GL_RASTERIZER_DISCARD:            return isRasterizerDiscardEnabled();
+      default:                               UNREACHABLE(); return false;
+    }
+}
+
</ins><span class="cx"> void Context::setClearColor(float red, float green, float blue, float alpha)
</span><span class="cx"> {
</span><span class="cx">     mState.colorClearValue.red = red;
</span><span class="lines">@@ -347,6 +483,16 @@
</span><span class="cx">     mState.stencilClearValue = stencil;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Context::setRasterizerDiscard(bool enabled)
+{
+    mState.rasterizer.rasterizerDiscard = enabled;
+}
+
+bool Context::isRasterizerDiscardEnabled() const
+{
+    return mState.rasterizer.rasterizerDiscard;
+}
+
</ins><span class="cx"> void Context::setCullFace(bool enabled)
</span><span class="cx"> {
</span><span class="cx">     mState.rasterizer.cullFace = enabled;
</span><span class="lines">@@ -565,6 +711,14 @@
</span><span class="cx">     mState.scissor.height = height;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Context::getScissorParams(GLint *x, GLint *y, GLsizei *width, GLsizei *height)
+{
+    *x = mState.scissor.x;
+    *y = mState.scissor.y;
+    *width = mState.scissor.width;
+    *height = mState.scissor.height;
+}
+
</ins><span class="cx"> void Context::setColorMask(bool red, bool green, bool blue, bool alpha)
</span><span class="cx"> {
</span><span class="cx">     mState.blend.colorMaskRed = red;
</span><span class="lines">@@ -598,6 +752,17 @@
</span><span class="cx">     return mState.renderbuffer.id();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLuint Context::getVertexArrayHandle() const
+{
+    return mState.vertexArray;
+}
+
+GLuint Context::getSamplerHandle(GLuint textureUnit) const
+{
+    ASSERT(textureUnit &lt; ArraySize(mState.samplers));
+    return mState.samplers[textureUnit];
+}
+
</ins><span class="cx"> GLuint Context::getArrayBufferHandle() const
</span><span class="cx"> {
</span><span class="cx">     return mState.arrayBuffer.id();
</span><span class="lines">@@ -605,86 +770,80 @@
</span><span class="cx"> 
</span><span class="cx"> GLuint Context::getActiveQuery(GLenum target) const
</span><span class="cx"> {
</span><del>-    Query *queryObject = NULL;
-    
-    switch (target)
-    {
-      case GL_ANY_SAMPLES_PASSED_EXT:
-        queryObject = mState.activeQuery[QUERY_ANY_SAMPLES_PASSED].get();
-        break;
-      case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
-        queryObject = mState.activeQuery[QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE].get();
-        break;
-      default:
-        ASSERT(false);
-    }
</del><ins>+    // All query types should already exist in the activeQueries map
+    ASSERT(mState.activeQueries.find(target) != mState.activeQueries.end());
</ins><span class="cx"> 
</span><del>-    if (queryObject)
-    {
-        return queryObject-&gt;id();
-    }
-    else
-    {
-        return 0;
-    }
</del><ins>+    const Query *queryObject = mState.activeQueries.at(target).get();
+    return queryObject ? queryObject-&gt;id() : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Context::setEnableVertexAttribArray(unsigned int attribNum, bool enabled)
</span><span class="cx"> {
</span><del>-    mState.vertexAttribute[attribNum].mArrayEnabled = enabled;
</del><ins>+    getCurrentVertexArray()-&gt;enableAttribute(attribNum, enabled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-const VertexAttribute &amp;Context::getVertexAttribState(unsigned int attribNum)
</del><ins>+const VertexAttribute &amp;Context::getVertexAttribState(unsigned int attribNum) const
</ins><span class="cx"> {
</span><del>-    return mState.vertexAttribute[attribNum];
</del><ins>+    return getCurrentVertexArray()-&gt;getVertexAttribute(attribNum);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const VertexAttribCurrentValueData &amp;Context::getVertexAttribCurrentValue(unsigned int attribNum) const
+{
+    ASSERT(attribNum &lt; MAX_VERTEX_ATTRIBS);
+    return mState.vertexAttribCurrentValues[attribNum];
+}
+
</ins><span class="cx"> void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, bool normalized,
</span><del>-                                   GLsizei stride, const void *pointer)
</del><ins>+                                   bool pureInteger, GLsizei stride, const void *pointer)
</ins><span class="cx"> {
</span><del>-    mState.vertexAttribute[attribNum].mBoundBuffer.set(boundBuffer);
-    mState.vertexAttribute[attribNum].mSize = size;
-    mState.vertexAttribute[attribNum].mType = type;
-    mState.vertexAttribute[attribNum].mNormalized = normalized;
-    mState.vertexAttribute[attribNum].mStride = stride;
-    mState.vertexAttribute[attribNum].mPointer = pointer;
</del><ins>+    getCurrentVertexArray()-&gt;setAttributeState(attribNum, boundBuffer, size, type, normalized, pureInteger, stride, pointer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const void *Context::getVertexAttribPointer(unsigned int attribNum) const
</span><span class="cx"> {
</span><del>-    return mState.vertexAttribute[attribNum].mPointer;
</del><ins>+    return getCurrentVertexArray()-&gt;getVertexAttribute(attribNum).mPointer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Context::setPackAlignment(GLint alignment)
</span><span class="cx"> {
</span><del>-    mState.packAlignment = alignment;
</del><ins>+    mState.pack.alignment = alignment;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLint Context::getPackAlignment() const
</span><span class="cx"> {
</span><del>-    return mState.packAlignment;
</del><ins>+    return mState.pack.alignment;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Context::setUnpackAlignment(GLint alignment)
</span><span class="cx"> {
</span><del>-    mState.unpackAlignment = alignment;
</del><ins>+    mState.unpack.alignment = alignment;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLint Context::getUnpackAlignment() const
</span><span class="cx"> {
</span><del>-    return mState.unpackAlignment;
</del><ins>+    return mState.unpack.alignment;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Context::setPackReverseRowOrder(bool reverseRowOrder)
</span><span class="cx"> {
</span><del>-    mState.packReverseRowOrder = reverseRowOrder;
</del><ins>+    mState.pack.reverseRowOrder = reverseRowOrder;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Context::getPackReverseRowOrder() const
</span><span class="cx"> {
</span><del>-    return mState.packReverseRowOrder;
</del><ins>+    return mState.pack.reverseRowOrder;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const PixelUnpackState &amp;Context::getUnpackState() const
+{
+    return mState.unpack;
+}
+
+const PixelPackState &amp;Context::getPackState() const
+{
+    return mState.pack;
+}
+
</ins><span class="cx"> GLuint Context::createBuffer()
</span><span class="cx"> {
</span><span class="cx">     return mResourceManager-&gt;createBuffer();
</span><span class="lines">@@ -710,6 +869,44 @@
</span><span class="cx">     return mResourceManager-&gt;createRenderbuffer();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLsync Context::createFenceSync(GLenum condition)
+{
+    GLuint handle = mResourceManager-&gt;createFenceSync();
+
+    gl::FenceSync *fenceSync = mResourceManager-&gt;getFenceSync(handle);
+    ASSERT(fenceSync);
+
+    fenceSync-&gt;set(condition);
+
+    return reinterpret_cast&lt;GLsync&gt;(handle);
+}
+
+GLuint Context::createVertexArray()
+{
+    GLuint handle = mVertexArrayHandleAllocator.allocate();
+
+    // Although the spec states VAO state is not initialized until the object is bound,
+    // we create it immediately. The resulting behaviour is transparent to the application,
+    // since it's not currently possible to access the state until the object is bound.
+    mVertexArrayMap[handle] = new VertexArray(mRenderer, handle);
+
+    return handle;
+}
+
+GLuint Context::createSampler()
+{
+    return mResourceManager-&gt;createSampler();
+}
+
+GLuint Context::createTransformFeedback()
+{
+    GLuint handle = mTransformFeedbackAllocator.allocate();
+    TransformFeedback *transformFeedback = new TransformFeedback(handle);
+    transformFeedback-&gt;addRef();
+    mTransformFeedbackMap[handle] = transformFeedback;
+    return handle;
+}
+
</ins><span class="cx"> // Returns an unused framebuffer name
</span><span class="cx"> GLuint Context::createFramebuffer()
</span><span class="cx"> {
</span><span class="lines">@@ -720,11 +917,11 @@
</span><span class="cx">     return handle;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLuint Context::createFence()
</del><ins>+GLuint Context::createFenceNV()
</ins><span class="cx"> {
</span><del>-    GLuint handle = mFenceHandleAllocator.allocate();
</del><ins>+    GLuint handle = mFenceNVHandleAllocator.allocate();
</ins><span class="cx"> 
</span><del>-    mFenceMap[handle] = new Fence(mRenderer);
</del><ins>+    mFenceNVMap[handle] = new FenceNV(mRenderer);
</ins><span class="cx"> 
</span><span class="cx">     return handle;
</span><span class="cx"> }
</span><span class="lines">@@ -779,6 +976,51 @@
</span><span class="cx">     mResourceManager-&gt;deleteRenderbuffer(renderbuffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Context::deleteFenceSync(GLsync fenceSync)
+{
+    // The spec specifies the underlying Fence object is not deleted until all current
+    // wait commands finish. However, since the name becomes invalid, we cannot query the fence,
+    // and since our API is currently designed for being called from a single thread, we can delete
+    // the fence immediately.
+    mResourceManager-&gt;deleteFenceSync(reinterpret_cast&lt;GLuint&gt;(fenceSync));
+}
+
+void Context::deleteVertexArray(GLuint vertexArray)
+{
+    auto vertexArrayObject = mVertexArrayMap.find(vertexArray);
+
+    if (vertexArrayObject != mVertexArrayMap.end())
+    {
+        detachVertexArray(vertexArray);
+
+        mVertexArrayHandleAllocator.release(vertexArrayObject-&gt;first);
+        delete vertexArrayObject-&gt;second;
+        mVertexArrayMap.erase(vertexArrayObject);
+    }
+}
+
+void Context::deleteSampler(GLuint sampler)
+{
+    if (mResourceManager-&gt;getSampler(sampler))
+    {
+        detachSampler(sampler);
+    }
+
+    mResourceManager-&gt;deleteSampler(sampler);
+}
+
+void Context::deleteTransformFeedback(GLuint transformFeedback)
+{
+    TransformFeedbackMap::const_iterator iter = mTransformFeedbackMap.find(transformFeedback);
+    if (iter != mTransformFeedbackMap.end())
+    {
+        detachTransformFeedback(transformFeedback);
+        mTransformFeedbackAllocator.release(transformFeedback);
+        iter-&gt;second-&gt;release();
+        mTransformFeedbackMap.erase(iter);
+    }
+}
+
</ins><span class="cx"> void Context::deleteFramebuffer(GLuint framebuffer)
</span><span class="cx"> {
</span><span class="cx">     FramebufferMap::iterator framebufferObject = mFramebufferMap.find(framebuffer);
</span><span class="lines">@@ -793,15 +1035,15 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Context::deleteFence(GLuint fence)
</del><ins>+void Context::deleteFenceNV(GLuint fence)
</ins><span class="cx"> {
</span><del>-    FenceMap::iterator fenceObject = mFenceMap.find(fence);
</del><ins>+    FenceNVMap::iterator fenceObject = mFenceNVMap.find(fence);
</ins><span class="cx"> 
</span><del>-    if (fenceObject != mFenceMap.end())
</del><ins>+    if (fenceObject != mFenceNVMap.end())
</ins><span class="cx">     {
</span><del>-        mFenceHandleAllocator.release(fenceObject-&gt;first);
</del><ins>+        mFenceNVHandleAllocator.release(fenceObject-&gt;first);
</ins><span class="cx">         delete fenceObject-&gt;second;
</span><del>-        mFenceMap.erase(fenceObject);
</del><ins>+        mFenceNVMap.erase(fenceObject);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -824,12 +1066,12 @@
</span><span class="cx">     return mResourceManager-&gt;getBuffer(handle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Shader *Context::getShader(GLuint handle)
</del><ins>+Shader *Context::getShader(GLuint handle) const
</ins><span class="cx"> {
</span><span class="cx">     return mResourceManager-&gt;getShader(handle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Program *Context::getProgram(GLuint handle)
</del><ins>+Program *Context::getProgram(GLuint handle) const
</ins><span class="cx"> {
</span><span class="cx">     return mResourceManager-&gt;getProgram(handle);
</span><span class="cx"> }
</span><span class="lines">@@ -844,6 +1086,43 @@
</span><span class="cx">     return mResourceManager-&gt;getRenderbuffer(handle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+FenceSync *Context::getFenceSync(GLsync handle) const
+{
+    return mResourceManager-&gt;getFenceSync(reinterpret_cast&lt;GLuint&gt;(handle));
+}
+
+VertexArray *Context::getVertexArray(GLuint handle) const
+{
+    auto vertexArray = mVertexArrayMap.find(handle);
+
+    if (vertexArray == mVertexArrayMap.end())
+    {
+        return NULL;
+    }
+    else
+    {
+        return vertexArray-&gt;second;
+    }
+}
+
+Sampler *Context::getSampler(GLuint handle) const
+{
+    return mResourceManager-&gt;getSampler(handle);
+}
+
+TransformFeedback *Context::getTransformFeedback(GLuint handle) const
+{
+    if (handle == 0)
+    {
+        return mTransformFeedbackZero.get();
+    }
+    else
+    {
+        TransformFeedbackMap::const_iterator iter = mTransformFeedbackMap.find(handle);
+        return (iter != mTransformFeedbackMap.end()) ? iter-&gt;second : NULL;
+    }
+}
+
</ins><span class="cx"> Framebuffer *Context::getReadFramebuffer()
</span><span class="cx"> {
</span><span class="cx">     return getFramebuffer(mState.readFramebuffer);
</span><span class="lines">@@ -854,6 +1133,23 @@
</span><span class="cx">     return mBoundDrawFramebuffer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+VertexArray *Context::getCurrentVertexArray() const
+{
+    VertexArray *vao = getVertexArray(mState.vertexArray);
+    ASSERT(vao != NULL);
+    return vao;
+}
+
+TransformFeedback *Context::getCurrentTransformFeedback() const
+{
+    return mState.transformFeedback.get();
+}
+
+bool Context::isSampler(GLuint samplerName) const
+{
+    return mResourceManager-&gt;isSampler(samplerName);
+}
+
</ins><span class="cx"> void Context::bindArrayBuffer(unsigned int buffer)
</span><span class="cx"> {
</span><span class="cx">     mResourceManager-&gt;checkBufferAllocation(buffer);
</span><span class="lines">@@ -865,7 +1161,7 @@
</span><span class="cx"> {
</span><span class="cx">     mResourceManager-&gt;checkBufferAllocation(buffer);
</span><span class="cx"> 
</span><del>-    mState.elementArrayBuffer.set(getBuffer(buffer));
</del><ins>+    getCurrentVertexArray()-&gt;setElementArrayBuffer(getBuffer(buffer));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Context::bindTexture2D(GLuint texture)
</span><span class="lines">@@ -882,6 +1178,20 @@
</span><span class="cx">     mState.samplerTexture[TEXTURE_CUBE][mState.activeSampler].set(getTexture(texture));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Context::bindTexture3D(GLuint texture)
+{
+    mResourceManager-&gt;checkTextureAllocation(texture, TEXTURE_3D);
+
+    mState.samplerTexture[TEXTURE_3D][mState.activeSampler].set(getTexture(texture));
+}
+
+void Context::bindTexture2DArray(GLuint texture)
+{
+    mResourceManager-&gt;checkTextureAllocation(texture, TEXTURE_2D_ARRAY);
+
+    mState.samplerTexture[TEXTURE_2D_ARRAY][mState.activeSampler].set(getTexture(texture));
+}
+
</ins><span class="cx"> void Context::bindReadFramebuffer(GLuint framebuffer)
</span><span class="cx"> {
</span><span class="cx">     if (!getFramebuffer(framebuffer))
</span><span class="lines">@@ -911,6 +1221,80 @@
</span><span class="cx">     mState.renderbuffer.set(getRenderbuffer(renderbuffer));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Context::bindVertexArray(GLuint vertexArray)
+{
+    if (!getVertexArray(vertexArray))
+    {
+        mVertexArrayMap[vertexArray] = new VertexArray(mRenderer, vertexArray);
+    }
+
+    mState.vertexArray = vertexArray;
+}
+
+void Context::bindSampler(GLuint textureUnit, GLuint sampler)
+{
+    ASSERT(textureUnit &lt; ArraySize(mState.samplers));
+    mResourceManager-&gt;checkSamplerAllocation(sampler);
+
+    mState.samplers[textureUnit] = sampler;
+}
+
+void Context::bindGenericUniformBuffer(GLuint buffer)
+{
+    mResourceManager-&gt;checkBufferAllocation(buffer);
+
+    mState.genericUniformBuffer.set(getBuffer(buffer));
+}
+
+void Context::bindIndexedUniformBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size)
+{
+    mResourceManager-&gt;checkBufferAllocation(buffer);
+
+    mState.uniformBuffers[index].set(getBuffer(buffer), offset, size);
+}
+
+void Context::bindGenericTransformFeedbackBuffer(GLuint buffer)
+{
+    mResourceManager-&gt;checkBufferAllocation(buffer);
+
+    mState.genericTransformFeedbackBuffer.set(getBuffer(buffer));
+}
+
+void Context::bindIndexedTransformFeedbackBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size)
+{
+    mResourceManager-&gt;checkBufferAllocation(buffer);
+
+    mState.transformFeedbackBuffers[index].set(getBuffer(buffer), offset, size);
+}
+
+void Context::bindCopyReadBuffer(GLuint buffer)
+{
+    mResourceManager-&gt;checkBufferAllocation(buffer);
+
+    mState.copyReadBuffer.set(getBuffer(buffer));
+}
+
+void Context::bindCopyWriteBuffer(GLuint buffer)
+{
+    mResourceManager-&gt;checkBufferAllocation(buffer);
+
+    mState.copyWriteBuffer.set(getBuffer(buffer));
+}
+
+void Context::bindPixelPackBuffer(GLuint buffer)
+{
+    mResourceManager-&gt;checkBufferAllocation(buffer);
+
+    mState.pack.pixelBuffer.set(getBuffer(buffer));
+}
+
+void Context::bindPixelUnpackBuffer(GLuint buffer)
+{
+    mResourceManager-&gt;checkBufferAllocation(buffer);
+
+    mState.unpack.pixelBuffer.set(getBuffer(buffer));
+}
+
</ins><span class="cx"> void Context::useProgram(GLuint program)
</span><span class="cx"> {
</span><span class="cx">     GLuint priorProgram = mState.currentProgram;
</span><span class="lines">@@ -964,6 +1348,12 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Context::bindTransformFeedback(GLuint transformFeedback)
+{
+    TransformFeedback *transformFeedbackObject = getTransformFeedback(transformFeedback);
+    mState.transformFeedback.set(transformFeedbackObject);
+}
+
</ins><span class="cx"> void Context::beginQuery(GLenum target, GLuint query)
</span><span class="cx"> {
</span><span class="cx">     // From EXT_occlusion_query_boolean: If BeginQueryEXT is called with an &lt;id&gt;  
</span><span class="lines">@@ -981,28 +1371,14 @@
</span><span class="cx">     //    b) There are no active queries for the requested target (and in the case
</span><span class="cx">     //       of GL_ANY_SAMPLES_PASSED_EXT and GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT,
</span><span class="cx">     //       no query may be active for either if glBeginQuery targets either.
</span><del>-    for (int i = 0; i &lt; QUERY_TYPE_COUNT; i++)
</del><ins>+    for (State::ActiveQueryMap::iterator i = mState.activeQueries.begin(); i != mState.activeQueries.end(); i++)
</ins><span class="cx">     {
</span><del>-        if (mState.activeQuery[i].get() != NULL)
</del><ins>+        if (i-&gt;second.get() != NULL)
</ins><span class="cx">         {
</span><span class="cx">             return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    QueryType qType;
-    switch (target)
-    {
-      case GL_ANY_SAMPLES_PASSED_EXT: 
-        qType = QUERY_ANY_SAMPLES_PASSED; 
-        break;
-      case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: 
-        qType = QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE; 
-        break;
-      default: 
-        ASSERT(false);
-        return;
-    }
-
</del><span class="cx">     Query *queryObject = getQuery(query, true, target);
</span><span class="cx"> 
</span><span class="cx">     // check that name was obtained with glGenQueries
</span><span class="lines">@@ -1018,7 +1394,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // set query as active for specified target
</span><del>-    mState.activeQuery[qType].set(queryObject);
</del><ins>+    mState.activeQueries[target].set(queryObject);
</ins><span class="cx"> 
</span><span class="cx">     // begin query
</span><span class="cx">     queryObject-&gt;begin();
</span><span class="lines">@@ -1026,23 +1402,8 @@
</span><span class="cx"> 
</span><span class="cx"> void Context::endQuery(GLenum target)
</span><span class="cx"> {
</span><del>-    QueryType qType;
</del><ins>+    Query *queryObject = mState.activeQueries[target].get();
</ins><span class="cx"> 
</span><del>-    switch (target)
-    {
-      case GL_ANY_SAMPLES_PASSED_EXT: 
-        qType = QUERY_ANY_SAMPLES_PASSED; 
-        break;
-      case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: 
-        qType = QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE; 
-        break;
-      default: 
-        ASSERT(false);
-        return;
-    }
-
-    Query *queryObject = mState.activeQuery[qType].get();
-
</del><span class="cx">     if (queryObject == NULL)
</span><span class="cx">     {
</span><span class="cx">         return gl::error(GL_INVALID_OPERATION);
</span><span class="lines">@@ -1050,7 +1411,7 @@
</span><span class="cx"> 
</span><span class="cx">     queryObject-&gt;end();
</span><span class="cx"> 
</span><del>-    mState.activeQuery[qType].set(NULL);
</del><ins>+    mState.activeQueries[target].set(NULL);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Context::setFramebufferZero(Framebuffer *buffer)
</span><span class="lines">@@ -1065,36 +1426,41 @@
</span><span class="cx"> 
</span><span class="cx"> void Context::setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples)
</span><span class="cx"> {
</span><ins>+    const bool color = gl::IsColorRenderingSupported(internalformat, this);
+    const bool depth = gl::IsDepthRenderingSupported(internalformat, this);
+    const bool stencil = gl::IsStencilRenderingSupported(internalformat, this);
+
</ins><span class="cx">     RenderbufferStorage *renderbuffer = NULL;
</span><del>-    switch (internalformat)
</del><ins>+
+    if (color)
</ins><span class="cx">     {
</span><del>-      case GL_DEPTH_COMPONENT16:
-        renderbuffer = new gl::Depthbuffer(mRenderer, width, height, samples);
-        break;
-      case GL_RGBA4:
-      case GL_RGB5_A1:
-      case GL_RGB565:
-      case GL_RGB8_OES:
-      case GL_RGBA8_OES:
</del><span class="cx">         renderbuffer = new gl::Colorbuffer(mRenderer,width, height, internalformat, samples);
</span><del>-        break;
-      case GL_STENCIL_INDEX8:
-        renderbuffer = new gl::Stencilbuffer(mRenderer, width, height, samples);
-        break;
-      case GL_DEPTH24_STENCIL8_OES:
</del><ins>+    }
+    else if (depth &amp;&amp; stencil)
+    {
</ins><span class="cx">         renderbuffer = new gl::DepthStencilbuffer(mRenderer, width, height, samples);
</span><del>-        break;
-      default:
-        UNREACHABLE(); return;
</del><span class="cx">     }
</span><ins>+    else if (depth)
+    {
+        renderbuffer = new gl::Depthbuffer(mRenderer, width, height, samples);
+    }
+    else if (stencil)
+    {
+        renderbuffer = new gl::Stencilbuffer(mRenderer, width, height, samples);
+    }
+    else
+    {
+        UNREACHABLE();
+        return;
+    }
</ins><span class="cx"> 
</span><span class="cx">     Renderbuffer *renderbufferObject = mState.renderbuffer.get();
</span><span class="cx">     renderbufferObject-&gt;setStorage(renderbuffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Framebuffer *Context::getFramebuffer(unsigned int handle)
</del><ins>+Framebuffer *Context::getFramebuffer(unsigned int handle) const
</ins><span class="cx"> {
</span><del>-    FramebufferMap::iterator framebuffer = mFramebufferMap.find(handle);
</del><ins>+    FramebufferMap::const_iterator framebuffer = mFramebufferMap.find(handle);
</ins><span class="cx"> 
</span><span class="cx">     if (framebuffer == mFramebufferMap.end())
</span><span class="cx">     {
</span><span class="lines">@@ -1106,11 +1472,11 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Fence *Context::getFence(unsigned int handle)
</del><ins>+FenceNV *Context::getFenceNV(unsigned int handle)
</ins><span class="cx"> {
</span><del>-    FenceMap::iterator fence = mFenceMap.find(handle);
</del><ins>+    FenceNVMap::iterator fence = mFenceNVMap.find(handle);
</ins><span class="cx"> 
</span><del>-    if (fence == mFenceMap.end())
</del><ins>+    if (fence == mFenceNVMap.end())
</ins><span class="cx">     {
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="lines">@@ -1139,14 +1505,30 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Buffer *Context::getTargetBuffer(GLenum target) const
+{
+    switch (target)
+    {
+      case GL_ARRAY_BUFFER:              return mState.arrayBuffer.get();
+      case GL_COPY_READ_BUFFER:          return mState.copyReadBuffer.get();
+      case GL_COPY_WRITE_BUFFER:         return mState.copyWriteBuffer.get();
+      case GL_ELEMENT_ARRAY_BUFFER:      return getCurrentVertexArray()-&gt;getElementArrayBuffer();
+      case GL_PIXEL_PACK_BUFFER:         return mState.pack.pixelBuffer.get();
+      case GL_PIXEL_UNPACK_BUFFER:       return mState.unpack.pixelBuffer.get();
+      case GL_TRANSFORM_FEEDBACK_BUFFER: return mState.genericTransformFeedbackBuffer.get();
+      case GL_UNIFORM_BUFFER:            return mState.genericUniformBuffer.get();
+      default: UNREACHABLE();            return NULL;
+    }
+}
+
</ins><span class="cx"> Buffer *Context::getArrayBuffer()
</span><span class="cx"> {
</span><span class="cx">     return mState.arrayBuffer.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Buffer *Context::getElementArrayBuffer()
</del><ins>+Buffer *Context::getElementArrayBuffer() const
</ins><span class="cx"> {
</span><del>-    return mState.elementArrayBuffer.get();
</del><ins>+    return getCurrentVertexArray()-&gt;getElementArrayBuffer();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ProgramBinary *Context::getCurrentProgramBinary()
</span><span class="lines">@@ -1154,18 +1536,98 @@
</span><span class="cx">     return mCurrentProgramBinary.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Texture2D *Context::getTexture2D()
</del><ins>+Texture *Context::getTargetTexture(GLenum target) const
</ins><span class="cx"> {
</span><ins>+    if (!ValidTextureTarget(this, target))
+    {
+        return NULL;
+    }
+
+    switch (target)
+    {
+      case GL_TEXTURE_2D:       return getTexture2D();
+      case GL_TEXTURE_CUBE_MAP: return getTextureCubeMap();
+      case GL_TEXTURE_3D:       return getTexture3D();
+      case GL_TEXTURE_2D_ARRAY: return getTexture2DArray();
+      default:                  return NULL;
+    }
+}
+
+GLuint Context::getTargetFramebufferHandle(GLenum target) const
+{
+    if (!ValidFramebufferTarget(target))
+    {
+        return GL_INVALID_INDEX;
+    }
+
+    if (target == GL_READ_FRAMEBUFFER_ANGLE)
+    {
+        return mState.readFramebuffer;
+    }
+    else
+    {
+        return mState.drawFramebuffer;
+    }
+}
+
+Framebuffer *Context::getTargetFramebuffer(GLenum target) const
+{
+    GLuint framebufferHandle = getTargetFramebufferHandle(target);
+    return (framebufferHandle == GL_INVALID_INDEX ? NULL : getFramebuffer(framebufferHandle));
+}
+
+Texture2D *Context::getTexture2D() const
+{
</ins><span class="cx">     return static_cast&lt;Texture2D*&gt;(getSamplerTexture(mState.activeSampler, TEXTURE_2D));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureCubeMap *Context::getTextureCubeMap()
</del><ins>+TextureCubeMap *Context::getTextureCubeMap() const
</ins><span class="cx"> {
</span><span class="cx">     return static_cast&lt;TextureCubeMap*&gt;(getSamplerTexture(mState.activeSampler, TEXTURE_CUBE));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type)
</del><ins>+Texture3D *Context::getTexture3D() const
</ins><span class="cx"> {
</span><ins>+    return static_cast&lt;Texture3D*&gt;(getSamplerTexture(mState.activeSampler, TEXTURE_3D));
+}
+
+Texture2DArray *Context::getTexture2DArray() const
+{
+    return static_cast&lt;Texture2DArray*&gt;(getSamplerTexture(mState.activeSampler, TEXTURE_2D_ARRAY));
+}
+
+Buffer *Context::getGenericUniformBuffer()
+{
+    return mState.genericUniformBuffer.get();
+}
+
+Buffer *Context::getGenericTransformFeedbackBuffer()
+{
+    return mState.genericTransformFeedbackBuffer.get();
+}
+
+Buffer *Context::getCopyReadBuffer()
+{
+    return mState.copyReadBuffer.get();
+}
+
+Buffer *Context::getCopyWriteBuffer()
+{
+    return mState.copyWriteBuffer.get();
+}
+
+Buffer *Context::getPixelPackBuffer()
+{
+    return mState.pack.pixelBuffer.get();
+}
+
+Buffer *Context::getPixelUnpackBuffer()
+{
+    return mState.unpack.pixelBuffer.get();
+}
+
+Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type) const
+{
</ins><span class="cx">     GLuint texid = mState.samplerTexture[type][sampler].id();
</span><span class="cx"> 
</span><span class="cx">     if (texid == 0)   // Special case: 0 refers to different initial textures based on the target
</span><span class="lines">@@ -1173,8 +1635,10 @@
</span><span class="cx">         switch (type)
</span><span class="cx">         {
</span><span class="cx">           default: UNREACHABLE();
</span><del>-          case TEXTURE_2D: return mTexture2DZero.get();
-          case TEXTURE_CUBE: return mTextureCubeMapZero.get();
</del><ins>+          case TEXTURE_2D:       return mTexture2DZero.get();
+          case TEXTURE_CUBE:     return mTextureCubeMapZero.get();
+          case TEXTURE_3D:       return mTexture3DZero.get();
+          case TEXTURE_2D_ARRAY: return mTexture2DArrayZero.get();
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1204,6 +1668,8 @@
</span><span class="cx">       case GL_BLEND:                     *params = mState.blend.blend;                  break;
</span><span class="cx">       case GL_DITHER:                    *params = mState.blend.dither;                 break;
</span><span class="cx">       case GL_CONTEXT_ROBUST_ACCESS_EXT: *params = mRobustAccess ? GL_TRUE : GL_FALSE;  break;
</span><ins>+      case GL_TRANSFORM_FEEDBACK_ACTIVE: *params = getCurrentTransformFeedback()-&gt;isStarted(); break;
+      case GL_TRANSFORM_FEEDBACK_PAUSED: *params = getCurrentTransformFeedback()-&gt;isPaused();  break;
</ins><span class="cx">       default:
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -1287,56 +1753,73 @@
</span><span class="cx">     // Context::getFloatv.
</span><span class="cx">     switch (pname)
</span><span class="cx">     {
</span><del>-      case GL_MAX_VERTEX_ATTRIBS:               *params = gl::MAX_VERTEX_ATTRIBS;               break;
-      case GL_MAX_VERTEX_UNIFORM_VECTORS:       *params = mRenderer-&gt;getMaxVertexUniformVectors(); break;
-      case GL_MAX_VARYING_VECTORS:              *params = mRenderer-&gt;getMaxVaryingVectors();    break;
-      case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = mRenderer-&gt;getMaxCombinedTextureImageUnits(); break;
-      case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:   *params = mRenderer-&gt;getMaxVertexTextureImageUnits(); break;
-      case GL_MAX_TEXTURE_IMAGE_UNITS:          *params = gl::MAX_TEXTURE_IMAGE_UNITS;          break;
-      case GL_MAX_FRAGMENT_UNIFORM_VECTORS:     *params = mRenderer-&gt;getMaxFragmentUniformVectors(); break;
-      case GL_MAX_RENDERBUFFER_SIZE:            *params = getMaximumRenderbufferDimension();    break;
-      case GL_MAX_COLOR_ATTACHMENTS_EXT:        *params = mRenderer-&gt;getMaxRenderTargets();     break;
-      case GL_MAX_DRAW_BUFFERS_EXT:             *params = mRenderer-&gt;getMaxRenderTargets();     break;
-      case GL_NUM_SHADER_BINARY_FORMATS:        *params = 0;                                    break;
-      case GL_SHADER_BINARY_FORMATS:      /* no shader binary formats are supported */          break;
-      case GL_ARRAY_BUFFER_BINDING:             *params = mState.arrayBuffer.id();              break;
-      case GL_ELEMENT_ARRAY_BUFFER_BINDING:     *params = mState.elementArrayBuffer.id();       break;
-      //case GL_FRAMEBUFFER_BINDING:            // now equivalent to GL_DRAW_FRAMEBUFFER_BINDING_ANGLE
-      case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE:   *params = mState.drawFramebuffer;               break;
-      case GL_READ_FRAMEBUFFER_BINDING_ANGLE:   *params = mState.readFramebuffer;               break;
-      case GL_RENDERBUFFER_BINDING:             *params = mState.renderbuffer.id();             break;
-      case GL_CURRENT_PROGRAM:                  *params = mState.currentProgram;                break;
-      case GL_PACK_ALIGNMENT:                   *params = mState.packAlignment;                 break;
-      case GL_PACK_REVERSE_ROW_ORDER_ANGLE:     *params = mState.packReverseRowOrder;           break;
-      case GL_UNPACK_ALIGNMENT:                 *params = mState.unpackAlignment;               break;
-      case GL_GENERATE_MIPMAP_HINT:             *params = mState.generateMipmapHint;            break;
-      case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: *params = mState.fragmentShaderDerivativeHint; break;
-      case GL_ACTIVE_TEXTURE:                   *params = (mState.activeSampler + GL_TEXTURE0); break;
-      case GL_STENCIL_FUNC:                     *params = mState.depthStencil.stencilFunc;             break;
-      case GL_STENCIL_REF:                      *params = mState.stencilRef;                           break;
-      case GL_STENCIL_VALUE_MASK:               *params = mState.depthStencil.stencilMask;             break;
-      case GL_STENCIL_BACK_FUNC:                *params = mState.depthStencil.stencilBackFunc;         break;
-      case GL_STENCIL_BACK_REF:                 *params = mState.stencilBackRef;                       break;
-      case GL_STENCIL_BACK_VALUE_MASK:          *params = mState.depthStencil.stencilBackMask;         break;
-      case GL_STENCIL_FAIL:                     *params = mState.depthStencil.stencilFail;             break;
-      case GL_STENCIL_PASS_DEPTH_FAIL:          *params = mState.depthStencil.stencilPassDepthFail;    break;
-      case GL_STENCIL_PASS_DEPTH_PASS:          *params = mState.depthStencil.stencilPassDepthPass;    break;
-      case GL_STENCIL_BACK_FAIL:                *params = mState.depthStencil.stencilBackFail;         break;
-      case GL_STENCIL_BACK_PASS_DEPTH_FAIL:     *params = mState.depthStencil.stencilBackPassDepthFail; break;
-      case GL_STENCIL_BACK_PASS_DEPTH_PASS:     *params = mState.depthStencil.stencilBackPassDepthPass; break;
-      case GL_DEPTH_FUNC:                       *params = mState.depthStencil.depthFunc;               break;
-      case GL_BLEND_SRC_RGB:                    *params = mState.blend.sourceBlendRGB;                 break;
-      case GL_BLEND_SRC_ALPHA:                  *params = mState.blend.sourceBlendAlpha;               break;
-      case GL_BLEND_DST_RGB:                    *params = mState.blend.destBlendRGB;                   break;
-      case GL_BLEND_DST_ALPHA:                  *params = mState.blend.destBlendAlpha;                 break;
-      case GL_BLEND_EQUATION_RGB:               *params = mState.blend.blendEquationRGB;               break;
-      case GL_BLEND_EQUATION_ALPHA:             *params = mState.blend.blendEquationAlpha;             break;
-      case GL_STENCIL_WRITEMASK:                *params = mState.depthStencil.stencilWritemask;        break;
-      case GL_STENCIL_BACK_WRITEMASK:           *params = mState.depthStencil.stencilBackWritemask;    break;
-      case GL_STENCIL_CLEAR_VALUE:              *params = mState.stencilClearValue;             break;
-      case GL_SUBPIXEL_BITS:                    *params = 4;                                    break;
-      case GL_MAX_TEXTURE_SIZE:                 *params = getMaximumTextureDimension();         break;
-      case GL_MAX_CUBE_MAP_TEXTURE_SIZE:        *params = getMaximumCubeTextureDimension();     break;
</del><ins>+      case GL_MAX_VERTEX_ATTRIBS:                       *params = gl::MAX_VERTEX_ATTRIBS;                               break;
+      case GL_MAX_VERTEX_UNIFORM_VECTORS:               *params = mRenderer-&gt;getMaxVertexUniformVectors();              break;
+      case GL_MAX_VERTEX_UNIFORM_COMPONENTS:            *params = mRenderer-&gt;getMaxVertexUniformVectors() * 4;          break;
+      case GL_MAX_VARYING_VECTORS:                      *params = mRenderer-&gt;getMaxVaryingVectors();                    break;
+      case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:         *params = mRenderer-&gt;getMaxCombinedTextureImageUnits();         break;
+      case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:           *params = mRenderer-&gt;getMaxVertexTextureImageUnits();           break;
+      case GL_MAX_TEXTURE_IMAGE_UNITS:                  *params = gl::MAX_TEXTURE_IMAGE_UNITS;                          break;
+      case GL_MAX_FRAGMENT_UNIFORM_VECTORS:             *params = mRenderer-&gt;getMaxFragmentUniformVectors();            break;
+      case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:          *params = mRenderer-&gt;getMaxFragmentUniformVectors() * 4;        break;
+      case GL_MAX_RENDERBUFFER_SIZE:                    *params = getMaximumRenderbufferDimension();                    break;
+      case GL_MAX_COLOR_ATTACHMENTS_EXT:                *params = mRenderer-&gt;getMaxRenderTargets();                     break;
+      case GL_MAX_DRAW_BUFFERS_EXT:                     *params = mRenderer-&gt;getMaxRenderTargets();                     break;
+      case GL_NUM_SHADER_BINARY_FORMATS:                *params = 0;                                                    break;
+      case GL_SHADER_BINARY_FORMATS:                    /* no shader binary formats are supported */                    break;
+      case GL_ARRAY_BUFFER_BINDING:                     *params = mState.arrayBuffer.id();                              break;
+      case GL_ELEMENT_ARRAY_BUFFER_BINDING:             *params = getCurrentVertexArray()-&gt;getElementArrayBufferId();   break;
+      //case GL_FRAMEBUFFER_BINDING:                    // now equivalent to GL_DRAW_FRAMEBUFFER_BINDING_ANGLE
+      case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE:           *params = mState.drawFramebuffer;                               break;
+      case GL_READ_FRAMEBUFFER_BINDING_ANGLE:           *params = mState.readFramebuffer;                               break;
+      case GL_RENDERBUFFER_BINDING:                     *params = mState.renderbuffer.id();                             break;
+      case GL_VERTEX_ARRAY_BINDING:                     *params = mState.vertexArray;                                   break;
+      case GL_CURRENT_PROGRAM:                          *params = mState.currentProgram;                                break;
+      case GL_PACK_ALIGNMENT:                           *params = mState.pack.alignment;                                break;
+      case GL_PACK_REVERSE_ROW_ORDER_ANGLE:             *params = mState.pack.reverseRowOrder;                          break;
+      case GL_UNPACK_ALIGNMENT:                         *params = mState.unpack.alignment;                              break;
+      case GL_GENERATE_MIPMAP_HINT:                     *params = mState.generateMipmapHint;                            break;
+      case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:      *params = mState.fragmentShaderDerivativeHint;                  break;
+      case GL_ACTIVE_TEXTURE:                           *params = (mState.activeSampler + GL_TEXTURE0);                 break;
+      case GL_STENCIL_FUNC:                             *params = mState.depthStencil.stencilFunc;                      break;
+      case GL_STENCIL_REF:                              *params = mState.stencilRef;                                    break;
+      case GL_STENCIL_VALUE_MASK:                       *params = clampToInt(mState.depthStencil.stencilMask);          break;
+      case GL_STENCIL_BACK_FUNC:                        *params = mState.depthStencil.stencilBackFunc;                  break;
+      case GL_STENCIL_BACK_REF:                         *params = mState.stencilBackRef;                                break;
+      case GL_STENCIL_BACK_VALUE_MASK:                  *params = clampToInt(mState.depthStencil.stencilBackMask);      break;
+      case GL_STENCIL_FAIL:                             *params = mState.depthStencil.stencilFail;                      break;
+      case GL_STENCIL_PASS_DEPTH_FAIL:                  *params = mState.depthStencil.stencilPassDepthFail;             break;
+      case GL_STENCIL_PASS_DEPTH_PASS:                  *params = mState.depthStencil.stencilPassDepthPass;             break;
+      case GL_STENCIL_BACK_FAIL:                        *params = mState.depthStencil.stencilBackFail;                  break;
+      case GL_STENCIL_BACK_PASS_DEPTH_FAIL:             *params = mState.depthStencil.stencilBackPassDepthFail;         break;
+      case GL_STENCIL_BACK_PASS_DEPTH_PASS:             *params = mState.depthStencil.stencilBackPassDepthPass;         break;
+      case GL_DEPTH_FUNC:                               *params = mState.depthStencil.depthFunc;                        break;
+      case GL_BLEND_SRC_RGB:                            *params = mState.blend.sourceBlendRGB;                          break;
+      case GL_BLEND_SRC_ALPHA:                          *params = mState.blend.sourceBlendAlpha;                        break;
+      case GL_BLEND_DST_RGB:                            *params = mState.blend.destBlendRGB;                            break;
+      case GL_BLEND_DST_ALPHA:                          *params = mState.blend.destBlendAlpha;                          break;
+      case GL_BLEND_EQUATION_RGB:                       *params = mState.blend.blendEquationRGB;                        break;
+      case GL_BLEND_EQUATION_ALPHA:                     *params = mState.blend.blendEquationAlpha;                      break;
+      case GL_STENCIL_WRITEMASK:                        *params = clampToInt(mState.depthStencil.stencilWritemask);     break;
+      case GL_STENCIL_BACK_WRITEMASK:                   *params = clampToInt(mState.depthStencil.stencilBackWritemask); break;
+      case GL_STENCIL_CLEAR_VALUE:                      *params = mState.stencilClearValue;                             break;
+      case GL_SUBPIXEL_BITS:                            *params = 4;                                                    break;
+      case GL_MAX_TEXTURE_SIZE:                         *params = getMaximum2DTextureDimension();                       break;
+      case GL_MAX_CUBE_MAP_TEXTURE_SIZE:                *params = getMaximumCubeTextureDimension();                     break;
+      case GL_MAX_3D_TEXTURE_SIZE:                      *params = getMaximum3DTextureDimension();                       break;
+      case GL_MAX_ARRAY_TEXTURE_LAYERS:                 *params = getMaximum2DArrayTextureLayers();                     break;
+      case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:          *params = getUniformBufferOffsetAlignment();                    break;
+      case GL_MAX_UNIFORM_BUFFER_BINDINGS:              *params = getMaximumCombinedUniformBufferBindings();            break;
+      case GL_MAX_VERTEX_UNIFORM_BLOCKS:                *params = mRenderer-&gt;getMaxVertexShaderUniformBuffers();        break;
+      case GL_MAX_FRAGMENT_UNIFORM_BLOCKS:              *params = mRenderer-&gt;getMaxFragmentShaderUniformBuffers();      break;
+      case GL_MAX_COMBINED_UNIFORM_BLOCKS:              *params = getMaximumCombinedUniformBufferBindings();            break;
+      case GL_MAJOR_VERSION:                            *params = mClientVersion;                                       break;
+      case GL_MINOR_VERSION:                            *params = 0;                                                    break;
+      case GL_MAX_ELEMENTS_INDICES:                     *params = mRenderer-&gt;getMaxRecommendedElementsIndices();        break;
+      case GL_MAX_ELEMENTS_VERTICES:                    *params = mRenderer-&gt;getMaxRecommendedElementsVertices();       break;
+      case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: *params = mRenderer-&gt;getMaxTransformFeedbackInterleavedComponents(); break;
+      case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:       *params = mRenderer-&gt;getMaxTransformFeedbackBuffers();               break;
+      case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:    *params = mRenderer-&gt;getMaxTransformFeedbackSeparateComponents();    break;
</ins><span class="cx">       case GL_NUM_COMPRESSED_TEXTURE_FORMATS:   
</span><span class="cx">         params[0] = mNumCompressedTextureFormats;
</span><span class="cx">         break;
</span><span class="lines">@@ -1386,8 +1869,8 @@
</span><span class="cx">       case GL_IMPLEMENTATION_COLOR_READ_TYPE:
</span><span class="cx">       case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
</span><span class="cx">         {
</span><del>-            GLenum format, type;
-            if (getCurrentReadFormatType(&amp;format, &amp;type))
</del><ins>+            GLenum internalFormat, format, type;
+            if (getCurrentReadFormatType(&amp;internalFormat, &amp;format, &amp;type))
</ins><span class="cx">             {
</span><span class="cx">                 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT)
</span><span class="cx">                     *params = format;
</span><span class="lines">@@ -1509,6 +1992,28 @@
</span><span class="cx">             *params = mState.samplerTexture[TEXTURE_CUBE][mState.activeSampler].id();
</span><span class="cx">         }
</span><span class="cx">         break;
</span><ins>+      case GL_TEXTURE_BINDING_3D:
+        {
+            if (mState.activeSampler &gt; mRenderer-&gt;getMaxCombinedTextureImageUnits() - 1)
+            {
+                gl::error(GL_INVALID_OPERATION);
+                return false;
+            }
+
+            *params = mState.samplerTexture[TEXTURE_3D][mState.activeSampler].id();
+        }
+        break;
+      case GL_TEXTURE_BINDING_2D_ARRAY:
+        {
+            if (mState.activeSampler &gt; mRenderer-&gt;getMaxCombinedTextureImageUnits() - 1)
+            {
+                gl::error(GL_INVALID_OPERATION);
+                return false;
+            }
+
+            *params = mState.samplerTexture[TEXTURE_2D_ARRAY][mState.activeSampler].id();
+        }
+        break;
</ins><span class="cx">       case GL_RESET_NOTIFICATION_STRATEGY_EXT:
</span><span class="cx">         *params = mResetStrategy;
</span><span class="cx">         break;
</span><span class="lines">@@ -1518,6 +2023,27 @@
</span><span class="cx">       case GL_PROGRAM_BINARY_FORMATS_OES:
</span><span class="cx">         *params = GL_PROGRAM_BINARY_ANGLE;
</span><span class="cx">         break;
</span><ins>+      case GL_UNIFORM_BUFFER_BINDING:
+        *params = mState.genericUniformBuffer.id();
+        break;
+      case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+        *params = mState.genericTransformFeedbackBuffer.id();
+        break;
+      case GL_COPY_READ_BUFFER_BINDING:
+        *params = mState.copyReadBuffer.id();
+        break;
+      case GL_COPY_WRITE_BUFFER_BINDING:
+        *params = mState.copyWriteBuffer.id();
+        break;
+      case GL_PIXEL_PACK_BUFFER_BINDING:
+        *params = mState.pack.pixelBuffer.id();
+        break;
+      case GL_PIXEL_UNPACK_BUFFER_BINDING:
+        *params = mState.unpack.pixelBuffer.id();
+        break;
+      case GL_NUM_EXTENSIONS:
+        *params = static_cast&lt;GLint&gt;(getNumExtensions());
+        break;
</ins><span class="cx">       default:
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -1525,6 +2051,99 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Context::getInteger64v(GLenum pname, GLint64 *params)
+{
+    switch (pname)
+    {
+      case GL_MAX_ELEMENT_INDEX:
+        *params = static_cast&lt;GLint64&gt;(std::numeric_limits&lt;unsigned int&gt;::max());
+        break;
+      case GL_MAX_UNIFORM_BLOCK_SIZE:
+        *params = static_cast&lt;GLint64&gt;(mRenderer-&gt;getMaxUniformBufferSize());
+        break;
+      case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:
+        {
+            GLint64 uniformBufferComponents = static_cast&lt;GLint64&gt;(mRenderer-&gt;getMaxVertexShaderUniformBuffers()) * static_cast&lt;GLint64&gt;(mRenderer-&gt;getMaxUniformBufferSize() / 4);
+            GLint64 defaultBufferComponents = static_cast&lt;GLint64&gt;(mRenderer-&gt;getMaxVertexUniformVectors() * 4);
+            *params = uniformBufferComponents + defaultBufferComponents;
+        }
+        break;
+      case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:
+        {
+            GLint64 uniformBufferComponents = static_cast&lt;GLint64&gt;(mRenderer-&gt;getMaxFragmentShaderUniformBuffers()) * static_cast&lt;GLint64&gt;(mRenderer-&gt;getMaxUniformBufferSize() / 4);
+            GLint64 defaultBufferComponents = static_cast&lt;GLint64&gt;(mRenderer-&gt;getMaxVertexUniformVectors() * 4);
+            *params = uniformBufferComponents + defaultBufferComponents;
+        }
+        break;
+      case GL_MAX_SERVER_WAIT_TIMEOUT:
+        // We do not wait for server fence objects internally, so report a max timeout of zero.
+        *params = 0;
+        break;
+      default:
+        return false;
+    }
+
+    return true;
+}
+
+bool Context::getIndexedIntegerv(GLenum target, GLuint index, GLint *data)
+{
+    switch (target)
+    {
+      case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+        if (index &lt; IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS)
+        {
+            *data = mState.transformFeedbackBuffers[index].id();
+        }
+        break;
+      case GL_UNIFORM_BUFFER_BINDING:
+        if (index &lt; IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS)
+        {
+            *data = mState.uniformBuffers[index].id();
+        }
+        break;
+      default:
+        return false;
+    }
+
+    return true;
+}
+
+bool Context::getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data)
+{
+    switch (target)
+    {
+      case GL_TRANSFORM_FEEDBACK_BUFFER_START:
+        if (index &lt; IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS)
+        {
+            *data = mState.transformFeedbackBuffers[index].getOffset();
+        }
+        break;
+      case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
+        if (index &lt; IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS)
+        {
+            *data = mState.transformFeedbackBuffers[index].getSize();
+        }
+        break;
+      case GL_UNIFORM_BUFFER_START:
+        if (index &lt; IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS)
+        {
+            *data = mState.uniformBuffers[index].getOffset();
+        }
+        break;
+      case GL_UNIFORM_BUFFER_SIZE:
+        if (index &lt; IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS)
+        {
+            *data = mState.uniformBuffers[index].getSize();
+        }
+        break;
+      default:
+        return false;
+    }
+
+    return true;
+}
+
</ins><span class="cx"> bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams)
</span><span class="cx"> {
</span><span class="cx">     if (pname &gt;= GL_DRAW_BUFFER0_EXT &amp;&amp; pname &lt;= GL_DRAW_BUFFER15_EXT)
</span><span class="lines">@@ -1548,13 +2167,13 @@
</span><span class="cx">             *type = GL_INT;
</span><span class="cx">             *numParams = mNumCompressedTextureFormats;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_SHADER_BINARY_FORMATS:
</span><span class="cx">         {
</span><span class="cx">             *type = GL_INT;
</span><span class="cx">             *numParams = 0;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_MAX_VERTEX_ATTRIBS:
</span><span class="cx">       case GL_MAX_VERTEX_UNIFORM_VECTORS:
</span><span class="cx">       case GL_MAX_VARYING_VECTORS:
</span><span class="lines">@@ -1624,7 +2243,7 @@
</span><span class="cx">             *type = GL_INT;
</span><span class="cx">             *numParams = 1;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_MAX_SAMPLES_ANGLE:
</span><span class="cx">         {
</span><span class="cx">             if (getMaxSupportedSamples() != 0)
</span><span class="lines">@@ -1637,20 +2256,20 @@
</span><span class="cx">                 return false;
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_MAX_VIEWPORT_DIMS:
</span><span class="cx">         {
</span><span class="cx">             *type = GL_INT;
</span><span class="cx">             *numParams = 2;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_VIEWPORT:
</span><span class="cx">       case GL_SCISSOR_BOX:
</span><span class="cx">         {
</span><span class="cx">             *type = GL_INT;
</span><span class="cx">             *numParams = 4;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_SHADER_COMPILER:
</span><span class="cx">       case GL_SAMPLE_COVERAGE_INVERT:
</span><span class="cx">       case GL_DEPTH_WRITEMASK:
</span><span class="lines">@@ -1668,13 +2287,13 @@
</span><span class="cx">             *type = GL_BOOL;
</span><span class="cx">             *numParams = 1;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_COLOR_WRITEMASK:
</span><span class="cx">         {
</span><span class="cx">             *type = GL_BOOL;
</span><span class="cx">             *numParams = 4;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_POLYGON_OFFSET_FACTOR:
</span><span class="cx">       case GL_POLYGON_OFFSET_UNITS:
</span><span class="cx">       case GL_SAMPLE_COVERAGE_VALUE:
</span><span class="lines">@@ -1684,7 +2303,7 @@
</span><span class="cx">             *type = GL_FLOAT;
</span><span class="cx">             *numParams = 1;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_ALIASED_LINE_WIDTH_RANGE:
</span><span class="cx">       case GL_ALIASED_POINT_SIZE_RANGE:
</span><span class="cx">       case GL_DEPTH_RANGE:
</span><span class="lines">@@ -1692,14 +2311,14 @@
</span><span class="cx">             *type = GL_FLOAT;
</span><span class="cx">             *numParams = 2;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_COLOR_CLEAR_VALUE:
</span><span class="cx">       case GL_BLEND_COLOR:
</span><span class="cx">         {
</span><span class="cx">             *type = GL_FLOAT;
</span><span class="cx">             *numParams = 4;
</span><span class="cx">         }
</span><del>-        break;
</del><ins>+        return true;
</ins><span class="cx">       case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
</span><span class="cx">         if (!supportsTextureFilterAnisotropy())
</span><span class="cx">         {
</span><span class="lines">@@ -1707,14 +2326,101 @@
</span><span class="cx">         }
</span><span class="cx">         *type = GL_FLOAT;
</span><span class="cx">         *numParams = 1;
</span><del>-        break;
-      default:
</del><ins>+        return true;
+    }
+
+    if (mClientVersion &lt; 3)
+    {
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return true;
</del><ins>+    // Check for ES3.0+ parameter names
+    switch (pname)
+    {
+      case GL_MAX_UNIFORM_BUFFER_BINDINGS:
+      case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
+      case GL_UNIFORM_BUFFER_BINDING:
+      case GL_TRANSFORM_FEEDBACK_BINDING:
+      case GL_COPY_READ_BUFFER_BINDING:
+      case GL_COPY_WRITE_BUFFER_BINDING:
+      case GL_PIXEL_PACK_BUFFER_BINDING:
+      case GL_PIXEL_UNPACK_BUFFER_BINDING:
+      case GL_TEXTURE_BINDING_3D:
+      case GL_TEXTURE_BINDING_2D_ARRAY:
+      case GL_MAX_3D_TEXTURE_SIZE:
+      case GL_MAX_ARRAY_TEXTURE_LAYERS:
+      case GL_MAX_VERTEX_UNIFORM_BLOCKS:
+      case GL_MAX_FRAGMENT_UNIFORM_BLOCKS:
+      case GL_MAX_COMBINED_UNIFORM_BLOCKS:
+      case GL_VERTEX_ARRAY_BINDING:
+      case GL_MAX_VERTEX_UNIFORM_COMPONENTS:
+      case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:
+      case GL_NUM_EXTENSIONS:
+      case GL_MAJOR_VERSION:
+      case GL_MINOR_VERSION:
+      case GL_MAX_ELEMENTS_INDICES:
+      case GL_MAX_ELEMENTS_VERTICES:
+      case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
+      case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
+      case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
+        {
+            *type = GL_INT;
+            *numParams = 1;
+        }
+        return true;
+
+      case GL_MAX_ELEMENT_INDEX:
+      case GL_MAX_UNIFORM_BLOCK_SIZE:
+      case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:
+      case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:
+      case GL_MAX_SERVER_WAIT_TIMEOUT:
+        {
+            *type = GL_INT_64_ANGLEX;
+            *numParams = 1;
+        }
+        return true;
+
+      case GL_TRANSFORM_FEEDBACK_ACTIVE:
+      case GL_TRANSFORM_FEEDBACK_PAUSED:
+        {
+            *type = GL_BOOL;
+            *numParams = 1;
+        }
+        return true;
+    }
+
+    return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams)
+{
+    if (mClientVersion &lt; 3)
+    {
+        return false;
+    }
+
+    switch (target)
+    {
+      case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+      case GL_UNIFORM_BUFFER_BINDING:
+        {
+            *type = GL_INT;
+            *numParams = 1;
+        }
+        return true;
+      case GL_TRANSFORM_FEEDBACK_BUFFER_START:
+      case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
+      case GL_UNIFORM_BUFFER_START:
+      case GL_UNIFORM_BUFFER_SIZE:
+        {
+            *type = GL_INT_64_ANGLEX;
+            *numParams = 1;
+        }
+    }
+
+    return false;
+}
+
</ins><span class="cx"> // Applies the render target surface, depth stencil surface, viewport rectangle and
</span><span class="cx"> // scissor rectangle to the renderer
</span><span class="cx"> bool Context::applyRenderTarget(GLenum drawMode, bool ignoreViewport)
</span><span class="lines">@@ -1785,33 +2491,91 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Applies the shaders and shader constants to the Direct3D 9 device
</span><del>-void Context::applyShaders()
</del><ins>+void Context::applyShaders(ProgramBinary *programBinary, bool transformFeedbackActive)
</ins><span class="cx"> {
</span><del>-    ProgramBinary *programBinary = getCurrentProgramBinary();
</del><ins>+    const VertexAttribute *vertexAttributes = getCurrentVertexArray()-&gt;getVertexAttributes();
</ins><span class="cx"> 
</span><del>-    mRenderer-&gt;applyShaders(programBinary);
-    
</del><ins>+    VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS];
+    VertexFormat::GetInputLayout(inputLayout, programBinary, vertexAttributes, mState.vertexAttribCurrentValues);
+
+    mRenderer-&gt;applyShaders(programBinary, mState.rasterizer.rasterizerDiscard, transformFeedbackActive, inputLayout);
+
</ins><span class="cx">     programBinary-&gt;applyUniforms();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Context::getCurrentTextureAndSamplerState(ProgramBinary *programBinary, SamplerType type, int index, Texture **outTexture,
+                                               TextureType *outTextureType, SamplerState *outSampler)
+{
+    int textureUnit = programBinary-&gt;getSamplerMapping(type, index);   // OpenGL texture image unit index
+
+    if (textureUnit != -1)
+    {
+        TextureType textureType = programBinary-&gt;getSamplerTextureType(type, index);
+        Texture *texture = getSamplerTexture(textureUnit, textureType);
+
+        SamplerState samplerState;
+        texture-&gt;getSamplerState(&amp;samplerState);
+
+        if (mState.samplers[textureUnit] != 0)
+        {
+            Sampler *samplerObject = getSampler(mState.samplers[textureUnit]);
+            samplerObject-&gt;getState(&amp;samplerState);
+        }
+
+        *outTexture = texture;
+        *outTextureType = textureType;
+        *outSampler = samplerState;
+
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+void Context::generateSwizzles(ProgramBinary *programBinary)
+{
+    generateSwizzles(programBinary, SAMPLER_PIXEL);
+
+    if (mSupportsVertexTexture)
+    {
+        generateSwizzles(programBinary, SAMPLER_VERTEX);
+    }
+}
+
+void Context::generateSwizzles(ProgramBinary *programBinary, SamplerType type)
+{
+    // Range of Direct3D samplers of given sampler type
+    int samplerRange = programBinary-&gt;getUsedSamplerRange(type);
+    for (int samplerIndex = 0; samplerIndex &lt; samplerRange; samplerIndex++)
+    {
+        Texture *texture = NULL;
+        TextureType textureType;
+        SamplerState samplerState;
+        if (getCurrentTextureAndSamplerState(programBinary, type, samplerIndex, &amp;texture, &amp;textureType, &amp;samplerState) &amp;&amp; texture-&gt;isSwizzled())
+        {
+            mRenderer-&gt;generateSwizzle(texture);
+        }
+    }
+}
+
</ins><span class="cx"> // Applies the textures and sampler states to the Direct3D 9 device
</span><del>-void Context::applyTextures()
</del><ins>+void Context::applyTextures(ProgramBinary *programBinary)
</ins><span class="cx"> {
</span><del>-    applyTextures(SAMPLER_PIXEL);
</del><ins>+    applyTextures(programBinary, SAMPLER_PIXEL);
</ins><span class="cx"> 
</span><span class="cx">     if (mSupportsVertexTexture)
</span><span class="cx">     {
</span><del>-        applyTextures(SAMPLER_VERTEX);
</del><ins>+        applyTextures(programBinary, SAMPLER_VERTEX);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// For each Direct3D 9 sampler of either the pixel or vertex stage,
</del><ins>+// For each Direct3D sampler of either the pixel or vertex stage,
</ins><span class="cx"> // looks up the corresponding OpenGL texture image unit and texture type,
</span><span class="cx"> // and sets the texture and its addressing/filtering state (or NULL when inactive).
</span><del>-void Context::applyTextures(SamplerType type)
</del><ins>+void Context::applyTextures(ProgramBinary *programBinary, SamplerType type)
</ins><span class="cx"> {
</span><del>-    ProgramBinary *programBinary = getCurrentProgramBinary();
-
</del><span class="cx">     FramebufferTextureSerialSet boundFramebufferTextures = getBoundFramebufferTextureSerials();
</span><span class="cx"> 
</span><span class="cx">     // Range of Direct3D samplers of given sampler type
</span><span class="lines">@@ -1820,22 +2584,16 @@
</span><span class="cx"> 
</span><span class="cx">     for (int samplerIndex = 0; samplerIndex &lt; samplerRange; samplerIndex++)
</span><span class="cx">     {
</span><del>-        int textureUnit = programBinary-&gt;getSamplerMapping(type, samplerIndex);   // OpenGL texture image unit index
-
-        if (textureUnit != -1)
</del><ins>+        Texture *texture = NULL;
+        TextureType textureType;
+        SamplerState samplerState;
+        if (getCurrentTextureAndSamplerState(programBinary, type, samplerIndex, &amp;texture, &amp;textureType, &amp;samplerState))
</ins><span class="cx">         {
</span><del>-            TextureType textureType = programBinary-&gt;getSamplerTextureType(type, samplerIndex);
-            Texture *texture = getSamplerTexture(textureUnit, textureType);
-
-            if (texture-&gt;isSamplerComplete() &amp;&amp;
</del><ins>+            if (texture-&gt;isSamplerComplete(samplerState) &amp;&amp;
</ins><span class="cx">                 boundFramebufferTextures.find(texture-&gt;getTextureSerial()) == boundFramebufferTextures.end())
</span><span class="cx">             {
</span><del>-                SamplerState samplerState;
-                texture-&gt;getSamplerState(&amp;samplerState);
</del><span class="cx">                 mRenderer-&gt;setSamplerState(type, samplerIndex, samplerState);
</span><del>-
</del><span class="cx">                 mRenderer-&gt;setTexture(type, samplerIndex, texture);
</span><del>-
</del><span class="cx">                 texture-&gt;resetDirty();
</span><span class="cx">             }
</span><span class="cx">             else
</span><span class="lines">@@ -1855,69 +2613,114 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
-                         GLenum format, GLenum type, GLsizei *bufSize, void* pixels)
</del><ins>+bool Context::applyUniformBuffers()
</ins><span class="cx"> {
</span><del>-    Framebuffer *framebuffer = getReadFramebuffer();
</del><ins>+    Program *programObject = getProgram(mState.currentProgram);
+    ProgramBinary *programBinary = programObject-&gt;getProgramBinary();
</ins><span class="cx"> 
</span><del>-    if (framebuffer-&gt;completeness() != GL_FRAMEBUFFER_COMPLETE)
</del><ins>+    std::vector&lt;gl::Buffer*&gt; boundBuffers;
+
+    for (unsigned int uniformBlockIndex = 0; uniformBlockIndex &lt; programBinary-&gt;getActiveUniformBlockCount(); uniformBlockIndex++)
</ins><span class="cx">     {
</span><del>-        return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
</del><ins>+        GLuint blockBinding = programObject-&gt;getUniformBlockBinding(uniformBlockIndex);
+        const OffsetBindingPointer&lt;Buffer&gt;&amp; boundBuffer = mState.uniformBuffers[blockBinding];
+        if (boundBuffer.id() == 0)
+        {
+            // undefined behaviour
+            return false;
+        }
+        else
+        {
+            gl::Buffer *uniformBuffer = boundBuffer.get();
+            ASSERT(uniformBuffer);
+            boundBuffers.push_back(uniformBuffer);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (getReadFramebufferHandle() != 0 &amp;&amp; framebuffer-&gt;getSamples() != 0)
</del><ins>+    return programBinary-&gt;applyUniformBuffers(boundBuffers);
+}
+
+bool Context::applyTransformFeedbackBuffers()
+{
+    TransformFeedback *curTransformFeedback = getCurrentTransformFeedback();
+    if (curTransformFeedback &amp;&amp; curTransformFeedback-&gt;isStarted() &amp;&amp; !curTransformFeedback-&gt;isPaused())
</ins><span class="cx">     {
</span><del>-        return gl::error(GL_INVALID_OPERATION);
</del><ins>+        Buffer *transformFeedbackBuffers[IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
+        GLintptr transformFeedbackOffsets[IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
+        for (size_t i = 0; i &lt; IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
+        {
+            transformFeedbackBuffers[i] = mState.transformFeedbackBuffers[i].get();
+            transformFeedbackOffsets[i] = mState.transformFeedbackBuffers[i].getOffset();
+        }
+        mRenderer-&gt;applyTransformFeedbackBuffers(transformFeedbackBuffers, transformFeedbackOffsets);
+        return true;
</ins><span class="cx">     }
</span><ins>+    else
+    {
+        return false;
+    }
+}
</ins><span class="cx"> 
</span><del>-    GLsizei outputPitch = ComputePitch(width, ConvertSizedInternalFormat(format, type), getPackAlignment());
-    // sized query sanity check
-    if (bufSize)
</del><ins>+void Context::markTransformFeedbackUsage()
+{
+    for (size_t i = 0; i &lt; IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
</ins><span class="cx">     {
</span><del>-        int requiredSize = outputPitch * height;
-        if (requiredSize &gt; *bufSize)
</del><ins>+        Buffer *buffer = mState.transformFeedbackBuffers[i].get();
+        if (buffer)
</ins><span class="cx">         {
</span><del>-            return gl::error(GL_INVALID_OPERATION);
</del><ins>+            buffer-&gt;markTransformFeedbackUsage();
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-
-    mRenderer-&gt;readPixels(framebuffer, x, y, width, height, format, type, outputPitch, getPackReverseRowOrder(), getPackAlignment(), pixels);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Context::clear(GLbitfield mask)
</span><span class="cx"> {
</span><del>-    Framebuffer *framebufferObject = getDrawFramebuffer();
</del><ins>+    if (isRasterizerDiscardEnabled())
+    {
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    if (!framebufferObject || framebufferObject-&gt;completeness() != GL_FRAMEBUFFER_COMPLETE)
</del><ins>+    ClearParameters clearParams = { 0 };
+    for (unsigned int i = 0; i &lt; ArraySize(clearParams.clearColor); i++)
</ins><span class="cx">     {
</span><del>-        return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
</del><ins>+        clearParams.clearColor[i] = false;
</ins><span class="cx">     }
</span><ins>+    clearParams.colorFClearValue = mState.colorClearValue;
+    clearParams.colorClearType = GL_FLOAT;
+    clearParams.colorMaskRed = mState.blend.colorMaskRed;
+    clearParams.colorMaskGreen = mState.blend.colorMaskGreen;
+    clearParams.colorMaskBlue = mState.blend.colorMaskBlue;
+    clearParams.colorMaskAlpha = mState.blend.colorMaskAlpha;
+    clearParams.clearDepth = false;
+    clearParams.depthClearValue = mState.depthClearValue;
+    clearParams.clearStencil = false;
+    clearParams.stencilClearValue = mState.stencilClearValue;
+    clearParams.stencilWriteMask = mState.depthStencil.stencilWritemask;
+    clearParams.scissorEnabled = mState.scissorTest;
+    clearParams.scissor = mState.scissor;
</ins><span class="cx"> 
</span><del>-    DWORD flags = 0;
-    GLbitfield finalMask = 0;
-
</del><ins>+    Framebuffer *framebufferObject = getDrawFramebuffer();
</ins><span class="cx">     if (mask &amp; GL_COLOR_BUFFER_BIT)
</span><span class="cx">     {
</span><del>-        mask &amp;= ~GL_COLOR_BUFFER_BIT;
-
</del><span class="cx">         if (framebufferObject-&gt;hasEnabledColorAttachment())
</span><span class="cx">         {
</span><del>-            finalMask |= GL_COLOR_BUFFER_BIT;
</del><ins>+            for (unsigned int i = 0; i &lt; ArraySize(clearParams.clearColor); i++)
+            {
+                clearParams.clearColor[i] = true;
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (mask &amp; GL_DEPTH_BUFFER_BIT)
</span><span class="cx">     {
</span><del>-        mask &amp;= ~GL_DEPTH_BUFFER_BIT;
</del><span class="cx">         if (mState.depthStencil.depthMask &amp;&amp; framebufferObject-&gt;getDepthbufferType() != GL_NONE)
</span><span class="cx">         {
</span><del>-            finalMask |= GL_DEPTH_BUFFER_BIT;
</del><ins>+            clearParams.clearDepth = true;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (mask &amp; GL_STENCIL_BUFFER_BIT)
</span><span class="cx">     {
</span><del>-        mask &amp;= ~GL_STENCIL_BUFFER_BIT;
</del><span class="cx">         if (framebufferObject-&gt;getStencilbufferType() != GL_NONE)
</span><span class="cx">         {
</span><span class="cx">             rx::RenderTarget *depthStencil = framebufferObject-&gt;getStencilbuffer()-&gt;getDepthStencil();
</span><span class="lines">@@ -1927,37 +2730,223 @@
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (GetStencilSize(depthStencil-&gt;getActualFormat()) &gt; 0)
</del><ins>+            if (gl::GetStencilBits(depthStencil-&gt;getActualFormat(), mClientVersion) &gt; 0)
</ins><span class="cx">             {
</span><del>-                finalMask |= GL_STENCIL_BUFFER_BIT;
</del><ins>+                clearParams.clearStencil = true;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mask != 0)
</del><ins>+
+    if (!applyRenderTarget(GL_TRIANGLES, true))   // Clips the clear to the scissor rectangle but not the viewport
</ins><span class="cx">     {
</span><del>-        return gl::error(GL_INVALID_VALUE);
</del><ins>+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    mRenderer-&gt;clear(clearParams, framebufferObject);
+}
+
+void Context::clearBufferfv(GLenum buffer, int drawbuffer, const float *values)
+{
+    if (isRasterizerDiscardEnabled())
+    {
+        return;
+    }
+
+    // glClearBufferfv can be called to clear the color buffer or depth buffer
+    ClearParameters clearParams = { 0 };
+
+    if (buffer == GL_COLOR)
+    {
+        for (unsigned int i = 0; i &lt; ArraySize(clearParams.clearColor); i++)
+        {
+            clearParams.clearColor[i] = (drawbuffer == static_cast&lt;int&gt;(i));
+        }
+        clearParams.colorFClearValue = ColorF(values[0], values[1], values[2], values[3]);
+        clearParams.colorClearType = GL_FLOAT;
+    }
+    else
+    {
+        for (unsigned int i = 0; i &lt; ArraySize(clearParams.clearColor); i++)
+        {
+            clearParams.clearColor[i] = false;
+        }
+        clearParams.colorFClearValue = mState.colorClearValue;
+        clearParams.colorClearType = GL_FLOAT;
+    }
+
+    clearParams.colorMaskRed = mState.blend.colorMaskRed;
+    clearParams.colorMaskGreen = mState.blend.colorMaskGreen;
+    clearParams.colorMaskBlue = mState.blend.colorMaskBlue;
+    clearParams.colorMaskAlpha = mState.blend.colorMaskAlpha;
+
+    if (buffer == GL_DEPTH)
+    {
+        clearParams.clearDepth = true;
+        clearParams.depthClearValue = values[0];
+    }
+    else
+    {
+        clearParams.clearDepth = false;
+        clearParams.depthClearValue = mState.depthClearValue;
+    }
+
+    clearParams.clearStencil = false;
+    clearParams.stencilClearValue = mState.stencilClearValue;
+    clearParams.stencilWriteMask = mState.depthStencil.stencilWritemask;
+    clearParams.scissorEnabled = mState.scissorTest;
+    clearParams.scissor = mState.scissor;
+
</ins><span class="cx">     if (!applyRenderTarget(GL_TRIANGLES, true))   // Clips the clear to the scissor rectangle but not the viewport
</span><span class="cx">     {
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ClearParameters clearParams;
-    clearParams.mask = finalMask;
-    clearParams.colorClearValue = mState.colorClearValue;
</del><ins>+    mRenderer-&gt;clear(clearParams, getDrawFramebuffer());
+}
+
+void Context::clearBufferuiv(GLenum buffer, int drawbuffer, const unsigned int *values)
+{
+    if (isRasterizerDiscardEnabled())
+    {
+        return;
+    }
+
+    // glClearBufferuv can only be called to clear a color buffer
+    ClearParameters clearParams = { 0 };
+    for (unsigned int i = 0; i &lt; ArraySize(clearParams.clearColor); i++)
+    {
+        clearParams.clearColor[i] = (drawbuffer == static_cast&lt;int&gt;(i));
+    }
+    clearParams.colorUIClearValue = ColorUI(values[0], values[1], values[2], values[3]);
+    clearParams.colorClearType = GL_UNSIGNED_INT;
</ins><span class="cx">     clearParams.colorMaskRed = mState.blend.colorMaskRed;
</span><span class="cx">     clearParams.colorMaskGreen = mState.blend.colorMaskGreen;
</span><span class="cx">     clearParams.colorMaskBlue = mState.blend.colorMaskBlue;
</span><span class="cx">     clearParams.colorMaskAlpha = mState.blend.colorMaskAlpha;
</span><ins>+    clearParams.clearDepth = false;
</ins><span class="cx">     clearParams.depthClearValue = mState.depthClearValue;
</span><ins>+    clearParams.clearStencil = false;
</ins><span class="cx">     clearParams.stencilClearValue = mState.stencilClearValue;
</span><span class="cx">     clearParams.stencilWriteMask = mState.depthStencil.stencilWritemask;
</span><ins>+    clearParams.scissorEnabled = mState.scissorTest;
+    clearParams.scissor = mState.scissor;
</ins><span class="cx"> 
</span><del>-    mRenderer-&gt;clear(clearParams, framebufferObject);
</del><ins>+    if (!applyRenderTarget(GL_TRIANGLES, true))   // Clips the clear to the scissor rectangle but not the viewport
+    {
+        return;
+    }
+
+    mRenderer-&gt;clear(clearParams, getDrawFramebuffer());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Context::clearBufferiv(GLenum buffer, int drawbuffer, const int *values)
+{
+    if (isRasterizerDiscardEnabled())
+    {
+        return;
+    }
+
+    // glClearBufferfv can be called to clear the color buffer or stencil buffer
+    ClearParameters clearParams = { 0 };
+
+    if (buffer == GL_COLOR)
+    {
+        for (unsigned int i = 0; i &lt; ArraySize(clearParams.clearColor); i++)
+        {
+            clearParams.clearColor[i] = (drawbuffer == static_cast&lt;int&gt;(i));
+        }
+        clearParams.colorIClearValue = ColorI(values[0], values[1], values[2], values[3]);
+        clearParams.colorClearType = GL_INT;
+    }
+    else
+    {
+        for (unsigned int i = 0; i &lt; ArraySize(clearParams.clearColor); i++)
+        {
+            clearParams.clearColor[i] = false;
+        }
+        clearParams.colorFClearValue = mState.colorClearValue;
+        clearParams.colorClearType = GL_FLOAT;
+    }
+
+    clearParams.colorMaskRed = mState.blend.colorMaskRed;
+    clearParams.colorMaskGreen = mState.blend.colorMaskGreen;
+    clearParams.colorMaskBlue = mState.blend.colorMaskBlue;
+    clearParams.colorMaskAlpha = mState.blend.colorMaskAlpha;
+
+    clearParams.clearDepth = false;
+    clearParams.depthClearValue = mState.depthClearValue;
+
+    if (buffer == GL_STENCIL)
+    {
+        clearParams.clearStencil = true;
+        clearParams.stencilClearValue = values[1];
+    }
+    else
+    {
+        clearParams.clearStencil = false;
+        clearParams.stencilClearValue = mState.stencilClearValue;
+    }
+    clearParams.stencilWriteMask = mState.depthStencil.stencilWritemask;
+
+    clearParams.scissorEnabled = mState.scissorTest;
+    clearParams.scissor = mState.scissor;
+
+    if (!applyRenderTarget(GL_TRIANGLES, true))   // Clips the clear to the scissor rectangle but not the viewport
+    {
+        return;
+    }
+
+    mRenderer-&gt;clear(clearParams, getDrawFramebuffer());
+}
+
+void Context::clearBufferfi(GLenum buffer, int drawbuffer, float depth, int stencil)
+{
+    if (isRasterizerDiscardEnabled())
+    {
+        return;
+    }
+
+    // glClearBufferfi can only be called to clear a depth stencil buffer
+    ClearParameters clearParams = { 0 };
+    for (unsigned int i = 0; i &lt; ArraySize(clearParams.clearColor); i++)
+    {
+        clearParams.clearColor[i] = false;
+    }
+    clearParams.colorFClearValue = mState.colorClearValue;
+    clearParams.colorClearType = GL_FLOAT;
+    clearParams.colorMaskRed = mState.blend.colorMaskRed;
+    clearParams.colorMaskGreen = mState.blend.colorMaskGreen;
+    clearParams.colorMaskBlue = mState.blend.colorMaskBlue;
+    clearParams.colorMaskAlpha = mState.blend.colorMaskAlpha;
+    clearParams.clearDepth = true;
+    clearParams.depthClearValue = depth;
+    clearParams.clearStencil = true;
+    clearParams.stencilClearValue = stencil;
+    clearParams.stencilWriteMask = mState.depthStencil.stencilWritemask;
+    clearParams.scissorEnabled = mState.scissorTest;
+    clearParams.scissor = mState.scissor;
+
+    if (!applyRenderTarget(GL_TRIANGLES, true))   // Clips the clear to the scissor rectangle but not the viewport
+    {
+        return;
+    }
+
+    mRenderer-&gt;clear(clearParams, getDrawFramebuffer());
+}
+
+void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+                         GLenum format, GLenum type, GLsizei *bufSize, void* pixels)
+{
+    gl::Framebuffer *framebuffer = getReadFramebuffer();
+
+    bool isSized = IsSizedInternalFormat(format, mClientVersion);
+    GLenum sizedInternalFormat = (isSized ? format : GetSizedInternalFormat(format, type, mClientVersion));
+    GLuint outputPitch = GetRowPitch(sizedInternalFormat, type, mClientVersion, width, mState.pack.alignment);
+
+    mRenderer-&gt;readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.pack, pixels);
+}
+
</ins><span class="cx"> void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances)
</span><span class="cx"> {
</span><span class="cx">     if (!mState.currentProgram)
</span><span class="lines">@@ -1965,6 +2954,11 @@
</span><span class="cx">         return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    ProgramBinary *programBinary = getCurrentProgramBinary();
+    programBinary-&gt;applyUniforms();
+
+    generateSwizzles(programBinary);
+
</ins><span class="cx">     if (!mRenderer-&gt;applyPrimitiveType(mode, count))
</span><span class="cx">     {
</span><span class="cx">         return;
</span><span class="lines">@@ -1977,17 +2971,22 @@
</span><span class="cx"> 
</span><span class="cx">     applyState(mode);
</span><span class="cx"> 
</span><del>-    ProgramBinary *programBinary = getCurrentProgramBinary();
-
-    GLenum err = mRenderer-&gt;applyVertexBuffer(programBinary, mState.vertexAttribute, first, count, instances);
</del><ins>+    GLenum err = mRenderer-&gt;applyVertexBuffer(programBinary, getCurrentVertexArray()-&gt;getVertexAttributes(), mState.vertexAttribCurrentValues, first, count, instances);
</ins><span class="cx">     if (err != GL_NO_ERROR)
</span><span class="cx">     {
</span><span class="cx">         return gl::error(err);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    applyShaders();
-    applyTextures();
</del><ins>+    bool transformFeedbackActive = applyTransformFeedbackBuffers();
</ins><span class="cx"> 
</span><ins>+    applyShaders(programBinary, transformFeedbackActive);
+    applyTextures(programBinary);
+
+    if (!applyUniformBuffers())
+    {
+        return;
+    }
+
</ins><span class="cx">     if (!programBinary-&gt;validateSamplers(NULL))
</span><span class="cx">     {
</span><span class="cx">         return gl::error(GL_INVALID_OPERATION);
</span><span class="lines">@@ -1995,7 +2994,12 @@
</span><span class="cx"> 
</span><span class="cx">     if (!skipDraw(mode))
</span><span class="cx">     {
</span><del>-        mRenderer-&gt;drawArrays(mode, count, instances);
</del><ins>+        mRenderer-&gt;drawArrays(mode, count, instances, transformFeedbackActive);
+
+        if (transformFeedbackActive)
+        {
+            markTransformFeedbackUsage();
+        }
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2006,11 +3010,17 @@
</span><span class="cx">         return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!indices &amp;&amp; !mState.elementArrayBuffer)
</del><ins>+    VertexArray *vao = getCurrentVertexArray();
+    if (!indices &amp;&amp; !vao-&gt;getElementArrayBuffer())
</ins><span class="cx">     {
</span><span class="cx">         return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">     }
</span><del>-    
</del><ins>+
+    ProgramBinary *programBinary = getCurrentProgramBinary();
+    programBinary-&gt;applyUniforms();
+
+    generateSwizzles(programBinary);
+
</ins><span class="cx">     if (!mRenderer-&gt;applyPrimitiveType(mode, count))
</span><span class="cx">     {
</span><span class="cx">         return;
</span><span class="lines">@@ -2024,24 +3034,32 @@
</span><span class="cx">     applyState(mode);
</span><span class="cx"> 
</span><span class="cx">     rx::TranslatedIndexData indexInfo;
</span><del>-    GLenum err = mRenderer-&gt;applyIndexBuffer(indices, mState.elementArrayBuffer.get(), count, mode, type, &amp;indexInfo);
</del><ins>+    GLenum err = mRenderer-&gt;applyIndexBuffer(indices, vao-&gt;getElementArrayBuffer(), count, mode, type, &amp;indexInfo);
</ins><span class="cx">     if (err != GL_NO_ERROR)
</span><span class="cx">     {
</span><span class="cx">         return gl::error(err);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ProgramBinary *programBinary = getCurrentProgramBinary();
-
</del><span class="cx">     GLsizei vertexCount = indexInfo.maxIndex - indexInfo.minIndex + 1;
</span><del>-    err = mRenderer-&gt;applyVertexBuffer(programBinary, mState.vertexAttribute, indexInfo.minIndex, vertexCount, instances);
</del><ins>+    err = mRenderer-&gt;applyVertexBuffer(programBinary, vao-&gt;getVertexAttributes(), mState.vertexAttribCurrentValues, indexInfo.minIndex, vertexCount, instances);
</ins><span class="cx">     if (err != GL_NO_ERROR)
</span><span class="cx">     {
</span><span class="cx">         return gl::error(err);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    applyShaders();
-    applyTextures();
</del><ins>+    bool transformFeedbackActive = applyTransformFeedbackBuffers();
+    // Transform feedback is not allowed for DrawElements, this error should have been caught at the API validation
+    // layer.
+    ASSERT(!transformFeedbackActive);
</ins><span class="cx"> 
</span><ins>+    applyShaders(programBinary, transformFeedbackActive);
+    applyTextures(programBinary);
+
+    if (!applyUniformBuffers())
+    {
+        return;
+    }
+
</ins><span class="cx">     if (!programBinary-&gt;validateSamplers(NULL))
</span><span class="cx">     {
</span><span class="cx">         return gl::error(GL_INVALID_OPERATION);
</span><span class="lines">@@ -2049,7 +3067,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!skipDraw(mode))
</span><span class="cx">     {
</span><del>-        mRenderer-&gt;drawElements(mode, count, type, indices, mState.elementArrayBuffer.get(), indexInfo, instances);
</del><ins>+        mRenderer-&gt;drawElements(mode, count, type, indices, vao-&gt;getElementArrayBuffer(), indexInfo, instances);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2155,6 +3173,11 @@
</span><span class="cx">     return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int Context::getClientVersion() const
+{
+    return mClientVersion;
+}
+
</ins><span class="cx"> int Context::getMajorShaderModel() const
</span><span class="cx"> {
</span><span class="cx">     return mMajorShaderModel;
</span><span class="lines">@@ -2170,11 +3193,43 @@
</span><span class="cx">     return mRenderer-&gt;getMaxCombinedTextureImageUnits();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+unsigned int Context::getMaximumCombinedUniformBufferBindings() const
+{
+    return mRenderer-&gt;getMaxVertexShaderUniformBuffers() +
+           mRenderer-&gt;getMaxFragmentShaderUniformBuffers();
+}
+
</ins><span class="cx"> int Context::getMaxSupportedSamples() const
</span><span class="cx"> {
</span><span class="cx">     return mRenderer-&gt;getMaxSupportedSamples();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLsizei Context::getMaxSupportedFormatSamples(GLenum internalFormat) const
+{
+    return mRenderer-&gt;getMaxSupportedFormatSamples(internalFormat);
+}
+
+GLsizei Context::getNumSampleCounts(GLenum internalFormat) const
+{
+    return mRenderer-&gt;getNumSampleCounts(internalFormat);
+}
+
+void Context::getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const
+{
+    mRenderer-&gt;getSampleCounts(internalFormat, bufSize, params);
+}
+
+unsigned int Context::getMaxTransformFeedbackBufferBindings() const
+{
+    return mRenderer-&gt;getMaxTransformFeedbackBuffers();
+}
+
+GLintptr Context::getUniformBufferOffsetAlignment() const
+{
+    // setting a large alignment forces uniform buffers to bind with zero offset
+    return static_cast&lt;GLintptr&gt;(std::numeric_limits&lt;GLint&gt;::max());
+}
+
</ins><span class="cx"> unsigned int Context::getMaximumRenderTargets() const
</span><span class="cx"> {
</span><span class="cx">     return mRenderer-&gt;getMaxRenderTargets();
</span><span class="lines">@@ -2245,9 +3300,9 @@
</span><span class="cx">     return mMaxRenderbufferDimension;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int Context::getMaximumTextureDimension() const
</del><ins>+int Context::getMaximum2DTextureDimension() const
</ins><span class="cx"> {
</span><del>-    return mMaxTextureDimension;
</del><ins>+    return mMax2DTextureDimension;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int Context::getMaximumCubeTextureDimension() const
</span><span class="lines">@@ -2255,11 +3310,36 @@
</span><span class="cx">     return mMaxCubeTextureDimension;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int Context::getMaximumTextureLevel() const
</del><ins>+int Context::getMaximum3DTextureDimension() const
</ins><span class="cx"> {
</span><del>-    return mMaxTextureLevel;
</del><ins>+    return mMax3DTextureDimension;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int Context::getMaximum2DArrayTextureLayers() const
+{
+    return mMax2DArrayTextureLayers;
+}
+
+int Context::getMaximum2DTextureLevel() const
+{
+    return mMax2DTextureLevel;
+}
+
+int Context::getMaximumCubeTextureLevel() const
+{
+    return mMaxCubeTextureLevel;
+}
+
+int Context::getMaximum3DTextureLevel() const
+{
+    return mMax3DTextureLevel;
+}
+
+int Context::getMaximum2DArrayTextureLevel() const
+{
+    return mMax2DArrayTextureLevel;
+}
+
</ins><span class="cx"> bool Context::supportsLuminanceTextures() const
</span><span class="cx"> {
</span><span class="cx">     return mSupportsLuminanceTextures;
</span><span class="lines">@@ -2270,6 +3350,11 @@
</span><span class="cx">     return mSupportsLuminanceAlphaTextures;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Context::supportsRGTextures() const
+{
+    return mSupportsRGTextures;
+}
+
</ins><span class="cx"> bool Context::supportsDepthTextures() const
</span><span class="cx"> {
</span><span class="cx">     return mSupportsDepthTextures;
</span><span class="lines">@@ -2295,12 +3380,17 @@
</span><span class="cx">     return mSupportsTextureFilterAnisotropy;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Context::supportsPBOs() const
+{
+    return mSupportsPBOs;
+}
+
</ins><span class="cx"> float Context::getTextureMaxAnisotropy() const
</span><span class="cx"> {
</span><span class="cx">     return mMaxTextureAnisotropy;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Context::getCurrentReadFormatType(GLenum *format, GLenum *type)
</del><ins>+bool Context::getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type)
</ins><span class="cx"> {
</span><span class="cx">     Framebuffer *framebuffer = getReadFramebuffer();
</span><span class="cx">     if (!framebuffer || framebuffer-&gt;completeness() != GL_FRAMEBUFFER_COMPLETE)
</span><span class="lines">@@ -2314,8 +3404,9 @@
</span><span class="cx">         return gl::error(GL_INVALID_OPERATION, false);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    *format = gl::ExtractFormat(renderbuffer-&gt;getActualFormat()); 
-    *type = gl::ExtractType(renderbuffer-&gt;getActualFormat());
</del><ins>+    *internalFormat = renderbuffer-&gt;getActualFormat();
+    *format = gl::GetFormat(renderbuffer-&gt;getActualFormat(), mClientVersion);
+    *type = gl::GetType(renderbuffer-&gt;getActualFormat(), mClientVersion);
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -2331,18 +3422,11 @@
</span><span class="cx">         mState.arrayBuffer.set(NULL);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mState.elementArrayBuffer.id() == buffer)
</del><ins>+    // mark as freed among the vertex array objects
+    for (auto vaoIt = mVertexArrayMap.begin(); vaoIt != mVertexArrayMap.end(); vaoIt++)
</ins><span class="cx">     {
</span><del>-        mState.elementArrayBuffer.set(NULL);
</del><ins>+        vaoIt-&gt;second-&gt;detachBuffer(buffer);
</ins><span class="cx">     }
</span><del>-
-    for (int attribute = 0; attribute &lt; MAX_VERTEX_ATTRIBS; attribute++)
-    {
-        if (mState.vertexAttribute[attribute].mBoundBuffer.id() == buffer)
-        {
-            mState.vertexAttribute[attribute].mBoundBuffer.set(NULL);
-        }
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Context::detachTexture(GLuint texture)
</span><span class="lines">@@ -2428,13 +3512,48 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Context::detachVertexArray(GLuint vertexArray)
+{
+    // [OpenGL ES 3.0.2] section 2.10 page 43:
+    // If a vertex array object that is currently bound is deleted, the binding
+    // for that object reverts to zero and the default vertex array becomes current.
+    if (mState.vertexArray == vertexArray)
+    {
+        bindVertexArray(0);
+    }
+}
+
+void Context::detachTransformFeedback(GLuint transformFeedback)
+{
+    if (mState.transformFeedback.id() == transformFeedback)
+    {
+        bindTransformFeedback(0);
+    }
+}
+
+void Context::detachSampler(GLuint sampler)
+{
+    // [OpenGL ES 3.0.2] section 3.8.2 pages 123-124:
+    // If a sampler object that is currently bound to one or more texture units is
+    // deleted, it is as though BindSampler is called once for each texture unit to
+    // which the sampler is bound, with unit set to the texture unit and sampler set to zero.
+    for (unsigned int textureUnit = 0; textureUnit &lt; ArraySize(mState.samplers); textureUnit++)
+    {
+        if (mState.samplers[textureUnit] == sampler)
+        {
+            mState.samplers[textureUnit] = 0;
+        }
+    }
+}
+
</ins><span class="cx"> Texture *Context::getIncompleteTexture(TextureType type)
</span><span class="cx"> {
</span><span class="cx">     Texture *t = mIncompleteTextures[type].get();
</span><span class="cx"> 
</span><span class="cx">     if (t == NULL)
</span><span class="cx">     {
</span><del>-        static const GLubyte color[] = { 0, 0, 0, 255 };
</del><ins>+        const GLubyte color[] = { 0, 0, 0, 255 };
+        const PixelUnpackState incompleteUnpackState(1);
</ins><span class="cx"> 
</span><span class="cx">         switch (type)
</span><span class="cx">         {
</span><span class="lines">@@ -2445,7 +3564,7 @@
</span><span class="cx">           case TEXTURE_2D:
</span><span class="cx">             {
</span><span class="cx">                 Texture2D *incomplete2d = new Texture2D(mRenderer, Texture::INCOMPLETE_TEXTURE_ID);
</span><del>-                incomplete2d-&gt;setImage(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
</del><ins>+                incomplete2d-&gt;setImage(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
</ins><span class="cx">                 t = incomplete2d;
</span><span class="cx">             }
</span><span class="cx">             break;
</span><span class="lines">@@ -2454,16 +3573,34 @@
</span><span class="cx">             {
</span><span class="cx">               TextureCubeMap *incompleteCube = new TextureCubeMap(mRenderer, Texture::INCOMPLETE_TEXTURE_ID);
</span><span class="cx"> 
</span><del>-              incompleteCube-&gt;setImagePosX(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
-              incompleteCube-&gt;setImageNegX(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
-              incompleteCube-&gt;setImagePosY(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
-              incompleteCube-&gt;setImageNegY(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
-              incompleteCube-&gt;setImagePosZ(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
-              incompleteCube-&gt;setImageNegZ(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
</del><ins>+              incompleteCube-&gt;setImagePosX(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
+              incompleteCube-&gt;setImageNegX(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
+              incompleteCube-&gt;setImagePosY(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
+              incompleteCube-&gt;setImageNegY(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
+              incompleteCube-&gt;setImagePosZ(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
+              incompleteCube-&gt;setImageNegZ(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
</ins><span class="cx"> 
</span><span class="cx">               t = incompleteCube;
</span><span class="cx">             }
</span><span class="cx">             break;
</span><ins>+
+          case TEXTURE_3D:
+            {
+                Texture3D *incomplete3d = new Texture3D(mRenderer, Texture::INCOMPLETE_TEXTURE_ID);
+                incomplete3d-&gt;setImage(0, 1, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
+
+                t = incomplete3d;
+            }
+            break;
+
+          case TEXTURE_2D_ARRAY:
+            {
+                Texture2DArray *incomplete2darray = new Texture2DArray(mRenderer, Texture::INCOMPLETE_TEXTURE_ID);
+                incomplete2darray-&gt;setImage(0, 1, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
+
+                t = incomplete2darray;
+            }
+            break;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         mIncompleteTextures[type].set(t);
</span><span class="lines">@@ -2499,150 +3636,285 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Context::setVertexAttrib(GLuint index, const GLfloat *values)
</del><ins>+void Context::setVertexAttribf(GLuint index, const GLfloat values[4])
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(index &lt; gl::MAX_VERTEX_ATTRIBS);
</span><ins>+    mState.vertexAttribCurrentValues[index].setFloatValues(values);
+}
</ins><span class="cx"> 
</span><del>-    mState.vertexAttribute[index].mCurrentValue[0] = values[0];
-    mState.vertexAttribute[index].mCurrentValue[1] = values[1];
-    mState.vertexAttribute[index].mCurrentValue[2] = values[2];
-    mState.vertexAttribute[index].mCurrentValue[3] = values[3];
</del><ins>+void Context::setVertexAttribu(GLuint index, const GLuint values[4])
+{
+    ASSERT(index &lt; gl::MAX_VERTEX_ATTRIBS);
+    mState.vertexAttribCurrentValues[index].setUnsignedIntValues(values);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Context::setVertexAttribDivisor(GLuint index, GLuint divisor)
</del><ins>+void Context::setVertexAttribi(GLuint index, const GLint values[4])
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(index &lt; gl::MAX_VERTEX_ATTRIBS);
</span><ins>+    mState.vertexAttribCurrentValues[index].setIntValues(values);
+}
</ins><span class="cx"> 
</span><del>-    mState.vertexAttribute[index].mDivisor = divisor;
</del><ins>+void Context::setVertexAttribDivisor(GLuint index, GLuint divisor)
+{
+    getCurrentVertexArray()-&gt;setVertexAttribDivisor(index, divisor);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-// keep list sorted in following order
-// OES extensions
-// EXT extensions
-// Vendor extensions
-void Context::initExtensionString()
</del><ins>+void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param)
</ins><span class="cx"> {
</span><del>-    std::string extensionString = &quot;&quot;;
</del><ins>+    mResourceManager-&gt;checkSamplerAllocation(sampler);
</ins><span class="cx"> 
</span><del>-    // OES extensions
-    if (supports32bitIndices())
-    {
-        extensionString += &quot;GL_OES_element_index_uint &quot;;
-    }
</del><ins>+    Sampler *samplerObject = getSampler(sampler);
+    ASSERT(samplerObject);
</ins><span class="cx"> 
</span><del>-    extensionString += &quot;GL_OES_packed_depth_stencil &quot;;
-    extensionString += &quot;GL_OES_get_program_binary &quot;;
-    extensionString += &quot;GL_OES_rgb8_rgba8 &quot;;
-    if (mRenderer-&gt;getDerivativeInstructionSupport())
</del><ins>+    switch (pname)
</ins><span class="cx">     {
</span><del>-        extensionString += &quot;GL_OES_standard_derivatives &quot;;
</del><ins>+      case GL_TEXTURE_MIN_FILTER:    samplerObject-&gt;setMinFilter(static_cast&lt;GLenum&gt;(param));       break;
+      case GL_TEXTURE_MAG_FILTER:    samplerObject-&gt;setMagFilter(static_cast&lt;GLenum&gt;(param));       break;
+      case GL_TEXTURE_WRAP_S:        samplerObject-&gt;setWrapS(static_cast&lt;GLenum&gt;(param));           break;
+      case GL_TEXTURE_WRAP_T:        samplerObject-&gt;setWrapT(static_cast&lt;GLenum&gt;(param));           break;
+      case GL_TEXTURE_WRAP_R:        samplerObject-&gt;setWrapR(static_cast&lt;GLenum&gt;(param));           break;
+      case GL_TEXTURE_MIN_LOD:       samplerObject-&gt;setMinLod(static_cast&lt;GLfloat&gt;(param));         break;
+      case GL_TEXTURE_MAX_LOD:       samplerObject-&gt;setMaxLod(static_cast&lt;GLfloat&gt;(param));         break;
+      case GL_TEXTURE_COMPARE_MODE:  samplerObject-&gt;setComparisonMode(static_cast&lt;GLenum&gt;(param));  break;
+      case GL_TEXTURE_COMPARE_FUNC:  samplerObject-&gt;setComparisonFunc(static_cast&lt;GLenum&gt;(param));  break;
+      default:                       UNREACHABLE(); break;
</ins><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    if (supportsFloat16Textures())
-    {
-        extensionString += &quot;GL_OES_texture_half_float &quot;;
-    }
-    if (supportsFloat16LinearFilter())
-    {
-        extensionString += &quot;GL_OES_texture_half_float_linear &quot;;
-    }
-    if (supportsFloat32Textures())
-    {
-        extensionString += &quot;GL_OES_texture_float &quot;;
-    }
-    if (supportsFloat32LinearFilter())
-    {
-        extensionString += &quot;GL_OES_texture_float_linear &quot;;
-    }
</del><ins>+void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
+{
+    mResourceManager-&gt;checkSamplerAllocation(sampler);
</ins><span class="cx"> 
</span><del>-    if (supportsNonPower2Texture())
-    {
-        extensionString += &quot;GL_OES_texture_npot &quot;;
-    }
</del><ins>+    Sampler *samplerObject = getSampler(sampler);
+    ASSERT(samplerObject);
</ins><span class="cx"> 
</span><del>-    // Multi-vendor (EXT) extensions
-    if (supportsOcclusionQueries())
</del><ins>+    switch (pname)
</ins><span class="cx">     {
</span><del>-        extensionString += &quot;GL_EXT_occlusion_query_boolean &quot;;
</del><ins>+      case GL_TEXTURE_MIN_FILTER:    samplerObject-&gt;setMinFilter(uiround&lt;GLenum&gt;(param));       break;
+      case GL_TEXTURE_MAG_FILTER:    samplerObject-&gt;setMagFilter(uiround&lt;GLenum&gt;(param));       break;
+      case GL_TEXTURE_WRAP_S:        samplerObject-&gt;setWrapS(uiround&lt;GLenum&gt;(param));           break;
+      case GL_TEXTURE_WRAP_T:        samplerObject-&gt;setWrapT(uiround&lt;GLenum&gt;(param));           break;
+      case GL_TEXTURE_WRAP_R:        samplerObject-&gt;setWrapR(uiround&lt;GLenum&gt;(param));           break;
+      case GL_TEXTURE_MIN_LOD:       samplerObject-&gt;setMinLod(param);                                      break;
+      case GL_TEXTURE_MAX_LOD:       samplerObject-&gt;setMaxLod(param);                                      break;
+      case GL_TEXTURE_COMPARE_MODE:  samplerObject-&gt;setComparisonMode(uiround&lt;GLenum&gt;(param));  break;
+      case GL_TEXTURE_COMPARE_FUNC:  samplerObject-&gt;setComparisonFunc(uiround&lt;GLenum&gt;(param));  break;
+      default:                       UNREACHABLE(); break;
</ins><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    extensionString += &quot;GL_EXT_read_format_bgra &quot;;
-    extensionString += &quot;GL_EXT_robustness &quot;;
</del><ins>+GLint Context::getSamplerParameteri(GLuint sampler, GLenum pname)
+{
+    mResourceManager-&gt;checkSamplerAllocation(sampler);
</ins><span class="cx"> 
</span><del>-    if (supportsDXT1Textures())
-    {
-        extensionString += &quot;GL_EXT_texture_compression_dxt1 &quot;;
-    }
</del><ins>+    Sampler *samplerObject = getSampler(sampler);
+    ASSERT(samplerObject);
</ins><span class="cx"> 
</span><del>-    if (supportsTextureFilterAnisotropy())
</del><ins>+    switch (pname)
</ins><span class="cx">     {
</span><del>-        extensionString += &quot;GL_EXT_texture_filter_anisotropic &quot;;
</del><ins>+      case GL_TEXTURE_MIN_FILTER:    return static_cast&lt;GLint&gt;(samplerObject-&gt;getMinFilter());
+      case GL_TEXTURE_MAG_FILTER:    return static_cast&lt;GLint&gt;(samplerObject-&gt;getMagFilter());
+      case GL_TEXTURE_WRAP_S:        return static_cast&lt;GLint&gt;(samplerObject-&gt;getWrapS());
+      case GL_TEXTURE_WRAP_T:        return static_cast&lt;GLint&gt;(samplerObject-&gt;getWrapT());
+      case GL_TEXTURE_WRAP_R:        return static_cast&lt;GLint&gt;(samplerObject-&gt;getWrapR());
+      case GL_TEXTURE_MIN_LOD:       return uiround&lt;GLint&gt;(samplerObject-&gt;getMinLod());
+      case GL_TEXTURE_MAX_LOD:       return uiround&lt;GLint&gt;(samplerObject-&gt;getMaxLod());
+      case GL_TEXTURE_COMPARE_MODE:  return static_cast&lt;GLint&gt;(samplerObject-&gt;getComparisonMode());
+      case GL_TEXTURE_COMPARE_FUNC:  return static_cast&lt;GLint&gt;(samplerObject-&gt;getComparisonFunc());
+      default:                       UNREACHABLE(); return 0;
</ins><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    if (supportsBGRATextures())
</del><ins>+GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname)
+{
+    mResourceManager-&gt;checkSamplerAllocation(sampler);
+
+    Sampler *samplerObject = getSampler(sampler);
+    ASSERT(samplerObject);
+
+    switch (pname)
</ins><span class="cx">     {
</span><del>-        extensionString += &quot;GL_EXT_texture_format_BGRA8888 &quot;;
</del><ins>+      case GL_TEXTURE_MIN_FILTER:    return static_cast&lt;GLfloat&gt;(samplerObject-&gt;getMinFilter());
+      case GL_TEXTURE_MAG_FILTER:    return static_cast&lt;GLfloat&gt;(samplerObject-&gt;getMagFilter());
+      case GL_TEXTURE_WRAP_S:        return static_cast&lt;GLfloat&gt;(samplerObject-&gt;getWrapS());
+      case GL_TEXTURE_WRAP_T:        return static_cast&lt;GLfloat&gt;(samplerObject-&gt;getWrapT());
+      case GL_TEXTURE_WRAP_R:        return static_cast&lt;GLfloat&gt;(samplerObject-&gt;getWrapR());
+      case GL_TEXTURE_MIN_LOD:       return samplerObject-&gt;getMinLod();
+      case GL_TEXTURE_MAX_LOD:       return samplerObject-&gt;getMaxLod();
+      case GL_TEXTURE_COMPARE_MODE:  return static_cast&lt;GLfloat&gt;(samplerObject-&gt;getComparisonMode());
+      case GL_TEXTURE_COMPARE_FUNC:  return static_cast&lt;GLfloat&gt;(samplerObject-&gt;getComparisonFunc());
+      default:                       UNREACHABLE(); return 0;
</ins><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    if (mRenderer-&gt;getMaxRenderTargets() &gt; 1)
</del><ins>+// keep list sorted in following order
+// OES extensions
+// EXT extensions
+// Vendor extensions
+void Context::initExtensionString()
+{
+    // Do not report extension in GLES 3 contexts for now
+    if (mClientVersion == 2)
</ins><span class="cx">     {
</span><del>-        extensionString += &quot;GL_EXT_draw_buffers &quot;;
-    }
</del><ins>+        // OES extensions
+        if (supports32bitIndices())
+        {
+            mExtensionStringList.push_back(&quot;GL_OES_element_index_uint&quot;);
+        }
</ins><span class="cx"> 
</span><del>-    extensionString += &quot;GL_EXT_texture_storage &quot;;
-    extensionString += &quot;GL_EXT_frag_depth &quot;;
</del><ins>+        mExtensionStringList.push_back(&quot;GL_OES_packed_depth_stencil&quot;);
+        mExtensionStringList.push_back(&quot;GL_OES_get_program_binary&quot;);
+        mExtensionStringList.push_back(&quot;GL_OES_rgb8_rgba8&quot;);
</ins><span class="cx"> 
</span><del>-    // ANGLE-specific extensions
-    if (supportsDepthTextures())
-    {
-        extensionString += &quot;GL_ANGLE_depth_texture &quot;;
-    }
</del><ins>+        if (supportsPBOs())
+        {
+            mExtensionStringList.push_back(&quot;GL_OES_mapbuffer&quot;);
+            mExtensionStringList.push_back(&quot;GL_EXT_map_buffer_range&quot;);
+        }
</ins><span class="cx"> 
</span><del>-    extensionString += &quot;GL_ANGLE_framebuffer_blit &quot;;
-    if (getMaxSupportedSamples() != 0)
-    {
-        extensionString += &quot;GL_ANGLE_framebuffer_multisample &quot;;
-    }
</del><ins>+        if (mRenderer-&gt;getDerivativeInstructionSupport())
+        {
+            mExtensionStringList.push_back(&quot;GL_OES_standard_derivatives&quot;);
+        }
</ins><span class="cx"> 
</span><del>-    if (supportsInstancing())
-    {
-        extensionString += &quot;GL_ANGLE_instanced_arrays &quot;;
-    }
</del><ins>+        if (supportsFloat16Textures())
+        {
+            mExtensionStringList.push_back(&quot;GL_OES_texture_half_float&quot;);
+        }
+        if (supportsFloat16LinearFilter())
+        {
+            mExtensionStringList.push_back(&quot;GL_OES_texture_half_float_linear&quot;);
+        }
+        if (supportsFloat32Textures())
+        {
+            mExtensionStringList.push_back(&quot;GL_OES_texture_float&quot;);
+        }
+        if (supportsFloat32LinearFilter())
+        {
+            mExtensionStringList.push_back(&quot;GL_OES_texture_float_linear&quot;);
+        }
</ins><span class="cx"> 
</span><del>-    extensionString += &quot;GL_ANGLE_pack_reverse_row_order &quot;;
</del><ins>+        if (supportsRGTextures())
+        {
+            mExtensionStringList.push_back(&quot;GL_EXT_texture_rg&quot;);
+        }
</ins><span class="cx"> 
</span><del>-    if (supportsDXT3Textures())
-    {
-        extensionString += &quot;GL_ANGLE_texture_compression_dxt3 &quot;;
</del><ins>+        if (supportsNonPower2Texture())
+        {
+            mExtensionStringList.push_back(&quot;GL_OES_texture_npot&quot;);
+        }
+
+        // Multi-vendor (EXT) extensions
+        if (supportsOcclusionQueries())
+        {
+            mExtensionStringList.push_back(&quot;GL_EXT_occlusion_query_boolean&quot;);
+        }
+
+        mExtensionStringList.push_back(&quot;GL_EXT_read_format_bgra&quot;);
+        mExtensionStringList.push_back(&quot;GL_EXT_robustness&quot;);
+        mExtensionStringList.push_back(&quot;GL_EXT_shader_texture_lod&quot;);
+
+        if (supportsDXT1Textures())
+        {
+            mExtensionStringList.push_back(&quot;GL_EXT_texture_compression_dxt1&quot;);
+        }
+
+        if (supportsTextureFilterAnisotropy())
+        {
+            mExtensionStringList.push_back(&quot;GL_EXT_texture_filter_anisotropic&quot;);
+        }
+
+        if (supportsBGRATextures())
+        {
+            mExtensionStringList.push_back(&quot;GL_EXT_texture_format_BGRA8888&quot;);
+        }
+
+        if (mRenderer-&gt;getMaxRenderTargets() &gt; 1)
+        {
+            mExtensionStringList.push_back(&quot;GL_EXT_draw_buffers&quot;);
+        }
+
+        mExtensionStringList.push_back(&quot;GL_EXT_texture_storage&quot;);
+        mExtensionStringList.push_back(&quot;GL_EXT_frag_depth&quot;);
+        mExtensionStringList.push_back(&quot;GL_EXT_blend_minmax&quot;);
+
+        // ANGLE-specific extensions
+        if (supportsDepthTextures())
+        {
+            mExtensionStringList.push_back(&quot;GL_ANGLE_depth_texture&quot;);
+        }
+
+        mExtensionStringList.push_back(&quot;GL_ANGLE_framebuffer_blit&quot;);
+        if (getMaxSupportedSamples() != 0)
+        {
+            mExtensionStringList.push_back(&quot;GL_ANGLE_framebuffer_multisample&quot;);
+        }
+
+        if (supportsInstancing())
+        {
+            mExtensionStringList.push_back(&quot;GL_ANGLE_instanced_arrays&quot;);
+        }
+
+        mExtensionStringList.push_back(&quot;GL_ANGLE_pack_reverse_row_order&quot;);
+
+        if (supportsDXT3Textures())
+        {
+            mExtensionStringList.push_back(&quot;GL_ANGLE_texture_compression_dxt3&quot;);
+        }
+        if (supportsDXT5Textures())
+        {
+            mExtensionStringList.push_back(&quot;GL_ANGLE_texture_compression_dxt5&quot;);
+        }
+
+        mExtensionStringList.push_back(&quot;GL_ANGLE_texture_usage&quot;);
+        mExtensionStringList.push_back(&quot;GL_ANGLE_translated_shader_source&quot;);
+
+        // Other vendor-specific extensions
+        if (supportsEventQueries())
+        {
+            mExtensionStringList.push_back(&quot;GL_NV_fence&quot;);
+        }
</ins><span class="cx">     }
</span><del>-    if (supportsDXT5Textures())
</del><ins>+
+    if (mClientVersion == 3)
</ins><span class="cx">     {
</span><del>-        extensionString += &quot;GL_ANGLE_texture_compression_dxt5 &quot;;
-    }
</del><ins>+        mExtensionStringList.push_back(&quot;GL_EXT_color_buffer_float&quot;);
</ins><span class="cx"> 
</span><del>-    extensionString += &quot;GL_ANGLE_texture_usage &quot;;
-    extensionString += &quot;GL_ANGLE_translated_shader_source &quot;;
</del><ins>+        mExtensionStringList.push_back(&quot;GL_EXT_read_format_bgra&quot;);
</ins><span class="cx"> 
</span><del>-    // Other vendor-specific extensions
-    if (supportsEventQueries())
-    {
-        extensionString += &quot;GL_NV_fence &quot;;
</del><ins>+        if (supportsBGRATextures())
+        {
+            mExtensionStringList.push_back(&quot;GL_EXT_texture_format_BGRA8888&quot;);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    std::string::size_type end = extensionString.find_last_not_of(' ');
-    if (end != std::string::npos)
</del><ins>+    // Join the extension strings to one long string for use with GetString
+    std::stringstream strstr;
+    for (unsigned int extensionIndex = 0; extensionIndex &lt; mExtensionStringList.size(); extensionIndex++)
</ins><span class="cx">     {
</span><del>-        extensionString.resize(end+1);
</del><ins>+        strstr &lt;&lt; mExtensionStringList[extensionIndex];
+        strstr &lt;&lt; &quot; &quot;;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mExtensionString = makeStaticString(extensionString);
</del><ins>+    mCombinedExtensionsString = makeStaticString(strstr.str());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-const char *Context::getExtensionString() const
</del><ins>+const char *Context::getCombinedExtensionsString() const
</ins><span class="cx"> {
</span><del>-    return mExtensionString;
</del><ins>+    return mCombinedExtensionsString;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const char *Context::getExtensionString(const GLuint index) const
+{
+    ASSERT(index &lt; mExtensionStringList.size());
+    return mExtensionStringList[index].c_str();
+}
+
+unsigned int Context::getNumExtensions() const
+{
+    return mExtensionStringList.size();
+}
+
</ins><span class="cx"> void Context::initRendererString()
</span><span class="cx"> {
</span><span class="cx">     std::ostringstream rendererString;
</span><span class="lines">@@ -2681,298 +3953,145 @@
</span><span class="cx">     return set;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 
-                              GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
-                              GLbitfield mask)
</del><ins>+void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+                              GLbitfield mask, GLenum filter)
</ins><span class="cx"> {
</span><span class="cx">     Framebuffer *readFramebuffer = getReadFramebuffer();
</span><span class="cx">     Framebuffer *drawFramebuffer = getDrawFramebuffer();
</span><span class="cx"> 
</span><del>-    if (!readFramebuffer || readFramebuffer-&gt;completeness() != GL_FRAMEBUFFER_COMPLETE ||
-        !drawFramebuffer || drawFramebuffer-&gt;completeness() != GL_FRAMEBUFFER_COMPLETE)
</del><ins>+    bool blitRenderTarget = false;
+    bool blitDepth = false;
+    bool blitStencil = false;
+    if ((mask &amp; GL_COLOR_BUFFER_BIT) &amp;&amp; readFramebuffer-&gt;getReadColorbuffer() &amp;&amp; drawFramebuffer-&gt;getFirstColorbuffer())
</ins><span class="cx">     {
</span><del>-        return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
</del><ins>+        blitRenderTarget = true;
</ins><span class="cx">     }
</span><del>-
-    if (drawFramebuffer-&gt;getSamples() != 0)
</del><ins>+    if ((mask &amp; GL_STENCIL_BUFFER_BIT) &amp;&amp; readFramebuffer-&gt;getStencilbuffer() &amp;&amp; drawFramebuffer-&gt;getStencilbuffer())
</ins><span class="cx">     {
</span><del>-        return gl::error(GL_INVALID_OPERATION);
</del><ins>+        blitStencil = true;
</ins><span class="cx">     }
</span><del>-
-    Renderbuffer *readColorBuffer = readFramebuffer-&gt;getReadColorbuffer();
-    Renderbuffer *drawColorBuffer = drawFramebuffer-&gt;getFirstColorbuffer();
-
-    if (drawColorBuffer == NULL)
</del><ins>+    if ((mask &amp; GL_DEPTH_BUFFER_BIT) &amp;&amp; readFramebuffer-&gt;getDepthbuffer() &amp;&amp; drawFramebuffer-&gt;getDepthbuffer())
</ins><span class="cx">     {
</span><del>-        ERR(&quot;Draw buffers formats don't match, which is not supported in this implementation of BlitFramebufferANGLE&quot;);
-        return gl::error(GL_INVALID_OPERATION);
</del><ins>+        blitDepth = true;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    int readBufferWidth = readColorBuffer-&gt;getWidth();
-    int readBufferHeight = readColorBuffer-&gt;getHeight();
-    int drawBufferWidth = drawColorBuffer-&gt;getWidth();
-    int drawBufferHeight = drawColorBuffer-&gt;getHeight();
-
-    Rectangle sourceRect;
-    Rectangle destRect;
-
-    if (srcX0 &lt; srcX1)
</del><ins>+    gl::Rectangle srcRect(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0);
+    gl::Rectangle dstRect(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0);
+    if (blitRenderTarget || blitDepth || blitStencil)
</ins><span class="cx">     {
</span><del>-        sourceRect.x = srcX0;
-        destRect.x = dstX0;
-        sourceRect.width = srcX1 - srcX0;
-        destRect.width = dstX1 - dstX0;
</del><ins>+        const gl::Rectangle *scissor = mState.scissorTest ? &amp;mState.scissor : NULL;
+        mRenderer-&gt;blitRect(readFramebuffer, srcRect, drawFramebuffer, dstRect, scissor,
+                            blitRenderTarget, blitDepth, blitStencil, filter);
</ins><span class="cx">     }
</span><del>-    else
-    {
-        sourceRect.x = srcX1;
-        destRect.x = dstX1;
-        sourceRect.width = srcX0 - srcX1;
-        destRect.width = dstX0 - dstX1;
-    }
</del><ins>+}
</ins><span class="cx"> 
</span><del>-    if (srcY0 &lt; srcY1)
</del><ins>+void Context::invalidateFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments,
+                                    GLint x, GLint y, GLsizei width, GLsizei height)
+{
+    Framebuffer *frameBuffer = NULL;
+    switch (target)
</ins><span class="cx">     {
</span><del>-        sourceRect.height = srcY1 - srcY0;
-        destRect.height = dstY1 - dstY0;
-        sourceRect.y = srcY0;
-        destRect.y = dstY0;
</del><ins>+      case GL_FRAMEBUFFER:
+      case GL_DRAW_FRAMEBUFFER:
+        frameBuffer = getDrawFramebuffer();
+        break;
+      case GL_READ_FRAMEBUFFER:
+        frameBuffer = getReadFramebuffer();
+        break;
+      default:
+        UNREACHABLE();
</ins><span class="cx">     }
</span><del>-    else
-    {
-        sourceRect.height = srcY0 - srcY1;
-        destRect.height = dstY0 - srcY1;
-        sourceRect.y = srcY1;
-        destRect.y = dstY1;
-    }
</del><span class="cx"> 
</span><del>-    Rectangle sourceScissoredRect = sourceRect;
-    Rectangle destScissoredRect = destRect;
-
-    if (mState.scissorTest)
</del><ins>+    if (frameBuffer &amp;&amp; frameBuffer-&gt;completeness() == GL_FRAMEBUFFER_COMPLETE)
</ins><span class="cx">     {
</span><del>-        // Only write to parts of the destination framebuffer which pass the scissor test.
-        if (destRect.x &lt; mState.scissor.x)
</del><ins>+        for (int i = 0; i &lt; numAttachments; ++i)
</ins><span class="cx">         {
</span><del>-            int xDiff = mState.scissor.x - destRect.x;
-            destScissoredRect.x = mState.scissor.x;
-            destScissoredRect.width -= xDiff;
-            sourceScissoredRect.x += xDiff;
-            sourceScissoredRect.width -= xDiff;
</del><ins>+            rx::RenderTarget *renderTarget = NULL;
</ins><span class="cx"> 
</span><del>-        }
-
-        if (destRect.x + destRect.width &gt; mState.scissor.x + mState.scissor.width)
-        {
-            int xDiff = (destRect.x + destRect.width) - (mState.scissor.x + mState.scissor.width);
-            destScissoredRect.width -= xDiff;
-            sourceScissoredRect.width -= xDiff;
-        }
-
-        if (destRect.y &lt; mState.scissor.y)
-        {
-            int yDiff = mState.scissor.y - destRect.y;
-            destScissoredRect.y = mState.scissor.y;
-            destScissoredRect.height -= yDiff;
-            sourceScissoredRect.y += yDiff;
-            sourceScissoredRect.height -= yDiff;
-        }
-
-        if (destRect.y + destRect.height &gt; mState.scissor.y + mState.scissor.height)
-        {
-            int yDiff = (destRect.y + destRect.height) - (mState.scissor.y + mState.scissor.height);
-            destScissoredRect.height  -= yDiff;
-            sourceScissoredRect.height -= yDiff;
-        }
-    }
-
-    bool blitRenderTarget = false;
-    bool blitDepthStencil = false;
-
-    Rectangle sourceTrimmedRect = sourceScissoredRect;
-    Rectangle destTrimmedRect = destScissoredRect;
-
-    // The source &amp; destination rectangles also may need to be trimmed if they fall out of the bounds of 
-    // the actual draw and read surfaces.
-    if (sourceTrimmedRect.x &lt; 0)
-    {
-        int xDiff = 0 - sourceTrimmedRect.x;
-        sourceTrimmedRect.x = 0;
-        sourceTrimmedRect.width -= xDiff;
-        destTrimmedRect.x += xDiff;
-        destTrimmedRect.width -= xDiff;
-    }
-
-    if (sourceTrimmedRect.x + sourceTrimmedRect.width &gt; readBufferWidth)
-    {
-        int xDiff = (sourceTrimmedRect.x + sourceTrimmedRect.width) - readBufferWidth;
-        sourceTrimmedRect.width -= xDiff;
-        destTrimmedRect.width -= xDiff;
-    }
-
-    if (sourceTrimmedRect.y &lt; 0)
-    {
-        int yDiff = 0 - sourceTrimmedRect.y;
-        sourceTrimmedRect.y = 0;
-        sourceTrimmedRect.height -= yDiff;
-        destTrimmedRect.y += yDiff;
-        destTrimmedRect.height -= yDiff;
-    }
-
-    if (sourceTrimmedRect.y + sourceTrimmedRect.height &gt; readBufferHeight)
-    {
-        int yDiff = (sourceTrimmedRect.y + sourceTrimmedRect.height) - readBufferHeight;
-        sourceTrimmedRect.height -= yDiff;
-        destTrimmedRect.height -= yDiff;
-    }
-
-    if (destTrimmedRect.x &lt; 0)
-    {
-        int xDiff = 0 - destTrimmedRect.x;
-        destTrimmedRect.x = 0;
-        destTrimmedRect.width -= xDiff;
-        sourceTrimmedRect.x += xDiff;
-        sourceTrimmedRect.width -= xDiff;
-    }
-
-    if (destTrimmedRect.x + destTrimmedRect.width &gt; drawBufferWidth)
-    {
-        int xDiff = (destTrimmedRect.x + destTrimmedRect.width) - drawBufferWidth;
-        destTrimmedRect.width -= xDiff;
-        sourceTrimmedRect.width -= xDiff;
-    }
-
-    if (destTrimmedRect.y &lt; 0)
-    {
-        int yDiff = 0 - destTrimmedRect.y;
-        destTrimmedRect.y = 0;
-        destTrimmedRect.height -= yDiff;
-        sourceTrimmedRect.y += yDiff;
-        sourceTrimmedRect.height -= yDiff;
-    }
-
-    if (destTrimmedRect.y + destTrimmedRect.height &gt; drawBufferHeight)
-    {
-        int yDiff = (destTrimmedRect.y + destTrimmedRect.height) - drawBufferHeight;
-        destTrimmedRect.height -= yDiff;
-        sourceTrimmedRect.height -= yDiff;
-    }
-
-    bool partialBufferCopy = false;
-    if (sourceTrimmedRect.height &lt; readBufferHeight ||
-        sourceTrimmedRect.width &lt; readBufferWidth || 
-        destTrimmedRect.height &lt; drawBufferHeight ||
-        destTrimmedRect.width &lt; drawBufferWidth ||
-        sourceTrimmedRect.y != 0 || destTrimmedRect.y != 0 || sourceTrimmedRect.x != 0 || destTrimmedRect.x != 0)
-    {
-        partialBufferCopy = true;
-    }
-
-    if (mask &amp; GL_COLOR_BUFFER_BIT)
-    {
-        const GLenum readColorbufferType = readFramebuffer-&gt;getReadColorbufferType();
-        const bool validReadType = (readColorbufferType == GL_TEXTURE_2D) || (readColorbufferType == GL_RENDERBUFFER);
-        bool validDrawType = true;
-        bool validDrawFormat = true;
-
-        for (unsigned int colorAttachment = 0; colorAttachment &lt; gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
-        {
-            if (drawFramebuffer-&gt;isEnabledColorAttachment(colorAttachment))
</del><ins>+            if (attachments[i] &gt;= GL_COLOR_ATTACHMENT0 &amp;&amp; attachments[i] &lt;= GL_COLOR_ATTACHMENT15)
</ins><span class="cx">             {
</span><del>-                if (drawFramebuffer-&gt;getColorbufferType(colorAttachment) != GL_TEXTURE_2D &amp;&amp;
-                    drawFramebuffer-&gt;getColorbufferType(colorAttachment) != GL_RENDERBUFFER)
</del><ins>+                gl::Renderbuffer *renderBuffer = frameBuffer-&gt;getColorbuffer(attachments[i] - GL_COLOR_ATTACHMENT0);
+                if (renderBuffer)
</ins><span class="cx">                 {
</span><del>-                    validDrawType = false;
</del><ins>+                    renderTarget = renderBuffer-&gt;getRenderTarget();
</ins><span class="cx">                 }
</span><ins>+            }
+            else if (attachments[i] == GL_COLOR)
+            {
+                 gl::Renderbuffer *renderBuffer = frameBuffer-&gt;getColorbuffer(0);
+                 if (renderBuffer)
+                 {
+                     renderTarget = renderBuffer-&gt;getRenderTarget();
+                 }
+            }
+            else
+            {
+                gl::Renderbuffer *renderBuffer = NULL;
+                switch (attachments[i])
+                {
+                  case GL_DEPTH_ATTACHMENT:
+                  case GL_DEPTH:
+                    renderBuffer = frameBuffer-&gt;getDepthbuffer();
+                    break;
+                  case GL_STENCIL_ATTACHMENT:
+                  case GL_STENCIL:
+                    renderBuffer = frameBuffer-&gt;getStencilbuffer();
+                    break;
+                  case GL_DEPTH_STENCIL_ATTACHMENT:
+                    renderBuffer = frameBuffer-&gt;getDepthOrStencilbuffer();
+                    break;
+                  default:
+                    UNREACHABLE();
+                }
</ins><span class="cx"> 
</span><del>-                if (drawFramebuffer-&gt;getColorbuffer(colorAttachment)-&gt;getActualFormat() != readColorBuffer-&gt;getActualFormat())
</del><ins>+                if (renderBuffer)
</ins><span class="cx">                 {
</span><del>-                    validDrawFormat = false;
</del><ins>+                    renderTarget = renderBuffer-&gt;getDepthStencil();
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><del>-        }
</del><span class="cx"> 
</span><del>-        if (!validReadType || !validDrawType || !validDrawFormat)
-        {
-            ERR(&quot;Color buffer format conversion in BlitFramebufferANGLE not supported by this implementation&quot;);
-            return gl::error(GL_INVALID_OPERATION);
</del><ins>+            if (renderTarget)
+            {
+                renderTarget-&gt;invalidate(x, y, width, height);
+            }
</ins><span class="cx">         }
</span><del>-        
-        if (partialBufferCopy &amp;&amp; readFramebuffer-&gt;getSamples() != 0)
-        {
-            return gl::error(GL_INVALID_OPERATION);
-        }
-
-        blitRenderTarget = true;
-
</del><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    if (mask &amp; (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT))
</del><ins>+bool Context::hasMappedBuffer(GLenum target) const
+{
+    if (target == GL_ARRAY_BUFFER)
</ins><span class="cx">     {
</span><del>-        Renderbuffer *readDSBuffer = NULL;
-        Renderbuffer *drawDSBuffer = NULL;
-
-        // We support OES_packed_depth_stencil, and do not support a separately attached depth and stencil buffer, so if we have
-        // both a depth and stencil buffer, it will be the same buffer.
-
-        if (mask &amp; GL_DEPTH_BUFFER_BIT)
</del><ins>+        for (unsigned int attribIndex = 0; attribIndex &lt; gl::MAX_VERTEX_ATTRIBS; attribIndex++)
</ins><span class="cx">         {
</span><del>-            if (readFramebuffer-&gt;getDepthbuffer() &amp;&amp; drawFramebuffer-&gt;getDepthbuffer())
</del><ins>+            const gl::VertexAttribute &amp;vertexAttrib = getVertexAttribState(attribIndex);
+            gl::Buffer *boundBuffer = vertexAttrib.mBoundBuffer.get();
+            if (vertexAttrib.mArrayEnabled &amp;&amp; boundBuffer &amp;&amp; boundBuffer-&gt;mapped())
</ins><span class="cx">             {
</span><del>-                if (readFramebuffer-&gt;getDepthbufferType() != drawFramebuffer-&gt;getDepthbufferType() ||
-                    readFramebuffer-&gt;getDepthbuffer()-&gt;getActualFormat() != drawFramebuffer-&gt;getDepthbuffer()-&gt;getActualFormat())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                blitDepthStencil = true;
-                readDSBuffer = readFramebuffer-&gt;getDepthbuffer();
-                drawDSBuffer = drawFramebuffer-&gt;getDepthbuffer();
</del><ins>+                return true;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><del>-
-        if (mask &amp; GL_STENCIL_BUFFER_BIT)
-        {
-            if (readFramebuffer-&gt;getStencilbuffer() &amp;&amp; drawFramebuffer-&gt;getStencilbuffer())
-            {
-                if (readFramebuffer-&gt;getStencilbufferType() != drawFramebuffer-&gt;getStencilbufferType() ||
-                    readFramebuffer-&gt;getStencilbuffer()-&gt;getActualFormat() != drawFramebuffer-&gt;getStencilbuffer()-&gt;getActualFormat())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                blitDepthStencil = true;
-                readDSBuffer = readFramebuffer-&gt;getStencilbuffer();
-                drawDSBuffer = drawFramebuffer-&gt;getStencilbuffer();
-            }
-        }
-
-        if (partialBufferCopy)
-        {
-            ERR(&quot;Only whole-buffer depth and stencil blits are supported by this implementation.&quot;);
-            return gl::error(GL_INVALID_OPERATION); // only whole-buffer copies are permitted
-        }
-
-        if ((drawDSBuffer &amp;&amp; drawDSBuffer-&gt;getSamples() != 0) || 
-            (readDSBuffer &amp;&amp; readDSBuffer-&gt;getSamples() != 0))
-        {
-            return gl::error(GL_INVALID_OPERATION);
-        }
</del><span class="cx">     }
</span><del>-
-    if (blitRenderTarget || blitDepthStencil)
</del><ins>+    else if (target == GL_ELEMENT_ARRAY_BUFFER)
</ins><span class="cx">     {
</span><del>-        mRenderer-&gt;blitRect(readFramebuffer, sourceTrimmedRect, drawFramebuffer, destTrimmedRect, blitRenderTarget, blitDepthStencil);
</del><ins>+        Buffer *elementBuffer = getElementArrayBuffer();
+        return (elementBuffer &amp;&amp; elementBuffer-&gt;mapped());
</ins><span class="cx">     }
</span><ins>+    else if (target == GL_TRANSFORM_FEEDBACK_BUFFER)
+    {
+        UNIMPLEMENTED();
+    }
+    else UNREACHABLE();
+    return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> extern &quot;C&quot;
</span><span class="cx"> {
</span><del>-gl::Context *glCreateContext(const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess)
</del><ins>+gl::Context *glCreateContext(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess)
</ins><span class="cx"> {
</span><del>-    return new gl::Context(shareContext, renderer, notifyResets, robustAccess);
</del><ins>+    return new gl::Context(clientVersion, shareContext, renderer, notifyResets, robustAccess);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void glDestroyContext(gl::Context *context)
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Contexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -10,26 +10,27 @@
</span><span class="cx"> #ifndef LIBGLESV2_CONTEXT_H_
</span><span class="cx"> #define LIBGLESV2_CONTEXT_H_
</span><span class="cx"> 
</span><ins>+#ifndef GL_APICALL
</ins><span class="cx"> #define GL_APICALL
</span><ins>+#endif
+#include &lt;GLES3/gl3.h&gt;
+#include &lt;GLES3/gl3ext.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> #include &lt;GLES2/gl2ext.h&gt;
</span><span class="cx"> #define EGLAPI
</span><span class="cx"> #include &lt;EGL/egl.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;string&gt;
</span><ins>+#include &lt;set&gt;
</ins><span class="cx"> #include &lt;map&gt;
</span><del>-#include &lt;set&gt;
-#ifdef _MSC_VER
-#include &lt;hash_map&gt;
-#else
</del><span class="cx"> #include &lt;unordered_map&gt;
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><span class="cx"> #include &quot;common/RefCountObject.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/HandleAllocator.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/angletypes.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Constants.h&quot;
</span><ins>+#include &quot;libGLESv2/VertexAttribute.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -49,6 +50,8 @@
</span><span class="cx"> class Texture;
</span><span class="cx"> class Texture2D;
</span><span class="cx"> class TextureCubeMap;
</span><ins>+class Texture3D;
+class Texture2DArray;
</ins><span class="cx"> class Framebuffer;
</span><span class="cx"> class Renderbuffer;
</span><span class="cx"> class RenderbufferStorage;
</span><span class="lines">@@ -56,73 +59,20 @@
</span><span class="cx"> class Depthbuffer;
</span><span class="cx"> class Stencilbuffer;
</span><span class="cx"> class DepthStencilbuffer;
</span><del>-class Fence;
</del><ins>+class FenceNV;
+class FenceSync;
</ins><span class="cx"> class Query;
</span><span class="cx"> class ResourceManager;
</span><span class="cx"> class Buffer;
</span><ins>+class VertexAttribute;
+class VertexArray;
+class Sampler;
+class TransformFeedback;
</ins><span class="cx"> 
</span><del>-enum QueryType
-{
-    QUERY_ANY_SAMPLES_PASSED,
-    QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE,
-
-    QUERY_TYPE_COUNT
-};
-
-// Helper structure describing a single vertex attribute
-class VertexAttribute
-{
-  public:
-    VertexAttribute() : mType(GL_FLOAT), mSize(4), mNormalized(false), mStride(0), mPointer(NULL), mArrayEnabled(false), mDivisor(0)
-    {
-        mCurrentValue[0] = 0.0f;
-        mCurrentValue[1] = 0.0f;
-        mCurrentValue[2] = 0.0f;
-        mCurrentValue[3] = 1.0f;
-    }
-
-    int typeSize() const
-    {
-        switch (mType)
-        {
-          case GL_BYTE:           return mSize * sizeof(GLbyte);
-          case GL_UNSIGNED_BYTE:  return mSize * sizeof(GLubyte);
-          case GL_SHORT:          return mSize * sizeof(GLshort);
-          case GL_UNSIGNED_SHORT: return mSize * sizeof(GLushort);
-          case GL_FIXED:          return mSize * sizeof(GLfixed);
-          case GL_FLOAT:          return mSize * sizeof(GLfloat);
-          default: UNREACHABLE(); return mSize * sizeof(GLfloat);
-        }
-    }
-
-    GLsizei stride() const
-    {
-        return mStride ? mStride : typeSize();
-    }
-
-    // From glVertexAttribPointer
-    GLenum mType;
-    GLint mSize;
-    bool mNormalized;
-    GLsizei mStride;   // 0 means natural stride
-
-    union
-    {
-        const void *mPointer;
-        intptr_t mOffset;
-    };
-
-    BindingPointer&lt;Buffer&gt; mBoundBuffer;   // Captured when glVertexAttribPointer is called.
-
-    bool mArrayEnabled;   // From glEnable/DisableVertexAttribArray
-    float mCurrentValue[4];   // From glVertexAttrib
-    unsigned int mDivisor;
-};
-
</del><span class="cx"> // Helper structure to store all raw state
</span><span class="cx"> struct State
</span><span class="cx"> {
</span><del>-    Color colorClearValue;
</del><ins>+    ColorF colorClearValue;
</ins><span class="cx">     GLclampf depthClearValue;
</span><span class="cx">     int stencilClearValue;
</span><span class="cx"> 
</span><span class="lines">@@ -131,7 +81,7 @@
</span><span class="cx">     Rectangle scissor;
</span><span class="cx"> 
</span><span class="cx">     BlendState blend;
</span><del>-    Color blendColor;
</del><ins>+    ColorF blendColor;
</ins><span class="cx">     bool sampleCoverage;
</span><span class="cx">     GLclampf sampleCoverageValue;
</span><span class="cx">     bool sampleCoverageInvert;
</span><span class="lines">@@ -151,27 +101,40 @@
</span><span class="cx"> 
</span><span class="cx">     unsigned int activeSampler;   // Active texture unit selector - GL_TEXTURE0
</span><span class="cx">     BindingPointer&lt;Buffer&gt; arrayBuffer;
</span><del>-    BindingPointer&lt;Buffer&gt; elementArrayBuffer;
</del><span class="cx">     GLuint readFramebuffer;
</span><span class="cx">     GLuint drawFramebuffer;
</span><span class="cx">     BindingPointer&lt;Renderbuffer&gt; renderbuffer;
</span><span class="cx">     GLuint currentProgram;
</span><span class="cx"> 
</span><del>-    VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS];
</del><ins>+    VertexAttribCurrentValueData vertexAttribCurrentValues[MAX_VERTEX_ATTRIBS]; // From glVertexAttrib
+    unsigned int vertexArray;
+
</ins><span class="cx">     BindingPointer&lt;Texture&gt; samplerTexture[TEXTURE_TYPE_COUNT][IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS];
</span><del>-    BindingPointer&lt;Query&gt; activeQuery[QUERY_TYPE_COUNT];
</del><ins>+    GLuint samplers[IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS];
</ins><span class="cx"> 
</span><del>-    GLint unpackAlignment;
-    GLint packAlignment;
-    bool packReverseRowOrder;
</del><ins>+    typedef std::map&lt; GLenum, BindingPointer&lt;Query&gt; &gt; ActiveQueryMap;
+    ActiveQueryMap activeQueries;
+
+    BindingPointer&lt;Buffer&gt; genericUniformBuffer;
+    OffsetBindingPointer&lt;Buffer&gt; uniformBuffers[IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS];
+
+    BindingPointer&lt;TransformFeedback&gt; transformFeedback;
+    BindingPointer&lt;Buffer&gt; genericTransformFeedbackBuffer;
+    OffsetBindingPointer&lt;Buffer&gt; transformFeedbackBuffers[IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
+
+    BindingPointer&lt;Buffer&gt; copyReadBuffer;
+    BindingPointer&lt;Buffer&gt; copyWriteBuffer;
+
+    PixelUnpackState unpack;
+    PixelPackState pack;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class Context
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    Context(const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess);
</del><ins>+    Context(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess);
</ins><span class="cx"> 
</span><del>-    ~Context();
</del><ins>+    virtual ~Context();
</ins><span class="cx"> 
</span><span class="cx">     void makeCurrent(egl::Surface *surface);
</span><span class="cx"> 
</span><span class="lines">@@ -179,12 +142,18 @@
</span><span class="cx">     bool isContextLost();
</span><span class="cx"> 
</span><span class="cx">     // State manipulation
</span><ins>+    void setCap(GLenum cap, bool enabled);
+    bool getCap(GLenum cap);
+
</ins><span class="cx">     void setClearColor(float red, float green, float blue, float alpha);
</span><span class="cx"> 
</span><span class="cx">     void setClearDepth(float depth);
</span><span class="cx"> 
</span><span class="cx">     void setClearStencil(int stencil);
</span><span class="cx"> 
</span><ins>+    void setRasterizerDiscard(bool enabled);
+    bool isRasterizerDiscardEnabled() const;
+
</ins><span class="cx">     void setCullFace(bool enabled);
</span><span class="cx">     bool isCullFaceEnabled() const;
</span><span class="cx"> 
</span><span class="lines">@@ -243,6 +212,7 @@
</span><span class="cx">     void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height);
</span><span class="cx"> 
</span><span class="cx">     void setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height);
</span><ins>+    void getScissorParams(GLint *x, GLint *y, GLsizei *width, GLsizei *height);
</ins><span class="cx"> 
</span><span class="cx">     void setColorMask(bool red, bool green, bool blue, bool alpha);
</span><span class="cx">     void setDepthMask(bool mask);
</span><span class="lines">@@ -252,22 +222,27 @@
</span><span class="cx">     GLuint getReadFramebufferHandle() const;
</span><span class="cx">     GLuint getDrawFramebufferHandle() const;
</span><span class="cx">     GLuint getRenderbufferHandle() const;
</span><ins>+    GLuint getVertexArrayHandle() const;
+    GLuint getSamplerHandle(GLuint textureUnit) const;
</ins><span class="cx"> 
</span><span class="cx">     GLuint getArrayBufferHandle() const;
</span><span class="cx"> 
</span><span class="cx">     GLuint getActiveQuery(GLenum target) const;
</span><span class="cx"> 
</span><span class="cx">     void setEnableVertexAttribArray(unsigned int attribNum, bool enabled);
</span><del>-    const VertexAttribute &amp;getVertexAttribState(unsigned int attribNum);
</del><ins>+    const VertexAttribute &amp;getVertexAttribState(unsigned int attribNum) const;
+    const VertexAttribCurrentValueData &amp;getVertexAttribCurrentValue(unsigned int attribNum) const;
</ins><span class="cx">     void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
</span><del>-                              bool normalized, GLsizei stride, const void *pointer);
</del><ins>+                              bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
</ins><span class="cx">     const void *getVertexAttribPointer(unsigned int attribNum) const;
</span><span class="cx"> 
</span><span class="cx">     void setUnpackAlignment(GLint alignment);
</span><span class="cx">     GLint getUnpackAlignment() const;
</span><ins>+    const PixelUnpackState &amp;getUnpackState() const;
</ins><span class="cx"> 
</span><span class="cx">     void setPackAlignment(GLint alignment);
</span><span class="cx">     GLint getPackAlignment() const;
</span><ins>+    const PixelPackState &amp;getPackState() const;
</ins><span class="cx"> 
</span><span class="cx">     void setPackReverseRowOrder(bool reverseRowOrder);
</span><span class="cx">     bool getPackReverseRowOrder() const;
</span><span class="lines">@@ -279,35 +254,58 @@
</span><span class="cx">     GLuint createProgram();
</span><span class="cx">     GLuint createTexture();
</span><span class="cx">     GLuint createRenderbuffer();
</span><ins>+    GLuint createSampler();
+    GLuint createTransformFeedback();
+    GLsync createFenceSync(GLenum condition);
</ins><span class="cx"> 
</span><span class="cx">     void deleteBuffer(GLuint buffer);
</span><span class="cx">     void deleteShader(GLuint shader);
</span><span class="cx">     void deleteProgram(GLuint program);
</span><span class="cx">     void deleteTexture(GLuint texture);
</span><span class="cx">     void deleteRenderbuffer(GLuint renderbuffer);
</span><ins>+    void deleteSampler(GLuint sampler);
+    void deleteTransformFeedback(GLuint transformFeedback);
+    void deleteFenceSync(GLsync fenceSync);
</ins><span class="cx"> 
</span><span class="cx">     // Framebuffers are owned by the Context, so these methods do not pass through
</span><span class="cx">     GLuint createFramebuffer();
</span><span class="cx">     void deleteFramebuffer(GLuint framebuffer);
</span><span class="cx"> 
</span><del>-    // Fences are owned by the Context.
-    GLuint createFence();
-    void deleteFence(GLuint fence);
</del><ins>+    // NV Fences are owned by the Context.
+    GLuint createFenceNV();
+    void deleteFenceNV(GLuint fence);
</ins><span class="cx">     
</span><span class="cx">     // Queries are owned by the Context;
</span><span class="cx">     GLuint createQuery();
</span><span class="cx">     void deleteQuery(GLuint query);
</span><span class="cx"> 
</span><ins>+    // Vertex arrays are owned by the Context
+    GLuint createVertexArray();
+    void deleteVertexArray(GLuint vertexArray);
+
</ins><span class="cx">     void bindArrayBuffer(GLuint buffer);
</span><span class="cx">     void bindElementArrayBuffer(GLuint buffer);
</span><span class="cx">     void bindTexture2D(GLuint texture);
</span><span class="cx">     void bindTextureCubeMap(GLuint texture);
</span><ins>+    void bindTexture3D(GLuint texture);
+    void bindTexture2DArray(GLuint texture);
</ins><span class="cx">     void bindReadFramebuffer(GLuint framebuffer);
</span><span class="cx">     void bindDrawFramebuffer(GLuint framebuffer);
</span><span class="cx">     void bindRenderbuffer(GLuint renderbuffer);
</span><ins>+    void bindVertexArray(GLuint vertexArray);
+    void bindSampler(GLuint textureUnit, GLuint sampler);
+    void bindGenericUniformBuffer(GLuint buffer);
+    void bindIndexedUniformBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size);
+    void bindGenericTransformFeedbackBuffer(GLuint buffer);
+    void bindIndexedTransformFeedbackBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size);
+    void bindCopyReadBuffer(GLuint buffer);
+    void bindCopyWriteBuffer(GLuint buffer);
+    void bindPixelPackBuffer(GLuint buffer);
+    void bindPixelUnpackBuffer(GLuint buffer);
</ins><span class="cx">     void useProgram(GLuint program);
</span><span class="cx">     void linkProgram(GLuint program);
</span><span class="cx">     void setProgramBinary(GLuint program, const void *binary, GLint length);
</span><ins>+    void bindTransformFeedback(GLuint transformFeedback);
</ins><span class="cx"> 
</span><span class="cx">     void beginQuery(GLenum target, GLuint query);
</span><span class="cx">     void endQuery(GLenum target);
</span><span class="lines">@@ -316,35 +314,75 @@
</span><span class="cx"> 
</span><span class="cx">     void setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples);
</span><span class="cx"> 
</span><del>-    void setVertexAttrib(GLuint index, const GLfloat *values);
</del><ins>+    void setVertexAttribf(GLuint index, const GLfloat values[4]);
+    void setVertexAttribu(GLuint index, const GLuint values[4]);
+    void setVertexAttribi(GLuint index, const GLint values[4]);
</ins><span class="cx">     void setVertexAttribDivisor(GLuint index, GLuint divisor);
</span><span class="cx"> 
</span><ins>+    void samplerParameteri(GLuint sampler, GLenum pname, GLint param);
+    void samplerParameterf(GLuint sampler, GLenum pname, GLfloat param);
+    GLint getSamplerParameteri(GLuint sampler, GLenum pname);
+    GLfloat getSamplerParameterf(GLuint sampler, GLenum pname);
+
</ins><span class="cx">     Buffer *getBuffer(GLuint handle);
</span><del>-    Fence *getFence(GLuint handle);
-    Shader *getShader(GLuint handle);
-    Program *getProgram(GLuint handle);
</del><ins>+    FenceNV *getFenceNV(GLuint handle);
+    FenceSync *getFenceSync(GLsync handle) const;
+    Shader *getShader(GLuint handle) const;
+    Program *getProgram(GLuint handle) const;
</ins><span class="cx">     Texture *getTexture(GLuint handle);
</span><del>-    Framebuffer *getFramebuffer(GLuint handle);
</del><ins>+    Framebuffer *getFramebuffer(GLuint handle) const;
</ins><span class="cx">     Renderbuffer *getRenderbuffer(GLuint handle);
</span><ins>+    VertexArray *getVertexArray(GLuint handle) const;
+    Sampler *getSampler(GLuint handle) const;
</ins><span class="cx">     Query *getQuery(GLuint handle, bool create, GLenum type);
</span><ins>+    TransformFeedback *getTransformFeedback(GLuint handle) const;
</ins><span class="cx"> 
</span><ins>+    Buffer *getTargetBuffer(GLenum target) const;
</ins><span class="cx">     Buffer *getArrayBuffer();
</span><del>-    Buffer *getElementArrayBuffer();
</del><ins>+    Buffer *getElementArrayBuffer() const;
</ins><span class="cx">     ProgramBinary *getCurrentProgramBinary();
</span><del>-    Texture2D *getTexture2D();
-    TextureCubeMap *getTextureCubeMap();
-    Texture *getSamplerTexture(unsigned int sampler, TextureType type);
</del><ins>+
+    Texture *getTargetTexture(GLenum target) const;
+    Texture2D *getTexture2D() const;
+    TextureCubeMap *getTextureCubeMap() const;
+    Texture3D *getTexture3D() const;
+    Texture2DArray *getTexture2DArray() const;
+
+    Buffer *getGenericUniformBuffer();
+    Buffer *getGenericTransformFeedbackBuffer();
+    Buffer *getCopyReadBuffer();
+    Buffer *getCopyWriteBuffer();
+    Buffer *getPixelPackBuffer();
+    Buffer *getPixelUnpackBuffer();
+    Texture *getSamplerTexture(unsigned int sampler, TextureType type) const;
+
+    Framebuffer *getTargetFramebuffer(GLenum target) const;
+    GLuint getTargetFramebufferHandle(GLenum target) const;
</ins><span class="cx">     Framebuffer *getReadFramebuffer();
</span><span class="cx">     Framebuffer *getDrawFramebuffer();
</span><ins>+    VertexArray *getCurrentVertexArray() const;
+    TransformFeedback *getCurrentTransformFeedback() const;
</ins><span class="cx"> 
</span><ins>+    bool isSampler(GLuint samplerName) const;
+
+    bool getBooleanv(GLenum pname, GLboolean *params);
</ins><span class="cx">     bool getFloatv(GLenum pname, GLfloat *params);
</span><span class="cx">     bool getIntegerv(GLenum pname, GLint *params);
</span><del>-    bool getBooleanv(GLenum pname, GLboolean *params);
</del><ins>+    bool getInteger64v(GLenum pname, GLint64 *params);
</ins><span class="cx"> 
</span><ins>+    bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data);
+    bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data);
+
</ins><span class="cx">     bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
</span><ins>+    bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams);
</ins><span class="cx"> 
</span><ins>+    void clear(GLbitfield mask);
+    void clearBufferfv(GLenum buffer, int drawbuffer, const float *values);
+    void clearBufferuiv(GLenum buffer, int drawbuffer, const unsigned int *values);
+    void clearBufferiv(GLenum buffer, int drawbuffer, const int *values);
+    void clearBufferfi(GLenum buffer, int drawbuffer, float depth, int stencil);
+
</ins><span class="cx">     void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);
</span><del>-    void clear(GLbitfield mask);
</del><span class="cx">     void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances);
</span><span class="cx">     void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instances);
</span><span class="cx">     void sync(bool block);   // flush/finish
</span><span class="lines">@@ -359,16 +397,31 @@
</span><span class="cx">     GLenum getResetStatus();
</span><span class="cx">     virtual bool isResetNotificationEnabled();
</span><span class="cx"> 
</span><ins>+    virtual int getClientVersion() const;
+
</ins><span class="cx">     int getMajorShaderModel() const;
</span><span class="cx">     float getMaximumPointSize() const;
</span><span class="cx">     unsigned int getMaximumCombinedTextureImageUnits() const;
</span><ins>+    unsigned int getMaximumCombinedUniformBufferBindings() const;
</ins><span class="cx">     int getMaximumRenderbufferDimension() const;
</span><del>-    int getMaximumTextureDimension() const;
</del><ins>+    int getMaximum2DTextureDimension() const;
</ins><span class="cx">     int getMaximumCubeTextureDimension() const;
</span><del>-    int getMaximumTextureLevel() const;
</del><ins>+    int getMaximum3DTextureDimension() const;
+    int getMaximum2DArrayTextureLayers() const;
+    int getMaximum2DTextureLevel() const;
+    int getMaximumCubeTextureLevel() const;
+    int getMaximum3DTextureLevel() const;
+    int getMaximum2DArrayTextureLevel() const;
</ins><span class="cx">     unsigned int getMaximumRenderTargets() const;
</span><span class="cx">     GLsizei getMaxSupportedSamples() const;
</span><del>-    const char *getExtensionString() const;
</del><ins>+    GLsizei getMaxSupportedFormatSamples(GLenum internalFormat) const;
+    GLsizei getNumSampleCounts(GLenum internalFormat) const;
+    void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const;
+    unsigned int getMaxTransformFeedbackBufferBindings() const;
+    GLintptr getUniformBufferOffsetAlignment() const;
+    const char *getCombinedExtensionsString() const;
+    const char *getExtensionString(const GLuint index) const;
+    unsigned int getNumExtensions() const;
</ins><span class="cx">     const char *getRendererString() const;
</span><span class="cx">     bool supportsEventQueries() const;
</span><span class="cx">     bool supportsOcclusionQueries() const;
</span><span class="lines">@@ -384,20 +437,26 @@
</span><span class="cx">     bool supportsFloat16RenderableTextures() const;
</span><span class="cx">     bool supportsLuminanceTextures() const;
</span><span class="cx">     bool supportsLuminanceAlphaTextures() const;
</span><ins>+    bool supportsRGTextures() const;
</ins><span class="cx">     bool supportsDepthTextures() const;
</span><span class="cx">     bool supports32bitIndices() const;
</span><span class="cx">     bool supportsNonPower2Texture() const;
</span><span class="cx">     bool supportsInstancing() const;
</span><span class="cx">     bool supportsTextureFilterAnisotropy() const;
</span><ins>+    bool supportsPBOs() const;
</ins><span class="cx"> 
</span><del>-    bool getCurrentReadFormatType(GLenum *format, GLenum *type);
</del><ins>+    bool getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type);
</ins><span class="cx"> 
</span><span class="cx">     float getTextureMaxAnisotropy() const;
</span><span class="cx"> 
</span><del>-    void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 
-                         GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
-                         GLbitfield mask);
</del><ins>+    void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+                         GLbitfield mask, GLenum filter);
</ins><span class="cx"> 
</span><ins>+    void invalidateFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments,
+                               GLint x, GLint y, GLsizei width, GLsizei height);
+
+    bool hasMappedBuffer(GLenum target) const;
+
</ins><span class="cx">     rx::Renderer *getRenderer() { return mRenderer; }
</span><span class="cx"> 
</span><span class="cx">   private:
</span><span class="lines">@@ -405,15 +464,25 @@
</span><span class="cx"> 
</span><span class="cx">     bool applyRenderTarget(GLenum drawMode, bool ignoreViewport);
</span><span class="cx">     void applyState(GLenum drawMode);
</span><del>-    void applyShaders();
-    void applyTextures();
-    void applyTextures(SamplerType type);
</del><ins>+    void applyShaders(ProgramBinary *programBinary, bool transformFeedbackActive);
+    void applyTextures(ProgramBinary *programBinary);
+    void applyTextures(ProgramBinary *programBinary, SamplerType type);
+    bool applyUniformBuffers();
+    bool applyTransformFeedbackBuffers();
+    void markTransformFeedbackUsage();
</ins><span class="cx"> 
</span><span class="cx">     void detachBuffer(GLuint buffer);
</span><span class="cx">     void detachTexture(GLuint texture);
</span><span class="cx">     void detachFramebuffer(GLuint framebuffer);
</span><span class="cx">     void detachRenderbuffer(GLuint renderbuffer);
</span><ins>+    void detachVertexArray(GLuint vertexArray);
+    void detachTransformFeedback(GLuint transformFeedback);
+    void detachSampler(GLuint sampler);
</ins><span class="cx"> 
</span><ins>+    void generateSwizzles(ProgramBinary *programBinary);
+    void generateSwizzles(ProgramBinary *programBinary, SamplerType type);
+    bool getCurrentTextureAndSamplerState(ProgramBinary *programBinary, SamplerType type, int index, Texture **outTexture,
+                                   TextureType *outTextureType, SamplerState *outSampler);
</ins><span class="cx">     Texture *getIncompleteTexture(TextureType type);
</span><span class="cx"> 
</span><span class="cx">     bool skipDraw(GLenum drawMode);
</span><span class="lines">@@ -426,32 +495,38 @@
</span><span class="cx"> 
</span><span class="cx">     rx::Renderer *const mRenderer;
</span><span class="cx"> 
</span><ins>+    int mClientVersion;
+
</ins><span class="cx">     State mState;
</span><span class="cx"> 
</span><span class="cx">     BindingPointer&lt;Texture2D&gt; mTexture2DZero;
</span><span class="cx">     BindingPointer&lt;TextureCubeMap&gt; mTextureCubeMapZero;
</span><ins>+    BindingPointer&lt;Texture3D&gt; mTexture3DZero;
+    BindingPointer&lt;Texture2DArray&gt; mTexture2DArrayZero;
</ins><span class="cx"> 
</span><del>-#ifndef HASH_MAP
-# ifdef _MSC_VER
-#  define HASH_MAP stdext::hash_map
-# else
-#  define HASH_MAP std::unordered_map
-# endif
-#endif
-
-    typedef HASH_MAP&lt;GLuint, Framebuffer*&gt; FramebufferMap;
</del><ins>+    typedef std::unordered_map&lt;GLuint, Framebuffer*&gt; FramebufferMap;
</ins><span class="cx">     FramebufferMap mFramebufferMap;
</span><span class="cx">     HandleAllocator mFramebufferHandleAllocator;
</span><span class="cx"> 
</span><del>-    typedef HASH_MAP&lt;GLuint, Fence*&gt; FenceMap;
-    FenceMap mFenceMap;
-    HandleAllocator mFenceHandleAllocator;
</del><ins>+    typedef std::unordered_map&lt;GLuint, FenceNV*&gt; FenceNVMap;
+    FenceNVMap mFenceNVMap;
+    HandleAllocator mFenceNVHandleAllocator;
</ins><span class="cx"> 
</span><del>-    typedef HASH_MAP&lt;GLuint, Query*&gt; QueryMap;
</del><ins>+    typedef std::unordered_map&lt;GLuint, Query*&gt; QueryMap;
</ins><span class="cx">     QueryMap mQueryMap;
</span><span class="cx">     HandleAllocator mQueryHandleAllocator;
</span><span class="cx"> 
</span><del>-    const char *mExtensionString;
</del><ins>+    typedef std::unordered_map&lt;GLuint, VertexArray*&gt; VertexArrayMap;
+    VertexArrayMap mVertexArrayMap;
+    HandleAllocator mVertexArrayHandleAllocator;
+
+    BindingPointer&lt;TransformFeedback&gt; mTransformFeedbackZero;
+    typedef std::unordered_map&lt;GLuint, TransformFeedback*&gt; TransformFeedbackMap;
+    TransformFeedbackMap mTransformFeedbackMap;
+    HandleAllocator mTransformFeedbackAllocator;
+
+    std::vector&lt;std::string&gt; mExtensionStringList;
+    const char *mCombinedExtensionsString;
</ins><span class="cx">     const char *mRendererString;
</span><span class="cx">     
</span><span class="cx">     BindingPointer&lt;Texture&gt; mIncompleteTextures[TEXTURE_TYPE_COUNT];
</span><span class="lines">@@ -480,9 +555,14 @@
</span><span class="cx">     bool mSupportsInstancing;
</span><span class="cx">     int  mMaxViewportDimension;
</span><span class="cx">     int  mMaxRenderbufferDimension;
</span><del>-    int  mMaxTextureDimension;
</del><ins>+    int  mMax2DTextureDimension;
</ins><span class="cx">     int  mMaxCubeTextureDimension;
</span><del>-    int  mMaxTextureLevel;
</del><ins>+    int  mMax3DTextureDimension;
+    int  mMax2DArrayTextureLayers;
+    int  mMax2DTextureLevel;
+    int  mMaxCubeTextureLevel;
+    int  mMax3DTextureLevel;
+    int  mMax2DArrayTextureLevel;
</ins><span class="cx">     float mMaxTextureAnisotropy;
</span><span class="cx">     bool mSupportsEventQueries;
</span><span class="cx">     bool mSupportsOcclusionQueries;
</span><span class="lines">@@ -498,9 +578,11 @@
</span><span class="cx">     bool mSupportsFloat16RenderableTextures;
</span><span class="cx">     bool mSupportsLuminanceTextures;
</span><span class="cx">     bool mSupportsLuminanceAlphaTextures;
</span><ins>+    bool mSupportsRGTextures;
</ins><span class="cx">     bool mSupportsDepthTextures;
</span><span class="cx">     bool mSupports32bitIndices;
</span><span class="cx">     bool mSupportsTextureFilterAnisotropy;
</span><ins>+    bool mSupportsPBOs;
</ins><span class="cx">     int mNumCompressedTextureFormats;
</span><span class="cx"> 
</span><span class="cx">     ResourceManager *mResourceManager;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2DynamicHLSLcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/DynamicHLSL.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/DynamicHLSL.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/DynamicHLSL.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,1047 @@
</span><ins>+//
+// Copyright (c) 2014 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.
+//
+// DynamicHLSL.cpp: Implementation for link and run-time HLSL generation
+//
+
+#include &quot;precompiled.h&quot;
+
+#include &quot;libGLESv2/DynamicHLSL.h&quot;
+#include &quot;libGLESv2/Shader.h&quot;
+#include &quot;libGLESv2/Program.h&quot;
+#include &quot;libGLESv2/renderer/Renderer.h&quot;
+#include &quot;common/utilities.h&quot;
+#include &quot;libGLESv2/ProgramBinary.h&quot;
+#include &quot;libGLESv2/formatutils.h&quot;
+#include &quot;common/blocklayout.h&quot;
+
+static std::string Str(int i)
+{
+    char buffer[20];
+    snprintf(buffer, sizeof(buffer), &quot;%d&quot;, i);
+    return buffer;
+}
+
+namespace gl_d3d
+{
+
+std::string HLSLComponentTypeString(GLenum componentType)
+{
+    switch (componentType)
+    {
+      case GL_UNSIGNED_INT:         return &quot;uint&quot;;
+      case GL_INT:                  return &quot;int&quot;;
+      case GL_UNSIGNED_NORMALIZED:
+      case GL_SIGNED_NORMALIZED:
+      case GL_FLOAT:                return &quot;float&quot;;
+      default: UNREACHABLE();       return &quot;not-component-type&quot;;
+    }
+}
+
+std::string HLSLComponentTypeString(GLenum componentType, int componentCount)
+{
+    return HLSLComponentTypeString(componentType) + (componentCount &gt; 1 ? Str(componentCount) : &quot;&quot;);
+}
+
+std::string HLSLMatrixTypeString(GLenum type)
+{
+    switch (type)
+    {
+      case GL_FLOAT_MAT2:     return &quot;float2x2&quot;;
+      case GL_FLOAT_MAT3:     return &quot;float3x3&quot;;
+      case GL_FLOAT_MAT4:     return &quot;float4x4&quot;;
+      case GL_FLOAT_MAT2x3:   return &quot;float2x3&quot;;
+      case GL_FLOAT_MAT3x2:   return &quot;float3x2&quot;;
+      case GL_FLOAT_MAT2x4:   return &quot;float2x4&quot;;
+      case GL_FLOAT_MAT4x2:   return &quot;float4x2&quot;;
+      case GL_FLOAT_MAT3x4:   return &quot;float3x4&quot;;
+      case GL_FLOAT_MAT4x3:   return &quot;float4x3&quot;;
+      default: UNREACHABLE(); return &quot;not-matrix-type&quot;;
+    }
+}
+
+std::string HLSLTypeString(GLenum type)
+{
+    if (gl::IsMatrixType(type))
+    {
+        return HLSLMatrixTypeString(type);
+    }
+
+    return HLSLComponentTypeString(gl::UniformComponentType(type), gl::UniformComponentCount(type));
+}
+
+}
+
+namespace gl
+{
+
+std::string ArrayString(unsigned int i)
+{
+    return (i == GL_INVALID_INDEX ? &quot;&quot; : &quot;[&quot; + Str(i) + &quot;]&quot;);
+}
+
+const std::string DynamicHLSL::VERTEX_ATTRIBUTE_STUB_STRING = &quot;@@ VERTEX ATTRIBUTES @@&quot;;
+
+DynamicHLSL::DynamicHLSL(rx::Renderer *const renderer)
+    : mRenderer(renderer)
+{
+}
+
+static bool packVarying(Varying *varying, const int maxVaryingVectors, const ShaderVariable *packing[][4])
+{
+    GLenum transposedType = TransposeMatrixType(varying-&gt;type);
+
+    // matrices within varying structs are not transposed
+    int registers = (varying-&gt;isStruct() ? HLSLVariableRegisterCount(*varying) : VariableRowCount(transposedType)) * varying-&gt;elementCount();
+    int elements = (varying-&gt;isStruct() ? 4 : VariableColumnCount(transposedType));
+    bool success = false;
+
+    if (elements == 2 || elements == 3 || elements == 4)
+    {
+        for (int r = 0; r &lt;= maxVaryingVectors - registers &amp;&amp; !success; r++)
+        {
+            bool available = true;
+
+            for (int y = 0; y &lt; registers &amp;&amp; available; y++)
+            {
+                for (int x = 0; x &lt; elements &amp;&amp; available; x++)
+                {
+                    if (packing[r + y][x])
+                    {
+                        available = false;
+                    }
+                }
+            }
+
+            if (available)
+            {
+                varying-&gt;registerIndex = r;
+                varying-&gt;elementIndex = 0;
+
+                for (int y = 0; y &lt; registers; y++)
+                {
+                    for (int x = 0; x &lt; elements; x++)
+                    {
+                        packing[r + y][x] = &amp;*varying;
+                    }
+                }
+
+                success = true;
+            }
+        }
+
+        if (!success &amp;&amp; elements == 2)
+        {
+            for (int r = maxVaryingVectors - registers; r &gt;= 0 &amp;&amp; !success; r--)
+            {
+                bool available = true;
+
+                for (int y = 0; y &lt; registers &amp;&amp; available; y++)
+                {
+                    for (int x = 2; x &lt; 4 &amp;&amp; available; x++)
+                    {
+                        if (packing[r + y][x])
+                        {
+                            available = false;
+                        }
+                    }
+                }
+
+                if (available)
+                {
+                    varying-&gt;registerIndex = r;
+                    varying-&gt;elementIndex = 2;
+
+                    for (int y = 0; y &lt; registers; y++)
+                    {
+                        for (int x = 2; x &lt; 4; x++)
+                        {
+                            packing[r + y][x] = &amp;*varying;
+                        }
+                    }
+
+                    success = true;
+                }
+            }
+        }
+    }
+    else if (elements == 1)
+    {
+        int space[4] = { 0 };
+
+        for (int y = 0; y &lt; maxVaryingVectors; y++)
+        {
+            for (int x = 0; x &lt; 4; x++)
+            {
+                space[x] += packing[y][x] ? 0 : 1;
+            }
+        }
+
+        int column = 0;
+
+        for (int x = 0; x &lt; 4; x++)
+        {
+            if (space[x] &gt;= registers &amp;&amp; space[x] &lt; space[column])
+            {
+                column = x;
+            }
+        }
+
+        if (space[column] &gt;= registers)
+        {
+            for (int r = 0; r &lt; maxVaryingVectors; r++)
+            {
+                if (!packing[r][column])
+                {
+                    varying-&gt;registerIndex = r;
+
+                    for (int y = r; y &lt; r + registers; y++)
+                    {
+                        packing[y][column] = &amp;*varying;
+                    }
+
+                    break;
+                }
+            }
+
+            varying-&gt;elementIndex = column;
+
+            success = true;
+        }
+    }
+    else UNREACHABLE();
+
+    return success;
+}
+
+// Packs varyings into generic varying registers, using the algorithm from [OpenGL ES Shading Language 1.00 rev. 17] appendix A section 7 page 111
+// Returns the number of used varying registers, or -1 if unsuccesful
+int DynamicHLSL::packVaryings(InfoLog &amp;infoLog, const ShaderVariable *packing[][4], FragmentShader *fragmentShader,
+                              VertexShader *vertexShader, const std::vector&lt;std::string&gt;&amp; transformFeedbackVaryings)
+{
+    const int maxVaryingVectors = mRenderer-&gt;getMaxVaryingVectors();
+
+    vertexShader-&gt;resetVaryingsRegisterAssignment();
+    fragmentShader-&gt;resetVaryingsRegisterAssignment();
+
+    std::set&lt;std::string&gt; packedVaryings;
+
+    for (unsigned int varyingIndex = 0; varyingIndex &lt; fragmentShader-&gt;mVaryings.size(); varyingIndex++)
+    {
+        Varying *varying = &amp;fragmentShader-&gt;mVaryings[varyingIndex];
+        if (packVarying(varying, maxVaryingVectors, packing))
+        {
+            packedVaryings.insert(varying-&gt;name);
+        }
+        else
+        {
+            infoLog.append(&quot;Could not pack varying %s&quot;, varying-&gt;name.c_str());
+            return -1;
+        }
+    }
+
+    for (unsigned int feedbackVaryingIndex = 0; feedbackVaryingIndex &lt; transformFeedbackVaryings.size(); feedbackVaryingIndex++)
+    {
+        const std::string &amp;transformFeedbackVarying = transformFeedbackVaryings[feedbackVaryingIndex];
+        if (packedVaryings.find(transformFeedbackVarying) == packedVaryings.end())
+        {
+            bool found = false;
+            for (unsigned int varyingIndex = 0; varyingIndex &lt; vertexShader-&gt;mVaryings.size(); varyingIndex++)
+            {
+                Varying *varying = &amp;vertexShader-&gt;mVaryings[varyingIndex];
+                if (transformFeedbackVarying == varying-&gt;name)
+                {
+                    if (!packVarying(varying, maxVaryingVectors, packing))
+                    {
+                        infoLog.append(&quot;Could not pack varying %s&quot;, varying-&gt;name.c_str());
+                        return -1;
+                    }
+
+                    found = true;
+                    break;
+                }
+            }
+
+            if (!found &amp;&amp; transformFeedbackVarying != &quot;gl_Position&quot; &amp;&amp; transformFeedbackVarying != &quot;gl_PointSize&quot;)
+            {
+                infoLog.append(&quot;Transform feedback varying %s does not exist in the vertex shader.&quot;, transformFeedbackVarying.c_str());
+                return -1;
+            }
+        }
+    }
+
+    // Return the number of used registers
+    int registers = 0;
+
+    for (int r = 0; r &lt; maxVaryingVectors; r++)
+    {
+        if (packing[r][0] || packing[r][1] || packing[r][2] || packing[r][3])
+        {
+            registers++;
+        }
+    }
+
+    return registers;
+}
+
+std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader, const std::string &amp;varyingSemantic,
+                                             std::vector&lt;LinkedVarying&gt; *linkedVaryings) const
+{
+    std::string varyingHLSL;
+
+    for (unsigned int varyingIndex = 0; varyingIndex &lt; shader-&gt;mVaryings.size(); varyingIndex++)
+    {
+        Varying *varying = &amp;shader-&gt;mVaryings[varyingIndex];
+        if (varying-&gt;registerAssigned())
+        {
+            GLenum transposedType = TransposeMatrixType(varying-&gt;type);
+            int variableRows = (varying-&gt;isStruct() ? 1 : VariableRowCount(transposedType));
+
+            for (unsigned int elementIndex = 0; elementIndex &lt; varying-&gt;elementCount(); elementIndex++)
+            {
+                for (int row = 0; row &lt; variableRows; row++)
+                {
+                    switch (varying-&gt;interpolation)
+                    {
+                      case INTERPOLATION_SMOOTH:   varyingHLSL += &quot;    &quot;;                 break;
+                      case INTERPOLATION_FLAT:     varyingHLSL += &quot;    nointerpolation &quot;; break;
+                      case INTERPOLATION_CENTROID: varyingHLSL += &quot;    centroid &quot;;        break;
+                      default:  UNREACHABLE();
+                    }
+
+                    unsigned int semanticIndex = elementIndex * variableRows + varying-&gt;registerIndex + row;
+                    std::string n = Str(semanticIndex);
+
+                    std::string typeString;
+
+                    if (varying-&gt;isStruct())
+                    {
+                        // matrices within structs are not transposed, so
+                        // do not use the special struct prefix &quot;rm&quot;
+                        typeString = decorateVariable(varying-&gt;structName);
+                    }
+                    else
+                    {
+                        GLenum componentType = UniformComponentType(transposedType);
+                        int columnCount = VariableColumnCount(transposedType);
+                        typeString = gl_d3d::HLSLComponentTypeString(componentType, columnCount);
+                    }
+                    varyingHLSL += typeString + &quot; v&quot; + n + &quot; : &quot; + varyingSemantic + n + &quot;;\n&quot;;
+                }
+            }
+
+            if (linkedVaryings)
+            {
+                linkedVaryings-&gt;push_back(LinkedVarying(varying-&gt;name, varying-&gt;type, varying-&gt;elementCount(),
+                                                        varyingSemantic, varying-&gt;registerIndex,
+                                                        variableRows * varying-&gt;elementCount()));
+            }
+        }
+    }
+
+    return varyingHLSL;
+}
+
+std::string DynamicHLSL::generateInputLayoutHLSL(const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const
+{
+    std::string structHLSL, initHLSL;
+
+    int semanticIndex = 0;
+    unsigned int inputIndex = 0;
+
+    for (unsigned int attributeIndex = 0; attributeIndex &lt; MAX_VERTEX_ATTRIBS; attributeIndex++)
+    {
+        ASSERT(inputIndex &lt; MAX_VERTEX_ATTRIBS);
+
+        const VertexFormat &amp;vertexFormat = inputLayout[inputIndex];
+        const Attribute &amp;shaderAttribute = shaderAttributes[attributeIndex];
+
+        if (!shaderAttribute.name.empty())
+        {
+            // HLSL code for input structure
+            if (IsMatrixType(shaderAttribute.type))
+            {
+                // Matrix types are always transposed
+                structHLSL += &quot;    &quot; + gl_d3d::HLSLMatrixTypeString(TransposeMatrixType(shaderAttribute.type));
+            }
+            else
+            {
+                GLenum componentType = mRenderer-&gt;getVertexComponentType(vertexFormat);
+                structHLSL += &quot;    &quot; + gl_d3d::HLSLComponentTypeString(componentType, UniformComponentCount(shaderAttribute.type));
+            }
+
+            structHLSL += &quot; &quot; + decorateVariable(shaderAttribute.name) + &quot; : TEXCOORD&quot; + Str(semanticIndex) + &quot;;\n&quot;;
+            semanticIndex += AttributeRegisterCount(shaderAttribute.type);
+
+            // HLSL code for initialization
+            initHLSL += &quot;    &quot; + decorateVariable(shaderAttribute.name) + &quot; = &quot;;
+
+            // Mismatched vertex attribute to vertex input may result in an undefined
+            // data reinterpretation (eg for pure integer-&gt;float, float-&gt;pure integer)
+            // TODO: issue warning with gl debug info extension, when supported
+            if (IsMatrixType(shaderAttribute.type) ||
+                (mRenderer-&gt;getVertexConversionType(vertexFormat) &amp; rx::VERTEX_CONVERT_GPU) != 0)
+            {
+                initHLSL += generateAttributeConversionHLSL(vertexFormat, shaderAttribute);
+            }
+            else
+            {
+                initHLSL += &quot;input.&quot; + decorateVariable(shaderAttribute.name);
+            }
+
+            initHLSL += &quot;;\n&quot;;
+
+            inputIndex += VariableRowCount(TransposeMatrixType(shaderAttribute.type));
+        }
+    }
+
+    return &quot;struct VS_INPUT\n&quot;
+           &quot;{\n&quot; +
+           structHLSL +
+           &quot;};\n&quot;
+           &quot;\n&quot;
+           &quot;void initAttributes(VS_INPUT input)\n&quot;
+           &quot;{\n&quot; +
+           initHLSL +
+           &quot;}\n&quot;;
+}
+
+bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &amp;infoLog, int registers, const ShaderVariable *packing[][4],
+                                         std::string&amp; pixelHLSL, std::string&amp; vertexHLSL,
+                                         FragmentShader *fragmentShader, VertexShader *vertexShader,
+                                         const std::vector&lt;std::string&gt;&amp; transformFeedbackVaryings,
+                                         std::vector&lt;LinkedVarying&gt; *linkedVaryings,
+                                         std::map&lt;int, VariableLocation&gt; *programOutputVars) const
+{
+    if (pixelHLSL.empty() || vertexHLSL.empty())
+    {
+        return false;
+    }
+
+    bool usesMRT = fragmentShader-&gt;mUsesMultipleRenderTargets;
+    bool usesFragColor = fragmentShader-&gt;mUsesFragColor;
+    bool usesFragData = fragmentShader-&gt;mUsesFragData;
+    if (usesFragColor &amp;&amp; usesFragData)
+    {
+        infoLog.append(&quot;Cannot use both gl_FragColor and gl_FragData in the same fragment shader.&quot;);
+        return false;
+    }
+
+    // Write the HLSL input/output declarations
+    const int shaderModel = mRenderer-&gt;getMajorShaderModel();
+    const int maxVaryingVectors = mRenderer-&gt;getMaxVaryingVectors();
+
+    const int registersNeeded = registers + (fragmentShader-&gt;mUsesFragCoord ? 1 : 0) + (fragmentShader-&gt;mUsesPointCoord ? 1 : 0);
+
+    // Two cases when writing to gl_FragColor and using ESSL 1.0:
+    // - with a 3.0 context, the output color is copied to channel 0
+    // - with a 2.0 context, the output color is broadcast to all channels
+    const bool broadcast = (fragmentShader-&gt;mUsesFragColor &amp;&amp; mRenderer-&gt;getCurrentClientVersion() &lt; 3);
+    const unsigned int numRenderTargets = (broadcast || usesMRT ? mRenderer-&gt;getMaxRenderTargets() : 1);
+
+    int shaderVersion = vertexShader-&gt;getShaderVersion();
+
+    if (registersNeeded &gt; maxVaryingVectors)
+    {
+        infoLog.append(&quot;No varying registers left to support gl_FragCoord/gl_PointCoord&quot;);
+
+        return false;
+    }
+
+    std::string varyingSemantic = (vertexShader-&gt;mUsesPointSize &amp;&amp; shaderModel == 3) ? &quot;COLOR&quot; : &quot;TEXCOORD&quot;;
+    std::string targetSemantic = (shaderModel &gt;= 4) ? &quot;SV_Target&quot; : &quot;COLOR&quot;;
+    std::string dxPositionSemantic = (shaderModel &gt;= 4) ? &quot;SV_Position&quot; : &quot;POSITION&quot;;
+    std::string depthSemantic = (shaderModel &gt;= 4) ? &quot;SV_Depth&quot; : &quot;DEPTH&quot;;
+
+    std::string varyingHLSL = generateVaryingHLSL(vertexShader, varyingSemantic, linkedVaryings);
+
+    // special varyings that use reserved registers
+    int reservedRegisterIndex = registers;
+
+    unsigned int glPositionSemanticIndex = reservedRegisterIndex++;
+    std::string glPositionSemantic = varyingSemantic;
+
+    std::string fragCoordSemantic;
+    unsigned int fragCoordSemanticIndex = 0;
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        fragCoordSemanticIndex = reservedRegisterIndex++;
+        fragCoordSemantic = varyingSemantic;
+    }
+
+    std::string pointCoordSemantic;
+    unsigned int pointCoordSemanticIndex = 0;
+    if (fragmentShader-&gt;mUsesPointCoord)
+    {
+        // Shader model 3 uses a special TEXCOORD semantic for point sprite texcoords.
+        // In DX11 we compute this in the GS.
+        if (shaderModel == 3)
+        {
+            pointCoordSemanticIndex = 0;
+            pointCoordSemantic = &quot;TEXCOORD0&quot;;
+        }
+        else if (shaderModel &gt;= 4)
+        {
+            pointCoordSemanticIndex = reservedRegisterIndex++;
+            pointCoordSemantic = varyingSemantic;
+        }
+    }
+
+    // Add stub string to be replaced when shader is dynamically defined by its layout
+    vertexHLSL += &quot;\n&quot; + VERTEX_ATTRIBUTE_STUB_STRING + &quot;\n&quot;;
+
+    vertexHLSL += &quot;struct VS_OUTPUT\n&quot;
+                  &quot;{\n&quot;;
+
+    if (shaderModel &lt; 4)
+    {
+        vertexHLSL += &quot;    float4 _dx_Position : &quot; + dxPositionSemantic + &quot;;\n&quot;;
+        vertexHLSL += &quot;    float4 gl_Position : &quot; + glPositionSemantic + Str(glPositionSemanticIndex) + &quot;;\n&quot;;
+        linkedVaryings-&gt;push_back(LinkedVarying(&quot;gl_Position&quot;, GL_FLOAT_VEC4, 1, glPositionSemantic, glPositionSemanticIndex, 1));
+
+    }
+
+    vertexHLSL += varyingHLSL;
+
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        vertexHLSL += &quot;    float4 gl_FragCoord : &quot; + fragCoordSemantic + Str(fragCoordSemanticIndex) + &quot;;\n&quot;;
+        linkedVaryings-&gt;push_back(LinkedVarying(&quot;gl_FragCoord&quot;, GL_FLOAT_VEC4, 1, fragCoordSemantic, fragCoordSemanticIndex, 1));
+    }
+
+    if (vertexShader-&gt;mUsesPointSize &amp;&amp; shaderModel &gt;= 3)
+    {
+        vertexHLSL += &quot;    float gl_PointSize : PSIZE;\n&quot;;
+        linkedVaryings-&gt;push_back(LinkedVarying(&quot;gl_PointSize&quot;, GL_FLOAT, 1, &quot;PSIZE&quot;, 0, 1));
+    }
+
+    if (shaderModel &gt;= 4)
+    {
+        vertexHLSL += &quot;    float4 _dx_Position : &quot; + dxPositionSemantic + &quot;;\n&quot;;
+        vertexHLSL += &quot;    float4 gl_Position : &quot; + glPositionSemantic + Str(glPositionSemanticIndex) + &quot;;\n&quot;;
+        linkedVaryings-&gt;push_back(LinkedVarying(&quot;gl_Position&quot;, GL_FLOAT_VEC4, 1, glPositionSemantic, glPositionSemanticIndex, 1));
+    }
+
+    vertexHLSL += &quot;};\n&quot;
+                  &quot;\n&quot;
+                  &quot;VS_OUTPUT main(VS_INPUT input)\n&quot;
+                  &quot;{\n&quot;
+                  &quot;    initAttributes(input);\n&quot;;
+
+    if (shaderModel &gt;= 4)
+    {
+        vertexHLSL += &quot;\n&quot;
+                      &quot;    gl_main();\n&quot;
+                      &quot;\n&quot;
+                      &quot;    VS_OUTPUT output;\n&quot;
+                      &quot;    output.gl_Position = gl_Position;\n&quot;
+                      &quot;    output._dx_Position.x = gl_Position.x;\n&quot;
+                      &quot;    output._dx_Position.y = -gl_Position.y;\n&quot;
+                      &quot;    output._dx_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n&quot;
+                      &quot;    output._dx_Position.w = gl_Position.w;\n&quot;;
+    }
+    else
+    {
+        vertexHLSL += &quot;\n&quot;
+                      &quot;    gl_main();\n&quot;
+                      &quot;\n&quot;
+                      &quot;    VS_OUTPUT output;\n&quot;
+                      &quot;    output.gl_Position = gl_Position;\n&quot;
+                      &quot;    output._dx_Position.x = gl_Position.x * dx_ViewAdjust.z + dx_ViewAdjust.x * gl_Position.w;\n&quot;
+                      &quot;    output._dx_Position.y = -(gl_Position.y * dx_ViewAdjust.w + dx_ViewAdjust.y * gl_Position.w);\n&quot;
+                      &quot;    output._dx_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n&quot;
+                      &quot;    output._dx_Position.w = gl_Position.w;\n&quot;;
+    }
+
+    if (vertexShader-&gt;mUsesPointSize &amp;&amp; shaderModel &gt;= 3)
+    {
+        vertexHLSL += &quot;    output.gl_PointSize = gl_PointSize;\n&quot;;
+    }
+
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        vertexHLSL += &quot;    output.gl_FragCoord = gl_Position;\n&quot;;
+    }
+
+    for (unsigned int vertVaryingIndex = 0; vertVaryingIndex &lt; vertexShader-&gt;mVaryings.size(); vertVaryingIndex++)
+    {
+        Varying *varying = &amp;vertexShader-&gt;mVaryings[vertVaryingIndex];
+        if (varying-&gt;registerAssigned())
+        {
+            for (unsigned int elementIndex = 0; elementIndex &lt; varying-&gt;elementCount(); elementIndex++)
+            {
+                int variableRows = (varying-&gt;isStruct() ? 1 : VariableRowCount(TransposeMatrixType(varying-&gt;type)));
+
+                for (int row = 0; row &lt; variableRows; row++)
+                {
+                    int r = varying-&gt;registerIndex + elementIndex * variableRows + row;
+                    vertexHLSL += &quot;    output.v&quot; + Str(r);
+
+                    bool sharedRegister = false;   // Register used by multiple varyings
+
+                    for (int x = 0; x &lt; 4; x++)
+                    {
+                        if (packing[r][x] &amp;&amp; packing[r][x] != packing[r][0])
+                        {
+                            sharedRegister = true;
+                            break;
+                        }
+                    }
+
+                    if(sharedRegister)
+                    {
+                        vertexHLSL += &quot;.&quot;;
+
+                        for (int x = 0; x &lt; 4; x++)
+                        {
+                            if (packing[r][x] == &amp;*varying)
+                            {
+                                switch(x)
+                                {
+                                  case 0: vertexHLSL += &quot;x&quot;; break;
+                                  case 1: vertexHLSL += &quot;y&quot;; break;
+                                  case 2: vertexHLSL += &quot;z&quot;; break;
+                                  case 3: vertexHLSL += &quot;w&quot;; break;
+                                }
+                            }
+                        }
+                    }
+
+                    vertexHLSL += &quot; = _&quot; + varying-&gt;name;
+
+                    if (varying-&gt;isArray())
+                    {
+                        vertexHLSL += ArrayString(elementIndex);
+                    }
+
+                    if (variableRows &gt; 1)
+                    {
+                        vertexHLSL += ArrayString(row);
+                    }
+
+                    vertexHLSL += &quot;;\n&quot;;
+                }
+            }
+        }
+    }
+
+    vertexHLSL += &quot;\n&quot;
+                  &quot;    return output;\n&quot;
+                  &quot;}\n&quot;;
+
+    pixelHLSL += &quot;struct PS_INPUT\n&quot;
+                 &quot;{\n&quot;;
+
+    pixelHLSL += varyingHLSL;
+
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        pixelHLSL += &quot;    float4 gl_FragCoord : &quot; + fragCoordSemantic + Str(fragCoordSemanticIndex) + &quot;;\n&quot;;
+    }
+
+    if (fragmentShader-&gt;mUsesPointCoord &amp;&amp; shaderModel &gt;= 3)
+    {
+        pixelHLSL += &quot;    float2 gl_PointCoord : &quot; + pointCoordSemantic + Str(pointCoordSemanticIndex) + &quot;;\n&quot;;
+    }
+
+    // Must consume the PSIZE element if the geometry shader is not active
+    // We won't know if we use a GS until we draw
+    if (vertexShader-&gt;mUsesPointSize &amp;&amp; shaderModel &gt;= 4)
+    {
+        pixelHLSL += &quot;    float gl_PointSize : PSIZE;\n&quot;;
+    }
+
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        if (shaderModel &gt;= 4)
+        {
+            pixelHLSL += &quot;    float4 dx_VPos : SV_Position;\n&quot;;
+        }
+        else if (shaderModel &gt;= 3)
+        {
+            pixelHLSL += &quot;    float2 dx_VPos : VPOS;\n&quot;;
+        }
+    }
+
+    pixelHLSL += &quot;};\n&quot;
+                 &quot;\n&quot;
+                 &quot;struct PS_OUTPUT\n&quot;
+                 &quot;{\n&quot;;
+
+    if (shaderVersion &lt; 300)
+    {
+        for (unsigned int renderTargetIndex = 0; renderTargetIndex &lt; numRenderTargets; renderTargetIndex++)
+        {
+            pixelHLSL += &quot;    float4 gl_Color&quot; + Str(renderTargetIndex) + &quot; : &quot; + targetSemantic + Str(renderTargetIndex) + &quot;;\n&quot;;
+        }
+
+        if (fragmentShader-&gt;mUsesFragDepth)
+        {
+            pixelHLSL += &quot;    float gl_Depth : &quot; + depthSemantic + &quot;;\n&quot;;
+        }
+    }
+    else
+    {
+        defineOutputVariables(fragmentShader, programOutputVars);
+
+        const std::vector&lt;Attribute&gt; &amp;shaderOutputVars = fragmentShader-&gt;getOutputVariables();
+        for (auto locationIt = programOutputVars-&gt;begin(); locationIt != programOutputVars-&gt;end(); locationIt++)
+        {
+            const VariableLocation &amp;outputLocation = locationIt-&gt;second;
+            const ShaderVariable &amp;outputVariable = shaderOutputVars[outputLocation.index];
+            const std::string &amp;elementString = (outputLocation.element == GL_INVALID_INDEX ? &quot;&quot; : Str(outputLocation.element));
+
+            pixelHLSL += &quot;    &quot; + gl_d3d::HLSLTypeString(outputVariable.type) +
+                         &quot; out_&quot; + outputLocation.name + elementString +
+                         &quot; : &quot; + targetSemantic + Str(locationIt-&gt;first) + &quot;;\n&quot;;
+        }
+    }
+
+    pixelHLSL += &quot;};\n&quot;
+                 &quot;\n&quot;;
+
+    if (fragmentShader-&gt;mUsesFrontFacing)
+    {
+        if (shaderModel &gt;= 4)
+        {
+            pixelHLSL += &quot;PS_OUTPUT main(PS_INPUT input, bool isFrontFace : SV_IsFrontFace)\n&quot;
+                         &quot;{\n&quot;;
+        }
+        else
+        {
+            pixelHLSL += &quot;PS_OUTPUT main(PS_INPUT input, float vFace : VFACE)\n&quot;
+                         &quot;{\n&quot;;
+        }
+    }
+    else
+    {
+        pixelHLSL += &quot;PS_OUTPUT main(PS_INPUT input)\n&quot;
+                     &quot;{\n&quot;;
+    }
+
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        pixelHLSL += &quot;    float rhw = 1.0 / input.gl_FragCoord.w;\n&quot;;
+
+        if (shaderModel &gt;= 4)
+        {
+            pixelHLSL += &quot;    gl_FragCoord.x = input.dx_VPos.x;\n&quot;
+                         &quot;    gl_FragCoord.y = input.dx_VPos.y;\n&quot;;
+        }
+        else if (shaderModel &gt;= 3)
+        {
+            pixelHLSL += &quot;    gl_FragCoord.x = input.dx_VPos.x + 0.5;\n&quot;
+                         &quot;    gl_FragCoord.y = input.dx_VPos.y + 0.5;\n&quot;;
+        }
+        else
+        {
+            // dx_ViewCoords contains the viewport width/2, height/2, center.x and center.y. See Renderer::setViewport()
+            pixelHLSL += &quot;    gl_FragCoord.x = (input.gl_FragCoord.x * rhw) * dx_ViewCoords.x + dx_ViewCoords.z;\n&quot;
+                         &quot;    gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * dx_ViewCoords.y + dx_ViewCoords.w;\n&quot;;
+        }
+
+        pixelHLSL += &quot;    gl_FragCoord.z = (input.gl_FragCoord.z * rhw) * dx_DepthFront.x + dx_DepthFront.y;\n&quot;
+                     &quot;    gl_FragCoord.w = rhw;\n&quot;;
+    }
+
+    if (fragmentShader-&gt;mUsesPointCoord &amp;&amp; shaderModel &gt;= 3)
+    {
+        pixelHLSL += &quot;    gl_PointCoord.x = input.gl_PointCoord.x;\n&quot;;
+        pixelHLSL += &quot;    gl_PointCoord.y = 1.0 - input.gl_PointCoord.y;\n&quot;;
+    }
+
+    if (fragmentShader-&gt;mUsesFrontFacing)
+    {
+        if (shaderModel &lt;= 3)
+        {
+            pixelHLSL += &quot;    gl_FrontFacing = (vFace * dx_DepthFront.z &gt;= 0.0);\n&quot;;
+        }
+        else
+        {
+            pixelHLSL += &quot;    gl_FrontFacing = isFrontFace;\n&quot;;
+        }
+    }
+
+    for (unsigned int varyingIndex = 0; varyingIndex &lt; fragmentShader-&gt;mVaryings.size(); varyingIndex++)
+    {
+        Varying *varying = &amp;fragmentShader-&gt;mVaryings[varyingIndex];
+        if (varying-&gt;registerAssigned())
+        {
+            for (unsigned int elementIndex = 0; elementIndex &lt; varying-&gt;elementCount(); elementIndex++)
+            {
+                GLenum transposedType = TransposeMatrixType(varying-&gt;type);
+                int variableRows = (varying-&gt;isStruct() ? 1 : VariableRowCount(transposedType));
+                for (int row = 0; row &lt; variableRows; row++)
+                {
+                    std::string n = Str(varying-&gt;registerIndex + elementIndex * variableRows + row);
+                    pixelHLSL += &quot;    _&quot; + varying-&gt;name;
+
+                    if (varying-&gt;isArray())
+                    {
+                        pixelHLSL += ArrayString(elementIndex);
+                    }
+
+                    if (variableRows &gt; 1)
+                    {
+                        pixelHLSL += ArrayString(row);
+                    }
+
+                    if (varying-&gt;isStruct())
+                    {
+                        pixelHLSL += &quot; = input.v&quot; + n + &quot;;\n&quot;;   break;
+                    }
+                    else
+                    {
+                        switch (VariableColumnCount(transposedType))
+                        {
+                          case 1: pixelHLSL += &quot; = input.v&quot; + n + &quot;.x;\n&quot;;   break;
+                          case 2: pixelHLSL += &quot; = input.v&quot; + n + &quot;.xy;\n&quot;;  break;
+                          case 3: pixelHLSL += &quot; = input.v&quot; + n + &quot;.xyz;\n&quot;; break;
+                          case 4: pixelHLSL += &quot; = input.v&quot; + n + &quot;;\n&quot;;     break;
+                          default: UNREACHABLE();
+                        }
+                    }
+                }
+            }
+        }
+        else UNREACHABLE();
+    }
+
+    pixelHLSL += &quot;\n&quot;
+                 &quot;    gl_main();\n&quot;
+                 &quot;\n&quot;
+                 &quot;    PS_OUTPUT output;\n&quot;;
+
+    if (shaderVersion &lt; 300)
+    {
+        for (unsigned int renderTargetIndex = 0; renderTargetIndex &lt; numRenderTargets; renderTargetIndex++)
+        {
+            unsigned int sourceColorIndex = broadcast ? 0 : renderTargetIndex;
+
+            pixelHLSL += &quot;    output.gl_Color&quot; + Str(renderTargetIndex) + &quot; = gl_Color[&quot; + Str(sourceColorIndex) + &quot;];\n&quot;;
+        }
+
+        if (fragmentShader-&gt;mUsesFragDepth)
+        {
+            pixelHLSL += &quot;    output.gl_Depth = gl_Depth;\n&quot;;
+        }
+    }
+    else
+    {
+        for (auto locationIt = programOutputVars-&gt;begin(); locationIt != programOutputVars-&gt;end(); locationIt++)
+        {
+            const VariableLocation &amp;outputLocation = locationIt-&gt;second;
+            const std::string &amp;variableName = &quot;out_&quot; + outputLocation.name;
+            const std::string &amp;outVariableName = variableName + (outputLocation.element == GL_INVALID_INDEX ? &quot;&quot; : Str(outputLocation.element));
+            const std::string &amp;staticVariableName = variableName + ArrayString(outputLocation.element);
+
+            pixelHLSL += &quot;    output.&quot; + outVariableName + &quot; = &quot; + staticVariableName + &quot;;\n&quot;;
+        }
+    }
+
+    pixelHLSL += &quot;\n&quot;
+                 &quot;    return output;\n&quot;
+                 &quot;}\n&quot;;
+
+    return true;
+}
+
+void DynamicHLSL::defineOutputVariables(FragmentShader *fragmentShader, std::map&lt;int, VariableLocation&gt; *programOutputVars) const
+{
+    const std::vector&lt;Attribute&gt; &amp;shaderOutputVars = fragmentShader-&gt;getOutputVariables();
+
+    for (unsigned int outputVariableIndex = 0; outputVariableIndex &lt; shaderOutputVars.size(); outputVariableIndex++)
+    {
+        const Attribute &amp;outputVariable = shaderOutputVars[outputVariableIndex];
+        const int baseLocation = outputVariable.location == -1 ? 0 : outputVariable.location;
+
+        if (outputVariable.arraySize &gt; 0)
+        {
+            for (unsigned int elementIndex = 0; elementIndex &lt; outputVariable.arraySize; elementIndex++)
+            {
+                const int location = baseLocation + elementIndex;
+                ASSERT(programOutputVars-&gt;count(location) == 0);
+                (*programOutputVars)[location] = VariableLocation(outputVariable.name, elementIndex, outputVariableIndex);
+            }
+        }
+        else
+        {
+            ASSERT(programOutputVars-&gt;count(baseLocation) == 0);
+            (*programOutputVars)[baseLocation] = VariableLocation(outputVariable.name, GL_INVALID_INDEX, outputVariableIndex);
+        }
+    }
+}
+
+std::string DynamicHLSL::generateGeometryShaderHLSL(int registers, const ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
+{
+    // for now we only handle point sprite emulation
+    ASSERT(vertexShader-&gt;mUsesPointSize &amp;&amp; mRenderer-&gt;getMajorShaderModel() &gt;= 4);
+    return generatePointSpriteHLSL(registers, packing, fragmentShader, vertexShader);
+}
+
+std::string DynamicHLSL::generatePointSpriteHLSL(int registers, const ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
+{
+    ASSERT(registers &gt;= 0);
+    ASSERT(vertexShader-&gt;mUsesPointSize);
+    ASSERT(mRenderer-&gt;getMajorShaderModel() &gt;= 4);
+
+    std::string geomHLSL;
+
+    std::string varyingSemantic = &quot;TEXCOORD&quot;;
+
+    std::string fragCoordSemantic;
+    std::string pointCoordSemantic;
+
+    int reservedRegisterIndex = registers;
+
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        fragCoordSemantic = varyingSemantic + Str(reservedRegisterIndex++);
+    }
+
+    if (fragmentShader-&gt;mUsesPointCoord)
+    {
+        pointCoordSemantic = varyingSemantic + Str(reservedRegisterIndex++);
+    }
+
+    geomHLSL += &quot;uniform float4 dx_ViewCoords : register(c1);\n&quot;
+                &quot;\n&quot;
+                &quot;struct GS_INPUT\n&quot;
+                &quot;{\n&quot;;
+
+    std::string varyingHLSL = generateVaryingHLSL(vertexShader, varyingSemantic, NULL);
+
+    geomHLSL += varyingHLSL;
+
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        geomHLSL += &quot;    float4 gl_FragCoord : &quot; + fragCoordSemantic + &quot;;\n&quot;;
+    }
+
+    geomHLSL += &quot;    float gl_PointSize : PSIZE;\n&quot;
+                &quot;    float4 gl_Position : SV_Position;\n&quot;
+                &quot;};\n&quot;
+                &quot;\n&quot;
+                &quot;struct GS_OUTPUT\n&quot;
+                &quot;{\n&quot;;
+
+    geomHLSL += varyingHLSL;
+
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        geomHLSL += &quot;    float4 gl_FragCoord : &quot; + fragCoordSemantic + &quot;;\n&quot;;
+    }
+
+    if (fragmentShader-&gt;mUsesPointCoord)
+    {
+        geomHLSL += &quot;    float2 gl_PointCoord : &quot; + pointCoordSemantic + &quot;;\n&quot;;
+    }
+
+    geomHLSL +=   &quot;    float gl_PointSize : PSIZE;\n&quot;
+                  &quot;    float4 gl_Position : SV_Position;\n&quot;
+                  &quot;};\n&quot;
+                  &quot;\n&quot;
+                  &quot;static float2 pointSpriteCorners[] = \n&quot;
+                  &quot;{\n&quot;
+                  &quot;    float2( 0.5f, -0.5f),\n&quot;
+                  &quot;    float2( 0.5f,  0.5f),\n&quot;
+                  &quot;    float2(-0.5f, -0.5f),\n&quot;
+                  &quot;    float2(-0.5f,  0.5f)\n&quot;
+                  &quot;};\n&quot;
+                  &quot;\n&quot;
+                  &quot;static float2 pointSpriteTexcoords[] = \n&quot;
+                  &quot;{\n&quot;
+                  &quot;    float2(1.0f, 1.0f),\n&quot;
+                  &quot;    float2(1.0f, 0.0f),\n&quot;
+                  &quot;    float2(0.0f, 1.0f),\n&quot;
+                  &quot;    float2(0.0f, 0.0f)\n&quot;
+                  &quot;};\n&quot;
+                  &quot;\n&quot;
+                  &quot;static float minPointSize = &quot; + Str(ALIASED_POINT_SIZE_RANGE_MIN) + &quot;.0f;\n&quot;
+                  &quot;static float maxPointSize = &quot; + Str(mRenderer-&gt;getMaxPointSize()) + &quot;.0f;\n&quot;
+                  &quot;\n&quot;
+                  &quot;[maxvertexcount(4)]\n&quot;
+                  &quot;void main(point GS_INPUT input[1], inout TriangleStream&lt;GS_OUTPUT&gt; outStream)\n&quot;
+                  &quot;{\n&quot;
+                  &quot;    GS_OUTPUT output = (GS_OUTPUT)0;\n&quot;
+                  &quot;    output.gl_PointSize = input[0].gl_PointSize;\n&quot;;
+
+    for (int r = 0; r &lt; registers; r++)
+    {
+        geomHLSL += &quot;    output.v&quot; + Str(r) + &quot; = input[0].v&quot; + Str(r) + &quot;;\n&quot;;
+    }
+
+    if (fragmentShader-&gt;mUsesFragCoord)
+    {
+        geomHLSL += &quot;    output.gl_FragCoord = input[0].gl_FragCoord;\n&quot;;
+    }
+
+    geomHLSL += &quot;    \n&quot;
+                &quot;    float gl_PointSize = clamp(input[0].gl_PointSize, minPointSize, maxPointSize);\n&quot;
+                &quot;    float4 gl_Position = input[0].gl_Position;\n&quot;
+                &quot;    float2 viewportScale = float2(1.0f / dx_ViewCoords.x, 1.0f / dx_ViewCoords.y) * gl_Position.w;\n&quot;;
+
+    for (int corner = 0; corner &lt; 4; corner++)
+    {
+        geomHLSL += &quot;    \n&quot;
+                    &quot;    output.gl_Position = gl_Position + float4(pointSpriteCorners[&quot; + Str(corner) + &quot;] * viewportScale * gl_PointSize, 0.0f, 0.0f);\n&quot;;
+
+        if (fragmentShader-&gt;mUsesPointCoord)
+        {
+            geomHLSL += &quot;    output.gl_PointCoord = pointSpriteTexcoords[&quot; + Str(corner) + &quot;];\n&quot;;
+        }
+
+        geomHLSL += &quot;    outStream.Append(output);\n&quot;;
+    }
+
+    geomHLSL += &quot;    \n&quot;
+                &quot;    outStream.RestartStrip();\n&quot;
+                &quot;}\n&quot;;
+
+    return geomHLSL;
+}
+
+// This method needs to match OutputHLSL::decorate
+std::string DynamicHLSL::decorateVariable(const std::string &amp;name)
+{
+    if (name.compare(0, 3, &quot;gl_&quot;) != 0 &amp;&amp; name.compare(0, 3, &quot;dx_&quot;) != 0)
+    {
+        return &quot;_&quot; + name;
+    }
+
+    return name;
+}
+
+std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &amp;vertexFormat, const ShaderVariable &amp;shaderAttrib) const
+{
+    std::string attribString = &quot;input.&quot; + decorateVariable(shaderAttrib.name);
+
+    // Matrix
+    if (IsMatrixType(shaderAttrib.type))
+    {
+        return &quot;transpose(&quot; + attribString + &quot;)&quot;;
+    }
+
+    GLenum shaderComponentType = UniformComponentType(shaderAttrib.type);
+    int shaderComponentCount = UniformComponentCount(shaderAttrib.type);
+
+    std::string padString = &quot;&quot;;
+
+    // Perform integer to float conversion (if necessary)
+    bool requiresTypeConversion = (shaderComponentType == GL_FLOAT &amp;&amp; vertexFormat.mType != GL_FLOAT);
+
+    // TODO: normalization for 32-bit integer formats
+    ASSERT(!requiresTypeConversion || !vertexFormat.mNormalized);
+
+    if (requiresTypeConversion || !padString.empty())
+    {
+        return &quot;float&quot; + Str(shaderComponentCount) + &quot;(&quot; + attribString + padString + &quot;)&quot;;
+    }
+
+    // No conversion necessary
+    return attribString;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2DynamicHLSLh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/DynamicHLSL.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/DynamicHLSL.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/DynamicHLSL.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,72 @@
</span><ins>+//
+// Copyright (c) 2014 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.
+//
+// DynamicHLSL.h: Interface for link and run-time HLSL generation
+//
+
+#ifndef LIBGLESV2_DYNAMIC_HLSL_H_
+#define LIBGLESV2_DYNAMIC_HLSL_H_
+
+#include &quot;common/angleutils.h&quot;
+
+namespace rx
+{
+class Renderer;
+}
+
+namespace gl
+{
+
+class InfoLog;
+class FragmentShader;
+class VertexShader;
+struct VariableLocation;
+struct LinkedVarying;
+class VertexAttribute;
+struct VertexFormat;
+struct ShaderVariable;
+struct Attribute;
+
+class DynamicHLSL
+{
+  public:
+    explicit DynamicHLSL(rx::Renderer *const renderer);
+
+    int packVaryings(InfoLog &amp;infoLog, const ShaderVariable *packing[][4], FragmentShader *fragmentShader,
+                     VertexShader *vertexShader, const std::vector&lt;std::string&gt;&amp; transformFeedbackVaryings);
+    std::string generateInputLayoutHLSL(const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const;
+    bool generateShaderLinkHLSL(InfoLog &amp;infoLog, int registers, const ShaderVariable *packing[][4],
+                                std::string&amp; pixelHLSL, std::string&amp; vertexHLSL,
+                                FragmentShader *fragmentShader, VertexShader *vertexShader,
+                                const std::vector&lt;std::string&gt;&amp; transformFeedbackVaryings,
+                                std::vector&lt;LinkedVarying&gt; *linkedVaryings,
+                                std::map&lt;int, VariableLocation&gt; *programOutputVars) const;
+
+    std::string generateGeometryShaderHLSL(int registers, const ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
+
+    static const std::string VERTEX_ATTRIBUTE_STUB_STRING;
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(DynamicHLSL);
+
+    rx::Renderer *const mRenderer;
+
+    std::string generateVaryingHLSL(VertexShader *shader, const std::string &amp;varyingSemantic,
+                                    std::vector&lt;LinkedVarying&gt; *linkedVaryings) const;
+    void defineOutputVariables(FragmentShader *fragmentShader, std::map&lt;int, VariableLocation&gt; *programOutputVars) const;
+    std::string generatePointSpriteHLSL(int registers, const ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
+
+    // Prepend an underscore
+    static std::string decorateVariable(const std::string &amp;name);
+
+    std::string generateAttributeConversionHLSL(const VertexFormat &amp;vertexFormat, const ShaderVariable &amp;shaderAttrib) const;
+};
+
+// Utility method shared between ProgramBinary and DynamicHLSL
+std::string ArrayString(unsigned int i);
+
+}
+
+#endif // LIBGLESV2_DYNAMIC_HLSL_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Fencecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -7,46 +7,184 @@
</span><span class="cx"> 
</span><span class="cx"> // Fence.cpp: Implements the gl::Fence class, which supports the GL_NV_fence extension.
</span><span class="cx"> 
</span><ins>+// Important note on accurate timers in Windows:
+//
+// QueryPerformanceCounter has a few major issues, including being 10x as expensive to call
+// as timeGetTime on laptops and &quot;jumping&quot; during certain hardware events.
+//
+// See the comments at the top of the Chromium source file &quot;chromium/src/base/time/time_win.cc&quot;
+//   https://code.google.com/p/chromium/codesearch#chromium/src/base/time/time_win.cc
+//
+// We still opt to use QPC. In the present and moving forward, most newer systems will not suffer
+// from buggy implementations.
+
</ins><span class="cx"> #include &quot;libGLESv2/Fence.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/FenceImpl.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><ins>+#include &quot;libGLESv2/main.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-Fence::Fence(rx::Renderer *renderer)
</del><ins>+FenceNV::FenceNV(rx::Renderer *renderer)
</ins><span class="cx"> {
</span><span class="cx">     mFence = renderer-&gt;createFence();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Fence::~Fence()
</del><ins>+FenceNV::~FenceNV()
</ins><span class="cx"> {
</span><span class="cx">     delete mFence;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLboolean Fence::isFence()
</del><ins>+GLboolean FenceNV::isFence() const
</ins><span class="cx"> {
</span><del>-    return mFence-&gt;isFence();
</del><ins>+    // GL_NV_fence spec:
+    // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence.
+    return (mFence-&gt;isSet() ? GL_TRUE : GL_FALSE);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Fence::setFence(GLenum condition)
</del><ins>+void FenceNV::setFence(GLenum condition)
</ins><span class="cx"> {
</span><del>-    mFence-&gt;setFence(condition);
</del><ins>+    mFence-&gt;set();
+
+    mCondition = condition;
+    mStatus = GL_FALSE;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLboolean Fence::testFence()
</del><ins>+GLboolean FenceNV::testFence()
</ins><span class="cx"> {
</span><del>-    return mFence-&gt;testFence();
</del><ins>+    // Flush the command buffer by default
+    bool result = mFence-&gt;test(true);
+
+    mStatus = (result ? GL_TRUE : GL_FALSE);
+    return mStatus;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Fence::finishFence()
</del><ins>+void FenceNV::finishFence()
</ins><span class="cx"> {
</span><del>-    mFence-&gt;finishFence();
</del><ins>+    ASSERT(mFence-&gt;isSet());
+
+    while (!mFence-&gt;test(true))
+    {
+        Sleep(0);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Fence::getFenceiv(GLenum pname, GLint *params)
</del><ins>+GLint FenceNV::getFencei(GLenum pname)
</ins><span class="cx"> {
</span><del>-    mFence-&gt;getFenceiv(pname, params);
</del><ins>+    ASSERT(mFence-&gt;isSet());
+
+    switch (pname)
+    {
+      case GL_FENCE_STATUS_NV:
+        {
+            // GL_NV_fence spec:
+            // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
+            // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
+            if (mStatus == GL_TRUE)
+            {
+                return GL_TRUE;
+            }
+
+            mStatus = (mFence-&gt;test(false) ? GL_TRUE : GL_FALSE);
+            return mStatus;
+        }
+
+      case GL_FENCE_CONDITION_NV:
+        return mCondition;
+
+      default: UNREACHABLE(); return 0;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+FenceSync::FenceSync(rx::Renderer *renderer, GLuint id)
+    : RefCountObject(id)
+{
+    mFence = renderer-&gt;createFence();
+
+    LARGE_INTEGER counterFreqency = { 0 };
+    BOOL success = QueryPerformanceFrequency(&amp;counterFreqency);
+    ASSERT(success);
+
+    mCounterFrequency = counterFreqency.QuadPart;
</ins><span class="cx"> }
</span><ins>+
+FenceSync::~FenceSync()
+{
+    delete mFence;
+}
+
+void FenceSync::set(GLenum condition)
+{
+    mCondition = condition;
+    mFence-&gt;set();
+}
+
+GLenum FenceSync::clientWait(GLbitfield flags, GLuint64 timeout)
+{
+    ASSERT(mFence-&gt;isSet());
+
+    bool flushCommandBuffer = ((flags &amp; GL_SYNC_FLUSH_COMMANDS_BIT) != 0);
+
+    if (mFence-&gt;test(flushCommandBuffer))
+    {
+        return GL_ALREADY_SIGNALED;
+    }
+
+    if (mFence-&gt;hasError())
+    {
+        return GL_WAIT_FAILED;
+    }
+
+    if (timeout == 0)
+    {
+        return GL_TIMEOUT_EXPIRED;
+    }
+
+    LARGE_INTEGER currentCounter = { 0 };
+    BOOL success = QueryPerformanceCounter(&amp;currentCounter);
+    ASSERT(success);
+
+    LONGLONG timeoutInSeconds = static_cast&lt;LONGLONG&gt;(timeout) * static_cast&lt;LONGLONG&gt;(1000000ll);
+    LONGLONG endCounter = currentCounter.QuadPart + mCounterFrequency * timeoutInSeconds;
+
+    while (currentCounter.QuadPart &lt; endCounter &amp;&amp; !mFence-&gt;test(flushCommandBuffer))
+    {
+        Sleep(0);
+        BOOL success = QueryPerformanceCounter(&amp;currentCounter);
+        ASSERT(success);
+    }
+
+    if (mFence-&gt;hasError())
+    {
+        return GL_WAIT_FAILED;
+    }
+
+    if (currentCounter.QuadPart &gt;= endCounter)
+    {
+        return GL_TIMEOUT_EXPIRED;
+    }
+
+    return GL_CONDITION_SATISFIED;
+}
+
+void FenceSync::serverWait()
+{
+    // Because our API is currently designed to be called from a single thread, we don't need to do
+    // extra work for a server-side fence. GPU commands issued after the fence is created will always
+    // be processed after the fence is signaled.
+}
+
+GLenum FenceSync::getStatus() const
+{
+    if (mFence-&gt;test(false))
+    {
+        // The spec does not specify any way to report errors during the status test (e.g. device lost)
+        // so we report the fence is unblocked in case of error or signaled.
+        return GL_SIGNALED;
+    }
+
+    return GL_UNSIGNALED;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Fenceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -10,6 +10,7 @@
</span><span class="cx"> #define LIBGLESV2_FENCE_H_
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><ins>+#include &quot;common/RefCountObject.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -20,24 +21,52 @@
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-class Fence
</del><ins>+class FenceNV
</ins><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    explicit Fence(rx::Renderer *renderer);
-    virtual ~Fence();
</del><ins>+    explicit FenceNV(rx::Renderer *renderer);
+    virtual ~FenceNV();
</ins><span class="cx"> 
</span><del>-    GLboolean isFence();
</del><ins>+    GLboolean isFence() const;
</ins><span class="cx">     void setFence(GLenum condition);
</span><span class="cx">     GLboolean testFence();
</span><span class="cx">     void finishFence();
</span><del>-    void getFenceiv(GLenum pname, GLint *params);
</del><ins>+    GLint getFencei(GLenum pname);
</ins><span class="cx"> 
</span><ins>+    GLboolean getStatus() const { return mStatus; }
+    GLuint getCondition() const { return mCondition; }
+
</ins><span class="cx">   private:
</span><del>-    DISALLOW_COPY_AND_ASSIGN(Fence);
</del><ins>+    DISALLOW_COPY_AND_ASSIGN(FenceNV);
</ins><span class="cx"> 
</span><span class="cx">     rx::FenceImpl *mFence;
</span><ins>+
+    GLboolean mStatus;
+    GLenum mCondition;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class FenceSync : public RefCountObject
+{
+  public:
+    explicit FenceSync(rx::Renderer *renderer, GLuint id);
+    virtual ~FenceSync();
+
+    void set(GLenum condition);
+    GLenum clientWait(GLbitfield flags, GLuint64 timeout);
+    void serverWait();
+    GLenum getStatus() const;
+
+    GLuint getCondition() const { return mCondition; }
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(FenceSync);
+
+    rx::FenceImpl *mFence;
+    LONGLONG mCounterFrequency;
+
+    GLenum mCondition;
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif   // LIBGLESV2_FENCE_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Framebuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -11,7 +11,8 @@
</span><span class="cx"> #include &quot;libGLESv2/Framebuffer.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;common/utilities.h&quot;
+#include &quot;libGLESv2/formatutils.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/Texture.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Context.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><span class="lines">@@ -25,91 +26,171 @@
</span><span class="cx"> {
</span><span class="cx">     for (unsigned int colorAttachment = 0; colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
</span><span class="cx">     {
</span><del>-        mColorbufferTypes[colorAttachment] = GL_NONE;
</del><span class="cx">         mDrawBufferStates[colorAttachment] = GL_NONE;
</span><span class="cx">     }
</span><span class="cx">     mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
</span><span class="cx">     mReadBufferState = GL_COLOR_ATTACHMENT0_EXT;
</span><del>-
-    mDepthbufferType = GL_NONE;
-    mStencilbufferType = GL_NONE;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Framebuffer::~Framebuffer()
</span><span class="cx"> {
</span><span class="cx">     for (unsigned int colorAttachment = 0; colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
</span><span class="cx">     {
</span><del>-        mColorbufferPointers[colorAttachment].set(NULL);
</del><ins>+        mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0);
</ins><span class="cx">     }
</span><del>-    mDepthbufferPointer.set(NULL);
-    mStencilbufferPointer.set(NULL);
</del><ins>+    mDepthbuffer.set(NULL, GL_NONE, 0, 0);
+    mStencilbuffer.set(NULL, GL_NONE, 0, 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle) const
</del><ins>+Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle, GLint level, GLint layer) const
</ins><span class="cx"> {
</span><span class="cx">     gl::Context *context = gl::getContext();
</span><del>-    Renderbuffer *buffer = NULL;
</del><span class="cx"> 
</span><del>-    if (type == GL_NONE)
</del><ins>+    switch (type)
</ins><span class="cx">     {
</span><del>-        buffer = NULL;
</del><ins>+      case GL_NONE:
+        return NULL;
+
+      case GL_RENDERBUFFER:
+        return context-&gt;getRenderbuffer(handle);
+
+      case GL_TEXTURE_2D:
+        {
+            Texture *texture = context-&gt;getTexture(handle);
+            if (texture &amp;&amp; texture-&gt;getTarget() == GL_TEXTURE_2D)
+            {
+                return static_cast&lt;Texture2D*&gt;(texture)-&gt;getRenderbuffer(level);
+            }
+            else
+            {
+                return NULL;
+            }
+        }
+
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+        {
+            Texture *texture = context-&gt;getTexture(handle);
+            if (texture &amp;&amp; texture-&gt;getTarget() == GL_TEXTURE_CUBE_MAP)
+            {
+                return static_cast&lt;TextureCubeMap*&gt;(texture)-&gt;getRenderbuffer(type, level);
+            }
+            else
+            {
+                return NULL;
+            }
+        }
+
+      case GL_TEXTURE_3D:
+        {
+            Texture *texture = context-&gt;getTexture(handle);
+            if (texture &amp;&amp; texture-&gt;getTarget() == GL_TEXTURE_3D)
+            {
+                return static_cast&lt;Texture3D*&gt;(texture)-&gt;getRenderbuffer(level, layer);
+            }
+            else
+            {
+                return NULL;
+            }
+        }
+
+      case GL_TEXTURE_2D_ARRAY:
+        {
+            Texture *texture = context-&gt;getTexture(handle);
+            if (texture &amp;&amp; texture-&gt;getTarget() == GL_TEXTURE_2D_ARRAY)
+            {
+                return static_cast&lt;Texture2DArray*&gt;(texture)-&gt;getRenderbuffer(level, layer);
+            }
+            else
+            {
+                return NULL;
+            }
+        }
+
+      default:
+        UNREACHABLE();
+        return NULL;
</ins><span class="cx">     }
</span><del>-    else if (type == GL_RENDERBUFFER)
</del><ins>+}
+
+void Framebuffer::setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer)
+{
+    ASSERT(colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS);
+    Renderbuffer *renderBuffer = lookupRenderbuffer(type, colorbuffer, level, layer);
+    if (renderBuffer)
</ins><span class="cx">     {
</span><del>-        buffer = context-&gt;getRenderbuffer(handle);
</del><ins>+        mColorbuffers[colorAttachment].set(renderBuffer, type, level, layer);
</ins><span class="cx">     }
</span><del>-    else if (IsInternalTextureTarget(type))
-    {
-        buffer = context-&gt;getTexture(handle)-&gt;getRenderbuffer(type);
-    }
</del><span class="cx">     else
</span><span class="cx">     {
</span><del>-        UNREACHABLE();
</del><ins>+        mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0);
</ins><span class="cx">     }
</span><del>-
-    return buffer;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Framebuffer::setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer)
</del><ins>+void Framebuffer::setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer)
</ins><span class="cx"> {
</span><del>-    ASSERT(colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS);
-    mColorbufferTypes[colorAttachment] = (colorbuffer != 0) ? type : GL_NONE;
-    mColorbufferPointers[colorAttachment].set(lookupRenderbuffer(type, colorbuffer));
</del><ins>+    Renderbuffer *renderBuffer = lookupRenderbuffer(type, depthbuffer, level, layer);
+    if (renderBuffer)
+    {
+        mDepthbuffer.set(renderBuffer, type, level, layer);
+    }
+    else
+    {
+        mDepthbuffer.set(NULL, GL_NONE, 0, 0);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Framebuffer::setDepthbuffer(GLenum type, GLuint depthbuffer)
</del><ins>+void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer)
</ins><span class="cx"> {
</span><del>-    mDepthbufferType = (depthbuffer != 0) ? type : GL_NONE;
-    mDepthbufferPointer.set(lookupRenderbuffer(type, depthbuffer));
</del><ins>+    Renderbuffer *renderBuffer = lookupRenderbuffer(type, stencilbuffer, level, layer);
+    if (renderBuffer)
+    {
+        mStencilbuffer.set(renderBuffer, type, level, layer);
+    }
+    else
+    {
+        mStencilbuffer.set(NULL, GL_NONE, 0, 0);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer)
</del><ins>+void Framebuffer::setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer)
</ins><span class="cx"> {
</span><del>-    mStencilbufferType = (stencilbuffer != 0) ? type : GL_NONE;
-    mStencilbufferPointer.set(lookupRenderbuffer(type, stencilbuffer));
</del><ins>+    Renderbuffer *renderBuffer = lookupRenderbuffer(type, depthStencilBuffer, level, layer);
+    if (renderBuffer &amp;&amp; renderBuffer-&gt;getDepthSize() &gt; 0 &amp;&amp; renderBuffer-&gt;getStencilSize() &gt; 0)
+    {
+        mDepthbuffer.set(renderBuffer, type, level, layer);
+        mStencilbuffer.set(renderBuffer, type, level, layer);
+    }
+    else
+    {
+        mDepthbuffer.set(NULL, GL_NONE, 0, 0);
+        mStencilbuffer.set(NULL, GL_NONE, 0, 0);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Framebuffer::detachTexture(GLuint texture)
</span><span class="cx"> {
</span><span class="cx">     for (unsigned int colorAttachment = 0; colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
</span><span class="cx">     {
</span><del>-        if (mColorbufferPointers[colorAttachment].id() == texture &amp;&amp; IsInternalTextureTarget(mColorbufferTypes[colorAttachment]))
</del><ins>+        if (mColorbuffers[colorAttachment].id() == texture &amp;&amp;
+            IsInternalTextureTarget(mColorbuffers[colorAttachment].type(), mRenderer-&gt;getCurrentClientVersion()))
</ins><span class="cx">         {
</span><del>-            mColorbufferTypes[colorAttachment] = GL_NONE;
-            mColorbufferPointers[colorAttachment].set(NULL);
</del><ins>+            mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mDepthbufferPointer.id() == texture &amp;&amp; IsInternalTextureTarget(mDepthbufferType))
</del><ins>+    if (mDepthbuffer.id() == texture &amp;&amp; IsInternalTextureTarget(mDepthbuffer.type(), mRenderer-&gt;getCurrentClientVersion()))
</ins><span class="cx">     {
</span><del>-        mDepthbufferType = GL_NONE;
-        mDepthbufferPointer.set(NULL);
</del><ins>+        mDepthbuffer.set(NULL, GL_NONE, 0, 0);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mStencilbufferPointer.id() == texture &amp;&amp; IsInternalTextureTarget(mStencilbufferType))
</del><ins>+    if (mStencilbuffer.id() == texture &amp;&amp; IsInternalTextureTarget(mStencilbuffer.type(), mRenderer-&gt;getCurrentClientVersion()))
</ins><span class="cx">     {
</span><del>-        mStencilbufferType = GL_NONE;
-        mStencilbufferPointer.set(NULL);
</del><ins>+        mStencilbuffer.set(NULL, GL_NONE, 0, 0);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -117,23 +198,20 @@
</span><span class="cx"> {
</span><span class="cx">     for (unsigned int colorAttachment = 0; colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
</span><span class="cx">     {
</span><del>-        if (mColorbufferPointers[colorAttachment].id() == renderbuffer &amp;&amp; mColorbufferTypes[colorAttachment] == GL_RENDERBUFFER)
</del><ins>+        if (mColorbuffers[colorAttachment].id() == renderbuffer &amp;&amp; mColorbuffers[colorAttachment].type() == GL_RENDERBUFFER)
</ins><span class="cx">         {
</span><del>-            mColorbufferTypes[colorAttachment] = GL_NONE;
-            mColorbufferPointers[colorAttachment].set(NULL);
</del><ins>+            mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mDepthbufferPointer.id() == renderbuffer &amp;&amp; mDepthbufferType == GL_RENDERBUFFER)
</del><ins>+    if (mDepthbuffer.id() == renderbuffer &amp;&amp; mDepthbuffer.type() == GL_RENDERBUFFER)
</ins><span class="cx">     {
</span><del>-        mDepthbufferType = GL_NONE;
-        mDepthbufferPointer.set(NULL);
</del><ins>+        mDepthbuffer.set(NULL, GL_NONE, 0, 0);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mStencilbufferPointer.id() == renderbuffer &amp;&amp; mStencilbufferType == GL_RENDERBUFFER)
</del><ins>+    if (mStencilbuffer.id() == renderbuffer &amp;&amp; mStencilbuffer.type() == GL_RENDERBUFFER)
</ins><span class="cx">     {
</span><del>-        mStencilbufferType = GL_NONE;
-        mStencilbufferPointer.set(NULL);
</del><ins>+        mStencilbuffer.set(NULL, GL_NONE, 0, 0);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -141,7 +219,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS);
</span><span class="cx"> 
</span><del>-    Renderbuffer *colorbuffer = mColorbufferPointers[colorAttachment].get();
</del><ins>+    Renderbuffer *colorbuffer = mColorbuffers[colorAttachment].get();
</ins><span class="cx"> 
</span><span class="cx">     if (colorbuffer)
</span><span class="cx">     {
</span><span class="lines">@@ -153,7 +231,7 @@
</span><span class="cx"> 
</span><span class="cx"> unsigned int Framebuffer::getDepthbufferSerial() const
</span><span class="cx"> {
</span><del>-    Renderbuffer *depthbuffer = mDepthbufferPointer.get();
</del><ins>+    Renderbuffer *depthbuffer = mDepthbuffer.get();
</ins><span class="cx"> 
</span><span class="cx">     if (depthbuffer)
</span><span class="cx">     {
</span><span class="lines">@@ -165,7 +243,7 @@
</span><span class="cx"> 
</span><span class="cx"> unsigned int Framebuffer::getStencilbufferSerial() const
</span><span class="cx"> {
</span><del>-    Renderbuffer *stencilbuffer = mStencilbufferPointer.get();
</del><ins>+    Renderbuffer *stencilbuffer = mStencilbuffer.get();
</ins><span class="cx"> 
</span><span class="cx">     if (stencilbuffer)
</span><span class="cx">     {
</span><span class="lines">@@ -178,26 +256,31 @@
</span><span class="cx"> Renderbuffer *Framebuffer::getColorbuffer(unsigned int colorAttachment) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS);
</span><del>-    return mColorbufferPointers[colorAttachment].get();
</del><ins>+    return mColorbuffers[colorAttachment].get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Renderbuffer *Framebuffer::getDepthbuffer() const
</span><span class="cx"> {
</span><del>-    return mDepthbufferPointer.get();
</del><ins>+    return mDepthbuffer.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Renderbuffer *Framebuffer::getStencilbuffer() const
</span><span class="cx"> {
</span><del>-    return mStencilbufferPointer.get();
</del><ins>+    return mStencilbuffer.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Renderbuffer *Framebuffer::getDepthStencilBuffer() const
+{
+    return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.get() : NULL;
+}
+
</ins><span class="cx"> Renderbuffer *Framebuffer::getDepthOrStencilbuffer() const
</span><span class="cx"> {
</span><del>-    Renderbuffer *depthstencilbuffer = mDepthbufferPointer.get();
</del><ins>+    Renderbuffer *depthstencilbuffer = mDepthbuffer.get();
</ins><span class="cx">     
</span><span class="cx">     if (!depthstencilbuffer)
</span><span class="cx">     {
</span><del>-        depthstencilbuffer = mStencilbufferPointer.get();
</del><ins>+        depthstencilbuffer = mStencilbuffer.get();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return depthstencilbuffer;
</span><span class="lines">@@ -206,22 +289,22 @@
</span><span class="cx"> Renderbuffer *Framebuffer::getReadColorbuffer() const
</span><span class="cx"> {
</span><span class="cx">     // Will require more logic if glReadBuffers is supported
</span><del>-    return mColorbufferPointers[0].get();
</del><ins>+    return mColorbuffers[0].get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLenum Framebuffer::getReadColorbufferType() const
</span><span class="cx"> {
</span><span class="cx">     // Will require more logic if glReadBuffers is supported
</span><del>-    return mColorbufferTypes[0];
</del><ins>+    return mColorbuffers[0].type();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Renderbuffer *Framebuffer::getFirstColorbuffer() const
</span><span class="cx"> {
</span><span class="cx">     for (unsigned int colorAttachment = 0; colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
</span><span class="cx">     {
</span><del>-        if (mColorbufferTypes[colorAttachment] != GL_NONE)
</del><ins>+        if (mColorbuffers[colorAttachment].type() != GL_NONE)
</ins><span class="cx">         {
</span><del>-            return mColorbufferPointers[colorAttachment].get();
</del><ins>+            return mColorbuffers[colorAttachment].get();
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -231,35 +314,87 @@
</span><span class="cx"> GLenum Framebuffer::getColorbufferType(unsigned int colorAttachment) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS);
</span><del>-    return mColorbufferTypes[colorAttachment];
</del><ins>+    return mColorbuffers[colorAttachment].type();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLenum Framebuffer::getDepthbufferType() const
</span><span class="cx"> {
</span><del>-    return mDepthbufferType;
</del><ins>+    return mDepthbuffer.type();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLenum Framebuffer::getStencilbufferType() const
</span><span class="cx"> {
</span><del>-    return mStencilbufferType;
</del><ins>+    return mStencilbuffer.type();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLenum Framebuffer::getDepthStencilbufferType() const
+{
+    return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.type() : GL_NONE;
+}
+
</ins><span class="cx"> GLuint Framebuffer::getColorbufferHandle(unsigned int colorAttachment) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS);
</span><del>-    return mColorbufferPointers[colorAttachment].id();
</del><ins>+    return mColorbuffers[colorAttachment].id();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLuint Framebuffer::getDepthbufferHandle() const
</span><span class="cx"> {
</span><del>-    return mDepthbufferPointer.id();
</del><ins>+    return mDepthbuffer.id();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLuint Framebuffer::getStencilbufferHandle() const
</span><span class="cx"> {
</span><del>-    return mStencilbufferPointer.id();
</del><ins>+    return mStencilbuffer.id();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLenum Framebuffer::getDepthStencilbufferHandle() const
+{
+    return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.id() : 0;
+}
+
+GLenum Framebuffer::getColorbufferMipLevel(unsigned int colorAttachment) const
+{
+    ASSERT(colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS);
+    return mColorbuffers[colorAttachment].mipLevel();
+}
+
+GLenum Framebuffer::getDepthbufferMipLevel() const
+{
+    return mDepthbuffer.mipLevel();
+}
+
+GLenum Framebuffer::getStencilbufferMipLevel() const
+{
+    return mStencilbuffer.mipLevel();
+}
+
+GLenum Framebuffer::getDepthStencilbufferMipLevel() const
+{
+    return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.mipLevel() : 0;
+}
+
+GLenum Framebuffer::getColorbufferLayer(unsigned int colorAttachment) const
+{
+    ASSERT(colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS);
+    return mColorbuffers[colorAttachment].layer();
+}
+
+GLenum Framebuffer::getDepthbufferLayer() const
+{
+    return mDepthbuffer.layer();
+}
+
+GLenum Framebuffer::getStencilbufferLayer() const
+{
+    return mStencilbuffer.layer();
+}
+
+GLenum Framebuffer::getDepthStencilbufferLayer() const
+{
+    return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.layer() : 0;
+}
+
</ins><span class="cx"> GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const
</span><span class="cx"> {
</span><span class="cx">     return mDrawBufferStates[colorAttachment];
</span><span class="lines">@@ -272,7 +407,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const
</span><span class="cx"> {
</span><del>-    return (mColorbufferTypes[colorAttachment] != GL_NONE &amp;&amp; mDrawBufferStates[colorAttachment] != GL_NONE);
</del><ins>+    return (mColorbuffers[colorAttachment].type() != GL_NONE &amp;&amp; mDrawBufferStates[colorAttachment] != GL_NONE);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Framebuffer::hasEnabledColorAttachment() const
</span><span class="lines">@@ -290,7 +425,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool Framebuffer::hasStencil() const
</span><span class="cx"> {
</span><del>-    if (mStencilbufferType != GL_NONE)
</del><ins>+    if (mStencilbuffer.type() != GL_NONE)
</ins><span class="cx">     {
</span><span class="cx">         const Renderbuffer *stencilbufferObject = getStencilbuffer();
</span><span class="cx"> 
</span><span class="lines">@@ -320,13 +455,14 @@
</span><span class="cx"> {
</span><span class="cx">     int width = 0;
</span><span class="cx">     int height = 0;
</span><del>-    int colorbufferSize = 0;
</del><ins>+    unsigned int colorbufferSize = 0;
</ins><span class="cx">     int samples = -1;
</span><span class="cx">     bool missingAttachment = true;
</span><ins>+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
</ins><span class="cx"> 
</span><span class="cx">     for (unsigned int colorAttachment = 0; colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
</span><span class="cx">     {
</span><del>-        if (mColorbufferTypes[colorAttachment] != GL_NONE)
</del><ins>+        if (mColorbuffers[colorAttachment].type() != GL_NONE)
</ins><span class="cx">         {
</span><span class="cx">             const Renderbuffer *colorbuffer = getColorbuffer(colorAttachment);
</span><span class="cx"> 
</span><span class="lines">@@ -340,36 +476,25 @@
</span><span class="cx">                 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (mColorbufferTypes[colorAttachment] == GL_RENDERBUFFER)
</del><ins>+            if (mColorbuffers[colorAttachment].type() == GL_RENDERBUFFER)
</ins><span class="cx">             {
</span><del>-                if (!gl::IsColorRenderable(colorbuffer-&gt;getInternalFormat()))
</del><ins>+                if (!gl::IsColorRenderingSupported(colorbuffer-&gt;getInternalFormat(), mRenderer))
</ins><span class="cx">                 {
</span><span class="cx">                     return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">                 }
</span><span class="cx">             }
</span><del>-            else if (IsInternalTextureTarget(mColorbufferTypes[colorAttachment]))
</del><ins>+            else if (IsInternalTextureTarget(mColorbuffers[colorAttachment].type(), mRenderer-&gt;getCurrentClientVersion()))
</ins><span class="cx">             {
</span><del>-                GLint internalformat = colorbuffer-&gt;getInternalFormat();
-                GLenum format = gl::ExtractFormat(internalformat);
</del><ins>+                GLenum internalformat = colorbuffer-&gt;getInternalFormat();
</ins><span class="cx"> 
</span><del>-                if (IsCompressed(format) ||
-                    format == GL_ALPHA ||
-                    format == GL_LUMINANCE ||
-                    format == GL_LUMINANCE_ALPHA)
</del><ins>+                if (!gl::IsColorRenderingSupported(internalformat, mRenderer))
</ins><span class="cx">                 {
</span><span class="cx">                     return GL_FRAMEBUFFER_UNSUPPORTED;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                bool filtering, renderable;
-
-                if ((gl::IsFloat32Format(internalformat) &amp;&amp; !mRenderer-&gt;getFloat32TextureSupport(&amp;filtering, &amp;renderable)) ||
-                    (gl::IsFloat16Format(internalformat) &amp;&amp; !mRenderer-&gt;getFloat16TextureSupport(&amp;filtering, &amp;renderable)))
</del><ins>+                if (gl::GetDepthBits(internalformat, clientVersion) &gt; 0 ||
+                    gl::GetStencilBits(internalformat, clientVersion) &gt; 0)
</ins><span class="cx">                 {
</span><del>-                    return GL_FRAMEBUFFER_UNSUPPORTED;
-                }
-
-                if (gl::IsDepthTexture(internalformat) || gl::IsStencilTexture(internalformat))
-                {
</del><span class="cx">                     return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">                 }
</span><span class="cx">             }
</span><span class="lines">@@ -394,16 +519,20 @@
</span><span class="cx">                     return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                // all color attachments attachments must have the same number of bitplanes
-                if (gl::ComputePixelSize(colorbuffer-&gt;getInternalFormat()) != colorbufferSize)
</del><ins>+                // in GLES 2.0, all color attachments attachments must have the same number of bitplanes
+                // in GLES 3.0, there is no such restriction
+                if (clientVersion &lt; 3)
</ins><span class="cx">                 {
</span><del>-                    return GL_FRAMEBUFFER_UNSUPPORTED;
</del><ins>+                    if (gl::GetPixelBytes(colorbuffer-&gt;getInternalFormat(), clientVersion) != colorbufferSize)
+                    {
+                        return GL_FRAMEBUFFER_UNSUPPORTED;
+                    }
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness
</span><span class="cx">                 for (unsigned int previousColorAttachment = 0; previousColorAttachment &lt; colorAttachment; previousColorAttachment++)
</span><span class="cx">                 {
</span><del>-                    if (mColorbufferPointers[colorAttachment].get() == mColorbufferPointers[previousColorAttachment].get())
</del><ins>+                    if (mColorbuffers[colorAttachment].get() == mColorbuffers[previousColorAttachment].get())
</ins><span class="cx">                     {
</span><span class="cx">                         return GL_FRAMEBUFFER_UNSUPPORTED;
</span><span class="cx">                     }
</span><span class="lines">@@ -414,7 +543,7 @@
</span><span class="cx">                 width = colorbuffer-&gt;getWidth();
</span><span class="cx">                 height = colorbuffer-&gt;getHeight();
</span><span class="cx">                 samples = colorbuffer-&gt;getSamples();
</span><del>-                colorbufferSize = gl::ComputePixelSize(colorbuffer-&gt;getInternalFormat());
</del><ins>+                colorbufferSize = gl::GetPixelBytes(colorbuffer-&gt;getInternalFormat(), clientVersion);
</ins><span class="cx">                 missingAttachment = false;
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -423,7 +552,7 @@
</span><span class="cx">     const Renderbuffer *depthbuffer = NULL;
</span><span class="cx">     const Renderbuffer *stencilbuffer = NULL;
</span><span class="cx"> 
</span><del>-    if (mDepthbufferType != GL_NONE)
</del><ins>+    if (mDepthbuffer.type() != GL_NONE)
</ins><span class="cx">     {
</span><span class="cx">         depthbuffer = getDepthbuffer();
</span><span class="cx"> 
</span><span class="lines">@@ -437,16 +566,16 @@
</span><span class="cx">             return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (mDepthbufferType == GL_RENDERBUFFER)
</del><ins>+        if (mDepthbuffer.type() == GL_RENDERBUFFER)
</ins><span class="cx">         {
</span><del>-            if (!gl::IsDepthRenderable(depthbuffer-&gt;getInternalFormat()))
</del><ins>+            if (!gl::IsDepthRenderingSupported(depthbuffer-&gt;getInternalFormat(), mRenderer))
</ins><span class="cx">             {
</span><span class="cx">                 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-        else if (IsInternalTextureTarget(mDepthbufferType))
</del><ins>+        else if (IsInternalTextureTarget(mDepthbuffer.type(), mRenderer-&gt;getCurrentClientVersion()))
</ins><span class="cx">         {
</span><del>-            GLint internalformat = depthbuffer-&gt;getInternalFormat();
</del><ins>+            GLenum internalformat = depthbuffer-&gt;getInternalFormat();
</ins><span class="cx"> 
</span><span class="cx">             // depth texture attachments require OES/ANGLE_depth_texture
</span><span class="cx">             if (!mRenderer-&gt;getDepthTextureSupport())
</span><span class="lines">@@ -454,7 +583,7 @@
</span><span class="cx">                 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (!gl::IsDepthTexture(internalformat))
</del><ins>+            if (gl::GetDepthBits(internalformat, clientVersion) == 0)
</ins><span class="cx">             {
</span><span class="cx">                 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">             }
</span><span class="lines">@@ -482,7 +611,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mStencilbufferType != GL_NONE)
</del><ins>+    if (mStencilbuffer.type() != GL_NONE)
</ins><span class="cx">     {
</span><span class="cx">         stencilbuffer = getStencilbuffer();
</span><span class="cx"> 
</span><span class="lines">@@ -496,16 +625,16 @@
</span><span class="cx">             return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (mStencilbufferType == GL_RENDERBUFFER)
</del><ins>+        if (mStencilbuffer.type() == GL_RENDERBUFFER)
</ins><span class="cx">         {
</span><del>-            if (!gl::IsStencilRenderable(stencilbuffer-&gt;getInternalFormat()))
</del><ins>+            if (!gl::IsStencilRenderingSupported(stencilbuffer-&gt;getInternalFormat(), mRenderer))
</ins><span class="cx">             {
</span><span class="cx">                 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-        else if (IsInternalTextureTarget(mStencilbufferType))
</del><ins>+        else if (IsInternalTextureTarget(mStencilbuffer.type(), mRenderer-&gt;getCurrentClientVersion()))
</ins><span class="cx">         {
</span><del>-            GLint internalformat = stencilbuffer-&gt;getInternalFormat();
</del><ins>+            GLenum internalformat = stencilbuffer-&gt;getInternalFormat();
</ins><span class="cx"> 
</span><span class="cx">             // texture stencil attachments come along as part
</span><span class="cx">             // of OES_packed_depth_stencil + OES/ANGLE_depth_texture
</span><span class="lines">@@ -514,7 +643,7 @@
</span><span class="cx">                 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (!gl::IsStencilTexture(internalformat))
</del><ins>+            if (gl::GetStencilBits(internalformat, clientVersion) == 0)
</ins><span class="cx">             {
</span><span class="cx">                 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
</span><span class="cx">             }
</span><span class="lines">@@ -561,16 +690,12 @@
</span><span class="cx"> DefaultFramebuffer::DefaultFramebuffer(rx::Renderer *renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil)
</span><span class="cx">     : Framebuffer(renderer)
</span><span class="cx"> {
</span><del>-    mColorbufferPointers[0].set(new Renderbuffer(mRenderer, 0, colorbuffer));
</del><ins>+    mColorbuffers[0].set(new Renderbuffer(mRenderer, 0, colorbuffer), GL_RENDERBUFFER, 0, 0);
</ins><span class="cx"> 
</span><span class="cx">     Renderbuffer *depthStencilRenderbuffer = new Renderbuffer(mRenderer, 0, depthStencil);
</span><del>-    mDepthbufferPointer.set(depthStencilRenderbuffer);
-    mStencilbufferPointer.set(depthStencilRenderbuffer);
</del><ins>+    mDepthbuffer.set(depthStencilRenderbuffer, (depthStencilRenderbuffer-&gt;getDepthSize() != 0) ? GL_RENDERBUFFER : GL_NONE, 0, 0);
+    mStencilbuffer.set(depthStencilRenderbuffer, (depthStencilRenderbuffer-&gt;getStencilSize() != 0) ? GL_RENDERBUFFER : GL_NONE, 0, 0);
</ins><span class="cx"> 
</span><del>-    mColorbufferTypes[0] = GL_RENDERBUFFER;
-    mDepthbufferType = (depthStencilRenderbuffer-&gt;getDepthSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
-    mStencilbufferType = (depthStencilRenderbuffer-&gt;getStencilSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
-
</del><span class="cx">     mDrawBufferStates[0] = GL_BACK;
</span><span class="cx">     mReadBufferState = GL_BACK;
</span><span class="cx"> }
</span><span class="lines">@@ -583,7 +708,7 @@
</span><span class="cx">         // in this case return the first nonzero sample size
</span><span class="cx">         for (unsigned int colorAttachment = 0; colorAttachment &lt; IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
</span><span class="cx">         {
</span><del>-            if (mColorbufferTypes[colorAttachment] != GL_NONE)
</del><ins>+            if (mColorbuffers[colorAttachment].type() != GL_NONE)
</ins><span class="cx">             {
</span><span class="cx">                 return getColorbuffer(colorAttachment)-&gt;getSamples();
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Framebufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><span class="cx"> #include &quot;common/RefCountObject.h&quot;
</span><del>-#include &quot;Constants.h&quot;
</del><ins>+#include &quot;constants.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -34,9 +34,10 @@
</span><span class="cx"> 
</span><span class="cx">     virtual ~Framebuffer();
</span><span class="cx"> 
</span><del>-    void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer);
-    void setDepthbuffer(GLenum type, GLuint depthbuffer);
-    void setStencilbuffer(GLenum type, GLuint stencilbuffer);
</del><ins>+    void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer);
+    void setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer);
+    void setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer);
+    void setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer);
</ins><span class="cx"> 
</span><span class="cx">     void detachTexture(GLuint texture);
</span><span class="cx">     void detachRenderbuffer(GLuint renderbuffer);
</span><span class="lines">@@ -48,6 +49,7 @@
</span><span class="cx">     Renderbuffer *getColorbuffer(unsigned int colorAttachment) const;
</span><span class="cx">     Renderbuffer *getDepthbuffer() const;
</span><span class="cx">     Renderbuffer *getStencilbuffer() const;
</span><ins>+    Renderbuffer *getDepthStencilBuffer() const;
</ins><span class="cx">     Renderbuffer *getDepthOrStencilbuffer() const;
</span><span class="cx">     Renderbuffer *getReadColorbuffer() const;
</span><span class="cx">     GLenum getReadColorbufferType() const;
</span><span class="lines">@@ -56,11 +58,23 @@
</span><span class="cx">     GLenum getColorbufferType(unsigned int colorAttachment) const;
</span><span class="cx">     GLenum getDepthbufferType() const;
</span><span class="cx">     GLenum getStencilbufferType() const;
</span><ins>+    GLenum getDepthStencilbufferType() const;
</ins><span class="cx"> 
</span><span class="cx">     GLuint getColorbufferHandle(unsigned int colorAttachment) const;
</span><span class="cx">     GLuint getDepthbufferHandle() const;
</span><span class="cx">     GLuint getStencilbufferHandle() const;
</span><ins>+    GLenum getDepthStencilbufferHandle() const;
</ins><span class="cx"> 
</span><ins>+    GLenum getColorbufferMipLevel(unsigned int colorAttachment) const;
+    GLenum getDepthbufferMipLevel() const;
+    GLenum getStencilbufferMipLevel() const;
+    GLenum getDepthStencilbufferMipLevel() const;
+
+    GLenum getColorbufferLayer(unsigned int colorAttachment) const;
+    GLenum getDepthbufferLayer() const;
+    GLenum getStencilbufferLayer() const;
+    GLenum getDepthStencilbufferLayer() const;
+
</ins><span class="cx">     GLenum getDrawBufferState(unsigned int colorAttachment) const;
</span><span class="cx">     void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
</span><span class="cx"> 
</span><span class="lines">@@ -73,23 +87,19 @@
</span><span class="cx">     virtual GLenum completeness() const;
</span><span class="cx"> 
</span><span class="cx">   protected:
</span><del>-    GLenum mColorbufferTypes[IMPLEMENTATION_MAX_DRAW_BUFFERS];
-    BindingPointer&lt;Renderbuffer&gt; mColorbufferPointers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
</del><ins>+    FramebufferTextureBindingPointer&lt;Renderbuffer&gt; mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
</ins><span class="cx">     GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
</span><span class="cx">     GLenum mReadBufferState;
</span><span class="cx"> 
</span><del>-    GLenum mDepthbufferType;
-    BindingPointer&lt;Renderbuffer&gt; mDepthbufferPointer;
</del><ins>+    FramebufferTextureBindingPointer&lt;Renderbuffer&gt; mDepthbuffer;
+    FramebufferTextureBindingPointer&lt;Renderbuffer&gt; mStencilbuffer;
</ins><span class="cx"> 
</span><del>-    GLenum mStencilbufferType;
-    BindingPointer&lt;Renderbuffer&gt; mStencilbufferPointer;
-
</del><span class="cx">     rx::Renderer *mRenderer;
</span><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Framebuffer);
</span><span class="cx"> 
</span><del>-    Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle) const;
</del><ins>+    Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle, GLint level, GLint layer) const;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class DefaultFramebuffer : public Framebuffer
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2HandleAllocatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/HandleAllocator.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/HandleAllocator.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/HandleAllocator.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -11,6 +11,7 @@
</span><span class="cx"> #define LIBGLESV2_HANDLEALLOCATOR_H_
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;vector&gt;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Programcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -95,36 +95,42 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    char info[1024];
-
</del><span class="cx">     va_list vararg;
</span><span class="cx">     va_start(vararg, format);
</span><del>-    vsnprintf(info, sizeof(info), format, vararg);
</del><ins>+    size_t infoLength = vsnprintf(NULL, 0, format, vararg);
</ins><span class="cx">     va_end(vararg);
</span><span class="cx"> 
</span><del>-    size_t infoLength = strlen(info);
</del><ins>+    char *logPointer = NULL;
+    size_t logLength = 0;
</ins><span class="cx"> 
</span><span class="cx">     if (!mInfoLog)
</span><span class="cx">     {
</span><del>-        const size_t newInfoLogLength = infoLength + 2;
-        mInfoLog = new char[newInfoLogLength];
-        strncpy(mInfoLog, info, newInfoLogLength);
-        strncpy(mInfoLog + infoLength, &quot;\n&quot;, newInfoLogLength - infoLength);
-        mInfoLog[newInfoLogLength - 1] = '\0';
</del><ins>+        mInfoLog = new char[infoLength + 2];
+        logPointer = mInfoLog;
+        logLength = infoLenfth + 2;
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        size_t logLength = strlen(mInfoLog);
-        const size_t newInfoLogLength = logLength + infoLength + 2;
</del><ins>+        size_t currentlogLength = strlen(mInfoLog);
+        size_t newInfoLogLength = currentlogLength + infoLength + 2; 
</ins><span class="cx">         char *newLog = new char[newInfoLogLength];
</span><span class="cx">         strncpy(newLog, mInfoLog, newInfoLogLength);
</span><del>-        strncpy(newLog + logLength, info, newInfoLogLength - logLength);
-        strncpy(newLog + logLength + infoLength, &quot;\n&quot;, newInfoLogLength - logLength - infoLength);
</del><span class="cx">         newLog[newInfoLogLength - 1] = '\0';
</span><span class="cx"> 
</span><span class="cx">         delete[] mInfoLog;
</span><span class="cx">         mInfoLog = newLog;
</span><ins>+
+        logPointer = mInfoLog + currentlogLength;
+        logLength = newInfoLogLength - currentlogLength;
</ins><span class="cx">     }
</span><ins>+
+    va_start(vararg, format);
+    vsnprintf(logPointer, infoLength, format, vararg);
+    va_end(vararg);
+
+    logPointer[infoLength] = 0;
+    strncpy(logPointer + infoLength, &quot;\n&quot;, logLength - infoLength);
+    logPointer[logLength - 1] = '\0';
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InfoLog::reset()
</span><span class="lines">@@ -145,6 +151,8 @@
</span><span class="cx">     mLinked = false;
</span><span class="cx">     mRefCount = 0;
</span><span class="cx">     mRenderer = renderer;
</span><ins>+
+    resetUniformBlockBindings();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Program::~Program()
</span><span class="lines">@@ -247,9 +255,11 @@
</span><span class="cx">     unlink(false);
</span><span class="cx"> 
</span><span class="cx">     mInfoLog.reset();
</span><ins>+    resetUniformBlockBindings();
</ins><span class="cx"> 
</span><span class="cx">     mProgramBinary.set(new ProgramBinary(mRenderer));
</span><del>-    mLinked = mProgramBinary-&gt;link(mInfoLog, mAttributeBindings, mFragmentShader, mVertexShader);
</del><ins>+    mLinked = mProgramBinary-&gt;link(mInfoLog, mAttributeBindings, mFragmentShader, mVertexShader,
+                                   mTransformFeedbackVaryings, mTransformFeedbackBufferMode);
</ins><span class="cx"> 
</span><span class="cx">     return mLinked;
</span><span class="cx"> }
</span><span class="lines">@@ -294,7 +304,7 @@
</span><span class="cx">     return mLinked;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ProgramBinary* Program::getProgramBinary()
</del><ins>+ProgramBinary* Program::getProgramBinary() const
</ins><span class="cx"> {
</span><span class="cx">     return mProgramBinary.get();
</span><span class="cx"> }
</span><span class="lines">@@ -526,4 +536,132 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLint Program::getActiveUniformBlockCount()
+{
+    ProgramBinary *programBinary = getProgramBinary();
+    if (programBinary)
+    {
+        return static_cast&lt;GLint&gt;(programBinary-&gt;getActiveUniformBlockCount());
+    }
+    else
+    {
+        return 0;
+    }
</ins><span class="cx"> }
</span><ins>+
+GLint Program::getActiveUniformBlockMaxLength()
+{
+    ProgramBinary *programBinary = getProgramBinary();
+    if (programBinary)
+    {
+        return static_cast&lt;GLint&gt;(programBinary-&gt;getActiveUniformBlockMaxLength());
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+void Program::bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBinding)
+{
+    mUniformBlockBindings[uniformBlockIndex] = uniformBlockBinding;
+}
+
+GLuint Program::getUniformBlockBinding(GLuint uniformBlockIndex) const
+{
+    return mUniformBlockBindings[uniformBlockIndex];
+}
+
+void Program::resetUniformBlockBindings()
+{
+    for (unsigned int blockId = 0; blockId &lt; IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS; blockId++)
+    {
+        mUniformBlockBindings[blockId] = 0;
+    }
+}
+
+void Program::setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode)
+{
+    mTransformFeedbackVaryings.resize(count);
+    for (GLsizei i = 0; i &lt; count; i++)
+    {
+        mTransformFeedbackVaryings[i] = varyings[i];
+    }
+
+    mTransformFeedbackBufferMode = bufferMode;
+}
+
+void Program::getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const
+{
+    ProgramBinary *programBinary = getProgramBinary();
+    if (programBinary &amp;&amp; index &lt; programBinary-&gt;getTransformFeedbackVaryingCount())
+    {
+        const LinkedVarying &amp;varying = programBinary-&gt;getTransformFeedbackVarying(index);
+        GLsizei lastNameIdx = std::min(bufSize - 1, static_cast&lt;GLsizei&gt;(varying.name.length()));
+        if (length)
+        {
+            *length = lastNameIdx;
+        }
+        if (size)
+        {
+            *size = varying.size;
+        }
+        if (type)
+        {
+            *type = varying.type;
+        }
+        if (name)
+        {
+            memcpy(name, varying.name.c_str(), lastNameIdx);
+            name[lastNameIdx] = '\0';
+        }
+    }
+}
+
+GLsizei Program::getTransformFeedbackVaryingCount() const
+{
+    ProgramBinary *programBinary = getProgramBinary();
+    if (programBinary)
+    {
+        return static_cast&lt;GLsizei&gt;(programBinary-&gt;getTransformFeedbackVaryingCount());
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+GLsizei Program::getTransformFeedbackVaryingMaxLength() const
+{
+    ProgramBinary *programBinary = getProgramBinary();
+    if (programBinary)
+    {
+        GLsizei maxSize = 0;
+        for (size_t i = 0; i &lt; programBinary-&gt;getTransformFeedbackVaryingCount(); i++)
+        {
+            const LinkedVarying &amp;varying = programBinary-&gt;getTransformFeedbackVarying(i);
+            maxSize = std::max(maxSize, static_cast&lt;GLsizei&gt;(varying.name.length() + 1));
+        }
+
+        return maxSize;
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+GLenum Program::getTransformFeedbackBufferMode() const
+{
+    ProgramBinary *programBinary = getProgramBinary();
+    if (programBinary)
+    {
+        return programBinary-&gt;getTransformFeedbackBufferMode();
+    }
+    else
+    {
+        return mTransformFeedbackBufferMode;
+    }
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Programh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Program.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Program.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Program.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx">     bool link();
</span><span class="cx">     bool isLinked();
</span><span class="cx">     bool setProgramBinary(const void *binary, GLsizei length);
</span><del>-    ProgramBinary *getProgramBinary();
</del><ins>+    ProgramBinary *getProgramBinary() const;
</ins><span class="cx"> 
</span><span class="cx">     int getInfoLogLength() const;
</span><span class="cx">     void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
</span><span class="lines">@@ -92,6 +92,18 @@
</span><span class="cx">     GLint getActiveUniformCount();
</span><span class="cx">     GLint getActiveUniformMaxLength();
</span><span class="cx"> 
</span><ins>+    GLint getActiveUniformBlockCount();
+    GLint getActiveUniformBlockMaxLength();
+
+    void bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+    GLuint getUniformBlockBinding(GLuint uniformBlockIndex) const;
+
+    void setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode);
+    void getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const;
+    GLsizei getTransformFeedbackVaryingCount() const;
+    GLsizei getTransformFeedbackVaryingMaxLength() const;
+    GLenum getTransformFeedbackBufferMode() const;
+
</ins><span class="cx">     void addRef();
</span><span class="cx">     void release();
</span><span class="cx">     unsigned int getRefCount() const;
</span><span class="lines">@@ -107,12 +119,18 @@
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Program);
</span><span class="cx"> 
</span><span class="cx">     void unlink(bool destroy = false);
</span><ins>+    void resetUniformBlockBindings();
</ins><span class="cx"> 
</span><span class="cx">     FragmentShader *mFragmentShader;
</span><span class="cx">     VertexShader *mVertexShader;
</span><span class="cx"> 
</span><span class="cx">     AttributeBindings mAttributeBindings;
</span><span class="cx"> 
</span><ins>+    GLuint mUniformBlockBindings[IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS];
+
+    std::vector&lt;std::string&gt; mTransformFeedbackVaryings;
+    GLuint mTransformFeedbackBufferMode;
+
</ins><span class="cx">     BindingPointer&lt;ProgramBinary&gt; mProgramBinary;
</span><span class="cx">     bool mLinked;
</span><span class="cx">     bool mDeleteStatus;   // Flag to indicate that the program can be deleted when no longer in use
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2ProgramBinarycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ProgramBinary.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ProgramBinary.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ProgramBinary.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -14,46 +14,132 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/debug.h&quot;
</span><span class="cx"> #include &quot;common/version.h&quot;
</span><del>-#include &quot;utilities.h&quot;
</del><ins>+#include &quot;common/utilities.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Shader.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Program.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/VertexDataManager.h&quot;
</span><ins>+#include &quot;libGLESv2/Context.h&quot;
+#include &quot;libGLESv2/Buffer.h&quot;
+#include &quot;libGLESv2/DynamicHLSL.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #undef near
</span><span class="cx"> #undef far
</span><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><del>-std::string str(int i)
</del><ins>+
+namespace 
</ins><span class="cx"> {
</span><del>-    char buffer[20];
-    snprintf(buffer, sizeof(buffer), &quot;%d&quot;, i);
-    return buffer;
</del><ins>+
+unsigned int ParseAndStripArrayIndex(std::string* name)
+{
+    unsigned int subscript = GL_INVALID_INDEX;
+
+    // Strip any trailing array operator and retrieve the subscript
+    size_t open = name-&gt;find_last_of('[');
+    size_t close = name-&gt;find_last_of(']');
+    if (open != std::string::npos &amp;&amp; close == name-&gt;length() - 1)
+    {
+        subscript = atoi(name-&gt;substr(open + 1).c_str());
+        name-&gt;erase(open);
+    }
+
+    return subscript;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static rx::D3DWorkaroundType DiscardWorkaround(bool usesDiscard)
</del><ins>+void GetInputLayoutFromShader(const std::vector&lt;gl::Attribute&gt; &amp;shaderAttributes, VertexFormat inputLayout[MAX_VERTEX_ATTRIBS])
</ins><span class="cx"> {
</span><del>-    return (usesDiscard ? rx::ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER : rx::ANGLE_D3D_WORKAROUND_NONE);
</del><ins>+    size_t layoutIndex = 0;
+    for (size_t attributeIndex = 0; attributeIndex &lt; shaderAttributes.size(); attributeIndex++)
+    {
+        ASSERT(layoutIndex &lt; MAX_VERTEX_ATTRIBS);
+
+        const gl::Attribute &amp;shaderAttr = shaderAttributes[attributeIndex];
+
+        if (shaderAttr.type != GL_NONE)
+        {
+            GLenum transposedType = TransposeMatrixType(shaderAttr.type);
+
+            for (size_t rowIndex = 0; static_cast&lt;int&gt;(rowIndex) &lt; VariableRowCount(transposedType); rowIndex++, layoutIndex++)
+            {
+                VertexFormat *defaultFormat = &amp;inputLayout[layoutIndex];
+
+                defaultFormat-&gt;mType = UniformComponentType(transposedType);
+                defaultFormat-&gt;mNormalized = false;
+                defaultFormat-&gt;mPureInteger = (defaultFormat-&gt;mType != GL_FLOAT); // note: inputs can not be bool
+                defaultFormat-&gt;mComponents = VariableColumnCount(transposedType);
+            }
+        }
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-UniformLocation::UniformLocation(const std::string &amp;name, unsigned int element, unsigned int index) 
</del><ins>+}
+
+VariableLocation::VariableLocation(const std::string &amp;name, unsigned int element, unsigned int index) 
</ins><span class="cx">     : name(name), element(element), index(index)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned int ProgramBinary::mCurrentSerial = 1;
</del><ins>+ProgramBinary::VertexExecutable::VertexExecutable(rx::Renderer *const renderer,
+                                                  const VertexFormat inputLayout[],
+                                                  rx::ShaderExecutable *shaderExecutable)
+    : mShaderExecutable(shaderExecutable)
+{
+    for (size_t attributeIndex = 0; attributeIndex &lt; gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
+    {
+        mInputs[attributeIndex] = inputLayout[attributeIndex];
+    }
+}
</ins><span class="cx"> 
</span><del>-ProgramBinary::ProgramBinary(rx::Renderer *renderer) : mRenderer(renderer), RefCountObject(0), mSerial(issueSerial())
</del><ins>+ProgramBinary::VertexExecutable::~VertexExecutable()
</ins><span class="cx"> {
</span><del>-    mPixelExecutable = NULL;
-    mVertexExecutable = NULL;
-    mGeometryExecutable = NULL;
</del><ins>+    delete mShaderExecutable;
+}
</ins><span class="cx"> 
</span><del>-    mValidated = false;
</del><ins>+bool ProgramBinary::VertexExecutable::matchesInputLayout(const VertexFormat attributes[]) const
+{
+    for (size_t attributeIndex = 0; attributeIndex &lt; gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
+    {
+        if (mInputs[attributeIndex] != attributes[attributeIndex])
+        {
+            return false;
+        }
+    }
</ins><span class="cx"> 
</span><ins>+    return true;
+}
+
+LinkedVarying::LinkedVarying()
+{
+}
+
+LinkedVarying::LinkedVarying(const std::string &amp;name, GLenum type, GLsizei size, const std::string &amp;semanticName,
+                             unsigned int semanticIndex, unsigned int semanticIndexCount)
+    : name(name), type(type), size(size), semanticName(semanticName), semanticIndex(semanticIndex), semanticIndexCount(semanticIndexCount)
+{
+}
+
+unsigned int ProgramBinary::mCurrentSerial = 1;
+
+ProgramBinary::ProgramBinary(rx::Renderer *renderer)
+    : RefCountObject(0),
+      mRenderer(renderer),
+      mDynamicHLSL(NULL),
+      mVertexWorkarounds(rx::ANGLE_D3D_WORKAROUND_NONE),
+      mPixelExecutable(NULL),
+      mGeometryExecutable(NULL),
+      mUsedVertexSamplerRange(0),
+      mUsedPixelSamplerRange(0),
+      mUsesPointSize(false),
+      mShaderVersion(100),
+      mVertexUniformStorage(NULL),
+      mFragmentUniformStorage(NULL),
+      mValidated(false),
+      mSerial(issueSerial())
+{
</ins><span class="cx">     for (int index = 0; index &lt; MAX_VERTEX_ATTRIBS; index++)
</span><span class="cx">     {
</span><span class="cx">         mSemanticIndex[index] = -1;
</span><span class="lines">@@ -69,27 +155,35 @@
</span><span class="cx">         mSamplersVS[index].active = false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mUsedVertexSamplerRange = 0;
-    mUsedPixelSamplerRange = 0;
-    mUsesPointSize = false;
</del><ins>+    mDynamicHLSL = new DynamicHLSL(renderer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ProgramBinary::~ProgramBinary()
</span><span class="cx"> {
</span><del>-    delete mPixelExecutable;
-    mPixelExecutable = NULL;
</del><ins>+    while (!mVertexExecutables.empty())
+    {
+        delete mVertexExecutables.back();
+        mVertexExecutables.pop_back();
+    }
</ins><span class="cx"> 
</span><del>-    delete mVertexExecutable;
-    mVertexExecutable = NULL;
</del><ins>+    SafeDelete(mGeometryExecutable);
+    SafeDelete(mPixelExecutable);
</ins><span class="cx"> 
</span><del>-    delete mGeometryExecutable;
-    mGeometryExecutable = NULL;
-
</del><span class="cx">     while (!mUniforms.empty())
</span><span class="cx">     {
</span><span class="cx">         delete mUniforms.back();
</span><span class="cx">         mUniforms.pop_back();
</span><span class="cx">     }
</span><ins>+
+    while (!mUniformBlocks.empty())
+    {
+        delete mUniformBlocks.back();
+        mUniformBlocks.pop_back();
+    }
+
+    SafeDelete(mVertexUniformStorage);
+    SafeDelete(mFragmentUniformStorage);
+    SafeDelete(mDynamicHLSL);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned int ProgramBinary::getSerial() const
</span><span class="lines">@@ -97,22 +191,62 @@
</span><span class="cx">     return mSerial;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int ProgramBinary::getShaderVersion() const
+{
+    return mShaderVersion;
+}
+
</ins><span class="cx"> unsigned int ProgramBinary::issueSerial()
</span><span class="cx"> {
</span><span class="cx">     return mCurrentSerial++;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-rx::ShaderExecutable *ProgramBinary::getPixelExecutable()
</del><ins>+rx::ShaderExecutable *ProgramBinary::getPixelExecutable() const
</ins><span class="cx"> {
</span><span class="cx">     return mPixelExecutable;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-rx::ShaderExecutable *ProgramBinary::getVertexExecutable()
</del><ins>+rx::ShaderExecutable *ProgramBinary::getVertexExecutableForInputLayout(const VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS])
</ins><span class="cx"> {
</span><del>-    return mVertexExecutable;
</del><ins>+    for (size_t executableIndex = 0; executableIndex &lt; mVertexExecutables.size(); executableIndex++)
+    {
+        if (mVertexExecutables[executableIndex]-&gt;matchesInputLayout(inputLayout))
+        {
+            return mVertexExecutables[executableIndex]-&gt;shaderExecutable();
+        }
+    }
+
+    // Generate new dynamic layout with attribute conversions
+    const std::string &amp;layoutHLSL = mDynamicHLSL-&gt;generateInputLayoutHLSL(inputLayout, mShaderAttributes);
+
+    // Generate new shader source by replacing the attributes stub with the defined input layout
+    std::string vertexHLSL = mVertexHLSL;
+    size_t insertPos = vertexHLSL.find(DynamicHLSL::VERTEX_ATTRIBUTE_STUB_STRING);
+    vertexHLSL.replace(insertPos, DynamicHLSL::VERTEX_ATTRIBUTE_STUB_STRING.length(), layoutHLSL);
+
+    // Generate new vertex executable
+    InfoLog tempInfoLog;
+    rx::ShaderExecutable *vertexExecutable = mRenderer-&gt;compileToExecutable(tempInfoLog, vertexHLSL.c_str(),
+                                                                            rx::SHADER_VERTEX,
+                                                                            mTransformFeedbackLinkedVaryings,
+                                                                            (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
+                                                                            mVertexWorkarounds);
+
+    if (!vertexExecutable)
+    {
+        std::vector&lt;char&gt; tempCharBuffer(tempInfoLog.getLength()+3);
+        tempInfoLog.getLog(tempInfoLog.getLength(), NULL, &amp;tempCharBuffer[0]);
+        ERR(&quot;Error compiling dynamic vertex executable:\n%s\n&quot;, &amp;tempCharBuffer[0]);
+    }
+    else
+    {
+        mVertexExecutables.push_back(new VertexExecutable(mRenderer, inputLayout, vertexExecutable));
+    }
+
+    return vertexExecutable;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-rx::ShaderExecutable *ProgramBinary::getGeometryExecutable()
</del><ins>+rx::ShaderExecutable *ProgramBinary::getGeometryExecutable() const
</ins><span class="cx"> {
</span><span class="cx">     return mGeometryExecutable;
</span><span class="cx"> }
</span><span class="lines">@@ -227,144 +361,125 @@
</span><span class="cx"> 
</span><span class="cx"> GLint ProgramBinary::getUniformLocation(std::string name)
</span><span class="cx"> {
</span><del>-    unsigned int subscript = 0;
</del><ins>+    unsigned int subscript = ParseAndStripArrayIndex(&amp;name);
</ins><span class="cx"> 
</span><del>-    // Strip any trailing array operator and retrieve the subscript
-    size_t open = name.find_last_of('[');
-    size_t close = name.find_last_of(']');
-    if (open != std::string::npos &amp;&amp; close == name.length() - 1)
-    {
-        subscript = atoi(name.substr(open + 1).c_str());
-        name.erase(open);
-    }
-
</del><span class="cx">     unsigned int numUniforms = mUniformIndex.size();
</span><span class="cx">     for (unsigned int location = 0; location &lt; numUniforms; location++)
</span><span class="cx">     {
</span><del>-        if (mUniformIndex[location].name == name &amp;&amp;
-            mUniformIndex[location].element == subscript)
</del><ins>+        if (mUniformIndex[location].name == name)
</ins><span class="cx">         {
</span><del>-            return location;
</del><ins>+            const int index = mUniformIndex[location].index;
+            const bool isArray = mUniforms[index]-&gt;isArray();
+
+            if ((isArray &amp;&amp; mUniformIndex[location].element == subscript) || 
+                (subscript == GL_INVALID_INDEX))
+            {
+                return location;
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return -1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::setUniform1fv(GLint location, GLsizei count, const GLfloat* v)
</del><ins>+GLuint ProgramBinary::getUniformIndex(std::string name)
</ins><span class="cx"> {
</span><del>-    if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
</del><ins>+    unsigned int subscript = ParseAndStripArrayIndex(&amp;name);
+
+    // The app is not allowed to specify array indices other than 0 for arrays of basic types
+    if (subscript != 0 &amp;&amp; subscript != GL_INVALID_INDEX)
</ins><span class="cx">     {
</span><del>-        return false;
</del><ins>+        return GL_INVALID_INDEX;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
-    targetUniform-&gt;dirty = true;
-
-    int elementCount = targetUniform-&gt;elementCount();
-
-    if (elementCount == 1 &amp;&amp; count &gt; 1)
-        return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
-
-    count = std::min(elementCount - (int)mUniformIndex[location].element, count);
-
-    if (targetUniform-&gt;type == GL_FLOAT)
</del><ins>+    unsigned int numUniforms = mUniforms.size();
+    for (unsigned int index = 0; index &lt; numUniforms; index++)
</ins><span class="cx">     {
</span><del>-        GLfloat *target = (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
</del><ins>+        if (mUniforms[index]-&gt;name == name)
</ins><span class="cx">         {
</span><del>-            target[0] = v[0];
-            target[1] = 0;
-            target[2] = 0;
-            target[3] = 0;
-            target += 4;
-            v += 1;
</del><ins>+            if (mUniforms[index]-&gt;isArray() || subscript == GL_INVALID_INDEX)
+            {
+                return index;
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else if (targetUniform-&gt;type == GL_BOOL)
</del><ins>+
+    return GL_INVALID_INDEX;
+}
+
+GLuint ProgramBinary::getUniformBlockIndex(std::string name)
+{
+    unsigned int subscript = ParseAndStripArrayIndex(&amp;name);
+
+    unsigned int numUniformBlocks = mUniformBlocks.size();
+    for (unsigned int blockIndex = 0; blockIndex &lt; numUniformBlocks; blockIndex++)
</ins><span class="cx">     {
</span><del>-        GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
</del><ins>+        const UniformBlock &amp;uniformBlock = *mUniformBlocks[blockIndex];
+        if (uniformBlock.name == name)
</ins><span class="cx">         {
</span><del>-            boolParams[0] = (v[0] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams[1] = GL_FALSE;
-            boolParams[2] = GL_FALSE;
-            boolParams[3] = GL_FALSE;
-            boolParams += 4;
-            v += 1;
</del><ins>+            const bool arrayElementZero = (subscript == GL_INVALID_INDEX &amp;&amp; uniformBlock.elementIndex == 0);
+            if (subscript == uniformBlock.elementIndex || arrayElementZero)
+            {
+                return blockIndex;
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else
-    {
-        return false;
-    }
</del><span class="cx"> 
</span><del>-    return true;
</del><ins>+    return GL_INVALID_INDEX;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::setUniform2fv(GLint location, GLsizei count, const GLfloat *v)
</del><ins>+UniformBlock *ProgramBinary::getUniformBlockByIndex(GLuint blockIndex)
</ins><span class="cx"> {
</span><del>-    if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
-    {
-        return false;
-    }
</del><ins>+    ASSERT(blockIndex &lt; mUniformBlocks.size());
+    return mUniformBlocks[blockIndex];
+}
</ins><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
-    targetUniform-&gt;dirty = true;
</del><ins>+GLint ProgramBinary::getFragDataLocation(const char *name) const
+{
+    std::string baseName(name);
+    unsigned int arrayIndex;
+    arrayIndex = ParseAndStripArrayIndex(&amp;baseName);
</ins><span class="cx"> 
</span><del>-    int elementCount = targetUniform-&gt;elementCount();
-
-    if (elementCount == 1 &amp;&amp; count &gt; 1)
-        return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
-
-    count = std::min(elementCount - (int)mUniformIndex[location].element, count);
-
-    if (targetUniform-&gt;type == GL_FLOAT_VEC2)
</del><ins>+    for (auto locationIt = mOutputVariables.begin(); locationIt != mOutputVariables.end(); locationIt++)
</ins><span class="cx">     {
</span><del>-        GLfloat *target = (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</del><ins>+        const VariableLocation &amp;outputVariable = locationIt-&gt;second;
</ins><span class="cx"> 
</span><del>-        for (int i = 0; i &lt; count; i++)
</del><ins>+        if (outputVariable.name == baseName &amp;&amp; (arrayIndex == GL_INVALID_INDEX || arrayIndex == outputVariable.element))
</ins><span class="cx">         {
</span><del>-            target[0] = v[0];
-            target[1] = v[1];
-            target[2] = 0;
-            target[3] = 0;
-            target += 4;
-            v += 2;
</del><ins>+            return static_cast&lt;GLint&gt;(locationIt-&gt;first);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else if (targetUniform-&gt;type == GL_BOOL_VEC2)
-    {
-        GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</del><span class="cx"> 
</span><del>-        for (int i = 0; i &lt; count; i++)
-        {
-            boolParams[0] = (v[0] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams[1] = (v[1] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams[2] = GL_FALSE;
-            boolParams[3] = GL_FALSE;
-            boolParams += 4;
-            v += 2;
-        }
-    }
-    else 
-    {
-        return false;
-    }
</del><ins>+    return -1;
+}
</ins><span class="cx"> 
</span><del>-    return true;
</del><ins>+size_t ProgramBinary::getTransformFeedbackVaryingCount() const
+{
+    return mTransformFeedbackLinkedVaryings.size();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::setUniform3fv(GLint location, GLsizei count, const GLfloat *v)
</del><ins>+const LinkedVarying &amp;ProgramBinary::getTransformFeedbackVarying(size_t idx) const
</ins><span class="cx"> {
</span><ins>+    return mTransformFeedbackLinkedVaryings[idx];
+}
+
+GLenum ProgramBinary::getTransformFeedbackBufferMode() const
+{
+    return mTransformFeedbackBufferMode;
+}
+
+template &lt;typename T&gt;
+bool ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType)
+{
</ins><span class="cx">     if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
</span><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
</del><ins>+    const int components = UniformComponentCount(targetUniformType);
+    const GLenum targetBoolType = UniformBoolVectorType(targetUniformType);
+
+    LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
</ins><span class="cx">     targetUniform-&gt;dirty = true;
</span><span class="cx"> 
</span><span class="cx">     int elementCount = targetUniform-&gt;elementCount();
</span><span class="lines">@@ -374,35 +489,43 @@
</span><span class="cx"> 
</span><span class="cx">     count = std::min(elementCount - (int)mUniformIndex[location].element, count);
</span><span class="cx"> 
</span><del>-    if (targetUniform-&gt;type == GL_FLOAT_VEC3)
</del><ins>+    if (targetUniform-&gt;type == targetUniformType)
</ins><span class="cx">     {
</span><del>-        GLfloat *target = (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</del><ins>+        T *target = (T*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</ins><span class="cx"> 
</span><span class="cx">         for (int i = 0; i &lt; count; i++)
</span><span class="cx">         {
</span><del>-            target[0] = v[0];
-            target[1] = v[1];
-            target[2] = v[2];
-            target[3] = 0;
</del><ins>+            for (int c = 0; c &lt; components; c++)
+            {
+                target[c] = v[c];
+            }
+            for (int c = components; c &lt; 4; c++)
+            {
+                target[c] = 0;
+            }
</ins><span class="cx">             target += 4;
</span><del>-            v += 3;
</del><ins>+            v += components;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else if (targetUniform-&gt;type == GL_BOOL_VEC3)
</del><ins>+    else if (targetUniform-&gt;type == targetBoolType)
</ins><span class="cx">     {
</span><span class="cx">         GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</span><span class="cx"> 
</span><span class="cx">         for (int i = 0; i &lt; count; i++)
</span><span class="cx">         {
</span><del>-            boolParams[0] = (v[0] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams[1] = (v[1] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams[2] = (v[2] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams[3] = GL_FALSE;
</del><ins>+            for (int c = 0; c &lt; components; c++)
+            {
+                boolParams[c] = (v[c] == static_cast&lt;T&gt;(0)) ? GL_FALSE : GL_TRUE;
+            }
+            for (int c = components; c &lt; 4; c++)
+            {
+                boolParams[c] = GL_FALSE;
+            }
</ins><span class="cx">             boolParams += 4;
</span><del>-            v += 3;
</del><ins>+            v += components;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else 
</del><ins>+    else
</ins><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -410,101 +533,100 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
</del><ins>+bool ProgramBinary::setUniform1fv(GLint location, GLsizei count, const GLfloat* v)
</ins><span class="cx"> {
</span><del>-    if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
-    {
-        return false;
-    }
</del><ins>+    return setUniform(location, count, v, GL_FLOAT);
+}
</ins><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
-    targetUniform-&gt;dirty = true;
</del><ins>+bool ProgramBinary::setUniform2fv(GLint location, GLsizei count, const GLfloat *v)
+{
+    return setUniform(location, count, v, GL_FLOAT_VEC2);
+}
</ins><span class="cx"> 
</span><del>-    int elementCount = targetUniform-&gt;elementCount();
</del><ins>+bool ProgramBinary::setUniform3fv(GLint location, GLsizei count, const GLfloat *v)
+{
+    return setUniform(location, count, v, GL_FLOAT_VEC3);
+}
</ins><span class="cx"> 
</span><del>-    if (elementCount == 1 &amp;&amp; count &gt; 1)
-        return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
</del><ins>+bool ProgramBinary::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
+{
+    return setUniform(location, count, v, GL_FLOAT_VEC4);
+}
</ins><span class="cx"> 
</span><del>-    count = std::min(elementCount - (int)mUniformIndex[location].element, count);
</del><ins>+template&lt;typename T&gt;
+void transposeMatrix(T *target, const GLfloat *value, int targetWidth, int targetHeight, int srcWidth, int srcHeight)
+{
+    int copyWidth = std::min(targetHeight, srcWidth);
+    int copyHeight = std::min(targetWidth, srcHeight);
</ins><span class="cx"> 
</span><del>-    if (targetUniform-&gt;type == GL_FLOAT_VEC4)
</del><ins>+    for (int x = 0; x &lt; copyWidth; x++)
</ins><span class="cx">     {
</span><del>-        GLfloat *target = (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
</del><ins>+        for (int y = 0; y &lt; copyHeight; y++)
</ins><span class="cx">         {
</span><del>-            target[0] = v[0];
-            target[1] = v[1];
-            target[2] = v[2];
-            target[3] = v[3];
-            target += 4;
-            v += 4;
</del><ins>+            target[x * targetWidth + y] = static_cast&lt;T&gt;(value[y * srcWidth + x]);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else if (targetUniform-&gt;type == GL_BOOL_VEC4)
</del><ins>+    // clear unfilled right side
+    for (int y = 0; y &lt; copyWidth; y++)
</ins><span class="cx">     {
</span><del>-        GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
</del><ins>+        for (int x = copyHeight; x &lt; targetWidth; x++)
</ins><span class="cx">         {
</span><del>-            boolParams[0] = (v[0] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams[1] = (v[1] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams[2] = (v[2] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams[3] = (v[3] == 0.0f) ? GL_FALSE : GL_TRUE;
-            boolParams += 4;
-            v += 4;
</del><ins>+            target[y * targetWidth + x] = static_cast&lt;T&gt;(0);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else 
</del><ins>+    // clear unfilled bottom.
+    for (int y = copyWidth; y &lt; targetHeight; y++)
</ins><span class="cx">     {
</span><del>-        return false;
</del><ins>+        for (int x = 0; x &lt; targetWidth; x++)
+        {
+            target[y * targetWidth + x] = static_cast&lt;T&gt;(0);
+        }
</ins><span class="cx">     }
</span><del>-
-    return true;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-template&lt;typename T, int targetWidth, int targetHeight, int srcWidth, int srcHeight&gt;
-void transposeMatrix(T *target, const GLfloat *value)
</del><ins>+template&lt;typename T&gt;
+void expandMatrix(T *target, const GLfloat *value, int targetWidth, int targetHeight, int srcWidth, int srcHeight)
</ins><span class="cx"> {
</span><span class="cx">     int copyWidth = std::min(targetWidth, srcWidth);
</span><span class="cx">     int copyHeight = std::min(targetHeight, srcHeight);
</span><span class="cx"> 
</span><del>-    for (int x = 0; x &lt; copyWidth; x++)
</del><ins>+    for (int y = 0; y &lt; copyHeight; y++)
</ins><span class="cx">     {
</span><del>-        for (int y = 0; y &lt; copyHeight; y++)
</del><ins>+        for (int x = 0; x &lt; copyWidth; x++)
</ins><span class="cx">         {
</span><del>-            target[x * targetWidth + y] = (T)value[y * srcWidth + x];
</del><ins>+            target[y * targetWidth + x] = static_cast&lt;T&gt;(value[y * srcWidth + x]);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     // clear unfilled right side
</span><span class="cx">     for (int y = 0; y &lt; copyHeight; y++)
</span><span class="cx">     {
</span><del>-        for (int x = srcWidth; x &lt; targetWidth; x++)
</del><ins>+        for (int x = copyWidth; x &lt; targetWidth; x++)
</ins><span class="cx">         {
</span><del>-            target[y * targetWidth + x] = (T)0;
</del><ins>+            target[y * targetWidth + x] = static_cast&lt;T&gt;(0);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     // clear unfilled bottom.
</span><del>-    for (int y = srcHeight; y &lt; targetHeight; y++)
</del><ins>+    for (int y = copyHeight; y &lt; targetHeight; y++)
</ins><span class="cx">     {
</span><span class="cx">         for (int x = 0; x &lt; targetWidth; x++)
</span><span class="cx">         {
</span><del>-            target[y * targetWidth + x] = (T)0;
</del><ins>+            target[y * targetWidth + x] = static_cast&lt;T&gt;(0);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::setUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value)
</del><ins>+template &lt;int cols, int rows&gt;
+bool ProgramBinary::setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType) 
</ins><span class="cx"> {
</span><span class="cx">     if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
</span><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
</del><ins>+    LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
</ins><span class="cx">     targetUniform-&gt;dirty = true;
</span><span class="cx"> 
</span><del>-    if (targetUniform-&gt;type != GL_FLOAT_MAT2)
</del><ins>+    if (targetUniform-&gt;type != targetUniformType)
</ins><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -515,83 +637,70 @@
</span><span class="cx">         return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
</span><span class="cx"> 
</span><span class="cx">     count = std::min(elementCount - (int)mUniformIndex[location].element, count);
</span><del>-    GLfloat *target = (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 8;
</del><ins>+    const unsigned int targetMatrixStride = (4 * rows);
+    GLfloat *target = (GLfloat*)(targetUniform-&gt;data + mUniformIndex[location].element * sizeof(GLfloat) * targetMatrixStride);
</ins><span class="cx"> 
</span><span class="cx">     for (int i = 0; i &lt; count; i++)
</span><span class="cx">     {
</span><del>-        transposeMatrix&lt;GLfloat,4,2,2,2&gt;(target, value);
-        target += 8;
-        value += 4;
</del><ins>+        // Internally store matrices as transposed versions to accomodate HLSL matrix indexing
+        if (transpose == GL_FALSE)
+        {
+            transposeMatrix&lt;GLfloat&gt;(target, value, 4, rows, rows, cols);
+        }
+        else
+        {
+            expandMatrix&lt;GLfloat&gt;(target, value, 4, rows, cols, rows);
+        }
+        target += targetMatrixStride;
+        value += cols * rows;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::setUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value)
</del><ins>+bool ProgramBinary::setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
</ins><span class="cx"> {
</span><del>-    if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
-    {
-        return false;
-    }
</del><ins>+    return setUniformMatrixfv&lt;2, 2&gt;(location, count, transpose, value, GL_FLOAT_MAT2);
+}
</ins><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
-    targetUniform-&gt;dirty = true;
</del><ins>+bool ProgramBinary::setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+    return setUniformMatrixfv&lt;3, 3&gt;(location, count, transpose, value, GL_FLOAT_MAT3);
+}
</ins><span class="cx"> 
</span><del>-    if (targetUniform-&gt;type != GL_FLOAT_MAT3)
-    {
-        return false;
-    }
</del><ins>+bool ProgramBinary::setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+    return setUniformMatrixfv&lt;4, 4&gt;(location, count, transpose, value, GL_FLOAT_MAT4);
+}
</ins><span class="cx"> 
</span><del>-    int elementCount = targetUniform-&gt;elementCount();
</del><ins>+bool ProgramBinary::setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+    return setUniformMatrixfv&lt;2, 3&gt;(location, count, transpose, value, GL_FLOAT_MAT2x3);
+}
</ins><span class="cx"> 
</span><del>-    if (elementCount == 1 &amp;&amp; count &gt; 1)
-        return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
</del><ins>+bool ProgramBinary::setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+    return setUniformMatrixfv&lt;3, 2&gt;(location, count, transpose, value, GL_FLOAT_MAT3x2);
+}
</ins><span class="cx"> 
</span><del>-    count = std::min(elementCount - (int)mUniformIndex[location].element, count);
-    GLfloat *target = (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 12;
</del><ins>+bool ProgramBinary::setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+    return setUniformMatrixfv&lt;2, 4&gt;(location, count, transpose, value, GL_FLOAT_MAT2x4);
+}
</ins><span class="cx"> 
</span><del>-    for (int i = 0; i &lt; count; i++)
-    {
-        transposeMatrix&lt;GLfloat,4,3,3,3&gt;(target, value);
-        target += 12;
-        value += 9;
-    }
</del><ins>+bool ProgramBinary::setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+    return setUniformMatrixfv&lt;4, 2&gt;(location, count, transpose, value, GL_FLOAT_MAT4x2);
+}
</ins><span class="cx"> 
</span><del>-    return true;
</del><ins>+bool ProgramBinary::setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+    return setUniformMatrixfv&lt;3, 4&gt;(location, count, transpose, value, GL_FLOAT_MAT3x4);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
-bool ProgramBinary::setUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value)
</del><ins>+bool ProgramBinary::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
</ins><span class="cx"> {
</span><del>-    if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
-    {
-        return false;
-    }
-
-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
-    targetUniform-&gt;dirty = true;
-
-    if (targetUniform-&gt;type != GL_FLOAT_MAT4)
-    {
-        return false;
-    }
-
-    int elementCount = targetUniform-&gt;elementCount();
-
-    if (elementCount == 1 &amp;&amp; count &gt; 1)
-        return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
-
-    count = std::min(elementCount - (int)mUniformIndex[location].element, count);
-    GLfloat *target = (GLfloat*)(targetUniform-&gt;data + mUniformIndex[location].element * sizeof(GLfloat) * 16);
-
-    for (int i = 0; i &lt; count; i++)
-    {
-        transposeMatrix&lt;GLfloat,4,4,4,4&gt;(target, value);
-        target += 16;
-        value += 16;
-    }
-
-    return true;
</del><ins>+    return setUniformMatrixfv&lt;4, 3&gt;(location, count, transpose, value, GL_FLOAT_MAT4x3);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ProgramBinary::setUniform1iv(GLint location, GLsizei count, const GLint *v)
</span><span class="lines">@@ -601,7 +710,7 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
</del><ins>+    LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
</ins><span class="cx">     targetUniform-&gt;dirty = true;
</span><span class="cx"> 
</span><span class="cx">     int elementCount = targetUniform-&gt;elementCount();
</span><span class="lines">@@ -611,9 +720,7 @@
</span><span class="cx"> 
</span><span class="cx">     count = std::min(elementCount - (int)mUniformIndex[location].element, count);
</span><span class="cx"> 
</span><del>-    if (targetUniform-&gt;type == GL_INT ||
-        targetUniform-&gt;type == GL_SAMPLER_2D ||
-        targetUniform-&gt;type == GL_SAMPLER_CUBE)
</del><ins>+    if (targetUniform-&gt;type == GL_INT || IsSampler(targetUniform-&gt;type))
</ins><span class="cx">     {
</span><span class="cx">         GLint *target = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</span><span class="cx"> 
</span><span class="lines">@@ -651,171 +758,48 @@
</span><span class="cx"> 
</span><span class="cx"> bool ProgramBinary::setUniform2iv(GLint location, GLsizei count, const GLint *v)
</span><span class="cx"> {
</span><del>-    if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
-    {
-        return false;
-    }
-
-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
-    targetUniform-&gt;dirty = true;
-
-    int elementCount = targetUniform-&gt;elementCount();
-
-    if (elementCount == 1 &amp;&amp; count &gt; 1)
-        return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
-
-    count = std::min(elementCount - (int)mUniformIndex[location].element, count);
-
-    if (targetUniform-&gt;type == GL_INT_VEC2)
-    {
-        GLint *target = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
-        {
-            target[0] = v[0];
-            target[1] = v[1];
-            target[2] = 0;
-            target[3] = 0;
-            target += 4;
-            v += 2;
-        }
-    }
-    else if (targetUniform-&gt;type == GL_BOOL_VEC2)
-    {
-        GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
-        {
-            boolParams[0] = (v[0] == 0) ? GL_FALSE : GL_TRUE;
-            boolParams[1] = (v[1] == 0) ? GL_FALSE : GL_TRUE;
-            boolParams[2] = GL_FALSE;
-            boolParams[3] = GL_FALSE;
-            boolParams += 4;
-            v += 2;
-        }
-    }
-    else
-    {
-        return false;
-    }
-
-    return true;
</del><ins>+    return setUniform(location, count, v, GL_INT_VEC2);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ProgramBinary::setUniform3iv(GLint location, GLsizei count, const GLint *v)
</span><span class="cx"> {
</span><del>-    if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
-    {
-        return false;
-    }
-
-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
-    targetUniform-&gt;dirty = true;
-
-    int elementCount = targetUniform-&gt;elementCount();
-
-    if (elementCount == 1 &amp;&amp; count &gt; 1)
-        return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
-
-    count = std::min(elementCount - (int)mUniformIndex[location].element, count);
-
-    if (targetUniform-&gt;type == GL_INT_VEC3)
-    {
-        GLint *target = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
-        {
-            target[0] = v[0];
-            target[1] = v[1];
-            target[2] = v[2];
-            target[3] = 0;
-            target += 4;
-            v += 3;
-        }
-    }
-    else if (targetUniform-&gt;type == GL_BOOL_VEC3)
-    {
-        GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
-        {
-            boolParams[0] = (v[0] == 0) ? GL_FALSE : GL_TRUE;
-            boolParams[1] = (v[1] == 0) ? GL_FALSE : GL_TRUE;
-            boolParams[2] = (v[2] == 0) ? GL_FALSE : GL_TRUE;
-            boolParams[3] = GL_FALSE;
-            boolParams += 4;
-            v += 3;
-        }
-    }
-    else
-    {
-        return false;
-    }
-
-    return true;
</del><ins>+    return setUniform(location, count, v, GL_INT_VEC3);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ProgramBinary::setUniform4iv(GLint location, GLsizei count, const GLint *v)
</span><span class="cx"> {
</span><del>-    if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
-    {
-        return false;
-    }
</del><ins>+    return setUniform(location, count, v, GL_INT_VEC4);
+}
</ins><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
-    targetUniform-&gt;dirty = true;
</del><ins>+bool ProgramBinary::setUniform1uiv(GLint location, GLsizei count, const GLuint *v)
+{
+    return setUniform(location, count, v, GL_UNSIGNED_INT);
+}
</ins><span class="cx"> 
</span><del>-    int elementCount = targetUniform-&gt;elementCount();
</del><ins>+bool ProgramBinary::setUniform2uiv(GLint location, GLsizei count, const GLuint *v)
+{
+    return setUniform(location, count, v, GL_UNSIGNED_INT_VEC2);
+}
</ins><span class="cx"> 
</span><del>-    if (elementCount == 1 &amp;&amp; count &gt; 1)
-        return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
</del><ins>+bool ProgramBinary::setUniform3uiv(GLint location, GLsizei count, const GLuint *v)
+{
+    return setUniform(location, count, v, GL_UNSIGNED_INT_VEC3);
+}
</ins><span class="cx"> 
</span><del>-    count = std::min(elementCount - (int)mUniformIndex[location].element, count);
-
-    if (targetUniform-&gt;type == GL_INT_VEC4)
-    {
-        GLint *target = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
-        {
-            target[0] = v[0];
-            target[1] = v[1];
-            target[2] = v[2];
-            target[3] = v[3];
-            target += 4;
-            v += 4;
-        }
-    }
-    else if (targetUniform-&gt;type == GL_BOOL_VEC4)
-    {
-        GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-        for (int i = 0; i &lt; count; i++)
-        {
-            boolParams[0] = (v[0] == 0) ? GL_FALSE : GL_TRUE;
-            boolParams[1] = (v[1] == 0) ? GL_FALSE : GL_TRUE;
-            boolParams[2] = (v[2] == 0) ? GL_FALSE : GL_TRUE;
-            boolParams[3] = (v[3] == 0) ? GL_FALSE : GL_TRUE;
-            boolParams += 4;
-            v += 4;
-        }
-    }
-    else
-    {
-        return false;
-    }
-
-    return true;
</del><ins>+bool ProgramBinary::setUniform4uiv(GLint location, GLsizei count, const GLuint *v)
+{
+    return setUniform(location, count, v, GL_UNSIGNED_INT_VEC4);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::getUniformfv(GLint location, GLsizei *bufSize, GLfloat *params)
</del><ins>+template &lt;typename T&gt;
+bool ProgramBinary::getUniformv(GLint location, GLsizei *bufSize, T *params, GLenum uniformType)
</ins><span class="cx"> {
</span><span class="cx">     if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
</span><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
</del><ins>+    LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
</ins><span class="cx"> 
</span><span class="cx">     // sized queries -- ensure the provided buffer is large enough
</span><span class="cx">     if (bufSize)
</span><span class="lines">@@ -827,123 +811,89 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    switch (targetUniform-&gt;type)
</del><ins>+    if (IsMatrixType(targetUniform-&gt;type))
</ins><span class="cx">     {
</span><del>-      case GL_FLOAT_MAT2:
-        transposeMatrix&lt;GLfloat,2,2,4,2&gt;(params, (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 8);
-        break;
-      case GL_FLOAT_MAT3:
-        transposeMatrix&lt;GLfloat,3,3,4,3&gt;(params, (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 12);
-        break;
-      case GL_FLOAT_MAT4:
-        transposeMatrix&lt;GLfloat,4,4,4,4&gt;(params, (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 16);
-        break;
-      default:
</del><ins>+        const int rows = VariableRowCount(targetUniform-&gt;type);
+        const int cols = VariableColumnCount(targetUniform-&gt;type);
+        transposeMatrix(params, (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 4 * rows, rows, cols, 4, rows);
+    }
+    else if (uniformType == UniformComponentType(targetUniform-&gt;type))
+    {
+        unsigned int size = UniformComponentCount(targetUniform-&gt;type);
+        memcpy(params, targetUniform-&gt;data + mUniformIndex[location].element * 4 * sizeof(T),
+                size * sizeof(T));
+    }
+    else
+    {
+        unsigned int size = UniformComponentCount(targetUniform-&gt;type);
+        switch (UniformComponentType(targetUniform-&gt;type))
</ins><span class="cx">         {
</span><del>-            unsigned int size = UniformComponentCount(targetUniform-&gt;type);
-
-            switch (UniformComponentType(targetUniform-&gt;type))
</del><ins>+          case GL_BOOL:
</ins><span class="cx">             {
</span><del>-              case GL_BOOL:
-                {
-                    GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</del><ins>+                GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</ins><span class="cx"> 
</span><del>-                    for (unsigned int i = 0; i &lt; size; i++)
-                    {
-                        params[i] = (boolParams[i] == GL_FALSE) ? 0.0f : 1.0f;
-                    }
-                }
-                break;
-              case GL_FLOAT:
-                memcpy(params, targetUniform-&gt;data + mUniformIndex[location].element * 4 * sizeof(GLfloat),
-                       size * sizeof(GLfloat));
-                break;
-              case GL_INT:
</del><ins>+                for (unsigned int i = 0; i &lt; size; i++)
</ins><span class="cx">                 {
</span><del>-                    GLint *intParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-                    for (unsigned int i = 0; i &lt; size; i++)
-                    {
-                        params[i] = (float)intParams[i];
-                    }
</del><ins>+                    params[i] = (boolParams[i] == GL_FALSE) ? static_cast&lt;T&gt;(0) : static_cast&lt;T&gt;(1);
</ins><span class="cx">                 }
</span><del>-                break;
-              default: UNREACHABLE();
</del><span class="cx">             }
</span><del>-        }
-    }
</del><ins>+            break;
</ins><span class="cx"> 
</span><del>-    return true;
-}
</del><ins>+          case GL_FLOAT:
+            {
+                GLfloat *floatParams = (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</ins><span class="cx"> 
</span><del>-bool ProgramBinary::getUniformiv(GLint location, GLsizei *bufSize, GLint *params)
-{
-    if (location &lt; 0 || location &gt;= (int)mUniformIndex.size())
-    {
-        return false;
-    }
</del><ins>+                for (unsigned int i = 0; i &lt; size; i++)
+                {
+                    params[i] = static_cast&lt;T&gt;(floatParams[i]);
+                }
+            }
+            break;
</ins><span class="cx"> 
</span><del>-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
</del><ins>+          case GL_INT:
+            {
+                GLint *intParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</ins><span class="cx"> 
</span><del>-    // sized queries -- ensure the provided buffer is large enough
-    if (bufSize)
-    {
-        int requiredBytes = UniformExternalSize(targetUniform-&gt;type);
-        if (*bufSize &lt; requiredBytes)
-        {
-            return false;
-        }
-    }
-
-    switch (targetUniform-&gt;type)
-    {
-      case GL_FLOAT_MAT2:
-        transposeMatrix&lt;GLint,2,2,4,2&gt;(params, (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 8);
-        break;
-      case GL_FLOAT_MAT3:
-        transposeMatrix&lt;GLint,3,3,4,3&gt;(params, (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 12);
-        break;
-      case GL_FLOAT_MAT4:
-        transposeMatrix&lt;GLint,4,4,4,4&gt;(params, (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 16);
-        break;
-      default:
-        {
-            unsigned int size = VariableColumnCount(targetUniform-&gt;type);
-
-            switch (UniformComponentType(targetUniform-&gt;type))
</del><ins>+                for (unsigned int i = 0; i &lt; size; i++)
+                {
+                    params[i] = static_cast&lt;T&gt;(intParams[i]);
+                }
+            }
+            break;
+       
+          case GL_UNSIGNED_INT:
</ins><span class="cx">             {
</span><del>-              case GL_BOOL:
-                {
-                    GLint *boolParams = (GLint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</del><ins>+                GLuint *uintParams = (GLuint*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
</ins><span class="cx"> 
</span><del>-                    for (unsigned int i = 0; i &lt; size; i++)
-                    {
-                        params[i] = boolParams[i];
-                    }
-                }
-                break;
-              case GL_FLOAT:
</del><ins>+                for (unsigned int i = 0; i &lt; size; i++)
</ins><span class="cx">                 {
</span><del>-                    GLfloat *floatParams = (GLfloat*)targetUniform-&gt;data + mUniformIndex[location].element * 4;
-
-                    for (unsigned int i = 0; i &lt; size; i++)
-                    {
-                        params[i] = (GLint)floatParams[i];
-                    }
</del><ins>+                    params[i] = static_cast&lt;T&gt;(uintParams[i]);
</ins><span class="cx">                 }
</span><del>-                break;
-              case GL_INT:
-                memcpy(params, targetUniform-&gt;data + mUniformIndex[location].element * 4 * sizeof(GLint),
-                    size * sizeof(GLint));
-                break;
-              default: UNREACHABLE();
</del><span class="cx">             }
</span><ins>+            break;
+          
+          default: UNREACHABLE();
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool ProgramBinary::getUniformfv(GLint location, GLsizei *bufSize, GLfloat *params)
+{
+    return getUniformv(location, bufSize, params, GL_FLOAT);
+}
+
+bool ProgramBinary::getUniformiv(GLint location, GLsizei *bufSize, GLint *params)
+{
+    return getUniformv(location, bufSize, params, GL_INT);
+}
+
+bool ProgramBinary::getUniformuiv(GLint location, GLsizei *bufSize, GLuint *params)
+{
+    return getUniformv(location, bufSize, params, GL_UNSIGNED_INT);
+}
+
</ins><span class="cx"> void ProgramBinary::dirtyAllUniforms()
</span><span class="cx"> {
</span><span class="cx">     unsigned int numUniforms = mUniforms.size();
</span><span class="lines">@@ -957,19 +907,18 @@
</span><span class="cx"> void ProgramBinary::applyUniforms()
</span><span class="cx"> {
</span><span class="cx">     // Retrieve sampler uniform values
</span><del>-    for (std::vector&lt;Uniform*&gt;::iterator ub = mUniforms.begin(), ue = mUniforms.end(); ub != ue; ++ub)
</del><ins>+    for (size_t uniformIndex = 0; uniformIndex &lt; mUniforms.size(); uniformIndex++)
</ins><span class="cx">     {
</span><del>-        Uniform *targetUniform = *ub;
</del><ins>+        LinkedUniform *targetUniform = mUniforms[uniformIndex];
</ins><span class="cx"> 
</span><span class="cx">         if (targetUniform-&gt;dirty)
</span><span class="cx">         {
</span><del>-            if (targetUniform-&gt;type == GL_SAMPLER_2D || 
-                targetUniform-&gt;type == GL_SAMPLER_CUBE)
</del><ins>+            if (IsSampler(targetUniform-&gt;type))
</ins><span class="cx">             {
</span><span class="cx">                 int count = targetUniform-&gt;elementCount();
</span><span class="cx">                 GLint (*v)[4] = (GLint(*)[4])targetUniform-&gt;data;
</span><span class="cx"> 
</span><del>-                if (targetUniform-&gt;psRegisterIndex &gt;= 0)
</del><ins>+                if (targetUniform-&gt;isReferencedByFragmentShader())
</ins><span class="cx">                 {
</span><span class="cx">                     unsigned int firstIndex = targetUniform-&gt;psRegisterIndex;
</span><span class="cx"> 
</span><span class="lines">@@ -985,7 +934,7 @@
</span><span class="cx">                     }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if (targetUniform-&gt;vsRegisterIndex &gt;= 0)
</del><ins>+                if (targetUniform-&gt;isReferencedByVertexShader())
</ins><span class="cx">                 {
</span><span class="cx">                     unsigned int firstIndex = targetUniform-&gt;vsRegisterIndex;
</span><span class="cx"> 
</span><span class="lines">@@ -1004,214 +953,81 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mRenderer-&gt;applyUniforms(this, &amp;mUniforms);
</del><ins>+    mRenderer-&gt;applyUniforms(*this);
+
+    for (size_t uniformIndex = 0; uniformIndex &lt; mUniforms.size(); uniformIndex++)
+    {
+        mUniforms[uniformIndex]-&gt;dirty = false;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Packs varyings into generic varying registers, using the algorithm from [OpenGL ES Shading Language 1.00 rev. 17] appendix A section 7 page 111
-// Returns the number of used varying registers, or -1 if unsuccesful
-int ProgramBinary::packVaryings(InfoLog &amp;infoLog, const Varying *packing[][4], FragmentShader *fragmentShader)
</del><ins>+bool ProgramBinary::applyUniformBuffers(const std::vector&lt;gl::Buffer*&gt; boundBuffers)
</ins><span class="cx"> {
</span><del>-    const int maxVaryingVectors = mRenderer-&gt;getMaxVaryingVectors();
</del><ins>+    const gl::Buffer *vertexUniformBuffers[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS] = {NULL};
+    const gl::Buffer *fragmentUniformBuffers[gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS] = {NULL};
</ins><span class="cx"> 
</span><del>-    fragmentShader-&gt;resetVaryingsRegisterAssignment();
</del><ins>+    const unsigned int reservedBuffersInVS = mRenderer-&gt;getReservedVertexUniformBuffers();
+    const unsigned int reservedBuffersInFS = mRenderer-&gt;getReservedFragmentUniformBuffers();
</ins><span class="cx"> 
</span><del>-    for (VaryingList::iterator varying = fragmentShader-&gt;mVaryings.begin(); varying != fragmentShader-&gt;mVaryings.end(); varying++)
</del><ins>+    ASSERT(boundBuffers.size() == mUniformBlocks.size());
+
+    for (unsigned int uniformBlockIndex = 0; uniformBlockIndex &lt; mUniformBlocks.size(); uniformBlockIndex++)
</ins><span class="cx">     {
</span><del>-        int n = VariableRowCount(varying-&gt;type) * varying-&gt;size;
-        int m = VariableColumnCount(varying-&gt;type);
-        bool success = false;
</del><ins>+        gl::UniformBlock *uniformBlock = getUniformBlockByIndex(uniformBlockIndex);
+        gl::Buffer *uniformBuffer = boundBuffers[uniformBlockIndex];
</ins><span class="cx"> 
</span><del>-        if (m == 2 || m == 3 || m == 4)
</del><ins>+        ASSERT(uniformBlock &amp;&amp; uniformBuffer);
+
+        if (uniformBuffer-&gt;size() &lt; uniformBlock-&gt;dataSize)
</ins><span class="cx">         {
</span><del>-            for (int r = 0; r &lt;= maxVaryingVectors - n &amp;&amp; !success; r++)
-            {
-                bool available = true;
-
-                for (int y = 0; y &lt; n &amp;&amp; available; y++)
-                {
-                    for (int x = 0; x &lt; m &amp;&amp; available; x++)
-                    {
-                        if (packing[r + y][x])
-                        {
-                            available = false;
-                        }
-                    }
-                }
-
-                if (available)
-                {
-                    varying-&gt;reg = r;
-                    varying-&gt;col = 0;
-
-                    for (int y = 0; y &lt; n; y++)
-                    {
-                        for (int x = 0; x &lt; m; x++)
-                        {
-                            packing[r + y][x] = &amp;*varying;
-                        }
-                    }
-
-                    success = true;
-                }
-            }
-
-            if (!success &amp;&amp; m == 2)
-            {
-                for (int r = maxVaryingVectors - n; r &gt;= 0 &amp;&amp; !success; r--)
-                {
-                    bool available = true;
-
-                    for (int y = 0; y &lt; n &amp;&amp; available; y++)
-                    {
-                        for (int x = 2; x &lt; 4 &amp;&amp; available; x++)
-                        {
-                            if (packing[r + y][x])
-                            {
-                                available = false;
-                            }
-                        }
-                    }
-
-                    if (available)
-                    {
-                        varying-&gt;reg = r;
-                        varying-&gt;col = 2;
-
-                        for (int y = 0; y &lt; n; y++)
-                        {
-                            for (int x = 2; x &lt; 4; x++)
-                            {
-                                packing[r + y][x] = &amp;*varying;
-                            }
-                        }
-
-                        success = true;
-                    }
-                }
-            }
</del><ins>+            // undefined behaviour
+            return false;
</ins><span class="cx">         }
</span><del>-        else if (m == 1)
-        {
-            int space[4] = {0};
</del><span class="cx"> 
</span><del>-            for (int y = 0; y &lt; maxVaryingVectors; y++)
-            {
-                for (int x = 0; x &lt; 4; x++)
-                {
-                    space[x] += packing[y][x] ? 0 : 1;
-                }
-            }
</del><ins>+        ASSERT(uniformBlock-&gt;isReferencedByVertexShader() || uniformBlock-&gt;isReferencedByFragmentShader());
</ins><span class="cx"> 
</span><del>-            int column = 0;
-
-            for (int x = 0; x &lt; 4; x++)
-            {
-                if (space[x] &gt;= n &amp;&amp; space[x] &lt; space[column])
-                {
-                    column = x;
-                }
-            }
-
-            if (space[column] &gt;= n)
-            {
-                for (int r = 0; r &lt; maxVaryingVectors; r++)
-                {
-                    if (!packing[r][column])
-                    {
-                        varying-&gt;reg = r;
-
-                        for (int y = r; y &lt; r + n; y++)
-                        {
-                            packing[y][column] = &amp;*varying;
-                        }
-
-                        break;
-                    }
-                }
-
-                varying-&gt;col = column;
-
-                success = true;
-            }
-        }
-        else UNREACHABLE();
-
-        if (!success)
</del><ins>+        if (uniformBlock-&gt;isReferencedByVertexShader())
</ins><span class="cx">         {
</span><del>-            infoLog.append(&quot;Could not pack varying %s&quot;, varying-&gt;name.c_str());
-
-            return -1;
</del><ins>+            unsigned int registerIndex = uniformBlock-&gt;vsRegisterIndex - reservedBuffersInVS;
+            ASSERT(vertexUniformBuffers[registerIndex] == NULL);
+            ASSERT(registerIndex &lt; mRenderer-&gt;getMaxVertexShaderUniformBuffers());
+            vertexUniformBuffers[registerIndex] = uniformBuffer;
</ins><span class="cx">         }
</span><del>-    }
</del><span class="cx"> 
</span><del>-    // Return the number of used registers
-    int registers = 0;
-
-    for (int r = 0; r &lt; maxVaryingVectors; r++)
-    {
-        if (packing[r][0] || packing[r][1] || packing[r][2] || packing[r][3])
</del><ins>+        if (uniformBlock-&gt;isReferencedByFragmentShader())
</ins><span class="cx">         {
</span><del>-            registers++;
</del><ins>+            unsigned int registerIndex = uniformBlock-&gt;psRegisterIndex - reservedBuffersInFS;
+            ASSERT(fragmentUniformBuffers[registerIndex] == NULL);
+            ASSERT(registerIndex &lt; mRenderer-&gt;getMaxFragmentShaderUniformBuffers());
+            fragmentUniformBuffers[registerIndex] = uniformBuffer;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return registers;
</del><ins>+    return mRenderer-&gt;setUniformBuffers(vertexUniformBuffers, fragmentUniformBuffers);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::linkVaryings(InfoLog &amp;infoLog, int registers, const Varying *packing[][4],
-                                 std::string&amp; pixelHLSL, std::string&amp; vertexHLSL,
-                                 FragmentShader *fragmentShader, VertexShader *vertexShader)
</del><ins>+bool ProgramBinary::linkVaryings(InfoLog &amp;infoLog, FragmentShader *fragmentShader, VertexShader *vertexShader)
</ins><span class="cx"> {
</span><del>-    if (pixelHLSL.empty() || vertexHLSL.empty())
-    {
-        return false;
-    }
</del><ins>+    std::vector&lt;gl::Varying&gt; &amp;fragmentVaryings = fragmentShader-&gt;getVaryings();
+    std::vector&lt;gl::Varying&gt; &amp;vertexVaryings = vertexShader-&gt;getVaryings();
</ins><span class="cx"> 
</span><del>-    bool usesMRT = fragmentShader-&gt;mUsesMultipleRenderTargets;
-    bool usesFragColor = fragmentShader-&gt;mUsesFragColor;
-    bool usesFragData = fragmentShader-&gt;mUsesFragData;
-    if (usesFragColor &amp;&amp; usesFragData)
</del><ins>+    for (size_t fragVaryingIndex = 0; fragVaryingIndex &lt; fragmentVaryings.size(); fragVaryingIndex++)
</ins><span class="cx">     {
</span><del>-        infoLog.append(&quot;Cannot use both gl_FragColor and gl_FragData in the same fragment shader.&quot;);
-        return false;
-    }
-
-    // Write the HLSL input/output declarations
-    const int shaderModel = mRenderer-&gt;getMajorShaderModel();
-    const int maxVaryingVectors = mRenderer-&gt;getMaxVaryingVectors();
-
-    const int registersNeeded = registers + (fragmentShader-&gt;mUsesFragCoord ? 1 : 0) + (fragmentShader-&gt;mUsesPointCoord ? 1 : 0);
-
-    // The output color is broadcast to all enabled draw buffers when writing to gl_FragColor 
-    const bool broadcast = fragmentShader-&gt;mUsesFragColor;
-    const unsigned int numRenderTargets = (broadcast || usesMRT ? mRenderer-&gt;getMaxRenderTargets() : 1);
-
-    if (registersNeeded &gt; maxVaryingVectors)
-    {
-        infoLog.append(&quot;No varying registers left to support gl_FragCoord/gl_PointCoord&quot;);
-
-        return false;
-    }
-
-    vertexShader-&gt;resetVaryingsRegisterAssignment();
-
-    for (VaryingList::iterator input = fragmentShader-&gt;mVaryings.begin(); input != fragmentShader-&gt;mVaryings.end(); input++)
-    {
</del><ins>+        gl::Varying *input = &amp;fragmentVaryings[fragVaryingIndex];
</ins><span class="cx">         bool matched = false;
</span><span class="cx"> 
</span><del>-        for (VaryingList::iterator output = vertexShader-&gt;mVaryings.begin(); output != vertexShader-&gt;mVaryings.end(); output++)
</del><ins>+        for (size_t vertVaryingIndex = 0; vertVaryingIndex &lt; vertexVaryings.size(); vertVaryingIndex++)
</ins><span class="cx">         {
</span><ins>+            gl::Varying *output = &amp;vertexVaryings[vertVaryingIndex];
</ins><span class="cx">             if (output-&gt;name == input-&gt;name)
</span><span class="cx">             {
</span><del>-                if (output-&gt;type != input-&gt;type || output-&gt;size != input-&gt;size)
</del><ins>+                if (!linkValidateVariables(infoLog, output-&gt;name, *input, *output))
</ins><span class="cx">                 {
</span><del>-                    infoLog.append(&quot;Type of vertex varying %s does not match that of the fragment varying&quot;, output-&gt;name.c_str());
-
</del><span class="cx">                     return false;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                output-&gt;reg = input-&gt;reg;
-                output-&gt;col = input-&gt;col;
</del><ins>+                output-&gt;registerIndex = input-&gt;registerIndex;
+                output-&gt;elementIndex = input-&gt;elementIndex;
</ins><span class="cx"> 
</span><span class="cx">                 matched = true;
</span><span class="cx">                 break;
</span><span class="lines">@@ -1221,397 +1037,10 @@
</span><span class="cx">         if (!matched)
</span><span class="cx">         {
</span><span class="cx">             infoLog.append(&quot;Fragment varying %s does not match any vertex varying&quot;, input-&gt;name.c_str());
</span><del>-
</del><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mUsesPointSize = vertexShader-&gt;mUsesPointSize;
-    std::string varyingSemantic = (mUsesPointSize &amp;&amp; shaderModel == 3) ? &quot;COLOR&quot; : &quot;TEXCOORD&quot;;
-    std::string targetSemantic = (shaderModel &gt;= 4) ? &quot;SV_Target&quot; : &quot;COLOR&quot;;
-    std::string positionSemantic = (shaderModel &gt;= 4) ? &quot;SV_Position&quot; : &quot;POSITION&quot;;
-    std::string depthSemantic = (shaderModel &gt;= 4) ? &quot;SV_Depth&quot; : &quot;DEPTH&quot;;
-
-    // special varyings that use reserved registers
-    int reservedRegisterIndex = registers;
-    std::string fragCoordSemantic;
-    std::string pointCoordSemantic;
-
-    if (fragmentShader-&gt;mUsesFragCoord)
-    {
-        fragCoordSemantic = varyingSemantic + str(reservedRegisterIndex++);
-    }
-
-    if (fragmentShader-&gt;mUsesPointCoord)
-    {
-        // Shader model 3 uses a special TEXCOORD semantic for point sprite texcoords.
-        // In DX11 we compute this in the GS.
-        if (shaderModel == 3)
-        {
-            pointCoordSemantic = &quot;TEXCOORD0&quot;;
-        }
-        else if (shaderModel &gt;= 4)
-        {
-            pointCoordSemantic = varyingSemantic + str(reservedRegisterIndex++); 
-        }
-    }
-
-    vertexHLSL += &quot;struct VS_INPUT\n&quot;
-                  &quot;{\n&quot;;
-
-    int semanticIndex = 0;
-    for (AttributeArray::iterator attribute = vertexShader-&gt;mAttributes.begin(); attribute != vertexShader-&gt;mAttributes.end(); attribute++)
-    {
-        switch (attribute-&gt;type)
-        {
-          case GL_FLOAT:      vertexHLSL += &quot;    float &quot;;    break;
-          case GL_FLOAT_VEC2: vertexHLSL += &quot;    float2 &quot;;   break;
-          case GL_FLOAT_VEC3: vertexHLSL += &quot;    float3 &quot;;   break;
-          case GL_FLOAT_VEC4: vertexHLSL += &quot;    float4 &quot;;   break;
-          case GL_FLOAT_MAT2: vertexHLSL += &quot;    float2x2 &quot;; break;
-          case GL_FLOAT_MAT3: vertexHLSL += &quot;    float3x3 &quot;; break;
-          case GL_FLOAT_MAT4: vertexHLSL += &quot;    float4x4 &quot;; break;
-          default:  UNREACHABLE();
-        }
-
-        vertexHLSL += decorateAttribute(attribute-&gt;name) + &quot; : TEXCOORD&quot; + str(semanticIndex) + &quot;;\n&quot;;
-
-        semanticIndex += VariableRowCount(attribute-&gt;type);
-    }
-
-    vertexHLSL += &quot;};\n&quot;
-                  &quot;\n&quot;
-                  &quot;struct VS_OUTPUT\n&quot;
-                  &quot;{\n&quot;;
-
-    if (shaderModel &lt; 4)
-    {
-        vertexHLSL += &quot;    float4 gl_Position : &quot; + positionSemantic + &quot;;\n&quot;;
-    }
-
-    for (int r = 0; r &lt; registers; r++)
-    {
-        int registerSize = packing[r][3] ? 4 : (packing[r][2] ? 3 : (packing[r][1] ? 2 : 1));
-
-        vertexHLSL += &quot;    float&quot; + str(registerSize) + &quot; v&quot; + str(r) + &quot; : &quot; + varyingSemantic + str(r) + &quot;;\n&quot;;
-    }
-
-    if (fragmentShader-&gt;mUsesFragCoord)
-    {
-        vertexHLSL += &quot;    float4 gl_FragCoord : &quot; + fragCoordSemantic + &quot;;\n&quot;;
-    }
-
-    if (vertexShader-&gt;mUsesPointSize &amp;&amp; shaderModel &gt;= 3)
-    {
-        vertexHLSL += &quot;    float gl_PointSize : PSIZE;\n&quot;;
-    }
-
-    if (shaderModel &gt;= 4)
-    {
-        vertexHLSL += &quot;    float4 gl_Position : &quot; + positionSemantic + &quot;;\n&quot;;
-    }
-
-    vertexHLSL += &quot;};\n&quot;
-                  &quot;\n&quot;
-                  &quot;VS_OUTPUT main(VS_INPUT input)\n&quot;
-                  &quot;{\n&quot;;
-
-    for (AttributeArray::iterator attribute = vertexShader-&gt;mAttributes.begin(); attribute != vertexShader-&gt;mAttributes.end(); attribute++)
-    {
-        vertexHLSL += &quot;    &quot; + decorateAttribute(attribute-&gt;name) + &quot; = &quot;;
-
-        if (VariableRowCount(attribute-&gt;type) &gt; 1)   // Matrix
-        {
-            vertexHLSL += &quot;transpose&quot;;
-        }
-
-        vertexHLSL += &quot;(input.&quot; + decorateAttribute(attribute-&gt;name) + &quot;);\n&quot;;
-    }
-
-    if (shaderModel &gt;= 4)
-    {
-        vertexHLSL += &quot;\n&quot;
-                      &quot;    gl_main();\n&quot;
-                      &quot;\n&quot;
-                      &quot;    VS_OUTPUT output;\n&quot;
-                      &quot;    output.gl_Position.x = gl_Position.x;\n&quot;
-                      &quot;    output.gl_Position.y = -gl_Position.y;\n&quot;
-                      &quot;    output.gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n&quot;
-                      &quot;    output.gl_Position.w = gl_Position.w;\n&quot;;
-    }
-    else
-    {
-        vertexHLSL += &quot;\n&quot;
-                      &quot;    gl_main();\n&quot;
-                      &quot;\n&quot;
-                      &quot;    VS_OUTPUT output;\n&quot;
-                      &quot;    output.gl_Position.x = gl_Position.x * dx_ViewAdjust.z + dx_ViewAdjust.x * gl_Position.w;\n&quot;
-                      &quot;    output.gl_Position.y = -(gl_Position.y * dx_ViewAdjust.w + dx_ViewAdjust.y * gl_Position.w);\n&quot;
-                      &quot;    output.gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n&quot;
-                      &quot;    output.gl_Position.w = gl_Position.w;\n&quot;;
-    }
-
-    if (vertexShader-&gt;mUsesPointSize &amp;&amp; shaderModel &gt;= 3)
-    {
-        vertexHLSL += &quot;    output.gl_PointSize = gl_PointSize;\n&quot;;
-    }
-
-    if (fragmentShader-&gt;mUsesFragCoord)
-    {
-        vertexHLSL += &quot;    output.gl_FragCoord = gl_Position;\n&quot;;
-    }
-
-    for (VaryingList::iterator varying = vertexShader-&gt;mVaryings.begin(); varying != vertexShader-&gt;mVaryings.end(); varying++)
-    {
-        if (varying-&gt;reg &gt;= 0)
-        {
-            for (int i = 0; i &lt; varying-&gt;size; i++)
-            {
-                int rows = VariableRowCount(varying-&gt;type);
-
-                for (int j = 0; j &lt; rows; j++)
-                {
-                    int r = varying-&gt;reg + i * rows + j;
-                    vertexHLSL += &quot;    output.v&quot; + str(r);
-
-                    bool sharedRegister = false;   // Register used by multiple varyings
-                    
-                    for (int x = 0; x &lt; 4; x++)
-                    {
-                        if (packing[r][x] &amp;&amp; packing[r][x] != packing[r][0])
-                        {
-                            sharedRegister = true;
-                            break;
-                        }
-                    }
-
-                    if(sharedRegister)
-                    {
-                        vertexHLSL += &quot;.&quot;;
-
-                        for (int x = 0; x &lt; 4; x++)
-                        {
-                            if (packing[r][x] == &amp;*varying)
-                            {
-                                switch(x)
-                                {
-                                  case 0: vertexHLSL += &quot;x&quot;; break;
-                                  case 1: vertexHLSL += &quot;y&quot;; break;
-                                  case 2: vertexHLSL += &quot;z&quot;; break;
-                                  case 3: vertexHLSL += &quot;w&quot;; break;
-                                }
-                            }
-                        }
-                    }
-
-                    vertexHLSL += &quot; = &quot; + varying-&gt;name;
-                    
-                    if (varying-&gt;array)
-                    {
-                        vertexHLSL += &quot;[&quot; + str(i) + &quot;]&quot;;
-                    }
-
-                    if (rows &gt; 1)
-                    {
-                        vertexHLSL += &quot;[&quot; + str(j) + &quot;]&quot;;
-                    }
-                    
-                    vertexHLSL += &quot;;\n&quot;;
-                }
-            }
-        }
-    }
-
-    vertexHLSL += &quot;\n&quot;
-                  &quot;    return output;\n&quot;
-                  &quot;}\n&quot;;
-
-    pixelHLSL += &quot;struct PS_INPUT\n&quot;
-                 &quot;{\n&quot;;
-    
-    for (VaryingList::iterator varying = fragmentShader-&gt;mVaryings.begin(); varying != fragmentShader-&gt;mVaryings.end(); varying++)
-    {
-        if (varying-&gt;reg &gt;= 0)
-        {
-            for (int i = 0; i &lt; varying-&gt;size; i++)
-            {
-                int rows = VariableRowCount(varying-&gt;type);
-                for (int j = 0; j &lt; rows; j++)
-                {
-                    std::string n = str(varying-&gt;reg + i * rows + j);
-                    pixelHLSL += &quot;    float&quot; + str(VariableColumnCount(varying-&gt;type)) + &quot; v&quot; + n + &quot; : &quot; + varyingSemantic + n + &quot;;\n&quot;;
-                }
-            }
-        }
-        else UNREACHABLE();
-    }
-
-    if (fragmentShader-&gt;mUsesFragCoord)
-    {
-        pixelHLSL += &quot;    float4 gl_FragCoord : &quot; + fragCoordSemantic + &quot;;\n&quot;;
-    }
-        
-    if (fragmentShader-&gt;mUsesPointCoord &amp;&amp; shaderModel &gt;= 3)
-    {
-        pixelHLSL += &quot;    float2 gl_PointCoord : &quot; + pointCoordSemantic + &quot;;\n&quot;;
-    }
-
-    // Must consume the PSIZE element if the geometry shader is not active
-    // We won't know if we use a GS until we draw
-    if (vertexShader-&gt;mUsesPointSize &amp;&amp; shaderModel &gt;= 4)
-    {
-        pixelHLSL += &quot;    float gl_PointSize : PSIZE;\n&quot;;
-    }
-
-    if (fragmentShader-&gt;mUsesFragCoord)
-    {
-        if (shaderModel &gt;= 4)
-        {
-            pixelHLSL += &quot;    float4 dx_VPos : SV_Position;\n&quot;;
-        }
-        else if (shaderModel &gt;= 3)
-        {
-            pixelHLSL += &quot;    float2 dx_VPos : VPOS;\n&quot;;
-        }
-    }
-
-    pixelHLSL += &quot;};\n&quot;
-                 &quot;\n&quot;
-                 &quot;struct PS_OUTPUT\n&quot;
-                 &quot;{\n&quot;;
-
-    for (unsigned int renderTargetIndex = 0; renderTargetIndex &lt; numRenderTargets; renderTargetIndex++)
-    {
-        pixelHLSL += &quot;    float4 gl_Color&quot; + str(renderTargetIndex) + &quot; : &quot; + targetSemantic + str(renderTargetIndex) + &quot;;\n&quot;;
-    }
-
-    if (fragmentShader-&gt;mUsesFragDepth)
-    {
-        pixelHLSL += &quot;    float gl_Depth : &quot; + depthSemantic + &quot;;\n&quot;;
-    }
-
-    pixelHLSL += &quot;};\n&quot;
-                 &quot;\n&quot;;
-
-    if (fragmentShader-&gt;mUsesFrontFacing)
-    {
-        if (shaderModel &gt;= 4)
-        {
-            pixelHLSL += &quot;PS_OUTPUT main(PS_INPUT input, bool isFrontFace : SV_IsFrontFace)\n&quot;
-                         &quot;{\n&quot;;
-        }
-        else
-        {
-            pixelHLSL += &quot;PS_OUTPUT main(PS_INPUT input, float vFace : VFACE)\n&quot;
-                         &quot;{\n&quot;;
-        }
-    }
-    else
-    {
-        pixelHLSL += &quot;PS_OUTPUT main(PS_INPUT input)\n&quot;
-                     &quot;{\n&quot;;
-    }
-
-    if (fragmentShader-&gt;mUsesFragCoord)
-    {
-        pixelHLSL += &quot;    float rhw = 1.0 / input.gl_FragCoord.w;\n&quot;;
-        
-        if (shaderModel &gt;= 4)
-        {
-            pixelHLSL += &quot;    gl_FragCoord.x = input.dx_VPos.x;\n&quot;
-                         &quot;    gl_FragCoord.y = input.dx_VPos.y;\n&quot;;
-        }
-        else if (shaderModel &gt;= 3)
-        {
-            pixelHLSL += &quot;    gl_FragCoord.x = input.dx_VPos.x + 0.5;\n&quot;
-                         &quot;    gl_FragCoord.y = input.dx_VPos.y + 0.5;\n&quot;;
-        }
-        else
-        {
-            // dx_ViewCoords contains the viewport width/2, height/2, center.x and center.y. See Renderer::setViewport()
-            pixelHLSL += &quot;    gl_FragCoord.x = (input.gl_FragCoord.x * rhw) * dx_ViewCoords.x + dx_ViewCoords.z;\n&quot;
-                         &quot;    gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * dx_ViewCoords.y + dx_ViewCoords.w;\n&quot;;
-        }
-        
-        pixelHLSL += &quot;    gl_FragCoord.z = (input.gl_FragCoord.z * rhw) * dx_DepthFront.x + dx_DepthFront.y;\n&quot;
-                     &quot;    gl_FragCoord.w = rhw;\n&quot;;
-    }
-
-    if (fragmentShader-&gt;mUsesPointCoord &amp;&amp; shaderModel &gt;= 3)
-    {
-        pixelHLSL += &quot;    gl_PointCoord.x = input.gl_PointCoord.x;\n&quot;;
-        pixelHLSL += &quot;    gl_PointCoord.y = 1.0 - input.gl_PointCoord.y;\n&quot;;
-    }
-
-    if (fragmentShader-&gt;mUsesFrontFacing)
-    {
-        if (shaderModel &lt;= 3)
-        {
-            pixelHLSL += &quot;    gl_FrontFacing = (vFace * dx_DepthFront.z &gt;= 0.0);\n&quot;;
-        }
-        else
-        {
-            pixelHLSL += &quot;    gl_FrontFacing = isFrontFace;\n&quot;;
-        }
-    }
-
-    for (VaryingList::iterator varying = fragmentShader-&gt;mVaryings.begin(); varying != fragmentShader-&gt;mVaryings.end(); varying++)
-    {
-        if (varying-&gt;reg &gt;= 0)
-        {
-            for (int i = 0; i &lt; varying-&gt;size; i++)
-            {
-                int rows = VariableRowCount(varying-&gt;type);
-                for (int j = 0; j &lt; rows; j++)
-                {
-                    std::string n = str(varying-&gt;reg + i * rows + j);
-                    pixelHLSL += &quot;    &quot; + varying-&gt;name;
-
-                    if (varying-&gt;array)
-                    {
-                        pixelHLSL += &quot;[&quot; + str(i) + &quot;]&quot;;
-                    }
-
-                    if (rows &gt; 1)
-                    {
-                        pixelHLSL += &quot;[&quot; + str(j) + &quot;]&quot;;
-                    }
-
-                    switch (VariableColumnCount(varying-&gt;type))
-                    {
-                      case 1: pixelHLSL += &quot; = input.v&quot; + n + &quot;.x;\n&quot;;   break;
-                      case 2: pixelHLSL += &quot; = input.v&quot; + n + &quot;.xy;\n&quot;;  break;
-                      case 3: pixelHLSL += &quot; = input.v&quot; + n + &quot;.xyz;\n&quot;; break;
-                      case 4: pixelHLSL += &quot; = input.v&quot; + n + &quot;;\n&quot;;     break;
-                      default: UNREACHABLE();
-                    }
-                }
-            }
-        }
-        else UNREACHABLE();
-    }
-
-    pixelHLSL += &quot;\n&quot;
-                 &quot;    gl_main();\n&quot;
-                 &quot;\n&quot;
-                 &quot;    PS_OUTPUT output;\n&quot;;
-
-    for (unsigned int renderTargetIndex = 0; renderTargetIndex &lt; numRenderTargets; renderTargetIndex++)
-    {
-        unsigned int sourceColorIndex = broadcast ? 0 : renderTargetIndex;
-
-        pixelHLSL += &quot;    output.gl_Color&quot; + str(renderTargetIndex) + &quot; = gl_Color[&quot; + str(sourceColorIndex) + &quot;];\n&quot;;
-    }
-
-    if (fragmentShader-&gt;mUsesFragDepth)
-    {
-        pixelHLSL += &quot;    output.gl_Depth = gl_Depth;\n&quot;;
-    }
-
-    pixelHLSL += &quot;\n&quot;
-                 &quot;    return output;\n&quot;
-                 &quot;}\n&quot;;
-
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1659,6 +1088,8 @@
</span><span class="cx">         std::string name;
</span><span class="cx">         stream.read(&amp;name);
</span><span class="cx">         mLinkedAttribute[i].name = name;
</span><ins>+        stream.read(&amp;mShaderAttributes[i].type);
+        stream.read(&amp;mShaderAttributes[i].name);
</ins><span class="cx">         stream.read(&amp;mSemanticIndex[i]);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1687,6 +1118,7 @@
</span><span class="cx">     stream.read(&amp;mUsedVertexSamplerRange);
</span><span class="cx">     stream.read(&amp;mUsedPixelSamplerRange);
</span><span class="cx">     stream.read(&amp;mUsesPointSize);
</span><ins>+    stream.read(&amp;mShaderVersion);
</ins><span class="cx"> 
</span><span class="cx">     size_t size;
</span><span class="cx">     stream.read(&amp;size);
</span><span class="lines">@@ -1703,17 +1135,32 @@
</span><span class="cx">         GLenum precision;
</span><span class="cx">         std::string name;
</span><span class="cx">         unsigned int arraySize;
</span><ins>+        int blockIndex;
</ins><span class="cx"> 
</span><span class="cx">         stream.read(&amp;type);
</span><span class="cx">         stream.read(&amp;precision);
</span><span class="cx">         stream.read(&amp;name);
</span><span class="cx">         stream.read(&amp;arraySize);
</span><ins>+        stream.read(&amp;blockIndex);
</ins><span class="cx"> 
</span><del>-        mUniforms[i] = new Uniform(type, precision, name, arraySize);
</del><ins>+        int offset;
+        int arrayStride;
+        int matrixStride;
+        bool isRowMajorMatrix;
+
+        stream.read(&amp;offset);
+        stream.read(&amp;arrayStride);
+        stream.read(&amp;matrixStride);
+        stream.read(&amp;isRowMajorMatrix);
+
+        const gl::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix);
+
+        mUniforms[i] = new LinkedUniform(type, precision, name, arraySize, blockIndex, blockInfo);
</ins><span class="cx">         
</span><span class="cx">         stream.read(&amp;mUniforms[i]-&gt;psRegisterIndex);
</span><span class="cx">         stream.read(&amp;mUniforms[i]-&gt;vsRegisterIndex);
</span><span class="cx">         stream.read(&amp;mUniforms[i]-&gt;registerCount);
</span><ins>+        stream.read(&amp;mUniforms[i]-&gt;registerElement);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     stream.read(&amp;size);
</span><span class="lines">@@ -1723,6 +1170,39 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    mUniformBlocks.resize(size);
+    for (unsigned int uniformBlockIndex = 0; uniformBlockIndex &lt; size; ++uniformBlockIndex)
+    {
+        std::string name;
+        unsigned int elementIndex;
+        unsigned int dataSize;
+
+        stream.read(&amp;name);
+        stream.read(&amp;elementIndex);
+        stream.read(&amp;dataSize);
+
+        mUniformBlocks[uniformBlockIndex] = new UniformBlock(name, elementIndex, dataSize);
+
+        UniformBlock&amp; uniformBlock = *mUniformBlocks[uniformBlockIndex];
+        stream.read(&amp;uniformBlock.psRegisterIndex);
+        stream.read(&amp;uniformBlock.vsRegisterIndex);
+
+        size_t numMembers;
+        stream.read(&amp;numMembers);
+        uniformBlock.memberUniformIndexes.resize(numMembers);
+        for (unsigned int blockMemberIndex = 0; blockMemberIndex &lt; numMembers; blockMemberIndex++)
+        {
+            stream.read(&amp;uniformBlock.memberUniformIndexes[blockMemberIndex]);
+        }
+    }
+
+    stream.read(&amp;size);
+    if (stream.error())
+    {
+        infoLog.append(&quot;Invalid program binary.&quot;);
+        return false;
+    }
+
</ins><span class="cx">     mUniformIndex.resize(size);
</span><span class="cx">     for (unsigned int i = 0; i &lt; size; ++i)
</span><span class="cx">     {
</span><span class="lines">@@ -1731,73 +1211,106 @@
</span><span class="cx">         stream.read(&amp;mUniformIndex[i].index);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned int pixelShaderSize;
-    stream.read(&amp;pixelShaderSize);
</del><ins>+    stream.read(&amp;mTransformFeedbackBufferMode);
+    stream.read(&amp;size);
+    mTransformFeedbackLinkedVaryings.resize(size);
+    for (size_t i = 0; i &lt; mTransformFeedbackLinkedVaryings.size(); i++)
+    {
+        LinkedVarying &amp;varying = mTransformFeedbackLinkedVaryings[i];
</ins><span class="cx"> 
</span><del>-    unsigned int vertexShaderSize;
-    stream.read(&amp;vertexShaderSize);
</del><ins>+        stream.read(&amp;varying.name);
+        stream.read(&amp;varying.type);
+        stream.read(&amp;varying.size);
+        stream.read(&amp;varying.semanticName);
+        stream.read(&amp;varying.semanticIndex);
+        stream.read(&amp;varying.semanticIndexCount);
+    }
</ins><span class="cx"> 
</span><del>-    unsigned int geometryShaderSize;
-    stream.read(&amp;geometryShaderSize);
</del><ins>+    stream.read(&amp;mVertexHLSL);
+    stream.read(&amp;mVertexWorkarounds);
</ins><span class="cx"> 
</span><del>-    const char *ptr = (const char*) binary + stream.offset();
</del><ins>+    unsigned int vertexShaderCount;
+    stream.read(&amp;vertexShaderCount);
</ins><span class="cx"> 
</span><del>-    const GUID *binaryIdentifier = (const GUID *) ptr;
-    ptr += sizeof(GUID);
-
-    GUID identifier = mRenderer-&gt;getAdapterIdentifier();
-    if (memcmp(&amp;identifier, binaryIdentifier, sizeof(GUID)) != 0)
</del><ins>+    for (unsigned int vertexShaderIndex = 0; vertexShaderIndex &lt; vertexShaderCount; vertexShaderIndex++)
</ins><span class="cx">     {
</span><del>-        infoLog.append(&quot;Invalid program binary.&quot;);
-        return false;
-    }
</del><ins>+        VertexFormat vertexInputs[gl::MAX_VERTEX_ATTRIBS];
</ins><span class="cx"> 
</span><del>-    const char *pixelShaderFunction = ptr;
-    ptr += pixelShaderSize;
</del><ins>+        for (size_t inputIndex = 0; inputIndex &lt; gl::MAX_VERTEX_ATTRIBS; inputIndex++)
+        {
+            VertexFormat *vertexInput = &amp;vertexInputs[inputIndex];
+            stream.read(&amp;vertexInput-&gt;mType);
+            stream.read(&amp;vertexInput-&gt;mNormalized);
+            stream.read(&amp;vertexInput-&gt;mComponents);
+            stream.read(&amp;vertexInput-&gt;mPureInteger);
+        }
</ins><span class="cx"> 
</span><del>-    const char *vertexShaderFunction = ptr;
-    ptr += vertexShaderSize;
</del><ins>+        unsigned int vertexShaderSize;
+        stream.read(&amp;vertexShaderSize);
</ins><span class="cx"> 
</span><del>-    const char *geometryShaderFunction = geometryShaderSize &gt; 0 ? ptr : NULL;
-    ptr += geometryShaderSize;
</del><ins>+        const char *vertexShaderFunction = (const char*) binary + stream.offset();
</ins><span class="cx"> 
</span><ins>+        rx::ShaderExecutable *shaderExecutable = mRenderer-&gt;loadExecutable(reinterpret_cast&lt;const DWORD*&gt;(vertexShaderFunction),
+                                                                           vertexShaderSize, rx::SHADER_VERTEX,
+                                                                           mTransformFeedbackLinkedVaryings,
+                                                                           (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS));
+        if (!shaderExecutable)
+        {
+            infoLog.append(&quot;Could not create vertex shader.&quot;);
+            return false;
+        }
+
+        mVertexExecutables.push_back(new VertexExecutable(mRenderer, vertexInputs, shaderExecutable));
+
+        stream.skip(vertexShaderSize);
+    }
+
+    unsigned int pixelShaderSize;
+    stream.read(&amp;pixelShaderSize);
+
+    const char *pixelShaderFunction = (const char*) binary + stream.offset();
</ins><span class="cx">     mPixelExecutable = mRenderer-&gt;loadExecutable(reinterpret_cast&lt;const DWORD*&gt;(pixelShaderFunction),
</span><del>-                                                 pixelShaderSize, rx::SHADER_PIXEL);
</del><ins>+                                                 pixelShaderSize, rx::SHADER_PIXEL, mTransformFeedbackLinkedVaryings,
+                                                 (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS));
</ins><span class="cx">     if (!mPixelExecutable)
</span><span class="cx">     {
</span><span class="cx">         infoLog.append(&quot;Could not create pixel shader.&quot;);
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><ins>+    stream.skip(pixelShaderSize);
</ins><span class="cx"> 
</span><del>-    mVertexExecutable = mRenderer-&gt;loadExecutable(reinterpret_cast&lt;const DWORD*&gt;(vertexShaderFunction),
-                                                  vertexShaderSize, rx::SHADER_VERTEX);
-    if (!mVertexExecutable)
-    {
-        infoLog.append(&quot;Could not create vertex shader.&quot;);
-        delete mPixelExecutable;
-        mPixelExecutable = NULL;
-        return false;
-    }
</del><ins>+    unsigned int geometryShaderSize;
+    stream.read(&amp;geometryShaderSize);
</ins><span class="cx"> 
</span><del>-    if (geometryShaderFunction != NULL &amp;&amp; geometryShaderSize &gt; 0)
</del><ins>+    if (geometryShaderSize &gt; 0)
</ins><span class="cx">     {
</span><ins>+        const char *geometryShaderFunction = (const char*) binary + stream.offset();
</ins><span class="cx">         mGeometryExecutable = mRenderer-&gt;loadExecutable(reinterpret_cast&lt;const DWORD*&gt;(geometryShaderFunction),
</span><del>-                                                        geometryShaderSize, rx::SHADER_GEOMETRY);
</del><ins>+                                                        geometryShaderSize, rx::SHADER_GEOMETRY, mTransformFeedbackLinkedVaryings,
+                                                        (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS));
</ins><span class="cx">         if (!mGeometryExecutable)
</span><span class="cx">         {
</span><span class="cx">             infoLog.append(&quot;Could not create geometry shader.&quot;);
</span><del>-            delete mPixelExecutable;
-            mPixelExecutable = NULL;
-            delete mVertexExecutable;
-            mVertexExecutable = NULL;
</del><ins>+            SafeDelete(mPixelExecutable);
</ins><span class="cx">             return false;
</span><span class="cx">         }
</span><ins>+        stream.skip(geometryShaderSize);
</ins><span class="cx">     }
</span><del>-    else
</del><ins>+
+    const char *ptr = (const char*) binary + stream.offset();
+
+    const GUID *binaryIdentifier = (const GUID *) ptr;
+    ptr += sizeof(GUID);
+
+    GUID identifier = mRenderer-&gt;getAdapterIdentifier();
+    if (memcmp(&amp;identifier, binaryIdentifier, sizeof(GUID)) != 0)
</ins><span class="cx">     {
</span><del>-        mGeometryExecutable = NULL;
</del><ins>+        infoLog.append(&quot;Invalid program binary.&quot;);
+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    initializeUniformStorage();
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1815,6 +1328,8 @@
</span><span class="cx">     {
</span><span class="cx">         stream.write(mLinkedAttribute[i].type);
</span><span class="cx">         stream.write(mLinkedAttribute[i].name);
</span><ins>+        stream.write(mShaderAttributes[i].type);
+        stream.write(mShaderAttributes[i].name);
</ins><span class="cx">         stream.write(mSemanticIndex[i]);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1835,43 +1350,116 @@
</span><span class="cx">     stream.write(mUsedVertexSamplerRange);
</span><span class="cx">     stream.write(mUsedPixelSamplerRange);
</span><span class="cx">     stream.write(mUsesPointSize);
</span><ins>+    stream.write(mShaderVersion);
</ins><span class="cx"> 
</span><span class="cx">     stream.write(mUniforms.size());
</span><del>-    for (unsigned int i = 0; i &lt; mUniforms.size(); ++i)
</del><ins>+    for (size_t uniformIndex = 0; uniformIndex &lt; mUniforms.size(); ++uniformIndex)
</ins><span class="cx">     {
</span><del>-        stream.write(mUniforms[i]-&gt;type);
-        stream.write(mUniforms[i]-&gt;precision);
-        stream.write(mUniforms[i]-&gt;name);
-        stream.write(mUniforms[i]-&gt;arraySize);
</del><ins>+        const LinkedUniform &amp;uniform = *mUniforms[uniformIndex];
</ins><span class="cx"> 
</span><del>-        stream.write(mUniforms[i]-&gt;psRegisterIndex);
-        stream.write(mUniforms[i]-&gt;vsRegisterIndex);
-        stream.write(mUniforms[i]-&gt;registerCount);
</del><ins>+        stream.write(uniform.type);
+        stream.write(uniform.precision);
+        stream.write(uniform.name);
+        stream.write(uniform.arraySize);
+        stream.write(uniform.blockIndex);
+
+        stream.write(uniform.blockInfo.offset);
+        stream.write(uniform.blockInfo.arrayStride);
+        stream.write(uniform.blockInfo.matrixStride);
+        stream.write(uniform.blockInfo.isRowMajorMatrix);
+
+        stream.write(uniform.psRegisterIndex);
+        stream.write(uniform.vsRegisterIndex);
+        stream.write(uniform.registerCount);
+        stream.write(uniform.registerElement);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    stream.write(mUniformBlocks.size());
+    for (size_t uniformBlockIndex = 0; uniformBlockIndex &lt; mUniformBlocks.size(); ++uniformBlockIndex)
+    {
+        const UniformBlock&amp; uniformBlock = *mUniformBlocks[uniformBlockIndex];
+
+        stream.write(uniformBlock.name);
+        stream.write(uniformBlock.elementIndex);
+        stream.write(uniformBlock.dataSize);
+
+        stream.write(uniformBlock.memberUniformIndexes.size());
+        for (unsigned int blockMemberIndex = 0; blockMemberIndex &lt; uniformBlock.memberUniformIndexes.size(); blockMemberIndex++)
+        {
+            stream.write(uniformBlock.memberUniformIndexes[blockMemberIndex]);
+        }
+
+        stream.write(uniformBlock.psRegisterIndex);
+        stream.write(uniformBlock.vsRegisterIndex);
+    }
+
</ins><span class="cx">     stream.write(mUniformIndex.size());
</span><del>-    for (unsigned int i = 0; i &lt; mUniformIndex.size(); ++i)
</del><ins>+    for (size_t i = 0; i &lt; mUniformIndex.size(); ++i)
</ins><span class="cx">     {
</span><span class="cx">         stream.write(mUniformIndex[i].name);
</span><span class="cx">         stream.write(mUniformIndex[i].element);
</span><span class="cx">         stream.write(mUniformIndex[i].index);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    stream.write(mTransformFeedbackBufferMode);
+    stream.write(mTransformFeedbackLinkedVaryings.size());
+    for (size_t i = 0; i &lt; mTransformFeedbackLinkedVaryings.size(); i++)
+    {
+        const LinkedVarying &amp;varying = mTransformFeedbackLinkedVaryings[i];
+
+        stream.write(varying.name);
+        stream.write(varying.type);
+        stream.write(varying.size);
+        stream.write(varying.semanticName);
+        stream.write(varying.semanticIndex);
+        stream.write(varying.semanticIndexCount);
+    }
+
+    stream.write(mVertexHLSL);
+    stream.write(mVertexWorkarounds);
+
+    stream.write(mVertexExecutables.size());
+    for (size_t vertexExecutableIndex = 0; vertexExecutableIndex &lt; mVertexExecutables.size(); vertexExecutableIndex++)
+    {
+        VertexExecutable *vertexExecutable = mVertexExecutables[vertexExecutableIndex];
+
+        for (size_t inputIndex = 0; inputIndex &lt; gl::MAX_VERTEX_ATTRIBS; inputIndex++)
+        {
+            const VertexFormat &amp;vertexInput = vertexExecutable-&gt;inputs()[inputIndex];
+            stream.write(vertexInput.mType);
+            stream.write(vertexInput.mNormalized);
+            stream.write(vertexInput.mComponents);
+            stream.write(vertexInput.mPureInteger);
+        }
+
+        UINT vertexShaderSize = vertexExecutable-&gt;shaderExecutable()-&gt;getLength();
+        stream.write(vertexShaderSize);
+
+        unsigned char *vertexBlob = static_cast&lt;unsigned char *&gt;(vertexExecutable-&gt;shaderExecutable()-&gt;getFunction());
+        stream.write(vertexBlob, vertexShaderSize);
+    }
+
</ins><span class="cx">     UINT pixelShaderSize = mPixelExecutable-&gt;getLength();
</span><span class="cx">     stream.write(pixelShaderSize);
</span><span class="cx"> 
</span><del>-    UINT vertexShaderSize = mVertexExecutable-&gt;getLength();
-    stream.write(vertexShaderSize);
</del><ins>+    unsigned char *pixelBlob = static_cast&lt;unsigned char *&gt;(mPixelExecutable-&gt;getFunction());
+    stream.write(pixelBlob, pixelShaderSize);
</ins><span class="cx"> 
</span><span class="cx">     UINT geometryShaderSize = (mGeometryExecutable != NULL) ? mGeometryExecutable-&gt;getLength() : 0;
</span><span class="cx">     stream.write(geometryShaderSize);
</span><span class="cx"> 
</span><ins>+    if (mGeometryExecutable != NULL &amp;&amp; geometryShaderSize &gt; 0)
+    {
+        unsigned char *geometryBlob = static_cast&lt;unsigned char *&gt;(mGeometryExecutable-&gt;getFunction());
+        stream.write(geometryBlob, geometryShaderSize);
+    }
+
</ins><span class="cx">     GUID identifier = mRenderer-&gt;getAdapterIdentifier();
</span><span class="cx"> 
</span><span class="cx">     GLsizei streamLength = stream.length();
</span><span class="cx">     const void *streamData = stream.data();
</span><span class="cx"> 
</span><del>-    GLsizei totalLength = streamLength + sizeof(GUID) + pixelShaderSize + vertexShaderSize + geometryShaderSize;
</del><ins>+    GLsizei totalLength = streamLength + sizeof(GUID);
</ins><span class="cx">     if (totalLength &gt; bufSize)
</span><span class="cx">     {
</span><span class="cx">         if (length)
</span><span class="lines">@@ -1892,18 +1480,6 @@
</span><span class="cx">         memcpy(ptr, &amp;identifier, sizeof(GUID));
</span><span class="cx">         ptr += sizeof(GUID);
</span><span class="cx"> 
</span><del>-        memcpy(ptr, mPixelExecutable-&gt;getFunction(), pixelShaderSize);
-        ptr += pixelShaderSize;
-
-        memcpy(ptr, mVertexExecutable-&gt;getFunction(), vertexShaderSize);
-        ptr += vertexShaderSize;
-
-        if (mGeometryExecutable != NULL &amp;&amp; geometryShaderSize &gt; 0)
-        {
-            memcpy(ptr, mGeometryExecutable-&gt;getFunction(), geometryShaderSize);
-            ptr += geometryShaderSize;
-        }
-
</del><span class="cx">         ASSERT(ptr - totalLength == binary);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1928,7 +1504,8 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::link(InfoLog &amp;infoLog, const AttributeBindings &amp;attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader)
</del><ins>+bool ProgramBinary::link(InfoLog &amp;infoLog, const AttributeBindings &amp;attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader,
+                         const std::vector&lt;std::string&gt;&amp; transformFeedbackVaryings, GLenum transformFeedbackBufferMode)
</ins><span class="cx"> {
</span><span class="cx">     if (!fragmentShader || !fragmentShader-&gt;isCompiled())
</span><span class="cx">     {
</span><span class="lines">@@ -1940,23 +1517,38 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    mTransformFeedbackLinkedVaryings.clear();
+    mTransformFeedbackBufferMode = transformFeedbackBufferMode;
+
+    mShaderVersion = vertexShader-&gt;getShaderVersion();
+
</ins><span class="cx">     std::string pixelHLSL = fragmentShader-&gt;getHLSL();
</span><del>-    std::string vertexHLSL = vertexShader-&gt;getHLSL();
</del><ins>+    mVertexHLSL = vertexShader-&gt;getHLSL();
+    mVertexWorkarounds = vertexShader-&gt;getD3DWorkarounds();
</ins><span class="cx"> 
</span><span class="cx">     // Map the varyings to the register file
</span><del>-    const Varying *packing[IMPLEMENTATION_MAX_VARYING_VECTORS][4] = {NULL};
-    int registers = packVaryings(infoLog, packing, fragmentShader);
</del><ins>+    const gl::ShaderVariable *packing[IMPLEMENTATION_MAX_VARYING_VECTORS][4] = {NULL};
+    int registers = mDynamicHLSL-&gt;packVaryings(infoLog, packing, fragmentShader, vertexShader, transformFeedbackVaryings);
</ins><span class="cx"> 
</span><span class="cx">     if (registers &lt; 0)
</span><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!linkVaryings(infoLog, registers, packing, pixelHLSL, vertexHLSL, fragmentShader, vertexShader))
</del><ins>+    if (!linkVaryings(infoLog, fragmentShader, vertexShader))
</ins><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    mUsesPointSize = vertexShader-&gt;usesPointSize();
+    std::vector&lt;LinkedVarying&gt; linkedVaryings;
+    if (!mDynamicHLSL-&gt;generateShaderLinkHLSL(infoLog, registers, packing, pixelHLSL, mVertexHLSL,
+                                              fragmentShader, vertexShader, transformFeedbackVaryings,
+                                              &amp;linkedVaryings, &amp;mOutputVariables))
+    {
+        return false;
+    }
+
</ins><span class="cx">     bool success = true;
</span><span class="cx"> 
</span><span class="cx">     if (!linkAttributes(infoLog, attributeBindings, fragmentShader, vertexShader))
</span><span class="lines">@@ -1970,35 +1562,59 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // special case for gl_DepthRange, the only built-in uniform (also a struct)
</span><del>-    if (vertexShader-&gt;mUsesDepthRange || fragmentShader-&gt;mUsesDepthRange)
</del><ins>+    if (vertexShader-&gt;usesDepthRange() || fragmentShader-&gt;usesDepthRange())
</ins><span class="cx">     {
</span><del>-        mUniforms.push_back(new Uniform(GL_FLOAT, GL_HIGH_FLOAT, &quot;gl_DepthRange.near&quot;, 0));
-        mUniforms.push_back(new Uniform(GL_FLOAT, GL_HIGH_FLOAT, &quot;gl_DepthRange.far&quot;, 0));
-        mUniforms.push_back(new Uniform(GL_FLOAT, GL_HIGH_FLOAT, &quot;gl_DepthRange.diff&quot;, 0));
</del><ins>+        mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, &quot;gl_DepthRange.near&quot;, 0, -1, gl::BlockMemberInfo::defaultBlockInfo));
+        mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, &quot;gl_DepthRange.far&quot;, 0, -1, gl::BlockMemberInfo::defaultBlockInfo));
+        mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, &quot;gl_DepthRange.diff&quot;, 0, -1, gl::BlockMemberInfo::defaultBlockInfo));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (!linkUniformBlocks(infoLog, vertexShader-&gt;getInterfaceBlocks(), fragmentShader-&gt;getInterfaceBlocks()))
+    {
+        success = false;
+    }
+
+    if (!gatherTransformFeedbackLinkedVaryings(infoLog, linkedVaryings, transformFeedbackVaryings,
+                                               transformFeedbackBufferMode, &amp;mTransformFeedbackLinkedVaryings))
+    {
+        success = false;
+    }
+
</ins><span class="cx">     if (success)
</span><span class="cx">     {
</span><del>-        mVertexExecutable = mRenderer-&gt;compileToExecutable(infoLog, vertexHLSL.c_str(), rx::SHADER_VERTEX, DiscardWorkaround(vertexShader-&gt;mUsesDiscardRewriting));
-        mPixelExecutable = mRenderer-&gt;compileToExecutable(infoLog, pixelHLSL.c_str(), rx::SHADER_PIXEL, DiscardWorkaround(fragmentShader-&gt;mUsesDiscardRewriting));
</del><ins>+        VertexFormat defaultInputLayout[MAX_VERTEX_ATTRIBS];
+        GetInputLayoutFromShader(vertexShader-&gt;activeAttributes(), defaultInputLayout);
</ins><span class="cx"> 
</span><ins>+        rx::ShaderExecutable *defaultVertexExecutable = getVertexExecutableForInputLayout(defaultInputLayout);
+        mPixelExecutable = mRenderer-&gt;compileToExecutable(infoLog, pixelHLSL.c_str(), rx::SHADER_PIXEL,
+                                                          mTransformFeedbackLinkedVaryings,
+                                                          (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
+                                                          fragmentShader-&gt;getD3DWorkarounds());
+
</ins><span class="cx">         if (usesGeometryShader())
</span><span class="cx">         {
</span><del>-            std::string geometryHLSL = generateGeometryShaderHLSL(registers, packing, fragmentShader, vertexShader);
-            mGeometryExecutable = mRenderer-&gt;compileToExecutable(infoLog, geometryHLSL.c_str(), rx::SHADER_GEOMETRY, rx::ANGLE_D3D_WORKAROUND_NONE);
</del><ins>+            std::string geometryHLSL = mDynamicHLSL-&gt;generateGeometryShaderHLSL(registers, packing, fragmentShader, vertexShader);
+            mGeometryExecutable = mRenderer-&gt;compileToExecutable(infoLog, geometryHLSL.c_str(), rx::SHADER_GEOMETRY,
+                                                                 mTransformFeedbackLinkedVaryings,
+                                                                 (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
+                                                                 rx::ANGLE_D3D_WORKAROUND_NONE);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (!mVertexExecutable || !mPixelExecutable || (usesGeometryShader() &amp;&amp; !mGeometryExecutable))
</del><ins>+        if (!defaultVertexExecutable || !mPixelExecutable || (usesGeometryShader() &amp;&amp; !mGeometryExecutable))
</ins><span class="cx">         {
</span><span class="cx">             infoLog.append(&quot;Failed to create D3D shaders.&quot;);
</span><span class="cx">             success = false;
</span><span class="cx"> 
</span><del>-            delete mVertexExecutable;
-            mVertexExecutable = NULL;
-            delete mPixelExecutable;
-            mPixelExecutable = NULL;
-            delete mGeometryExecutable;
-            mGeometryExecutable = NULL;
</del><ins>+            while (!mVertexExecutables.empty())
+            {
+                delete mVertexExecutables.back();
+                mVertexExecutables.pop_back();
+            }
+
+            SafeDelete(mGeometryExecutable);
+            SafeDelete(mPixelExecutable);
+
+            mTransformFeedbackLinkedVaryings.clear();
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2009,62 +1625,75 @@
</span><span class="cx"> bool ProgramBinary::linkAttributes(InfoLog &amp;infoLog, const AttributeBindings &amp;attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader)
</span><span class="cx"> {
</span><span class="cx">     unsigned int usedLocations = 0;
</span><ins>+    const std::vector&lt;gl::Attribute&gt; &amp;activeAttributes = vertexShader-&gt;activeAttributes();
</ins><span class="cx"> 
</span><span class="cx">     // Link attributes that have a binding location
</span><del>-    for (AttributeArray::iterator attribute = vertexShader-&gt;mAttributes.begin(); attribute != vertexShader-&gt;mAttributes.end(); attribute++)
</del><ins>+    for (unsigned int attributeIndex = 0; attributeIndex &lt; activeAttributes.size(); attributeIndex++)
</ins><span class="cx">     {
</span><del>-        int location = attributeBindings.getAttributeBinding(attribute-&gt;name);
</del><ins>+        const gl::Attribute &amp;attribute = activeAttributes[attributeIndex];
+        const int location = attribute.location == -1 ? attributeBindings.getAttributeBinding(attribute.name) : attribute.location;
</ins><span class="cx"> 
</span><del>-        if (location != -1)   // Set by glBindAttribLocation
</del><ins>+        mShaderAttributes[attributeIndex] = attribute;
+
+        if (location != -1)   // Set by glBindAttribLocation or by location layout qualifier
</ins><span class="cx">         {
</span><del>-            if (!mLinkedAttribute[location].name.empty())
-            {
-                // Multiple active attributes bound to the same location; not an error
-            }
</del><ins>+            const int rows = AttributeRegisterCount(attribute.type);
</ins><span class="cx"> 
</span><del>-            mLinkedAttribute[location] = *attribute;
-
-            int rows = VariableRowCount(attribute-&gt;type);
-
</del><span class="cx">             if (rows + location &gt; MAX_VERTEX_ATTRIBS)
</span><span class="cx">             {
</span><del>-                infoLog.append(&quot;Active attribute (%s) at location %d is too big to fit&quot;, attribute-&gt;name.c_str(), location);
</del><ins>+                infoLog.append(&quot;Active attribute (%s) at location %d is too big to fit&quot;, attribute.name.c_str(), location);
</ins><span class="cx"> 
</span><span class="cx">                 return false;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            for (int i = 0; i &lt; rows; i++)
</del><ins>+            for (int row = 0; row &lt; rows; row++)
</ins><span class="cx">             {
</span><del>-                usedLocations |= 1 &lt;&lt; (location + i);
</del><ins>+                const int rowLocation = location + row;
+                gl::ShaderVariable &amp;linkedAttribute = mLinkedAttribute[rowLocation];
+
+                // In GLSL 3.00, attribute aliasing produces a link error
+                // In GLSL 1.00, attribute aliasing is allowed
+                if (mShaderVersion &gt;= 300)
+                {
+                    if (!linkedAttribute.name.empty())
+                    {
+                        infoLog.append(&quot;Attribute '%s' aliases attribute '%s' at location %d&quot;, attribute.name.c_str(), linkedAttribute.name.c_str(), rowLocation);
+                        return false;
+                    }
+                }
+
+                linkedAttribute = attribute;
+                usedLocations |= 1 &lt;&lt; rowLocation;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Link attributes that don't have a binding location
</span><del>-    for (AttributeArray::iterator attribute = vertexShader-&gt;mAttributes.begin(); attribute != vertexShader-&gt;mAttributes.end(); attribute++)
</del><ins>+    for (unsigned int attributeIndex = 0; attributeIndex &lt; activeAttributes.size(); attributeIndex++)
</ins><span class="cx">     {
</span><del>-        int location = attributeBindings.getAttributeBinding(attribute-&gt;name);
</del><ins>+        const gl::Attribute &amp;attribute = activeAttributes[attributeIndex];
+        const int location = attribute.location == -1 ? attributeBindings.getAttributeBinding(attribute.name) : attribute.location;
</ins><span class="cx"> 
</span><del>-        if (location == -1)   // Not set by glBindAttribLocation
</del><ins>+        if (location == -1)   // Not set by glBindAttribLocation or by location layout qualifier
</ins><span class="cx">         {
</span><del>-            int rows = VariableRowCount(attribute-&gt;type);
</del><ins>+            int rows = AttributeRegisterCount(attribute.type);
</ins><span class="cx">             int availableIndex = AllocateFirstFreeBits(&amp;usedLocations, rows, MAX_VERTEX_ATTRIBS);
</span><span class="cx"> 
</span><span class="cx">             if (availableIndex == -1 || availableIndex + rows &gt; MAX_VERTEX_ATTRIBS)
</span><span class="cx">             {
</span><del>-                infoLog.append(&quot;Too many active attributes (%s)&quot;, attribute-&gt;name.c_str());
</del><ins>+                infoLog.append(&quot;Too many active attributes (%s)&quot;, attribute.name.c_str());
</ins><span class="cx"> 
</span><span class="cx">                 return false;   // Fail to link
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            mLinkedAttribute[availableIndex] = *attribute;
</del><ins>+            mLinkedAttribute[availableIndex] = attribute;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (int attributeIndex = 0; attributeIndex &lt; MAX_VERTEX_ATTRIBS; )
</span><span class="cx">     {
</span><span class="cx">         int index = vertexShader-&gt;getSemanticIndex(mLinkedAttribute[attributeIndex].name);
</span><del>-        int rows = std::max(VariableRowCount(mLinkedAttribute[attributeIndex].type), 1);
</del><ins>+        int rows = AttributeRegisterCount(mLinkedAttribute[attributeIndex].type);
</ins><span class="cx"> 
</span><span class="cx">         for (int r = 0; r &lt; rows; r++)
</span><span class="cx">         {
</span><span class="lines">@@ -2077,32 +1706,262 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::linkUniforms(InfoLog &amp;infoLog, const sh::ActiveUniforms &amp;vertexUniforms, const sh::ActiveUniforms &amp;fragmentUniforms)
</del><ins>+bool ProgramBinary::linkValidateVariablesBase(InfoLog &amp;infoLog, const std::string &amp;variableName, const gl::ShaderVariable &amp;vertexVariable, const gl::ShaderVariable &amp;fragmentVariable, bool validatePrecision)
</ins><span class="cx"> {
</span><del>-    for (sh::ActiveUniforms::const_iterator uniform = vertexUniforms.begin(); uniform != vertexUniforms.end(); uniform++)
</del><ins>+    if (vertexVariable.type != fragmentVariable.type)
</ins><span class="cx">     {
</span><del>-        if (!defineUniform(GL_VERTEX_SHADER, *uniform, infoLog))
</del><ins>+        infoLog.append(&quot;Types for %s differ between vertex and fragment shaders&quot;, variableName.c_str());
+        return false;
+    }
+    if (vertexVariable.arraySize != fragmentVariable.arraySize)
+    {
+        infoLog.append(&quot;Array sizes for %s differ between vertex and fragment shaders&quot;, variableName.c_str());
+        return false;
+    }
+    if (validatePrecision &amp;&amp; vertexVariable.precision != fragmentVariable.precision)
+    {
+        infoLog.append(&quot;Precisions for %s differ between vertex and fragment shaders&quot;, variableName.c_str());
+        return false;
+    }
+
+    return true;
+}
+
+template &lt;class ShaderVarType&gt;
+bool ProgramBinary::linkValidateFields(InfoLog &amp;infoLog, const std::string &amp;varName, const ShaderVarType &amp;vertexVar, const ShaderVarType &amp;fragmentVar)
+{
+    if (vertexVar.fields.size() != fragmentVar.fields.size())
+    {
+        infoLog.append(&quot;Structure lengths for %s differ between vertex and fragment shaders&quot;, varName.c_str());
+        return false;
+    }
+    const unsigned int numMembers = vertexVar.fields.size();
+    for (unsigned int memberIndex = 0; memberIndex &lt; numMembers; memberIndex++)
+    {
+        const ShaderVarType &amp;vertexMember = vertexVar.fields[memberIndex];
+        const ShaderVarType &amp;fragmentMember = fragmentVar.fields[memberIndex];
+
+        if (vertexMember.name != fragmentMember.name)
</ins><span class="cx">         {
</span><ins>+            infoLog.append(&quot;Name mismatch for field '%d' of %s: (in vertex: '%s', in fragment: '%s')&quot;,
+                           memberIndex, varName.c_str(), vertexMember.name.c_str(), fragmentMember.name.c_str());
</ins><span class="cx">             return false;
</span><span class="cx">         }
</span><ins>+
+        const std::string memberName = varName.substr(0, varName.length()-1) + &quot;.&quot; + vertexVar.name + &quot;'&quot;;
+        if (!linkValidateVariables(infoLog, memberName, vertexMember, fragmentMember))
+        {
+            return false;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (sh::ActiveUniforms::const_iterator uniform = fragmentUniforms.begin(); uniform != fragmentUniforms.end(); uniform++)
</del><ins>+    return true;
+}
+
+bool ProgramBinary::linkValidateVariables(InfoLog &amp;infoLog, const std::string &amp;uniformName, const gl::Uniform &amp;vertexUniform, const gl::Uniform &amp;fragmentUniform)
+{
+    if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
</ins><span class="cx">     {
</span><del>-        if (!defineUniform(GL_FRAGMENT_SHADER, *uniform, infoLog))
</del><ins>+        return false;
+    }
+
+    if (!linkValidateFields&lt;gl::Uniform&gt;(infoLog, uniformName, vertexUniform, fragmentUniform))
+    {
+        return false;
+    }
+
+    return true;
+}
+
+bool ProgramBinary::linkValidateVariables(InfoLog &amp;infoLog, const std::string &amp;varyingName, const gl::Varying &amp;vertexVarying, const gl::Varying &amp;fragmentVarying)
+{
+    if (!linkValidateVariablesBase(infoLog, varyingName, vertexVarying, fragmentVarying, false))
+    {
+        return false;
+    }
+
+    if (vertexVarying.interpolation != fragmentVarying.interpolation)
+    {
+        infoLog.append(&quot;Interpolation types for %s differ between vertex and fragment shaders&quot;, varyingName.c_str());
+        return false;
+    }
+
+    if (!linkValidateFields&lt;gl::Varying&gt;(infoLog, varyingName, vertexVarying, fragmentVarying))
+    {
+        return false;
+    }
+
+    return true;
+}
+
+bool ProgramBinary::linkValidateVariables(InfoLog &amp;infoLog, const std::string &amp;uniformName, const gl::InterfaceBlockField &amp;vertexUniform, const gl::InterfaceBlockField &amp;fragmentUniform)
+{
+    if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
+    {
+        return false;
+    }
+
+    if (vertexUniform.isRowMajorMatrix != fragmentUniform.isRowMajorMatrix)
+    {
+        infoLog.append(&quot;Matrix packings for %s differ between vertex and fragment shaders&quot;, uniformName.c_str());
+        return false;
+    }
+
+    if (!linkValidateFields&lt;gl::InterfaceBlockField&gt;(infoLog, uniformName, vertexUniform, fragmentUniform))
+    {
+        return false;
+    }
+
+    return true;
+}
+
+bool ProgramBinary::linkUniforms(InfoLog &amp;infoLog, const std::vector&lt;gl::Uniform&gt; &amp;vertexUniforms, const std::vector&lt;gl::Uniform&gt; &amp;fragmentUniforms)
+{
+    // Check that uniforms defined in the vertex and fragment shaders are identical
+    typedef std::map&lt;std::string, const gl::Uniform*&gt; UniformMap;
+    UniformMap linkedUniforms;
+
+    for (unsigned int vertexUniformIndex = 0; vertexUniformIndex &lt; vertexUniforms.size(); vertexUniformIndex++)
+    {
+        const gl::Uniform &amp;vertexUniform = vertexUniforms[vertexUniformIndex];
+        linkedUniforms[vertexUniform.name] = &amp;vertexUniform;
+    }
+
+    for (unsigned int fragmentUniformIndex = 0; fragmentUniformIndex &lt; fragmentUniforms.size(); fragmentUniformIndex++)
+    {
+        const gl::Uniform &amp;fragmentUniform = fragmentUniforms[fragmentUniformIndex];
+        UniformMap::const_iterator entry = linkedUniforms.find(fragmentUniform.name);
+        if (entry != linkedUniforms.end())
</ins><span class="cx">         {
</span><ins>+            const gl::Uniform &amp;vertexUniform = *entry-&gt;second;
+            const std::string &amp;uniformName = &quot;uniform '&quot; + vertexUniform.name + &quot;'&quot;;
+            if (!linkValidateVariables(infoLog, uniformName, vertexUniform, fragmentUniform))
+            {
+                return false;
+            }
+        }
+    }
+
+    for (unsigned int uniformIndex = 0; uniformIndex &lt; vertexUniforms.size(); uniformIndex++)
+    {
+        if (!defineUniform(GL_VERTEX_SHADER, vertexUniforms[uniformIndex], infoLog))
+        {
</ins><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    for (unsigned int uniformIndex = 0; uniformIndex &lt; fragmentUniforms.size(); uniformIndex++)
+    {
+        if (!defineUniform(GL_FRAGMENT_SHADER, fragmentUniforms[uniformIndex], infoLog))
+        {
+            return false;
+        }
+    }
+
+    initializeUniformStorage();
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &amp;constant, InfoLog &amp;infoLog)
</del><ins>+int totalRegisterCount(const gl::Uniform &amp;uniform)
</ins><span class="cx"> {
</span><del>-    if (constant.type == GL_SAMPLER_2D ||
-        constant.type == GL_SAMPLER_CUBE)
</del><ins>+    int registerCount = 0;
+
+    if (!uniform.fields.empty())
</ins><span class="cx">     {
</span><ins>+        for (unsigned int fieldIndex = 0; fieldIndex &lt; uniform.fields.size(); fieldIndex++)
+        {
+            registerCount += totalRegisterCount(uniform.fields[fieldIndex]);
+        }
+    }
+    else
+    {
+        registerCount = 1;
+    }
+
+    return (uniform.arraySize &gt; 0) ? uniform.arraySize * registerCount : registerCount;
+}
+
+TextureType ProgramBinary::getTextureType(GLenum samplerType, InfoLog &amp;infoLog)
+{
+    switch(samplerType)
+    {
+      case GL_SAMPLER_2D:
+      case GL_INT_SAMPLER_2D:
+      case GL_UNSIGNED_INT_SAMPLER_2D:
+      case GL_SAMPLER_2D_SHADOW:
+        return TEXTURE_2D;
+      case GL_SAMPLER_3D:
+      case GL_INT_SAMPLER_3D:
+      case GL_UNSIGNED_INT_SAMPLER_3D:
+        return TEXTURE_3D;
+      case GL_SAMPLER_CUBE:
+      case GL_SAMPLER_CUBE_SHADOW:
+        return TEXTURE_CUBE;
+      case GL_INT_SAMPLER_CUBE:
+      case GL_UNSIGNED_INT_SAMPLER_CUBE:
+        return TEXTURE_CUBE;
+      case GL_SAMPLER_2D_ARRAY:
+      case GL_INT_SAMPLER_2D_ARRAY:
+      case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
+      case GL_SAMPLER_2D_ARRAY_SHADOW:
+        return TEXTURE_2D_ARRAY;
+      default: UNREACHABLE();
+    }
+
+    return TEXTURE_2D;
+}
+
+bool ProgramBinary::defineUniform(GLenum shader, const gl::Uniform &amp;constant, InfoLog &amp;infoLog)
+{
+    if (constant.isStruct())
+    {
+        if (constant.arraySize &gt; 0)
+        {
+            unsigned int elementRegisterIndex = constant.registerIndex;
+
+            for (unsigned int elementIndex = 0; elementIndex &lt; constant.arraySize; elementIndex++)
+            {
+                for (size_t fieldIndex = 0; fieldIndex &lt; constant.fields.size(); fieldIndex++)
+                {
+                    const gl::Uniform &amp;field = constant.fields[fieldIndex];
+                    const std::string &amp;uniformName = constant.name + ArrayString(elementIndex) + &quot;.&quot; + field.name;
+                    gl::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
+                                             elementRegisterIndex, field.elementIndex);
+
+                    fieldUniform.fields = field.fields;
+                    if (!defineUniform(shader, fieldUniform, infoLog))
+                    {
+                        return false;
+                    }
+                    elementRegisterIndex += totalRegisterCount(field);
+                }
+            }
+        }
+        else
+        {
+            for (size_t fieldIndex = 0; fieldIndex &lt; constant.fields.size(); fieldIndex++)
+            {
+                const gl::Uniform &amp;field = constant.fields[fieldIndex];
+                const std::string &amp;uniformName = constant.name + &quot;.&quot; + field.name;
+
+                gl::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
+                                         field.registerIndex, field.elementIndex);
+
+                fieldUniform.fields = field.fields;
+
+                if (!defineUniform(shader, fieldUniform, infoLog))
+                {
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
+
+    if (IsSampler(constant.type))
+    {
</ins><span class="cx">         unsigned int samplerIndex = constant.registerIndex;
</span><span class="cx">             
</span><span class="cx">         do
</span><span class="lines">@@ -2112,7 +1971,7 @@
</span><span class="cx">                 if (samplerIndex &lt; mRenderer-&gt;getMaxVertexTextureImageUnits())
</span><span class="cx">                 {
</span><span class="cx">                     mSamplersVS[samplerIndex].active = true;
</span><del>-                    mSamplersVS[samplerIndex].textureType = (constant.type == GL_SAMPLER_CUBE) ? TEXTURE_CUBE : TEXTURE_2D;
</del><ins>+                    mSamplersVS[samplerIndex].textureType = getTextureType(constant.type, infoLog);
</ins><span class="cx">                     mSamplersVS[samplerIndex].logicalTextureUnit = 0;
</span><span class="cx">                     mUsedVertexSamplerRange = std::max(samplerIndex + 1, mUsedVertexSamplerRange);
</span><span class="cx">                 }
</span><span class="lines">@@ -2127,7 +1986,7 @@
</span><span class="cx">                 if (samplerIndex &lt; MAX_TEXTURE_IMAGE_UNITS)
</span><span class="cx">                 {
</span><span class="cx">                     mSamplersPS[samplerIndex].active = true;
</span><del>-                    mSamplersPS[samplerIndex].textureType = (constant.type == GL_SAMPLER_CUBE) ? TEXTURE_CUBE : TEXTURE_2D;
</del><ins>+                    mSamplersPS[samplerIndex].textureType = getTextureType(constant.type, infoLog);
</ins><span class="cx">                     mSamplersPS[samplerIndex].logicalTextureUnit = 0;
</span><span class="cx">                     mUsedPixelSamplerRange = std::max(samplerIndex + 1, mUsedPixelSamplerRange);
</span><span class="cx">                 }
</span><span class="lines">@@ -2144,28 +2003,17 @@
</span><span class="cx">         while (samplerIndex &lt; constant.registerIndex + constant.arraySize);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Uniform *uniform = NULL;
</del><ins>+    LinkedUniform *uniform = NULL;
</ins><span class="cx">     GLint location = getUniformLocation(constant.name);
</span><span class="cx"> 
</span><span class="cx">     if (location &gt;= 0)   // Previously defined, type and precision must match
</span><span class="cx">     {
</span><span class="cx">         uniform = mUniforms[mUniformIndex[location].index];
</span><del>-
-        if (uniform-&gt;type != constant.type)
-        {
-            infoLog.append(&quot;Types for uniform %s do not match between the vertex and fragment shader&quot;, uniform-&gt;name.c_str());
-            return false;
-        }
-
-        if (uniform-&gt;precision != constant.precision)
-        {
-            infoLog.append(&quot;Precisions for uniform %s do not match between the vertex and fragment shader&quot;, uniform-&gt;name.c_str());
-            return false;
-        }
</del><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        uniform = new Uniform(constant.type, constant.precision, constant.name, constant.arraySize);
</del><ins>+        uniform = new LinkedUniform(constant.type, constant.precision, constant.name, constant.arraySize, -1, gl::BlockMemberInfo::defaultBlockInfo);
+        uniform-&gt;registerElement = constant.elementIndex;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!uniform)
</span><span class="lines">@@ -2191,9 +2039,9 @@
</span><span class="cx">     mUniforms.push_back(uniform);
</span><span class="cx">     unsigned int uniformIndex = mUniforms.size() - 1;
</span><span class="cx"> 
</span><del>-    for (unsigned int i = 0; i &lt; uniform-&gt;elementCount(); i++)
</del><ins>+    for (unsigned int arrayElementIndex = 0; arrayElementIndex &lt; uniform-&gt;elementCount(); arrayElementIndex++)
</ins><span class="cx">     {
</span><del>-        mUniformIndex.push_back(UniformLocation(constant.name, i, uniformIndex));
</del><ins>+        mUniformIndex.push_back(VariableLocation(uniform-&gt;name, arrayElementIndex, uniformIndex));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (shader == GL_VERTEX_SHADER)
</span><span class="lines">@@ -2217,152 +2065,268 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::string ProgramBinary::generateGeometryShaderHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
</del><ins>+bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &amp;infoLog, const gl::InterfaceBlock &amp;vertexInterfaceBlock, const gl::InterfaceBlock &amp;fragmentInterfaceBlock)
</ins><span class="cx"> {
</span><del>-    // for now we only handle point sprite emulation
-    ASSERT(usesPointSpriteEmulation());
-    return generatePointSpriteHLSL(registers, packing, fragmentShader, vertexShader);
-}
</del><ins>+    const char* blockName = vertexInterfaceBlock.name.c_str();
</ins><span class="cx"> 
</span><del>-std::string ProgramBinary::generatePointSpriteHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
-{
-    ASSERT(registers &gt;= 0);
-    ASSERT(vertexShader-&gt;mUsesPointSize);
-    ASSERT(mRenderer-&gt;getMajorShaderModel() &gt;= 4);
</del><ins>+    // validate blocks for the same member types
+    if (vertexInterfaceBlock.fields.size() != fragmentInterfaceBlock.fields.size())
+    {
+        infoLog.append(&quot;Types for interface block '%s' differ between vertex and fragment shaders&quot;, blockName);
+        return false;
+    }
</ins><span class="cx"> 
</span><del>-    std::string geomHLSL;
</del><ins>+    if (vertexInterfaceBlock.arraySize != fragmentInterfaceBlock.arraySize)
+    {
+        infoLog.append(&quot;Array sizes differ for interface block '%s' between vertex and fragment shaders&quot;, blockName);
+        return false;
+    }
</ins><span class="cx"> 
</span><del>-    std::string varyingSemantic = &quot;TEXCOORD&quot;;
</del><ins>+    if (vertexInterfaceBlock.layout != fragmentInterfaceBlock.layout || vertexInterfaceBlock.isRowMajorLayout != fragmentInterfaceBlock.isRowMajorLayout)
+    {
+        infoLog.append(&quot;Layout qualifiers differ for interface block '%s' between vertex and fragment shaders&quot;, blockName);
+        return false;
+    }
</ins><span class="cx"> 
</span><del>-    std::string fragCoordSemantic;
-    std::string pointCoordSemantic;
</del><ins>+    const unsigned int numBlockMembers = vertexInterfaceBlock.fields.size();
+    for (unsigned int blockMemberIndex = 0; blockMemberIndex &lt; numBlockMembers; blockMemberIndex++)
+    {
+        const gl::InterfaceBlockField &amp;vertexMember = vertexInterfaceBlock.fields[blockMemberIndex];
+        const gl::InterfaceBlockField &amp;fragmentMember = fragmentInterfaceBlock.fields[blockMemberIndex];
</ins><span class="cx"> 
</span><del>-    int reservedRegisterIndex = registers;
</del><ins>+        if (vertexMember.name != fragmentMember.name)
+        {
+            infoLog.append(&quot;Name mismatch for field %d of interface block '%s': (in vertex: '%s', in fragment: '%s')&quot;,
+                           blockMemberIndex, blockName, vertexMember.name.c_str(), fragmentMember.name.c_str());
+            return false;
+        }
</ins><span class="cx"> 
</span><del>-    if (fragmentShader-&gt;mUsesFragCoord)
</del><ins>+        std::string uniformName = &quot;interface block '&quot; + vertexInterfaceBlock.name + &quot;' member '&quot; + vertexMember.name + &quot;'&quot;;
+        if (!linkValidateVariables(infoLog, uniformName, vertexMember, fragmentMember))
+        {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool ProgramBinary::linkUniformBlocks(InfoLog &amp;infoLog, const std::vector&lt;gl::InterfaceBlock&gt; &amp;vertexInterfaceBlocks,
+                                      const std::vector&lt;gl::InterfaceBlock&gt; &amp;fragmentInterfaceBlocks)
+{
+    // Check that interface blocks defined in the vertex and fragment shaders are identical
+    typedef std::map&lt;std::string, const gl::InterfaceBlock*&gt; UniformBlockMap;
+    UniformBlockMap linkedUniformBlocks;
+
+    for (unsigned int blockIndex = 0; blockIndex &lt; vertexInterfaceBlocks.size(); blockIndex++)
</ins><span class="cx">     {
</span><del>-        fragCoordSemantic = varyingSemantic + str(reservedRegisterIndex++);
</del><ins>+        const gl::InterfaceBlock &amp;vertexInterfaceBlock = vertexInterfaceBlocks[blockIndex];
+        linkedUniformBlocks[vertexInterfaceBlock.name] = &amp;vertexInterfaceBlock;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (fragmentShader-&gt;mUsesPointCoord)
</del><ins>+    for (unsigned int blockIndex = 0; blockIndex &lt; fragmentInterfaceBlocks.size(); blockIndex++)
</ins><span class="cx">     {
</span><del>-        pointCoordSemantic = varyingSemantic + str(reservedRegisterIndex++);
</del><ins>+        const gl::InterfaceBlock &amp;fragmentInterfaceBlock = fragmentInterfaceBlocks[blockIndex];
+        UniformBlockMap::const_iterator entry = linkedUniformBlocks.find(fragmentInterfaceBlock.name);
+        if (entry != linkedUniformBlocks.end())
+        {
+            const gl::InterfaceBlock &amp;vertexInterfaceBlock = *entry-&gt;second;
+            if (!areMatchingInterfaceBlocks(infoLog, vertexInterfaceBlock, fragmentInterfaceBlock))
+            {
+                return false;
+            }
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    geomHLSL += &quot;uniform float4 dx_ViewCoords : register(c1);\n&quot;
-                &quot;\n&quot;
-                &quot;struct GS_INPUT\n&quot;
-                &quot;{\n&quot;;
-
-    for (int r = 0; r &lt; registers; r++)
</del><ins>+    for (unsigned int blockIndex = 0; blockIndex &lt; vertexInterfaceBlocks.size(); blockIndex++)
</ins><span class="cx">     {
</span><del>-        int registerSize = packing[r][3] ? 4 : (packing[r][2] ? 3 : (packing[r][1] ? 2 : 1));
-
-        geomHLSL += &quot;    float&quot; + str(registerSize) + &quot; v&quot; + str(r) + &quot; : &quot; + varyingSemantic + str(r) + &quot;;\n&quot;;
</del><ins>+        if (!defineUniformBlock(infoLog, GL_VERTEX_SHADER, vertexInterfaceBlocks[blockIndex]))
+        {
+            return false;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (fragmentShader-&gt;mUsesFragCoord)
</del><ins>+    for (unsigned int blockIndex = 0; blockIndex &lt; fragmentInterfaceBlocks.size(); blockIndex++)
</ins><span class="cx">     {
</span><del>-        geomHLSL += &quot;    float4 gl_FragCoord : &quot; + fragCoordSemantic + &quot;;\n&quot;;
</del><ins>+        if (!defineUniformBlock(infoLog, GL_FRAGMENT_SHADER, fragmentInterfaceBlocks[blockIndex]))
+        {
+            return false;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    geomHLSL += &quot;    float gl_PointSize : PSIZE;\n&quot;
-                &quot;    float4 gl_Position : SV_Position;\n&quot;
-                &quot;};\n&quot;
-                &quot;\n&quot;
-                &quot;struct GS_OUTPUT\n&quot;
-                &quot;{\n&quot;;
</del><ins>+    return true;
+}
</ins><span class="cx"> 
</span><del>-    for (int r = 0; r &lt; registers; r++)
</del><ins>+bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &amp;infoLog, const std::vector&lt;LinkedVarying&gt; &amp;linkedVaryings,
+                                                          const std::vector&lt;std::string&gt; &amp;transformFeedbackVaryingNames,
+                                                          GLenum transformFeedbackBufferMode,
+                                                          std::vector&lt;LinkedVarying&gt; *outTransformFeedbackLinkedVaryings) const
+{
+    size_t totalComponents = 0;
+    const size_t maxSeparateComponents = mRenderer-&gt;getMaxTransformFeedbackSeparateComponents();
+    const size_t maxInterleavedComponents = mRenderer-&gt;getMaxTransformFeedbackInterleavedComponents();
+
+    // Gather the linked varyings that are used for transform feedback, they should all exist.
+    outTransformFeedbackLinkedVaryings-&gt;clear();
+    for (size_t i = 0; i &lt; transformFeedbackVaryingNames.size(); i++)
</ins><span class="cx">     {
</span><del>-        int registerSize = packing[r][3] ? 4 : (packing[r][2] ? 3 : (packing[r][1] ? 2 : 1));
</del><ins>+        bool found = false;
+        for (size_t j = 0; j &lt; linkedVaryings.size(); j++)
+        {
+            if (transformFeedbackVaryingNames[i] == linkedVaryings[j].name)
+            {
+                for (size_t k = 0; k &lt; outTransformFeedbackLinkedVaryings-&gt;size(); k++)
+                {
+                    if (outTransformFeedbackLinkedVaryings-&gt;at(k).name == linkedVaryings[j].name)
+                    {
+                        infoLog.append(&quot;Two transform feedback varyings specify the same output variable (%s).&quot;, linkedVaryings[j].name.c_str());
+                        return false;
+                    }
+                }
</ins><span class="cx"> 
</span><del>-        geomHLSL += &quot;    float&quot; + str(registerSize) + &quot; v&quot; + str(r) + &quot; : &quot; + varyingSemantic + str(r) + &quot;;\n&quot;;
</del><ins>+                size_t componentCount = linkedVaryings[j].semanticIndexCount * 4;
+                if (transformFeedbackBufferMode == GL_SEPARATE_ATTRIBS &amp;&amp;
+                    componentCount &gt; maxSeparateComponents)
+                {
+                    infoLog.append(&quot;Transform feedback varying's %s components (%u) exceed the maximum separate components (%u).&quot;,
+                                   linkedVaryings[j].name.c_str(), componentCount, maxSeparateComponents);
+                    return false;
+                }
+
+                totalComponents += componentCount;
+
+                outTransformFeedbackLinkedVaryings-&gt;push_back(linkedVaryings[j]);
+                found = true;
+                break;
+            }
+        }
+
+        // All transform feedback varyings are expected to exist since packVaryings checks for them.
+        ASSERT(found);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (fragmentShader-&gt;mUsesFragCoord)
</del><ins>+    if (transformFeedbackBufferMode == GL_INTERLEAVED_ATTRIBS &amp;&amp; totalComponents &gt; maxInterleavedComponents)
</ins><span class="cx">     {
</span><del>-        geomHLSL += &quot;    float4 gl_FragCoord : &quot; + fragCoordSemantic + &quot;;\n&quot;;
</del><ins>+        infoLog.append(&quot;Transform feedback varying total components (%u) exceed the maximum interleaved components (%u).&quot;,
+                       totalComponents, maxInterleavedComponents);
+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (fragmentShader-&gt;mUsesPointCoord)
</del><ins>+    return true;
+}
+
+void ProgramBinary::defineUniformBlockMembers(const std::vector&lt;gl::InterfaceBlockField&gt; &amp;fields, const std::string &amp;prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector&lt;unsigned int&gt; *blockUniformIndexes)
+{
+    for (unsigned int uniformIndex = 0; uniformIndex &lt; fields.size(); uniformIndex++)
</ins><span class="cx">     {
</span><del>-        geomHLSL += &quot;    float2 gl_PointCoord : &quot; + pointCoordSemantic + &quot;;\n&quot;;
-    }
</del><ins>+        const gl::InterfaceBlockField &amp;field = fields[uniformIndex];
+        const std::string &amp;fieldName = (prefix.empty() ? field.name : prefix + &quot;.&quot; + field.name);
</ins><span class="cx"> 
</span><del>-    geomHLSL +=   &quot;    float gl_PointSize : PSIZE;\n&quot;
-                  &quot;    float4 gl_Position : SV_Position;\n&quot;
-                  &quot;};\n&quot;
-                  &quot;\n&quot;
-                  &quot;static float2 pointSpriteCorners[] = \n&quot;
-                  &quot;{\n&quot;
-                  &quot;    float2( 0.5f, -0.5f),\n&quot;
-                  &quot;    float2( 0.5f,  0.5f),\n&quot;
-                  &quot;    float2(-0.5f, -0.5f),\n&quot;
-                  &quot;    float2(-0.5f,  0.5f)\n&quot;
-                  &quot;};\n&quot;
-                  &quot;\n&quot;
-                  &quot;static float2 pointSpriteTexcoords[] = \n&quot;
-                  &quot;{\n&quot;
-                  &quot;    float2(1.0f, 1.0f),\n&quot;
-                  &quot;    float2(1.0f, 0.0f),\n&quot;
-                  &quot;    float2(0.0f, 1.0f),\n&quot;
-                  &quot;    float2(0.0f, 0.0f)\n&quot;
-                  &quot;};\n&quot;
-                  &quot;\n&quot;
-                  &quot;static float minPointSize = &quot; + str(ALIASED_POINT_SIZE_RANGE_MIN) + &quot;.0f;\n&quot;
-                  &quot;static float maxPointSize = &quot; + str(mRenderer-&gt;getMaxPointSize()) + &quot;.0f;\n&quot;
-                  &quot;\n&quot;
-                  &quot;[maxvertexcount(4)]\n&quot;
-                  &quot;void main(point GS_INPUT input[1], inout TriangleStream&lt;GS_OUTPUT&gt; outStream)\n&quot;
-                  &quot;{\n&quot;
-                  &quot;    GS_OUTPUT output = (GS_OUTPUT)0;\n&quot;
-                  &quot;    output.gl_PointSize = input[0].gl_PointSize;\n&quot;;
</del><ins>+        if (!field.fields.empty())
+        {
+            if (field.arraySize &gt; 0)
+            {
+                for (unsigned int arrayElement = 0; arrayElement &lt; field.arraySize; arrayElement++)
+                {
+                    const std::string uniformElementName = fieldName + ArrayString(arrayElement);
+                    defineUniformBlockMembers(field.fields, uniformElementName, blockIndex, blockInfoItr, blockUniformIndexes);
+                }
+            }
+            else
+            {
+                defineUniformBlockMembers(field.fields, fieldName, blockIndex, blockInfoItr, blockUniformIndexes);
+            }
+        }
+        else
+        {
+            LinkedUniform *newUniform = new LinkedUniform(field.type, field.precision, fieldName, field.arraySize,
+                                                          blockIndex, **blockInfoItr);
</ins><span class="cx"> 
</span><del>-    for (int r = 0; r &lt; registers; r++)
-    {
-        geomHLSL += &quot;    output.v&quot; + str(r) + &quot; = input[0].v&quot; + str(r) + &quot;;\n&quot;;
</del><ins>+            // add to uniform list, but not index, since uniform block uniforms have no location
+            blockUniformIndexes-&gt;push_back(mUniforms.size());
+            mUniforms.push_back(newUniform);
+            (*blockInfoItr)++;
+        }
</ins><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    if (fragmentShader-&gt;mUsesFragCoord)
</del><ins>+bool ProgramBinary::defineUniformBlock(InfoLog &amp;infoLog, GLenum shader, const gl::InterfaceBlock &amp;interfaceBlock)
+{
+    // create uniform block entries if they do not exist
+    if (getUniformBlockIndex(interfaceBlock.name) == GL_INVALID_INDEX)
</ins><span class="cx">     {
</span><del>-        geomHLSL += &quot;    output.gl_FragCoord = input[0].gl_FragCoord;\n&quot;;
</del><ins>+        std::vector&lt;unsigned int&gt; blockUniformIndexes;
+        const unsigned int blockIndex = mUniformBlocks.size();
+
+        // define member uniforms
+        BlockInfoItr blockInfoItr = interfaceBlock.blockInfo.cbegin();
+        defineUniformBlockMembers(interfaceBlock.fields, &quot;&quot;, blockIndex, &amp;blockInfoItr, &amp;blockUniformIndexes);
+
+        // create all the uniform blocks
+        if (interfaceBlock.arraySize &gt; 0)
+        {
+            for (unsigned int uniformBlockElement = 0; uniformBlockElement &lt; interfaceBlock.arraySize; uniformBlockElement++)
+            {
+                gl::UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, uniformBlockElement, interfaceBlock.dataSize);
+                newUniformBlock-&gt;memberUniformIndexes = blockUniformIndexes;
+                mUniformBlocks.push_back(newUniformBlock);
+            }
+        }
+        else
+        {
+            gl::UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, GL_INVALID_INDEX, interfaceBlock.dataSize);
+            newUniformBlock-&gt;memberUniformIndexes = blockUniformIndexes;
+            mUniformBlocks.push_back(newUniformBlock);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    geomHLSL += &quot;    \n&quot;
-                &quot;    float gl_PointSize = clamp(input[0].gl_PointSize, minPointSize, maxPointSize);\n&quot;
-                &quot;    float4 gl_Position = input[0].gl_Position;\n&quot;
-                &quot;    float2 viewportScale = float2(1.0f / dx_ViewCoords.x, 1.0f / dx_ViewCoords.y) * gl_Position.w;\n&quot;;
</del><ins>+    // Assign registers to the uniform blocks
+    const GLuint blockIndex = getUniformBlockIndex(interfaceBlock.name);
+    const unsigned int elementCount = std::max(1u, interfaceBlock.arraySize);
+    ASSERT(blockIndex != GL_INVALID_INDEX);
+    ASSERT(blockIndex + elementCount &lt;= mUniformBlocks.size());
</ins><span class="cx"> 
</span><del>-    for (int corner = 0; corner &lt; 4; corner++)
</del><ins>+    for (unsigned int uniformBlockElement = 0; uniformBlockElement &lt; elementCount; uniformBlockElement++)
</ins><span class="cx">     {
</span><del>-        geomHLSL += &quot;    \n&quot;
-                    &quot;    output.gl_Position = gl_Position + float4(pointSpriteCorners[&quot; + str(corner) + &quot;] * viewportScale * gl_PointSize, 0.0f, 0.0f);\n&quot;;
</del><ins>+        gl::UniformBlock *uniformBlock = mUniformBlocks[blockIndex + uniformBlockElement];
+        ASSERT(uniformBlock-&gt;name == interfaceBlock.name);
</ins><span class="cx"> 
</span><del>-        if (fragmentShader-&gt;mUsesPointCoord)
</del><ins>+        if (!assignUniformBlockRegister(infoLog, uniformBlock, shader, interfaceBlock.registerIndex + uniformBlockElement))
</ins><span class="cx">         {
</span><del>-            geomHLSL += &quot;    output.gl_PointCoord = pointSpriteTexcoords[&quot; + str(corner) + &quot;];\n&quot;;
</del><ins>+            return false;
</ins><span class="cx">         }
</span><del>-
-        geomHLSL += &quot;    outStream.Append(output);\n&quot;;
</del><span class="cx">     }
</span><span class="cx"> 
</span><del>-    geomHLSL += &quot;    \n&quot;
-                &quot;    outStream.RestartStrip();\n&quot;
-                &quot;}\n&quot;;
-
-    return geomHLSL;
</del><ins>+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-// This method needs to match OutputHLSL::decorate
-std::string ProgramBinary::decorateAttribute(const std::string &amp;name)
</del><ins>+bool ProgramBinary::assignUniformBlockRegister(InfoLog &amp;infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex)
</ins><span class="cx"> {
</span><del>-    if (name.compare(0, 3, &quot;gl_&quot;) != 0 &amp;&amp; name.compare(0, 3, &quot;dx_&quot;) != 0)
</del><ins>+    if (shader == GL_VERTEX_SHADER)
</ins><span class="cx">     {
</span><del>-        return &quot;_&quot; + name;
</del><ins>+        uniformBlock-&gt;vsRegisterIndex = registerIndex;
+        unsigned int maximumBlocks = mRenderer-&gt;getMaxVertexShaderUniformBuffers();
+
+        if (registerIndex - mRenderer-&gt;getReservedVertexUniformBuffers() &gt;= maximumBlocks)
+        {
+            infoLog.append(&quot;Vertex shader uniform block count exceed GL_MAX_VERTEX_UNIFORM_BLOCKS (%u)&quot;, maximumBlocks);
+            return false;
+        }
</ins><span class="cx">     }
</span><del>-    
-    return name;
</del><ins>+    else if (shader == GL_FRAGMENT_SHADER)
+    {
+        uniformBlock-&gt;psRegisterIndex = registerIndex;
+        unsigned int maximumBlocks = mRenderer-&gt;getMaxFragmentShaderUniformBuffers();
+
+        if (registerIndex - mRenderer-&gt;getReservedFragmentUniformBuffers() &gt;= maximumBlocks)
+        {
+            infoLog.append(&quot;Fragment shader uniform block count exceed GL_MAX_FRAGMENT_UNIFORM_BLOCKS (%u)&quot;, maximumBlocks);
+            return false;
+        }
+    }
+    else UNREACHABLE();
+
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ProgramBinary::isValidated() const 
</span><span class="lines">@@ -2491,6 +2455,116 @@
</span><span class="cx">     return maxLength;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLint ProgramBinary::getActiveUniformi(GLuint index, GLenum pname) const
+{
+    const gl::LinkedUniform&amp; uniform = *mUniforms[index];
+
+    switch (pname)
+    {
+      case GL_UNIFORM_TYPE:         return static_cast&lt;GLint&gt;(uniform.type);
+      case GL_UNIFORM_SIZE:         return static_cast&lt;GLint&gt;(uniform.elementCount());
+      case GL_UNIFORM_NAME_LENGTH:  return static_cast&lt;GLint&gt;(uniform.name.size() + 1 + (uniform.isArray() ? 3 : 0));
+      case GL_UNIFORM_BLOCK_INDEX:  return uniform.blockIndex;
+
+      case GL_UNIFORM_OFFSET:       return uniform.blockInfo.offset;
+      case GL_UNIFORM_ARRAY_STRIDE: return uniform.blockInfo.arrayStride;
+      case GL_UNIFORM_MATRIX_STRIDE: return uniform.blockInfo.matrixStride;
+      case GL_UNIFORM_IS_ROW_MAJOR: return static_cast&lt;GLint&gt;(uniform.blockInfo.isRowMajorMatrix);
+
+      default:
+        UNREACHABLE();
+        break;
+    }
+    return 0;
+}
+
+void ProgramBinary::getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) const
+{
+    ASSERT(uniformBlockIndex &lt; mUniformBlocks.size());   // index must be smaller than getActiveUniformBlockCount()
+
+    const UniformBlock &amp;uniformBlock = *mUniformBlocks[uniformBlockIndex];
+
+    if (bufSize &gt; 0)
+    {
+        std::string string = uniformBlock.name;
+
+        if (uniformBlock.isArrayElement())
+        {
+            string += ArrayString(uniformBlock.elementIndex);
+        }
+
+        strncpy(uniformBlockName, string.c_str(), bufSize);
+        uniformBlockName[bufSize - 1] = '\0';
+
+        if (length)
+        {
+            *length = strlen(uniformBlockName);
+        }
+    }
+}
+
+void ProgramBinary::getActiveUniformBlockiv(GLuint uniformBlockIndex, GLenum pname, GLint *params) const
+{
+    ASSERT(uniformBlockIndex &lt; mUniformBlocks.size());   // index must be smaller than getActiveUniformBlockCount()
+
+    const UniformBlock &amp;uniformBlock = *mUniformBlocks[uniformBlockIndex];
+
+    switch (pname)
+    {
+      case GL_UNIFORM_BLOCK_DATA_SIZE:
+        *params = static_cast&lt;GLint&gt;(uniformBlock.dataSize);
+        break;
+      case GL_UNIFORM_BLOCK_NAME_LENGTH:
+        *params = static_cast&lt;GLint&gt;(uniformBlock.name.size() + 1 + (uniformBlock.isArrayElement() ? 3 : 0));
+        break;
+      case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
+        *params = static_cast&lt;GLint&gt;(uniformBlock.memberUniformIndexes.size());
+        break;
+      case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
+        {
+            for (unsigned int blockMemberIndex = 0; blockMemberIndex &lt; uniformBlock.memberUniformIndexes.size(); blockMemberIndex++)
+            {
+                params[blockMemberIndex] = static_cast&lt;GLint&gt;(uniformBlock.memberUniformIndexes[blockMemberIndex]);
+            }
+        }
+        break;
+      case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
+        *params = static_cast&lt;GLint&gt;(uniformBlock.isReferencedByVertexShader());
+        break;
+      case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
+        *params = static_cast&lt;GLint&gt;(uniformBlock.isReferencedByFragmentShader());
+        break;
+      default: UNREACHABLE();
+    }
+}
+
+GLuint ProgramBinary::getActiveUniformBlockCount() const
+{
+    return mUniformBlocks.size();
+}
+
+GLuint ProgramBinary::getActiveUniformBlockMaxLength() const
+{
+    unsigned int maxLength = 0;
+
+    unsigned int numUniformBlocks = mUniformBlocks.size();
+    for (unsigned int uniformBlockIndex = 0; uniformBlockIndex &lt; numUniformBlocks; uniformBlockIndex++)
+    {
+        const UniformBlock &amp;uniformBlock = *mUniformBlocks[uniformBlockIndex];
+        if (!uniformBlock.name.empty())
+        {
+            const unsigned int length = uniformBlock.name.length() + 1;
+
+            // Counting in &quot;[0]&quot;.
+            const unsigned int arrayLength = (uniformBlock.isArrayElement() ? 3 : 0);
+
+            maxLength = std::max(length + arrayLength, maxLength);
+        }
+    }
+
+    return maxLength;
+}
+
</ins><span class="cx"> void ProgramBinary::validate(InfoLog &amp;infoLog)
</span><span class="cx"> {
</span><span class="cx">     applyUniforms();
</span><span class="lines">@@ -2639,4 +2713,30 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ProgramBinary::initializeUniformStorage()
+{
+    // Compute total default block size
+    unsigned int vertexRegisters = 0;
+    unsigned int fragmentRegisters = 0;
+    for (size_t uniformIndex = 0; uniformIndex &lt; mUniforms.size(); uniformIndex++)
+    {
+        const LinkedUniform &amp;uniform = *mUniforms[uniformIndex];
+
+        if (!IsSampler(uniform.type))
+        {
+            if (uniform.isReferencedByVertexShader())
+            {
+                vertexRegisters = std::max(vertexRegisters, uniform.vsRegisterIndex + uniform.registerCount);
+            }
+            if (uniform.isReferencedByFragmentShader())
+            {
+                fragmentRegisters = std::max(fragmentRegisters, uniform.psRegisterIndex + uniform.registerCount);
+            }
+        }
+    }
+
+    mVertexUniformStorage = mRenderer-&gt;createUniformStorage(vertexRegisters * 16u);
+    mFragmentUniformStorage = mRenderer-&gt;createUniformStorage(fragmentRegisters * 16u);
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2ProgramBinaryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ProgramBinary.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ProgramBinary.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ProgramBinary.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -11,6 +11,8 @@
</span><span class="cx"> #define LIBGLESV2_PROGRAM_BINARY_H_
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
+#include &lt;GLES3/gl3ext.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> #include &lt;GLES2/gl2ext.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -19,16 +21,19 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/RefCountObject.h&quot;
</span><span class="cx"> #include &quot;angletypes.h&quot;
</span><del>-#include &quot;libGLESv2/mathutil.h&quot;
</del><ins>+#include &quot;common/mathutil.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/Uniform.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Shader.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Constants.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/VertexDataManager.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> class ShaderExecutable;
</span><span class="cx"> class Renderer;
</span><span class="cx"> struct TranslatedAttribute;
</span><ins>+class UniformStorage;
+class DynamicHLSL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="lines">@@ -37,22 +42,40 @@
</span><span class="cx"> class VertexShader;
</span><span class="cx"> class InfoLog;
</span><span class="cx"> class AttributeBindings;
</span><del>-struct Varying;
</del><ins>+class Buffer;
</ins><span class="cx"> 
</span><span class="cx"> // Struct used for correlating uniforms/elements of uniform arrays to handles
</span><del>-struct UniformLocation
</del><ins>+struct VariableLocation
</ins><span class="cx"> {
</span><del>-    UniformLocation()
</del><ins>+    VariableLocation()
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    UniformLocation(const std::string &amp;name, unsigned int element, unsigned int index);
</del><ins>+    VariableLocation(const std::string &amp;name, unsigned int element, unsigned int index);
</ins><span class="cx"> 
</span><span class="cx">     std::string name;
</span><span class="cx">     unsigned int element;
</span><span class="cx">     unsigned int index;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+struct LinkedVarying
+{
+    LinkedVarying();
+    LinkedVarying(const std::string &amp;name, GLenum type, GLsizei size, const std::string &amp;semanticName,
+                  unsigned int semanticIndex, unsigned int semanticIndexCount);
+
+    // Original GL name
+    std::string name;
+
+    GLenum type;
+    GLsizei size;
+
+    // DirectX semantic information
+    std::string semanticName;
+    unsigned int semanticIndex;
+    unsigned int semanticIndexCount;
+};
+
</ins><span class="cx"> // This is the result of linking a program. It is the state that would be passed to ProgramBinary.
</span><span class="cx"> class ProgramBinary : public RefCountObject
</span><span class="cx"> {
</span><span class="lines">@@ -60,9 +83,9 @@
</span><span class="cx">     explicit ProgramBinary(rx::Renderer *renderer);
</span><span class="cx">     ~ProgramBinary();
</span><span class="cx"> 
</span><del>-    rx::ShaderExecutable *getPixelExecutable();
-    rx::ShaderExecutable *getVertexExecutable();
-    rx::ShaderExecutable *getGeometryExecutable();
</del><ins>+    rx::ShaderExecutable *getPixelExecutable() const;
+    rx::ShaderExecutable *getVertexExecutableForInputLayout(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS]);
+    rx::ShaderExecutable *getGeometryExecutable() const;
</ins><span class="cx"> 
</span><span class="cx">     GLuint getAttributeLocation(const char *name);
</span><span class="cx">     int getSemanticIndex(int attributeIndex);
</span><span class="lines">@@ -75,29 +98,44 @@
</span><span class="cx">     bool usesGeometryShader() const;
</span><span class="cx"> 
</span><span class="cx">     GLint getUniformLocation(std::string name);
</span><ins>+    GLuint getUniformIndex(std::string name);
+    GLuint getUniformBlockIndex(std::string name);
</ins><span class="cx">     bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
</span><span class="cx">     bool setUniform2fv(GLint location, GLsizei count, const GLfloat *v);
</span><span class="cx">     bool setUniform3fv(GLint location, GLsizei count, const GLfloat *v);
</span><span class="cx">     bool setUniform4fv(GLint location, GLsizei count, const GLfloat *v);
</span><del>-    bool setUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value);
-    bool setUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value);
-    bool setUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value);
</del><span class="cx">     bool setUniform1iv(GLint location, GLsizei count, const GLint *v);
</span><span class="cx">     bool setUniform2iv(GLint location, GLsizei count, const GLint *v);
</span><span class="cx">     bool setUniform3iv(GLint location, GLsizei count, const GLint *v);
</span><span class="cx">     bool setUniform4iv(GLint location, GLsizei count, const GLint *v);
</span><ins>+    bool setUniform1uiv(GLint location, GLsizei count, const GLuint *v);
+    bool setUniform2uiv(GLint location, GLsizei count, const GLuint *v);
+    bool setUniform3uiv(GLint location, GLsizei count, const GLuint *v);
+    bool setUniform4uiv(GLint location, GLsizei count, const GLuint *v);
+    bool setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+    bool setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+    bool setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+    bool setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+    bool setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+    bool setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+    bool setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+    bool setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+    bool setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
</ins><span class="cx"> 
</span><span class="cx">     bool getUniformfv(GLint location, GLsizei *bufSize, GLfloat *params);
</span><span class="cx">     bool getUniformiv(GLint location, GLsizei *bufSize, GLint *params);
</span><ins>+    bool getUniformuiv(GLint location, GLsizei *bufSize, GLuint *params);
</ins><span class="cx"> 
</span><span class="cx">     void dirtyAllUniforms();
</span><span class="cx">     void applyUniforms();
</span><ins>+    bool applyUniformBuffers(const std::vector&lt;Buffer*&gt; boundBuffers);
</ins><span class="cx"> 
</span><span class="cx">     bool load(InfoLog &amp;infoLog, const void *binary, GLsizei length);
</span><span class="cx">     bool save(void* binary, GLsizei bufSize, GLsizei *length);
</span><span class="cx">     GLint getLength();
</span><span class="cx"> 
</span><del>-    bool link(InfoLog &amp;infoLog, const AttributeBindings &amp;attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader);
</del><ins>+    bool link(InfoLog &amp;infoLog, const AttributeBindings &amp;attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader,
+              const std::vector&lt;std::string&gt;&amp; transformFeedbackVaryings, GLenum transformFeedbackBufferMode);
</ins><span class="cx">     void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
</span><span class="cx"> 
</span><span class="cx">     void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
</span><span class="lines">@@ -107,44 +145,109 @@
</span><span class="cx">     void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
</span><span class="cx">     GLint getActiveUniformCount() const;
</span><span class="cx">     GLint getActiveUniformMaxLength() const;
</span><ins>+    GLint getActiveUniformi(GLuint index, GLenum pname) const;
</ins><span class="cx"> 
</span><ins>+    void getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) const;
+    void getActiveUniformBlockiv(GLuint uniformBlockIndex, GLenum pname, GLint *params) const;
+    GLuint getActiveUniformBlockCount() const;
+    GLuint getActiveUniformBlockMaxLength() const;
+    UniformBlock *getUniformBlockByIndex(GLuint blockIndex);
+
+    GLint getFragDataLocation(const char *name) const;
+
+    size_t getTransformFeedbackVaryingCount() const;
+    const LinkedVarying &amp;getTransformFeedbackVarying(size_t idx) const;
+    GLenum getTransformFeedbackBufferMode() const;
+
</ins><span class="cx">     void validate(InfoLog &amp;infoLog);
</span><span class="cx">     bool validateSamplers(InfoLog *infoLog);
</span><span class="cx">     bool isValidated() const;
</span><span class="cx"> 
</span><span class="cx">     unsigned int getSerial() const;
</span><ins>+    int getShaderVersion() const;
</ins><span class="cx"> 
</span><span class="cx">     void initAttributesByLayout();
</span><del>-    void sortAttributesByLayout(rx::TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
</del><ins>+    void sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
</ins><span class="cx"> 
</span><del>-    static std::string decorateAttribute(const std::string &amp;name);    // Prepend an underscore
</del><ins>+    const std::vector&lt;LinkedUniform*&gt; &amp;getUniforms() const { return mUniforms; }
+    const rx::UniformStorage &amp;getVertexUniformStorage() const { return *mVertexUniformStorage; }
+    const rx::UniformStorage &amp;getFragmentUniformStorage() const { return *mFragmentUniformStorage; }
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(ProgramBinary);
</span><span class="cx"> 
</span><del>-    int packVaryings(InfoLog &amp;infoLog, const Varying *packing[][4], FragmentShader *fragmentShader);
-    bool linkVaryings(InfoLog &amp;infoLog, int registers, const Varying *packing[][4],
-                      std::string&amp; pixelHLSL, std::string&amp; vertexHLSL,
-                      FragmentShader *fragmentShader, VertexShader *vertexShader);
-
</del><ins>+    bool linkVaryings(InfoLog &amp;infoLog, FragmentShader *fragmentShader, VertexShader *vertexShader);
</ins><span class="cx">     bool linkAttributes(InfoLog &amp;infoLog, const AttributeBindings &amp;attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader);
</span><span class="cx"> 
</span><del>-    bool linkUniforms(InfoLog &amp;infoLog, const sh::ActiveUniforms &amp;vertexUniforms, const sh::ActiveUniforms &amp;fragmentUniforms);
-    bool defineUniform(GLenum shader, const sh::Uniform &amp;constant, InfoLog &amp;infoLog);
-    
-    std::string generateGeometryShaderHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
-    std::string generatePointSpriteHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
</del><ins>+    typedef BlockMemberInfoArray::const_iterator BlockInfoItr;
</ins><span class="cx"> 
</span><ins>+    template &lt;class ShaderVarType&gt;
+    bool linkValidateFields(InfoLog &amp;infoLog, const std::string &amp;varName, const ShaderVarType &amp;vertexVar, const ShaderVarType &amp;fragmentVar);
+    bool linkValidateVariablesBase(InfoLog &amp;infoLog, const std::string &amp;variableName, const ShaderVariable &amp;vertexVariable, const ShaderVariable &amp;fragmentVariable, bool validatePrecision);
+
+    bool linkValidateVariables(InfoLog &amp;infoLog, const std::string &amp;uniformName, const Uniform &amp;vertexUniform, const Uniform &amp;fragmentUniform);
+    bool linkValidateVariables(InfoLog &amp;infoLog, const std::string &amp;varyingName, const Varying &amp;vertexVarying, const Varying &amp;fragmentVarying);
+    bool linkValidateVariables(InfoLog &amp;infoLog, const std::string &amp;uniformName, const InterfaceBlockField &amp;vertexUniform, const InterfaceBlockField &amp;fragmentUniform);
+    bool linkUniforms(InfoLog &amp;infoLog, const std::vector&lt;Uniform&gt; &amp;vertexUniforms, const std::vector&lt;Uniform&gt; &amp;fragmentUniforms);
+    bool defineUniform(GLenum shader, const Uniform &amp;constant, InfoLog &amp;infoLog);
+    bool areMatchingInterfaceBlocks(InfoLog &amp;infoLog, const InterfaceBlock &amp;vertexInterfaceBlock, const InterfaceBlock &amp;fragmentInterfaceBlock);
+    bool linkUniformBlocks(InfoLog &amp;infoLog, const std::vector&lt;InterfaceBlock&gt; &amp;vertexUniformBlocks, const std::vector&lt;InterfaceBlock&gt; &amp;fragmentUniformBlocks);
+    bool gatherTransformFeedbackLinkedVaryings(InfoLog &amp;infoLog, const std::vector&lt;LinkedVarying&gt; &amp;linkedVaryings,
+                                               const std::vector&lt;std::string&gt; &amp;transformFeedbackVaryingNames,
+                                               GLenum transformFeedbackBufferMode,
+                                               std::vector&lt;LinkedVarying&gt; *outTransformFeedbackLinkedVaryings) const;
+    void defineUniformBlockMembers(const std::vector&lt;InterfaceBlockField&gt; &amp;fields, const std::string &amp;prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector&lt;unsigned int&gt; *blockUniformIndexes);
+    bool defineUniformBlock(InfoLog &amp;infoLog, GLenum shader, const InterfaceBlock &amp;interfaceBlock);
+    bool assignUniformBlockRegister(InfoLog &amp;infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex);
+    void defineOutputVariables(FragmentShader *fragmentShader);
+    void initializeUniformStorage();
+
+    template &lt;typename T&gt;
+    bool setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType);
+
+    template &lt;int cols, int rows&gt;
+    bool setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType);
+
+    template &lt;typename T&gt;
+    bool getUniformv(GLint location, GLsizei *bufSize, T *params, GLenum uniformType);
+
+    static TextureType getTextureType(GLenum samplerType, InfoLog &amp;infoLog);
+
+    class VertexExecutable
+    {
+      public:
+        VertexExecutable(rx::Renderer *const renderer,
+                         const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS],
+                         rx::ShaderExecutable *shaderExecutable);
+        ~VertexExecutable();
+
+        bool matchesInputLayout(const VertexFormat attributes[MAX_VERTEX_ATTRIBS]) const;
+
+        const VertexFormat *inputs() const { return mInputs; }
+        rx::ShaderExecutable *shaderExecutable() const { return mShaderExecutable; }
+
+      private:
+        VertexFormat mInputs[MAX_VERTEX_ATTRIBS];
+        rx::ShaderExecutable *mShaderExecutable;
+    };
+
</ins><span class="cx">     rx::Renderer *const mRenderer;
</span><ins>+    DynamicHLSL *mDynamicHLSL;
</ins><span class="cx"> 
</span><ins>+    std::string mVertexHLSL;
+    rx::D3DWorkaroundType mVertexWorkarounds;
+    std::vector&lt;VertexExecutable *&gt; mVertexExecutables;
+    rx::ShaderExecutable *mGeometryExecutable;
</ins><span class="cx">     rx::ShaderExecutable *mPixelExecutable;
</span><del>-    rx::ShaderExecutable *mVertexExecutable;
-    rx::ShaderExecutable *mGeometryExecutable;
</del><span class="cx"> 
</span><span class="cx">     Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
</span><ins>+    Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS];
</ins><span class="cx">     int mSemanticIndex[MAX_VERTEX_ATTRIBS];
</span><span class="cx">     int mAttributesByLayout[MAX_VERTEX_ATTRIBS];
</span><span class="cx"> 
</span><ins>+    GLenum mTransformFeedbackBufferMode;
+    std::vector&lt;LinkedVarying&gt; mTransformFeedbackLinkedVaryings;
+
</ins><span class="cx">     struct Sampler
</span><span class="cx">     {
</span><span class="cx">         Sampler();
</span><span class="lines">@@ -159,10 +262,14 @@
</span><span class="cx">     GLuint mUsedVertexSamplerRange;
</span><span class="cx">     GLuint mUsedPixelSamplerRange;
</span><span class="cx">     bool mUsesPointSize;
</span><ins>+    int mShaderVersion;
</ins><span class="cx"> 
</span><del>-    UniformArray mUniforms;
-    typedef std::vector&lt;UniformLocation&gt; UniformIndex;
-    UniformIndex mUniformIndex;
</del><ins>+    std::vector&lt;LinkedUniform*&gt; mUniforms;
+    std::vector&lt;UniformBlock*&gt; mUniformBlocks;
+    std::vector&lt;VariableLocation&gt; mUniformIndex;
+    std::map&lt;int, VariableLocation&gt; mOutputVariables;
+    rx::UniformStorage *mVertexUniformStorage;
+    rx::UniformStorage *mFragmentUniformStorage;
</ins><span class="cx"> 
</span><span class="cx">     bool mValidated;
</span><span class="cx"> 
</span><span class="lines">@@ -171,6 +278,7 @@
</span><span class="cx">     static unsigned int issueSerial();
</span><span class="cx">     static unsigned int mCurrentSerial;
</span><span class="cx"> };
</span><ins>+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif   // LIBGLESV2_PROGRAM_BINARY_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Queryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Query.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Query.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Query.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -10,6 +10,7 @@
</span><span class="cx"> #define LIBGLESV2_QUERY_H_
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Renderbuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -14,7 +14,9 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/Texture.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;libGLESv2/renderer/TextureStorage.h&quot;
+#include &quot;common/utilities.h&quot;
+#include &quot;libGLESv2/formatutils.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="lines">@@ -35,39 +37,9 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLuint RenderbufferInterface::getRedSize() const
-{
-    return gl::GetRedSize(getActualFormat());
-}
-
-GLuint RenderbufferInterface::getGreenSize() const
-{
-    return gl::GetGreenSize(getActualFormat());
-}
-
-GLuint RenderbufferInterface::getBlueSize() const
-{
-    return gl::GetBlueSize(getActualFormat());
-}
-
-GLuint RenderbufferInterface::getAlphaSize() const
-{
-    return gl::GetAlphaSize(getActualFormat());
-}
-
-GLuint RenderbufferInterface::getDepthSize() const
-{
-    return gl::GetDepthSize(getActualFormat());
-}
-
-GLuint RenderbufferInterface::getStencilSize() const
-{
-    return gl::GetStencilSize(getActualFormat());
-}
-
</del><span class="cx"> ///// RenderbufferTexture2D Implementation ////////
</span><span class="cx"> 
</span><del>-RenderbufferTexture2D::RenderbufferTexture2D(Texture2D *texture, GLenum target) : mTarget(target)
</del><ins>+RenderbufferTexture2D::RenderbufferTexture2D(Texture2D *texture, GLint level) : mLevel(level)
</ins><span class="cx"> {
</span><span class="cx">     mTexture2D.set(texture);
</span><span class="cx"> }
</span><span class="lines">@@ -91,32 +63,37 @@
</span><span class="cx"> 
</span><span class="cx"> rx::RenderTarget *RenderbufferTexture2D::getRenderTarget()
</span><span class="cx"> {
</span><del>-    return mTexture2D-&gt;getRenderTarget(mTarget);
</del><ins>+    return mTexture2D-&gt;getRenderTarget(mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> rx::RenderTarget *RenderbufferTexture2D::getDepthStencil()
</span><span class="cx"> {
</span><del>-    return mTexture2D-&gt;getDepthStencil(mTarget);
</del><ins>+    return mTexture2D-&gt;getDepthSencil(mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+rx::TextureStorage *RenderbufferTexture2D::getTextureStorage()
+{
+    return mTexture2D-&gt;getNativeTexture()-&gt;getStorageInstance();
+}
+
</ins><span class="cx"> GLsizei RenderbufferTexture2D::getWidth() const
</span><span class="cx"> {
</span><del>-    return mTexture2D-&gt;getWidth(0);
</del><ins>+    return mTexture2D-&gt;getWidth(mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLsizei RenderbufferTexture2D::getHeight() const
</span><span class="cx"> {
</span><del>-    return mTexture2D-&gt;getHeight(0);
</del><ins>+    return mTexture2D-&gt;getHeight(mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLenum RenderbufferTexture2D::getInternalFormat() const
</span><span class="cx"> {
</span><del>-    return mTexture2D-&gt;getInternalFormat(0);
</del><ins>+    return mTexture2D-&gt;getInternalFormat(mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLenum RenderbufferTexture2D::getActualFormat() const
</span><span class="cx"> {
</span><del>-    return mTexture2D-&gt;getActualFormat(0);
</del><ins>+    return mTexture2D-&gt;getActualFormat(mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLsizei RenderbufferTexture2D::getSamples() const
</span><span class="lines">@@ -126,7 +103,7 @@
</span><span class="cx"> 
</span><span class="cx"> unsigned int RenderbufferTexture2D::getSerial() const
</span><span class="cx"> {
</span><del>-    return mTexture2D-&gt;getRenderTargetSerial(mTarget);
</del><ins>+    return mTexture2D-&gt;getRenderTargetSerial(mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned int RenderbufferTexture2D::getTextureSerial() const
</span><span class="lines">@@ -136,7 +113,8 @@
</span><span class="cx"> 
</span><span class="cx"> ///// RenderbufferTextureCubeMap Implementation ////////
</span><span class="cx"> 
</span><del>-RenderbufferTextureCubeMap::RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum target) : mTarget(target)
</del><ins>+RenderbufferTextureCubeMap::RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum faceTarget, GLint level)
+    : mFaceTarget(faceTarget), mLevel(level)
</ins><span class="cx"> {
</span><span class="cx">     mTextureCubeMap.set(texture);
</span><span class="cx"> }
</span><span class="lines">@@ -160,32 +138,37 @@
</span><span class="cx"> 
</span><span class="cx"> rx::RenderTarget *RenderbufferTextureCubeMap::getRenderTarget()
</span><span class="cx"> {
</span><del>-    return mTextureCubeMap-&gt;getRenderTarget(mTarget);
</del><ins>+    return mTextureCubeMap-&gt;getRenderTarget(mFaceTarget, mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> rx::RenderTarget *RenderbufferTextureCubeMap::getDepthStencil()
</span><span class="cx"> {
</span><del>-    return NULL;
</del><ins>+    return mTextureCubeMap-&gt;getDepthStencil(mFaceTarget, mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+rx::TextureStorage *RenderbufferTextureCubeMap::getTextureStorage()
+{
+    return mTextureCubeMap-&gt;getNativeTexture()-&gt;getStorageInstance();
+}
+
</ins><span class="cx"> GLsizei RenderbufferTextureCubeMap::getWidth() const
</span><span class="cx"> {
</span><del>-    return mTextureCubeMap-&gt;getWidth(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
</del><ins>+    return mTextureCubeMap-&gt;getWidth(mFaceTarget, mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLsizei RenderbufferTextureCubeMap::getHeight() const
</span><span class="cx"> {
</span><del>-    return mTextureCubeMap-&gt;getHeight(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
</del><ins>+    return mTextureCubeMap-&gt;getHeight(mFaceTarget, mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLenum RenderbufferTextureCubeMap::getInternalFormat() const
</span><span class="cx"> {
</span><del>-    return mTextureCubeMap-&gt;getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
</del><ins>+    return mTextureCubeMap-&gt;getInternalFormat(mFaceTarget, mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLenum RenderbufferTextureCubeMap::getActualFormat() const
</span><span class="cx"> {
</span><del>-    return mTextureCubeMap-&gt;getActualFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
</del><ins>+    return mTextureCubeMap-&gt;getActualFormat(mFaceTarget, mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLsizei RenderbufferTextureCubeMap::getSamples() const
</span><span class="lines">@@ -195,7 +178,7 @@
</span><span class="cx"> 
</span><span class="cx"> unsigned int RenderbufferTextureCubeMap::getSerial() const
</span><span class="cx"> {
</span><del>-    return mTextureCubeMap-&gt;getRenderTargetSerial(mTarget);
</del><ins>+    return mTextureCubeMap-&gt;getRenderTargetSerial(mFaceTarget, mLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned int RenderbufferTextureCubeMap::getTextureSerial() const
</span><span class="lines">@@ -203,12 +186,163 @@
</span><span class="cx">     return mTextureCubeMap-&gt;getTextureSerial();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+///// RenderbufferTexture3DLayer Implementation ////////
+
+RenderbufferTexture3DLayer::RenderbufferTexture3DLayer(Texture3D *texture, GLint level, GLint layer)
+    : mLevel(level), mLayer(layer)
+{
+    mTexture3D.set(texture);
+}
+
+RenderbufferTexture3DLayer::~RenderbufferTexture3DLayer()
+{
+    mTexture3D.set(NULL);
+}
+
+// Textures need to maintain their own reference count for references via
+// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
+void RenderbufferTexture3DLayer::addProxyRef(const Renderbuffer *proxy)
+{
+    mTexture3D-&gt;addProxyRef(proxy);
+}
+
+void RenderbufferTexture3DLayer::releaseProxy(const Renderbuffer *proxy)
+{
+    mTexture3D-&gt;releaseProxy(proxy);
+}
+
+rx::RenderTarget *RenderbufferTexture3DLayer::getRenderTarget()
+{
+    return mTexture3D-&gt;getRenderTarget(mLevel, mLayer);
+}
+
+rx::RenderTarget *RenderbufferTexture3DLayer::getDepthStencil()
+{
+    return mTexture3D-&gt;getDepthStencil(mLevel, mLayer);
+}
+
+rx::TextureStorage *RenderbufferTexture3DLayer::getTextureStorage()
+{
+    return mTexture3D-&gt;getNativeTexture()-&gt;getStorageInstance();
+}
+
+GLsizei RenderbufferTexture3DLayer::getWidth() const
+{
+    return mTexture3D-&gt;getWidth(mLevel);
+}
+
+GLsizei RenderbufferTexture3DLayer::getHeight() const
+{
+    return mTexture3D-&gt;getHeight(mLevel);
+}
+
+GLenum RenderbufferTexture3DLayer::getInternalFormat() const
+{
+    return mTexture3D-&gt;getInternalFormat(mLevel);
+}
+
+GLenum RenderbufferTexture3DLayer::getActualFormat() const
+{
+    return mTexture3D-&gt;getActualFormat(mLevel);
+}
+
+GLsizei RenderbufferTexture3DLayer::getSamples() const
+{
+    return 0;
+}
+
+unsigned int RenderbufferTexture3DLayer::getSerial() const
+{
+    return mTexture3D-&gt;getRenderTargetSerial(mLevel, mLayer);
+}
+
+unsigned int RenderbufferTexture3DLayer::getTextureSerial() const
+{
+    return mTexture3D-&gt;getTextureSerial();
+}
+
+////// RenderbufferTexture2DArrayLayer Implementation //////
+
+RenderbufferTexture2DArrayLayer::RenderbufferTexture2DArrayLayer(Texture2DArray *texture, GLint level, GLint layer)
+    : mLevel(level), mLayer(layer)
+{
+    mTexture2DArray.set(texture);
+}
+
+RenderbufferTexture2DArrayLayer::~RenderbufferTexture2DArrayLayer()
+{
+    mTexture2DArray.set(NULL);
+}
+
+void RenderbufferTexture2DArrayLayer::addProxyRef(const Renderbuffer *proxy)
+{
+    mTexture2DArray-&gt;addProxyRef(proxy);
+}
+
+void RenderbufferTexture2DArrayLayer::releaseProxy(const Renderbuffer *proxy)
+{
+    mTexture2DArray-&gt;releaseProxy(proxy);
+}
+
+rx::RenderTarget *RenderbufferTexture2DArrayLayer::getRenderTarget()
+{
+    return mTexture2DArray-&gt;getRenderTarget(mLevel, mLayer);
+}
+
+rx::RenderTarget *RenderbufferTexture2DArrayLayer::getDepthStencil()
+{
+    return mTexture2DArray-&gt;getDepthStencil(mLevel, mLayer);
+}
+
+rx::TextureStorage *RenderbufferTexture2DArrayLayer::getTextureStorage()
+{
+    return mTexture2DArray-&gt;getNativeTexture()-&gt;getStorageInstance();
+}
+
+GLsizei RenderbufferTexture2DArrayLayer::getWidth() const
+{
+    return mTexture2DArray-&gt;getWidth(mLevel);
+}
+
+GLsizei RenderbufferTexture2DArrayLayer::getHeight() const
+{
+    return mTexture2DArray-&gt;getHeight(mLevel);
+}
+
+GLenum RenderbufferTexture2DArrayLayer::getInternalFormat() const
+{
+    return mTexture2DArray-&gt;getInternalFormat(mLevel);
+}
+
+GLenum RenderbufferTexture2DArrayLayer::getActualFormat() const
+{
+    return mTexture2DArray-&gt;getActualFormat(mLevel);
+}
+
+GLsizei RenderbufferTexture2DArrayLayer::getSamples() const
+{
+    return 0;
+}
+
+unsigned int RenderbufferTexture2DArrayLayer::getSerial() const
+{
+    return mTexture2DArray-&gt;getRenderTargetSerial(mLevel, mLayer);
+}
+
+unsigned int RenderbufferTexture2DArrayLayer::getTextureSerial() const
+{
+    return mTexture2DArray-&gt;getTextureSerial();
+}
+
</ins><span class="cx"> ////// Renderbuffer Implementation //////
</span><span class="cx"> 
</span><span class="cx"> Renderbuffer::Renderbuffer(rx::Renderer *renderer, GLuint id, RenderbufferInterface *instance) : RefCountObject(id)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(instance != NULL);
</span><span class="cx">     mInstance = instance;
</span><ins>+
+    ASSERT(renderer != NULL);
+    mRenderer = renderer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Renderbuffer::~Renderbuffer()
</span><span class="lines">@@ -242,6 +376,11 @@
</span><span class="cx">     return mInstance-&gt;getDepthStencil();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+rx::TextureStorage *Renderbuffer::getTextureStorage()
+{
+    return mInstance-&gt;getTextureStorage();
+}
+
</ins><span class="cx"> GLsizei Renderbuffer::getWidth() const
</span><span class="cx"> {
</span><span class="cx">     return mInstance-&gt;getWidth();
</span><span class="lines">@@ -264,34 +403,44 @@
</span><span class="cx"> 
</span><span class="cx"> GLuint Renderbuffer::getRedSize() const
</span><span class="cx"> {
</span><del>-    return mInstance-&gt;getRedSize();
</del><ins>+    return gl::GetRedBits(getActualFormat(), mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLuint Renderbuffer::getGreenSize() const
</span><span class="cx"> {
</span><del>-    return mInstance-&gt;getGreenSize();
</del><ins>+    return gl::GetGreenBits(getActualFormat(), mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLuint Renderbuffer::getBlueSize() const
</span><span class="cx"> {
</span><del>-    return mInstance-&gt;getBlueSize();
</del><ins>+    return gl::GetBlueBits(getActualFormat(), mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLuint Renderbuffer::getAlphaSize() const
</span><span class="cx"> {
</span><del>-    return mInstance-&gt;getAlphaSize();
</del><ins>+    return gl::GetAlphaBits(getActualFormat(), mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLuint Renderbuffer::getDepthSize() const
</span><span class="cx"> {
</span><del>-    return mInstance-&gt;getDepthSize();
</del><ins>+    return gl::GetDepthBits(getActualFormat(), mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLuint Renderbuffer::getStencilSize() const
</span><span class="cx"> {
</span><del>-    return mInstance-&gt;getStencilSize();
</del><ins>+    return gl::GetStencilBits(getActualFormat(), mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLenum Renderbuffer::getComponentType() const
+{
+    return gl::GetComponentType(getActualFormat(), mRenderer-&gt;getCurrentClientVersion());
+}
+
+GLenum Renderbuffer::getColorEncoding() const
+{
+    return gl::GetColorEncoding(getActualFormat(), mRenderer-&gt;getCurrentClientVersion());
+}
+
</ins><span class="cx"> GLsizei Renderbuffer::getSamples() const
</span><span class="cx"> {
</span><span class="cx">     return mInstance-&gt;getSamples();
</span><span class="lines">@@ -315,7 +464,7 @@
</span><span class="cx">     mInstance = newStorage;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerial())
</del><ins>+RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerials(1))
</ins><span class="cx"> {
</span><span class="cx">     mWidth = 0;
</span><span class="cx">     mHeight = 0;
</span><span class="lines">@@ -338,6 +487,11 @@
</span><span class="cx">     return NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+rx::TextureStorage *RenderbufferStorage::getTextureStorage()
+{
+    return NULL;
+}
+
</ins><span class="cx"> GLsizei RenderbufferStorage::getWidth() const
</span><span class="cx"> {
</span><span class="cx">     return mWidth;
</span><span class="lines">@@ -368,15 +522,10 @@
</span><span class="cx">     return mSerial;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned int RenderbufferStorage::issueSerial()
</del><ins>+unsigned int RenderbufferStorage::issueSerials(GLuint count)
</ins><span class="cx"> {
</span><del>-    return mCurrentSerial++;
-}
-
-unsigned int RenderbufferStorage::issueCubeSerials()
-{
</del><span class="cx">     unsigned int firstSerial = mCurrentSerial;
</span><del>-    mCurrentSerial += 6;
</del><ins>+    mCurrentSerial += count;
</ins><span class="cx">     return firstSerial;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -396,7 +545,7 @@
</span><span class="cx"> 
</span><span class="cx"> Colorbuffer::Colorbuffer(rx::Renderer *renderer, int width, int height, GLenum format, GLsizei samples) : mRenderTarget(NULL)
</span><span class="cx"> {
</span><del>-    mRenderTarget = renderer-&gt;createRenderTarget(width, height, format, samples, false);
</del><ins>+    mRenderTarget = renderer-&gt;createRenderTarget(width, height, format, samples);
</ins><span class="cx"> 
</span><span class="cx">     if (mRenderTarget)
</span><span class="cx">     {
</span><span class="lines">@@ -418,12 +567,7 @@
</span><span class="cx"> 
</span><span class="cx"> rx::RenderTarget *Colorbuffer::getRenderTarget()
</span><span class="cx"> {
</span><del>-    if (mRenderTarget)
-    {
-        return mRenderTarget;
-    }
-
-    return NULL;
</del><ins>+    return mRenderTarget;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> DepthStencilbuffer::DepthStencilbuffer(rx::Renderer *renderer, rx::SwapChain *swapChain)
</span><span class="lines">@@ -442,7 +586,7 @@
</span><span class="cx"> DepthStencilbuffer::DepthStencilbuffer(rx::Renderer *renderer, int width, int height, GLsizei samples)
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-    mDepthStencil = renderer-&gt;createRenderTarget(width, height, GL_DEPTH24_STENCIL8_OES, samples, true);
</del><ins>+    mDepthStencil = renderer-&gt;createRenderTarget(width, height, GL_DEPTH24_STENCIL8_OES, samples);
</ins><span class="cx"> 
</span><span class="cx">     mWidth = mDepthStencil-&gt;getWidth();
</span><span class="cx">     mHeight = mDepthStencil-&gt;getHeight();
</span><span class="lines">@@ -461,12 +605,7 @@
</span><span class="cx"> 
</span><span class="cx"> rx::RenderTarget *DepthStencilbuffer::getDepthStencil()
</span><span class="cx"> {
</span><del>-    if (mDepthStencil)
-    {
-        return mDepthStencil;
-    }
-
-    return NULL;
</del><ins>+    return mDepthStencil;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Depthbuffer::Depthbuffer(rx::Renderer *renderer, int width, int height, GLsizei samples) : DepthStencilbuffer(renderer, width, height, samples)
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Renderbufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -13,6 +13,7 @@
</span><span class="cx"> #define LIBGLESV2_RENDERBUFFER_H_
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><span class="lines">@@ -23,12 +24,15 @@
</span><span class="cx"> class Renderer;
</span><span class="cx"> class SwapChain;
</span><span class="cx"> class RenderTarget;
</span><ins>+class TextureStorage;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="cx"> class Texture2D;
</span><span class="cx"> class TextureCubeMap;
</span><ins>+class Texture3D;
+class Texture2DArray;
</ins><span class="cx"> class Renderbuffer;
</span><span class="cx"> class Colorbuffer;
</span><span class="cx"> class DepthStencilbuffer;
</span><span class="lines">@@ -45,6 +49,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual rx::RenderTarget *getRenderTarget() = 0;
</span><span class="cx">     virtual rx::RenderTarget *getDepthStencil() = 0;
</span><ins>+    virtual rx::TextureStorage *getTextureStorage() = 0;
</ins><span class="cx"> 
</span><span class="cx">     virtual GLsizei getWidth() const = 0;
</span><span class="cx">     virtual GLsizei getHeight() const = 0;
</span><span class="lines">@@ -52,13 +57,6 @@
</span><span class="cx">     virtual GLenum getActualFormat() const = 0;
</span><span class="cx">     virtual GLsizei getSamples() const = 0;
</span><span class="cx"> 
</span><del>-    GLuint getRedSize() const;
-    GLuint getGreenSize() const;
-    GLuint getBlueSize() const;
-    GLuint getAlphaSize() const;
-    GLuint getDepthSize() const;
-    GLuint getStencilSize() const;
-
</del><span class="cx">     virtual unsigned int getSerial() const = 0;
</span><span class="cx">     virtual unsigned int getTextureSerial() const = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -69,7 +67,7 @@
</span><span class="cx"> class RenderbufferTexture2D : public RenderbufferInterface
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    RenderbufferTexture2D(Texture2D *texture, GLenum target);
</del><ins>+    RenderbufferTexture2D(Texture2D *texture, GLint level);
</ins><span class="cx"> 
</span><span class="cx">     virtual ~RenderbufferTexture2D();
</span><span class="cx"> 
</span><span class="lines">@@ -78,6 +76,7 @@
</span><span class="cx"> 
</span><span class="cx">     rx::RenderTarget *getRenderTarget();
</span><span class="cx">     rx::RenderTarget *getDepthStencil();
</span><ins>+    rx::TextureStorage *getTextureStorage();
</ins><span class="cx"> 
</span><span class="cx">     virtual GLsizei getWidth() const;
</span><span class="cx">     virtual GLsizei getHeight() const;
</span><span class="lines">@@ -92,13 +91,13 @@
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(RenderbufferTexture2D);
</span><span class="cx"> 
</span><span class="cx">     BindingPointer &lt;Texture2D&gt; mTexture2D;
</span><del>-    GLenum mTarget;
</del><ins>+    const GLint mLevel;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class RenderbufferTextureCubeMap : public RenderbufferInterface
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum target);
</del><ins>+    RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum faceTarget, GLint level);
</ins><span class="cx"> 
</span><span class="cx">     virtual ~RenderbufferTextureCubeMap();
</span><span class="cx"> 
</span><span class="lines">@@ -107,6 +106,7 @@
</span><span class="cx"> 
</span><span class="cx">     rx::RenderTarget *getRenderTarget();
</span><span class="cx">     rx::RenderTarget *getDepthStencil();
</span><ins>+    rx::TextureStorage *getTextureStorage();
</ins><span class="cx"> 
</span><span class="cx">     virtual GLsizei getWidth() const;
</span><span class="cx">     virtual GLsizei getHeight() const;
</span><span class="lines">@@ -121,9 +121,72 @@
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(RenderbufferTextureCubeMap);
</span><span class="cx"> 
</span><span class="cx">     BindingPointer &lt;TextureCubeMap&gt; mTextureCubeMap;
</span><del>-    GLenum mTarget;
</del><ins>+    const GLint mLevel;
+    const GLenum mFaceTarget;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class RenderbufferTexture3DLayer : public RenderbufferInterface
+{
+public:
+    RenderbufferTexture3DLayer(Texture3D *texture, GLint level, GLint layer);
+
+    virtual ~RenderbufferTexture3DLayer();
+
+    void addProxyRef(const Renderbuffer *proxy);
+    void releaseProxy(const Renderbuffer *proxy);
+
+    rx::RenderTarget *getRenderTarget();
+    rx::RenderTarget *getDepthStencil();
+    rx::TextureStorage *getTextureStorage();
+
+    virtual GLsizei getWidth() const;
+    virtual GLsizei getHeight() const;
+    virtual GLenum getInternalFormat() const;
+    virtual GLenum getActualFormat() const;
+    virtual GLsizei getSamples() const;
+
+    virtual unsigned int getSerial() const;
+    virtual unsigned int getTextureSerial() const;
+
+private:
+    DISALLOW_COPY_AND_ASSIGN(RenderbufferTexture3DLayer);
+
+    BindingPointer&lt;Texture3D&gt; mTexture3D;
+    const GLint mLevel;
+    const GLint mLayer;
+};
+
+class RenderbufferTexture2DArrayLayer : public RenderbufferInterface
+{
+public:
+    RenderbufferTexture2DArrayLayer(Texture2DArray *texture, GLint level, GLint layer);
+
+    virtual ~RenderbufferTexture2DArrayLayer();
+
+    void addProxyRef(const Renderbuffer *proxy);
+    void releaseProxy(const Renderbuffer *proxy);
+
+    rx::RenderTarget *getRenderTarget();
+    rx::RenderTarget *getDepthStencil();
+    rx::TextureStorage *getTextureStorage();
+
+    virtual GLsizei getWidth() const;
+    virtual GLsizei getHeight() const;
+    virtual GLenum getInternalFormat() const;
+    virtual GLenum getActualFormat() const;
+    virtual GLsizei getSamples() const;
+
+    virtual unsigned int getSerial() const;
+    virtual unsigned int getTextureSerial() const;
+
+private:
+    DISALLOW_COPY_AND_ASSIGN(RenderbufferTexture2DArrayLayer);
+
+    BindingPointer&lt;Texture2DArray&gt; mTexture2DArray;
+    const GLint mLevel;
+    const GLint mLayer;
+};
+
</ins><span class="cx"> // A class derived from RenderbufferStorage is created whenever glRenderbufferStorage
</span><span class="cx"> // is called. The specific concrete type depends on whether the internal format is
</span><span class="cx"> // colour depth, stencil or packed depth/stencil.
</span><span class="lines">@@ -136,6 +199,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual rx::RenderTarget *getRenderTarget();
</span><span class="cx">     virtual rx::RenderTarget *getDepthStencil();
</span><ins>+    virtual rx::TextureStorage *getTextureStorage();
</ins><span class="cx"> 
</span><span class="cx">     virtual GLsizei getWidth() const;
</span><span class="cx">     virtual GLsizei getHeight() const;
</span><span class="lines">@@ -146,8 +210,7 @@
</span><span class="cx">     virtual unsigned int getSerial() const;
</span><span class="cx">     virtual unsigned int getTextureSerial() const { return 0; }
</span><span class="cx"> 
</span><del>-    static unsigned int issueSerial();
-    static unsigned int issueCubeSerials();
</del><ins>+    static unsigned int issueSerials(GLuint count);
</ins><span class="cx"> 
</span><span class="cx">   protected:
</span><span class="cx">     GLsizei mWidth;
</span><span class="lines">@@ -183,6 +246,7 @@
</span><span class="cx"> 
</span><span class="cx">     rx::RenderTarget *getRenderTarget();
</span><span class="cx">     rx::RenderTarget *getDepthStencil();
</span><ins>+    rx::TextureStorage *getTextureStorage();
</ins><span class="cx"> 
</span><span class="cx">     GLsizei getWidth() const;
</span><span class="cx">     GLsizei getHeight() const;
</span><span class="lines">@@ -194,6 +258,8 @@
</span><span class="cx">     GLuint getAlphaSize() const;
</span><span class="cx">     GLuint getDepthSize() const;
</span><span class="cx">     GLuint getStencilSize() const;
</span><ins>+    GLenum getComponentType() const;
+    GLenum getColorEncoding() const;
</ins><span class="cx">     GLsizei getSamples() const;
</span><span class="cx"> 
</span><span class="cx">     unsigned int getSerial() const;
</span><span class="lines">@@ -204,6 +270,7 @@
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Renderbuffer);
</span><span class="cx"> 
</span><ins>+    rx::Renderer const *mRenderer;
</ins><span class="cx">     RenderbufferInterface *mInstance;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2RenderbufferProxySetcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/RenderbufferProxySet.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/RenderbufferProxySet.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/RenderbufferProxySet.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,87 @@
</span><ins>+#include &quot;precompiled.h&quot;
+//
+// 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.
+//
+
+// RenderbufferProxySet.cpp: Implements the gl::RenderbufferProxySet, a class for
+// maintaining a Texture's weak references to the Renderbuffers that represent it.
+
+#include &quot;libGLESv2/RenderbufferProxySet.h&quot;
+#include &quot;common/debug.h&quot;
+
+namespace gl
+{
+
+void RenderbufferProxySet::addRef(const Renderbuffer *proxy)
+{
+    RefCountMap::iterator i = mRefCountMap.find(proxy);
+    if (i != mRefCountMap.end())
+    {
+        i-&gt;second++;
+    }
+}
+
+void RenderbufferProxySet::release(const Renderbuffer *proxy)
+{
+    RefCountMap::iterator i = mRefCountMap.find(proxy);
+    if (i != mRefCountMap.end())
+    {
+        if (i-&gt;second &gt; 0)
+        {
+            i-&gt;second--;
+        }
+
+        if (i-&gt;second == 0)
+        {
+            // Clear the buffer map of references to this Renderbuffer
+            BufferMap::iterator j = mBufferMap.begin();
+            while (j != mBufferMap.end())
+            {
+                if (j-&gt;second == proxy)
+                {
+                    j = mBufferMap.erase(j);
+                }
+                else
+                {
+                    ++j;
+                }
+            }
+
+            mRefCountMap.erase(i);
+        }
+    }
+}
+
+void RenderbufferProxySet::add(unsigned int mipLevel, unsigned int layer, Renderbuffer *renderBuffer)
+{
+    if (mRefCountMap.find(renderBuffer) == mRefCountMap.end())
+    {
+        mRefCountMap.insert(std::make_pair(renderBuffer, 0));
+    }
+
+    RenderbufferKey key;
+    key.mipLevel = mipLevel;
+    key.layer = layer;
+    if (mBufferMap.find(key) == mBufferMap.end())
+    {
+        mBufferMap.insert(std::make_pair(key, renderBuffer));
+    }
+}
+
+Renderbuffer *RenderbufferProxySet::get(unsigned int mipLevel, unsigned int layer) const
+{
+    RenderbufferKey key;
+    key.mipLevel = mipLevel;
+    key.layer = layer;
+    BufferMap::const_iterator i = mBufferMap.find(key);
+    return (i != mBufferMap.end()) ? i-&gt;second : NULL;
+}
+
+bool RenderbufferProxySet::RenderbufferKey::operator&lt;(const RenderbufferKey &amp;other) const
+{
+    return (mipLevel != other.mipLevel) ? mipLevel &lt; other.mipLevel : layer &lt; other.layer;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2RenderbufferProxySeth"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/RenderbufferProxySet.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/RenderbufferProxySet.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/RenderbufferProxySet.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+//
+// 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.
+//
+
+// RenderbufferProxySet.h: Defines the gl::RenderbufferProxySet, a class for
+// maintaining a Texture's weak references to the Renderbuffers that represent it.
+
+#ifndef LIBGLESV2_RENDERBUFFERPROXYSET_H_
+#define LIBGLESV2_RENDERBUFFERPROXYSET_H_
+
+#include &lt;map&gt;
+
+namespace gl
+{
+class Renderbuffer;
+
+class RenderbufferProxySet
+{
+  public:
+    void addRef(const Renderbuffer *proxy);
+    void release(const Renderbuffer *proxy);
+
+    void add(unsigned int mipLevel, unsigned int layer, Renderbuffer *renderBuffer);
+    Renderbuffer *get(unsigned int mipLevel, unsigned int layer) const;
+
+  private:
+    struct RenderbufferKey
+    {
+        unsigned int mipLevel;
+        unsigned int layer;
+
+        bool operator&lt;(const RenderbufferKey &amp;other) const;
+    };
+
+    typedef std::map&lt;RenderbufferKey, Renderbuffer*&gt; BufferMap;
+    BufferMap mBufferMap;
+
+    typedef std::map&lt;const Renderbuffer*, unsigned int&gt; RefCountMap;
+    RefCountMap mRefCountMap;
+};
+
+}
+
+#endif // LIBGLESV2_RENDERBUFFERPROXYSET_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2ResourceManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ResourceManager.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ResourceManager.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ResourceManager.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -15,6 +15,8 @@
</span><span class="cx"> #include &quot;libGLESv2/Renderbuffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Shader.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Texture.h&quot;
</span><ins>+#include &quot;libGLESv2/Sampler.h&quot;
+#include &quot;libGLESv2/Fence.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="lines">@@ -50,6 +52,16 @@
</span><span class="cx">     {
</span><span class="cx">         deleteTexture(mTextureMap.begin()-&gt;first);
</span><span class="cx">     }
</span><ins>+
+    while (!mSamplerMap.empty())
+    {
+        deleteSampler(mSamplerMap.begin()-&gt;first);
+    }
+
+    while (!mFenceSyncMap.empty())
+    {
+        deleteFenceSync(mFenceSyncMap.begin()-&gt;first);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ResourceManager::addRef()
</span><span class="lines">@@ -123,6 +135,26 @@
</span><span class="cx">     return handle;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// Returns an unused sampler name
+GLuint ResourceManager::createSampler()
+{
+    GLuint handle = mSamplerHandleAllocator.allocate();
+
+    mSamplerMap[handle] = NULL;
+
+    return handle;
+}
+
+// Returns the next unused fence name, and allocates the fence
+GLuint ResourceManager::createFenceSync()
+{
+    GLuint handle = mFenceSyncHandleAllocator.allocate();
+
+    mFenceSyncMap[handle] = new FenceSync(mRenderer, handle);
+
+    return handle;
+}
+
</ins><span class="cx"> void ResourceManager::deleteBuffer(GLuint buffer)
</span><span class="cx"> {
</span><span class="cx">     BufferMap::iterator bufferObject = mBufferMap.find(buffer);
</span><span class="lines">@@ -197,6 +229,30 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ResourceManager::deleteSampler(GLuint sampler)
+{
+    auto samplerObject = mSamplerMap.find(sampler);
+
+    if (samplerObject != mSamplerMap.end())
+    {
+        mSamplerHandleAllocator.release(samplerObject-&gt;first);
+        if (samplerObject-&gt;second) samplerObject-&gt;second-&gt;release();
+        mSamplerMap.erase(samplerObject);
+    }
+}
+
+void ResourceManager::deleteFenceSync(GLuint fenceSync)
+{
+    auto fenceObjectIt = mFenceSyncMap.find(fenceSync);
+
+    if (fenceObjectIt != mFenceSyncMap.end())
+    {
+        mFenceSyncHandleAllocator.release(fenceObjectIt-&gt;first);
+        if (fenceObjectIt-&gt;second) fenceObjectIt-&gt;second-&gt;release();
+        mFenceSyncMap.erase(fenceObjectIt);
+    }
+}
+
</ins><span class="cx"> Buffer *ResourceManager::getBuffer(unsigned int handle)
</span><span class="cx"> {
</span><span class="cx">     BufferMap::iterator buffer = mBufferMap.find(handle);
</span><span class="lines">@@ -269,6 +325,34 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Sampler *ResourceManager::getSampler(unsigned int handle)
+{
+    auto sampler = mSamplerMap.find(handle);
+
+    if (sampler == mSamplerMap.end())
+    {
+        return NULL;
+    }
+    else
+    {
+        return sampler-&gt;second;
+    }
+}
+
+FenceSync *ResourceManager::getFenceSync(unsigned int handle)
+{
+    auto fenceObjectIt = mFenceSyncMap.find(handle);
+
+    if (fenceObjectIt == mFenceSyncMap.end())
+    {
+        return NULL;
+    }
+    else
+    {
+        return fenceObjectIt-&gt;second;
+    }
+}
+
</ins><span class="cx"> void ResourceManager::setRenderbuffer(GLuint handle, Renderbuffer *buffer)
</span><span class="cx"> {
</span><span class="cx">     mRenderbufferMap[handle] = buffer;
</span><span class="lines">@@ -298,6 +382,14 @@
</span><span class="cx">         {
</span><span class="cx">             textureObject = new TextureCubeMap(mRenderer, texture);
</span><span class="cx">         }
</span><ins>+        else if (type == TEXTURE_3D)
+        {
+            textureObject = new Texture3D(mRenderer, texture);
+        }
+        else if (type == TEXTURE_2D_ARRAY)
+        {
+            textureObject = new Texture2DArray(mRenderer, texture);
+        }
</ins><span class="cx">         else
</span><span class="cx">         {
</span><span class="cx">             UNREACHABLE();
</span><span class="lines">@@ -319,4 +411,19 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ResourceManager::checkSamplerAllocation(GLuint sampler)
+{
+    if (sampler != 0 &amp;&amp; !getSampler(sampler))
+    {
+        Sampler *samplerObject = new Sampler(sampler);
+        mSamplerMap[sampler] = samplerObject;
+        samplerObject-&gt;addRef();
+    }
</ins><span class="cx"> }
</span><ins>+
+bool ResourceManager::isSampler(GLuint sampler)
+{
+    return mSamplerMap.find(sampler) != mSamplerMap.end();
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2ResourceManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ResourceManager.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ResourceManager.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/ResourceManager.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -11,13 +11,10 @@
</span><span class="cx"> #define LIBGLESV2_RESOURCEMANAGER_H_
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> 
</span><del>-#ifdef _MSC_VER
-#include &lt;hash_map&gt;
-#else
</del><span class="cx"> #include &lt;unordered_map&gt;
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/angletypes.h&quot;
</span><span class="lines">@@ -35,6 +32,8 @@
</span><span class="cx"> class Program;
</span><span class="cx"> class Texture;
</span><span class="cx"> class Renderbuffer;
</span><ins>+class Sampler;
+class FenceSync;
</ins><span class="cx"> 
</span><span class="cx"> class ResourceManager
</span><span class="cx"> {
</span><span class="lines">@@ -50,57 +49,66 @@
</span><span class="cx">     GLuint createProgram();
</span><span class="cx">     GLuint createTexture();
</span><span class="cx">     GLuint createRenderbuffer();
</span><ins>+    GLuint createSampler();
+    GLuint createFenceSync();
</ins><span class="cx"> 
</span><span class="cx">     void deleteBuffer(GLuint buffer);
</span><span class="cx">     void deleteShader(GLuint shader);
</span><span class="cx">     void deleteProgram(GLuint program);
</span><span class="cx">     void deleteTexture(GLuint texture);
</span><span class="cx">     void deleteRenderbuffer(GLuint renderbuffer);
</span><ins>+    void deleteSampler(GLuint sampler);
+    void deleteFenceSync(GLuint fenceSync);
</ins><span class="cx"> 
</span><span class="cx">     Buffer *getBuffer(GLuint handle);
</span><span class="cx">     Shader *getShader(GLuint handle);
</span><span class="cx">     Program *getProgram(GLuint handle);
</span><span class="cx">     Texture *getTexture(GLuint handle);
</span><span class="cx">     Renderbuffer *getRenderbuffer(GLuint handle);
</span><ins>+    Sampler *getSampler(GLuint handle);
+    FenceSync *getFenceSync(GLuint handle);
</ins><span class="cx">     
</span><span class="cx">     void setRenderbuffer(GLuint handle, Renderbuffer *renderbuffer);
</span><span class="cx"> 
</span><span class="cx">     void checkBufferAllocation(unsigned int buffer);
</span><span class="cx">     void checkTextureAllocation(GLuint texture, TextureType type);
</span><span class="cx">     void checkRenderbufferAllocation(GLuint renderbuffer);
</span><ins>+    void checkSamplerAllocation(GLuint sampler);
</ins><span class="cx"> 
</span><ins>+    bool isSampler(GLuint sampler);
+
</ins><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(ResourceManager);
</span><span class="cx"> 
</span><span class="cx">     std::size_t mRefCount;
</span><span class="cx">     rx::Renderer *mRenderer;
</span><span class="cx"> 
</span><del>-#ifndef HASH_MAP
-# ifdef _MSC_VER
-#  define HASH_MAP stdext::hash_map
-# else
-#  define HASH_MAP std::unordered_map
-# endif
-#endif
-
-    typedef HASH_MAP&lt;GLuint, Buffer*&gt; BufferMap;
</del><ins>+    typedef std::unordered_map&lt;GLuint, Buffer*&gt; BufferMap;
</ins><span class="cx">     BufferMap mBufferMap;
</span><span class="cx">     HandleAllocator mBufferHandleAllocator;
</span><span class="cx"> 
</span><del>-    typedef HASH_MAP&lt;GLuint, Shader*&gt; ShaderMap;
</del><ins>+    typedef std::unordered_map&lt;GLuint, Shader*&gt; ShaderMap;
</ins><span class="cx">     ShaderMap mShaderMap;
</span><span class="cx"> 
</span><del>-    typedef HASH_MAP&lt;GLuint, Program*&gt; ProgramMap;
</del><ins>+    typedef std::unordered_map&lt;GLuint, Program*&gt; ProgramMap;
</ins><span class="cx">     ProgramMap mProgramMap;
</span><span class="cx">     HandleAllocator mProgramShaderHandleAllocator;
</span><span class="cx"> 
</span><del>-    typedef HASH_MAP&lt;GLuint, Texture*&gt; TextureMap;
</del><ins>+    typedef std::unordered_map&lt;GLuint, Texture*&gt; TextureMap;
</ins><span class="cx">     TextureMap mTextureMap;
</span><span class="cx">     HandleAllocator mTextureHandleAllocator;
</span><span class="cx"> 
</span><del>-    typedef HASH_MAP&lt;GLuint, Renderbuffer*&gt; RenderbufferMap;
</del><ins>+    typedef std::unordered_map&lt;GLuint, Renderbuffer*&gt; RenderbufferMap;
</ins><span class="cx">     RenderbufferMap mRenderbufferMap;
</span><span class="cx">     HandleAllocator mRenderbufferHandleAllocator;
</span><ins>+
+    typedef std::unordered_map&lt;GLuint, Sampler*&gt; SamplerMap;
+    SamplerMap mSamplerMap;
+    HandleAllocator mSamplerHandleAllocator;
+
+    typedef std::unordered_map&lt;GLuint, FenceSync*&gt; FenceMap;
+    FenceMap mFenceSyncMap;
+    HandleAllocator mFenceSyncHandleAllocator;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Samplercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Sampler.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Sampler.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Sampler.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+#include &quot;precompiled.h&quot;
+//
+// 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.
+//
+
+// Sampler.cpp : Implements the Sampler class, which represents a GLES 3
+// sampler object. Sampler objects store some state needed to sample textures.
+
+#include &quot;libGLESv2/Sampler.h&quot;
+#include &quot;libGLESv2/angletypes.h&quot;
+
+namespace gl
+{
+
+Sampler::Sampler(GLuint id)
+    : RefCountObject(id),
+      mMinFilter(GL_NEAREST_MIPMAP_LINEAR),
+      mMagFilter(GL_LINEAR),
+      mWrapS(GL_REPEAT),
+      mWrapT(GL_REPEAT),
+      mWrapR(GL_REPEAT),
+      mMinLod(-1000.0f),
+      mMaxLod(1000.0f),
+      mComparisonMode(GL_NONE),
+      mComparisonFunc(GL_LEQUAL)
+{
+}
+
+void Sampler::getState(SamplerState *samplerState) const
+{
+    samplerState-&gt;minFilter   = mMinFilter;
+    samplerState-&gt;magFilter   = mMagFilter;
+    samplerState-&gt;wrapS       = mWrapS;
+    samplerState-&gt;wrapT       = mWrapT;
+    samplerState-&gt;wrapR       = mWrapR;
+    samplerState-&gt;minLod      = mMinLod;
+    samplerState-&gt;maxLod      = mMaxLod;
+    samplerState-&gt;compareMode = mComparisonMode;
+    samplerState-&gt;compareFunc = mComparisonFunc;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Samplerh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Sampler.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Sampler.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Sampler.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+//
+// 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.
+//
+
+// Sampler.h : Defines the Sampler class, which represents a GLES 3
+// sampler object. Sampler objects store some state needed to sample textures.
+
+#ifndef LIBGLESV2_SAMPLER_H_
+#define LIBGLESV2_SAMPLER_H_
+
+#include &quot;common/RefCountObject.h&quot;
+
+namespace gl
+{
+struct SamplerState;
+
+class Sampler : public RefCountObject
+{
+  public:
+    Sampler(GLuint id);
+
+    void setMinFilter(GLenum minFilter) { mMinFilter = minFilter; }
+    void setMagFilter(GLenum magFilter) { mMagFilter = magFilter; }
+    void setWrapS(GLenum wrapS) { mWrapS = wrapS; }
+    void setWrapT(GLenum wrapT) { mWrapT = wrapT; }
+    void setWrapR(GLenum wrapR) { mWrapR = wrapR; }
+    void setMinLod(GLfloat minLod) { mMinLod = minLod; }
+    void setMaxLod(GLfloat maxLod) { mMaxLod = maxLod; }
+    void setComparisonMode(GLenum comparisonMode) { mComparisonMode = comparisonMode; }
+    void setComparisonFunc(GLenum comparisonFunc) { mComparisonFunc = comparisonFunc; }
+
+    GLenum getMinFilter() const { return mMinFilter; }
+    GLenum getMagFilter() const { return mMagFilter; }
+    GLenum getWrapS() const { return mWrapS; }
+    GLenum getWrapT() const { return mWrapT; }
+    GLenum getWrapR() const { return mWrapR; }
+    GLfloat getMinLod() const { return mMinLod; }
+    GLfloat getMaxLod() const { return mMaxLod; }
+    GLenum getComparisonMode() const { return mComparisonMode; }
+    GLenum getComparisonFunc() const { return mComparisonFunc; }
+
+    void getState(SamplerState *samplerState) const;
+
+  private:
+    GLenum mMinFilter;
+    GLenum mMagFilter;
+    GLenum mWrapS;
+    GLenum mWrapT;
+    GLenum mWrapR;
+    GLfloat mMinLod;
+    GLfloat mMaxLod;
+    GLenum mComparisonMode;
+    GLenum mComparisonFunc;
+};
+
+}
+
+#endif // LIBGLESV2_SAMPLER_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Shadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx"> #include &quot;libGLESv2/Shader.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;GLSLANG/ShaderLang.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;common/utilities.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Constants.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/ResourceManager.h&quot;
</span><span class="lines">@@ -25,22 +25,16 @@
</span><span class="cx"> Shader::Shader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle)
</span><span class="cx">     : mHandle(handle), mRenderer(renderer), mResourceManager(manager)
</span><span class="cx"> {
</span><del>-    mSource = NULL;
-    mHlsl = NULL;
-    mInfoLog = NULL;
-
</del><span class="cx">     uncompile();
</span><span class="cx">     initializeCompiler();
</span><span class="cx"> 
</span><span class="cx">     mRefCount = 0;
</span><span class="cx">     mDeleteStatus = false;
</span><ins>+    mShaderVersion = 100;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Shader::~Shader()
</span><span class="cx"> {
</span><del>-    delete[] mSource;
-    delete[] mHlsl;
-    delete[] mInfoLog;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLuint Shader::getHandle() const
</span><span class="lines">@@ -48,69 +42,31 @@
</span><span class="cx">     return mHandle;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Shader::setSource(GLsizei count, const char **string, const GLint *length)
</del><ins>+void Shader::setSource(GLsizei count, const char *const *string, const GLint *length)
</ins><span class="cx"> {
</span><del>-    delete[] mSource;
-    int totalLength = 0;
</del><ins>+    std::ostringstream stream;
</ins><span class="cx"> 
</span><span class="cx">     for (int i = 0; i &lt; count; i++)
</span><span class="cx">     {
</span><del>-        if (length &amp;&amp; length[i] &gt;= 0)
-        {
-            totalLength += length[i];
-        }
-        else
-        {
-            totalLength += (int)strlen(string[i]);
-        }
</del><ins>+        stream &lt;&lt; string[i];
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mSource = new char[totalLength + 1];
-    char *code = mSource;
-
-    for (int i = 0; i &lt; count; i++)
-    {
-        int stringLength;
-
-        if (length &amp;&amp; length[i] &gt;= 0)
-        {
-            stringLength = length[i];
-        }
-        else
-        {
-            stringLength = (int)strlen(string[i]);
-        }
-
-        strncpy(code, string[i], stringLength);
-        code += stringLength;
-    }
-
-    mSource[totalLength] = '\0';
</del><ins>+    mSource = stream.str();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int Shader::getInfoLogLength() const
</span><span class="cx"> {
</span><del>-    if (!mInfoLog)
-    {
-        return 0;
-    }
-    else
-    {
-       return strlen(mInfoLog) + 1;
-    }
</del><ins>+    return mInfoLog.empty() ? 0 : (mInfoLog.length() + 1);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Shader::getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog)
</del><ins>+void Shader::getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog) const
</ins><span class="cx"> {
</span><span class="cx">     int index = 0;
</span><span class="cx"> 
</span><span class="cx">     if (bufSize &gt; 0)
</span><span class="cx">     {
</span><del>-        if (mInfoLog)
-        {
-            index = std::min(bufSize - 1, (int)strlen(mInfoLog));
-            memcpy(infoLog, mInfoLog, index);
-        }
</del><ins>+        index = std::min(bufSize - 1, static_cast&lt;GLsizei&gt;(mInfoLog.length()));
+        memcpy(infoLog, mInfoLog.c_str(), index);
</ins><span class="cx"> 
</span><span class="cx">         infoLog[index] = '\0';
</span><span class="cx">     }
</span><span class="lines">@@ -123,39 +79,22 @@
</span><span class="cx"> 
</span><span class="cx"> int Shader::getSourceLength() const
</span><span class="cx"> {
</span><del>-    if (!mSource)
-    {
-        return 0;
-    }
-    else
-    {
-       return strlen(mSource) + 1;
-    }
</del><ins>+    return mSource.empty() ? 0 : (mSource.length() + 1);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int Shader::getTranslatedSourceLength() const
</span><span class="cx"> {
</span><del>-    if (!mHlsl)
-    {
-        return 0;
-    }
-    else
-    {
-       return strlen(mHlsl) + 1;
-    }
</del><ins>+    return mHlsl.empty() ? 0 : (mHlsl.length() + 1);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Shader::getSourceImpl(char *source, GLsizei bufSize, GLsizei *length, char *buffer)
</del><ins>+void Shader::getSourceImpl(const std::string &amp;source, GLsizei bufSize, GLsizei *length, char *buffer) const
</ins><span class="cx"> {
</span><span class="cx">     int index = 0;
</span><span class="cx"> 
</span><span class="cx">     if (bufSize &gt; 0)
</span><span class="cx">     {
</span><del>-        if (source)
-        {
-            index = std::min(bufSize - 1, (int)strlen(source));
-            memcpy(buffer, source, index);
-        }
</del><ins>+        index = std::min(bufSize - 1, static_cast&lt;GLsizei&gt;(source.length()));
+        memcpy(buffer, source.c_str(), index);
</ins><span class="cx"> 
</span><span class="cx">         buffer[index] = '\0';
</span><span class="cx">     }
</span><span class="lines">@@ -166,28 +105,38 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Shader::getSource(GLsizei bufSize, GLsizei *length, char *buffer)
</del><ins>+void Shader::getSource(GLsizei bufSize, GLsizei *length, char *buffer) const
</ins><span class="cx"> {
</span><span class="cx">     getSourceImpl(mSource, bufSize, length, buffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Shader::getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer)
</del><ins>+void Shader::getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const
</ins><span class="cx"> {
</span><span class="cx">     getSourceImpl(mHlsl, bufSize, length, buffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-const sh::ActiveUniforms &amp;Shader::getUniforms()
</del><ins>+const std::vector&lt;Uniform&gt; &amp;Shader::getUniforms() const
</ins><span class="cx"> {
</span><span class="cx">     return mActiveUniforms;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Shader::isCompiled()
</del><ins>+const std::vector&lt;InterfaceBlock&gt; &amp;Shader::getInterfaceBlocks() const
</ins><span class="cx"> {
</span><del>-    return mHlsl != NULL;
</del><ins>+    return mActiveInterfaceBlocks;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-const char *Shader::getHLSL()
</del><ins>+std::vector&lt;Varying&gt; &amp;Shader::getVaryings()
</ins><span class="cx"> {
</span><ins>+    return mVaryings;
+}
+
+bool Shader::isCompiled() const
+{
+    return !mHlsl.empty();
+}
+
+const std::string &amp;Shader::getHLSL() const
+{
</ins><span class="cx">     return mHlsl;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -245,9 +194,15 @@
</span><span class="cx">             resources.MaxDrawBuffers = mRenderer-&gt;getMaxRenderTargets();
</span><span class="cx">             resources.OES_standard_derivatives = mRenderer-&gt;getDerivativeInstructionSupport();
</span><span class="cx">             resources.EXT_draw_buffers = mRenderer-&gt;getMaxRenderTargets() &gt; 1;
</span><ins>+            resources.EXT_shader_texture_lod = 1;
</ins><span class="cx">             // resources.OES_EGL_image_external = mRenderer-&gt;getShareHandleSupport() ? 1 : 0; // TODO: commented out until the extension is actually supported.
</span><span class="cx">             resources.FragmentPrecisionHigh = 1;   // Shader Model 2+ always supports FP24 (s16e7) which corresponds to highp
</span><span class="cx">             resources.EXT_frag_depth = 1; // Shader Model 2+ always supports explicit depth output
</span><ins>+            // GLSL ES 3.0 constants
+            resources.MaxVertexOutputVectors = mRenderer-&gt;getMaxVaryingVectors();
+            resources.MaxFragmentInputVectors = mRenderer-&gt;getMaxVaryingVectors();
+            resources.MinProgramTexelOffset = -8;   // D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE
+            resources.MaxProgramTexelOffset = 7;    // D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE
</ins><span class="cx"> 
</span><span class="cx">             mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, hlslVersion, &amp;resources);
</span><span class="cx">             mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, hlslVersion, &amp;resources);
</span><span class="lines">@@ -266,57 +221,33 @@
</span><span class="cx">     ShFinalize();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Shader::parseVaryings()
</del><ins>+void Shader::parseVaryings(void *compiler)
</ins><span class="cx"> {
</span><del>-    if (mHlsl)
</del><ins>+    if (!mHlsl.empty())
</ins><span class="cx">     {
</span><del>-        const char *input = strstr(mHlsl, &quot;// Varyings&quot;) + 12;
</del><ins>+        std::vector&lt;Varying&gt; *activeVaryings;
+        ShGetInfoPointer(compiler, SH_ACTIVE_VARYINGS_ARRAY, reinterpret_cast&lt;void**&gt;(&amp;activeVaryings));
+        mVaryings = *activeVaryings;
</ins><span class="cx"> 
</span><del>-        while(true)
-        {
-            char varyingType[256];
-            char varyingName[256];
-
-            int matches = sscanf(input, &quot;static %255s %255s&quot;, varyingType, varyingName);
-
-            if (matches != 2)
-            {
-                break;
-            }
-
-            char *array = strstr(varyingName, &quot;[&quot;);
-            int size = 1;
-
-            if (array)
-            {
-                size = atoi(array + 1);
-                *array = '\0';
-            }
-
-            mVaryings.push_back(Varying(parseType(varyingType), varyingName, size, array != NULL));
-
-            input = strstr(input, &quot;;&quot;) + 2;
-        }
-
-        mUsesMultipleRenderTargets = strstr(mHlsl, &quot;GL_USES_MRT&quot;) != NULL;
-        mUsesFragColor = strstr(mHlsl, &quot;GL_USES_FRAG_COLOR&quot;) != NULL;
-        mUsesFragData = strstr(mHlsl, &quot;GL_USES_FRAG_DATA&quot;) != NULL;
-        mUsesFragCoord = strstr(mHlsl, &quot;GL_USES_FRAG_COORD&quot;) != NULL;
-        mUsesFrontFacing = strstr(mHlsl, &quot;GL_USES_FRONT_FACING&quot;) != NULL;
-        mUsesPointSize = strstr(mHlsl, &quot;GL_USES_POINT_SIZE&quot;) != NULL;
-        mUsesPointCoord = strstr(mHlsl, &quot;GL_USES_POINT_COORD&quot;) != NULL;
-        mUsesDepthRange = strstr(mHlsl, &quot;GL_USES_DEPTH_RANGE&quot;) != NULL;
-        mUsesFragDepth = strstr(mHlsl, &quot;GL_USES_FRAG_DEPTH&quot;) != NULL;
-        mUsesDiscardRewriting = strstr(mHlsl, &quot;ANGLE_USES_DISCARD_REWRITING&quot;) != NULL;
</del><ins>+        mUsesMultipleRenderTargets = mHlsl.find(&quot;GL_USES_MRT&quot;)          != std::string::npos;
+        mUsesFragColor             = mHlsl.find(&quot;GL_USES_FRAG_COLOR&quot;)   != std::string::npos;
+        mUsesFragData              = mHlsl.find(&quot;GL_USES_FRAG_DATA&quot;)    != std::string::npos;
+        mUsesFragCoord             = mHlsl.find(&quot;GL_USES_FRAG_COORD&quot;)   != std::string::npos;
+        mUsesFrontFacing           = mHlsl.find(&quot;GL_USES_FRONT_FACING&quot;) != std::string::npos;
+        mUsesPointSize             = mHlsl.find(&quot;GL_USES_POINT_SIZE&quot;)   != std::string::npos;
+        mUsesPointCoord            = mHlsl.find(&quot;GL_USES_POINT_COORD&quot;)  != std::string::npos;
+        mUsesDepthRange            = mHlsl.find(&quot;GL_USES_DEPTH_RANGE&quot;)  != std::string::npos;
+        mUsesFragDepth             = mHlsl.find(&quot;GL_USES_FRAG_DEPTH&quot;)   != std::string::npos;
+        mUsesDiscardRewriting      = mHlsl.find(&quot;ANGLE_USES_DISCARD_REWRITING&quot;) != std::string::npos;
+        mUsesNestedBreak           = mHlsl.find(&quot;ANGLE_USES_NESTED_BREAK&quot;) != std::string::npos;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Shader::resetVaryingsRegisterAssignment()
</span><span class="cx"> {
</span><del>-    for (VaryingList::iterator var = mVaryings.begin(); var != mVaryings.end(); var++)
</del><ins>+    for (unsigned int varyingIndex = 0; varyingIndex &lt; mVaryings.size(); varyingIndex++)
</ins><span class="cx">     {
</span><del>-        var-&gt;reg = -1;
-        var-&gt;col = -1;
</del><ins>+        mVaryings[varyingIndex].resetRegisterAssignment();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -324,10 +255,8 @@
</span><span class="cx"> void Shader::uncompile()
</span><span class="cx"> {
</span><span class="cx">     // set by compileToHLSL
</span><del>-    delete[] mHlsl;
-    mHlsl = NULL;
-    delete[] mInfoLog;
-    mInfoLog = NULL;
</del><ins>+    mHlsl.clear();
+    mInfoLog.clear();
</ins><span class="cx"> 
</span><span class="cx">     // set by parseVaryings
</span><span class="cx">     mVaryings.clear();
</span><span class="lines">@@ -341,20 +270,16 @@
</span><span class="cx">     mUsesPointCoord = false;
</span><span class="cx">     mUsesDepthRange = false;
</span><span class="cx">     mUsesFragDepth = false;
</span><ins>+    mShaderVersion = 100;
</ins><span class="cx">     mUsesDiscardRewriting = false;
</span><ins>+    mUsesNestedBreak = false;
</ins><span class="cx"> 
</span><span class="cx">     mActiveUniforms.clear();
</span><ins>+    mActiveInterfaceBlocks.clear();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Shader::compileToHLSL(void *compiler)
</span><span class="cx"> {
</span><del>-    // ensure we don't pass a NULL source to the compiler
-    const char *source = &quot;\0&quot;;
-    if (mSource)
-    {
-        source = mSource;
-    }
-
</del><span class="cx">     // ensure the compiler is loaded
</span><span class="cx">     initializeCompiler();
</span><span class="cx"> 
</span><span class="lines">@@ -363,166 +288,191 @@
</span><span class="cx">     if (perfActive())
</span><span class="cx">     {
</span><span class="cx">         sourcePath = getTempPath();
</span><del>-        writeFile(sourcePath.c_str(), source, strlen(source));
</del><ins>+        writeFile(sourcePath.c_str(), mSource.c_str(), mSource.length());
</ins><span class="cx">         compileOptions |= SH_LINE_DIRECTIVES;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     int result;
</span><span class="cx">     if (sourcePath.empty())
</span><span class="cx">     {
</span><del>-        result = ShCompile(compiler, &amp;source, 1, compileOptions);
</del><ins>+        const char* sourceStrings[] =
+        {
+            mSource.c_str(),
+        };
+
+        result = ShCompile(compiler, sourceStrings, ArraySize(sourceStrings), compileOptions);
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        const char* sourceStrings[2] =
</del><ins>+        const char* sourceStrings[] =
</ins><span class="cx">         {
</span><span class="cx">             sourcePath.c_str(),
</span><del>-            source
</del><ins>+            mSource.c_str(),
</ins><span class="cx">         };
</span><span class="cx"> 
</span><del>-        result = ShCompile(compiler, sourceStrings, 2, compileOptions | SH_SOURCE_PATH);
</del><ins>+        result = ShCompile(compiler, sourceStrings, ArraySize(sourceStrings), compileOptions | SH_SOURCE_PATH);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (result)
</del><ins>+    size_t shaderVersion = 100;
+    ShGetInfo(compiler, SH_SHADER_VERSION, &amp;shaderVersion);
+
+    mShaderVersion = static_cast&lt;int&gt;(shaderVersion);
+
+    if (shaderVersion == 300 &amp;&amp; mRenderer-&gt;getCurrentClientVersion() &lt; 3)
</ins><span class="cx">     {
</span><ins>+        mInfoLog = &quot;GLSL ES 3.00 is not supported by OpenGL ES 2.0 contexts&quot;;
+        TRACE(&quot;\n%s&quot;, mInfoLog.c_str());
+    }
+    else if (result)
+    {
</ins><span class="cx">         size_t objCodeLen = 0;
</span><span class="cx">         ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &amp;objCodeLen);
</span><del>-        mHlsl = new char[objCodeLen];
-        ShGetObjectCode(compiler, mHlsl);
</del><span class="cx"> 
</span><ins>+        char* outputHLSL = new char[objCodeLen];
+        ShGetObjectCode(compiler, outputHLSL);
+
+#ifdef _DEBUG
+        std::ostringstream hlslStream;
+        hlslStream &lt;&lt; &quot;// GLSL\n&quot;;
+        hlslStream &lt;&lt; &quot;//\n&quot;;
+
+        size_t curPos = 0;
+        while (curPos != std::string::npos)
+        {
+            size_t nextLine = mSource.find(&quot;\n&quot;, curPos);
+            size_t len = (nextLine == std::string::npos) ? std::string::npos : (nextLine - curPos + 1);
+
+            hlslStream &lt;&lt; &quot;// &quot; &lt;&lt; mSource.substr(curPos, len);
+
+            curPos = (nextLine == std::string::npos) ? std::string::npos : (nextLine + 1);
+        }
+        hlslStream &lt;&lt; &quot;\n\n&quot;;
+        hlslStream &lt;&lt; outputHLSL;
+        mHlsl = hlslStream.str();
+#else
+        mHlsl = outputHLSL;
+#endif
+
+        delete[] outputHLSL;
+
</ins><span class="cx">         void *activeUniforms;
</span><span class="cx">         ShGetInfoPointer(compiler, SH_ACTIVE_UNIFORMS_ARRAY, &amp;activeUniforms);
</span><del>-        mActiveUniforms = *(sh::ActiveUniforms*)activeUniforms;
</del><ins>+        mActiveUniforms = *(std::vector&lt;Uniform&gt;*)activeUniforms;
+
+        void *activeInterfaceBlocks;
+        ShGetInfoPointer(compiler, SH_ACTIVE_INTERFACE_BLOCKS_ARRAY, &amp;activeInterfaceBlocks);
+        mActiveInterfaceBlocks = *(std::vector&lt;InterfaceBlock&gt;*)activeInterfaceBlocks;
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="cx">         size_t infoLogLen = 0;
</span><span class="cx">         ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &amp;infoLogLen);
</span><del>-        mInfoLog = new char[infoLogLen];
-        ShGetInfoLog(compiler, mInfoLog);
</del><span class="cx"> 
</span><del>-        TRACE(&quot;\n%s&quot;, mInfoLog);
</del><ins>+        char* infoLog = new char[infoLogLen];
+        ShGetInfoLog(compiler, infoLog);
+        mInfoLog = infoLog;
+
+        TRACE(&quot;\n%s&quot;, mInfoLog.c_str());
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLenum Shader::parseType(const std::string &amp;type)
</del><ins>+rx::D3DWorkaroundType Shader::getD3DWorkarounds() const
</ins><span class="cx"> {
</span><del>-    if (type == &quot;float&quot;)
</del><ins>+    if (mUsesDiscardRewriting)
</ins><span class="cx">     {
</span><del>-        return GL_FLOAT;
</del><ins>+        // ANGLE issue 486:
+        // Work-around a D3D9 compiler bug that presents itself when using conditional discard, by disabling optimization
+        return rx::ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION;
</ins><span class="cx">     }
</span><del>-    else if (type == &quot;float2&quot;)
</del><ins>+
+    if (mUsesNestedBreak)
</ins><span class="cx">     {
</span><del>-        return GL_FLOAT_VEC2;
</del><ins>+        // ANGLE issue 603:
+        // Work-around a D3D9 compiler bug that presents itself when using break in a nested loop, by maximizing optimization
+        // We want to keep the use of ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION minimal to prevent hangs, so usesDiscard takes precedence
+        return rx::ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION;
</ins><span class="cx">     }
</span><del>-    else if (type == &quot;float3&quot;)
-    {
-        return GL_FLOAT_VEC3;
-    }
-    else if (type == &quot;float4&quot;)
-    {
-        return GL_FLOAT_VEC4;
-    }
-    else if (type == &quot;float2x2&quot;)
-    {
-        return GL_FLOAT_MAT2;
-    }
-    else if (type == &quot;float3x3&quot;)
-    {
-        return GL_FLOAT_MAT3;
-    }
-    else if (type == &quot;float4x4&quot;)
-    {
-        return GL_FLOAT_MAT4;
-    }
-    else UNREACHABLE();
</del><span class="cx"> 
</span><del>-    return GL_NONE;
</del><ins>+    return rx::ANGLE_D3D_WORKAROUND_NONE;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// [OpenGL ES SL 3.00.4] Section 11 p. 120
+// Vertex Outs/Fragment Ins packing priorities
+static const GLenum varyingPriorityList[] =
+{
+    // 1. Arrays of mat4 and mat4
+    GL_FLOAT_MAT4,
+
+    // Non-square matrices of type matCxR consume the same space as a square
+    // matrix of type matN where N is the greater of C and R
+    GL_FLOAT_MAT3x4,
+    GL_FLOAT_MAT4x3,
+    GL_FLOAT_MAT2x4,
+    GL_FLOAT_MAT4x2,
+
+    // 2. Arrays of mat2 and mat2 (since they occupy full rows)
+    GL_FLOAT_MAT2,
+
+    // 3. Arrays of vec4 and vec4
+    GL_FLOAT_VEC4,
+    GL_INT_VEC4,
+    GL_UNSIGNED_INT_VEC4,
+
+    // 4. Arrays of mat3 and mat3
+    GL_FLOAT_MAT3,
+    GL_FLOAT_MAT2x3,
+    GL_FLOAT_MAT3x2,
+
+    // 5. Arrays of vec3 and vec3
+    GL_FLOAT_VEC3,
+    GL_INT_VEC3,
+    GL_UNSIGNED_INT_VEC3,
+
+    // 6. Arrays of vec2 and vec2
+    GL_FLOAT_VEC2,
+    GL_INT_VEC2,
+    GL_UNSIGNED_INT_VEC2,
+
+    // 7. Arrays of float and float
+    GL_FLOAT,
+    GL_INT,
+    GL_UNSIGNED_INT,
+};
+
</ins><span class="cx"> // true if varying x has a higher priority in packing than y
</span><del>-bool Shader::compareVarying(const Varying &amp;x, const Varying &amp;y)
</del><ins>+bool Shader::compareVarying(const ShaderVariable &amp;x, const ShaderVariable &amp;y)
</ins><span class="cx"> {
</span><del>-    if(x.type == y.type)
</del><ins>+    if (x.type == y.type)
</ins><span class="cx">     {
</span><del>-        return x.size &gt; y.size;
</del><ins>+        return x.arraySize &gt; y.arraySize;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    switch (x.type)
</del><ins>+    // Special case for handling structs: we sort these to the end of the list
+    if (x.type == GL_STRUCT_ANGLEX)
</ins><span class="cx">     {
</span><del>-      case GL_FLOAT_MAT4: return true;
-      case GL_FLOAT_MAT2:
-        switch(y.type)
-        {
-          case GL_FLOAT_MAT4: return false;
-          case GL_FLOAT_MAT2: return true;
-          case GL_FLOAT_VEC4: return true;
-          case GL_FLOAT_MAT3: return true;
-          case GL_FLOAT_VEC3: return true;
-          case GL_FLOAT_VEC2: return true;
-          case GL_FLOAT:      return true;
-          default: UNREACHABLE();
-        }
-        break;
-      case GL_FLOAT_VEC4:
-        switch(y.type)
-        {
-          case GL_FLOAT_MAT4: return false;
-          case GL_FLOAT_MAT2: return false;
-          case GL_FLOAT_VEC4: return true;
-          case GL_FLOAT_MAT3: return true;
-          case GL_FLOAT_VEC3: return true;
-          case GL_FLOAT_VEC2: return true;
-          case GL_FLOAT:      return true;
-          default: UNREACHABLE();
-        }
-        break;
-      case GL_FLOAT_MAT3:
-        switch(y.type)
-        {
-          case GL_FLOAT_MAT4: return false;
-          case GL_FLOAT_MAT2: return false;
-          case GL_FLOAT_VEC4: return false;
-          case GL_FLOAT_MAT3: return true;
-          case GL_FLOAT_VEC3: return true;
-          case GL_FLOAT_VEC2: return true;
-          case GL_FLOAT:      return true;
-          default: UNREACHABLE();
-        }
-        break;
-      case GL_FLOAT_VEC3:
-        switch(y.type)
-        {
-          case GL_FLOAT_MAT4: return false;
-          case GL_FLOAT_MAT2: return false;
-          case GL_FLOAT_VEC4: return false;
-          case GL_FLOAT_MAT3: return false;
-          case GL_FLOAT_VEC3: return true;
-          case GL_FLOAT_VEC2: return true;
-          case GL_FLOAT:      return true;
-          default: UNREACHABLE();
-        }
-        break;
-      case GL_FLOAT_VEC2:
-        switch(y.type)
-        {
-          case GL_FLOAT_MAT4: return false;
-          case GL_FLOAT_MAT2: return false;
-          case GL_FLOAT_VEC4: return false;
-          case GL_FLOAT_MAT3: return false;
-          case GL_FLOAT_VEC3: return false;
-          case GL_FLOAT_VEC2: return true;
-          case GL_FLOAT:      return true;
-          default: UNREACHABLE();
-        }
-        break;
-      case GL_FLOAT: return false;
-      default: UNREACHABLE();
</del><ins>+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return false;
</del><ins>+    unsigned int xPriority = GL_INVALID_INDEX;
+    unsigned int yPriority = GL_INVALID_INDEX;
+
+    for (unsigned int priorityIndex = 0; priorityIndex &lt; ArraySize(varyingPriorityList); priorityIndex++)
+    {
+        if (varyingPriorityList[priorityIndex] == x.type) xPriority = priorityIndex;
+        if (varyingPriorityList[priorityIndex] == y.type) yPriority = priorityIndex;
+        if (xPriority != GL_INVALID_INDEX &amp;&amp; yPriority != GL_INVALID_INDEX) break;
+    }
+
+    ASSERT(xPriority != GL_INVALID_INDEX &amp;&amp; yPriority != GL_INVALID_INDEX);
+
+    return xPriority &lt;= yPriority;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int Shader::getShaderVersion() const
+{
+    return mShaderVersion;
+}
+
</ins><span class="cx"> VertexShader::VertexShader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle)
</span><span class="cx">     : Shader(manager, renderer, handle)
</span><span class="cx"> {
</span><span class="lines">@@ -542,7 +492,7 @@
</span><span class="cx">     Shader::uncompile();
</span><span class="cx"> 
</span><span class="cx">     // set by ParseAttributes
</span><del>-    mAttributes.clear();
</del><ins>+    mActiveAttributes.clear();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void VertexShader::compile()
</span><span class="lines">@@ -551,7 +501,7 @@
</span><span class="cx"> 
</span><span class="cx">     compileToHLSL(mVertexCompiler);
</span><span class="cx">     parseAttributes();
</span><del>-    parseVaryings();
</del><ins>+    parseVaryings(mVertexCompiler);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int VertexShader::getSemanticIndex(const std::string &amp;attributeName)
</span><span class="lines">@@ -559,14 +509,16 @@
</span><span class="cx">     if (!attributeName.empty())
</span><span class="cx">     {
</span><span class="cx">         int semanticIndex = 0;
</span><del>-        for (AttributeArray::iterator attribute = mAttributes.begin(); attribute != mAttributes.end(); attribute++)
</del><ins>+        for (unsigned int attributeIndex = 0; attributeIndex &lt; mActiveAttributes.size(); attributeIndex++)
</ins><span class="cx">         {
</span><del>-            if (attribute-&gt;name == attributeName)
</del><ins>+            const ShaderVariable &amp;attribute = mActiveAttributes[attributeIndex];
+
+            if (attribute.name == attributeName)
</ins><span class="cx">             {
</span><span class="cx">                 return semanticIndex;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            semanticIndex += VariableRowCount(attribute-&gt;type);
</del><ins>+            semanticIndex += AttributeRegisterCount(attribute.type);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -575,27 +527,12 @@
</span><span class="cx"> 
</span><span class="cx"> void VertexShader::parseAttributes()
</span><span class="cx"> {
</span><del>-    const char *hlsl = getHLSL();
-    if (hlsl)
</del><ins>+    const std::string &amp;hlsl = getHLSL();
+    if (!hlsl.empty())
</ins><span class="cx">     {
</span><del>-        const char *input = strstr(hlsl, &quot;// Attributes&quot;) + 14;
-
-        while(true)
-        {
-            char attributeType[256];
-            char attributeName[256];
-
-            int matches = sscanf(input, &quot;static %255s _%255s&quot;, attributeType, attributeName);
-
-            if (matches != 2)
-            {
-                break;
-            }
-
-            mAttributes.push_back(Attribute(parseType(attributeType), attributeName));
-
-            input = strstr(input, &quot;;&quot;) + 2;
-        }
</del><ins>+        void *activeAttributes;
+        ShGetInfoPointer(mVertexCompiler, SH_ACTIVE_ATTRIBUTES_ARRAY, &amp;activeAttributes);
+        mActiveAttributes = *(std::vector&lt;Attribute&gt;*)activeAttributes;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -618,7 +555,28 @@
</span><span class="cx">     uncompile();
</span><span class="cx"> 
</span><span class="cx">     compileToHLSL(mFragmentCompiler);
</span><del>-    parseVaryings();
-    mVaryings.sort(compareVarying);
</del><ins>+    parseVaryings(mFragmentCompiler);
+    std::sort(mVaryings.begin(), mVaryings.end(), compareVarying);
+
+    const std::string &amp;hlsl = getHLSL();
+    if (!hlsl.empty())
+    {
+        void *activeOutputVariables;
+        ShGetInfoPointer(mFragmentCompiler, SH_ACTIVE_OUTPUT_VARIABLES_ARRAY, &amp;activeOutputVariables);
+        mActiveOutputVariables = *(std::vector&lt;Attribute&gt;*)activeOutputVariables;
+    }
</ins><span class="cx"> }
</span><ins>+
+void FragmentShader::uncompile()
+{
+    Shader::uncompile();
+
+    mActiveOutputVariables.clear();
</ins><span class="cx"> }
</span><ins>+
+const std::vector&lt;Attribute&gt; &amp;FragmentShader::getOutputVariables() const
+{
+    return mActiveOutputVariables;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Shaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -13,13 +13,15 @@
</span><span class="cx"> #define LIBGLESV2_SHADER_H_
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> #include &lt;string&gt;
</span><span class="cx"> #include &lt;list&gt;
</span><span class="cx"> #include &lt;vector&gt;
</span><span class="cx"> 
</span><del>-#include &quot;compiler/translator/Uniform.h&quot;
</del><ins>+#include &quot;common/shadervars.h&quot;
</ins><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><ins>+#include &quot;libGLESv2/angletypes.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -30,27 +32,9 @@
</span><span class="cx"> {
</span><span class="cx"> class ResourceManager;
</span><span class="cx"> 
</span><del>-struct Varying
-{
-    Varying(GLenum type, const std::string &amp;name, int size, bool array)
-        : type(type), name(name), size(size), array(array), reg(-1), col(-1)
-    {
-    }
-
-    GLenum type;
-    std::string name;
-    int size;   // Number of 'type' elements
-    bool array;
-
-    int reg;    // First varying register, assigned during link
-    int col;    // First register element, assigned during link
-};
-
-typedef std::list&lt;Varying&gt; VaryingList;
-
</del><span class="cx"> class Shader
</span><span class="cx"> {
</span><del>-    friend class ProgramBinary;
</del><ins>+    friend class DynamicHLSL;
</ins><span class="cx"> 
</span><span class="cx">   public:
</span><span class="cx">     Shader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle);
</span><span class="lines">@@ -61,42 +45,48 @@
</span><span class="cx">     GLuint getHandle() const;
</span><span class="cx"> 
</span><span class="cx">     void deleteSource();
</span><del>-    void setSource(GLsizei count, const char **string, const GLint *length);
</del><ins>+    void setSource(GLsizei count, const char *const *string, const GLint *length);
</ins><span class="cx">     int getInfoLogLength() const;
</span><del>-    void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
</del><ins>+    void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog) const;
</ins><span class="cx">     int getSourceLength() const;
</span><del>-    void getSource(GLsizei bufSize, GLsizei *length, char *buffer);
</del><ins>+    void getSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
</ins><span class="cx">     int getTranslatedSourceLength() const;
</span><del>-    void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer);
-    const sh::ActiveUniforms &amp;getUniforms();
</del><ins>+    void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
+    const std::vector&lt;Uniform&gt; &amp;getUniforms() const;
+    const std::vector&lt;InterfaceBlock&gt; &amp;getInterfaceBlocks() const;
+    std::vector&lt;Varying&gt; &amp;getVaryings();
</ins><span class="cx"> 
</span><span class="cx">     virtual void compile() = 0;
</span><span class="cx">     virtual void uncompile();
</span><del>-    bool isCompiled();
-    const char *getHLSL();
</del><ins>+    bool isCompiled() const;
+    const std::string &amp;getHLSL() const;
</ins><span class="cx"> 
</span><span class="cx">     void addRef();
</span><span class="cx">     void release();
</span><span class="cx">     unsigned int getRefCount() const;
</span><span class="cx">     bool isFlaggedForDeletion() const;
</span><span class="cx">     void flagForDeletion();
</span><ins>+    int getShaderVersion() const;
+    void resetVaryingsRegisterAssignment();
</ins><span class="cx"> 
</span><span class="cx">     static void releaseCompiler();
</span><span class="cx"> 
</span><ins>+    bool usesDepthRange() const { return mUsesDepthRange; }
+    bool usesPointSize() const { return mUsesPointSize; }
+    rx::D3DWorkaroundType getD3DWorkarounds() const;
+
</ins><span class="cx">   protected:
</span><del>-    void parseVaryings();
-    void resetVaryingsRegisterAssignment();
</del><ins>+    void parseVaryings(void *compiler);
</ins><span class="cx"> 
</span><span class="cx">     void compileToHLSL(void *compiler);
</span><span class="cx"> 
</span><del>-    void getSourceImpl(char *source, GLsizei bufSize, GLsizei *length, char *buffer);
</del><ins>+    void getSourceImpl(const std::string &amp;source, GLsizei bufSize, GLsizei *length, char *buffer) const;
</ins><span class="cx"> 
</span><del>-    static GLenum parseType(const std::string &amp;type);
-    static bool compareVarying(const Varying &amp;x, const Varying &amp;y);
</del><ins>+    static bool compareVarying(const ShaderVariable &amp;x, const ShaderVariable &amp;y);
</ins><span class="cx"> 
</span><span class="cx">     const rx::Renderer *const mRenderer;
</span><span class="cx"> 
</span><del>-    VaryingList mVaryings;
</del><ins>+    std::vector&lt;Varying&gt; mVaryings;
</ins><span class="cx"> 
</span><span class="cx">     bool mUsesMultipleRenderTargets;
</span><span class="cx">     bool mUsesFragColor;
</span><span class="lines">@@ -107,7 +97,9 @@
</span><span class="cx">     bool mUsesPointCoord;
</span><span class="cx">     bool mUsesDepthRange;
</span><span class="cx">     bool mUsesFragDepth;
</span><ins>+    int mShaderVersion;
</ins><span class="cx">     bool mUsesDiscardRewriting;
</span><ins>+    bool mUsesNestedBreak;
</ins><span class="cx"> 
</span><span class="cx">     static void *mFragmentCompiler;
</span><span class="cx">     static void *mVertexCompiler;
</span><span class="lines">@@ -121,33 +113,18 @@
</span><span class="cx">     unsigned int mRefCount;     // Number of program objects this shader is attached to
</span><span class="cx">     bool mDeleteStatus;         // Flag to indicate that the shader can be deleted when no longer in use
</span><span class="cx"> 
</span><del>-    char *mSource;
-    char *mHlsl;
-    char *mInfoLog;
-    sh::ActiveUniforms mActiveUniforms;
</del><ins>+    std::string mSource;
+    std::string mHlsl;
+    std::string mInfoLog;
+    std::vector&lt;Uniform&gt; mActiveUniforms;
+    std::vector&lt;InterfaceBlock&gt; mActiveInterfaceBlocks;
</ins><span class="cx"> 
</span><span class="cx">     ResourceManager *mResourceManager;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-struct Attribute
-{
-    Attribute() : type(GL_NONE), name(&quot;&quot;)
-    {
-    }
-
-    Attribute(GLenum type, const std::string &amp;name) : type(type), name(name)
-    {
-    }
-
-    GLenum type;
-    std::string name;
-};
-
-typedef std::vector&lt;Attribute&gt; AttributeArray;
-
</del><span class="cx"> class VertexShader : public Shader
</span><span class="cx"> {
</span><del>-    friend class ProgramBinary;
</del><ins>+    friend class DynamicHLSL;
</ins><span class="cx"> 
</span><span class="cx">   public:
</span><span class="cx">     VertexShader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle);
</span><span class="lines">@@ -159,12 +136,14 @@
</span><span class="cx">     virtual void uncompile();
</span><span class="cx">     int getSemanticIndex(const std::string &amp;attributeName);
</span><span class="cx"> 
</span><ins>+    const std::vector&lt;Attribute&gt; &amp;activeAttributes() const { return mActiveAttributes; }
+
</ins><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(VertexShader);
</span><span class="cx"> 
</span><span class="cx">     void parseAttributes();
</span><span class="cx"> 
</span><del>-    AttributeArray mAttributes;
</del><ins>+    std::vector&lt;Attribute&gt; mActiveAttributes;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class FragmentShader : public Shader
</span><span class="lines">@@ -176,9 +155,13 @@
</span><span class="cx"> 
</span><span class="cx">     virtual GLenum getType();
</span><span class="cx">     virtual void compile();
</span><ins>+    virtual void uncompile();
+    const std::vector&lt;Attribute&gt; &amp;getOutputVariables() const;
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(FragmentShader);
</span><ins>+
+    std::vector&lt;Attribute&gt; mActiveOutputVariables;
</ins><span class="cx"> };
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Texturecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -12,129 +12,176 @@
</span><span class="cx"> #include &quot;libGLESv2/Texture.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><del>-#include &quot;libGLESv2/mathutil.h&quot;
-#include &quot;libGLESv2/utilities.h&quot;
-#include &quot;libGLESv2/renderer/d3d9/Blit.h&quot;
</del><ins>+#include &quot;common/mathutil.h&quot;
+#include &quot;common/utilities.h&quot;
+#include &quot;libGLESv2/formatutils.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/Renderbuffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Image.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/TextureStorage.h&quot;
</span><span class="cx"> #include &quot;libEGL/Surface.h&quot;
</span><ins>+#include &quot;libGLESv2/Buffer.h&quot;
+#include &quot;libGLESv2/renderer/BufferStorage.h&quot;
+#include &quot;libGLESv2/renderer/RenderTarget.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-Texture::Texture(rx::Renderer *renderer, GLuint id) : RefCountObject(id)
</del><ins>+bool IsMipmapFiltered(const SamplerState &amp;samplerState)
</ins><span class="cx"> {
</span><ins>+    switch (samplerState.minFilter)
+    {
+      case GL_NEAREST:
+      case GL_LINEAR:
+        return false;
+      case GL_NEAREST_MIPMAP_NEAREST:
+      case GL_LINEAR_MIPMAP_NEAREST:
+      case GL_NEAREST_MIPMAP_LINEAR:
+      case GL_LINEAR_MIPMAP_LINEAR:
+        return true;
+      default: UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsRenderTargetUsage(GLenum usage)
+{
+    return (usage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
+}
+
+Texture::Texture(rx::Renderer *renderer, GLuint id, GLenum target) : RefCountObject(id)
+{
</ins><span class="cx">     mRenderer = renderer;
</span><span class="cx"> 
</span><span class="cx">     mSamplerState.minFilter = GL_NEAREST_MIPMAP_LINEAR;
</span><span class="cx">     mSamplerState.magFilter = GL_LINEAR;
</span><span class="cx">     mSamplerState.wrapS = GL_REPEAT;
</span><span class="cx">     mSamplerState.wrapT = GL_REPEAT;
</span><ins>+    mSamplerState.wrapR = GL_REPEAT;
</ins><span class="cx">     mSamplerState.maxAnisotropy = 1.0f;
</span><del>-    mSamplerState.lodOffset = 0;
</del><ins>+    mSamplerState.baseLevel = 0;
+    mSamplerState.maxLevel = 1000;
+    mSamplerState.minLod = -1000.0f;
+    mSamplerState.maxLod = 1000.0f;
+    mSamplerState.compareMode = GL_NONE;
+    mSamplerState.compareFunc = GL_LEQUAL;
+    mSamplerState.swizzleRed = GL_RED;
+    mSamplerState.swizzleGreen = GL_GREEN;
+    mSamplerState.swizzleBlue = GL_BLUE;
+    mSamplerState.swizzleAlpha = GL_ALPHA;
</ins><span class="cx">     mUsage = GL_NONE;
</span><del>-    
</del><ins>+
</ins><span class="cx">     mDirtyImages = true;
</span><span class="cx"> 
</span><span class="cx">     mImmutable = false;
</span><ins>+
+    mTarget = target;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Texture::~Texture()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Returns true on successful filter state update (valid enum parameter)
-bool Texture::setMinFilter(GLenum filter)
</del><ins>+GLenum Texture::getTarget() const
</ins><span class="cx"> {
</span><del>-    switch (filter)
-    {
-      case GL_NEAREST:
-      case GL_LINEAR:
-      case GL_NEAREST_MIPMAP_NEAREST:
-      case GL_LINEAR_MIPMAP_NEAREST:
-      case GL_NEAREST_MIPMAP_LINEAR:
-      case GL_LINEAR_MIPMAP_LINEAR:
-        mSamplerState.minFilter = filter;
-        return true;
-      default:
-        return false;
-    }
</del><ins>+    return mTarget;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Returns true on successful filter state update (valid enum parameter)
-bool Texture::setMagFilter(GLenum filter)
</del><ins>+void Texture::addProxyRef(const Renderbuffer *proxy)
</ins><span class="cx"> {
</span><del>-    switch (filter)
-    {
-      case GL_NEAREST:
-      case GL_LINEAR:
-        mSamplerState.magFilter = filter;
-        return true;
-      default:
-        return false;
-    }
</del><ins>+    mRenderbufferProxies.addRef(proxy);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Returns true on successful wrap state update (valid enum parameter)
-bool Texture::setWrapS(GLenum wrap)
</del><ins>+void Texture::releaseProxy(const Renderbuffer *proxy)
</ins><span class="cx"> {
</span><del>-    switch (wrap)
-    {
-      case GL_REPEAT:
-      case GL_CLAMP_TO_EDGE:
-      case GL_MIRRORED_REPEAT:
-        mSamplerState.wrapS = wrap;
-        return true;
-      default:
-        return false;
-    }
</del><ins>+    mRenderbufferProxies.release(proxy);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Returns true on successful wrap state update (valid enum parameter)
-bool Texture::setWrapT(GLenum wrap)
</del><ins>+void Texture::setMinFilter(GLenum filter)
</ins><span class="cx"> {
</span><del>-    switch (wrap)
-    {
-      case GL_REPEAT:
-      case GL_CLAMP_TO_EDGE:
-      case GL_MIRRORED_REPEAT:
-        mSamplerState.wrapT = wrap;
-        return true;
-      default:
-        return false;
-    }
</del><ins>+    mSamplerState.minFilter = filter;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Returns true on successful max anisotropy update (valid anisotropy value)
-bool Texture::setMaxAnisotropy(float textureMaxAnisotropy, float contextMaxAnisotropy)
</del><ins>+void Texture::setMagFilter(GLenum filter)
</ins><span class="cx"> {
</span><del>-    textureMaxAnisotropy = std::min(textureMaxAnisotropy, contextMaxAnisotropy);
-    if (textureMaxAnisotropy &lt; 1.0f)
-    {
-        return false;
-    }
</del><ins>+    mSamplerState.magFilter = filter;
+}
</ins><span class="cx"> 
</span><del>-    mSamplerState.maxAnisotropy = textureMaxAnisotropy;
</del><ins>+void Texture::setWrapS(GLenum wrap)
+{
+    mSamplerState.wrapS = wrap;
+}
</ins><span class="cx"> 
</span><del>-    return true;
</del><ins>+void Texture::setWrapT(GLenum wrap)
+{
+    mSamplerState.wrapT = wrap;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Returns true on successful usage state update (valid enum parameter)
-bool Texture::setUsage(GLenum usage)
</del><ins>+void Texture::setWrapR(GLenum wrap)
</ins><span class="cx"> {
</span><del>-    switch (usage)
-    {
-      case GL_NONE:
-      case GL_FRAMEBUFFER_ATTACHMENT_ANGLE:
-        mUsage = usage;
-        return true;
-      default:
-        return false;
-    }
</del><ins>+    mSamplerState.wrapR = wrap;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Texture::setMaxAnisotropy(float textureMaxAnisotropy, float contextMaxAnisotropy)
+{
+    mSamplerState.maxAnisotropy = std::min(textureMaxAnisotropy, contextMaxAnisotropy);
+}
+
+void Texture::setCompareMode(GLenum mode)
+{
+    mSamplerState.compareMode = mode;
+}
+
+void Texture::setCompareFunc(GLenum func)
+{
+    mSamplerState.compareFunc = func;
+}
+
+void Texture::setSwizzleRed(GLenum swizzle)
+{
+    mSamplerState.swizzleRed = swizzle;
+}
+
+void Texture::setSwizzleGreen(GLenum swizzle)
+{
+    mSamplerState.swizzleGreen = swizzle;
+}
+
+void Texture::setSwizzleBlue(GLenum swizzle)
+{
+    mSamplerState.swizzleBlue = swizzle;
+}
+
+void Texture::setSwizzleAlpha(GLenum swizzle)
+{
+    mSamplerState.swizzleAlpha = swizzle;
+}
+
+void Texture::setBaseLevel(GLint baseLevel)
+{
+    mSamplerState.baseLevel = baseLevel;
+}
+
+void Texture::setMaxLevel(GLint maxLevel)
+{
+    mSamplerState.maxLevel = maxLevel;
+}
+
+void Texture::setMinLod(GLfloat minLod)
+{
+    mSamplerState.minLod = minLod;
+}
+
+void Texture::setMaxLod(GLfloat maxLod)
+{
+    mSamplerState.maxLod = maxLod;
+}
+
+void Texture::setUsage(GLenum usage)
+{
+    mUsage = usage;
+}
+
</ins><span class="cx"> GLenum Texture::getMinFilter() const
</span><span class="cx"> {
</span><span class="cx">     return mSamplerState.minFilter;
</span><span class="lines">@@ -155,21 +202,72 @@
</span><span class="cx">     return mSamplerState.wrapT;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLenum Texture::getWrapR() const
+{
+    return mSamplerState.wrapR;
+}
+
</ins><span class="cx"> float Texture::getMaxAnisotropy() const
</span><span class="cx"> {
</span><span class="cx">     return mSamplerState.maxAnisotropy;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int Texture::getLodOffset()
</del><ins>+GLenum Texture::getSwizzleRed() const
</ins><span class="cx"> {
</span><del>-    rx::TextureStorageInterface *texture = getStorage(false);
-    return texture ? texture-&gt;getLodOffset() : 0;
</del><ins>+    return mSamplerState.swizzleRed;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLenum Texture::getSwizzleGreen() const
+{
+    return mSamplerState.swizzleGreen;
+}
+
+GLenum Texture::getSwizzleBlue() const
+{
+    return mSamplerState.swizzleBlue;
+}
+
+GLenum Texture::getSwizzleAlpha() const
+{
+    return mSamplerState.swizzleAlpha;
+}
+
+GLint Texture::getBaseLevel() const
+{
+    return mSamplerState.baseLevel;
+}
+
+GLint Texture::getMaxLevel() const
+{
+    return mSamplerState.maxLevel;
+}
+
+GLfloat Texture::getMinLod() const
+{
+    return mSamplerState.minLod;
+}
+
+GLfloat Texture::getMaxLod() const
+{
+    return mSamplerState.maxLod;
+}
+
+bool Texture::isSwizzled() const
+{
+    return mSamplerState.swizzleRed   != GL_RED   ||
+           mSamplerState.swizzleGreen != GL_GREEN ||
+           mSamplerState.swizzleBlue  != GL_BLUE  ||
+           mSamplerState.swizzleAlpha != GL_ALPHA;
+}
+
</ins><span class="cx"> void Texture::getSamplerState(SamplerState *sampler)
</span><span class="cx"> {
</span><span class="cx">     *sampler = mSamplerState;
</span><del>-    sampler-&gt;lodOffset = getLodOffset();
</del><ins>+
+    // Offset the effective base level by the texture storage's top level
+    rx::TextureStorageInterface *texture = getNativeTexture();
+    int topLevel = texture ? texture-&gt;getTopLevel() : 0;
+    sampler-&gt;baseLevel = topLevel + mSamplerState.baseLevel;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLenum Texture::getUsage() const
</span><span class="lines">@@ -177,57 +275,121 @@
</span><span class="cx">     return mUsage;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Texture::isMipmapFiltered() const
</del><ins>+GLint Texture::getBaseLevelWidth() const
</ins><span class="cx"> {
</span><del>-    switch (mSamplerState.minFilter)
</del><ins>+    const rx::Image *baseImage = getBaseLevelImage();
+    return (baseImage ? baseImage-&gt;getWidth() : 0);
+}
+
+GLint Texture::getBaseLevelHeight() const
+{
+    const rx::Image *baseImage = getBaseLevelImage();
+    return (baseImage ? baseImage-&gt;getHeight() : 0);
+}
+
+GLint Texture::getBaseLevelDepth() const
+{
+    const rx::Image *baseImage = getBaseLevelImage();
+    return (baseImage ? baseImage-&gt;getDepth() : 0);
+}
+
+// Note: &quot;base level image&quot; is loosely defined to be any image from the base level,
+// where in the base of 2D array textures and cube maps there are several. Don't use
+// the base level image for anything except querying texture format and size.
+GLenum Texture::getBaseLevelInternalFormat() const
+{
+    const rx::Image *baseImage = getBaseLevelImage();
+    return (baseImage ? baseImage-&gt;getInternalFormat() : GL_NONE);
+}
+
+void Texture::setImage(const PixelUnpackState &amp;unpack, GLenum type, const void *pixels, rx::Image *image)
+{
+    // No-op
+    if (image-&gt;getWidth() == 0 || image-&gt;getHeight() == 0 || image-&gt;getDepth() == 0)
</ins><span class="cx">     {
</span><del>-      case GL_NEAREST:
-      case GL_LINEAR:
-        return false;
-      case GL_NEAREST_MIPMAP_NEAREST:
-      case GL_LINEAR_MIPMAP_NEAREST:
-      case GL_NEAREST_MIPMAP_LINEAR:
-      case GL_LINEAR_MIPMAP_LINEAR:
-        return true;
-      default: UNREACHABLE();
-        return false;
</del><ins>+        return;
</ins><span class="cx">     }
</span><ins>+
+    // We no longer need the &quot;GLenum format&quot; parameter to TexImage to determine what data format &quot;pixels&quot; contains.
+    // From our image internal format we know how many channels to expect, and &quot;type&quot; gives the format of pixel's components.
+    const void *pixelData = pixels;
+
+    if (unpack.pixelBuffer.id() != 0)
+    {
+        // Do a CPU readback here, if we have an unpack buffer bound and the fast GPU path is not supported
+        Buffer *pixelBuffer = unpack.pixelBuffer.get();
+        ptrdiff_t offset = reinterpret_cast&lt;ptrdiff_t&gt;(pixels);
+        const void *bufferData = pixelBuffer-&gt;getStorage()-&gt;getData();
+        pixelData = static_cast&lt;const unsigned char *&gt;(bufferData) + offset;
+    }
+
+    if (pixelData != NULL)
+    {
+        image-&gt;loadData(0, 0, 0, image-&gt;getWidth(), image-&gt;getHeight(), image-&gt;getDepth(), unpack.alignment, type, pixelData);
+        mDirtyImages = true;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Texture::setImage(GLint unpackAlignment, const void *pixels, rx::Image *image)
</del><ins>+bool Texture::isFastUnpackable(const PixelUnpackState &amp;unpack, GLenum sizedInternalFormat)
</ins><span class="cx"> {
</span><del>-    if (pixels != NULL)
</del><ins>+    return unpack.pixelBuffer.id() != 0 &amp;&amp; mRenderer-&gt;supportsFastCopyBufferToTexture(sizedInternalFormat);
+}
+
+bool Texture::fastUnpackPixels(const PixelUnpackState &amp;unpack, const void *pixels, const Box &amp;destArea,
+                               GLenum sizedInternalFormat, GLenum type, rx::RenderTarget *destRenderTarget)
+{
+    if (destArea.width &lt;= 0 &amp;&amp; destArea.height &lt;= 0 &amp;&amp; destArea.depth &lt;= 0)
</ins><span class="cx">     {
</span><del>-        image-&gt;loadData(0, 0, image-&gt;getWidth(), image-&gt;getHeight(), unpackAlignment, pixels);
-        mDirtyImages = true;
</del><ins>+        return true;
</ins><span class="cx">     }
</span><ins>+
+    // In order to perform the fast copy through the shader, we must have the right format, and be able
+    // to create a render target.
+    ASSERT(mRenderer-&gt;supportsFastCopyBufferToTexture(sizedInternalFormat));
+
+    unsigned int offset = reinterpret_cast&lt;unsigned int&gt;(pixels);
+
+    return mRenderer-&gt;fastCopyBufferToTexture(unpack, offset, destRenderTarget, sizedInternalFormat, type, destArea);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, rx::Image *image)
</span><span class="cx"> {
</span><span class="cx">     if (pixels != NULL)
</span><span class="cx">     {
</span><del>-        image-&gt;loadCompressedData(0, 0, image-&gt;getWidth(), image-&gt;getHeight(), pixels);
</del><ins>+        image-&gt;loadCompressedData(0, 0, 0, image-&gt;getWidth(), image-&gt;getHeight(), image-&gt;getDepth(), pixels);
</ins><span class="cx">         mDirtyImages = true;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image)
</del><ins>+bool Texture::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                       GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels, rx::Image *image)
</ins><span class="cx"> {
</span><del>-    if (pixels != NULL)
</del><ins>+    const void *pixelData = pixels;
+
+    // CPU readback &amp; copy where direct GPU copy is not supported
+    if (unpack.pixelBuffer.id() != 0)
</ins><span class="cx">     {
</span><del>-        image-&gt;loadData(xoffset, yoffset, width, height, unpackAlignment, pixels);
</del><ins>+        Buffer *pixelBuffer = unpack.pixelBuffer.get();
+        unsigned int offset = reinterpret_cast&lt;unsigned int&gt;(pixels);
+        const void *bufferData = pixelBuffer-&gt;getStorage()-&gt;getData();
+        pixelData = static_cast&lt;const unsigned char *&gt;(bufferData) + offset;
+    }
+
+    if (pixelData != NULL)
+    {
+        image-&gt;loadData(xoffset, yoffset, zoffset, width, height, depth, unpack.alignment, type, pixelData);
</ins><span class="cx">         mDirtyImages = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image)
</del><ins>+bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                                 GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image)
</ins><span class="cx"> {
</span><span class="cx">     if (pixels != NULL)
</span><span class="cx">     {
</span><del>-        image-&gt;loadCompressedData(xoffset, yoffset, width, height, pixels);
</del><ins>+        image-&gt;loadCompressedData(xoffset, yoffset, zoffset, width, height, depth, pixels);
</ins><span class="cx">         mDirtyImages = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -237,11 +399,12 @@
</span><span class="cx"> rx::TextureStorageInterface *Texture::getNativeTexture()
</span><span class="cx"> {
</span><span class="cx">     // ensure the underlying texture is created
</span><ins>+    initializeStorage(false);
</ins><span class="cx"> 
</span><del>-    rx::TextureStorageInterface *storage = getStorage(false);
</del><ins>+    rx::TextureStorageInterface *storage = getBaseLevelStorage();
</ins><span class="cx">     if (storage)
</span><span class="cx">     {
</span><del>-        updateTexture();
</del><ins>+        updateStorage();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return storage;
</span><span class="lines">@@ -259,26 +422,26 @@
</span><span class="cx"> 
</span><span class="cx"> unsigned int Texture::getTextureSerial()
</span><span class="cx"> {
</span><del>-    rx::TextureStorageInterface *texture = getStorage(false);
</del><ins>+    rx::TextureStorageInterface *texture = getNativeTexture();
</ins><span class="cx">     return texture ? texture-&gt;getTextureSerial() : 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned int Texture::getRenderTargetSerial(GLenum target)
</del><ins>+bool Texture::isImmutable() const
</ins><span class="cx"> {
</span><del>-    rx::TextureStorageInterface *texture = getStorage(true);
-    return texture ? texture-&gt;getRenderTargetSerial(target) : 0;
</del><ins>+    return mImmutable;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Texture::isImmutable() const
</del><ins>+int Texture::immutableLevelCount()
</ins><span class="cx"> {
</span><del>-    return mImmutable;
</del><ins>+    return (mImmutable ? getNativeTexture()-&gt;getStorageInstance()-&gt;getLevelCount() : 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLint Texture::creationLevels(GLsizei width, GLsizei height) const
</del><ins>+GLint Texture::creationLevels(GLsizei width, GLsizei height, GLsizei depth) const
</ins><span class="cx"> {
</span><del>-    if ((isPow2(width) &amp;&amp; isPow2(height)) || mRenderer-&gt;getNonPower2TextureSupport())
</del><ins>+    if ((isPow2(width) &amp;&amp; isPow2(height) &amp;&amp; isPow2(depth)) || mRenderer-&gt;getNonPower2TextureSupport())
</ins><span class="cx">     {
</span><del>-        return 0;   // Maximum number of levels
</del><ins>+        // Maximum number of levels
+        return log2(std::max(std::max(width, height), depth)) + 1;
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="lines">@@ -287,17 +450,15 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLint Texture::creationLevels(GLsizei size) const
</del><ins>+int Texture::mipLevels() const
</ins><span class="cx"> {
</span><del>-    return creationLevels(size, size);
</del><ins>+    return log2(std::max(std::max(getBaseLevelWidth(), getBaseLevelHeight()), getBaseLevelDepth())) + 1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-Texture2D::Texture2D(rx::Renderer *renderer, GLuint id) : Texture(renderer, id)
</del><ins>+Texture2D::Texture2D(rx::Renderer *renderer, GLuint id) : Texture(renderer, id, GL_TEXTURE_2D)
</ins><span class="cx"> {
</span><span class="cx">     mTexStorage = NULL;
</span><span class="cx">     mSurface = NULL;
</span><del>-    mColorbufferProxy = NULL;
-    mProxyRefs = 0;
</del><span class="cx"> 
</span><span class="cx">     for (int i = 0; i &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i)
</span><span class="cx">     {
</span><span class="lines">@@ -307,8 +468,6 @@
</span><span class="cx"> 
</span><span class="cx"> Texture2D::~Texture2D()
</span><span class="cx"> {
</span><del>-    mColorbufferProxy = NULL;
-
</del><span class="cx">     delete mTexStorage;
</span><span class="cx">     mTexStorage = NULL;
</span><span class="cx">     
</span><span class="lines">@@ -324,28 +483,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// We need to maintain a count of references to renderbuffers acting as 
-// proxies for this texture, so that we do not attempt to use a pointer 
-// to a renderbuffer proxy which has been deleted.
-void Texture2D::addProxyRef(const Renderbuffer *proxy)
-{
-    mProxyRefs++;
-}
-
-void Texture2D::releaseProxy(const Renderbuffer *proxy)
-{
-    if (mProxyRefs &gt; 0)
-        mProxyRefs--;
-
-    if (mProxyRefs == 0)
-        mColorbufferProxy = NULL;
-}
-
-GLenum Texture2D::getTarget() const
-{
-    return GL_TEXTURE_2D;
-}
-
</del><span class="cx"> GLsizei Texture2D::getWidth(GLint level) const
</span><span class="cx"> {
</span><span class="cx">     if (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS)
</span><span class="lines">@@ -375,24 +512,24 @@
</span><span class="cx">     if (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS)
</span><span class="cx">         return mImageArray[level]-&gt;getActualFormat();
</span><span class="cx">     else
</span><del>-        return D3DFMT_UNKNOWN;
</del><ins>+        return GL_NONE;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Texture2D::redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height)
</del><ins>+void Texture2D::redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height)
</ins><span class="cx"> {
</span><span class="cx">     releaseTexImage();
</span><span class="cx"> 
</span><span class="cx">     // If there currently is a corresponding storage texture image, it has these parameters
</span><del>-    const int storageWidth = std::max(1, mImageArray[0]-&gt;getWidth() &gt;&gt; level);
-    const int storageHeight = std::max(1, mImageArray[0]-&gt;getHeight() &gt;&gt; level);
-    const int storageFormat = mImageArray[0]-&gt;getInternalFormat();
</del><ins>+    const int storageWidth = std::max(1, getBaseLevelWidth() &gt;&gt; level);
+    const int storageHeight = std::max(1, getBaseLevelHeight() &gt;&gt; level);
+    const GLenum storageFormat = getBaseLevelInternalFormat();
</ins><span class="cx"> 
</span><del>-    mImageArray[level]-&gt;redefine(mRenderer, internalformat, width, height, false);
</del><ins>+    mImageArray[level]-&gt;redefine(mRenderer, GL_TEXTURE_2D, internalformat, width, height, 1, false);
</ins><span class="cx"> 
</span><span class="cx">     if (mTexStorage)
</span><span class="cx">     {
</span><del>-        const int storageLevels = mTexStorage-&gt;levelCount();
-        
</del><ins>+        const int storageLevels = mTexStorage-&gt;getLevelCount();
+
</ins><span class="cx">         if ((level &gt;= storageLevels &amp;&amp; storageLevels != 0) ||
</span><span class="cx">             width != storageWidth ||
</span><span class="cx">             height != storageHeight ||
</span><span class="lines">@@ -410,21 +547,44 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    GLint internalformat = ConvertSizedInternalFormat(format, type);
-    redefineImage(level, internalformat, width, height);
</del><ins>+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat
+                                                                                      : GetSizedInternalFormat(format, type, clientVersion);
+    redefineImage(level, sizedInternalFormat, width, height);
</ins><span class="cx"> 
</span><del>-    Texture::setImage(unpackAlignment, pixels, mImageArray[level]);
</del><ins>+    bool fastUnpacked = false;
+
+    // Attempt a fast gpu copy of the pixel data to the surface
+    if (isFastUnpackable(unpack, sizedInternalFormat) &amp;&amp; isLevelComplete(level))
+    {
+        // Will try to create RT storage if it does not exist
+        rx::RenderTarget *destRenderTarget = getRenderTarget(level);
+        Box destArea(0, 0, 0, getWidth(level), getHeight(level), 1);
+
+        if (destRenderTarget &amp;&amp; fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, destRenderTarget))
+        {
+            // Ensure we don't overwrite our newly initialized data
+            mImageArray[level]-&gt;markClean();
+
+            fastUnpacked = true;
+        }
+    }
+
+    if (!fastUnpacked)
+    {
+        Texture::setImage(unpack, type, pixels, mImageArray[level]);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Texture2D::bindTexImage(egl::Surface *surface)
</span><span class="cx"> {
</span><span class="cx">     releaseTexImage();
</span><span class="cx"> 
</span><del>-    GLint internalformat = surface-&gt;getFormat();
</del><ins>+    GLenum internalformat = surface-&gt;getFormat();
</ins><span class="cx"> 
</span><del>-    mImageArray[0]-&gt;redefine(mRenderer, internalformat, surface-&gt;getWidth(), surface-&gt;getHeight(), true);
</del><ins>+    mImageArray[0]-&gt;redefine(mRenderer, GL_TEXTURE_2D, internalformat, surface-&gt;getWidth(), surface-&gt;getHeight(), 1, true);
</ins><span class="cx"> 
</span><span class="cx">     delete mTexStorage;
</span><span class="cx">     mTexStorage = new rx::TextureStorageInterface2D(mRenderer, surface-&gt;getSwapChain());
</span><span class="lines">@@ -449,7 +609,7 @@
</span><span class="cx"> 
</span><span class="cx">         for (int i = 0; i &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
</span><span class="cx">         {
</span><del>-            mImageArray[i]-&gt;redefine(mRenderer, GL_NONE, 0, 0, true);
</del><ins>+            mImageArray[i]-&gt;redefine(mRenderer, GL_TEXTURE_2D, GL_NONE, 0, 0, 0, true);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -464,27 +624,43 @@
</span><span class="cx"> 
</span><span class="cx"> void Texture2D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</span><span class="cx"> {
</span><del>-    if (level &lt; levelCount())
</del><ins>+    if (isValidLevel(level))
</ins><span class="cx">     {
</span><span class="cx">         rx::Image *image = mImageArray[level];
</span><del>-        if (image-&gt;updateSurface(mTexStorage, level, xoffset, yoffset, width, height))
</del><ins>+        if (image-&gt;copyToStorage(mTexStorage, level, xoffset, yoffset, width, height))
</ins><span class="cx">         {
</span><span class="cx">             image-&gt;markClean();
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    if (Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, mImageArray[level]))
</del><ins>+    bool fastUnpacked = false;
+
+    if (isFastUnpackable(unpack, getInternalFormat(level)) &amp;&amp; isLevelComplete(level))
</ins><span class="cx">     {
</span><ins>+        rx::RenderTarget *renderTarget = getRenderTarget(level);
+        Box destArea(xoffset, yoffset, 0, width, height, 1);
+
+        if (renderTarget &amp;&amp; fastUnpackPixels(unpack, pixels, destArea, getInternalFormat(level), type, renderTarget))
+        {
+            // Ensure we don't overwrite our newly initialized data
+            mImageArray[level]-&gt;markClean();
+
+            fastUnpacked = true;
+        }
+    }
+
+    if (!fastUnpacked &amp;&amp; Texture::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels, mImageArray[level]))
+    {
</ins><span class="cx">         commitRect(level, xoffset, yoffset, width, height);
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
</span><span class="cx"> {
</span><del>-    if (Texture::subImageCompressed(xoffset, yoffset, width, height, format, imageSize, pixels, mImageArray[level]))
</del><ins>+    if (Texture::subImageCompressed(xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels, mImageArray[level]))
</ins><span class="cx">     {
</span><span class="cx">         commitRect(level, xoffset, yoffset, width, height);
</span><span class="cx">     }
</span><span class="lines">@@ -492,24 +668,22 @@
</span><span class="cx"> 
</span><span class="cx"> void Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
</span><span class="cx"> {
</span><del>-    GLint internalformat = ConvertSizedInternalFormat(format, GL_UNSIGNED_BYTE);
-    redefineImage(level, internalformat, width, height);
</del><ins>+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLenum sizedInternalFormat = IsSizedInternalFormat(format, clientVersion) ? format
+                                                                              : GetSizedInternalFormat(format, GL_UNSIGNED_BYTE, clientVersion);
+    redefineImage(level, sizedInternalFormat, width, height);
</ins><span class="cx"> 
</span><span class="cx">     if (!mImageArray[level]-&gt;isRenderableFormat())
</span><span class="cx">     {
</span><del>-        mImageArray[level]-&gt;copy(0, 0, x, y, width, height, source);
</del><ins>+        mImageArray[level]-&gt;copy(0, 0, 0, x, y, width, height, source);
</ins><span class="cx">         mDirtyImages = true;
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        if (!mTexStorage || !mTexStorage-&gt;isRenderTarget())
-        {
-            convertToRenderTarget();
-        }
-        
</del><ins>+        ensureRenderTarget();
</ins><span class="cx">         mImageArray[level]-&gt;markClean();
</span><span class="cx"> 
</span><del>-        if (width != 0 &amp;&amp; height != 0 &amp;&amp; level &lt; levelCount())
</del><ins>+        if (width != 0 &amp;&amp; height != 0 &amp;&amp; isValidLevel(level))
</ins><span class="cx">         {
</span><span class="cx">             gl::Rectangle sourceRect;
</span><span class="cx">             sourceRect.x = x;
</span><span class="lines">@@ -522,37 +696,40 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
</del><ins>+void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
</ins><span class="cx"> {
</span><del>-    if (xoffset + width &gt; mImageArray[level]-&gt;getWidth() || yoffset + height &gt; mImageArray[level]-&gt;getHeight())
</del><ins>+    if (xoffset + width &gt; mImageArray[level]-&gt;getWidth() || yoffset + height &gt; mImageArray[level]-&gt;getHeight() || zoffset != 0)
</ins><span class="cx">     {
</span><span class="cx">         return gl::error(GL_INVALID_VALUE);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!mImageArray[level]-&gt;isRenderableFormat() || (!mTexStorage &amp;&amp; !isSamplerComplete()))
</del><ins>+    // can only make our texture storage to a render target if level 0 is defined (with a width &amp; height) and
+    // the current level we're copying to is defined (with appropriate format, width &amp; height)
+    bool canCreateRenderTarget = isLevelComplete(level) &amp;&amp; isLevelComplete(0);
+
+    if (!mImageArray[level]-&gt;isRenderableFormat() || (!mTexStorage &amp;&amp; !canCreateRenderTarget))
</ins><span class="cx">     {
</span><del>-        mImageArray[level]-&gt;copy(xoffset, yoffset, x, y, width, height, source);
</del><ins>+        mImageArray[level]-&gt;copy(xoffset, yoffset, 0, x, y, width, height, source);
</ins><span class="cx">         mDirtyImages = true;
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        if (!mTexStorage || !mTexStorage-&gt;isRenderTarget())
</del><ins>+        ensureRenderTarget();
+        
+        if (isValidLevel(level))
</ins><span class="cx">         {
</span><del>-            convertToRenderTarget();
-        }
-        
-        updateTexture();
</del><ins>+            updateStorageLevel(level);
</ins><span class="cx"> 
</span><del>-        if (level &lt; levelCount())
-        {
</del><ins>+            GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+
</ins><span class="cx">             gl::Rectangle sourceRect;
</span><span class="cx">             sourceRect.x = x;
</span><span class="cx">             sourceRect.width = width;
</span><span class="cx">             sourceRect.y = y;
</span><span class="cx">             sourceRect.height = height;
</span><span class="cx"> 
</span><del>-            mRenderer-&gt;copyImage(source, sourceRect, 
-                                 gl::ExtractFormat(mImageArray[0]-&gt;getInternalFormat()),
</del><ins>+            mRenderer-&gt;copyImage(source, sourceRect,
+                                 gl::GetFormat(getBaseLevelInternalFormat(), clientVersion),
</ins><span class="cx">                                  xoffset, yoffset, mTexStorage, level);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -560,52 +737,54 @@
</span><span class="cx"> 
</span><span class="cx"> void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
</span><span class="cx"> {
</span><del>-    delete mTexStorage;
-    mTexStorage = new rx::TextureStorageInterface2D(mRenderer, levels, internalformat, mUsage, false, width, height);
-    mImmutable = true;
-
</del><span class="cx">     for (int level = 0; level &lt; levels; level++)
</span><span class="cx">     {
</span><del>-        mImageArray[level]-&gt;redefine(mRenderer, internalformat, width, height, true);
-        width = std::max(1, width &gt;&gt; 1);
-        height = std::max(1, height &gt;&gt; 1);
</del><ins>+        GLsizei levelWidth = std::max(1, width &gt;&gt; level);
+        GLsizei levelHeight = std::max(1, height &gt;&gt; level);
+        mImageArray[level]-&gt;redefine(mRenderer, GL_TEXTURE_2D, internalformat, levelWidth, levelHeight, 1, true);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (int level = levels; level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
</span><span class="cx">     {
</span><del>-        mImageArray[level]-&gt;redefine(mRenderer, GL_NONE, 0, 0, true);
</del><ins>+        mImageArray[level]-&gt;redefine(mRenderer, GL_TEXTURE_2D, GL_NONE, 0, 0, 0, true);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mTexStorage-&gt;isManaged())
</del><ins>+    mImmutable = true;
+
+    setCompleteTexStorage(new rx::TextureStorageInterface2D(mRenderer, internalformat, IsRenderTargetUsage(mUsage), width, height, levels));
+}
+
+void Texture2D::setCompleteTexStorage(rx::TextureStorageInterface2D *newCompleteTexStorage)
+{
+    SafeDelete(mTexStorage);
+    mTexStorage = newCompleteTexStorage;
+
+    if (mTexStorage &amp;&amp; mTexStorage-&gt;isManaged())
</ins><span class="cx">     {
</span><del>-        int levels = levelCount();
-
-        for (int level = 0; level &lt; levels; level++)
</del><ins>+        for (int level = 0; level &lt; mTexStorage-&gt;getLevelCount(); level++)
</ins><span class="cx">         {
</span><span class="cx">             mImageArray[level]-&gt;setManagedSurface(mTexStorage, level);
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+
+    mDirtyImages = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85.
</span><del>-bool Texture2D::isSamplerComplete() const
</del><ins>+bool Texture2D::isSamplerComplete(const SamplerState &amp;samplerState) const
</ins><span class="cx"> {
</span><del>-    GLsizei width = mImageArray[0]-&gt;getWidth();
-    GLsizei height = mImageArray[0]-&gt;getHeight();
</del><ins>+    GLsizei width = getBaseLevelWidth();
+    GLsizei height = getBaseLevelHeight();
</ins><span class="cx"> 
</span><span class="cx">     if (width &lt;= 0 || height &lt;= 0)
</span><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool mipmapping = isMipmapFiltered();
-    bool filtering, renderable;
-
-    if ((IsFloat32Format(getInternalFormat(0)) &amp;&amp; !mRenderer-&gt;getFloat32TextureSupport(&amp;filtering, &amp;renderable)) ||
-        (IsFloat16Format(getInternalFormat(0)) &amp;&amp; !mRenderer-&gt;getFloat16TextureSupport(&amp;filtering, &amp;renderable)))
</del><ins>+    if (!IsTextureFilteringSupported(getInternalFormat(0), mRenderer))
</ins><span class="cx">     {
</span><del>-        if (mSamplerState.magFilter != GL_NEAREST ||
-            (mSamplerState.minFilter != GL_NEAREST &amp;&amp; mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
</del><ins>+        if (samplerState.magFilter != GL_NEAREST ||
+            (samplerState.minFilter != GL_NEAREST &amp;&amp; samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
</ins><span class="cx">         {
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="lines">@@ -615,14 +794,14 @@
</span><span class="cx"> 
</span><span class="cx">     if (!npotSupport)
</span><span class="cx">     {
</span><del>-        if ((mSamplerState.wrapS != GL_CLAMP_TO_EDGE &amp;&amp; !isPow2(width)) ||
-            (mSamplerState.wrapT != GL_CLAMP_TO_EDGE &amp;&amp; !isPow2(height)))
</del><ins>+        if ((samplerState.wrapS != GL_CLAMP_TO_EDGE &amp;&amp; !isPow2(width)) ||
+            (samplerState.wrapT != GL_CLAMP_TO_EDGE &amp;&amp; !isPow2(height)))
</ins><span class="cx">         {
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mipmapping)
</del><ins>+    if (IsMipmapFiltered(samplerState))
</ins><span class="cx">     {
</span><span class="cx">         if (!npotSupport)
</span><span class="cx">         {
</span><span class="lines">@@ -638,43 +817,82 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // OpenGLES 3.0.2 spec section 3.8.13 states that a texture is not mipmap complete if:
+    // The internalformat specified for the texture arrays is a sized internal depth or
+    // depth and stencil format (see table 3.13), the value of TEXTURE_COMPARE_-
+    // MODE is NONE, and either the magnification filter is not NEAREST or the mini-
+    // fication filter is neither NEAREST nor NEAREST_MIPMAP_NEAREST.
+    if (gl::GetDepthBits(getInternalFormat(0), mRenderer-&gt;getCurrentClientVersion()) &gt; 0 &amp;&amp;
+        mRenderer-&gt;getCurrentClientVersion() &gt; 2)
+    {
+        if (mSamplerState.compareMode == GL_NONE)
+        {
+            if ((mSamplerState.minFilter != GL_NEAREST &amp;&amp; mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST) ||
+                mSamplerState.magFilter != GL_NEAREST)
+            {
+                return false;
+            }
+        }
+    }
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Tests for 2D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
</span><span class="cx"> bool Texture2D::isMipmapComplete() const
</span><span class="cx"> {
</span><ins>+    int levelCount = mipLevels();
+
+    for (int level = 0; level &lt; levelCount; level++)
+    {
+        if (!isLevelComplete(level))
+        {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool Texture2D::isLevelComplete(int level) const
+{
</ins><span class="cx">     if (isImmutable())
</span><span class="cx">     {
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    GLsizei width = mImageArray[0]-&gt;getWidth();
-    GLsizei height = mImageArray[0]-&gt;getHeight();
</del><ins>+    const rx::Image *baseImage = getBaseLevelImage();
</ins><span class="cx"> 
</span><ins>+    GLsizei width = baseImage-&gt;getWidth();
+    GLsizei height = baseImage-&gt;getHeight();
+
</ins><span class="cx">     if (width &lt;= 0 || height &lt;= 0)
</span><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    int q = log2(std::max(width, height));
</del><ins>+    // The base image level is complete if the width and height are positive
+    if (level == 0)
+    {
+        return true;
+    }
</ins><span class="cx"> 
</span><del>-    for (int level = 1; level &lt;= q; level++)
</del><ins>+    ASSERT(level &gt;= 1 &amp;&amp; level &lt;= (int)ArraySize(mImageArray) &amp;&amp; mImageArray[level] != NULL);
+    rx::Image *image = mImageArray[level];
+
+    if (image-&gt;getInternalFormat() != baseImage-&gt;getInternalFormat())
</ins><span class="cx">     {
</span><del>-        if (mImageArray[level]-&gt;getInternalFormat() != mImageArray[0]-&gt;getInternalFormat())
-        {
-            return false;
-        }
</del><ins>+        return false;
+    }
</ins><span class="cx"> 
</span><del>-        if (mImageArray[level]-&gt;getWidth() != std::max(1, width &gt;&gt; level))
-        {
-            return false;
-        }
</del><ins>+    if (image-&gt;getWidth() != std::max(1, width &gt;&gt; level))
+    {
+        return false;
+    }
</ins><span class="cx"> 
</span><del>-        if (mImageArray[level]-&gt;getHeight() != std::max(1, height &gt;&gt; level))
-        {
-            return false;
-        }
</del><ins>+    if (image-&gt;getHeight() != std::max(1, height &gt;&gt; level))
+    {
+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="lines">@@ -682,211 +900,201 @@
</span><span class="cx"> 
</span><span class="cx"> bool Texture2D::isCompressed(GLint level) const
</span><span class="cx"> {
</span><del>-    return IsCompressed(getInternalFormat(level));
</del><ins>+    return IsFormatCompressed(getInternalFormat(level), mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Texture2D::isDepth(GLint level) const
</span><span class="cx"> {
</span><del>-    return IsDepthTexture(getInternalFormat(level));
</del><ins>+    return GetDepthBits(getInternalFormat(level), mRenderer-&gt;getCurrentClientVersion()) &gt; 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Constructs a native texture resource from the texture images
</span><del>-void Texture2D::createTexture()
</del><ins>+void Texture2D::initializeStorage(bool renderTarget)
</ins><span class="cx"> {
</span><del>-    GLsizei width = mImageArray[0]-&gt;getWidth();
-    GLsizei height = mImageArray[0]-&gt;getHeight();
</del><ins>+    // Only initialize the first time this texture is used as a render target or shader resource
+    if (mTexStorage)
+    {
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    if (!(width &gt; 0 &amp;&amp; height &gt; 0))
-        return; // do not attempt to create native textures for nonexistant data
</del><ins>+    // do not attempt to create storage for nonexistant data
+    if (!isLevelComplete(0))
+    {
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    GLint levels = creationLevels(width, height);
-    GLenum internalformat = mImageArray[0]-&gt;getInternalFormat();
</del><ins>+    bool createRenderTarget = (renderTarget || IsRenderTargetUsage(mUsage));
</ins><span class="cx"> 
</span><del>-    delete mTexStorage;
-    mTexStorage = new rx::TextureStorageInterface2D(mRenderer, levels, internalformat, mUsage, false, width, height);
-    
-    if (mTexStorage-&gt;isManaged())
-    {
-        int levels = levelCount();
</del><ins>+    setCompleteTexStorage(createCompleteStorage(createRenderTarget));
+    ASSERT(mTexStorage);
</ins><span class="cx"> 
</span><del>-        for (int level = 0; level &lt; levels; level++)
-        {
-            mImageArray[level]-&gt;setManagedSurface(mTexStorage, level);
-        }
-    }
-
-    mDirtyImages = true;
</del><ins>+    // flush image data to the storage
+    updateStorage();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Texture2D::updateTexture()
</del><ins>+rx::TextureStorageInterface2D *Texture2D::createCompleteStorage(bool renderTarget) const
</ins><span class="cx"> {
</span><del>-    bool mipmapping = (isMipmapFiltered() &amp;&amp; isMipmapComplete());
</del><ins>+    GLsizei width = getBaseLevelWidth();
+    GLsizei height = getBaseLevelHeight();
</ins><span class="cx"> 
</span><del>-    int levels = (mipmapping ? levelCount() : 1);
</del><ins>+    ASSERT(width &gt; 0 &amp;&amp; height &gt; 0);
</ins><span class="cx"> 
</span><del>-    for (int level = 0; level &lt; levels; level++)
</del><ins>+    // use existing storage level count, when previously specified by TexStorage*D
+    GLint levels = (mTexStorage ? mTexStorage-&gt;getLevelCount() : creationLevels(width, height, 1));
+
+    return new rx::TextureStorageInterface2D(mRenderer, getBaseLevelInternalFormat(), renderTarget, width, height, levels);
+}
+
+void Texture2D::updateStorage()
+{
+    for (int level = 0; level &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
</ins><span class="cx">     {
</span><del>-        rx::Image *image = mImageArray[level];
-
-        if (image-&gt;isDirty())
</del><ins>+        if (mImageArray[level]-&gt;isDirty() &amp;&amp; isLevelComplete(level))
</ins><span class="cx">         {
</span><del>-            commitRect(level, 0, 0, mImageArray[level]-&gt;getWidth(), mImageArray[level]-&gt;getHeight());
</del><ins>+            updateStorageLevel(level);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Texture2D::convertToRenderTarget()
</del><ins>+void Texture2D::updateStorageLevel(int level)
</ins><span class="cx"> {
</span><del>-    rx::TextureStorageInterface2D *newTexStorage = NULL;
</del><ins>+    ASSERT(level &lt;= (int)ArraySize(mImageArray) &amp;&amp; mImageArray[level] != NULL);
+    ASSERT(isLevelComplete(level));
</ins><span class="cx"> 
</span><del>-    if (mImageArray[0]-&gt;getWidth() != 0 &amp;&amp; mImageArray[0]-&gt;getHeight() != 0)
</del><ins>+    if (mImageArray[level]-&gt;isDirty())
</ins><span class="cx">     {
</span><del>-        GLsizei width = mImageArray[0]-&gt;getWidth();
-        GLsizei height = mImageArray[0]-&gt;getHeight();
-        GLint levels = mTexStorage != NULL ? mTexStorage-&gt;levelCount() : creationLevels(width, height);
-        GLenum internalformat = mImageArray[0]-&gt;getInternalFormat();
</del><ins>+        commitRect(level, 0, 0, getWidth(level), getHeight(level));
+    }
+}
</ins><span class="cx"> 
</span><del>-        newTexStorage = new rx::TextureStorageInterface2D(mRenderer, levels, internalformat, GL_FRAMEBUFFER_ATTACHMENT_ANGLE, true, width, height);
</del><ins>+bool Texture2D::ensureRenderTarget()
+{
+    initializeStorage(true);
</ins><span class="cx"> 
</span><del>-        if (mTexStorage != NULL)
</del><ins>+    if (getBaseLevelWidth() &gt; 0 &amp;&amp; getBaseLevelHeight() &gt; 0)
+    {
+        ASSERT(mTexStorage);
+        if (!mTexStorage-&gt;isRenderTarget())
</ins><span class="cx">         {
</span><del>-            if (!mRenderer-&gt;copyToRenderTarget(newTexStorage, mTexStorage))
-            {   
-                delete newTexStorage;
-                return gl::error(GL_OUT_OF_MEMORY);
</del><ins>+            rx::TextureStorageInterface2D *newRenderTargetStorage = createCompleteStorage(true);
+
+            if (!mRenderer-&gt;copyToRenderTarget(newRenderTargetStorage, mTexStorage))
+            {
+                delete newRenderTargetStorage;
+                return gl::error(GL_OUT_OF_MEMORY, false);
</ins><span class="cx">             }
</span><ins>+
+            setCompleteTexStorage(newRenderTargetStorage);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    delete mTexStorage;
-    mTexStorage = newTexStorage;
-
-    mDirtyImages = true;
</del><ins>+    return (mTexStorage &amp;&amp; mTexStorage-&gt;isRenderTarget());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Texture2D::generateMipmaps()
</span><span class="cx"> {
</span><del>-    if (!mRenderer-&gt;getNonPower2TextureSupport())
-    {
-        if (!isPow2(mImageArray[0]-&gt;getWidth()) || !isPow2(mImageArray[0]-&gt;getHeight()))
-        {
-            return gl::error(GL_INVALID_OPERATION);
-        }
-    }
-
</del><span class="cx">     // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
</span><del>-    unsigned int q = log2(std::max(mImageArray[0]-&gt;getWidth(), mImageArray[0]-&gt;getHeight()));
-    for (unsigned int i = 1; i &lt;= q; i++)
</del><ins>+    int levelCount = mipLevels();
+    for (int level = 1; level &lt; levelCount; level++)
</ins><span class="cx">     {
</span><del>-        redefineImage(i, mImageArray[0]-&gt;getInternalFormat(),
-                      std::max(mImageArray[0]-&gt;getWidth() &gt;&gt; i, 1),
-                      std::max(mImageArray[0]-&gt;getHeight() &gt;&gt; i, 1));
</del><ins>+        redefineImage(level, getBaseLevelInternalFormat(),
+                      std::max(getBaseLevelWidth() &gt;&gt; level, 1),
+                      std::max(getBaseLevelHeight() &gt;&gt; level, 1));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (mTexStorage &amp;&amp; mTexStorage-&gt;isRenderTarget())
</span><span class="cx">     {
</span><del>-        for (unsigned int i = 1; i &lt;= q; i++)
</del><ins>+        for (int level = 1; level &lt; levelCount; level++)
</ins><span class="cx">         {
</span><del>-            mTexStorage-&gt;generateMipmap(i);
</del><ins>+            mTexStorage-&gt;generateMipmap(level);
</ins><span class="cx"> 
</span><del>-            mImageArray[i]-&gt;markClean();
</del><ins>+            mImageArray[level]-&gt;markClean();
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        for (unsigned int i = 1; i &lt;= q; i++)
</del><ins>+        for (int level = 1; level &lt; levelCount; level++)
</ins><span class="cx">         {
</span><del>-            mRenderer-&gt;generateMipmap(mImageArray[i], mImageArray[i - 1]);
</del><ins>+            mRenderer-&gt;generateMipmap(mImageArray[level], mImageArray[level - 1]);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Renderbuffer *Texture2D::getRenderbuffer(GLenum target)
</del><ins>+const rx::Image *Texture2D::getBaseLevelImage() const
</ins><span class="cx"> {
</span><del>-    if (target != GL_TEXTURE_2D)
-    {
-        return gl::error(GL_INVALID_OPERATION, (Renderbuffer *)NULL);
-    }
</del><ins>+    return mImageArray[0];
+}
</ins><span class="cx"> 
</span><del>-    if (mColorbufferProxy == NULL)
</del><ins>+rx::TextureStorageInterface *Texture2D::getBaseLevelStorage()
+{
+    return mTexStorage;
+}
+
+Renderbuffer *Texture2D::getRenderbuffer(GLint level)
+{
+    Renderbuffer *renderBuffer = mRenderbufferProxies.get(level, 0);
+    if (!renderBuffer)
</ins><span class="cx">     {
</span><del>-        mColorbufferProxy = new Renderbuffer(mRenderer, id(), new RenderbufferTexture2D(this, target));
</del><ins>+        renderBuffer = new Renderbuffer(mRenderer, id(), new RenderbufferTexture2D(this, level));
+        mRenderbufferProxies.add(level, 0, renderBuffer);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return mColorbufferProxy;
</del><ins>+    return renderBuffer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-rx::RenderTarget *Texture2D::getRenderTarget(GLenum target)
</del><ins>+unsigned int Texture2D::getRenderTargetSerial(GLint level)
</ins><span class="cx"> {
</span><del>-    ASSERT(target == GL_TEXTURE_2D);
</del><ins>+    return (ensureRenderTarget() ? mTexStorage-&gt;getRenderTargetSerial(level) : 0);
+}
</ins><span class="cx"> 
</span><ins>+rx::RenderTarget *Texture2D::getRenderTarget(GLint level)
+{
</ins><span class="cx">     // ensure the underlying texture is created
</span><del>-    if (getStorage(true) == NULL)
</del><ins>+    if (!ensureRenderTarget())
</ins><span class="cx">     {
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    updateTexture();
-    
</del><ins>+    updateStorageLevel(level);
+
</ins><span class="cx">     // ensure this is NOT a depth texture
</span><del>-    if (isDepth(0))
</del><ins>+    if (isDepth(level))
</ins><span class="cx">     {
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return mTexStorage-&gt;getRenderTarget();
</del><ins>+    return mTexStorage-&gt;getRenderTarget(level);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-rx::RenderTarget *Texture2D::getDepthStencil(GLenum target)
</del><ins>+rx::RenderTarget *Texture2D::getDepthSencil(GLint level)
</ins><span class="cx"> {
</span><del>-    ASSERT(target == GL_TEXTURE_2D);
-
</del><span class="cx">     // ensure the underlying texture is created
</span><del>-    if (getStorage(true) == NULL)
</del><ins>+    if (!ensureRenderTarget())
</ins><span class="cx">     {
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    updateTexture();
</del><ins>+    updateStorageLevel(level);
</ins><span class="cx"> 
</span><span class="cx">     // ensure this is actually a depth texture
</span><del>-    if (!isDepth(0))
</del><ins>+    if (!isDepth(level))
</ins><span class="cx">     {
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><del>-    return mTexStorage-&gt;getRenderTarget();
-}
</del><span class="cx"> 
</span><del>-int Texture2D::levelCount()
-{
-    return mTexStorage ? mTexStorage-&gt;levelCount() : 0;
</del><ins>+    return mTexStorage-&gt;getRenderTarget(level);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-rx::TextureStorageInterface *Texture2D::getStorage(bool renderTarget)
</del><ins>+bool Texture2D::isValidLevel(int level) const
</ins><span class="cx"> {
</span><del>-    if (!mTexStorage || (renderTarget &amp;&amp; !mTexStorage-&gt;isRenderTarget()))
-    {
-        if (renderTarget)
-        {
-            convertToRenderTarget();
-        }
-        else
-        {
-            createTexture();
-        }
-    }
-
-    return mTexStorage;
</del><ins>+    return (mTexStorage ? (level &gt;= 0 &amp;&amp; level &lt; mTexStorage-&gt;getLevelCount()) : false);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureCubeMap::TextureCubeMap(rx::Renderer *renderer, GLuint id) : Texture(renderer, id)
</del><ins>+TextureCubeMap::TextureCubeMap(rx::Renderer *renderer, GLuint id) : Texture(renderer, id, GL_TEXTURE_CUBE_MAP)
</ins><span class="cx"> {
</span><span class="cx">     mTexStorage = NULL;
</span><span class="cx">     for (int i = 0; i &lt; 6; i++)
</span><span class="cx">     {
</span><del>-        mFaceProxies[i] = NULL;
-        mFaceProxyRefs[i] = 0;
-
</del><span class="cx">         for (int j = 0; j &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++j)
</span><span class="cx">         {
</span><span class="cx">             mImageArray[i][j] = renderer-&gt;createImage();
</span><span class="lines">@@ -898,8 +1106,6 @@
</span><span class="cx"> {
</span><span class="cx">     for (int i = 0; i &lt; 6; i++)
</span><span class="cx">     {
</span><del>-        mFaceProxies[i] = NULL;
-
</del><span class="cx">         for (int j = 0; j &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++j)
</span><span class="cx">         {
</span><span class="cx">             delete mImageArray[i][j];
</span><span class="lines">@@ -910,44 +1116,10 @@
</span><span class="cx">     mTexStorage = NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// We need to maintain a count of references to renderbuffers acting as 
-// proxies for this texture, so that the texture is not deleted while 
-// proxy references still exist. If the reference count drops to zero,
-// we set our proxy pointer NULL, so that a new attempt at referencing
-// will cause recreation.
-void TextureCubeMap::addProxyRef(const Renderbuffer *proxy)
-{
-    for (int i = 0; i &lt; 6; i++)
-    {
-        if (mFaceProxies[i] == proxy)
-            mFaceProxyRefs[i]++;
-    }
-}
-
-void TextureCubeMap::releaseProxy(const Renderbuffer *proxy)
-{
-    for (int i = 0; i &lt; 6; i++)
-    {
-        if (mFaceProxies[i] == proxy)
-        {
-            if (mFaceProxyRefs[i] &gt; 0)
-                mFaceProxyRefs[i]--;
-
-            if (mFaceProxyRefs[i] == 0)
-                mFaceProxies[i] = NULL;
-        }
-    }
-}
-
-GLenum TextureCubeMap::getTarget() const
-{
-    return GL_TEXTURE_CUBE_MAP;
-}
-
</del><span class="cx"> GLsizei TextureCubeMap::getWidth(GLenum target, GLint level) const
</span><span class="cx"> {
</span><span class="cx">     if (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS)
</span><del>-        return mImageArray[faceIndex(target)][level]-&gt;getWidth();
</del><ins>+        return mImageArray[targetToIndex(target)][level]-&gt;getWidth();
</ins><span class="cx">     else
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -955,7 +1127,7 @@
</span><span class="cx"> GLsizei TextureCubeMap::getHeight(GLenum target, GLint level) const
</span><span class="cx"> {
</span><span class="cx">     if (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS)
</span><del>-        return mImageArray[faceIndex(target)][level]-&gt;getHeight();
</del><ins>+        return mImageArray[targetToIndex(target)][level]-&gt;getHeight();
</ins><span class="cx">     else
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -963,7 +1135,7 @@
</span><span class="cx"> GLenum TextureCubeMap::getInternalFormat(GLenum target, GLint level) const
</span><span class="cx"> {
</span><span class="cx">     if (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS)
</span><del>-        return mImageArray[faceIndex(target)][level]-&gt;getInternalFormat();
</del><ins>+        return mImageArray[targetToIndex(target)][level]-&gt;getInternalFormat();
</ins><span class="cx">     else
</span><span class="cx">         return GL_NONE;
</span><span class="cx"> }
</span><span class="lines">@@ -971,88 +1143,89 @@
</span><span class="cx"> GLenum TextureCubeMap::getActualFormat(GLenum target, GLint level) const
</span><span class="cx"> {
</span><span class="cx">     if (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS)
</span><del>-        return mImageArray[faceIndex(target)][level]-&gt;getActualFormat();
</del><ins>+        return mImageArray[targetToIndex(target)][level]-&gt;getActualFormat();
</ins><span class="cx">     else
</span><del>-        return D3DFMT_UNKNOWN;
</del><ins>+        return GL_NONE;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void TextureCubeMap::setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    setImage(0, level, width, height, format, type, unpackAlignment, pixels);
</del><ins>+    setImage(0, level, width, height, internalFormat, format, type, unpack, pixels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void TextureCubeMap::setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    setImage(1, level, width, height, format, type, unpackAlignment, pixels);
</del><ins>+    setImage(1, level, width, height, internalFormat, format, type, unpack, pixels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void TextureCubeMap::setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    setImage(2, level, width, height, format, type, unpackAlignment, pixels);
</del><ins>+    setImage(2, level, width, height, internalFormat, format, type, unpack, pixels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void TextureCubeMap::setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    setImage(3, level, width, height, format, type, unpackAlignment, pixels);
</del><ins>+    setImage(3, level, width, height, internalFormat, format, type, unpack, pixels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void TextureCubeMap::setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    setImage(4, level, width, height, format, type, unpackAlignment, pixels);
</del><ins>+    setImage(4, level, width, height, internalFormat, format, type, unpack, pixels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void TextureCubeMap::setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    setImage(5, level, width, height, format, type, unpackAlignment, pixels);
</del><ins>+    setImage(5, level, width, height, internalFormat, format, type, unpack, pixels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
</del><ins>+void TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
</ins><span class="cx"> {
</span><span class="cx">     // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
</span><del>-    redefineImage(faceIndex(face), level, format, width, height);
</del><ins>+    int faceIndex = targetToIndex(target);
+    redefineImage(faceIndex, level, format, width, height);
</ins><span class="cx"> 
</span><del>-    Texture::setCompressedImage(imageSize, pixels, mImageArray[faceIndex(face)][level]);
</del><ins>+    Texture::setCompressedImage(imageSize, pixels, mImageArray[faceIndex][level]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::commitRect(int face, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</del><ins>+void TextureCubeMap::commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</ins><span class="cx"> {
</span><del>-    if (level &lt; levelCount())
</del><ins>+    if (isValidFaceLevel(faceIndex, level))
</ins><span class="cx">     {
</span><del>-        rx::Image *image = mImageArray[face][level];
-        if (image-&gt;updateSurface(mTexStorage, face, level, xoffset, yoffset, width, height))
</del><ins>+        rx::Image *image = mImageArray[faceIndex][level];
+        if (image-&gt;copyToStorage(mTexStorage, faceIndex, level, xoffset, yoffset, width, height))
</ins><span class="cx">             image-&gt;markClean();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    if (Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, mImageArray[faceIndex(target)][level]))
</del><ins>+    int faceIndex = targetToIndex(target);
+    if (Texture::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels, mImageArray[faceIndex][level]))
</ins><span class="cx">     {
</span><del>-        commitRect(faceIndex(target), level, xoffset, yoffset, width, height);
</del><ins>+        commitRect(faceIndex, level, xoffset, yoffset, width, height);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
</span><span class="cx"> {
</span><del>-    if (Texture::subImageCompressed(xoffset, yoffset, width, height, format, imageSize, pixels, mImageArray[faceIndex(target)][level]))
</del><ins>+    int faceIndex = targetToIndex(target);
+    if (Texture::subImageCompressed(xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels, mImageArray[faceIndex][level]))
</ins><span class="cx">     {
</span><del>-        commitRect(faceIndex(target), level, xoffset, yoffset, width, height);
</del><ins>+        commitRect(faceIndex, level, xoffset, yoffset, width, height);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Tests for cube map sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 86.
</span><del>-bool TextureCubeMap::isSamplerComplete() const
</del><ins>+bool TextureCubeMap::isSamplerComplete(const SamplerState &amp;samplerState) const
</ins><span class="cx"> {
</span><del>-    int size = mImageArray[0][0]-&gt;getWidth();
</del><ins>+    int size = getBaseLevelWidth();
</ins><span class="cx"> 
</span><del>-    bool mipmapping = isMipmapFiltered();
-    bool filtering, renderable;
</del><ins>+    bool mipmapping = IsMipmapFiltered(samplerState);
</ins><span class="cx"> 
</span><del>-    if ((gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)) == GL_FLOAT &amp;&amp; !mRenderer-&gt;getFloat32TextureSupport(&amp;filtering, &amp;renderable)) ||
-        (gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0) == GL_HALF_FLOAT_OES) &amp;&amp; !mRenderer-&gt;getFloat16TextureSupport(&amp;filtering, &amp;renderable)))
</del><ins>+    if (!IsTextureFilteringSupported(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0), mRenderer))
</ins><span class="cx">     {
</span><del>-        if (mSamplerState.magFilter != GL_NEAREST ||
-            (mSamplerState.minFilter != GL_NEAREST &amp;&amp; mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
</del><ins>+        if (samplerState.magFilter != GL_NEAREST ||
+            (samplerState.minFilter != GL_NEAREST &amp;&amp; samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
</ins><span class="cx">         {
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="lines">@@ -1060,7 +1233,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!isPow2(size) &amp;&amp; !mRenderer-&gt;getNonPower2TextureSupport())
</span><span class="cx">     {
</span><del>-        if (mSamplerState.wrapS != GL_CLAMP_TO_EDGE || mSamplerState.wrapT != GL_CLAMP_TO_EDGE || mipmapping)
</del><ins>+        if (samplerState.wrapS != GL_CLAMP_TO_EDGE || samplerState.wrapT != GL_CLAMP_TO_EDGE || mipmapping)
</ins><span class="cx">         {
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="lines">@@ -1087,16 +1260,22 @@
</span><span class="cx"> // Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
</span><span class="cx"> bool TextureCubeMap::isCubeComplete() const
</span><span class="cx"> {
</span><del>-    if (mImageArray[0][0]-&gt;getWidth() &lt;= 0 || mImageArray[0][0]-&gt;getHeight() != mImageArray[0][0]-&gt;getWidth())
</del><ins>+    int    baseWidth  = getBaseLevelWidth();
+    int    baseHeight = getBaseLevelHeight();
+    GLenum baseFormat = getBaseLevelInternalFormat();
+
+    if (baseWidth &lt;= 0 || baseWidth != baseHeight)
</ins><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (unsigned int face = 1; face &lt; 6; face++)
</del><ins>+    for (int faceIndex = 1; faceIndex &lt; 6; faceIndex++)
</ins><span class="cx">     {
</span><del>-        if (mImageArray[face][0]-&gt;getWidth() != mImageArray[0][0]-&gt;getWidth() ||
-            mImageArray[face][0]-&gt;getWidth() != mImageArray[0][0]-&gt;getHeight() ||
-            mImageArray[face][0]-&gt;getInternalFormat() != mImageArray[0][0]-&gt;getInternalFormat())
</del><ins>+        const rx::Image &amp;faceBaseImage = *mImageArray[faceIndex][0];
+
+        if (faceBaseImage.getWidth()          != baseWidth  ||
+            faceBaseImage.getHeight()         != baseHeight ||
+            faceBaseImage.getInternalFormat() != baseFormat )
</ins><span class="cx">         {
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="lines">@@ -1117,57 +1296,119 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    GLsizei size = mImageArray[0][0]-&gt;getWidth();
</del><ins>+    int levelCount = mipLevels();
</ins><span class="cx"> 
</span><del>-    int q = log2(size);
-
</del><span class="cx">     for (int face = 0; face &lt; 6; face++)
</span><span class="cx">     {
</span><del>-        for (int level = 1; level &lt;= q; level++)
</del><ins>+        for (int level = 1; level &lt; levelCount; level++)
</ins><span class="cx">         {
</span><del>-            if (mImageArray[face][level]-&gt;getInternalFormat() != mImageArray[0][0]-&gt;getInternalFormat())
</del><ins>+            if (!isFaceLevelComplete(face, level))
</ins><span class="cx">             {
</span><span class="cx">                 return false;
</span><span class="cx">             }
</span><del>-
-            if (mImageArray[face][level]-&gt;getWidth() != std::max(1, size &gt;&gt; level))
-            {
-                return false;
-            }
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TextureCubeMap::isFaceLevelComplete(int faceIndex, int level) const
+{
+    ASSERT(level &gt;= 0 &amp;&amp; faceIndex &lt; 6 &amp;&amp; level &lt; (int)ArraySize(mImageArray[faceIndex]) &amp;&amp; mImageArray[faceIndex][level] != NULL);
+
+    if (isImmutable())
+    {
+        return true;
+    }
+
+    int baseSize = getBaseLevelWidth();
+
+    if (baseSize &lt;= 0)
+    {
+        return false;
+    }
+
+    // &quot;isCubeComplete&quot; checks for base level completeness and we must call that
+    // to determine if any face at level 0 is complete. We omit that check here
+    // to avoid re-checking cube-completeness for every face at level 0.
+    if (level == 0)
+    {
+        return true;
+    }
+
+    // Check that non-zero levels are consistent with the base level.
+    const rx::Image *faceLevelImage = mImageArray[faceIndex][level];
+
+    if (faceLevelImage-&gt;getInternalFormat() != getBaseLevelInternalFormat())
+    {
+        return false;
+    }
+
+    if (faceLevelImage-&gt;getWidth() != std::max(1, baseSize &gt;&gt; level))
+    {
+        return false;
+    }
+
+    return true;
+}
+
</ins><span class="cx"> bool TextureCubeMap::isCompressed(GLenum target, GLint level) const
</span><span class="cx"> {
</span><del>-    return IsCompressed(getInternalFormat(target, level));
</del><ins>+    return IsFormatCompressed(getInternalFormat(target, level), mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Constructs a native texture resource from the texture images, or returns an existing one
-void TextureCubeMap::createTexture()
</del><ins>+bool TextureCubeMap::isDepth(GLenum target, GLint level) const
</ins><span class="cx"> {
</span><del>-    GLsizei size = mImageArray[0][0]-&gt;getWidth();
</del><ins>+    return GetDepthBits(getInternalFormat(target, level), mRenderer-&gt;getCurrentClientVersion()) &gt; 0;
+}
</ins><span class="cx"> 
</span><del>-    if (!(size &gt; 0))
-        return; // do not attempt to create native textures for nonexistant data
</del><ins>+void TextureCubeMap::initializeStorage(bool renderTarget)
+{
+    // Only initialize the first time this texture is used as a render target or shader resource
+    if (mTexStorage)
+    {
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    GLint levels = creationLevels(size);
-    GLenum internalformat = mImageArray[0][0]-&gt;getInternalFormat();
</del><ins>+    // do not attempt to create storage for nonexistant data
+    if (!isFaceLevelComplete(0, 0))
+    {
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    delete mTexStorage;
-    mTexStorage = new rx::TextureStorageInterfaceCube(mRenderer, levels, internalformat, mUsage, false, size);
</del><ins>+    bool createRenderTarget = (renderTarget || IsRenderTargetUsage(mUsage));
</ins><span class="cx"> 
</span><del>-    if (mTexStorage-&gt;isManaged())
</del><ins>+    setCompleteTexStorage(createCompleteStorage(createRenderTarget));
+    ASSERT(mTexStorage);
+
+    // flush image data to the storage
+    updateStorage();
+}
+
+rx::TextureStorageInterfaceCube *TextureCubeMap::createCompleteStorage(bool renderTarget) const
+{
+    GLsizei size = getBaseLevelWidth();
+
+    ASSERT(size &gt; 0);
+
+    // use existing storage level count, when previously specified by TexStorage*D
+    GLint levels = (mTexStorage ? mTexStorage-&gt;getLevelCount() : creationLevels(size, size, 1));
+
+    return new rx::TextureStorageInterfaceCube(mRenderer, getBaseLevelInternalFormat(), renderTarget, size, levels);
+}
+
+void TextureCubeMap::setCompleteTexStorage(rx::TextureStorageInterfaceCube *newCompleteTexStorage)
+{
+    SafeDelete(mTexStorage);
+    mTexStorage = newCompleteTexStorage;
+
+    if (mTexStorage &amp;&amp; mTexStorage-&gt;isManaged())
</ins><span class="cx">     {
</span><del>-        int levels = levelCount();
-
-        for (int face = 0; face &lt; 6; face++)
</del><ins>+        for (int faceIndex = 0; faceIndex &lt; 6; faceIndex++)
</ins><span class="cx">         {
</span><del>-            for (int level = 0; level &lt; levels; level++)
</del><ins>+            for (int level = 0; level &lt; mTexStorage-&gt;getLevelCount(); level++)
</ins><span class="cx">             {
</span><del>-                mImageArray[face][level]-&gt;setManagedSurface(mTexStorage, face, level);
</del><ins>+                mImageArray[faceIndex][level]-&gt;setManagedSurface(mTexStorage, faceIndex, level);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -1175,63 +1416,67 @@
</span><span class="cx">     mDirtyImages = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::updateTexture()
</del><ins>+void TextureCubeMap::updateStorage()
</ins><span class="cx"> {
</span><del>-    bool mipmapping = isMipmapFiltered() &amp;&amp; isMipmapCubeComplete();
-
</del><span class="cx">     for (int face = 0; face &lt; 6; face++)
</span><span class="cx">     {
</span><del>-        int levels = (mipmapping ? levelCount() : 1);
-
-        for (int level = 0; level &lt; levels; level++)
</del><ins>+        for (int level = 0; level &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
</ins><span class="cx">         {
</span><del>-            rx::Image *image = mImageArray[face][level];
-
-            if (image-&gt;isDirty())
</del><ins>+            if (isFaceLevelComplete(face, level))
</ins><span class="cx">             {
</span><del>-                commitRect(face, level, 0, 0, image-&gt;getWidth(), image-&gt;getHeight());
</del><ins>+                updateStorageFaceLevel(face, level);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::convertToRenderTarget()
</del><ins>+void TextureCubeMap::updateStorageFaceLevel(int faceIndex, int level)
</ins><span class="cx"> {
</span><del>-    rx::TextureStorageInterfaceCube *newTexStorage = NULL;
</del><ins>+    ASSERT(level &gt;= 0 &amp;&amp; faceIndex &lt; 6 &amp;&amp; level &lt; (int)ArraySize(mImageArray[faceIndex]) &amp;&amp; mImageArray[faceIndex][level] != NULL);
+    rx::Image *image = mImageArray[faceIndex][level];
</ins><span class="cx"> 
</span><del>-    if (mImageArray[0][0]-&gt;getWidth() != 0)
</del><ins>+    if (image-&gt;isDirty())
</ins><span class="cx">     {
</span><del>-        GLsizei size = mImageArray[0][0]-&gt;getWidth();
-        GLint levels = mTexStorage != NULL ? mTexStorage-&gt;levelCount() : creationLevels(size);
-        GLenum internalformat = mImageArray[0][0]-&gt;getInternalFormat();
</del><ins>+        commitRect(faceIndex, level, 0, 0, image-&gt;getWidth(), image-&gt;getHeight());
+    }
+}
</ins><span class="cx"> 
</span><del>-        newTexStorage = new rx::TextureStorageInterfaceCube(mRenderer, levels, internalformat, GL_FRAMEBUFFER_ATTACHMENT_ANGLE, true, size);
</del><ins>+bool TextureCubeMap::ensureRenderTarget()
+{
+    initializeStorage(true);
</ins><span class="cx"> 
</span><del>-        if (mTexStorage != NULL)
</del><ins>+    if (getBaseLevelWidth() &gt; 0)
+    {
+        ASSERT(mTexStorage);
+        if (!mTexStorage-&gt;isRenderTarget())
</ins><span class="cx">         {
</span><del>-            if (!mRenderer-&gt;copyToRenderTarget(newTexStorage, mTexStorage))
</del><ins>+            rx::TextureStorageInterfaceCube *newRenderTargetStorage = createCompleteStorage(true);
+
+            if (!mRenderer-&gt;copyToRenderTarget(newRenderTargetStorage, mTexStorage))
</ins><span class="cx">             {
</span><del>-                delete newTexStorage;
-                return gl::error(GL_OUT_OF_MEMORY);
</del><ins>+                delete newRenderTargetStorage;
+                return gl::error(GL_OUT_OF_MEMORY, false);
</ins><span class="cx">             }
</span><ins>+
+            setCompleteTexStorage(newRenderTargetStorage);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    delete mTexStorage;
-    mTexStorage = newTexStorage;
-
-    mDirtyImages = true;
</del><ins>+    return (mTexStorage &amp;&amp; mTexStorage-&gt;isRenderTarget());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
</del><ins>+void TextureCubeMap::setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
</ins><span class="cx"> {
</span><del>-    GLint internalformat = ConvertSizedInternalFormat(format, type);
-    redefineImage(faceIndex, level, internalformat, width, height);
</del><ins>+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat
+                                                                                      : GetSizedInternalFormat(format, type, clientVersion);
</ins><span class="cx"> 
</span><del>-    Texture::setImage(unpackAlignment, pixels, mImageArray[faceIndex][level]);
</del><ins>+    redefineImage(faceIndex, level, sizedInternalFormat, width, height);
+
+    Texture::setImage(unpack, type, pixels, mImageArray[faceIndex][level]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned int TextureCubeMap::faceIndex(GLenum face)
</del><ins>+int TextureCubeMap::targetToIndex(GLenum target)
</ins><span class="cx"> {
</span><span class="cx">     META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1);
</span><span class="cx">     META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 2);
</span><span class="lines">@@ -1239,32 +1484,32 @@
</span><span class="cx">     META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 4);
</span><span class="cx">     META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 5);
</span><span class="cx"> 
</span><del>-    return face - GL_TEXTURE_CUBE_MAP_POSITIVE_X;
</del><ins>+    return target - GL_TEXTURE_CUBE_MAP_POSITIVE_X;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::redefineImage(int face, GLint level, GLint internalformat, GLsizei width, GLsizei height)
</del><ins>+void TextureCubeMap::redefineImage(int faceIndex, GLint level, GLenum internalformat, GLsizei width, GLsizei height)
</ins><span class="cx"> {
</span><span class="cx">     // If there currently is a corresponding storage texture image, it has these parameters
</span><del>-    const int storageWidth = std::max(1, mImageArray[0][0]-&gt;getWidth() &gt;&gt; level);
-    const int storageHeight = std::max(1, mImageArray[0][0]-&gt;getHeight() &gt;&gt; level);
-    const int storageFormat = mImageArray[0][0]-&gt;getInternalFormat();
</del><ins>+    const int storageWidth = std::max(1, getBaseLevelWidth() &gt;&gt; level);
+    const int storageHeight = std::max(1, getBaseLevelHeight() &gt;&gt; level);
+    const GLenum storageFormat = getBaseLevelInternalFormat();
</ins><span class="cx"> 
</span><del>-    mImageArray[face][level]-&gt;redefine(mRenderer, internalformat, width, height, false);
</del><ins>+    mImageArray[faceIndex][level]-&gt;redefine(mRenderer, GL_TEXTURE_CUBE_MAP, internalformat, width, height, 1, false);
</ins><span class="cx"> 
</span><span class="cx">     if (mTexStorage)
</span><span class="cx">     {
</span><del>-        const int storageLevels = mTexStorage-&gt;levelCount();
-        
</del><ins>+        const int storageLevels = mTexStorage-&gt;getLevelCount();
+
</ins><span class="cx">         if ((level &gt;= storageLevels &amp;&amp; storageLevels != 0) ||
</span><span class="cx">             width != storageWidth ||
</span><span class="cx">             height != storageHeight ||
</span><span class="cx">             internalformat != storageFormat)   // Discard mismatched storage
</span><span class="cx">         {
</span><del>-            for (int i = 0; i &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
</del><ins>+            for (int level = 0; level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
</ins><span class="cx">             {
</span><del>-                for (int f = 0; f &lt; 6; f++)
</del><ins>+                for (int faceIndex = 0; faceIndex &lt; 6; faceIndex++)
</ins><span class="cx">                 {
</span><del>-                    mImageArray[f][i]-&gt;markDirty();
</del><ins>+                    mImageArray[faceIndex][level]-&gt;markDirty();
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="lines">@@ -1278,27 +1523,25 @@
</span><span class="cx"> 
</span><span class="cx"> void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
</span><span class="cx"> {
</span><del>-    unsigned int faceindex = faceIndex(target);
-    GLint internalformat = gl::ConvertSizedInternalFormat(format, GL_UNSIGNED_BYTE);
-    redefineImage(faceindex, level, internalformat, width, height);
</del><ins>+    int faceIndex = targetToIndex(target);
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLenum sizedInternalFormat = IsSizedInternalFormat(format, clientVersion) ? format
+                                                                              : GetSizedInternalFormat(format, GL_UNSIGNED_BYTE, clientVersion);
+    redefineImage(faceIndex, level, sizedInternalFormat, width, height);
</ins><span class="cx"> 
</span><del>-    if (!mImageArray[faceindex][level]-&gt;isRenderableFormat())
</del><ins>+    if (!mImageArray[faceIndex][level]-&gt;isRenderableFormat())
</ins><span class="cx">     {
</span><del>-        mImageArray[faceindex][level]-&gt;copy(0, 0, x, y, width, height, source);
</del><ins>+        mImageArray[faceIndex][level]-&gt;copy(0, 0, 0, x, y, width, height, source);
</ins><span class="cx">         mDirtyImages = true;
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        if (!mTexStorage || !mTexStorage-&gt;isRenderTarget())
-        {
-            convertToRenderTarget();
-        }
-        
-        mImageArray[faceindex][level]-&gt;markClean();
</del><ins>+        ensureRenderTarget();
+        mImageArray[faceIndex][level]-&gt;markClean();
</ins><span class="cx"> 
</span><span class="cx">         ASSERT(width == height);
</span><span class="cx"> 
</span><del>-        if (width &gt; 0 &amp;&amp; level &lt; levelCount())
</del><ins>+        if (width &gt; 0 &amp;&amp; isValidFaceLevel(faceIndex, level))
</ins><span class="cx">         {
</span><span class="cx">             gl::Rectangle sourceRect;
</span><span class="cx">             sourceRect.x = x;
</span><span class="lines">@@ -1311,40 +1554,44 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
</del><ins>+void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
</ins><span class="cx"> {
</span><del>-    GLsizei size = mImageArray[faceIndex(target)][level]-&gt;getWidth();
</del><ins>+    int faceIndex = targetToIndex(target);
</ins><span class="cx"> 
</span><del>-    if (xoffset + width &gt; size || yoffset + height &gt; size)
</del><ins>+    GLsizei size = mImageArray[faceIndex][level]-&gt;getWidth();
+
+    if (xoffset + width &gt; size || yoffset + height &gt; size || zoffset != 0)
</ins><span class="cx">     {
</span><span class="cx">         return gl::error(GL_INVALID_VALUE);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned int faceindex = faceIndex(target);
</del><ins>+    // We can only make our texture storage to a render target if the level we're copying *to* is complete
+    // and the base level is cube-complete. The base level must be cube complete (common case) because we cannot
+    // rely on the &quot;getBaseLevel*&quot; methods reliably otherwise.
+    bool canCreateRenderTarget = isFaceLevelComplete(faceIndex, level) &amp;&amp; isCubeComplete();
</ins><span class="cx"> 
</span><del>-    if (!mImageArray[faceindex][level]-&gt;isRenderableFormat() || (!mTexStorage &amp;&amp; !isSamplerComplete()))
</del><ins>+    if (!mImageArray[faceIndex][level]-&gt;isRenderableFormat() || (!mTexStorage &amp;&amp; !canCreateRenderTarget))
</ins><span class="cx">     {
</span><del>-        mImageArray[faceindex][level]-&gt;copy(0, 0, x, y, width, height, source);
</del><ins>+        mImageArray[faceIndex][level]-&gt;copy(0, 0, 0, x, y, width, height, source);
</ins><span class="cx">         mDirtyImages = true;
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        if (!mTexStorage || !mTexStorage-&gt;isRenderTarget())
</del><ins>+        ensureRenderTarget();
+        
+        if (isValidFaceLevel(faceIndex, level))
</ins><span class="cx">         {
</span><del>-            convertToRenderTarget();
-        }
-        
-        updateTexture();
</del><ins>+            updateStorageFaceLevel(faceIndex, level);
</ins><span class="cx"> 
</span><del>-        if (level &lt; levelCount())
-        {
</del><ins>+            GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+
</ins><span class="cx">             gl::Rectangle sourceRect;
</span><span class="cx">             sourceRect.x = x;
</span><span class="cx">             sourceRect.width = width;
</span><span class="cx">             sourceRect.y = y;
</span><span class="cx">             sourceRect.height = height;
</span><span class="cx"> 
</span><del>-            mRenderer-&gt;copyImage(source, sourceRect, gl::ExtractFormat(mImageArray[0][0]-&gt;getInternalFormat()), 
</del><ins>+            mRenderer-&gt;copyImage(source, sourceRect, gl::GetFormat(getBaseLevelInternalFormat(), clientVersion),
</ins><span class="cx">                                  xoffset, yoffset, mTexStorage, target, level);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -1352,144 +1599,1239 @@
</span><span class="cx"> 
</span><span class="cx"> void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size)
</span><span class="cx"> {
</span><del>-    delete mTexStorage;
-    mTexStorage = new rx::TextureStorageInterfaceCube(mRenderer, levels, internalformat, mUsage, false, size);
-    mImmutable = true;
-
</del><span class="cx">     for (int level = 0; level &lt; levels; level++)
</span><span class="cx">     {
</span><span class="cx">         GLsizei mipSize = std::max(1, size &gt;&gt; level);
</span><del>-        for (int face = 0; face &lt; 6; face++)
</del><ins>+        for (int faceIndex = 0; faceIndex &lt; 6; faceIndex++)
</ins><span class="cx">         {
</span><del>-            mImageArray[face][level]-&gt;redefine(mRenderer, internalformat, mipSize, mipSize, true);
</del><ins>+            mImageArray[faceIndex][level]-&gt;redefine(mRenderer, GL_TEXTURE_CUBE_MAP, internalformat, mipSize, mipSize, 1, true);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (int level = levels; level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
</span><span class="cx">     {
</span><del>-        for (int face = 0; face &lt; 6; face++)
</del><ins>+        for (int faceIndex = 0; faceIndex &lt; 6; faceIndex++)
</ins><span class="cx">         {
</span><del>-            mImageArray[face][level]-&gt;redefine(mRenderer, GL_NONE, 0, 0, true);
</del><ins>+            mImageArray[faceIndex][level]-&gt;redefine(mRenderer, GL_TEXTURE_CUBE_MAP, GL_NONE, 0, 0, 0, true);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mTexStorage-&gt;isManaged())
</del><ins>+    mImmutable = true;
+
+    setCompleteTexStorage(new rx::TextureStorageInterfaceCube(mRenderer, internalformat, IsRenderTargetUsage(mUsage), size, levels));
+}
+
+void TextureCubeMap::generateMipmaps()
+{
+    // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
+    int levelCount = mipLevels();
+    for (int faceIndex = 0; faceIndex &lt; 6; faceIndex++)
</ins><span class="cx">     {
</span><del>-        int levels = levelCount();
</del><ins>+        for (int level = 1; level &lt; levelCount; level++)
+        {
+            int faceLevelSize = (std::max(mImageArray[faceIndex][0]-&gt;getWidth() &gt;&gt; level, 1));
+            redefineImage(faceIndex, level, mImageArray[faceIndex][0]-&gt;getInternalFormat(), faceLevelSize, faceLevelSize);
+        }
+    }
</ins><span class="cx"> 
</span><del>-        for (int face = 0; face &lt; 6; face++)
</del><ins>+    if (mTexStorage &amp;&amp; mTexStorage-&gt;isRenderTarget())
+    {
+        for (int faceIndex = 0; faceIndex &lt; 6; faceIndex++)
</ins><span class="cx">         {
</span><del>-            for (int level = 0; level &lt; levels; level++)
</del><ins>+            for (int level = 1; level &lt; levelCount; level++)
</ins><span class="cx">             {
</span><del>-                mImageArray[face][level]-&gt;setManagedSurface(mTexStorage, face, level);
</del><ins>+                mTexStorage-&gt;generateMipmap(faceIndex, level);
+
+                mImageArray[faceIndex][level]-&gt;markClean();
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+    else
+    {
+        for (int faceIndex = 0; faceIndex &lt; 6; faceIndex++)
+        {
+            for (int level = 1; level &lt; levelCount; level++)
+            {
+                mRenderer-&gt;generateMipmap(mImageArray[faceIndex][level], mImageArray[faceIndex][level - 1]);
+            }
+        }
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureCubeMap::generateMipmaps()
</del><ins>+const rx::Image *TextureCubeMap::getBaseLevelImage() const
</ins><span class="cx"> {
</span><del>-    if (!isCubeComplete())
</del><ins>+    // Note: if we are not cube-complete, there is no single base level image that can describe all
+    // cube faces, so this method is only well-defined for a cube-complete base level.
+    return mImageArray[0][0];
+}
+
+rx::TextureStorageInterface *TextureCubeMap::getBaseLevelStorage()
+{
+    return mTexStorage;
+}
+
+Renderbuffer *TextureCubeMap::getRenderbuffer(GLenum target, GLint level)
+{
+    if (!IsCubemapTextureTarget(target))
</ins><span class="cx">     {
</span><del>-        return gl::error(GL_INVALID_OPERATION);
</del><ins>+        return gl::error(GL_INVALID_OPERATION, (Renderbuffer *)NULL);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!mRenderer-&gt;getNonPower2TextureSupport())
</del><ins>+    int faceIndex = targetToIndex(target);
+
+    Renderbuffer *renderBuffer = mRenderbufferProxies.get(level, faceIndex);
+    if (!renderBuffer)
</ins><span class="cx">     {
</span><del>-        if (!isPow2(mImageArray[0][0]-&gt;getWidth()))
</del><ins>+        renderBuffer = new Renderbuffer(mRenderer, id(), new RenderbufferTextureCubeMap(this, target, level));
+        mRenderbufferProxies.add(level, faceIndex, renderBuffer);
+    }
+
+    return renderBuffer;
+}
+
+unsigned int TextureCubeMap::getRenderTargetSerial(GLenum target, GLint level)
+{
+    return (ensureRenderTarget() ? mTexStorage-&gt;getRenderTargetSerial(target, level) : 0);
+}
+
+rx::RenderTarget *TextureCubeMap::getRenderTarget(GLenum target, GLint level)
+{
+    ASSERT(IsCubemapTextureTarget(target));
+
+    // ensure the underlying texture is created
+    if (!ensureRenderTarget())
+    {
+        return NULL;
+    }
+
+    updateStorageFaceLevel(targetToIndex(target), level);
+
+    // ensure this is NOT a depth texture
+    if (isDepth(target, level))
+    {
+        return NULL;
+    }
+
+    return mTexStorage-&gt;getRenderTarget(target, level);
+}
+
+rx::RenderTarget *TextureCubeMap::getDepthStencil(GLenum target, GLint level)
+{
+    ASSERT(IsCubemapTextureTarget(target));
+
+    // ensure the underlying texture is created
+    if (!ensureRenderTarget())
+    {
+        return NULL;
+    }
+
+    updateStorageFaceLevel(targetToIndex(target), level);
+
+    // ensure this is a depth texture
+    if (!isDepth(target, level))
+    {
+        return NULL;
+    }
+
+    return mTexStorage-&gt;getRenderTarget(target, level);
+}
+
+bool TextureCubeMap::isValidFaceLevel(int faceIndex, int level) const
+{
+    return (mTexStorage ? (level &gt;= 0 &amp;&amp; level &lt; mTexStorage-&gt;getLevelCount()) : 0);
+}
+
+Texture3D::Texture3D(rx::Renderer *renderer, GLuint id) : Texture(renderer, id, GL_TEXTURE_3D)
+{
+    mTexStorage = NULL;
+
+    for (int i = 0; i &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i)
+    {
+        mImageArray[i] = renderer-&gt;createImage();
+    }
+}
+
+Texture3D::~Texture3D()
+{
+    delete mTexStorage;
+    mTexStorage = NULL;
+
+    for (int i = 0; i &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i)
+    {
+        delete mImageArray[i];
+    }
+}
+
+GLsizei Texture3D::getWidth(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mImageArray[level]-&gt;getWidth() : 0;
+}
+
+GLsizei Texture3D::getHeight(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mImageArray[level]-&gt;getHeight() : 0;
+}
+
+GLsizei Texture3D::getDepth(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mImageArray[level]-&gt;getDepth() : 0;
+}
+
+GLenum Texture3D::getInternalFormat(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mImageArray[level]-&gt;getInternalFormat() : GL_NONE;
+}
+
+GLenum Texture3D::getActualFormat(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mImageArray[level]-&gt;getActualFormat() : GL_NONE;
+}
+
+bool Texture3D::isCompressed(GLint level) const
+{
+    return IsFormatCompressed(getInternalFormat(level), mRenderer-&gt;getCurrentClientVersion());
+}
+
+bool Texture3D::isDepth(GLint level) const
+{
+    return GetDepthBits(getInternalFormat(level), mRenderer-&gt;getCurrentClientVersion()) &gt; 0;
+}
+
+void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
+{
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat
+                                                                                      : GetSizedInternalFormat(format, type, clientVersion);
+    redefineImage(level, sizedInternalFormat, width, height, depth);
+
+    bool fastUnpacked = false;
+
+    // Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer
+    if (isFastUnpackable(unpack, sizedInternalFormat))
+    {
+        // Will try to create RT storage if it does not exist
+        rx::RenderTarget *destRenderTarget = getRenderTarget(level);
+        Box destArea(0, 0, 0, getWidth(level), getHeight(level), getDepth(level));
+
+        if (destRenderTarget &amp;&amp; fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, destRenderTarget))
</ins><span class="cx">         {
</span><del>-            return gl::error(GL_INVALID_OPERATION);
</del><ins>+            // Ensure we don't overwrite our newly initialized data
+            mImageArray[level]-&gt;markClean();
+
+            fastUnpacked = true;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
-    unsigned int q = log2(mImageArray[0][0]-&gt;getWidth());
-    for (unsigned int f = 0; f &lt; 6; f++)
</del><ins>+    if (!fastUnpacked)
</ins><span class="cx">     {
</span><del>-        for (unsigned int i = 1; i &lt;= q; i++)
</del><ins>+        Texture::setImage(unpack, type, pixels, mImageArray[level]);
+    }
+}
+
+void Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
+{
+    // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
+    redefineImage(level, format, width, height, depth);
+
+    Texture::setCompressedImage(imageSize, pixels, mImageArray[level]);
+}
+
+void Texture3D::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
+{
+    bool fastUnpacked = false;
+
+    // Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer
+    if (isFastUnpackable(unpack, getInternalFormat(level)))
+    {
+        rx::RenderTarget *destRenderTarget = getRenderTarget(level);
+        Box destArea(xoffset, yoffset, zoffset, width, height, depth);
+
+        if (destRenderTarget &amp;&amp; fastUnpackPixels(unpack, pixels, destArea, getInternalFormat(level), type, destRenderTarget))
</ins><span class="cx">         {
</span><del>-            redefineImage(f, i, mImageArray[f][0]-&gt;getInternalFormat(),
-                          std::max(mImageArray[f][0]-&gt;getWidth() &gt;&gt; i, 1),
-                          std::max(mImageArray[f][0]-&gt;getWidth() &gt;&gt; i, 1));
</del><ins>+            // Ensure we don't overwrite our newly initialized data
+            mImageArray[level]-&gt;markClean();
+
+            fastUnpacked = true;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (!fastUnpacked &amp;&amp; Texture::subImage(xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels, mImageArray[level]))
+    {
+        commitRect(level, xoffset, yoffset, zoffset, width, height, depth);
+    }
+}
+
+void Texture3D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
+{
+    if (Texture::subImageCompressed(xoffset, yoffset, zoffset, width, height, depth, format, imageSize, pixels, mImageArray[level]))
+    {
+        commitRect(level, xoffset, yoffset, zoffset, width, height, depth);
+    }
+}
+
+void Texture3D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
+{
+    for (int level = 0; level &lt; levels; level++)
+    {
+        GLsizei levelWidth = std::max(1, width &gt;&gt; level);
+        GLsizei levelHeight = std::max(1, height &gt;&gt; level);
+        GLsizei levelDepth = std::max(1, depth &gt;&gt; level);
+        mImageArray[level]-&gt;redefine(mRenderer, GL_TEXTURE_3D, internalformat, levelWidth, levelHeight, levelDepth, true);
+    }
+
+    for (int level = levels; level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
+    {
+        mImageArray[level]-&gt;redefine(mRenderer, GL_TEXTURE_3D, GL_NONE, 0, 0, 0, true);
+    }
+
+    mImmutable = true;
+
+    setCompleteTexStorage(new rx::TextureStorageInterface3D(mRenderer, internalformat, IsRenderTargetUsage(mUsage), width, height, depth, levels));
+}
+
+void Texture3D::generateMipmaps()
+{
+    // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
+    int levelCount = mipLevels();
+    for (int level = 1; level &lt; levelCount; level++)
+    {
+        redefineImage(level, getBaseLevelInternalFormat(),
+                      std::max(getBaseLevelWidth() &gt;&gt; level, 1),
+                      std::max(getBaseLevelHeight() &gt;&gt; level, 1),
+                      std::max(getBaseLevelDepth() &gt;&gt; level, 1));
+    }
+
</ins><span class="cx">     if (mTexStorage &amp;&amp; mTexStorage-&gt;isRenderTarget())
</span><span class="cx">     {
</span><del>-        for (unsigned int f = 0; f &lt; 6; f++)
</del><ins>+        for (int level = 1; level &lt; levelCount; level++)
</ins><span class="cx">         {
</span><del>-            for (unsigned int i = 1; i &lt;= q; i++)
</del><ins>+            mTexStorage-&gt;generateMipmap(level);
+
+            mImageArray[level]-&gt;markClean();
+        }
+    }
+    else
+    {
+        for (int level = 1; level &lt; levelCount; level++)
+        {
+            mRenderer-&gt;generateMipmap(mImageArray[level], mImageArray[level - 1]);
+        }
+    }
+}
+
+const rx::Image *Texture3D::getBaseLevelImage() const
+{
+    return mImageArray[0];
+}
+
+rx::TextureStorageInterface *Texture3D::getBaseLevelStorage()
+{
+    return mTexStorage;
+}
+
+void Texture3D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
+{
+    if (xoffset + width &gt; mImageArray[level]-&gt;getWidth() || yoffset + height &gt; mImageArray[level]-&gt;getHeight() || zoffset &gt;= mImageArray[level]-&gt;getDepth())
+    {
+        return gl::error(GL_INVALID_VALUE);
+    }
+
+    // can only make our texture storage to a render target if level 0 is defined (with a width &amp; height) and
+    // the current level we're copying to is defined (with appropriate format, width &amp; height)
+    bool canCreateRenderTarget = isLevelComplete(level) &amp;&amp; isLevelComplete(0);
+
+    if (!mImageArray[level]-&gt;isRenderableFormat() || (!mTexStorage &amp;&amp; !canCreateRenderTarget))
+    {
+        mImageArray[level]-&gt;copy(xoffset, yoffset, zoffset, x, y, width, height, source);
+        mDirtyImages = true;
+    }
+    else
+    {
+        ensureRenderTarget();
+
+        if (isValidLevel(level))
+        {
+            updateStorageLevel(level);
+
+            gl::Rectangle sourceRect;
+            sourceRect.x = x;
+            sourceRect.width = width;
+            sourceRect.y = y;
+            sourceRect.height = height;
+
+            GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+
+            mRenderer-&gt;copyImage(source, sourceRect,
+                                 gl::GetFormat(getBaseLevelInternalFormat(), clientVersion),
+                                 xoffset, yoffset, zoffset, mTexStorage, level);
+        }
+    }
+}
+
+bool Texture3D::isSamplerComplete(const SamplerState &amp;samplerState) const
+{
+    GLsizei width = getBaseLevelWidth();
+    GLsizei height = getBaseLevelHeight();
+    GLsizei depth = getBaseLevelDepth();
+
+    if (width &lt;= 0 || height &lt;= 0 || depth &lt;= 0)
+    {
+        return false;
+    }
+
+    if (!IsTextureFilteringSupported(getInternalFormat(0), mRenderer))
+    {
+        if (samplerState.magFilter != GL_NEAREST ||
+            (samplerState.minFilter != GL_NEAREST &amp;&amp; samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
+        {
+            return false;
+        }
+    }
+
+    if (IsMipmapFiltered(samplerState) &amp;&amp; !isMipmapComplete())
+    {
+        return false;
+    }
+
+    return true;
+}
+
+bool Texture3D::isMipmapComplete() const
+{
+    int levelCount = mipLevels();
+
+    for (int level = 0; level &lt; levelCount; level++)
+    {
+        if (!isLevelComplete(level))
+        {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool Texture3D::isLevelComplete(int level) const
+{
+    ASSERT(level &gt;= 0 &amp;&amp; level &lt; (int)ArraySize(mImageArray) &amp;&amp; mImageArray[level] != NULL);
+
+    if (isImmutable())
+    {
+        return true;
+    }
+
+    GLsizei width = getBaseLevelWidth();
+    GLsizei height = getBaseLevelHeight();
+    GLsizei depth = getBaseLevelDepth();
+
+    if (width &lt;= 0 || height &lt;= 0 || depth &lt;= 0)
+    {
+        return false;
+    }
+
+    if (level == 0)
+    {
+        return true;
+    }
+
+    rx::Image *levelImage = mImageArray[level];
+
+    if (levelImage-&gt;getInternalFormat() != getBaseLevelInternalFormat())
+    {
+        return false;
+    }
+
+    if (levelImage-&gt;getWidth() != std::max(1, width &gt;&gt; level))
+    {
+        return false;
+    }
+
+    if (levelImage-&gt;getHeight() != std::max(1, height &gt;&gt; level))
+    {
+        return false;
+    }
+
+    if (levelImage-&gt;getDepth() != std::max(1, depth &gt;&gt; level))
+    {
+        return false;
+    }
+
+    return true;
+}
+
+Renderbuffer *Texture3D::getRenderbuffer(GLint level, GLint layer)
+{
+    Renderbuffer *renderBuffer = mRenderbufferProxies.get(level, layer);
+    if (!renderBuffer)
+    {
+        renderBuffer = new Renderbuffer(mRenderer, id(), new RenderbufferTexture3DLayer(this, level, layer));
+        mRenderbufferProxies.add(level, 0, renderBuffer);
+    }
+
+    return renderBuffer;
+}
+
+unsigned int Texture3D::getRenderTargetSerial(GLint level, GLint layer)
+{
+    return (ensureRenderTarget() ? mTexStorage-&gt;getRenderTargetSerial(level, layer) : 0);
+}
+
+bool Texture3D::isValidLevel(int level) const
+{
+    return (mTexStorage ? (level &gt;= 0 &amp;&amp; level &lt; mTexStorage-&gt;getLevelCount()) : 0);
+}
+
+void Texture3D::initializeStorage(bool renderTarget)
+{
+    // Only initialize the first time this texture is used as a render target or shader resource
+    if (mTexStorage)
+    {
+        return;
+    }
+
+    // do not attempt to create storage for nonexistant data
+    if (!isLevelComplete(0))
+    {
+        return;
+    }
+
+    bool createRenderTarget = (renderTarget || mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
+
+    setCompleteTexStorage(createCompleteStorage(createRenderTarget));
+    ASSERT(mTexStorage);
+
+    // flush image data to the storage
+    updateStorage();
+}
+
+rx::TextureStorageInterface3D *Texture3D::createCompleteStorage(bool renderTarget) const
+{
+    GLsizei width = getBaseLevelWidth();
+    GLsizei height = getBaseLevelHeight();
+    GLsizei depth = getBaseLevelDepth();
+
+    ASSERT(width &gt; 0 &amp;&amp; height &gt; 0 &amp;&amp; depth &gt; 0);
+
+    // use existing storage level count, when previously specified by TexStorage*D
+    GLint levels = (mTexStorage ? mTexStorage-&gt;getLevelCount() : creationLevels(width, height, depth));
+
+    return new rx::TextureStorageInterface3D(mRenderer, getBaseLevelInternalFormat(), renderTarget, width, height, depth, levels);
+}
+
+void Texture3D::setCompleteTexStorage(rx::TextureStorageInterface3D *newCompleteTexStorage)
+{
+    SafeDelete(mTexStorage);
+    mTexStorage = newCompleteTexStorage;
+    mDirtyImages = true;
+
+    // We do not support managed 3D storage, as that is D3D9/ES2-only
+    ASSERT(!mTexStorage-&gt;isManaged());
+}
+
+void Texture3D::updateStorage()
+{
+    for (int level = 0; level &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
+    {
+        if (isLevelComplete(level))
+        {
+            updateStorageLevel(level);
+        }
+    }
+}
+
+void Texture3D::updateStorageLevel(int level)
+{
+    ASSERT(level &gt;= 0 &amp;&amp; level &lt; (int)ArraySize(mImageArray) &amp;&amp; mImageArray[level] != NULL);
+    ASSERT(isLevelComplete(level));
+
+    if (mImageArray[level]-&gt;isDirty())
+    {
+        commitRect(level, 0, 0, 0, getWidth(level), getHeight(level), getDepth(level));
+    }
+}
+
+bool Texture3D::ensureRenderTarget()
+{
+    initializeStorage(true);
+
+    if (getBaseLevelWidth() &gt; 0 &amp;&amp; getBaseLevelHeight() &gt; 0 &amp;&amp; getBaseLevelDepth() &gt; 0)
+    {
+        ASSERT(mTexStorage);
+        if (!mTexStorage-&gt;isRenderTarget())
+        {
+            rx::TextureStorageInterface3D *newRenderTargetStorage = createCompleteStorage(true);
+
+            if (!mRenderer-&gt;copyToRenderTarget(newRenderTargetStorage, mTexStorage))
</ins><span class="cx">             {
</span><del>-                mTexStorage-&gt;generateMipmap(f, i);
</del><ins>+                delete newRenderTargetStorage;
+                return gl::error(GL_OUT_OF_MEMORY, false);
+            }
</ins><span class="cx"> 
</span><del>-                mImageArray[f][i]-&gt;markClean();
</del><ins>+            setCompleteTexStorage(newRenderTargetStorage);
+        }
+    }
+
+    return (mTexStorage &amp;&amp; mTexStorage-&gt;isRenderTarget());
+}
+
+rx::RenderTarget *Texture3D::getRenderTarget(GLint level)
+{
+    // ensure the underlying texture is created
+    if (!ensureRenderTarget())
+    {
+        return NULL;
+    }
+
+    updateStorageLevel(level);
+
+    // ensure this is NOT a depth texture
+    if (isDepth(level))
+    {
+        return NULL;
+    }
+
+    return mTexStorage-&gt;getRenderTarget(level);
+}
+
+rx::RenderTarget *Texture3D::getRenderTarget(GLint level, GLint layer)
+{
+    // ensure the underlying texture is created
+    if (!ensureRenderTarget())
+    {
+        return NULL;
+    }
+
+    updateStorage();
+
+    // ensure this is NOT a depth texture
+    if (isDepth(level))
+    {
+        return NULL;
+    }
+
+    return mTexStorage-&gt;getRenderTarget(level, layer);
+}
+
+rx::RenderTarget *Texture3D::getDepthStencil(GLint level, GLint layer)
+{
+    // ensure the underlying texture is created
+    if (!ensureRenderTarget())
+    {
+        return NULL;
+    }
+
+    updateStorageLevel(level);
+
+    // ensure this is a depth texture
+    if (!isDepth(level))
+    {
+        return NULL;
+    }
+
+    return mTexStorage-&gt;getRenderTarget(level, layer);
+}
+
+void Texture3D::redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
+{
+    // If there currently is a corresponding storage texture image, it has these parameters
+    const int storageWidth = std::max(1, getBaseLevelWidth() &gt;&gt; level);
+    const int storageHeight = std::max(1, getBaseLevelHeight() &gt;&gt; level);
+    const int storageDepth = std::max(1, getBaseLevelDepth() &gt;&gt; level);
+    const GLenum storageFormat = getBaseLevelInternalFormat();
+
+    mImageArray[level]-&gt;redefine(mRenderer, GL_TEXTURE_3D, internalformat, width, height, depth, false);
+
+    if (mTexStorage)
+    {
+        const int storageLevels = mTexStorage-&gt;getLevelCount();
+
+        if ((level &gt;= storageLevels &amp;&amp; storageLevels != 0) ||
+            width != storageWidth ||
+            height != storageHeight ||
+            depth != storageDepth ||
+            internalformat != storageFormat)   // Discard mismatched storage
+        {
+            for (int i = 0; i &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
+            {
+                mImageArray[i]-&gt;markDirty();
</ins><span class="cx">             }
</span><ins>+
+            delete mTexStorage;
+            mTexStorage = NULL;
+            mDirtyImages = true;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><ins>+}
+
+void Texture3D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth)
+{
+    if (isValidLevel(level))
+    {
+        rx::Image *image = mImageArray[level];
+        if (image-&gt;copyToStorage(mTexStorage, level, xoffset, yoffset, zoffset, width, height, depth))
+        {
+            image-&gt;markClean();
+        }
+    }
+}
+
+Texture2DArray::Texture2DArray(rx::Renderer *renderer, GLuint id) : Texture(renderer, id, GL_TEXTURE_2D_ARRAY)
+{
+    mTexStorage = NULL;
+
+    for (int level = 0; level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++level)
+    {
+        mLayerCounts[level] = 0;
+        mImageArray[level] = NULL;
+    }
+}
+
+Texture2DArray::~Texture2DArray()
+{
+    delete mTexStorage;
+    mTexStorage = NULL;
+
+    deleteImages();
+}
+
+void Texture2DArray::deleteImages()
+{
+    for (int level = 0; level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++level)
+    {
+        for (int layer = 0; layer &lt; mLayerCounts[level]; ++layer)
+        {
+            delete mImageArray[level][layer];
+        }
+        delete[] mImageArray[level];
+        mImageArray[level] = NULL;
+        mLayerCounts[level] = 0;
+    }
+}
+
+GLsizei Texture2DArray::getWidth(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS &amp;&amp; mLayerCounts[level] &gt; 0) ? mImageArray[level][0]-&gt;getWidth() : 0;
+}
+
+GLsizei Texture2DArray::getHeight(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS &amp;&amp; mLayerCounts[level] &gt; 0) ? mImageArray[level][0]-&gt;getHeight() : 0;
+}
+
+GLsizei Texture2DArray::getLayers(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS &amp;&amp; mLayerCounts[level] &gt; 0) ? mLayerCounts[level] : 0;
+}
+
+GLenum Texture2DArray::getInternalFormat(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS &amp;&amp; mLayerCounts[level] &gt; 0) ? mImageArray[level][0]-&gt;getInternalFormat() : GL_NONE;
+}
+
+GLenum Texture2DArray::getActualFormat(GLint level) const
+{
+    return (level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS &amp;&amp; mLayerCounts[level] &gt; 0) ? mImageArray[level][0]-&gt;getActualFormat() : GL_NONE;
+}
+
+bool Texture2DArray::isCompressed(GLint level) const
+{
+    return IsFormatCompressed(getInternalFormat(level), mRenderer-&gt;getCurrentClientVersion());
+}
+
+bool Texture2DArray::isDepth(GLint level) const
+{
+    return GetDepthBits(getInternalFormat(level), mRenderer-&gt;getCurrentClientVersion()) &gt; 0;
+}
+
+void Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
+{
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat
+                                                                                      : GetSizedInternalFormat(format, type, clientVersion);
+    redefineImage(level, sizedInternalFormat, width, height, depth);
+
+    GLsizei inputDepthPitch = gl::GetDepthPitch(sizedInternalFormat, type, clientVersion, width, height, unpack.alignment);
+
+    for (int i = 0; i &lt; depth; i++)
+    {
+        const void *layerPixels = pixels ? (reinterpret_cast&lt;const unsigned char*&gt;(pixels) + (inputDepthPitch * i)) : NULL;
+        Texture::setImage(unpack, type, layerPixels, mImageArray[level][i]);
+    }
+}
+
+void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
+{
+    // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
+    redefineImage(level, format, width, height, depth);
+
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLsizei inputDepthPitch = gl::GetDepthPitch(format, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
+
+    for (int i = 0; i &lt; depth; i++)
+    {
+        const void *layerPixels = pixels ? (reinterpret_cast&lt;const unsigned char*&gt;(pixels) + (inputDepthPitch * i)) : NULL;
+        Texture::setCompressedImage(imageSize, layerPixels, mImageArray[level][i]);
+    }
+}
+
+void Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels)
+{
+    GLenum internalformat = getInternalFormat(level);
+    GLuint clientVersion =  mRenderer-&gt;getCurrentClientVersion();
+    GLsizei inputDepthPitch = gl::GetDepthPitch(internalformat, type, clientVersion, width, height, unpack.alignment);
+
+    for (int i = 0; i &lt; depth; i++)
+    {
+        int layer = zoffset + i;
+        const void *layerPixels = pixels ? (reinterpret_cast&lt;const unsigned char*&gt;(pixels) + (inputDepthPitch * i)) : NULL;
+
+        if (Texture::subImage(xoffset, yoffset, zoffset, width, height, 1, format, type, unpack, layerPixels, mImageArray[level][layer]))
+        {
+            commitRect(level, xoffset, yoffset, layer, width, height);
+        }
+    }
+}
+
+void Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
+{
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLsizei inputDepthPitch = gl::GetDepthPitch(format, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
+
+    for (int i = 0; i &lt; depth; i++)
+    {
+        int layer = zoffset + i;
+        const void *layerPixels = pixels ? (reinterpret_cast&lt;const unsigned char*&gt;(pixels) + (inputDepthPitch * i)) : NULL;
+
+        if (Texture::subImageCompressed(xoffset, yoffset, zoffset, width, height, 1, format, imageSize, layerPixels, mImageArray[level][layer]))
+        {
+            commitRect(level, xoffset, yoffset, layer, width, height);
+        }
+    }
+}
+
+void Texture2DArray::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
+{
+    deleteImages();
+
+    for (int level = 0; level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
+    {
+        GLsizei levelWidth = std::max(1, width &gt;&gt; level);
+        GLsizei levelHeight = std::max(1, height &gt;&gt; level);
+
+        mLayerCounts[level] = (level &lt; levels ? depth : 0);
+
+        if (mLayerCounts[level] &gt; 0)
+        {
+            // Create new images for this level
+            mImageArray[level] = new rx::Image*[mLayerCounts[level]];
+
+            for (int layer = 0; layer &lt; mLayerCounts[level]; layer++)
+            {
+                mImageArray[level][layer] = mRenderer-&gt;createImage();
+                mImageArray[level][layer]-&gt;redefine(mRenderer, GL_TEXTURE_2D_ARRAY, internalformat, levelWidth,
+                                                    levelHeight, 1, true);
+            }
+        }
+    }
+
+    mImmutable = true;
+    setCompleteTexStorage(new rx::TextureStorageInterface2DArray(mRenderer, internalformat, IsRenderTargetUsage(mUsage), width, height, depth, levels));
+}
+
+void Texture2DArray::generateMipmaps()
+{
+    int baseWidth = getBaseLevelWidth();
+    int baseHeight = getBaseLevelHeight();
+    int baseDepth = getBaseLevelDepth();
+    GLenum baseFormat = getBaseLevelInternalFormat();
+
+    // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
+    int levelCount = mipLevels();
+    for (int level = 1; level &lt; levelCount; level++)
+    {
+        redefineImage(level, baseFormat, std::max(baseWidth &gt;&gt; level, 1), std::max(baseHeight &gt;&gt; level, 1), baseDepth);
+    }
+
+    if (mTexStorage &amp;&amp; mTexStorage-&gt;isRenderTarget())
+    {
+        for (int level = 1; level &lt; levelCount; level++)
+        {
+            mTexStorage-&gt;generateMipmap(level);
+
+            for (int layer = 0; layer &lt; mLayerCounts[level]; layer++)
+            {
+                mImageArray[level][layer]-&gt;markClean();
+            }
+        }
+    }
</ins><span class="cx">     else
</span><span class="cx">     {
</span><del>-        for (unsigned int f = 0; f &lt; 6; f++)
</del><ins>+        for (int level = 1; level &lt; levelCount; level++)
</ins><span class="cx">         {
</span><del>-            for (unsigned int i = 1; i &lt;= q; i++)
</del><ins>+            for (int layer = 0; layer &lt; mLayerCounts[level]; layer++)
</ins><span class="cx">             {
</span><del>-                mRenderer-&gt;generateMipmap(mImageArray[f][i], mImageArray[f][i - 1]);
</del><ins>+                mRenderer-&gt;generateMipmap(mImageArray[level][layer], mImageArray[level - 1][layer]);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Renderbuffer *TextureCubeMap::getRenderbuffer(GLenum target)
</del><ins>+const rx::Image *Texture2DArray::getBaseLevelImage() const
</ins><span class="cx"> {
</span><del>-    if (!IsCubemapTextureTarget(target))
</del><ins>+    return (mLayerCounts[0] &gt; 0 ? mImageArray[0][0] : NULL);
+}
+
+rx::TextureStorageInterface *Texture2DArray::getBaseLevelStorage()
+{
+    return mTexStorage;
+}
+
+void Texture2DArray::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
+{
+    if (xoffset + width &gt; getWidth(level) || yoffset + height &gt; getHeight(level) || zoffset &gt;= getLayers(level) || getLayers(level) == 0)
</ins><span class="cx">     {
</span><del>-        return gl::error(GL_INVALID_OPERATION, (Renderbuffer *)NULL);
</del><ins>+        return gl::error(GL_INVALID_VALUE);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned int face = faceIndex(target);
</del><ins>+    // can only make our texture storage to a render target if level 0 is defined (with a width &amp; height) and
+    // the current level we're copying to is defined (with appropriate format, width &amp; height)
+    bool canCreateRenderTarget = isLevelComplete(level) &amp;&amp; isLevelComplete(0);
</ins><span class="cx"> 
</span><del>-    if (mFaceProxies[face] == NULL)
</del><ins>+    if (!mImageArray[level][0]-&gt;isRenderableFormat() || (!mTexStorage &amp;&amp; !canCreateRenderTarget))
</ins><span class="cx">     {
</span><del>-        mFaceProxies[face] = new Renderbuffer(mRenderer, id(), new RenderbufferTextureCubeMap(this, target));
</del><ins>+        mImageArray[level][zoffset]-&gt;copy(xoffset, yoffset, 0, x, y, width, height, source);
+        mDirtyImages = true;
</ins><span class="cx">     }
</span><ins>+    else
+    {
+        ensureRenderTarget();
</ins><span class="cx"> 
</span><del>-    return mFaceProxies[face];
</del><ins>+        if (isValidLevel(level))
+        {
+            updateStorageLevel(level);
+
+            GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+
+            gl::Rectangle sourceRect;
+            sourceRect.x = x;
+            sourceRect.width = width;
+            sourceRect.y = y;
+            sourceRect.height = height;
+
+            mRenderer-&gt;copyImage(source, sourceRect, gl::GetFormat(getInternalFormat(0), clientVersion),
+                                 xoffset, yoffset, zoffset, mTexStorage, level);
+        }
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-rx::RenderTarget *TextureCubeMap::getRenderTarget(GLenum target)
</del><ins>+bool Texture2DArray::isSamplerComplete(const SamplerState &amp;samplerState) const
</ins><span class="cx"> {
</span><del>-    ASSERT(IsCubemapTextureTarget(target));
</del><ins>+    GLsizei width = getBaseLevelWidth();
+    GLsizei height = getBaseLevelHeight();
+    GLsizei depth = getLayers(0);
</ins><span class="cx"> 
</span><ins>+    if (width &lt;= 0 || height &lt;= 0 || depth &lt;= 0)
+    {
+        return false;
+    }
+
+    if (!IsTextureFilteringSupported(getBaseLevelInternalFormat(), mRenderer))
+    {
+        if (samplerState.magFilter != GL_NEAREST ||
+            (samplerState.minFilter != GL_NEAREST &amp;&amp; samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
+        {
+            return false;
+        }
+    }
+
+    if (IsMipmapFiltered(samplerState) &amp;&amp; !isMipmapComplete())
+    {
+        return false;
+    }
+
+    return true;
+}
+
+bool Texture2DArray::isMipmapComplete() const
+{
+    int levelCount = mipLevels();
+
+    for (int level = 1; level &lt; levelCount; level++)
+    {
+        if (!isLevelComplete(level))
+        {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool Texture2DArray::isLevelComplete(int level) const
+{
+    ASSERT(level &gt;= 0 &amp;&amp; level &lt; (int)ArraySize(mImageArray));
+
+    if (isImmutable())
+    {
+        return true;
+    }
+
+    GLsizei width = getBaseLevelWidth();
+    GLsizei height = getBaseLevelHeight();
+    GLsizei layers = getLayers(0);
+
+    if (width &lt;= 0 || height &lt;= 0 || layers &lt;= 0)
+    {
+        return false;
+    }
+
+    if (level == 0)
+    {
+        return true;
+    }
+
+    if (getInternalFormat(level) != getInternalFormat(0))
+    {
+        return false;
+    }
+
+    if (getWidth(level) != std::max(1, width &gt;&gt; level))
+    {
+        return false;
+    }
+
+    if (getHeight(level) != std::max(1, height &gt;&gt; level))
+    {
+        return false;
+    }
+
+    if (getLayers(level) != layers)
+    {
+        return false;
+    }
+
+    return true;
+}
+
+Renderbuffer *Texture2DArray::getRenderbuffer(GLint level, GLint layer)
+{
+    Renderbuffer *renderBuffer = mRenderbufferProxies.get(level, layer);
+    if (!renderBuffer)
+    {
+        renderBuffer = new Renderbuffer(mRenderer, id(), new RenderbufferTexture2DArrayLayer(this, level, layer));
+        mRenderbufferProxies.add(level, 0, renderBuffer);
+    }
+
+    return renderBuffer;
+}
+
+unsigned int Texture2DArray::getRenderTargetSerial(GLint level, GLint layer)
+{
+    return (ensureRenderTarget() ? mTexStorage-&gt;getRenderTargetSerial(level, layer) : 0);
+}
+
+bool Texture2DArray::isValidLevel(int level) const
+{
+    return (mTexStorage ? (level &gt;= 0 &amp;&amp; level &lt; mTexStorage-&gt;getLevelCount()) : 0);
+}
+
+void Texture2DArray::initializeStorage(bool renderTarget)
+{
+    // Only initialize the first time this texture is used as a render target or shader resource
+    if (mTexStorage)
+    {
+        return;
+    }
+
+    // do not attempt to create storage for nonexistant data
+    if (!isLevelComplete(0))
+    {
+        return;
+    }
+
+    bool createRenderTarget = (renderTarget || mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
+
+    setCompleteTexStorage(createCompleteStorage(createRenderTarget));
+    ASSERT(mTexStorage);
+
+    // flush image data to the storage
+    updateStorage();
+}
+
+rx::TextureStorageInterface2DArray *Texture2DArray::createCompleteStorage(bool renderTarget) const
+{
+    GLsizei width = getBaseLevelWidth();
+    GLsizei height = getBaseLevelHeight();
+    GLsizei depth = getLayers(0);
+
+    ASSERT(width &gt; 0 &amp;&amp; height &gt; 0 &amp;&amp; depth &gt; 0);
+
+    // use existing storage level count, when previously specified by TexStorage*D
+    GLint levels = (mTexStorage ? mTexStorage-&gt;getLevelCount() : creationLevels(width, height, 1));
+
+    return new rx::TextureStorageInterface2DArray(mRenderer, getBaseLevelInternalFormat(), renderTarget, width, height, depth, levels);
+}
+
+void Texture2DArray::setCompleteTexStorage(rx::TextureStorageInterface2DArray *newCompleteTexStorage)
+{
+    SafeDelete(mTexStorage);
+    mTexStorage = newCompleteTexStorage;
+    mDirtyImages = true;
+
+    // We do not support managed 2D array storage, as managed storage is ES2/D3D9 only
+    ASSERT(!mTexStorage-&gt;isManaged());
+}
+
+void Texture2DArray::updateStorage()
+{
+    for (int level = 0; level &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
+    {
+        if (isLevelComplete(level))
+        {
+            updateStorageLevel(level);
+        }
+    }
+}
+
+void Texture2DArray::updateStorageLevel(int level)
+{
+    ASSERT(level &gt;= 0 &amp;&amp; level &lt; (int)ArraySize(mLayerCounts));
+    ASSERT(isLevelComplete(level));
+
+    for (int layer = 0; layer &lt; mLayerCounts[level]; layer++)
+    {
+        ASSERT(mImageArray[level] != NULL &amp;&amp; mImageArray[level][layer] != NULL);
+        if (mImageArray[level][layer]-&gt;isDirty())
+        {
+            commitRect(level, 0, 0, layer, getWidth(level), getHeight(level));
+        }
+    }
+}
+
+bool Texture2DArray::ensureRenderTarget()
+{
+    initializeStorage(true);
+
+    if (getBaseLevelWidth() &gt; 0 &amp;&amp; getBaseLevelHeight() &gt; 0 &amp;&amp; getLayers(0) &gt; 0)
+    {
+        ASSERT(mTexStorage);
+        if (!mTexStorage-&gt;isRenderTarget())
+        {
+            rx::TextureStorageInterface2DArray *newRenderTargetStorage = createCompleteStorage(true);
+
+            if (!mRenderer-&gt;copyToRenderTarget(newRenderTargetStorage, mTexStorage))
+            {
+                delete newRenderTargetStorage;
+                return gl::error(GL_OUT_OF_MEMORY, false);
+            }
+
+            setCompleteTexStorage(newRenderTargetStorage);
+        }
+    }
+
+    return (mTexStorage &amp;&amp; mTexStorage-&gt;isRenderTarget());
+}
+
+rx::RenderTarget *Texture2DArray::getRenderTarget(GLint level, GLint layer)
+{
</ins><span class="cx">     // ensure the underlying texture is created
</span><del>-    if (getStorage(true) == NULL)
</del><ins>+    if (!ensureRenderTarget())
</ins><span class="cx">     {
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    updateTexture();
-    
-    return mTexStorage-&gt;getRenderTarget(target);
</del><ins>+    updateStorageLevel(level);
+
+    // ensure this is NOT a depth texture
+    if (isDepth(level))
+    {
+        return NULL;
+    }
+
+    return mTexStorage-&gt;getRenderTarget(level, layer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int TextureCubeMap::levelCount()
</del><ins>+rx::RenderTarget *Texture2DArray::getDepthStencil(GLint level, GLint layer)
</ins><span class="cx"> {
</span><del>-    return mTexStorage ? mTexStorage-&gt;levelCount() - getLodOffset() : 0;
</del><ins>+    // ensure the underlying texture is created
+    if (!ensureRenderTarget())
+    {
+        return NULL;
+    }
+
+    updateStorageLevel(level);
+
+    // ensure this is a depth texture
+    if (!isDepth(level))
+    {
+        return NULL;
+    }
+
+    return mTexStorage-&gt;getRenderTarget(level, layer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-rx::TextureStorageInterface *TextureCubeMap::getStorage(bool renderTarget)
</del><ins>+void Texture2DArray::redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
</ins><span class="cx"> {
</span><del>-    if (!mTexStorage || (renderTarget &amp;&amp; !mTexStorage-&gt;isRenderTarget()))
</del><ins>+    // If there currently is a corresponding storage texture image, it has these parameters
+    const int storageWidth = std::max(1, getBaseLevelWidth() &gt;&gt; level);
+    const int storageHeight = std::max(1, getBaseLevelHeight() &gt;&gt; level);
+    const int storageDepth = getLayers(0);
+    const GLenum storageFormat = getBaseLevelInternalFormat();
+
+    for (int layer = 0; layer &lt; mLayerCounts[level]; layer++)
</ins><span class="cx">     {
</span><del>-        if (renderTarget)
</del><ins>+        delete mImageArray[level][layer];
+    }
+    delete[] mImageArray[level];
+    mImageArray[level] = NULL;
+    mLayerCounts[level] = depth;
+
+    if (depth &gt; 0)
+    {
+        mImageArray[level] = new rx::Image*[depth]();
+
+        for (int layer = 0; layer &lt; mLayerCounts[level]; layer++)
</ins><span class="cx">         {
</span><del>-            convertToRenderTarget();
</del><ins>+            mImageArray[level][layer] = mRenderer-&gt;createImage();
+            mImageArray[level][layer]-&gt;redefine(mRenderer, GL_TEXTURE_2D_ARRAY, internalformat, width, height, 1, false);
</ins><span class="cx">         }
</span><del>-        else
</del><ins>+    }
+
+    if (mTexStorage)
+    {
+        const int storageLevels = mTexStorage-&gt;getLevelCount();
+
+        if ((level &gt;= storageLevels &amp;&amp; storageLevels != 0) ||
+            width != storageWidth ||
+            height != storageHeight ||
+            depth != storageDepth ||
+            internalformat != storageFormat)   // Discard mismatched storage
</ins><span class="cx">         {
</span><del>-            createTexture();
</del><ins>+            for (int level = 0; level &lt; IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
+            {
+                for (int layer = 0; layer &lt; mLayerCounts[level]; layer++)
+                {
+                    mImageArray[level][layer]-&gt;markDirty();
+                }
+            }
+
+            delete mTexStorage;
+            mTexStorage = NULL;
+            mDirtyImages = true;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    return mTexStorage;
</del><ins>+void Texture2DArray::commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height)
+{
+    if (isValidLevel(level) &amp;&amp; layerTarget &lt; getLayers(level))
+    {
+        rx::Image *image = mImageArray[level][layerTarget];
+        if (image-&gt;copyToStorage(mTexStorage, level, xoffset, yoffset, layerTarget, width, height))
+        {
+            image-&gt;markClean();
+        }
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Textureh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -14,11 +14,13 @@
</span><span class="cx"> #include &lt;vector&gt;
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/debug.h&quot;
</span><span class="cx"> #include &quot;common/RefCountObject.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/angletypes.h&quot;
</span><ins>+#include &quot;libGLESv2/RenderbufferProxySet.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace egl
</span><span class="cx"> {
</span><span class="lines">@@ -31,6 +33,8 @@
</span><span class="cx"> class TextureStorageInterface;
</span><span class="cx"> class TextureStorageInterface2D;
</span><span class="cx"> class TextureStorageInterfaceCube;
</span><ins>+class TextureStorageInterface3D;
+class TextureStorageInterface2DArray;
</ins><span class="cx"> class RenderTarget;
</span><span class="cx"> class Image;
</span><span class="cx"> }
</span><span class="lines">@@ -45,75 +49,104 @@
</span><span class="cx">     // These are the maximums the implementation can support
</span><span class="cx">     // The actual GL caps are limited by the device caps
</span><span class="cx">     // and should be queried from the Context
</span><del>-    IMPLEMENTATION_MAX_TEXTURE_SIZE = 16384,
</del><ins>+    IMPLEMENTATION_MAX_2D_TEXTURE_SIZE = 16384,
</ins><span class="cx">     IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384,
</span><ins>+    IMPLEMENTATION_MAX_3D_TEXTURE_SIZE = 2048,
+    IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS = 2048,
</ins><span class="cx"> 
</span><span class="cx">     IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15   // 1+log2 of MAX_TEXTURE_SIZE
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+bool IsMipmapFiltered(const SamplerState &amp;samplerState);
+
</ins><span class="cx"> class Texture : public RefCountObject
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    Texture(rx::Renderer *renderer, GLuint id);
</del><ins>+    Texture(rx::Renderer *renderer, GLuint id, GLenum target);
</ins><span class="cx"> 
</span><span class="cx">     virtual ~Texture();
</span><span class="cx"> 
</span><del>-    virtual void addProxyRef(const Renderbuffer *proxy) = 0;
-    virtual void releaseProxy(const Renderbuffer *proxy) = 0;
</del><ins>+    void addProxyRef(const Renderbuffer *proxy);
+    void releaseProxy(const Renderbuffer *proxy);
</ins><span class="cx"> 
</span><del>-    virtual GLenum getTarget() const = 0;
</del><ins>+    GLenum getTarget() const;
</ins><span class="cx"> 
</span><del>-    bool setMinFilter(GLenum filter);
-    bool setMagFilter(GLenum filter);
-    bool setWrapS(GLenum wrap);
-    bool setWrapT(GLenum wrap);
-    bool setMaxAnisotropy(float textureMaxAnisotropy, float contextMaxAnisotropy);
-    bool setUsage(GLenum usage);
</del><ins>+    void setMinFilter(GLenum filter);
+    void setMagFilter(GLenum filter);
+    void setWrapS(GLenum wrap);
+    void setWrapT(GLenum wrap);
+    void setWrapR(GLenum wrap);
+    void setMaxAnisotropy(float textureMaxAnisotropy, float contextMaxAnisotropy);
+    void setCompareMode(GLenum mode);
+    void setCompareFunc(GLenum func);
+    void setSwizzleRed(GLenum swizzle);
+    void setSwizzleGreen(GLenum swizzle);
+    void setSwizzleBlue(GLenum swizzle);
+    void setSwizzleAlpha(GLenum swizzle);
+    void setBaseLevel(GLint baseLevel);
+    void setMaxLevel(GLint maxLevel);
+    void setMinLod(GLfloat minLod);
+    void setMaxLod(GLfloat maxLod);
+    void setUsage(GLenum usage);
</ins><span class="cx"> 
</span><span class="cx">     GLenum getMinFilter() const;
</span><span class="cx">     GLenum getMagFilter() const;
</span><span class="cx">     GLenum getWrapS() const;
</span><span class="cx">     GLenum getWrapT() const;
</span><ins>+    GLenum getWrapR() const;
</ins><span class="cx">     float getMaxAnisotropy() const;
</span><del>-    int getLodOffset();
</del><ins>+    GLenum getSwizzleRed() const;
+    GLenum getSwizzleGreen() const;
+    GLenum getSwizzleBlue() const;
+    GLenum getSwizzleAlpha() const;
+    GLint getBaseLevel() const;
+    GLint getMaxLevel() const;
+    GLfloat getMinLod() const;
+    GLfloat getMaxLod() const;
+    bool isSwizzled() const;
</ins><span class="cx">     void getSamplerState(SamplerState *sampler);
</span><span class="cx">     GLenum getUsage() const;
</span><del>-    bool isMipmapFiltered() const;
</del><span class="cx"> 
</span><del>-    virtual bool isSamplerComplete() const = 0;
</del><ins>+    GLint getBaseLevelWidth() const;
+    GLint getBaseLevelHeight() const;
+    GLint getBaseLevelDepth() const;
+    GLenum getBaseLevelInternalFormat() const;
</ins><span class="cx"> 
</span><ins>+    virtual bool isSamplerComplete(const SamplerState &amp;samplerState) const = 0;
+
</ins><span class="cx">     rx::TextureStorageInterface *getNativeTexture();
</span><del>-    virtual Renderbuffer *getRenderbuffer(GLenum target) = 0;
</del><span class="cx"> 
</span><span class="cx">     virtual void generateMipmaps() = 0;
</span><del>-    virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0;
</del><ins>+    virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0;
</ins><span class="cx"> 
</span><span class="cx">     bool hasDirtyParameters() const;
</span><span class="cx">     bool hasDirtyImages() const;
</span><span class="cx">     void resetDirty();
</span><span class="cx">     unsigned int getTextureSerial();
</span><del>-    unsigned int getRenderTargetSerial(GLenum target);
</del><span class="cx"> 
</span><span class="cx">     bool isImmutable() const;
</span><ins>+    int immutableLevelCount();
</ins><span class="cx"> 
</span><span class="cx">     static const GLuint INCOMPLETE_TEXTURE_ID = static_cast&lt;GLuint&gt;(-1);   // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
</span><span class="cx"> 
</span><span class="cx">   protected:
</span><del>-    void setImage(GLint unpackAlignment, const void *pixels, rx::Image *image);
-    bool subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image);
</del><ins>+    void setImage(const PixelUnpackState &amp;unpack, GLenum type, const void *pixels, rx::Image *image);
+    bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                  GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels, rx::Image *image);
</ins><span class="cx">     void setCompressedImage(GLsizei imageSize, const void *pixels, rx::Image *image);
</span><del>-    bool subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image);
</del><ins>+    bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                            GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image);
+    bool isFastUnpackable(const PixelUnpackState &amp;unpack, GLenum sizedInternalFormat);
+    bool fastUnpackPixels(const PixelUnpackState &amp;unpack, const void *pixels, const Box &amp;destArea,
+                          GLenum sizedInternalFormat, GLenum type, rx::RenderTarget *destRenderTarget);
</ins><span class="cx"> 
</span><del>-    GLint creationLevels(GLsizei width, GLsizei height) const;
-    GLint creationLevels(GLsizei size) const;
</del><ins>+    GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const;
+    int mipLevels() const;
</ins><span class="cx"> 
</span><del>-    virtual void createTexture() = 0;
-    virtual void updateTexture() = 0;
-    virtual void convertToRenderTarget() = 0;
-    virtual rx::RenderTarget *getRenderTarget(GLenum target) = 0;
</del><ins>+    virtual void initializeStorage(bool renderTarget) = 0;
+    virtual void updateStorage() = 0;
+    virtual bool ensureRenderTarget() = 0;
</ins><span class="cx"> 
</span><del>-    virtual int levelCount() = 0;
-
</del><span class="cx">     rx::Renderer *mRenderer;
</span><span class="cx"> 
</span><span class="cx">     SamplerState mSamplerState;
</span><span class="lines">@@ -123,10 +156,20 @@
</span><span class="cx"> 
</span><span class="cx">     bool mImmutable;
</span><span class="cx"> 
</span><ins>+    GLenum mTarget;
+
+    // A specific internal reference count is kept for colorbuffer proxy references,
+    // because, as the renderbuffer acting as proxy will maintain a binding pointer
+    // back to this texture, there would be a circular reference if we used a binding
+    // pointer here. This reference count will cause the pointer to be set to NULL if
+    // the count drops to zero, but will not cause deletion of the Renderbuffer.
+    RenderbufferProxySet mRenderbufferProxies;
+
</ins><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Texture);
</span><span class="cx"> 
</span><del>-    virtual rx::TextureStorageInterface *getStorage(bool renderTarget) = 0;
</del><ins>+    virtual rx::TextureStorageInterface *getBaseLevelStorage() = 0;
+    virtual const rx::Image *getBaseLevelImage() const = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class Texture2D : public Texture
</span><span class="lines">@@ -136,11 +179,6 @@
</span><span class="cx"> 
</span><span class="cx">     ~Texture2D();
</span><span class="cx"> 
</span><del>-    void addProxyRef(const Renderbuffer *proxy);
-    void releaseProxy(const Renderbuffer *proxy);
-
-    virtual GLenum getTarget() const;
-
</del><span class="cx">     GLsizei getWidth(GLint level) const;
</span><span class="cx">     GLsizei getHeight(GLint level) const;
</span><span class="cx">     GLenum getInternalFormat(GLint level) const;
</span><span class="lines">@@ -148,53 +186,52 @@
</span><span class="cx">     bool isCompressed(GLint level) const;
</span><span class="cx">     bool isDepth(GLint level) const;
</span><span class="cx"> 
</span><del>-    void setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
</del><ins>+    void setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
</ins><span class="cx">     void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
</span><del>-    void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
</del><ins>+    void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
</ins><span class="cx">     void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
</span><span class="cx">     void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
</span><del>-    virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
</del><ins>+    virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
</ins><span class="cx">     void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
</span><span class="cx"> 
</span><del>-    virtual bool isSamplerComplete() const;
</del><ins>+    virtual bool isSamplerComplete(const SamplerState &amp;samplerState) const;
</ins><span class="cx">     virtual void bindTexImage(egl::Surface *surface);
</span><span class="cx">     virtual void releaseTexImage();
</span><span class="cx"> 
</span><span class="cx">     virtual void generateMipmaps();
</span><span class="cx"> 
</span><del>-    virtual Renderbuffer *getRenderbuffer(GLenum target);
</del><ins>+    Renderbuffer *getRenderbuffer(GLint level);
+    unsigned int getRenderTargetSerial(GLint level);
</ins><span class="cx"> 
</span><span class="cx">   protected:
</span><span class="cx">     friend class RenderbufferTexture2D;
</span><del>-    virtual rx::RenderTarget *getRenderTarget(GLenum target);
-    virtual rx::RenderTarget *getDepthStencil(GLenum target);
-    virtual int levelCount();
</del><ins>+    rx::RenderTarget *getRenderTarget(GLint level);
+    rx::RenderTarget *getDepthSencil(GLint level);
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Texture2D);
</span><span class="cx"> 
</span><del>-    virtual void createTexture();
-    virtual void updateTexture();
-    virtual void convertToRenderTarget();
-    virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
</del><ins>+    virtual void initializeStorage(bool renderTarget);
+    rx::TextureStorageInterface2D *createCompleteStorage(bool renderTarget) const;
+    void setCompleteTexStorage(rx::TextureStorageInterface2D *newCompleteTexStorage);
</ins><span class="cx"> 
</span><ins>+    virtual void updateStorage();
+    virtual bool ensureRenderTarget();
+    virtual rx::TextureStorageInterface *getBaseLevelStorage();
+    virtual const rx::Image *getBaseLevelImage() const;
+
</ins><span class="cx">     bool isMipmapComplete() const;
</span><ins>+    bool isValidLevel(int level) const;
+    bool isLevelComplete(int level) const;
+    void updateStorageLevel(int level);
</ins><span class="cx"> 
</span><del>-    void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height);
</del><ins>+    void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height);
</ins><span class="cx">     void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
</span><span class="cx"> 
</span><span class="cx">     rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
</span><span class="cx"> 
</span><span class="cx">     rx::TextureStorageInterface2D *mTexStorage;
</span><span class="cx">     egl::Surface *mSurface;
</span><del>-
-    // A specific internal reference count is kept for colorbuffer proxy references,
-    // because, as the renderbuffer acting as proxy will maintain a binding pointer
-    // back to this texture, there would be a circular reference if we used a binding
-    // pointer here. This reference count will cause the pointer to be set to NULL if
-    // the count drops to zero, but will not cause deletion of the Renderbuffer.
-    Renderbuffer *mColorbufferProxy;
-    unsigned int mProxyRefs;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class TextureCubeMap : public Texture
</span><span class="lines">@@ -204,72 +241,196 @@
</span><span class="cx"> 
</span><span class="cx">     ~TextureCubeMap();
</span><span class="cx"> 
</span><del>-    void addProxyRef(const Renderbuffer *proxy);
-    void releaseProxy(const Renderbuffer *proxy);
-
-    virtual GLenum getTarget() const;
-    
</del><span class="cx">     GLsizei getWidth(GLenum target, GLint level) const;
</span><span class="cx">     GLsizei getHeight(GLenum target, GLint level) const;
</span><span class="cx">     GLenum getInternalFormat(GLenum target, GLint level) const;
</span><span class="cx">     GLenum getActualFormat(GLenum target, GLint level) const;
</span><span class="cx">     bool isCompressed(GLenum target, GLint level) const;
</span><ins>+    bool isDepth(GLenum target, GLint level) const;
</ins><span class="cx"> 
</span><del>-    void setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
-    void setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
-    void setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
-    void setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
-    void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
-    void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
</del><ins>+    void setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
+    void setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
+    void setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
+    void setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
+    void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
+    void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
</ins><span class="cx"> 
</span><del>-    void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
</del><ins>+    void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
</ins><span class="cx"> 
</span><del>-    void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
</del><ins>+    void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
</ins><span class="cx">     void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
</span><span class="cx">     void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
</span><del>-    virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
</del><ins>+    virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
</ins><span class="cx">     void storage(GLsizei levels, GLenum internalformat, GLsizei size);
</span><span class="cx"> 
</span><del>-    virtual bool isSamplerComplete() const;
</del><ins>+    virtual bool isSamplerComplete(const SamplerState &amp;samplerState) const;
+    bool isCubeComplete() const;
</ins><span class="cx"> 
</span><span class="cx">     virtual void generateMipmaps();
</span><span class="cx"> 
</span><del>-    virtual Renderbuffer *getRenderbuffer(GLenum target);
</del><ins>+    Renderbuffer *getRenderbuffer(GLenum target, GLint level);
+    unsigned int getRenderTargetSerial(GLenum target, GLint level);
</ins><span class="cx"> 
</span><del>-    static unsigned int faceIndex(GLenum face);
</del><ins>+    static int targetToIndex(GLenum target);
</ins><span class="cx"> 
</span><span class="cx">   protected:
</span><span class="cx">     friend class RenderbufferTextureCubeMap;
</span><del>-    virtual rx::RenderTarget *getRenderTarget(GLenum target);
-    virtual int levelCount();
</del><ins>+    rx::RenderTarget *getRenderTarget(GLenum target, GLint level);
+    rx::RenderTarget *getDepthStencil(GLenum target, GLint level);
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
</span><span class="cx"> 
</span><del>-    virtual void createTexture();
-    virtual void updateTexture();
-    virtual void convertToRenderTarget();
-    virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
</del><ins>+    virtual void initializeStorage(bool renderTarget);
+    rx::TextureStorageInterfaceCube *createCompleteStorage(bool renderTarget) const;
+    void setCompleteTexStorage(rx::TextureStorageInterfaceCube *newCompleteTexStorage);
</ins><span class="cx"> 
</span><del>-    bool isCubeComplete() const;
</del><ins>+    virtual void updateStorage();
+    virtual bool ensureRenderTarget();
+    virtual rx::TextureStorageInterface *getBaseLevelStorage();
+    virtual const rx::Image *getBaseLevelImage() const;
+
</ins><span class="cx">     bool isMipmapCubeComplete() const;
</span><ins>+    bool isValidFaceLevel(int faceIndex, int level) const;
+    bool isFaceLevelComplete(int faceIndex, int level) const;
+    void updateStorageFaceLevel(int faceIndex, int level);
</ins><span class="cx"> 
</span><del>-    void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
</del><ins>+    void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
</ins><span class="cx">     void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
</span><del>-    void redefineImage(int faceIndex, GLint level, GLint internalformat, GLsizei width, GLsizei height);
</del><ins>+    void redefineImage(int faceIndex, GLint level, GLenum internalformat, GLsizei width, GLsizei height);
</ins><span class="cx"> 
</span><span class="cx">     rx::Image *mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
</span><span class="cx"> 
</span><span class="cx">     rx::TextureStorageInterfaceCube *mTexStorage;
</span><ins>+};
</ins><span class="cx"> 
</span><del>-    // A specific internal reference count is kept for colorbuffer proxy references,
-    // because, as the renderbuffer acting as proxy will maintain a binding pointer
-    // back to this texture, there would be a circular reference if we used a binding
-    // pointer here. This reference count will cause the pointer to be set to NULL if
-    // the count drops to zero, but will not cause deletion of the Renderbuffer.
-    Renderbuffer *mFaceProxies[6];
-    unsigned int *mFaceProxyRefs[6];
</del><ins>+class Texture3D : public Texture
+{
+  public:
+    Texture3D(rx::Renderer *renderer, GLuint id);
+
+    ~Texture3D();
+
+    GLsizei getWidth(GLint level) const;
+    GLsizei getHeight(GLint level) const;
+    GLsizei getDepth(GLint level) const;
+    GLenum getInternalFormat(GLint level) const;
+    GLenum getActualFormat(GLint level) const;
+    bool isCompressed(GLint level) const;
+    bool isDepth(GLint level) const;
+
+    void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
+    void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
+    void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
+    void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
+    void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+
+    virtual void generateMipmaps();
+    virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
+
+    virtual bool isSamplerComplete(const SamplerState &amp;samplerState) const;
+    virtual bool isMipmapComplete() const;
+
+    Renderbuffer *getRenderbuffer(GLint level, GLint layer);
+    unsigned int getRenderTargetSerial(GLint level, GLint layer);
+
+  protected:
+    friend class RenderbufferTexture3DLayer;
+    rx::RenderTarget *getRenderTarget(GLint level);
+    rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
+    rx::RenderTarget *getDepthStencil(GLint level, GLint layer);
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(Texture3D);
+
+    virtual void initializeStorage(bool renderTarget);
+    rx::TextureStorageInterface3D *createCompleteStorage(bool renderTarget) const;
+    void setCompleteTexStorage(rx::TextureStorageInterface3D *newCompleteTexStorage);
+
+    virtual void updateStorage();
+    virtual bool ensureRenderTarget();
+
+    virtual rx::TextureStorageInterface *getBaseLevelStorage();
+    virtual const rx::Image *getBaseLevelImage() const;
+
+    void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+    void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
+
+    bool isValidLevel(int level) const;
+    bool isLevelComplete(int level) const;
+    void updateStorageLevel(int level);
+
+    rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
+
+    rx::TextureStorageInterface3D *mTexStorage;
</ins><span class="cx"> };
</span><ins>+
+class Texture2DArray : public Texture
+{
+  public:
+    Texture2DArray(rx::Renderer *renderer, GLuint id);
+
+    ~Texture2DArray();
+
+    GLsizei getWidth(GLint level) const;
+    GLsizei getHeight(GLint level) const;
+    GLsizei getLayers(GLint level) const;
+    GLenum getInternalFormat(GLint level) const;
+    GLenum getActualFormat(GLint level) const;
+    bool isCompressed(GLint level) const;
+    bool isDepth(GLint level) const;
+
+    void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
+    void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
+    void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &amp;unpack, const void *pixels);
+    void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
+    void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+
+    virtual void generateMipmaps();
+    virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
+
+    virtual bool isSamplerComplete(const SamplerState &amp;samplerState) const;
+    virtual bool isMipmapComplete() const;
+
+    Renderbuffer *getRenderbuffer(GLint level, GLint layer);
+    unsigned int getRenderTargetSerial(GLint level, GLint layer);
+
+  protected:
+    friend class RenderbufferTexture2DArrayLayer;
+    rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
+    rx::RenderTarget *getDepthStencil(GLint level, GLint layer);
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(Texture2DArray);
+
+    virtual void initializeStorage(bool renderTarget);
+    rx::TextureStorageInterface2DArray *createCompleteStorage(bool renderTarget) const;
+    void setCompleteTexStorage(rx::TextureStorageInterface2DArray *newCompleteTexStorage);
+
+    virtual void updateStorage();
+    virtual bool ensureRenderTarget();
+
+    virtual rx::TextureStorageInterface *getBaseLevelStorage();
+    virtual const rx::Image *getBaseLevelImage() const;
+
+    void deleteImages();
+    void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+    void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height);
+
+    bool isValidLevel(int level) const;
+    bool isLevelComplete(int level) const;
+    void updateStorageLevel(int level);
+
+    // Storing images as an array of single depth textures since D3D11 treats each array level of a
+    // Texture2D object as a separate subresource.  Each layer would have to be looped over
+    // to update all the texture layers since they cannot all be updated at once and it makes the most
+    // sense for the Image class to not have to worry about layer subresource as well as mip subresources.
+    GLsizei mLayerCounts[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
+    rx::Image **mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
+
+    rx::TextureStorageInterface2DArray *mTexStorage;
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif   // LIBGLESV2_TEXTURE_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2TransformFeedbackcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/TransformFeedback.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/TransformFeedback.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/TransformFeedback.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+//
+// Copyright (c) 2014 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 &quot;libGLESv2/TransformFeedback.h&quot;
+
+namespace gl
+{
+
+TransformFeedback::TransformFeedback(GLuint id)
+    : RefCountObject(id),
+      mStarted(GL_FALSE),
+      mPrimitiveMode(GL_NONE),
+      mPaused(GL_FALSE)
+{
+}
+
+TransformFeedback::~TransformFeedback()
+{
+}
+
+void TransformFeedback::start(GLenum primitiveMode)
+{
+    mStarted = GL_TRUE;
+    mPrimitiveMode = primitiveMode;
+    mPaused = GL_FALSE;
+}
+
+void TransformFeedback::stop()
+{
+    mStarted = GL_FALSE;
+    mPrimitiveMode = GL_NONE;
+    mPaused = GL_FALSE;
+}
+
+GLboolean TransformFeedback::isStarted() const
+{
+    return mStarted;
+}
+
+GLenum TransformFeedback::getDrawMode() const
+{
+    return mPrimitiveMode;
+}
+
+void TransformFeedback::pause()
+{
+    mPaused = GL_TRUE;
+}
+
+void TransformFeedback::resume()
+{
+    mPaused = GL_FALSE;
+}
+
+GLboolean TransformFeedback::isPaused() const
+{
+    return mPaused;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2TransformFeedbackh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/TransformFeedback.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/TransformFeedback.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/TransformFeedback.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+//
+// Copyright (c) 2014 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 LIBGLESV2_TRANSFORM_FEEDBACK_H_
+#define LIBGLESV2_TRANSFORM_FEEDBACK_H_
+
+#include &quot;common/angleutils.h&quot;
+#include &quot;common/RefCountObject.h&quot;
+
+#define GL_APICALL
+#include &lt;GLES3/gl3.h&gt;
+#include &lt;GLES2/gl2.h&gt;
+
+namespace gl
+{
+
+class TransformFeedback : public RefCountObject
+{
+  public:
+    explicit TransformFeedback(GLuint id);
+    virtual ~TransformFeedback();
+
+    void start(GLenum primitiveMode);
+    void stop();
+    GLboolean isStarted() const;
+
+    GLenum getDrawMode() const;
+
+    void pause();
+    void resume();
+    GLboolean isPaused() const;
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(TransformFeedback);
+
+    GLboolean mStarted;
+    GLenum mPrimitiveMode;
+    GLboolean mPaused;
+};
+
+}
+
+#endif // LIBGLESV2_TRANSFORM_FEEDBACK_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Uniformcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Uniform.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Uniform.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Uniform.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -7,37 +7,100 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/Uniform.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;common/utilities.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-Uniform::Uniform(GLenum type, GLenum precision, const std::string &amp;name, unsigned int arraySize)
-    : type(type), precision(precision), name(name), arraySize(arraySize)
</del><ins>+LinkedUniform::LinkedUniform(GLenum type, GLenum precision, const std::string &amp;name, unsigned int arraySize,
+                             const int blockIndex, const BlockMemberInfo &amp;blockInfo)
+    : type(type),
+      precision(precision),
+      name(name),
+      arraySize(arraySize),
+      blockIndex(blockIndex),
+      blockInfo(blockInfo),
+      data(NULL),
+      dirty(true),
+      psRegisterIndex(GL_INVALID_INDEX),
+      vsRegisterIndex(GL_INVALID_INDEX),
+      registerCount(0),
+      registerElement(0)
</ins><span class="cx"> {
</span><del>-    int bytes = gl::UniformInternalSize(type) * elementCount();
-    data = new unsigned char[bytes];
-    memset(data, 0, bytes);
-    dirty = true;
-
-    psRegisterIndex = -1;
-    vsRegisterIndex = -1;
-    registerCount = VariableRowCount(type) * elementCount();
</del><ins>+    // We use data storage for default block uniforms to cache values that are sent to D3D during rendering
+    // Uniform blocks/buffers are treated separately by the Renderer (ES3 path only)
+    if (isInDefaultBlock())
+    {
+        size_t bytes = dataSize();
+        data = new unsigned char[bytes];
+        memset(data, 0, bytes);
+        registerCount = VariableRowCount(type) * elementCount();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-Uniform::~Uniform()
</del><ins>+LinkedUniform::~LinkedUniform()
</ins><span class="cx"> {
</span><span class="cx">     delete[] data;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Uniform::isArray() const
</del><ins>+bool LinkedUniform::isArray() const
</ins><span class="cx"> {
</span><span class="cx">     return arraySize &gt; 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned int Uniform::elementCount() const
</del><ins>+unsigned int LinkedUniform::elementCount() const
</ins><span class="cx"> {
</span><span class="cx">     return arraySize &gt; 0 ? arraySize : 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool LinkedUniform::isReferencedByVertexShader() const
+{
+    return vsRegisterIndex != GL_INVALID_INDEX;
</ins><span class="cx"> }
</span><ins>+
+bool LinkedUniform::isReferencedByFragmentShader() const
+{
+    return psRegisterIndex != GL_INVALID_INDEX;
+}
+
+bool LinkedUniform::isInDefaultBlock() const
+{
+    return blockIndex == -1;
+}
+
+size_t LinkedUniform::dataSize() const
+{
+    ASSERT(type != GL_STRUCT_ANGLEX);
+    return UniformInternalSize(type) * elementCount();
+}
+
+bool LinkedUniform::isSampler() const
+{
+    return IsSampler(type);
+}
+
+UniformBlock::UniformBlock(const std::string &amp;name, unsigned int elementIndex, unsigned int dataSize)
+    : name(name),
+      elementIndex(elementIndex),
+      dataSize(dataSize),
+      psRegisterIndex(GL_INVALID_INDEX),
+      vsRegisterIndex(GL_INVALID_INDEX)
+{
+}
+
+bool UniformBlock::isArrayElement() const
+{
+    return elementIndex != GL_INVALID_INDEX;
+}
+
+bool UniformBlock::isReferencedByVertexShader() const
+{
+    return vsRegisterIndex != GL_INVALID_INDEX;
+}
+
+bool UniformBlock::isReferencedByFragmentShader() const
+{
+    return psRegisterIndex != GL_INVALID_INDEX;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2Uniformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Uniform.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Uniform.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/Uniform.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -11,38 +11,70 @@
</span><span class="cx"> #include &lt;vector&gt;
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/debug.h&quot;
</span><ins>+#include &quot;angletypes.h&quot;
+#include &quot;common/shadervars.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="cx"> 
</span><span class="cx"> // Helper struct representing a single shader uniform
</span><del>-struct Uniform
</del><ins>+struct LinkedUniform
</ins><span class="cx"> {
</span><del>-    Uniform(GLenum type, GLenum precision, const std::string &amp;name, unsigned int arraySize);
</del><ins>+    LinkedUniform(GLenum type, GLenum precision, const std::string &amp;name, unsigned int arraySize, const int blockIndex, const BlockMemberInfo &amp;blockInfo);
</ins><span class="cx"> 
</span><del>-    ~Uniform();
</del><ins>+    ~LinkedUniform();
</ins><span class="cx"> 
</span><span class="cx">     bool isArray() const;
</span><span class="cx">     unsigned int elementCount() const;
</span><ins>+    bool isReferencedByVertexShader() const;
+    bool isReferencedByFragmentShader() const;
+    bool isInDefaultBlock() const;
+    size_t dataSize() const;
+    bool isSampler() const;
</ins><span class="cx"> 
</span><span class="cx">     const GLenum type;
</span><span class="cx">     const GLenum precision;
</span><span class="cx">     const std::string name;
</span><span class="cx">     const unsigned int arraySize;
</span><ins>+    const int blockIndex;
+    const BlockMemberInfo blockInfo;
</ins><span class="cx"> 
</span><span class="cx">     unsigned char *data;
</span><span class="cx">     bool dirty;
</span><span class="cx"> 
</span><del>-    int psRegisterIndex;
-    int vsRegisterIndex;
</del><ins>+    unsigned int psRegisterIndex;
+    unsigned int vsRegisterIndex;
</ins><span class="cx">     unsigned int registerCount;
</span><ins>+
+    // Register &quot;elements&quot; are used for uniform structs in ES3, to appropriately identify single uniforms
+    // inside aggregate types, which are packed according C-like structure rules.
+    unsigned int registerElement;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-typedef std::vector&lt;Uniform*&gt; UniformArray;
</del><ins>+// Helper struct representing a single shader uniform block
+struct UniformBlock
+{
+    // use GL_INVALID_INDEX for non-array elements
+    UniformBlock(const std::string &amp;name, unsigned int elementIndex, unsigned int dataSize);
</ins><span class="cx"> 
</span><ins>+    bool isArrayElement() const;
+    bool isReferencedByVertexShader() const;
+    bool isReferencedByFragmentShader() const;
+
+    const std::string name;
+    const unsigned int elementIndex;
+    const unsigned int dataSize;
+
+    std::vector&lt;unsigned int&gt; memberUniformIndexes;
+
+    unsigned int psRegisterIndex;
+    unsigned int vsRegisterIndex;
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif   // LIBGLESV2_UNIFORM_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2VertexArraycpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexArray.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexArray.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexArray.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+#include &quot;precompiled.h&quot;
+//
+// 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.
+//
+// Implementation of the state class for mananging GLES 3 Vertex Array Objects.
+//
+
+#include &quot;libGLESv2/VertexArray.h&quot;
+#include &quot;libGLESv2/Buffer.h&quot;
+
+namespace gl
+{
+
+VertexArray::VertexArray(rx::Renderer *renderer, GLuint id)
+    : RefCountObject(id)
+{
+}
+
+VertexArray::~VertexArray()
+{
+    for (int i = 0; i &lt; MAX_VERTEX_ATTRIBS; i++)
+    {
+        mVertexAttributes[i].mBoundBuffer.set(NULL);
+    }
+    mElementArrayBuffer.set(NULL);
+}
+
+void VertexArray::detachBuffer(GLuint bufferName)
+{
+    for (int attribute = 0; attribute &lt; MAX_VERTEX_ATTRIBS; attribute++)
+    {
+        if (mVertexAttributes[attribute].mBoundBuffer.id() == bufferName)
+        {
+            mVertexAttributes[attribute].mBoundBuffer.set(NULL);
+        }
+    }
+
+    if (mElementArrayBuffer.id() == bufferName)
+    {
+        mElementArrayBuffer.set(NULL);
+    }
+}
+
+const VertexAttribute&amp; VertexArray::getVertexAttribute(unsigned int attributeIndex) const
+{
+    ASSERT(attributeIndex &lt; MAX_VERTEX_ATTRIBS);
+    return mVertexAttributes[attributeIndex];
+}
+
+void VertexArray::setVertexAttribDivisor(GLuint index, GLuint divisor)
+{
+    ASSERT(index &lt; gl::MAX_VERTEX_ATTRIBS);
+    mVertexAttributes[index].mDivisor = divisor;
+}
+
+void VertexArray::enableAttribute(unsigned int attributeIndex, bool enabledState)
+{
+    ASSERT(attributeIndex &lt; gl::MAX_VERTEX_ATTRIBS);
+    mVertexAttributes[attributeIndex].mArrayEnabled = enabledState;
+}
+
+void VertexArray::setAttributeState(unsigned int attributeIndex, gl::Buffer *boundBuffer, GLint size, GLenum type,
+                                    bool normalized, bool pureInteger, GLsizei stride, const void *pointer)
+{
+    ASSERT(attributeIndex &lt; gl::MAX_VERTEX_ATTRIBS);
+    mVertexAttributes[attributeIndex].setState(boundBuffer, size, type, normalized, pureInteger, stride, pointer);
+}
+
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2VertexArrayh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexArray.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexArray.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexArray.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+//
+// 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.
+//
+// This class contains prototypes for representing GLES 3 Vertex Array Objects:
+//
+//   The buffer objects that are to be used by the vertex stage of the GL are collected
+//   together to form a vertex array object. All state related to the definition of data used
+//   by the vertex processor is encapsulated in a vertex array object.
+//
+
+#ifndef LIBGLESV2_VERTEXARRAY_H_
+#define LIBGLESV2_VERTEXARRAY_H_
+
+#include &quot;common/RefCountObject.h&quot;
+#include &quot;libGLESv2/constants.h&quot;
+#include &quot;libGLESv2/VertexAttribute.h&quot;
+
+namespace rx
+{
+class Renderer;
+}
+
+namespace gl
+{
+class Buffer;
+
+class VertexArray : public RefCountObject
+{
+  public:
+    VertexArray(rx::Renderer *renderer, GLuint id);
+    ~VertexArray();
+
+    const VertexAttribute&amp; getVertexAttribute(unsigned int attributeIndex) const;
+    void detachBuffer(GLuint bufferName);
+    void setVertexAttribDivisor(GLuint index, GLuint divisor);
+    void enableAttribute(unsigned int attributeIndex, bool enabledState);
+    void setAttributeState(unsigned int attributeIndex, gl::Buffer *boundBuffer, GLint size, GLenum type,
+                           bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
+
+    const VertexAttribute* getVertexAttributes() const { return mVertexAttributes; }
+    Buffer *getElementArrayBuffer() const { return mElementArrayBuffer.get(); }
+    void setElementArrayBuffer(Buffer *elementArrayBuffer) { mElementArrayBuffer.set(elementArrayBuffer); }
+    GLuint getElementArrayBufferId() const { return mElementArrayBuffer.id(); }
+
+  private:
+    VertexAttribute mVertexAttributes[MAX_VERTEX_ATTRIBS];
+    BindingPointer&lt;Buffer&gt; mElementArrayBuffer;
+};
+
+}
+
+#endif // LIBGLESV2_VERTEXARRAY_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2VertexAttributeh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexAttribute.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexAttribute.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/VertexAttribute.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,156 @@
</span><ins>+//
+// 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.
+//
+// Helper structure describing a single vertex attribute
+//
+
+#ifndef LIBGLESV2_VERTEXATTRIBUTE_H_
+#define LIBGLESV2_VERTEXATTRIBUTE_H_
+
+#include &quot;libGLESv2/Buffer.h&quot;
+
+namespace gl
+{
+
+class VertexAttribute
+{
+  public:
+    VertexAttribute() : mType(GL_FLOAT), mSize(4), mNormalized(false), mPureInteger(false),
+                        mStride(0), mPointer(NULL), mArrayEnabled(false), mDivisor(0)
+    {
+    }
+
+    int typeSize() const
+    {
+        switch (mType)
+        {
+          case GL_BYTE:                        return mSize * sizeof(GLbyte);
+          case GL_UNSIGNED_BYTE:               return mSize * sizeof(GLubyte);
+          case GL_SHORT:                       return mSize * sizeof(GLshort);
+          case GL_UNSIGNED_SHORT:              return mSize * sizeof(GLushort);
+          case GL_INT:                         return mSize * sizeof(GLint);
+          case GL_UNSIGNED_INT:                return mSize * sizeof(GLuint);
+          case GL_INT_2_10_10_10_REV:          return 4;
+          case GL_UNSIGNED_INT_2_10_10_10_REV: return 4;
+          case GL_FIXED:                       return mSize * sizeof(GLfixed);
+          case GL_HALF_FLOAT:                  return mSize * sizeof(GLhalf);
+          case GL_FLOAT:                       return mSize * sizeof(GLfloat);
+          default: UNREACHABLE();              return mSize * sizeof(GLfloat);
+        }
+    }
+
+    GLsizei stride() const
+    {
+        return (mArrayEnabled ? (mStride ? mStride : typeSize()) : 16);
+    }
+
+    void setState(gl::Buffer *boundBuffer, GLint size, GLenum type, bool normalized,
+                  bool pureInteger, GLsizei stride, const void *pointer)
+    {
+        mBoundBuffer.set(boundBuffer);
+        mSize = size;
+        mType = type;
+        mNormalized = normalized;
+        mPureInteger = pureInteger;
+        mStride = stride;
+        mPointer = pointer;
+    }
+
+    template &lt;typename T&gt;
+    T querySingleParameter(GLenum pname) const
+    {
+        switch (pname)
+        {
+          case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
+            return static_cast&lt;T&gt;(mArrayEnabled ? GL_TRUE : GL_FALSE);
+          case GL_VERTEX_ATTRIB_ARRAY_SIZE:
+            return static_cast&lt;T&gt;(mSize);
+          case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
+            return static_cast&lt;T&gt;(mStride);
+          case GL_VERTEX_ATTRIB_ARRAY_TYPE:
+            return static_cast&lt;T&gt;(mType);
+          case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
+            return static_cast&lt;T&gt;(mNormalized ? GL_TRUE : GL_FALSE);
+          case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
+            return static_cast&lt;T&gt;(mBoundBuffer.id());
+          case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
+            return static_cast&lt;T&gt;(mDivisor);
+          case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
+            return static_cast&lt;T&gt;(mPureInteger ? GL_TRUE : GL_FALSE);
+          default:
+            UNREACHABLE();
+            return static_cast&lt;T&gt;(0);
+        }
+    }
+
+    // From glVertexAttribPointer
+    GLenum mType;
+    GLint mSize;
+    bool mNormalized;
+    bool mPureInteger;
+    GLsizei mStride;   // 0 means natural stride
+
+    union
+    {
+        const void *mPointer;
+        intptr_t mOffset;
+    };
+
+    BindingPointer&lt;Buffer&gt; mBoundBuffer;   // Captured when glVertexAttribPointer is called.
+    bool mArrayEnabled;   // From glEnable/DisableVertexAttribArray
+    unsigned int mDivisor;
+};
+
+struct VertexAttribCurrentValueData
+{
+    union
+    {
+        GLfloat FloatValues[4];
+        GLint IntValues[4];
+        GLuint UnsignedIntValues[4];
+    };
+    GLenum Type;
+
+    void setFloatValues(const GLfloat floatValues[4])
+    {
+        for (unsigned int valueIndex = 0; valueIndex &lt; 4; valueIndex++)
+        {
+            FloatValues[valueIndex] = floatValues[valueIndex];
+        }
+        Type = GL_FLOAT;
+    }
+
+    void setIntValues(const GLint intValues[4])
+    {
+        for (unsigned int valueIndex = 0; valueIndex &lt; 4; valueIndex++)
+        {
+            IntValues[valueIndex] = intValues[valueIndex];
+        }
+        Type = GL_INT;
+    }
+
+    void setUnsignedIntValues(const GLuint unsignedIntValues[4])
+    {
+        for (unsigned int valueIndex = 0; valueIndex &lt; 4; valueIndex++)
+        {
+            UnsignedIntValues[valueIndex] = unsignedIntValues[valueIndex];
+        }
+        Type = GL_UNSIGNED_INT;
+    }
+
+    bool operator==(const VertexAttribCurrentValueData &amp;other)
+    {
+        return (Type == other.Type &amp;&amp; memcmp(FloatValues, other.FloatValues, sizeof(float) * 4) == 0);
+    }
+
+    bool operator!=(const VertexAttribCurrentValueData &amp;other)
+    {
+        return !(*this == other);
+    }
+};
+
+}
+
+#endif // LIBGLESV2_VERTEXATTRIBUTE_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2angletypescpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/angletypes.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/angletypes.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/angletypes.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,177 @@
</span><ins>+#include &quot;precompiled.h&quot;
+//
+// 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.
+//
+
+// angletypes.h : Defines a variety of structures and enum types that are used throughout libGLESv2
+
+#include &quot;libGLESv2/angletypes.h&quot;
+#include &quot;libGLESv2/ProgramBinary.h&quot;
+#include &quot;libGLESv2/VertexAttribute.h&quot;
+
+namespace gl
+{
+
+bool SamplerState::swizzleRequired() const
+{
+    return swizzleRed != GL_RED || swizzleGreen != GL_GREEN ||
+           swizzleBlue != GL_BLUE || swizzleAlpha != GL_ALPHA;
+}
+
+static void MinMax(int a, int b, int *minimum, int *maximum)
+{
+    if (a &lt; b)
+    {
+        *minimum = a;
+        *maximum = b;
+    }
+    else
+    {
+        *minimum = b;
+        *maximum = a;
+    }
+}
+
+bool ClipRectangle(const Rectangle &amp;source, const Rectangle &amp;clip, Rectangle *intersection)
+{
+    int minSourceX, maxSourceX, minSourceY, maxSourceY;
+    MinMax(source.x, source.x + source.width, &amp;minSourceX, &amp;maxSourceX);
+    MinMax(source.y, source.y + source.height, &amp;minSourceY, &amp;maxSourceY);
+
+    int minClipX, maxClipX, minClipY, maxClipY;
+    MinMax(clip.x, clip.x + clip.width, &amp;minClipX, &amp;maxClipX);
+    MinMax(clip.y, clip.y + clip.height, &amp;minClipY, &amp;maxClipY);
+
+    if (minSourceX &gt;= maxClipX || maxSourceX &lt;= minClipX || minSourceY &gt;= maxClipY || maxSourceY &lt;= minClipY)
+    {
+        if (intersection)
+        {
+            intersection-&gt;x = minSourceX;
+            intersection-&gt;y = maxSourceY;
+            intersection-&gt;width = maxSourceX - minSourceX;
+            intersection-&gt;height = maxSourceY - minSourceY;
+        }
+
+        return false;
+    }
+    else
+    {
+        if (intersection)
+        {
+            intersection-&gt;x = std::max(minSourceX, minClipX);
+            intersection-&gt;y = std::max(minSourceY, minClipY);
+            intersection-&gt;width  = std::min(maxSourceX, maxClipX) - std::max(minSourceX, minClipX);
+            intersection-&gt;height = std::min(maxSourceY, maxClipY) - std::max(minSourceY, minClipY);
+        }
+
+        return true;
+    }
+}
+
+VertexFormat::VertexFormat()
+    : mType(GL_NONE),
+      mNormalized(GL_FALSE),
+      mComponents(0),
+      mPureInteger(false)
+{}
+
+VertexFormat::VertexFormat(GLenum type, GLboolean normalized, GLuint components, bool pureInteger)
+    : mType(type),
+      mNormalized(normalized),
+      mComponents(components),
+      mPureInteger(pureInteger)
+{
+    // Float data can not be normalized, so ignore the user setting
+    if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED)
+    {
+        mNormalized = GL_FALSE;
+    }
+}
+
+VertexFormat::VertexFormat(const VertexAttribute &amp;attribute)
+    : mType(attribute.mType),
+      mNormalized(attribute.mNormalized ? GL_TRUE : GL_FALSE),
+      mComponents(attribute.mSize),
+      mPureInteger(attribute.mPureInteger)
+{
+    // Ensure we aren't initializing a vertex format which should be using
+    // the current-value type
+    ASSERT(attribute.mArrayEnabled);
+
+    // Float data can not be normalized, so ignore the user setting
+    if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED)
+    {
+        mNormalized = GL_FALSE;
+    }
+}
+
+VertexFormat::VertexFormat(const VertexAttribute &amp;attribute, GLenum currentValueType)
+    : mType(attribute.mType),
+      mNormalized(attribute.mNormalized ? GL_TRUE : GL_FALSE),
+      mComponents(attribute.mSize),
+      mPureInteger(attribute.mPureInteger)
+{
+    if (!attribute.mArrayEnabled)
+    {
+        mType = currentValueType;
+        mNormalized = GL_FALSE;
+        mComponents = 4;
+        mPureInteger = (currentValueType != GL_FLOAT);
+    }
+
+    // Float data can not be normalized, so ignore the user setting
+    if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED)
+    {
+        mNormalized = GL_FALSE;
+    }
+}
+
+void VertexFormat::GetInputLayout(VertexFormat *inputLayout,
+                                  ProgramBinary *programBinary,
+                                  const VertexAttribute *attributes,
+                                  const gl::VertexAttribCurrentValueData *currentValues)
+{
+    for (unsigned int attributeIndex = 0; attributeIndex &lt; MAX_VERTEX_ATTRIBS; attributeIndex++)
+    {
+        int semanticIndex = programBinary-&gt;getSemanticIndex(attributeIndex);
+
+        if (semanticIndex != -1)
+        {
+            inputLayout[semanticIndex] = VertexFormat(attributes[attributeIndex], currentValues[attributeIndex].Type);
+        }
+    }
+}
+
+bool VertexFormat::operator==(const VertexFormat &amp;other) const
+{
+    return (mType == other.mType                &amp;&amp;
+            mComponents == other.mComponents    &amp;&amp;
+            mNormalized == other.mNormalized    &amp;&amp;
+            mPureInteger == other.mPureInteger  );
+}
+
+bool VertexFormat::operator!=(const VertexFormat &amp;other) const
+{
+    return !(*this == other);
+}
+
+bool VertexFormat::operator&lt;(const VertexFormat&amp; other) const
+{
+    if (mType != other.mType)
+    {
+        return mType &lt; other.mType;
+    }
+    if (mNormalized != other.mNormalized)
+    {
+        return mNormalized &lt; other.mNormalized;
+    }
+    if (mComponents != other.mComponents)
+    {
+        return mComponents &lt; other.mComponents;
+    }
+    return mPureInteger &lt; other.mPureInteger;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2angletypesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/angletypes.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/angletypes.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/angletypes.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -9,13 +9,22 @@
</span><span class="cx"> #ifndef LIBGLESV2_ANGLETYPES_H_
</span><span class="cx"> #define LIBGLESV2_ANGLETYPES_H_
</span><span class="cx"> 
</span><ins>+#include &quot;libGLESv2/constants.h&quot;
+#include &quot;common/RefCountObject.h&quot;
+
</ins><span class="cx"> namespace gl
</span><span class="cx"> {
</span><ins>+class Buffer;
+class ProgramBinary;
+class VertexAttribute;
+struct VertexAttribCurrentValueData;
</ins><span class="cx"> 
</span><span class="cx"> enum TextureType
</span><span class="cx"> {
</span><span class="cx">     TEXTURE_2D,
</span><span class="cx">     TEXTURE_CUBE,
</span><ins>+    TEXTURE_3D,
+    TEXTURE_2D_ARRAY,
</ins><span class="cx"> 
</span><span class="cx">     TEXTURE_TYPE_COUNT,
</span><span class="cx">     TEXTURE_UNKNOWN
</span><span class="lines">@@ -27,22 +36,58 @@
</span><span class="cx">     SAMPLER_VERTEX
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+template &lt;typename T&gt;
</ins><span class="cx"> struct Color
</span><span class="cx"> {
</span><del>-    float red;
-    float green;
-    float blue;
-    float alpha;
</del><ins>+    T red;
+    T green;
+    T blue;
+    T alpha;
+
+    Color() : red(0), green(0), blue(0), alpha(0) { }
+    Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a) { }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+typedef Color&lt;float&gt; ColorF;
+typedef Color&lt;int&gt; ColorI;
+typedef Color&lt;unsigned int&gt; ColorUI;
+
</ins><span class="cx"> struct Rectangle
</span><span class="cx"> {
</span><span class="cx">     int x;
</span><span class="cx">     int y;
</span><span class="cx">     int width;
</span><span class="cx">     int height;
</span><ins>+
+    Rectangle() : x(0), y(0), width(0), height(0) { }
+    Rectangle(int x_in, int y_in, int width_in, int height_in) : x(x_in), y(y_in), width(width_in), height(height_in) { }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+bool ClipRectangle(const Rectangle &amp;source, const Rectangle &amp;clip, Rectangle *intersection);
+
+struct Box
+{
+    int x;
+    int y;
+    int z;
+    int width;
+    int height;
+    int depth;
+
+    Box() : x(0), y(0), z(0), width(0), height(0), depth(0) { }
+    Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in) : x(x_in), y(y_in), z(z_in), width(width_in), height(height_in), depth(depth_in) { }
+};
+
+struct Extents
+{
+    int width;
+    int height;
+    int depth;
+
+    Extents() : width(0), height(0), depth(0) { }
+    Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { }
+};
+
</ins><span class="cx"> struct RasterizerState
</span><span class="cx"> {
</span><span class="cx">     bool cullFace;
</span><span class="lines">@@ -55,6 +100,8 @@
</span><span class="cx"> 
</span><span class="cx">     bool pointDrawMode;
</span><span class="cx">     bool multiSample;
</span><ins>+
+    bool rasterizerDiscard;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct BlendState
</span><span class="lines">@@ -104,26 +151,121 @@
</span><span class="cx">     GLenum magFilter;
</span><span class="cx">     GLenum wrapS;
</span><span class="cx">     GLenum wrapT;
</span><ins>+    GLenum wrapR;
</ins><span class="cx">     float maxAnisotropy;
</span><del>-    int lodOffset;
</del><ins>+
+    GLint baseLevel;
+    GLint maxLevel;
+    GLfloat minLod;
+    GLfloat maxLod;
+
+    GLenum compareMode;
+    GLenum compareFunc;
+
+    GLenum swizzleRed;
+    GLenum swizzleGreen;
+    GLenum swizzleBlue;
+    GLenum swizzleAlpha;
+
+    bool swizzleRequired() const;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct ClearParameters
</span><span class="cx"> {
</span><del>-    GLbitfield mask;
-
-    Color colorClearValue;
</del><ins>+    bool clearColor[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS];
+    ColorF colorFClearValue;
+    ColorI colorIClearValue;
+    ColorUI colorUIClearValue;
+    GLenum colorClearType;
</ins><span class="cx">     bool colorMaskRed;
</span><span class="cx">     bool colorMaskGreen;
</span><span class="cx">     bool colorMaskBlue;
</span><span class="cx">     bool colorMaskAlpha;
</span><span class="cx"> 
</span><ins>+    bool clearDepth;
</ins><span class="cx">     float depthClearValue;
</span><span class="cx"> 
</span><ins>+    bool clearStencil;
</ins><span class="cx">     GLint stencilClearValue;
</span><span class="cx">     GLuint stencilWriteMask;
</span><ins>+
+    bool scissorEnabled;
+    Rectangle scissor;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+struct PixelUnpackState
+{
+    BindingPointer&lt;Buffer&gt; pixelBuffer;
+    GLint alignment;
+
+    PixelUnpackState()
+        : alignment(4)
+    {}
+
+    explicit PixelUnpackState(GLint alignmentIn)
+        : alignment(alignmentIn)
+    {}
+};
+
+struct PixelPackState
+{
+    BindingPointer&lt;Buffer&gt; pixelBuffer;
+    GLint alignment;
+    bool reverseRowOrder;
+
+    PixelPackState()
+        : alignment(4),
+          reverseRowOrder(false)
+    {}
+
+    explicit PixelPackState(GLint alignmentIn, bool reverseRowOrderIn)
+        : alignment(alignmentIn),
+          reverseRowOrder(reverseRowOrderIn)
+    {}
+};
+
+struct VertexFormat
+{
+    GLenum      mType;
+    GLboolean   mNormalized;
+    GLuint      mComponents;
+    bool        mPureInteger;
+
+    VertexFormat();
+    VertexFormat(GLenum type, GLboolean normalized, GLuint components, bool pureInteger);
+    explicit VertexFormat(const VertexAttribute &amp;attribute);
+    VertexFormat(const VertexAttribute &amp;attribute, GLenum currentValueType);
+
+    static void GetInputLayout(VertexFormat *inputLayout,
+                               ProgramBinary *programBinary,
+                               const VertexAttribute *attributes,
+                               const gl::VertexAttribCurrentValueData *currentValues);
+
+    bool operator==(const VertexFormat &amp;other) const;
+    bool operator!=(const VertexFormat &amp;other) const;
+    bool operator&lt;(const VertexFormat&amp; other) const;
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+namespace rx
+{
+
+enum VertexConversionType
+{
+    VERTEX_CONVERT_NONE = 0,
+    VERTEX_CONVERT_CPU  = 1,
+    VERTEX_CONVERT_GPU  = 2,
+    VERTEX_CONVERT_BOTH = 3
+};
+
+enum D3DWorkaroundType
+{
+    ANGLE_D3D_WORKAROUND_NONE,
+    ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION,
+    ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION
+};
+
+}
+
</ins><span class="cx"> #endif // LIBGLESV2_ANGLETYPES_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2formatutilscpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/formatutils.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/formatutils.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/formatutils.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,1812 @@
</span><ins>+#include &quot;precompiled.h&quot;
+//
+// 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.
+//
+
+// formatutils.cpp: Queries for GL image formats.
+
+#include &quot;common/mathutil.h&quot;
+#include &quot;libGLESv2/formatutils.h&quot;
+#include &quot;libGLESv2/Context.h&quot;
+#include &quot;libGLESv2/Framebuffer.h&quot;
+#include &quot;libGLESv2/renderer/Renderer.h&quot;
+#include &quot;libGLESv2/renderer/imageformats.h&quot;
+#include &quot;libGLESv2/renderer/copyimage.h&quot;
+
+namespace gl
+{
+
+// ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the implementation
+// can decide the true, sized, internal format. The ES2FormatMap determines the internal format for all valid
+// format and type combinations.
+
+struct FormatTypeInfo
+{
+    GLenum mInternalFormat;
+    ColorWriteFunction mColorWriteFunction;
+
+    FormatTypeInfo(GLenum internalFormat, ColorWriteFunction writeFunc)
+        : mInternalFormat(internalFormat), mColorWriteFunction(writeFunc)
+    { }
+};
+
+typedef std::pair&lt;GLenum, GLenum&gt; FormatTypePair;
+typedef std::pair&lt;FormatTypePair, FormatTypeInfo&gt; FormatPair;
+typedef std::map&lt;FormatTypePair, FormatTypeInfo&gt; FormatMap;
+
+// A helper function to insert data into the format map with fewer characters.
+static inline void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLenum internalFormat, ColorWriteFunction writeFunc)
+{
+    map-&gt;insert(FormatPair(FormatTypePair(format, type), FormatTypeInfo(internalFormat, writeFunc)));
+}
+
+FormatMap BuildES2FormatMap()
+{
+    FormatMap map;
+
+    using namespace rx;
+
+    //                       | Format                            | Type                             | Internal format                   | Color write function             |
+    InsertFormatMapping(&amp;map, GL_ALPHA,                           GL_UNSIGNED_BYTE,                  GL_ALPHA8_EXT,                      WriteColor&lt;A8, GLfloat&gt;           );
+    InsertFormatMapping(&amp;map, GL_ALPHA,                           GL_FLOAT,                          GL_ALPHA32F_EXT,                    WriteColor&lt;A32F, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_ALPHA,                           GL_HALF_FLOAT_OES,                 GL_ALPHA16F_EXT,                    WriteColor&lt;A16F, GLfloat&gt;         );
+
+    InsertFormatMapping(&amp;map, GL_LUMINANCE,                       GL_UNSIGNED_BYTE,                  GL_LUMINANCE8_EXT,                  WriteColor&lt;L8, GLfloat&gt;           );
+    InsertFormatMapping(&amp;map, GL_LUMINANCE,                       GL_FLOAT,                          GL_LUMINANCE32F_EXT,                WriteColor&lt;L32F, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_LUMINANCE,                       GL_HALF_FLOAT_OES,                 GL_LUMINANCE16F_EXT,                WriteColor&lt;L16F, GLfloat&gt;         );
+
+    InsertFormatMapping(&amp;map, GL_LUMINANCE_ALPHA,                 GL_UNSIGNED_BYTE,                  GL_LUMINANCE8_ALPHA8_EXT,           WriteColor&lt;L8A8, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_LUMINANCE_ALPHA,                 GL_FLOAT,                          GL_LUMINANCE_ALPHA32F_EXT,          WriteColor&lt;L32A32F, GLfloat&gt;      );
+    InsertFormatMapping(&amp;map, GL_LUMINANCE_ALPHA,                 GL_HALF_FLOAT_OES,                 GL_LUMINANCE_ALPHA16F_EXT,          WriteColor&lt;L16A16F, GLfloat&gt;      );
+
+    InsertFormatMapping(&amp;map, GL_RED,                             GL_UNSIGNED_BYTE,                  GL_R8_EXT,                          WriteColor&lt;R8, GLfloat&gt;           );
+    InsertFormatMapping(&amp;map, GL_RED,                             GL_FLOAT,                          GL_R32F_EXT,                        WriteColor&lt;R32F, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_RED,                             GL_HALF_FLOAT_OES,                 GL_R16F_EXT,                        WriteColor&lt;R16F, GLfloat&gt;         );
+
+    InsertFormatMapping(&amp;map, GL_RG,                              GL_UNSIGNED_BYTE,                  GL_RG8_EXT,                         WriteColor&lt;R8G8, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_RG,                              GL_FLOAT,                          GL_RG32F_EXT,                       WriteColor&lt;R32G32F, GLfloat&gt;      );
+    InsertFormatMapping(&amp;map, GL_RG,                              GL_HALF_FLOAT_OES,                 GL_RG16F_EXT,                       WriteColor&lt;R16G16F, GLfloat&gt;      );
+
+    InsertFormatMapping(&amp;map, GL_RGB,                             GL_UNSIGNED_BYTE,                  GL_RGB8_OES,                        WriteColor&lt;R8G8B8, GLfloat&gt;       );
+    InsertFormatMapping(&amp;map, GL_RGB,                             GL_UNSIGNED_SHORT_5_6_5,           GL_RGB565,                          WriteColor&lt;R5G6B5, GLfloat&gt;       );
+    InsertFormatMapping(&amp;map, GL_RGB,                             GL_FLOAT,                          GL_RGB32F_EXT,                      WriteColor&lt;R32G32B32F, GLfloat&gt;   );
+    InsertFormatMapping(&amp;map, GL_RGB,                             GL_HALF_FLOAT_OES,                 GL_RGB16F_EXT,                      WriteColor&lt;R16G16B16F, GLfloat&gt;   );
+
+    InsertFormatMapping(&amp;map, GL_RGBA,                            GL_UNSIGNED_BYTE,                  GL_RGBA8_OES,                       WriteColor&lt;R8G8B8A8, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGBA,                            GL_UNSIGNED_SHORT_4_4_4_4,         GL_RGBA4,                           WriteColor&lt;R4G4B4A4, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGBA,                            GL_UNSIGNED_SHORT_5_5_5_1,         GL_RGB5_A1,                         WriteColor&lt;R5G5B5A1, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGBA,                            GL_FLOAT,                          GL_RGBA32F_EXT,                     WriteColor&lt;R32G32B32A32F, GLfloat&gt;);
+    InsertFormatMapping(&amp;map, GL_RGBA,                            GL_HALF_FLOAT_OES,                 GL_RGBA16F_EXT,                     WriteColor&lt;R16G16B16A16F, GLfloat&gt;);
+
+    InsertFormatMapping(&amp;map, GL_BGRA_EXT,                        GL_UNSIGNED_BYTE,                  GL_BGRA8_EXT,                       WriteColor&lt;B8G8R8A8, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_BGRA_EXT,                        GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX,                    WriteColor&lt;B4G4R4A4, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_BGRA_EXT,                        GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX,                  WriteColor&lt;B5G5R5A1, GLfloat&gt;     );
+
+    InsertFormatMapping(&amp;map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,    GL_UNSIGNED_BYTE,                  GL_COMPRESSED_RGB_S3TC_DXT1_EXT,    NULL                              );
+    InsertFormatMapping(&amp;map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,   GL_UNSIGNED_BYTE,                  GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,   NULL                              );
+    InsertFormatMapping(&amp;map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE,                  GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, NULL                              );
+    InsertFormatMapping(&amp;map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE,                  GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, NULL                              );
+
+    InsertFormatMapping(&amp;map, GL_DEPTH_COMPONENT,                 GL_UNSIGNED_SHORT,                 GL_DEPTH_COMPONENT16,               NULL                              );
+    InsertFormatMapping(&amp;map, GL_DEPTH_COMPONENT,                 GL_UNSIGNED_INT,                   GL_DEPTH_COMPONENT32_OES,           NULL                              );
+
+    InsertFormatMapping(&amp;map, GL_DEPTH_STENCIL_OES,               GL_UNSIGNED_INT_24_8_OES,          GL_DEPTH24_STENCIL8_OES,            NULL                              );
+
+    return map;
+}
+
+FormatMap BuildES3FormatMap()
+{
+    FormatMap map;
+
+    using namespace rx;
+
+    //                       | Format               | Type                             | Internal format          | Color write function             |
+    InsertFormatMapping(&amp;map, GL_RGBA,               GL_UNSIGNED_BYTE,                  GL_RGBA8,                  WriteColor&lt;R8G8B8A8, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGBA,               GL_BYTE,                           GL_RGBA8_SNORM,            WriteColor&lt;R8G8B8A8S, GLfloat&gt;    );
+    InsertFormatMapping(&amp;map, GL_RGBA,               GL_UNSIGNED_SHORT_4_4_4_4,         GL_RGBA4,                  WriteColor&lt;R4G4B4A4, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGBA,               GL_UNSIGNED_SHORT_5_5_5_1,         GL_RGB5_A1,                WriteColor&lt;R5G5B5A1, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGBA,               GL_UNSIGNED_INT_2_10_10_10_REV,    GL_RGB10_A2,               WriteColor&lt;R10G10B10A2, GLfloat&gt;  );
+    InsertFormatMapping(&amp;map, GL_RGBA,               GL_FLOAT,                          GL_RGBA32F,                WriteColor&lt;R32G32B32A32F, GLfloat&gt;);
+    InsertFormatMapping(&amp;map, GL_RGBA,               GL_HALF_FLOAT,                     GL_RGBA16F,                WriteColor&lt;R16G16B16A16F, GLfloat&gt;);
+
+    InsertFormatMapping(&amp;map, GL_RGBA_INTEGER,       GL_UNSIGNED_BYTE,                  GL_RGBA8UI,                WriteColor&lt;R8G8B8A8, GLuint&gt;      );
+    InsertFormatMapping(&amp;map, GL_RGBA_INTEGER,       GL_BYTE,                           GL_RGBA8I,                 WriteColor&lt;R8G8B8A8S, GLint&gt;      );
+    InsertFormatMapping(&amp;map, GL_RGBA_INTEGER,       GL_UNSIGNED_SHORT,                 GL_RGBA16UI,               WriteColor&lt;R16G16B16A16, GLuint&gt;  );
+    InsertFormatMapping(&amp;map, GL_RGBA_INTEGER,       GL_SHORT,                          GL_RGBA16I,                WriteColor&lt;R16G16B16A16S, GLint&gt;  );
+    InsertFormatMapping(&amp;map, GL_RGBA_INTEGER,       GL_UNSIGNED_INT,                   GL_RGBA32UI,               WriteColor&lt;R32G32B32A32, GLuint&gt;  );
+    InsertFormatMapping(&amp;map, GL_RGBA_INTEGER,       GL_INT,                            GL_RGBA32I,                WriteColor&lt;R32G32B32A32S, GLint&gt;  );
+    InsertFormatMapping(&amp;map, GL_RGBA_INTEGER,       GL_UNSIGNED_INT_2_10_10_10_REV,    GL_RGB10_A2UI,             WriteColor&lt;R10G10B10A2, GLuint&gt;   );
+
+    InsertFormatMapping(&amp;map, GL_RGB,                GL_UNSIGNED_BYTE,                  GL_RGB8,                   WriteColor&lt;R8G8B8, GLfloat&gt;       );
+    InsertFormatMapping(&amp;map, GL_RGB,                GL_BYTE,                           GL_RGB8_SNORM,             WriteColor&lt;R8G8B8S, GLfloat&gt;      );
+    InsertFormatMapping(&amp;map, GL_RGB,                GL_UNSIGNED_SHORT_5_6_5,           GL_RGB565,                 WriteColor&lt;R5G6B5, GLfloat&gt;       );
+    InsertFormatMapping(&amp;map, GL_RGB,                GL_UNSIGNED_INT_10F_11F_11F_REV,   GL_R11F_G11F_B10F,         WriteColor&lt;R11G11B10F, GLfloat&gt;   );
+    InsertFormatMapping(&amp;map, GL_RGB,                GL_UNSIGNED_INT_5_9_9_9_REV,       GL_RGB9_E5,                WriteColor&lt;R9G9B9E5, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGB,                GL_FLOAT,                          GL_RGB32F,                 WriteColor&lt;R32G32B32F, GLfloat&gt;   );
+    InsertFormatMapping(&amp;map, GL_RGB,                GL_HALF_FLOAT,                     GL_RGB16F,                 WriteColor&lt;R16G16B16F, GLfloat&gt;   );
+
+    InsertFormatMapping(&amp;map, GL_RGB_INTEGER,        GL_UNSIGNED_BYTE,                  GL_RGB8UI,                 WriteColor&lt;R8G8B8, GLuint&gt;        );
+    InsertFormatMapping(&amp;map, GL_RGB_INTEGER,        GL_BYTE,                           GL_RGB8I,                  WriteColor&lt;R8G8B8S, GLint&gt;        );
+    InsertFormatMapping(&amp;map, GL_RGB_INTEGER,        GL_UNSIGNED_SHORT,                 GL_RGB16UI,                WriteColor&lt;R16G16B16, GLuint&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGB_INTEGER,        GL_SHORT,                          GL_RGB16I,                 WriteColor&lt;R16G16B16S, GLint&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGB_INTEGER,        GL_UNSIGNED_INT,                   GL_RGB32UI,                WriteColor&lt;R32G32B32, GLuint&gt;     );
+    InsertFormatMapping(&amp;map, GL_RGB_INTEGER,        GL_INT,                            GL_RGB32I,                 WriteColor&lt;R32G32B32S, GLint&gt;     );
+
+    InsertFormatMapping(&amp;map, GL_RG,                 GL_UNSIGNED_BYTE,                  GL_RG8,                    WriteColor&lt;R8G8, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_RG,                 GL_BYTE,                           GL_RG8_SNORM,              WriteColor&lt;R8G8S, GLfloat&gt;        );
+    InsertFormatMapping(&amp;map, GL_RG,                 GL_FLOAT,                          GL_RG32F,                  WriteColor&lt;R32G32F, GLfloat&gt;      );
+    InsertFormatMapping(&amp;map, GL_RG,                 GL_HALF_FLOAT,                     GL_RG16F,                  WriteColor&lt;R16G16F, GLfloat&gt;      );
+
+    InsertFormatMapping(&amp;map, GL_RG_INTEGER,         GL_UNSIGNED_BYTE,                  GL_RG8UI,                  WriteColor&lt;R8G8, GLuint&gt;          );
+    InsertFormatMapping(&amp;map, GL_RG_INTEGER,         GL_BYTE,                           GL_RG8I,                   WriteColor&lt;R8G8S, GLint&gt;          );
+    InsertFormatMapping(&amp;map, GL_RG_INTEGER,         GL_UNSIGNED_SHORT,                 GL_RG16UI,                 WriteColor&lt;R16G16, GLuint&gt;        );
+    InsertFormatMapping(&amp;map, GL_RG_INTEGER,         GL_SHORT,                          GL_RG16I,                  WriteColor&lt;R16G16S, GLint&gt;        );
+    InsertFormatMapping(&amp;map, GL_RG_INTEGER,         GL_UNSIGNED_INT,                   GL_RG32UI,                 WriteColor&lt;R32G32, GLuint&gt;        );
+    InsertFormatMapping(&amp;map, GL_RG_INTEGER,         GL_INT,                            GL_RG32I,                  WriteColor&lt;R32G32S, GLint&gt;        );
+
+    InsertFormatMapping(&amp;map, GL_RED,                GL_UNSIGNED_BYTE,                  GL_R8,                     WriteColor&lt;R8, GLfloat&gt;           );
+    InsertFormatMapping(&amp;map, GL_RED,                GL_BYTE,                           GL_R8_SNORM,               WriteColor&lt;R8S, GLfloat&gt;          );
+    InsertFormatMapping(&amp;map, GL_RED,                GL_FLOAT,                          GL_R32F,                   WriteColor&lt;R32F, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_RED,                GL_HALF_FLOAT,                     GL_R16F,                   WriteColor&lt;R16F, GLfloat&gt;         );
+
+    InsertFormatMapping(&amp;map, GL_RED_INTEGER,        GL_UNSIGNED_BYTE,                  GL_R8UI,                   WriteColor&lt;R8, GLuint&gt;            );
+    InsertFormatMapping(&amp;map, GL_RED_INTEGER,        GL_BYTE,                           GL_R8I,                    WriteColor&lt;R8S, GLint&gt;            );
+    InsertFormatMapping(&amp;map, GL_RED_INTEGER,        GL_UNSIGNED_SHORT,                 GL_R16UI,                  WriteColor&lt;R16, GLuint&gt;           );
+    InsertFormatMapping(&amp;map, GL_RED_INTEGER,        GL_SHORT,                          GL_R16I,                   WriteColor&lt;R16S, GLint&gt;           );
+    InsertFormatMapping(&amp;map, GL_RED_INTEGER,        GL_UNSIGNED_INT,                   GL_R32UI,                  WriteColor&lt;R32, GLuint&gt;           );
+    InsertFormatMapping(&amp;map, GL_RED_INTEGER,        GL_INT,                            GL_R32I,                   WriteColor&lt;R32S, GLint&gt;           );
+
+    InsertFormatMapping(&amp;map, GL_LUMINANCE_ALPHA,    GL_UNSIGNED_BYTE,                  GL_LUMINANCE8_ALPHA8_EXT,  WriteColor&lt;L8A8, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_LUMINANCE,          GL_UNSIGNED_BYTE,                  GL_LUMINANCE8_EXT,         WriteColor&lt;L8, GLfloat&gt;           );
+    InsertFormatMapping(&amp;map, GL_ALPHA,              GL_UNSIGNED_BYTE,                  GL_ALPHA8_EXT,             WriteColor&lt;A8, GLfloat&gt;           );
+    InsertFormatMapping(&amp;map, GL_LUMINANCE_ALPHA,    GL_FLOAT,                          GL_LUMINANCE_ALPHA32F_EXT, WriteColor&lt;L32A32F, GLfloat&gt;      );
+    InsertFormatMapping(&amp;map, GL_LUMINANCE,          GL_FLOAT,                          GL_LUMINANCE32F_EXT,       WriteColor&lt;L32F, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_ALPHA,              GL_FLOAT,                          GL_ALPHA32F_EXT,           WriteColor&lt;A32F, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_LUMINANCE_ALPHA,    GL_HALF_FLOAT,                     GL_LUMINANCE_ALPHA16F_EXT, WriteColor&lt;L16A16F, GLfloat&gt;      );
+    InsertFormatMapping(&amp;map, GL_LUMINANCE,          GL_HALF_FLOAT,                     GL_LUMINANCE16F_EXT,       WriteColor&lt;L16F, GLfloat&gt;         );
+    InsertFormatMapping(&amp;map, GL_ALPHA,              GL_HALF_FLOAT,                     GL_ALPHA16F_EXT,           WriteColor&lt;A16F, GLfloat&gt;         );
+
+    InsertFormatMapping(&amp;map, GL_BGRA_EXT,           GL_UNSIGNED_BYTE,                  GL_BGRA8_EXT,              WriteColor&lt;B8G8R8A8, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_BGRA_EXT,           GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX,           WriteColor&lt;B4G4R4A4, GLfloat&gt;     );
+    InsertFormatMapping(&amp;map, GL_BGRA_EXT,           GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX,         WriteColor&lt;B5G5R5A1, GLfloat&gt;     );
+
+    InsertFormatMapping(&amp;map, GL_DEPTH_COMPONENT,    GL_UNSIGNED_SHORT,                 GL_DEPTH_COMPONENT16,      NULL                              );
+    InsertFormatMapping(&amp;map, GL_DEPTH_COMPONENT,    GL_UNSIGNED_INT,                   GL_DEPTH_COMPONENT24,      NULL                              );
+    InsertFormatMapping(&amp;map, GL_DEPTH_COMPONENT,    GL_FLOAT,                          GL_DEPTH_COMPONENT32F,     NULL                              );
+
+    InsertFormatMapping(&amp;map, GL_DEPTH_STENCIL,      GL_UNSIGNED_INT_24_8,              GL_DEPTH24_STENCIL8,       NULL                              );
+    InsertFormatMapping(&amp;map, GL_DEPTH_STENCIL,      GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_DEPTH32F_STENCIL8,      NULL                              );
+
+    return map;
+}
+
+static const FormatMap &amp;GetFormatMap(GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        static const FormatMap formats = BuildES2FormatMap();
+        return formats;
+    }
+    else if (clientVersion == 3)
+    {
+        static const FormatMap formats = BuildES3FormatMap();
+        return formats;
+    }
+    else
+    {
+        UNREACHABLE();
+        static FormatMap emptyMap;
+        return emptyMap;
+    }
+}
+
+struct FormatInfo
+{
+    GLenum mInternalformat;
+    GLenum mFormat;
+    GLenum mType;
+
+    FormatInfo(GLenum internalformat, GLenum format, GLenum type)
+        : mInternalformat(internalformat), mFormat(format), mType(type) { }
+
+    bool operator&lt;(const FormatInfo&amp; other) const
+    {
+        return memcmp(this, &amp;other, sizeof(FormatInfo)) &lt; 0;
+    }
+};
+
+// ES3 has a specific set of permutations of internal formats, formats and types which are acceptable.
+typedef std::set&lt;FormatInfo&gt; ES3FormatSet;
+
+ES3FormatSet BuildES3FormatSet()
+{
+    ES3FormatSet set;
+
+    // Format combinations from ES 3.0.1 spec, table 3.2
+
+    //                   | Internal format      | Format            | Type                            |
+    //                   |                      |                   |                                 |
+    set.insert(FormatInfo(GL_RGBA8,              GL_RGBA,            GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RGB5_A1,            GL_RGBA,            GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RGBA4,              GL_RGBA,            GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_SRGB8_ALPHA8,       GL_RGBA,            GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RGBA8_SNORM,        GL_RGBA,            GL_BYTE                          ));
+    set.insert(FormatInfo(GL_RGBA4,              GL_RGBA,            GL_UNSIGNED_SHORT_4_4_4_4        ));
+    set.insert(FormatInfo(GL_RGB10_A2,           GL_RGBA,            GL_UNSIGNED_INT_2_10_10_10_REV   ));
+    set.insert(FormatInfo(GL_RGB5_A1,            GL_RGBA,            GL_UNSIGNED_INT_2_10_10_10_REV   ));
+    set.insert(FormatInfo(GL_RGB5_A1,            GL_RGBA,            GL_UNSIGNED_SHORT_5_5_5_1        ));
+    set.insert(FormatInfo(GL_RGBA16F,            GL_RGBA,            GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_RGBA32F,            GL_RGBA,            GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_RGBA16F,            GL_RGBA,            GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_RGBA8UI,            GL_RGBA_INTEGER,    GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RGBA8I,             GL_RGBA_INTEGER,    GL_BYTE                          ));
+    set.insert(FormatInfo(GL_RGBA16UI,           GL_RGBA_INTEGER,    GL_UNSIGNED_SHORT                ));
+    set.insert(FormatInfo(GL_RGBA16I,            GL_RGBA_INTEGER,    GL_SHORT                         ));
+    set.insert(FormatInfo(GL_RGBA32UI,           GL_RGBA_INTEGER,    GL_UNSIGNED_INT                  ));
+    set.insert(FormatInfo(GL_RGBA32I,            GL_RGBA_INTEGER,    GL_INT                           ));
+    set.insert(FormatInfo(GL_RGB10_A2UI,         GL_RGBA_INTEGER,    GL_UNSIGNED_INT_2_10_10_10_REV   ));
+    set.insert(FormatInfo(GL_RGB8,               GL_RGB,             GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RGB565,             GL_RGB,             GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_SRGB8,              GL_RGB,             GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RGB8_SNORM,         GL_RGB,             GL_BYTE                          ));
+    set.insert(FormatInfo(GL_RGB565,             GL_RGB,             GL_UNSIGNED_SHORT_5_6_5          ));
+    set.insert(FormatInfo(GL_R11F_G11F_B10F,     GL_RGB,             GL_UNSIGNED_INT_10F_11F_11F_REV  ));
+    set.insert(FormatInfo(GL_RGB9_E5,            GL_RGB,             GL_UNSIGNED_INT_5_9_9_9_REV      ));
+    set.insert(FormatInfo(GL_RGB16F,             GL_RGB,             GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_R11F_G11F_B10F,     GL_RGB,             GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_RGB9_E5,            GL_RGB,             GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_RGB32F,             GL_RGB,             GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_RGB16F,             GL_RGB,             GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_R11F_G11F_B10F,     GL_RGB,             GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_RGB9_E5,            GL_RGB,             GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_RGB8UI,             GL_RGB_INTEGER,     GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RGB8I,              GL_RGB_INTEGER,     GL_BYTE                          ));
+    set.insert(FormatInfo(GL_RGB16UI,            GL_RGB_INTEGER,     GL_UNSIGNED_SHORT                ));
+    set.insert(FormatInfo(GL_RGB16I,             GL_RGB_INTEGER,     GL_SHORT                         ));
+    set.insert(FormatInfo(GL_RGB32UI,            GL_RGB_INTEGER,     GL_UNSIGNED_INT                  ));
+    set.insert(FormatInfo(GL_RGB32I,             GL_RGB_INTEGER,     GL_INT                           ));
+    set.insert(FormatInfo(GL_RG8,                GL_RG,              GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RG8_SNORM,          GL_RG,              GL_BYTE                          ));
+    set.insert(FormatInfo(GL_RG16F,              GL_RG,              GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_RG32F,              GL_RG,              GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_RG16F,              GL_RG,              GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_RG8UI,              GL_RG_INTEGER,      GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RG8I,               GL_RG_INTEGER,      GL_BYTE                          ));
+    set.insert(FormatInfo(GL_RG16UI,             GL_RG_INTEGER,      GL_UNSIGNED_SHORT                ));
+    set.insert(FormatInfo(GL_RG16I,              GL_RG_INTEGER,      GL_SHORT                         ));
+    set.insert(FormatInfo(GL_RG32UI,             GL_RG_INTEGER,      GL_UNSIGNED_INT                  ));
+    set.insert(FormatInfo(GL_RG32I,              GL_RG_INTEGER,      GL_INT                           ));
+    set.insert(FormatInfo(GL_R8,                 GL_RED,             GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_R8_SNORM,           GL_RED,             GL_BYTE                          ));
+    set.insert(FormatInfo(GL_R16F,               GL_RED,             GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_R32F,               GL_RED,             GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_R16F,               GL_RED,             GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_R8UI,               GL_RED_INTEGER,     GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_R8I,                GL_RED_INTEGER,     GL_BYTE                          ));
+    set.insert(FormatInfo(GL_R16UI,              GL_RED_INTEGER,     GL_UNSIGNED_SHORT                ));
+    set.insert(FormatInfo(GL_R16I,               GL_RED_INTEGER,     GL_SHORT                         ));
+    set.insert(FormatInfo(GL_R32UI,              GL_RED_INTEGER,     GL_UNSIGNED_INT                  ));
+    set.insert(FormatInfo(GL_R32I,               GL_RED_INTEGER,     GL_INT                           ));
+
+    // Unsized formats
+    set.insert(FormatInfo(GL_RGBA,               GL_RGBA,            GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RGBA,               GL_RGBA,            GL_UNSIGNED_SHORT_4_4_4_4        ));
+    set.insert(FormatInfo(GL_RGBA,               GL_RGBA,            GL_UNSIGNED_SHORT_5_5_5_1        ));
+    set.insert(FormatInfo(GL_RGB,                GL_RGB,             GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_RGB,                GL_RGB,             GL_UNSIGNED_SHORT_5_6_5          ));
+    set.insert(FormatInfo(GL_LUMINANCE_ALPHA,    GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_LUMINANCE,          GL_LUMINANCE,       GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_ALPHA,              GL_ALPHA,           GL_UNSIGNED_BYTE                 ));
+
+    // Depth stencil formats
+    set.insert(FormatInfo(GL_DEPTH_COMPONENT16,  GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT                ));
+    set.insert(FormatInfo(GL_DEPTH_COMPONENT24,  GL_DEPTH_COMPONENT, GL_UNSIGNED_INT                  ));
+    set.insert(FormatInfo(GL_DEPTH_COMPONENT16,  GL_DEPTH_COMPONENT, GL_UNSIGNED_INT                  ));
+    set.insert(FormatInfo(GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_DEPTH24_STENCIL8,   GL_DEPTH_STENCIL,   GL_UNSIGNED_INT_24_8             ));
+    set.insert(FormatInfo(GL_DEPTH32F_STENCIL8,  GL_DEPTH_STENCIL,   GL_FLOAT_32_UNSIGNED_INT_24_8_REV));
+
+    // From GL_OES_texture_float
+    set.insert(FormatInfo(GL_LUMINANCE_ALPHA,    GL_LUMINANCE_ALPHA, GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_LUMINANCE,          GL_LUMINANCE,       GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_ALPHA,              GL_ALPHA,           GL_FLOAT                         ));
+
+    // From GL_OES_texture_half_float
+    set.insert(FormatInfo(GL_LUMINANCE_ALPHA,    GL_LUMINANCE_ALPHA, GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_LUMINANCE,          GL_LUMINANCE,       GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_ALPHA,              GL_ALPHA,           GL_HALF_FLOAT                    ));
+
+    // From GL_EXT_texture_format_BGRA8888
+    set.insert(FormatInfo(GL_BGRA_EXT,           GL_BGRA_EXT,        GL_UNSIGNED_BYTE                 ));
+
+    // From GL_EXT_texture_storage
+    //                   | Internal format          | Format            | Type                            |
+    //                   |                          |                   |                                 |
+    set.insert(FormatInfo(GL_ALPHA8_EXT,             GL_ALPHA,           GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_LUMINANCE8_EXT,         GL_LUMINANCE,       GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_LUMINANCE8_ALPHA8_EXT,  GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_ALPHA32F_EXT,           GL_ALPHA,           GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_LUMINANCE32F_EXT,       GL_LUMINANCE,       GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE_ALPHA, GL_FLOAT                         ));
+    set.insert(FormatInfo(GL_ALPHA16F_EXT,           GL_ALPHA,           GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_LUMINANCE16F_EXT,       GL_LUMINANCE,       GL_HALF_FLOAT                    ));
+    set.insert(FormatInfo(GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT                    ));
+
+    // From GL_EXT_texture_storage and GL_EXT_texture_format_BGRA8888
+    set.insert(FormatInfo(GL_BGRA8_EXT,              GL_BGRA_EXT,        GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_BGRA4_ANGLEX,           GL_BGRA_EXT,        GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT));
+    set.insert(FormatInfo(GL_BGRA4_ANGLEX,           GL_BGRA_EXT,        GL_UNSIGNED_BYTE                 ));
+    set.insert(FormatInfo(GL_BGR5_A1_ANGLEX,         GL_BGRA_EXT,        GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT));
+    set.insert(FormatInfo(GL_BGR5_A1_ANGLEX,         GL_BGRA_EXT,        GL_UNSIGNED_BYTE                 ));
+
+    // From GL_ANGLE_depth_texture
+    set.insert(FormatInfo(GL_DEPTH_COMPONENT32_OES,  GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_24_8_OES         ));
+
+    // Compressed formats
+    // From ES 3.0.1 spec, table 3.16
+    //                   | Internal format                             | Format                                      | Type           |
+    //                   |                                             |                                             |                |
+    set.insert(FormatInfo(GL_COMPRESSED_R11_EAC,                        GL_COMPRESSED_R11_EAC,                        GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_R11_EAC,                        GL_COMPRESSED_R11_EAC,                        GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_SIGNED_R11_EAC,                 GL_COMPRESSED_SIGNED_R11_EAC,                 GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_RG11_EAC,                       GL_COMPRESSED_RG11_EAC,                       GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_SIGNED_RG11_EAC,                GL_COMPRESSED_SIGNED_RG11_EAC,                GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_RGB8_ETC2,                      GL_COMPRESSED_RGB8_ETC2,                      GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_SRGB8_ETC2,                     GL_COMPRESSED_SRGB8_ETC2,                     GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,  GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,  GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_RGBA8_ETC2_EAC,                 GL_COMPRESSED_RGBA8_ETC2_EAC,                 GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,          GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,          GL_UNSIGNED_BYTE));
+
+
+    // From GL_EXT_texture_compression_dxt1
+    set.insert(FormatInfo(GL_COMPRESSED_RGB_S3TC_DXT1_EXT,              GL_COMPRESSED_RGB_S3TC_DXT1_EXT,              GL_UNSIGNED_BYTE));
+    set.insert(FormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,             GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,             GL_UNSIGNED_BYTE));
+
+    // From GL_ANGLE_texture_compression_dxt3
+    set.insert(FormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,           GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,           GL_UNSIGNED_BYTE));
+
+    // From GL_ANGLE_texture_compression_dxt5
+    set.insert(FormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,           GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,           GL_UNSIGNED_BYTE));
+
+    return set;
+}
+
+static const ES3FormatSet &amp;GetES3FormatSet()
+{
+    static const ES3FormatSet es3FormatSet = BuildES3FormatSet();
+    return es3FormatSet;
+}
+
+// Map of sizes of input types
+struct TypeInfo
+{
+    GLuint mTypeBytes;
+    bool mSpecialInterpretation;
+
+    TypeInfo()
+        : mTypeBytes(0), mSpecialInterpretation(false) { }
+
+    TypeInfo(GLuint typeBytes, bool specialInterpretation)
+        : mTypeBytes(typeBytes), mSpecialInterpretation(specialInterpretation) { }
+
+    bool operator&lt;(const TypeInfo&amp; other) const
+    {
+        return memcmp(this, &amp;other, sizeof(TypeInfo)) &lt; 0;
+    }
+};
+
+typedef std::pair&lt;GLenum, TypeInfo&gt; TypeInfoPair;
+typedef std::map&lt;GLenum, TypeInfo&gt; TypeInfoMap;
+
+static TypeInfoMap BuildTypeInfoMap()
+{
+    TypeInfoMap map;
+
+    map.insert(TypeInfoPair(GL_UNSIGNED_BYTE,                  TypeInfo( 1, false)));
+    map.insert(TypeInfoPair(GL_BYTE,                           TypeInfo( 1, false)));
+    map.insert(TypeInfoPair(GL_UNSIGNED_SHORT,                 TypeInfo( 2, false)));
+    map.insert(TypeInfoPair(GL_SHORT,                          TypeInfo( 2, false)));
+    map.insert(TypeInfoPair(GL_UNSIGNED_INT,                   TypeInfo( 4, false)));
+    map.insert(TypeInfoPair(GL_INT,                            TypeInfo( 4, false)));
+    map.insert(TypeInfoPair(GL_HALF_FLOAT,                     TypeInfo( 2, false)));
+    map.insert(TypeInfoPair(GL_HALF_FLOAT_OES,                 TypeInfo( 2, false)));
+    map.insert(TypeInfoPair(GL_FLOAT,                          TypeInfo( 4, false)));
+    map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_5_6_5,           TypeInfo( 2, true )));
+    map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_4_4_4_4,         TypeInfo( 2, true )));
+    map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_5_5_5_1,         TypeInfo( 2, true )));
+    map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, TypeInfo( 2, true )));
+    map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, TypeInfo( 2, true )));
+    map.insert(TypeInfoPair(GL_UNSIGNED_INT_2_10_10_10_REV,    TypeInfo( 4, true )));
+    map.insert(TypeInfoPair(GL_UNSIGNED_INT_24_8,              TypeInfo( 4, true )));
+    map.insert(TypeInfoPair(GL_UNSIGNED_INT_10F_11F_11F_REV,   TypeInfo( 4, true )));
+    map.insert(TypeInfoPair(GL_UNSIGNED_INT_5_9_9_9_REV,       TypeInfo( 4, true )));
+    map.insert(TypeInfoPair(GL_UNSIGNED_INT_24_8_OES,          TypeInfo( 4, true )));
+    map.insert(TypeInfoPair(GL_FLOAT_32_UNSIGNED_INT_24_8_REV, TypeInfo( 8, true )));
+
+    return map;
+}
+
+static bool GetTypeInfo(GLenum type, TypeInfo *outTypeInfo)
+{
+    static const TypeInfoMap infoMap = BuildTypeInfoMap();
+    TypeInfoMap::const_iterator iter = infoMap.find(type);
+    if (iter != infoMap.end())
+    {
+        if (outTypeInfo)
+        {
+            *outTypeInfo = iter-&gt;second;
+        }
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+// Information about internal formats
+typedef bool ((Context::*ContextSupportCheckMemberFunction)(void) const);
+typedef bool (*ContextSupportCheckFunction)(const Context *context);
+
+typedef bool ((rx::Renderer::*RendererSupportCheckMemberFunction)(void) const);
+typedef bool (*ContextRendererSupportCheckFunction)(const Context *context, const rx::Renderer *renderer);
+
+template &lt;ContextSupportCheckMemberFunction func&gt;
+bool CheckSupport(const Context *context)
+{
+    return (context-&gt;*func)();
+}
+
+template &lt;ContextSupportCheckMemberFunction contextFunc, RendererSupportCheckMemberFunction rendererFunc&gt;
+bool CheckSupport(const Context *context, const rx::Renderer *renderer)
+{
+    if (context)
+    {
+        return (context-&gt;*contextFunc)();
+    }
+    else if (renderer)
+    {
+        return (renderer-&gt;*rendererFunc)();
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+template &lt;typename objectType&gt;
+bool AlwaysSupported(const objectType*)
+{
+    return true;
+}
+
+template &lt;typename objectTypeA, typename objectTypeB&gt;
+bool AlwaysSupported(const objectTypeA*, const objectTypeB*)
+{
+    return true;
+}
+
+template &lt;typename objectType&gt;
+bool NeverSupported(const objectType*)
+{
+    return false;
+}
+
+template &lt;typename objectTypeA, typename objectTypeB&gt;
+bool NeverSupported(const objectTypeA *, const objectTypeB *)
+{
+    return false;
+}
+
+template &lt;typename objectType&gt;
+bool UnimplementedSupport(const objectType*)
+{
+    UNIMPLEMENTED();
+    return false;
+}
+
+template &lt;typename objectTypeA, typename objectTypeB&gt;
+bool UnimplementedSupport(const objectTypeA*, const objectTypeB*)
+{
+    UNIMPLEMENTED();
+    return false;
+}
+
+struct InternalFormatInfo
+{
+    GLuint mRedBits;
+    GLuint mGreenBits;
+    GLuint mBlueBits;
+
+    GLuint mLuminanceBits;
+
+    GLuint mAlphaBits;
+    GLuint mSharedBits;
+
+    GLuint mDepthBits;
+    GLuint mStencilBits;
+
+    GLuint mPixelBits;
+
+    GLuint mComponentCount;
+
+    GLuint mCompressedBlockWidth;
+    GLuint mCompressedBlockHeight;
+
+    GLenum mFormat;
+    GLenum mType;
+
+    GLenum mComponentType;
+    GLenum mColorEncoding;
+
+    bool mIsCompressed;
+
+    ContextRendererSupportCheckFunction mIsColorRenderable;
+    ContextRendererSupportCheckFunction mIsDepthRenderable;
+    ContextRendererSupportCheckFunction mIsStencilRenderable;
+    ContextRendererSupportCheckFunction mIsTextureFilterable;
+
+    ContextSupportCheckFunction mSupportFunction;
+
+    InternalFormatInfo() : mRedBits(0), mGreenBits(0), mBlueBits(0), mLuminanceBits(0), mAlphaBits(0), mSharedBits(0), mDepthBits(0), mStencilBits(0),
+                           mPixelBits(0), mComponentCount(0), mCompressedBlockWidth(0), mCompressedBlockHeight(0), mFormat(GL_NONE), mType(GL_NONE),
+                           mComponentType(GL_NONE), mColorEncoding(GL_NONE), mIsCompressed(false), mIsColorRenderable(NeverSupported),
+                           mIsDepthRenderable(NeverSupported), mIsStencilRenderable(NeverSupported), mIsTextureFilterable(NeverSupported),
+                           mSupportFunction(NeverSupported)
+    {
+    }
+
+    static InternalFormatInfo UnsizedFormat(GLenum format, ContextSupportCheckFunction supportFunction)
+    {
+        InternalFormatInfo formatInfo;
+        formatInfo.mFormat = format;
+        formatInfo.mSupportFunction = supportFunction;
+
+        if (format == GL_RGB || format == GL_RGBA)
+            formatInfo.mIsColorRenderable = AlwaysSupported;
+
+        return formatInfo;
+    }
+
+    static InternalFormatInfo RGBAFormat(GLuint red, GLuint green, GLuint blue, GLuint alpha, GLuint shared,
+                                         GLenum format, GLenum type, GLenum componentType, bool srgb,
+                                         ContextRendererSupportCheckFunction colorRenderable,
+                                         ContextRendererSupportCheckFunction textureFilterable,
+                                         ContextSupportCheckFunction supportFunction)
+    {
+        InternalFormatInfo formatInfo;
+        formatInfo.mRedBits = red;
+        formatInfo.mGreenBits = green;
+        formatInfo.mBlueBits = blue;
+        formatInfo.mAlphaBits = alpha;
+        formatInfo.mSharedBits = shared;
+        formatInfo.mPixelBits = red + green + blue + alpha + shared;
+        formatInfo.mComponentCount = ((red &gt; 0) ? 1 : 0) + ((green &gt; 0) ? 1 : 0) + ((blue &gt; 0) ? 1 : 0) + ((alpha &gt; 0) ? 1 : 0);
+        formatInfo.mFormat = format;
+        formatInfo.mType = type;
+        formatInfo.mComponentType = componentType;
+        formatInfo.mColorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
+        formatInfo.mIsColorRenderable = colorRenderable;
+        formatInfo.mIsTextureFilterable = textureFilterable;
+        formatInfo.mSupportFunction = supportFunction;
+        return formatInfo;
+    }
+
+    static InternalFormatInfo LUMAFormat(GLuint luminance, GLuint alpha, GLenum format, GLenum type, GLenum componentType,
+                                         ContextSupportCheckFunction supportFunction)
+    {
+        InternalFormatInfo formatInfo;
+        formatInfo.mLuminanceBits = luminance;
+        formatInfo.mAlphaBits = alpha;
+        formatInfo.mPixelBits = luminance + alpha;
+        formatInfo.mComponentCount = ((luminance &gt; 0) ? 1 : 0) + ((alpha &gt; 0) ? 1 : 0);
+        formatInfo.mFormat = format;
+        formatInfo.mType = type;
+        formatInfo.mComponentType = componentType;
+        formatInfo.mColorEncoding = GL_LINEAR;
+        formatInfo.mIsTextureFilterable = AlwaysSupported;
+        formatInfo.mSupportFunction = supportFunction;
+        return formatInfo;
+    }
+
+    static InternalFormatInfo DepthStencilFormat(GLuint depthBits, GLuint stencilBits, GLuint unusedBits, GLenum format,
+                                                 GLenum type, GLenum componentType,
+                                                 ContextRendererSupportCheckFunction depthRenderable,
+                                                 ContextRendererSupportCheckFunction stencilRenderable,
+                                                 ContextSupportCheckFunction supportFunction)
+    {
+        InternalFormatInfo formatInfo;
+        formatInfo.mDepthBits = depthBits;
+        formatInfo.mStencilBits = stencilBits;
+        formatInfo.mPixelBits = depthBits + stencilBits + unusedBits;
+        formatInfo.mComponentCount = ((depthBits &gt; 0) ? 1 : 0) + ((stencilBits &gt; 0) ? 1 : 0);
+        formatInfo.mFormat = format;
+        formatInfo.mType = type;
+        formatInfo.mComponentType = componentType;
+        formatInfo.mColorEncoding = GL_LINEAR;
+        formatInfo.mIsDepthRenderable = depthRenderable;
+        formatInfo.mIsStencilRenderable = stencilRenderable;
+        formatInfo.mIsTextureFilterable = AlwaysSupported;
+        formatInfo.mSupportFunction = supportFunction;
+        return formatInfo;
+    }
+
+    static InternalFormatInfo CompressedFormat(GLuint compressedBlockWidth, GLuint compressedBlockHeight, GLuint compressedBlockSize,
+                                               GLuint componentCount, GLenum format, GLenum type, bool srgb,
+                                               ContextSupportCheckFunction supportFunction)
+    {
+        InternalFormatInfo formatInfo;
+        formatInfo.mCompressedBlockWidth = compressedBlockWidth;
+        formatInfo.mCompressedBlockHeight = compressedBlockHeight;
+        formatInfo.mPixelBits = compressedBlockSize;
+        formatInfo.mComponentCount = componentCount;
+        formatInfo.mFormat = format;
+        formatInfo.mType = type;
+        formatInfo.mComponentType = GL_UNSIGNED_NORMALIZED;
+        formatInfo.mColorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
+        formatInfo.mIsCompressed = true;
+        formatInfo.mIsTextureFilterable = AlwaysSupported;
+        formatInfo.mSupportFunction = supportFunction;
+        return formatInfo;
+    }
+};
+
+typedef std::pair&lt;GLenum, InternalFormatInfo&gt; InternalFormatInfoPair;
+typedef std::map&lt;GLenum, InternalFormatInfo&gt; InternalFormatInfoMap;
+
+static InternalFormatInfoMap BuildES3InternalFormatInfoMap()
+{
+    InternalFormatInfoMap map;
+
+    // From ES 3.0.1 spec, table 3.12
+    map.insert(InternalFormatInfoPair(GL_NONE,              InternalFormatInfo()));
+
+    //                               | Internal format     |                              | R | G | B | A |S | Format         | Type                           | Component type        | SRGB | Color          | Texture        | Supported          |
+    //                               |                     |                              |   |   |   |   |  |                |                                |                       |      | renderable     | filterable     |                    |
+    map.insert(InternalFormatInfoPair(GL_R8,                InternalFormatInfo::RGBAFormat( 8,  0,  0,  0, 0, GL_RED,          GL_UNSIGNED_BYTE,                GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_R8_SNORM,          InternalFormatInfo::RGBAFormat( 8,  0,  0,  0, 0, GL_RED,          GL_BYTE,                         GL_SIGNED_NORMALIZED,   false, NeverSupported,  AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG8,               InternalFormatInfo::RGBAFormat( 8,  8,  0,  0, 0, GL_RG,           GL_UNSIGNED_BYTE,                GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG8_SNORM,         InternalFormatInfo::RGBAFormat( 8,  8,  0,  0, 0, GL_RG,           GL_BYTE,                         GL_SIGNED_NORMALIZED,   false, NeverSupported,  AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB8,              InternalFormatInfo::RGBAFormat( 8,  8,  8,  0, 0, GL_RGB,          GL_UNSIGNED_BYTE,                GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB8_SNORM,        InternalFormatInfo::RGBAFormat( 8,  8,  8,  0, 0, GL_RGB,          GL_BYTE,                         GL_SIGNED_NORMALIZED,   false, NeverSupported,  AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB565,            InternalFormatInfo::RGBAFormat( 5,  6,  5,  0, 0, GL_RGB,          GL_UNSIGNED_SHORT_5_6_5,         GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA4,             InternalFormatInfo::RGBAFormat( 4,  4,  4,  4, 0, GL_RGBA,         GL_UNSIGNED_SHORT_4_4_4_4,       GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB5_A1,           InternalFormatInfo::RGBAFormat( 5,  5,  5,  1, 0, GL_RGBA,         GL_UNSIGNED_SHORT_5_5_5_1,       GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA8,             InternalFormatInfo::RGBAFormat( 8,  8,  8,  8, 0, GL_RGBA,         GL_UNSIGNED_BYTE,                GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM,       InternalFormatInfo::RGBAFormat( 8,  8,  8,  8, 0, GL_RGBA,         GL_BYTE,                         GL_SIGNED_NORMALIZED,   false, NeverSupported,  AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB10_A2,          InternalFormatInfo::RGBAFormat(10, 10, 10,  2, 0, GL_RGBA,         GL_UNSIGNED_INT_2_10_10_10_REV,  GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB10_A2UI,        InternalFormatInfo::RGBAFormat(10, 10, 10,  2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV,  GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_SRGB8,             InternalFormatInfo::RGBAFormat( 8,  8,  8,  0, 0, GL_RGB,          GL_UNSIGNED_BYTE,                GL_UNSIGNED_NORMALIZED, true,  NeverSupported,  AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8,      InternalFormatInfo::RGBAFormat( 8,  8,  8,  8, 0, GL_RGBA,         GL_UNSIGNED_BYTE,                GL_UNSIGNED_NORMALIZED, true,  AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_R11F_G11F_B10F,    InternalFormatInfo::RGBAFormat(11, 11, 10,  0, 0, GL_RGB,          GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT,               false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB9_E5,           InternalFormatInfo::RGBAFormat( 9,  9,  9,  0, 5, GL_RGB,          GL_UNSIGNED_INT_5_9_9_9_REV,     GL_FLOAT,               false, NeverSupported,  AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_R8I,               InternalFormatInfo::RGBAFormat( 8,  0,  0,  0, 0, GL_RED_INTEGER,  GL_BYTE,                         GL_INT,                 false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_R8UI,              InternalFormatInfo::RGBAFormat( 8,  0,  0,  0, 0, GL_RED_INTEGER,  GL_UNSIGNED_BYTE,                GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_R16I,              InternalFormatInfo::RGBAFormat(16,  0,  0,  0, 0, GL_RED_INTEGER,  GL_SHORT,                        GL_INT,                 false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_R16UI,             InternalFormatInfo::RGBAFormat(16,  0,  0,  0, 0, GL_RED_INTEGER,  GL_UNSIGNED_SHORT,               GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_R32I,              InternalFormatInfo::RGBAFormat(32,  0,  0,  0, 0, GL_RED_INTEGER,  GL_INT,                          GL_INT,                 false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_R32UI,             InternalFormatInfo::RGBAFormat(32,  0,  0,  0, 0, GL_RED_INTEGER,  GL_UNSIGNED_INT,                 GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG8I,              InternalFormatInfo::RGBAFormat( 8,  8,  0,  0, 0, GL_RG_INTEGER,   GL_BYTE,                         GL_INT,                 false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG8UI,             InternalFormatInfo::RGBAFormat( 8,  8,  0,  0, 0, GL_RG_INTEGER,   GL_UNSIGNED_BYTE,                GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG16I,             InternalFormatInfo::RGBAFormat(16, 16,  0,  0, 0, GL_RG_INTEGER,   GL_SHORT,                        GL_INT,                 false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG16UI,            InternalFormatInfo::RGBAFormat(16, 16,  0,  0, 0, GL_RG_INTEGER,   GL_UNSIGNED_SHORT,               GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG32I,             InternalFormatInfo::RGBAFormat(32, 32,  0,  0, 0, GL_RG_INTEGER,   GL_INT,                          GL_INT,                 false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG32UI,            InternalFormatInfo::RGBAFormat(32, 32,  0,  0, 0, GL_RG_INTEGER,   GL_UNSIGNED_INT,                 GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB8I,             InternalFormatInfo::RGBAFormat( 8,  8,  8,  0, 0, GL_RGB_INTEGER,  GL_BYTE,                         GL_INT,                 false, NeverSupported,  NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB8UI,            InternalFormatInfo::RGBAFormat( 8,  8,  8,  0, 0, GL_RGB_INTEGER,  GL_UNSIGNED_BYTE,                GL_UNSIGNED_INT,        false, NeverSupported,  NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB16I,            InternalFormatInfo::RGBAFormat(16, 16, 16,  0, 0, GL_RGB_INTEGER,  GL_SHORT,                        GL_INT,                 false, NeverSupported,  NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB16UI,           InternalFormatInfo::RGBAFormat(16, 16, 16,  0, 0, GL_RGB_INTEGER,  GL_UNSIGNED_SHORT,               GL_UNSIGNED_INT,        false, NeverSupported,  NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB32I,            InternalFormatInfo::RGBAFormat(32, 32, 32,  0, 0, GL_RGB_INTEGER,  GL_INT,                          GL_INT,                 false, NeverSupported,  NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB32UI,           InternalFormatInfo::RGBAFormat(32, 32, 32,  0, 0, GL_RGB_INTEGER,  GL_UNSIGNED_INT,                 GL_UNSIGNED_INT,        false, NeverSupported,  NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA8I,            InternalFormatInfo::RGBAFormat( 8,  8,  8,  8, 0, GL_RGBA_INTEGER, GL_BYTE,                         GL_INT,                 false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA8UI,           InternalFormatInfo::RGBAFormat( 8,  8,  8,  8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE,                GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA16I,           InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT,                        GL_INT,                 false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA16UI,          InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT,               GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA32I,           InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT,                          GL_INT,                 false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA32UI,          InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT,                 GL_UNSIGNED_INT,        false, AlwaysSupported, NeverSupported,  AlwaysSupported     )));
+
+    map.insert(InternalFormatInfoPair(GL_BGRA8_EXT,         InternalFormatInfo::RGBAFormat( 8,  8,  8,  8, 0, GL_BGRA_EXT,     GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX,      InternalFormatInfo::RGBAFormat( 4,  4,  4,  4, 0, GL_BGRA_EXT,     GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX,    InternalFormatInfo::RGBAFormat( 5,  5,  5,  1, 0, GL_BGRA_EXT,     GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported     )));
+
+    // Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float
+    //                               | Internal format        |                                   | D |S | Format             | Type                           | Comp   | SRGB | Color renderable                                                                                           | Texture filterable                                                                                    | Supported          |
+    //                               |                        |                                   |   |  |                    |                                | type   |      |                                                                                                            |                                                                                                       |                    |
+    map.insert(InternalFormatInfoPair(GL_R16F,              InternalFormatInfo::RGBAFormat(16,  0,  0,  0, 0, GL_RED,          GL_HALF_FLOAT,                   GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat16RenderableTextures, &amp;rx::Renderer::getFloat16TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat16LinearFilter, &amp;rx::Renderer::getFloat16TextureFilteringSupport&gt;, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG16F,             InternalFormatInfo::RGBAFormat(16, 16,  0,  0, 0, GL_RG,           GL_HALF_FLOAT,                   GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat16RenderableTextures, &amp;rx::Renderer::getFloat16TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat16LinearFilter, &amp;rx::Renderer::getFloat16TextureFilteringSupport&gt;, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB16F,            InternalFormatInfo::RGBAFormat(16, 16, 16,  0, 0, GL_RGB,          GL_HALF_FLOAT,                   GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat16RenderableTextures, &amp;rx::Renderer::getFloat16TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat16LinearFilter, &amp;rx::Renderer::getFloat16TextureFilteringSupport&gt;, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA16F,           InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA,         GL_HALF_FLOAT,                   GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat16RenderableTextures, &amp;rx::Renderer::getFloat16TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat16LinearFilter, &amp;rx::Renderer::getFloat16TextureFilteringSupport&gt;, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_R32F,              InternalFormatInfo::RGBAFormat(32,  0,  0,  0, 0, GL_RED,          GL_FLOAT,                        GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat32RenderableTextures, &amp;rx::Renderer::getFloat32TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat32LinearFilter, &amp;rx::Renderer::getFloat32TextureFilteringSupport&gt;, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RG32F,             InternalFormatInfo::RGBAFormat(32, 32,  0,  0, 0, GL_RG,           GL_FLOAT,                        GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat32RenderableTextures, &amp;rx::Renderer::getFloat32TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat32LinearFilter, &amp;rx::Renderer::getFloat32TextureFilteringSupport&gt;, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGB32F,            InternalFormatInfo::RGBAFormat(32, 32, 32,  0, 0, GL_RGB,          GL_FLOAT,                        GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat32RenderableTextures, &amp;rx::Renderer::getFloat32TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat32LinearFilter, &amp;rx::Renderer::getFloat32TextureFilteringSupport&gt;, AlwaysSupported     )));
+    map.insert(InternalFormatInfoPair(GL_RGBA32F,           InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA,         GL_FLOAT,                        GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat32RenderableTextures, &amp;rx::Renderer::getFloat32TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat32LinearFilter, &amp;rx::Renderer::getFloat32TextureFilteringSupport&gt;, AlwaysSupported     )));
+
+    // Depth stencil formats
+    //                               | Internal format         |                                      | D |S | X | Format            | Type                             | Component type        | Depth          | Stencil        | Supported     |
+    //                               |                         |                                      |   |  |   |                   |                                  |                       | renderable     | renderable     |               |
+    map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16,     InternalFormatInfo::DepthStencilFormat(16, 0,  0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT,                 GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported,  AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT24,     InternalFormatInfo::DepthStencilFormat(24, 0,  0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,                   GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported,  AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32F,    InternalFormatInfo::DepthStencilFormat(32, 0,  0, GL_DEPTH_COMPONENT, GL_FLOAT,                          GL_FLOAT,               AlwaysSupported, NeverSupported,  AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES, InternalFormatInfo::DepthStencilFormat(32, 0,  0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,                   GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported,  AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8,      InternalFormatInfo::DepthStencilFormat(24, 8,  0, GL_DEPTH_STENCIL,   GL_UNSIGNED_INT_24_8,              GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_DEPTH32F_STENCIL8,     InternalFormatInfo::DepthStencilFormat(32, 8, 24, GL_DEPTH_STENCIL,   GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT,               AlwaysSupported, AlwaysSupported, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8,        InternalFormatInfo::DepthStencilFormat( 0, 8,  0, GL_DEPTH_STENCIL,   GL_UNSIGNED_BYTE,                  GL_UNSIGNED_INT,        NeverSupported,  AlwaysSupported, AlwaysSupported)));
+
+    // Luminance alpha formats
+    //                               | Internal format          |                              | L | A | Format            | Type            | Component type        | Supported     |
+    map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT,             InternalFormatInfo::LUMAFormat( 0,  8, GL_ALPHA,           GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT,         InternalFormatInfo::LUMAFormat( 8,  0, GL_LUMINANCE,       GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT,           InternalFormatInfo::LUMAFormat( 0, 32, GL_ALPHA,           GL_FLOAT,         GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT,       InternalFormatInfo::LUMAFormat(32,  0, GL_LUMINANCE,       GL_FLOAT,         GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT,           InternalFormatInfo::LUMAFormat( 0, 16, GL_ALPHA,           GL_HALF_FLOAT,    GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT,       InternalFormatInfo::LUMAFormat(16,  0, GL_LUMINANCE,       GL_HALF_FLOAT,    GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT,  InternalFormatInfo::LUMAFormat( 8,  8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT,         GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT,    GL_FLOAT,               AlwaysSupported)));
+
+    // Unsized formats
+    //                               | Internal format   |                                 | Format            | Supported     |
+    map.insert(InternalFormatInfoPair(GL_ALPHA,           InternalFormatInfo::UnsizedFormat(GL_ALPHA,           AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE,       InternalFormatInfo::UnsizedFormat(GL_LUMINANCE,       AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE_ALPHA, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RED,             InternalFormatInfo::UnsizedFormat(GL_RED,             AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RG,              InternalFormatInfo::UnsizedFormat(GL_RG,              AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RGB,             InternalFormatInfo::UnsizedFormat(GL_RGB,             AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RGBA,            InternalFormatInfo::UnsizedFormat(GL_RGBA,            AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RED_INTEGER,     InternalFormatInfo::UnsizedFormat(GL_RED_INTEGER,     AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RG_INTEGER,      InternalFormatInfo::UnsizedFormat(GL_RG_INTEGER,      AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RGB_INTEGER,     InternalFormatInfo::UnsizedFormat(GL_RGB_INTEGER,     AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RGBA_INTEGER,    InternalFormatInfo::UnsizedFormat(GL_RGBA_INTEGER,    AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_BGRA_EXT,        InternalFormatInfo::UnsizedFormat(GL_BGRA_EXT,        AlwaysSupported)));
+
+    // Compressed formats, From ES 3.0.1 spec, table 3.16
+    //                               | Internal format                             |                                    |W |H | BS |CC| Format                                      | Type            | SRGB | Supported          |
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_R11_EAC,                        InternalFormatInfo::CompressedFormat(4, 4,  64, 1, GL_COMPRESSED_R11_EAC,                        GL_UNSIGNED_BYTE, false, UnimplementedSupport)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_R11_EAC,                 InternalFormatInfo::CompressedFormat(4, 4,  64, 1, GL_COMPRESSED_SIGNED_R11_EAC,                 GL_UNSIGNED_BYTE, false, UnimplementedSupport)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RG11_EAC,                       InternalFormatInfo::CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_RG11_EAC,                       GL_UNSIGNED_BYTE, false, UnimplementedSupport)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_RG11_EAC,                InternalFormatInfo::CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_SIGNED_RG11_EAC,                GL_UNSIGNED_BYTE, false, UnimplementedSupport)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_ETC2,                      InternalFormatInfo::CompressedFormat(4, 4,  64, 3, GL_COMPRESSED_RGB8_ETC2,                      GL_UNSIGNED_BYTE, false, UnimplementedSupport)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ETC2,                     InternalFormatInfo::CompressedFormat(4, 4,  64, 3, GL_COMPRESSED_SRGB8_ETC2,                     GL_UNSIGNED_BYTE, true,  UnimplementedSupport)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,  InternalFormatInfo::CompressedFormat(4, 4,  64, 3, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,  GL_UNSIGNED_BYTE, false, UnimplementedSupport)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, InternalFormatInfo::CompressedFormat(4, 4,  64, 3, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, true,  UnimplementedSupport)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA8_ETC2_EAC,                 InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA8_ETC2_EAC,                 GL_UNSIGNED_BYTE, false, UnimplementedSupport)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,          InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,          GL_UNSIGNED_BYTE, true,  UnimplementedSupport)));
+
+    // From GL_EXT_texture_compression_dxt1
+    //                               | Internal format                   |                                    |W |H | BS |CC| Format                            | Type            | SRGB | Supported     |
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT,    InternalFormatInfo::CompressedFormat(4, 4,  64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,    GL_UNSIGNED_BYTE, false, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,   InternalFormatInfo::CompressedFormat(4, 4,  64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,   GL_UNSIGNED_BYTE, false, AlwaysSupported)));
+
+    // From GL_ANGLE_texture_compression_dxt3
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, AlwaysSupported)));
+
+    // From GL_ANGLE_texture_compression_dxt5
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, AlwaysSupported)));
+
+    return map;
+}
+
+static InternalFormatInfoMap BuildES2InternalFormatInfoMap()
+{
+    InternalFormatInfoMap map;
+
+    // From ES 2.0.25 table 4.5
+    map.insert(InternalFormatInfoPair(GL_NONE,                 InternalFormatInfo()));
+
+    //                               | Internal format        |                              | R | G | B | A |S | Format          | Type                     | Component type        | SRGB | Color         | Texture        | Supported      |
+    //                               |                        |                              |   |   |   |   |  |                 |                          |                       |      | renderable    | filterable     |                |
+    map.insert(InternalFormatInfoPair(GL_RGBA4,                InternalFormatInfo::RGBAFormat( 4,  4,  4,  4, 0, GL_RGBA,          GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RGB5_A1,              InternalFormatInfo::RGBAFormat( 5,  5,  5,  1, 0, GL_RGBA,          GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RGB565,               InternalFormatInfo::RGBAFormat( 5,  6,  5,  0, 0, GL_RGB,           GL_UNSIGNED_SHORT_5_6_5,   GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported)));
+
+    // Extension formats
+    map.insert(InternalFormatInfoPair(GL_R8_EXT,               InternalFormatInfo::RGBAFormat( 8,  0,  0,  0, 0, GL_RED_EXT,       GL_UNSIGNED_BYTE,          GL_UNSIGNED_NORMALIZED, false, CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;, CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;, CheckSupport&lt;&amp;Context::supportsRGTextures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_RG8_EXT,              InternalFormatInfo::RGBAFormat( 8,  8,  0,  0, 0, GL_RG_EXT,        GL_UNSIGNED_BYTE,          GL_UNSIGNED_NORMALIZED, false, CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;, CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;, CheckSupport&lt;&amp;Context::supportsRGTextures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_RGB8_OES,             InternalFormatInfo::RGBAFormat( 8,  8,  8,  0, 0, GL_RGB,           GL_UNSIGNED_BYTE,          GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RGBA8_OES,            InternalFormatInfo::RGBAFormat( 8,  8,  8,  8, 0, GL_RGBA,          GL_UNSIGNED_BYTE,          GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_BGRA8_EXT,            InternalFormatInfo::RGBAFormat( 8,  8,  8,  8, 0, GL_BGRA_EXT,      GL_UNSIGNED_BYTE,          GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX,         InternalFormatInfo::RGBAFormat( 4,  4,  4,  4, 0, GL_BGRA_EXT,      GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, NeverSupported,  AlwaysSupported, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX,       InternalFormatInfo::RGBAFormat( 5,  5,  5,  1, 0, GL_BGRA_EXT,      GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, NeverSupported,  AlwaysSupported, AlwaysSupported)));
+
+    // Floating point formats have to query the renderer for support
+    //                               | Internal format        |                              | R | G | B | A |S | Format          | Type                     | Comp    | SRGB | Color renderable                                                                                           | Texture filterable                                                                                   | Supported                                     |
+    //                               |                        |                              |   |   |   |   |  |                 |                          | type    |      |                                                                                                            |                                                                                                      |                                               |
+    map.insert(InternalFormatInfoPair(GL_R16F_EXT,             InternalFormatInfo::RGBAFormat(16,  0,  0,  0, 0, GL_RED,           GL_HALF_FLOAT_OES,         GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;,                              CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;,                        CheckSupport&lt;&amp;Context::supportsRGTextures&gt;     )));
+    map.insert(InternalFormatInfoPair(GL_R32F_EXT,             InternalFormatInfo::RGBAFormat(32,  0,  0,  0, 0, GL_RED,           GL_FLOAT,                  GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;,                              CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;,                        CheckSupport&lt;&amp;Context::supportsRGTextures&gt;     )));
+    map.insert(InternalFormatInfoPair(GL_RG16F_EXT,            InternalFormatInfo::RGBAFormat(16, 16,  0,  0, 0, GL_RG,            GL_HALF_FLOAT_OES,         GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;,                              CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;,                        CheckSupport&lt;&amp;Context::supportsRGTextures&gt;     )));
+    map.insert(InternalFormatInfoPair(GL_RG32F_EXT,            InternalFormatInfo::RGBAFormat(32, 32,  0,  0, 0, GL_RG,            GL_FLOAT,                  GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;,                              CheckSupport&lt;&amp;Context::supportsRGTextures, &amp;rx::Renderer::getRGTextureSupport&gt;,                        CheckSupport&lt;&amp;Context::supportsRGTextures&gt;     )));
+    map.insert(InternalFormatInfoPair(GL_RGB16F_EXT,           InternalFormatInfo::RGBAFormat(16, 16, 16,  0, 0, GL_RGB,           GL_HALF_FLOAT_OES,         GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat16RenderableTextures, &amp;rx::Renderer::getFloat16TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat16LinearFilter, &amp;rx::Renderer::getFloat16TextureFilteringSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat16Textures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_RGB32F_EXT,           InternalFormatInfo::RGBAFormat(32, 32, 32,  0, 0, GL_RGB,           GL_FLOAT,                  GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat32RenderableTextures, &amp;rx::Renderer::getFloat32TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat32LinearFilter, &amp;rx::Renderer::getFloat32TextureFilteringSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat32Textures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_RGBA16F_EXT,          InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA,          GL_HALF_FLOAT_OES,         GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat16RenderableTextures, &amp;rx::Renderer::getFloat16TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat16LinearFilter, &amp;rx::Renderer::getFloat16TextureFilteringSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat16Textures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_RGBA32F_EXT,          InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA,          GL_FLOAT,                  GL_FLOAT, false, CheckSupport&lt;&amp;Context::supportsFloat32RenderableTextures, &amp;rx::Renderer::getFloat32TextureRenderingSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat32LinearFilter, &amp;rx::Renderer::getFloat32TextureFilteringSupport&gt;, CheckSupport&lt;&amp;Context::supportsFloat32Textures&gt;)));
+
+    // Depth and stencil formats
+    //                               | Internal format        |                                      | D |S |X | Format              | Type                     | Internal format     | Depth          | Stencil         | Supported                                  |
+    //                               |                        |                                      |   |  |  |                     |                          | type                | renderable     | renderable      |                                            |
+    map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES,InternalFormatInfo::DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT,   GL_UNSIGNED_INT,           GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported,  CheckSupport&lt;&amp;Context::supportsDepthTextures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8_OES, InternalFormatInfo::DepthStencilFormat(24, 8, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES,  GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, CheckSupport&lt;&amp;Context::supportsDepthTextures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16,    InternalFormatInfo::DepthStencilFormat(16, 0, 0, GL_DEPTH_COMPONENT,   GL_UNSIGNED_SHORT,         GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported,  AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8,       InternalFormatInfo::DepthStencilFormat( 0, 8, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_BYTE,          GL_UNSIGNED_NORMALIZED, NeverSupported,  AlwaysSupported, AlwaysSupported)));
+
+    // Unsized formats
+    //                               | Internal format        |                                 | Format              | Supported     |
+    map.insert(InternalFormatInfoPair(GL_ALPHA,                InternalFormatInfo::UnsizedFormat(GL_ALPHA,             AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE,            InternalFormatInfo::UnsizedFormat(GL_LUMINANCE,         AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA,      InternalFormatInfo::UnsizedFormat(GL_LUMINANCE_ALPHA,   AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RED_EXT,              InternalFormatInfo::UnsizedFormat(GL_RED_EXT,           CheckSupport&lt;&amp;Context::supportsRGTextures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_RG_EXT,               InternalFormatInfo::UnsizedFormat(GL_RG_EXT,            CheckSupport&lt;&amp;Context::supportsRGTextures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_RGB,                  InternalFormatInfo::UnsizedFormat(GL_RGB,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_RGBA,                 InternalFormatInfo::UnsizedFormat(GL_RGBA,              AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_BGRA_EXT,             InternalFormatInfo::UnsizedFormat(GL_BGRA_EXT,          AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT,      InternalFormatInfo::UnsizedFormat(GL_DEPTH_COMPONENT,   AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL_OES,    InternalFormatInfo::UnsizedFormat(GL_DEPTH_STENCIL_OES, AlwaysSupported)));
+
+    // Luminance alpha formats from GL_EXT_texture_storage
+    //                               | Internal format          |                              | L | A | Format                   | Type                     | Component type        | Supported     |
+    map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT,             InternalFormatInfo::LUMAFormat( 0,  8, GL_ALPHA,                  GL_UNSIGNED_BYTE,          GL_UNSIGNED_NORMALIZED, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT,         InternalFormatInfo::LUMAFormat( 8,  0, GL_LUMINANCE,              GL_UNSIGNED_BYTE,          GL_UNSIGNED_NORMALIZED, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT,           InternalFormatInfo::LUMAFormat( 0, 32, GL_ALPHA,                  GL_FLOAT,                  GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT,       InternalFormatInfo::LUMAFormat(32,  0, GL_LUMINANCE,              GL_FLOAT,                  GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT,           InternalFormatInfo::LUMAFormat( 0, 16, GL_ALPHA,                  GL_HALF_FLOAT_OES,         GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT,       InternalFormatInfo::LUMAFormat(16,  0, GL_LUMINANCE,              GL_HALF_FLOAT_OES,         GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT,  InternalFormatInfo::LUMAFormat( 8,  8, GL_LUMINANCE_ALPHA,        GL_UNSIGNED_BYTE,          GL_UNSIGNED_NORMALIZED, AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat(32, 32, GL_LUMINANCE_ALPHA,        GL_FLOAT,                  GL_FLOAT,               AlwaysSupported)));
+    map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat(16, 16, GL_LUMINANCE_ALPHA,        GL_HALF_FLOAT_OES,         GL_FLOAT,               AlwaysSupported)));
+
+    // From GL_EXT_texture_compression_dxt1
+    //                               | Internal format                   |                                    |W |H | BS |CC|Format                             | Type            | SRGB | Supported                                  |
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT,    InternalFormatInfo::CompressedFormat(4, 4,  64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,    GL_UNSIGNED_BYTE, false, CheckSupport&lt;&amp;Context::supportsDXT1Textures&gt;)));
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,   InternalFormatInfo::CompressedFormat(4, 4,  64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,   GL_UNSIGNED_BYTE, false, CheckSupport&lt;&amp;Context::supportsDXT1Textures&gt;)));
+
+    // From GL_ANGLE_texture_compression_dxt3
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, CheckSupport&lt;&amp;Context::supportsDXT3Textures&gt;)));
+
+    // From GL_ANGLE_texture_compression_dxt5
+    map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, CheckSupport&lt;&amp;Context::supportsDXT5Textures&gt;)));
+
+    return map;
+}
+
+static bool GetInternalFormatInfo(GLenum internalFormat, GLuint clientVersion, InternalFormatInfo *outFormatInfo)
+{
+    const InternalFormatInfoMap* map = NULL;
+
+    if (clientVersion == 2)
+    {
+        static const InternalFormatInfoMap formatMap = BuildES2InternalFormatInfoMap();
+        map = &amp;formatMap;
+    }
+    else if (clientVersion == 3)
+    {
+        static const InternalFormatInfoMap formatMap = BuildES3InternalFormatInfoMap();
+        map = &amp;formatMap;
+    }
+    else
+    {
+        UNREACHABLE();
+    }
+
+    InternalFormatInfoMap::const_iterator iter = map-&gt;find(internalFormat);
+    if (iter != map-&gt;end())
+    {
+        if (outFormatInfo)
+        {
+            *outFormatInfo = iter-&gt;second;
+        }
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+typedef std::set&lt;GLenum&gt; FormatSet;
+
+static FormatSet BuildES2ValidFormatSet()
+{
+    static const FormatMap &amp;formatMap = GetFormatMap(2);
+
+    FormatSet set;
+
+    for (FormatMap::const_iterator i = formatMap.begin(); i != formatMap.end(); i++)
+    {
+        const FormatTypePair&amp; formatPair = i-&gt;first;
+        set.insert(formatPair.first);
+    }
+
+    return set;
+}
+
+static FormatSet BuildES3ValidFormatSet()
+{
+    static const ES3FormatSet &amp;formatSet = GetES3FormatSet();
+
+    FormatSet set;
+
+    for (ES3FormatSet::const_iterator i = formatSet.begin(); i != formatSet.end(); i++)
+    {
+        const FormatInfo&amp; formatInfo = *i;
+        set.insert(formatInfo.mFormat);
+    }
+
+    return set;
+}
+
+typedef std::set&lt;GLenum&gt; TypeSet;
+
+static TypeSet BuildES2ValidTypeSet()
+{
+    static const FormatMap &amp;formatMap = GetFormatMap(2);
+
+    TypeSet set;
+
+    for (FormatMap::const_iterator i = formatMap.begin(); i != formatMap.end(); i++)
+    {
+        const FormatTypePair&amp; formatPair = i-&gt;first;
+        set.insert(formatPair.second);
+    }
+
+    return set;
+}
+
+static TypeSet BuildES3ValidTypeSet()
+{
+    static const ES3FormatSet &amp;formatSet = GetES3FormatSet();
+
+    TypeSet set;
+
+    for (ES3FormatSet::const_iterator i = formatSet.begin(); i != formatSet.end(); i++)
+    {
+        const FormatInfo&amp; formatInfo = *i;
+        set.insert(formatInfo.mType);
+    }
+
+    return set;
+}
+
+struct EffectiveInternalFormatInfo
+{
+    GLenum mEffectiveFormat;
+    GLenum mDestFormat;
+    GLuint mMinRedBits;
+    GLuint mMaxRedBits;
+    GLuint mMinGreenBits;
+    GLuint mMaxGreenBits;
+    GLuint mMinBlueBits;
+    GLuint mMaxBlueBits;
+    GLuint mMinAlphaBits;
+    GLuint mMaxAlphaBits;
+
+    EffectiveInternalFormatInfo(GLenum effectiveFormat, GLenum destFormat, GLuint minRedBits, GLuint maxRedBits,
+                                GLuint minGreenBits, GLuint maxGreenBits, GLuint minBlueBits, GLuint maxBlueBits,
+                                GLuint minAlphaBits, GLuint maxAlphaBits)
+        : mEffectiveFormat(effectiveFormat), mDestFormat(destFormat), mMinRedBits(minRedBits),
+          mMaxRedBits(maxRedBits), mMinGreenBits(minGreenBits), mMaxGreenBits(maxGreenBits),
+          mMinBlueBits(minBlueBits), mMaxBlueBits(maxBlueBits), mMinAlphaBits(minAlphaBits),
+          mMaxAlphaBits(maxAlphaBits) {};
+};
+
+typedef std::vector&lt;EffectiveInternalFormatInfo&gt; EffectiveInternalFormatList;
+
+static EffectiveInternalFormatList BuildSizedEffectiveInternalFormatList()
+{
+    EffectiveInternalFormatList list;
+
+    // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: Effective internal format coresponding to destination internal format and
+    //                                                    linear source buffer component sizes.
+    //                                                                            | Source channel min/max sizes |
+    //                                         Effective Internal Format |  N/A   |  R   |  G   |  B   |  A      |
+    list.push_back(EffectiveInternalFormatInfo(GL_ALPHA8_EXT,              GL_NONE, 0,  0, 0,  0, 0,  0, 1, 8));
+    list.push_back(EffectiveInternalFormatInfo(GL_R8,                      GL_NONE, 1,  8, 0,  0, 0,  0, 0, 0));
+    list.push_back(EffectiveInternalFormatInfo(GL_RG8,                     GL_NONE, 1,  8, 1,  8, 0,  0, 0, 0));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGB565,                  GL_NONE, 1,  5, 1,  6, 1,  5, 0, 0));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGB8,                    GL_NONE, 6,  8, 7,  8, 6,  8, 0, 0));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGBA4,                   GL_NONE, 1,  4, 1,  4, 1,  4, 1, 4));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGB5_A1,                 GL_NONE, 5,  5, 5,  5, 5,  5, 1, 1));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGBA8,                   GL_NONE, 5,  8, 5,  8, 5,  8, 2, 8));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGB10_A2,                GL_NONE, 9, 10, 9, 10, 9, 10, 2, 2));
+
+    return list;
+}
+
+
+static EffectiveInternalFormatList BuildUnsizedEffectiveInternalFormatList()
+{
+    EffectiveInternalFormatList list;
+
+    // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: Effective internal format coresponding to destination internal format and
+    //                                                    linear source buffer component sizes.
+    //                                                                                        |          Source channel min/max sizes            |
+    //                                         Effective Internal Format |    Dest Format     |     R     |      G     |      B     |      A     |
+    list.push_back(EffectiveInternalFormatInfo(GL_ALPHA8_EXT,              GL_ALPHA,           0, UINT_MAX, 0, UINT_MAX, 0, UINT_MAX, 1,        8));
+    list.push_back(EffectiveInternalFormatInfo(GL_LUMINANCE8_EXT,          GL_LUMINANCE,       1,        8, 0, UINT_MAX, 0, UINT_MAX, 0, UINT_MAX));
+    list.push_back(EffectiveInternalFormatInfo(GL_LUMINANCE8_ALPHA8_EXT,   GL_LUMINANCE_ALPHA, 1,        8, 0, UINT_MAX, 0, UINT_MAX, 1,        8));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGB565,                  GL_RGB,             1,        5, 1,        6, 1,        5, 0, UINT_MAX));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGB8,                    GL_RGB,             6,        8, 7,        8, 6,        8, 0, UINT_MAX));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGBA4,                   GL_RGBA,            1,        4, 1,        4, 1,        4, 1,        4));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGB5_A1,                 GL_RGBA,            5,        5, 5,        5, 5,        5, 1,        1));
+    list.push_back(EffectiveInternalFormatInfo(GL_RGBA8,                   GL_RGBA,            5,        8, 5,        8, 5,        8, 5,        8));
+
+    return list;
+}
+
+static bool GetEffectiveInternalFormat(const InternalFormatInfo &amp;srcFormat, const InternalFormatInfo &amp;destFormat,
+                                       GLuint clientVersion, GLenum *outEffectiveFormat)
+{
+    const EffectiveInternalFormatList *list = NULL;
+    GLenum targetFormat = GL_NONE;
+
+    if (gl::IsSizedInternalFormat(destFormat.mFormat, clientVersion))
+    {
+        static const EffectiveInternalFormatList sizedList = BuildSizedEffectiveInternalFormatList();
+        list = &amp;sizedList;
+    }
+    else
+    {
+        static const EffectiveInternalFormatList unsizedList = BuildUnsizedEffectiveInternalFormatList();
+        list = &amp;unsizedList;
+        targetFormat = destFormat.mFormat;
+    }
+
+    for (size_t curFormat = 0; curFormat &lt; list-&gt;size(); ++curFormat)
+    {
+        const EffectiveInternalFormatInfo&amp; formatInfo = list-&gt;at(curFormat);
+        if ((formatInfo.mDestFormat == targetFormat) &amp;&amp;
+            (formatInfo.mMinRedBits   &lt;= srcFormat.mRedBits   &amp;&amp; formatInfo.mMaxRedBits   &gt;= srcFormat.mRedBits)   &amp;&amp;
+            (formatInfo.mMinGreenBits &lt;= srcFormat.mGreenBits &amp;&amp; formatInfo.mMaxGreenBits &gt;= srcFormat.mGreenBits) &amp;&amp;
+            (formatInfo.mMinBlueBits  &lt;= srcFormat.mBlueBits  &amp;&amp; formatInfo.mMaxBlueBits  &gt;= srcFormat.mBlueBits)  &amp;&amp;
+            (formatInfo.mMinAlphaBits &lt;= srcFormat.mAlphaBits &amp;&amp; formatInfo.mMaxAlphaBits &gt;= srcFormat.mAlphaBits))
+        {
+            *outEffectiveFormat = formatInfo.mEffectiveFormat;
+            return true;
+        }
+    }
+
+    return false;
+}
+
+struct CopyConversion
+{
+    GLenum mTextureFormat;
+    GLenum mFramebufferFormat;
+
+    CopyConversion(GLenum textureFormat, GLenum framebufferFormat)
+        : mTextureFormat(textureFormat), mFramebufferFormat(framebufferFormat) { }
+
+    bool operator&lt;(const CopyConversion&amp; other) const
+    {
+        return memcmp(this, &amp;other, sizeof(CopyConversion)) &lt; 0;
+    }
+};
+
+typedef std::set&lt;CopyConversion&gt; CopyConversionSet;
+
+static CopyConversionSet BuildValidES3CopyTexImageCombinations()
+{
+    CopyConversionSet set;
+
+    // From ES 3.0.1 spec, table 3.15
+    set.insert(CopyConversion(GL_ALPHA,           GL_RGBA));
+    set.insert(CopyConversion(GL_LUMINANCE,       GL_RED));
+    set.insert(CopyConversion(GL_LUMINANCE,       GL_RG));
+    set.insert(CopyConversion(GL_LUMINANCE,       GL_RGB));
+    set.insert(CopyConversion(GL_LUMINANCE,       GL_RGBA));
+    set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_RGBA));
+    set.insert(CopyConversion(GL_RED,             GL_RED));
+    set.insert(CopyConversion(GL_RED,             GL_RG));
+    set.insert(CopyConversion(GL_RED,             GL_RGB));
+    set.insert(CopyConversion(GL_RED,             GL_RGBA));
+    set.insert(CopyConversion(GL_RG,              GL_RG));
+    set.insert(CopyConversion(GL_RG,              GL_RGB));
+    set.insert(CopyConversion(GL_RG,              GL_RGBA));
+    set.insert(CopyConversion(GL_RGB,             GL_RGB));
+    set.insert(CopyConversion(GL_RGB,             GL_RGBA));
+    set.insert(CopyConversion(GL_RGBA,            GL_RGBA));
+
+    // Necessary for ANGLE back-buffers
+    set.insert(CopyConversion(GL_ALPHA,           GL_BGRA_EXT));
+    set.insert(CopyConversion(GL_LUMINANCE,       GL_BGRA_EXT));
+    set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_BGRA_EXT));
+    set.insert(CopyConversion(GL_RED,             GL_BGRA_EXT));
+    set.insert(CopyConversion(GL_RG,              GL_BGRA_EXT));
+    set.insert(CopyConversion(GL_RGB,             GL_BGRA_EXT));
+    set.insert(CopyConversion(GL_RGBA,            GL_BGRA_EXT));
+
+    set.insert(CopyConversion(GL_RED_INTEGER,     GL_RED_INTEGER));
+    set.insert(CopyConversion(GL_RED_INTEGER,     GL_RG_INTEGER));
+    set.insert(CopyConversion(GL_RED_INTEGER,     GL_RGB_INTEGER));
+    set.insert(CopyConversion(GL_RED_INTEGER,     GL_RGBA_INTEGER));
+    set.insert(CopyConversion(GL_RG_INTEGER,      GL_RG_INTEGER));
+    set.insert(CopyConversion(GL_RG_INTEGER,      GL_RGB_INTEGER));
+    set.insert(CopyConversion(GL_RG_INTEGER,      GL_RGBA_INTEGER));
+    set.insert(CopyConversion(GL_RGB_INTEGER,     GL_RGB_INTEGER));
+    set.insert(CopyConversion(GL_RGB_INTEGER,     GL_RGBA_INTEGER));
+    set.insert(CopyConversion(GL_RGBA_INTEGER,    GL_RGBA_INTEGER));
+
+    return set;
+}
+
+bool IsValidInternalFormat(GLenum internalFormat, const Context *context)
+{
+    if (!context)
+    {
+        return false;
+    }
+
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, context-&gt;getClientVersion(), &amp;internalFormatInfo))
+    {
+        ASSERT(internalFormatInfo.mSupportFunction != NULL);
+        return internalFormatInfo.mSupportFunction(context);
+    }
+    else
+    {
+        return false;
+    }
+}
+
+bool IsValidFormat(GLenum format, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        static const FormatSet formatSet = BuildES2ValidFormatSet();
+        return formatSet.find(format) != formatSet.end();
+    }
+    else if (clientVersion == 3)
+    {
+        static const FormatSet formatSet = BuildES3ValidFormatSet();
+        return formatSet.find(format) != formatSet.end();
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsValidType(GLenum type, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        static const TypeSet typeSet = BuildES2ValidTypeSet();
+        return typeSet.find(type) != typeSet.end();
+    }
+    else if (clientVersion == 3)
+    {
+        static const TypeSet typeSet = BuildES3ValidTypeSet();
+        return typeSet.find(type) != typeSet.end();
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        static const FormatMap &amp;formats = GetFormatMap(clientVersion);
+        FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type));
+
+        return (iter != formats.end()) &amp;&amp; ((internalFormat == (GLint)type) || (internalFormat == iter-&gt;second.mInternalFormat));
+    }
+    else if (clientVersion == 3)
+    {
+        static const ES3FormatSet &amp;formats = GetES3FormatSet();
+        return formats.find(FormatInfo(internalFormat, format, type)) != formats.end();
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint readBufferHandle, GLuint clientVersion)
+{
+    InternalFormatInfo textureInternalFormatInfo;
+    InternalFormatInfo framebufferInternalFormatInfo;
+    if (GetInternalFormatInfo(textureInternalFormat, clientVersion, &amp;textureInternalFormatInfo) &amp;&amp;
+        GetInternalFormatInfo(frameBufferInternalFormat, clientVersion, &amp;framebufferInternalFormatInfo))
+    {
+        if (clientVersion == 2)
+        {
+            UNIMPLEMENTED();
+            return false;
+        }
+        else if (clientVersion == 3)
+        {
+            static const CopyConversionSet conversionSet = BuildValidES3CopyTexImageCombinations();
+            const CopyConversion conversion = CopyConversion(textureInternalFormatInfo.mFormat,
+                                                             framebufferInternalFormatInfo.mFormat);
+            if (conversionSet.find(conversion) != conversionSet.end())
+            {
+                // Section 3.8.5 of the GLES 3.0.3 spec states that source and destination formats
+                // must both be signed, unsigned, or fixed point and both source and destinations
+                // must be either both SRGB or both not SRGB. EXT_color_buffer_float adds allowed
+                // conversion between fixed and floating point.
+
+                if ((textureInternalFormatInfo.mColorEncoding == GL_SRGB) != (framebufferInternalFormatInfo.mColorEncoding == GL_SRGB))
+                {
+                    return false;
+                }
+
+                if (((textureInternalFormatInfo.mComponentType == GL_INT) != (framebufferInternalFormatInfo.mComponentType == GL_INT)) ||
+                    ((textureInternalFormatInfo.mComponentType == GL_UNSIGNED_INT) != (framebufferInternalFormatInfo.mComponentType == GL_UNSIGNED_INT)))
+                {
+                    return false;
+                }
+
+                if (gl::IsFloatOrFixedComponentType(textureInternalFormatInfo.mComponentType) &amp;&amp;
+                    !gl::IsFloatOrFixedComponentType(framebufferInternalFormatInfo.mComponentType))
+                {
+                    return false;
+                }
+
+                // GLES specification 3.0.3, sec 3.8.5, pg 139-140:
+                // The effective internal format of the source buffer is determined with the following rules applied in order:
+                //    * If the source buffer is a texture or renderbuffer that was created with a sized internal format then the
+                //      effective internal format is the source buffer's sized internal format.
+                //    * If the source buffer is a texture that was created with an unsized base internal format, then the
+                //      effective internal format is the source image array's effective internal format, as specified by table
+                //      3.12, which is determined from the &lt;format&gt; and &lt;type&gt; that were used when the source image array was
+                //      specified by TexImage*.
+                //    * Otherwise the effective internal format is determined by the row in table 3.17 or 3.18 where
+                //      Destination Internal Format matches internalformat and where the [source channel sizes] are consistent
+                //      with the values of the source buffer's [channel sizes]. Table 3.17 is used if the
+                //      FRAMEBUFFER_ATTACHMENT_ENCODING is LINEAR and table 3.18 is used if the FRAMEBUFFER_ATTACHMENT_ENCODING
+                //      is SRGB.
+                InternalFormatInfo sourceEffectiveFormat;
+                if (readBufferHandle != 0)
+                {
+                    // Not the default framebuffer, therefore the read buffer must be a user-created texture or renderbuffer
+                    if (gl::IsSizedInternalFormat(framebufferInternalFormatInfo.mFormat, clientVersion))
+                    {
+                        sourceEffectiveFormat = framebufferInternalFormatInfo;
+                    }
+                    else
+                    {
+                        // Renderbuffers cannot be created with an unsized internal format, so this must be an unsized-format
+                        // texture. We can use the same table we use when creating textures to get its effective sized format.
+                        GLenum effectiveFormat = gl::GetSizedInternalFormat(framebufferInternalFormatInfo.mFormat,
+                                                                            framebufferInternalFormatInfo.mType, clientVersion);
+                        gl::GetInternalFormatInfo(effectiveFormat, clientVersion, &amp;sourceEffectiveFormat);
+                    }
+                }
+                else
+                {
+                    // The effective internal format must be derived from the source framebuffer's channel sizes.
+                    // This is done in GetEffectiveInternalFormat for linear buffers (table 3.17)
+                    if (framebufferInternalFormatInfo.mColorEncoding == GL_LINEAR)
+                    {
+                        GLenum effectiveFormat;
+                        if (GetEffectiveInternalFormat(framebufferInternalFormatInfo, textureInternalFormatInfo, clientVersion, &amp;effectiveFormat))
+                        {
+                            gl::GetInternalFormatInfo(effectiveFormat, clientVersion, &amp;sourceEffectiveFormat);
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else if (framebufferInternalFormatInfo.mColorEncoding == GL_SRGB)
+                    {
+                        // SRGB buffers can only be copied to sized format destinations according to table 3.18
+                        if (gl::IsSizedInternalFormat(textureInternalFormat, clientVersion) &amp;&amp;
+                            (framebufferInternalFormatInfo.mRedBits   &gt;= 1 &amp;&amp; framebufferInternalFormatInfo.mRedBits   &lt;= 8) &amp;&amp;
+                            (framebufferInternalFormatInfo.mGreenBits &gt;= 1 &amp;&amp; framebufferInternalFormatInfo.mGreenBits &lt;= 8) &amp;&amp;
+                            (framebufferInternalFormatInfo.mBlueBits  &gt;= 1 &amp;&amp; framebufferInternalFormatInfo.mBlueBits  &lt;= 8) &amp;&amp;
+                            (framebufferInternalFormatInfo.mAlphaBits &gt;= 1 &amp;&amp; framebufferInternalFormatInfo.mAlphaBits &lt;= 8))
+                        {
+                            gl::GetInternalFormatInfo(GL_SRGB8_ALPHA8, clientVersion, &amp;sourceEffectiveFormat);
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        UNREACHABLE();
+                    }
+                }
+
+                if (gl::IsSizedInternalFormat(textureInternalFormatInfo.mFormat, clientVersion))
+                {
+                    // Section 3.8.5 of the GLES 3.0.3 spec, pg 139, requires that, if the destination format is sized,
+                    // component sizes of the source and destination formats must exactly match
+                    if (textureInternalFormatInfo.mRedBits != sourceEffectiveFormat.mRedBits ||
+                        textureInternalFormatInfo.mGreenBits != sourceEffectiveFormat.mGreenBits ||
+                        textureInternalFormatInfo.mBlueBits != sourceEffectiveFormat.mBlueBits ||
+                        textureInternalFormatInfo.mAlphaBits != sourceEffectiveFormat.mAlphaBits)
+                    {
+                        return false;
+                    }
+                }
+
+
+                return true; // A conversion function exists, and no rule in the specification has precluded conversion
+                             // between these formats.
+            }
+
+            return false;
+        }
+        else
+        {
+            UNREACHABLE();
+            return false;
+        }
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsSizedInternalFormat(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mPixelBits &gt; 0;
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+GLenum GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion)
+{
+    const FormatMap &amp;formats = GetFormatMap(clientVersion);
+    FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type));
+    return (iter != formats.end()) ? iter-&gt;second.mInternalFormat : GL_NONE;
+}
+
+GLuint GetPixelBytes(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mPixelBits / 8;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetAlphaBits(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mAlphaBits;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetRedBits(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mRedBits;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetGreenBits(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mGreenBits;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetBlueBits(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mBlueBits;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetLuminanceBits(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mLuminanceBits;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetDepthBits(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mDepthBits;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetStencilBits(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mStencilBits;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetTypeBytes(GLenum type)
+{
+    TypeInfo typeInfo;
+    if (GetTypeInfo(type, &amp;typeInfo))
+    {
+        return typeInfo.mTypeBytes;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+bool IsSpecialInterpretationType(GLenum type)
+{
+    TypeInfo typeInfo;
+    if (GetTypeInfo(type, &amp;typeInfo))
+    {
+        return typeInfo.mSpecialInterpretation;
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsFloatOrFixedComponentType(GLenum type)
+{
+    if (type == GL_UNSIGNED_NORMALIZED ||
+        type == GL_SIGNED_NORMALIZED ||
+        type == GL_FLOAT)
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+GLenum GetFormat(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mFormat;
+    }
+    else
+    {
+        UNREACHABLE();
+        return GL_NONE;
+    }
+}
+
+GLenum GetType(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mType;
+    }
+    else
+    {
+        UNREACHABLE();
+        return GL_NONE;
+    }
+}
+
+GLenum GetComponentType(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mComponentType;
+    }
+    else
+    {
+        UNREACHABLE();
+        return GL_NONE;
+    }
+}
+
+GLuint GetComponentCount(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mComponentCount;
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+GLenum GetColorEncoding(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mColorEncoding;
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsColorRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (renderer &amp;&amp; GetInternalFormatInfo(internalFormat, renderer-&gt;getCurrentClientVersion(), &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mIsColorRenderable(NULL, renderer);
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsColorRenderingSupported(GLenum internalFormat, const Context *context)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (context &amp;&amp; GetInternalFormatInfo(internalFormat, context-&gt;getClientVersion(), &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mIsColorRenderable(context, NULL);
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsTextureFilteringSupported(GLenum internalFormat, const rx::Renderer *renderer)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (renderer &amp;&amp; GetInternalFormatInfo(internalFormat, renderer-&gt;getCurrentClientVersion(), &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mIsTextureFilterable(NULL, renderer);
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsTextureFilteringSupported(GLenum internalFormat, const Context *context)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (context &amp;&amp; GetInternalFormatInfo(internalFormat, context-&gt;getClientVersion(), &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mIsTextureFilterable(context, NULL);
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsDepthRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (renderer &amp;&amp; GetInternalFormatInfo(internalFormat, renderer-&gt;getCurrentClientVersion(), &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mIsDepthRenderable(NULL, renderer);
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsDepthRenderingSupported(GLenum internalFormat, const Context *context)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (context &amp;&amp; GetInternalFormatInfo(internalFormat, context-&gt;getClientVersion(), &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mIsDepthRenderable(context, NULL);
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsStencilRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (renderer &amp;&amp; GetInternalFormatInfo(internalFormat, renderer-&gt;getCurrentClientVersion(), &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mIsStencilRenderable(NULL, renderer);
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+bool IsStencilRenderingSupported(GLenum internalFormat, const Context *context)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (context &amp;&amp; GetInternalFormatInfo(internalFormat, context-&gt;getClientVersion(), &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mIsStencilRenderable(context, NULL);
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment)
+{
+    ASSERT(alignment &gt; 0 &amp;&amp; isPow2(alignment));
+    return rx::roundUp(GetBlockSize(internalFormat, type, clientVersion, width, 1), static_cast&lt;GLuint&gt;(alignment));
+}
+
+GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment)
+{
+    return GetRowPitch(internalFormat, type, clientVersion, width, alignment) * height;
+}
+
+GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        if (internalFormatInfo.mIsCompressed)
+        {
+            GLsizei numBlocksWide = (width + internalFormatInfo.mCompressedBlockWidth - 1) / internalFormatInfo.mCompressedBlockWidth;
+            GLsizei numBlocksHight = (height + internalFormatInfo.mCompressedBlockHeight - 1) / internalFormatInfo.mCompressedBlockHeight;
+
+            return (internalFormatInfo.mPixelBits * numBlocksWide * numBlocksHight) / 8;
+        }
+        else
+        {
+            TypeInfo typeInfo;
+            if (GetTypeInfo(type, &amp;typeInfo))
+            {
+                if (typeInfo.mSpecialInterpretation)
+                {
+                    return typeInfo.mTypeBytes * width * height;
+                }
+                else
+                {
+                    return internalFormatInfo.mComponentCount * typeInfo.mTypeBytes * width * height;
+                }
+            }
+            else
+            {
+                UNREACHABLE();
+                return 0;
+            }
+        }
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+bool IsFormatCompressed(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mIsCompressed;
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
+}
+
+GLuint GetCompressedBlockWidth(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mCompressedBlockWidth;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetCompressedBlockHeight(GLenum internalFormat, GLuint clientVersion)
+{
+    InternalFormatInfo internalFormatInfo;
+    if (GetInternalFormatInfo(internalFormat, clientVersion, &amp;internalFormatInfo))
+    {
+        return internalFormatInfo.mCompressedBlockHeight;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion)
+{
+    static const FormatMap &amp;formats = GetFormatMap(clientVersion);
+    FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type));
+    return (iter != formats.end()) ? iter-&gt;second.mColorWriteFunction : NULL;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2formatutilsh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/formatutils.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/formatutils.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/formatutils.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,99 @@
</span><ins>+//
+// 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.
+//
+
+// formatutils.h: Queries for GL image formats.
+
+#ifndef LIBGLESV2_FORMATUTILS_H_
+#define LIBGLESV2_FORMATUTILS_H_
+
+#define GL_APICALL
+#include &lt;GLES3/gl3.h&gt;
+#include &lt;GLES2/gl2.h&gt;
+#include &lt;GLES2/gl2ext.h&gt;
+
+#include &quot;libGLESv2/angletypes.h&quot;
+
+typedef void (*MipGenerationFunction)(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                                      const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                                      unsigned char *destData, int destRowPitch, int destDepthPitch);
+
+typedef void (*LoadImageFunction)(int width, int height, int depth,
+                                  const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
+                                  void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
+
+typedef void (*InitializeTextureDataFunction)(int width, int height, int depth,
+                                              void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
+
+typedef void (*ColorReadFunction)(const void *source, void *dest);
+typedef void (*ColorWriteFunction)(const void *source, void *dest);
+typedef void (*ColorCopyFunction)(const void *source, void *dest);
+
+typedef void (*VertexCopyFunction)(const void *input, size_t stride, size_t count, void *output);
+
+namespace rx
+{
+
+class Renderer;
+
+}
+
+namespace gl
+{
+
+class Context;
+
+bool IsValidInternalFormat(GLenum internalFormat, const Context *context);
+bool IsValidFormat(GLenum format, GLuint clientVersion);
+bool IsValidType(GLenum type, GLuint clientVersion);
+
+bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, GLuint clientVersion);
+bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint readBufferHandle, GLuint clientVersion);
+
+bool IsSizedInternalFormat(GLenum internalFormat, GLuint clientVersion);
+GLenum GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion);
+
+GLuint GetPixelBytes(GLenum internalFormat, GLuint clientVersion);
+GLuint GetAlphaBits(GLenum internalFormat, GLuint clientVersion);
+GLuint GetRedBits(GLenum internalFormat, GLuint clientVersion);
+GLuint GetGreenBits(GLenum internalFormat, GLuint clientVersion);
+GLuint GetBlueBits(GLenum internalFormat, GLuint clientVersion);
+GLuint GetLuminanceBits(GLenum internalFormat, GLuint clientVersion);
+GLuint GetDepthBits(GLenum internalFormat, GLuint clientVersion);
+GLuint GetStencilBits(GLenum internalFormat, GLuint clientVersion);
+
+GLuint GetTypeBytes(GLenum type);
+bool IsSpecialInterpretationType(GLenum type);
+bool IsFloatOrFixedComponentType(GLenum type);
+
+GLenum GetFormat(GLenum internalFormat, GLuint clientVersion);
+GLenum GetType(GLenum internalFormat, GLuint clientVersion);
+
+GLenum GetComponentType(GLenum internalFormat, GLuint clientVersion);
+GLuint GetComponentCount(GLenum internalFormat, GLuint clientVersion);
+GLenum GetColorEncoding(GLenum internalFormat, GLuint clientVersion);
+
+bool IsColorRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer);
+bool IsColorRenderingSupported(GLenum internalFormat, const Context *context);
+bool IsTextureFilteringSupported(GLenum internalFormat, const rx::Renderer *renderer);
+bool IsTextureFilteringSupported(GLenum internalFormat, const Context *context);
+bool IsDepthRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer);
+bool IsDepthRenderingSupported(GLenum internalFormat, const Context *context);
+bool IsStencilRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer);
+bool IsStencilRenderingSupported(GLenum internalFormat, const Context *context);
+
+GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment);
+GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment);
+GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height);
+
+bool IsFormatCompressed(GLenum internalFormat, GLuint clientVersion);
+GLuint GetCompressedBlockWidth(GLenum internalFormat, GLuint clientVersion);
+GLuint GetCompressedBlockHeight(GLenum internalFormat, GLuint clientVersion);
+
+ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion);
+
+}
+
+#endif LIBGLESV2_FORMATUTILS_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2libGLESv2cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -10,7 +10,8 @@
</span><span class="cx"> #include &quot;common/version.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;common/utilities.h&quot;
+#include &quot;libGLESv2/formatutils.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/Buffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Fence.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Framebuffer.h&quot;
</span><span class="lines">@@ -20,242 +21,19 @@
</span><span class="cx"> #include &quot;libGLESv2/Texture.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Query.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Context.h&quot;
</span><ins>+#include &quot;libGLESv2/VertexArray.h&quot;
+#include &quot;libGLESv2/TransformFeedback.h&quot;
</ins><span class="cx"> 
</span><del>-bool validImageSize(GLint level, GLsizei width, GLsizei height)
-{
-    if (level &lt; 0 || width &lt; 0 || height &lt; 0)
-    {
-        return false;
-    }
</del><ins>+#include &quot;libGLESv2/validationES.h&quot;
+#include &quot;libGLESv2/validationES2.h&quot;
+#include &quot;libGLESv2/validationES3.h&quot;
+#include &quot;libGLESv2/queryconversions.h&quot;
</ins><span class="cx"> 
</span><del>-    if (gl::getContext() &amp;&amp; gl::getContext()-&gt;supportsNonPower2Texture())
-    {
-        return true;
-    }
-
-    if (level == 0)
-    {
-        return true;
-    }
-
-    if (gl::isPow2(width) &amp;&amp; gl::isPow2(height))
-    {
-        return true;
-    }
-
-    return false;
-}
-
-// Verify that format/type are one of the combinations from table 3.4.
-bool checkTextureFormatType(GLenum format, GLenum type)
</del><ins>+extern &quot;C&quot;
</ins><span class="cx"> {
</span><del>-    // validate &lt;format&gt; by itself (used as secondary key below)
-    switch (format)
-    {
-      case GL_RGBA:
-      case GL_BGRA_EXT:
-      case GL_RGB:
-      case GL_ALPHA:
-      case GL_LUMINANCE:
-      case GL_LUMINANCE_ALPHA:
-      case GL_DEPTH_COMPONENT:
-      case GL_DEPTH_STENCIL_OES:
-        break;
-      default:
-        return gl::error(GL_INVALID_ENUM, false);
-    }
</del><span class="cx"> 
</span><del>-    // invalid &lt;type&gt; -&gt; sets INVALID_ENUM
-    // invalid &lt;format&gt;+&lt;type&gt; combination -&gt; sets INVALID_OPERATION
-    switch (type)
-    {
-      case GL_UNSIGNED_BYTE:
-        switch (format)
-        {
-          case GL_RGBA:
-          case GL_BGRA_EXT:
-          case GL_RGB:
-          case GL_ALPHA:
-          case GL_LUMINANCE:
-          case GL_LUMINANCE_ALPHA:
-            return true;
-          default:
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
</del><ins>+// OpenGL ES 2.0 functions
</ins><span class="cx"> 
</span><del>-      case GL_FLOAT:
-      case GL_HALF_FLOAT_OES:
-        switch (format)
-        {
-          case GL_RGBA:
-          case GL_RGB:
-          case GL_ALPHA:
-          case GL_LUMINANCE:
-          case GL_LUMINANCE_ALPHA:
-            return true;
-          default:
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
-
-      case GL_UNSIGNED_SHORT_4_4_4_4:
-      case GL_UNSIGNED_SHORT_5_5_5_1:
-        switch (format)
-        {
-          case GL_RGBA:
-            return true;
-          default:
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
-
-      case GL_UNSIGNED_SHORT_5_6_5:
-        switch (format)
-        {
-          case GL_RGB:
-            return true;
-          default:
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
-
-      case GL_UNSIGNED_SHORT:
-      case GL_UNSIGNED_INT:
-        switch (format)
-        {
-          case GL_DEPTH_COMPONENT:
-            return true;
-          default:
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
-
-      case GL_UNSIGNED_INT_24_8_OES:
-        switch (format)
-        {
-          case GL_DEPTH_STENCIL_OES:
-            return true;
-          default:
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
-
-      default:
-        return gl::error(GL_INVALID_ENUM, false);
-    }
-}
-
-bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height,
-                              GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type,
-                              gl::Texture2D *texture)
-{
-    if (!texture)
-    {
-        return gl::error(GL_INVALID_OPERATION, false);
-    }
-
-    if (compressed != texture-&gt;isCompressed(level))
-    {
-        return gl::error(GL_INVALID_OPERATION, false);
-    }
-
-    if (format != GL_NONE)
-    {
-        GLenum internalformat = gl::ConvertSizedInternalFormat(format, type);
-        if (internalformat != texture-&gt;getInternalFormat(level))
-        {
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
-    }
-
-    if (compressed)
-    {
-        if ((width % 4 != 0 &amp;&amp; width != texture-&gt;getWidth(0)) ||
-            (height % 4 != 0 &amp;&amp; height != texture-&gt;getHeight(0)))
-        {
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
-    }
-
-    if (xoffset + width &gt; texture-&gt;getWidth(level) ||
-        yoffset + height &gt; texture-&gt;getHeight(level))
-    {
-        return gl::error(GL_INVALID_VALUE, false);
-    }
-
-    return true;
-}
-
-bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height,
-                                GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type,
-                                gl::TextureCubeMap *texture)
-{
-    if (!texture)
-    {
-        return gl::error(GL_INVALID_OPERATION, false);
-    }
-
-    if (compressed != texture-&gt;isCompressed(target, level))
-    {
-        return gl::error(GL_INVALID_OPERATION, false);
-    }
-
-    if (format != GL_NONE)
-    {
-        GLenum internalformat = gl::ConvertSizedInternalFormat(format, type);
-        if (internalformat != texture-&gt;getInternalFormat(target, level))
-        {
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
-    }
-
-    if (compressed)
-    {
-        if ((width % 4 != 0 &amp;&amp; width != texture-&gt;getWidth(target, 0)) ||
-            (height % 4 != 0 &amp;&amp; height != texture-&gt;getHeight(target, 0)))
-        {
-            return gl::error(GL_INVALID_OPERATION, false);
-        }
-    }
-
-    if (xoffset + width &gt; texture-&gt;getWidth(target, level) ||
-        yoffset + height &gt; texture-&gt;getHeight(target, level))
-    {
-        return gl::error(GL_INVALID_VALUE, false);
-    }
-
-    return true;
-}
-
-// check for combinations of format and type that are valid for ReadPixels
-bool validReadFormatType(GLenum format, GLenum type)
-{
-    switch (format)
-    {
-      case GL_RGBA:
-        switch (type)
-        {
-          case GL_UNSIGNED_BYTE:
-            break;
-          default:
-            return false;
-        }
-        break;
-      case GL_BGRA_EXT:
-        switch (type)
-        {
-          case GL_UNSIGNED_BYTE:
-          case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
-          case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
-            break;
-          default:
-            return false;
-        }
-        break;
-      default:
-        return false;
-    }
-    return true;
-}
-
-extern &quot;C&quot;
-{
-
</del><span class="cx"> void __stdcall glActiveTexture(GLenum texture)
</span><span class="cx"> {
</span><span class="cx">     EVENT(&quot;(GLenum texture = 0x%X)&quot;, texture);
</span><span class="lines">@@ -335,24 +113,20 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        switch (target)
-        {
-          case GL_ANY_SAMPLES_PASSED_EXT: 
-          case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
-              break;
-          default: 
-              return gl::error(GL_INVALID_ENUM);
-        }
</del><ins>+        gl::Context *context = gl::getNonLostContext();
</ins><span class="cx"> 
</span><del>-        if (id == 0)
</del><ins>+        if (context)
</ins><span class="cx">         {
</span><del>-            return gl::error(GL_INVALID_OPERATION);
-        }
</del><ins>+            if (!ValidQueryType(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
</ins><span class="cx"> 
</span><del>-        gl::Context *context = gl::getNonLostContext();
</del><ins>+            if (id == 0)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
</ins><span class="cx"> 
</span><del>-        if (context)
-        {
</del><span class="cx">             context-&gt;beginQuery(target, id);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -415,6 +189,11 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><ins>+            if (!gl::ValidBufferTarget(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
</ins><span class="cx">             switch (target)
</span><span class="cx">             {
</span><span class="cx">               case GL_ARRAY_BUFFER:
</span><span class="lines">@@ -423,6 +202,24 @@
</span><span class="cx">               case GL_ELEMENT_ARRAY_BUFFER:
</span><span class="cx">                 context-&gt;bindElementArrayBuffer(buffer);
</span><span class="cx">                 return;
</span><ins>+              case GL_COPY_READ_BUFFER:
+                context-&gt;bindCopyReadBuffer(buffer);
+                return;
+              case GL_COPY_WRITE_BUFFER:
+                context-&gt;bindCopyWriteBuffer(buffer);
+                return;
+              case GL_PIXEL_PACK_BUFFER:
+                context-&gt;bindPixelPackBuffer(buffer);
+                return;
+              case GL_PIXEL_UNPACK_BUFFER:
+                context-&gt;bindPixelUnpackBuffer(buffer);
+                return;
+              case GL_UNIFORM_BUFFER:
+                context-&gt;bindGenericUniformBuffer(buffer);
+                return;
+              case GL_TRANSFORM_FEEDBACK_BUFFER:
+                context-&gt;bindGenericTransformFeedbackBuffer(buffer);
+                return;
</ins><span class="cx">               default:
</span><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="lines">@@ -440,7 +237,7 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (target != GL_FRAMEBUFFER &amp;&amp; target != GL_DRAW_FRAMEBUFFER_ANGLE &amp;&amp; target != GL_READ_FRAMEBUFFER_ANGLE)
</del><ins>+        if (!gl::ValidFramebufferTarget(target))
</ins><span class="cx">         {
</span><span class="cx">             return gl::error(GL_INVALID_ENUM);
</span><span class="cx">         }
</span><span class="lines">@@ -515,6 +312,20 @@
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP:
</span><span class="cx">                 context-&gt;bindTextureCubeMap(texture);
</span><span class="cx">                 return;
</span><ins>+              case GL_TEXTURE_3D:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                context-&gt;bindTexture3D(texture);
+                return;
+              case GL_TEXTURE_2D_ARRAY:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                context-&gt;bindTexture2DArray(texture);
+                return;
</ins><span class="cx">               default:
</span><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="lines">@@ -557,12 +368,17 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><ins>+        gl::Context *context = gl::getNonLostContext();
+
</ins><span class="cx">         switch (modeRGB)
</span><span class="cx">         {
</span><span class="cx">           case GL_FUNC_ADD:
</span><span class="cx">           case GL_FUNC_SUBTRACT:
</span><span class="cx">           case GL_FUNC_REVERSE_SUBTRACT:
</span><ins>+          case GL_MIN:
+          case GL_MAX:
</ins><span class="cx">             break;
</span><ins>+
</ins><span class="cx">           default:
</span><span class="cx">             return gl::error(GL_INVALID_ENUM);
</span><span class="cx">         }
</span><span class="lines">@@ -572,13 +388,14 @@
</span><span class="cx">           case GL_FUNC_ADD:
</span><span class="cx">           case GL_FUNC_SUBTRACT:
</span><span class="cx">           case GL_FUNC_REVERSE_SUBTRACT:
</span><ins>+          case GL_MIN:
+          case GL_MAX:
</ins><span class="cx">             break;
</span><ins>+
</ins><span class="cx">           default:
</span><span class="cx">             return gl::error(GL_INVALID_ENUM);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        gl::Context *context = gl::getNonLostContext();
-
</del><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             context-&gt;setBlendEquation(modeRGB, modeAlpha);
</span><span class="lines">@@ -602,6 +419,8 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><ins>+        gl::Context *context = gl::getNonLostContext();
+
</ins><span class="cx">         switch (srcRGB)
</span><span class="cx">         {
</span><span class="cx">           case GL_ZERO:
</span><span class="lines">@@ -641,6 +460,14 @@
</span><span class="cx">           case GL_CONSTANT_ALPHA:
</span><span class="cx">           case GL_ONE_MINUS_CONSTANT_ALPHA:
</span><span class="cx">             break;
</span><ins>+
+          case GL_SRC_ALPHA_SATURATE:
+            if (!context || context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+            break;
+
</ins><span class="cx">           default:
</span><span class="cx">             return gl::error(GL_INVALID_ENUM);
</span><span class="cx">         }
</span><span class="lines">@@ -684,6 +511,14 @@
</span><span class="cx">           case GL_CONSTANT_ALPHA:
</span><span class="cx">           case GL_ONE_MINUS_CONSTANT_ALPHA:
</span><span class="cx">             break;
</span><ins>+
+          case GL_SRC_ALPHA_SATURATE:
+            if (!context || context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+            break;
+
</ins><span class="cx">           default:
</span><span class="cx">             return gl::error(GL_INVALID_ENUM);
</span><span class="cx">         }
</span><span class="lines">@@ -700,8 +535,6 @@
</span><span class="cx">             return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        gl::Context *context = gl::getNonLostContext();
-
</del><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             context-&gt;setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
</span><span class="lines">@@ -725,34 +558,40 @@
</span><span class="cx">             return gl::error(GL_INVALID_VALUE);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        gl::Context *context = gl::getNonLostContext();
+
</ins><span class="cx">         switch (usage)
</span><span class="cx">         {
</span><span class="cx">           case GL_STREAM_DRAW:
</span><span class="cx">           case GL_STATIC_DRAW:
</span><span class="cx">           case GL_DYNAMIC_DRAW:
</span><span class="cx">             break;
</span><ins>+
+          case GL_STREAM_READ:
+          case GL_STREAM_COPY:
+          case GL_STATIC_READ:
+          case GL_STATIC_COPY:
+          case GL_DYNAMIC_READ:
+          case GL_DYNAMIC_COPY:
+            if (context &amp;&amp; context-&gt;getClientVersion() &lt; 3)
+            {
+              return gl::error(GL_INVALID_ENUM);
+            }
+            break;
+
</ins><span class="cx">           default:
</span><span class="cx">             return gl::error(GL_INVALID_ENUM);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        gl::Context *context = gl::getNonLostContext();
-
</del><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Buffer *buffer;
-
-            switch (target)
</del><ins>+            if (!gl::ValidBufferTarget(context, target))
</ins><span class="cx">             {
</span><del>-              case GL_ARRAY_BUFFER:
-                buffer = context-&gt;getArrayBuffer();
-                break;
-              case GL_ELEMENT_ARRAY_BUFFER:
-                buffer = context-&gt;getElementArrayBuffer();
-                break;
-              default:
</del><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            gl::Buffer *buffer = context-&gt;getTargetBuffer(target);
+
</ins><span class="cx">             if (!buffer)
</span><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="lines">@@ -788,25 +627,23 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Buffer *buffer;
-
-            switch (target)
</del><ins>+            if (!gl::ValidBufferTarget(context, target))
</ins><span class="cx">             {
</span><del>-              case GL_ARRAY_BUFFER:
-                buffer = context-&gt;getArrayBuffer();
-                break;
-              case GL_ELEMENT_ARRAY_BUFFER:
-                buffer = context-&gt;getElementArrayBuffer();
-                break;
-              default:
</del><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            gl::Buffer *buffer = context-&gt;getTargetBuffer(target);
+
</ins><span class="cx">             if (!buffer)
</span><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            if (buffer-&gt;mapped())
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
</ins><span class="cx">             if ((size_t)size + offset &gt; buffer-&gt;size())
</span><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_VALUE);
</span><span class="lines">@@ -827,7 +664,7 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (target != GL_FRAMEBUFFER &amp;&amp; target != GL_DRAW_FRAMEBUFFER_ANGLE &amp;&amp; target != GL_READ_FRAMEBUFFER_ANGLE)
</del><ins>+        if (!gl::ValidFramebufferTarget(target))
</ins><span class="cx">         {
</span><span class="cx">             return gl::error(GL_INVALID_ENUM, 0);
</span><span class="cx">         }
</span><span class="lines">@@ -836,16 +673,8 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Framebuffer *framebuffer = NULL;
-            if (target == GL_READ_FRAMEBUFFER_ANGLE)
-            {
-                framebuffer = context-&gt;getReadFramebuffer();
-            }
-            else
-            {
-                framebuffer = context-&gt;getDrawFramebuffer();
-            }
-
</del><ins>+            gl::Framebuffer *framebuffer = context-&gt;getTargetFramebuffer(target);
+            ASSERT(framebuffer);
</ins><span class="cx">             return framebuffer-&gt;completeness();
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -859,7 +688,7 @@
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glClear(GLbitfield mask)
</span><span class="cx"> {
</span><del>-    EVENT(&quot;(GLbitfield mask = %X)&quot;, mask);
</del><ins>+    EVENT(&quot;(GLbitfield mask = 0x%X)&quot;, mask);
</ins><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><span class="lines">@@ -867,6 +696,18 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><ins>+            gl::Framebuffer *framebufferObject = context-&gt;getDrawFramebuffer();
+
+            if (!framebufferObject || framebufferObject-&gt;completeness() != GL_FRAMEBUFFER_COMPLETE)
+            {
+                return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
+            }
+
+            if ((mask &amp; ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
</ins><span class="cx">             context-&gt;clear(mask);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -936,7 +777,7 @@
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
</span><span class="cx"> {
</span><del>-    EVENT(&quot;(GLboolean red = %d, GLboolean green = %d, GLboolean blue = %d, GLboolean alpha = %d)&quot;,
</del><ins>+    EVENT(&quot;(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)&quot;,
</ins><span class="cx">           red, green, blue, alpha);
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="lines">@@ -996,149 +837,54 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (!validImageSize(level, width, height) || border != 0 || imageSize &lt; 0)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        switch (internalformat)
-        {
-          case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-          case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-          case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-          case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-            break;
-          default:
-            return gl::error(GL_INVALID_ENUM);
-        }
-
-        if (border != 0)
-        {
-            return gl::error(GL_INVALID_OPERATION);
-        }
-
-        if (width != 1 &amp;&amp; width != 2 &amp;&amp; width % 4 != 0)
-        {
-            return gl::error(GL_INVALID_OPERATION);
-        }
-
-        if (height != 1 &amp;&amp; height != 2 &amp;&amp; height % 4 != 0)
-        {
-            return gl::error(GL_INVALID_OPERATION);
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (level &gt; context-&gt;getMaximumTextureLevel())
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3 &amp;&amp;
+                !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
+                                               0, 0, width, height, 0, GL_NONE, GL_NONE, data))
</ins><span class="cx">             {
</span><ins>+                return;
+            }
+
+            if (context-&gt;getClientVersion() &gt;= 3 &amp;&amp;
+                !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
+                                               0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
+            {
+                return;
+            }
+
+            if (imageSize &lt; 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context-&gt;getClientVersion(), width, height))
+            {
</ins><span class="cx">                 return gl::error(GL_INVALID_VALUE);
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             switch (target)
</span><span class="cx">             {
</span><span class="cx">               case GL_TEXTURE_2D:
</span><del>-                if (width &gt; (context-&gt;getMaximumTextureDimension() &gt;&gt; level) ||
-                    height &gt; (context-&gt;getMaximumTextureDimension() &gt;&gt; level))
</del><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_VALUE);
</del><ins>+                    gl::Texture2D *texture = context-&gt;getTexture2D();
+                    texture-&gt;setCompressedImage(level, internalformat, width, height, imageSize, data);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><ins>+
</ins><span class="cx">               case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
</span><del>-                if (width != height)
</del><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_VALUE);
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;setCompressedImage(target, level, internalformat, width, height, imageSize, data);
</ins><span class="cx">                 }
</span><ins>+                break;
</ins><span class="cx"> 
</span><del>-                if (width &gt; (context-&gt;getMaximumCubeTextureDimension() &gt;&gt; level) ||
-                    height &gt; (context-&gt;getMaximumCubeTextureDimension() &gt;&gt; level))
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
-                break;
</del><span class="cx">               default:
</span><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><del>-
-            switch (internalformat) {
-              case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-              case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-                if (!context-&gt;supportsDXT1Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
-                }
-                break;
-              case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-                if (!context-&gt;supportsDXT3Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
-                }
-                break;
-              case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-                if (!context-&gt;supportsDXT5Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
-                }
-                break;
-              default: UNREACHABLE();
-            }
-
-            if (imageSize != gl::ComputeCompressedSize(width, height, internalformat))
-            {
-                return gl::error(GL_INVALID_VALUE);
-            }
-
-            if (target == GL_TEXTURE_2D)
-            {
-                gl::Texture2D *texture = context-&gt;getTexture2D();
-
-                if (!texture)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                if (texture-&gt;isImmutable())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                texture-&gt;setCompressedImage(level, internalformat, width, height, imageSize, data);
-            }
-            else
-            {
-                gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
-
-                if (!texture)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                if (texture-&gt;isImmutable())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                switch (target)
-                {
-                  case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-                  case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-                  case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-                  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-                  case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-                  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-                    texture-&gt;setCompressedImage(target, level, internalformat, width, height, imageSize, data);
-                    break;
-                  default: UNREACHABLE();
-                }
-            }
</del><span class="cx">         }
</span><del>-
</del><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="cx">     {
</span><span class="lines">@@ -1156,95 +902,53 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (!gl::IsInternalTextureTarget(target))
-        {
-            return gl::error(GL_INVALID_ENUM);
-        }
-
-        if (xoffset &lt; 0 || yoffset &lt; 0 || !validImageSize(level, width, height) || imageSize &lt; 0)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        switch (format)
-        {
-          case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-          case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-          case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-          case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-            break;
-          default:
-            return gl::error(GL_INVALID_ENUM);
-        }
-
-        if (width == 0 || height == 0 || data == NULL)
-        {
-            return;
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (level &gt; context-&gt;getMaximumTextureLevel())
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3 &amp;&amp;
+                !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
+                                               xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
</ins><span class="cx">             {
</span><del>-                return gl::error(GL_INVALID_VALUE);
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            switch (format) {
-              case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-              case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-                if (!context-&gt;supportsDXT1Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
-                }
-                break;
-              case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-                if (!context-&gt;supportsDXT3Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
-                }
-                break;
-              case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-                if (!context-&gt;supportsDXT5Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
-                }
-                break;
-              default: UNREACHABLE();
</del><ins>+            if (context-&gt;getClientVersion() &gt;= 3 &amp;&amp;
+                !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
+                                               xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
+            {
+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (imageSize != gl::ComputeCompressedSize(width, height, format))
</del><ins>+            if (imageSize &lt; 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context-&gt;getClientVersion(), width, height))
</ins><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_VALUE);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (xoffset % 4 != 0 || yoffset % 4 != 0)
</del><ins>+            switch (target)
</ins><span class="cx">             {
</span><del>-                return gl::error(GL_INVALID_OPERATION); // we wait to check the offsets until this point, because the multiple-of-four restriction
-                                                    // does not exist unless DXT textures are supported.
-            }
-
-            if (target == GL_TEXTURE_2D)
-            {
-                gl::Texture2D *texture = context-&gt;getTexture2D();
-                if (validateSubImageParams2D(true, width, height, xoffset, yoffset, level, format, GL_NONE, texture))
</del><ins>+              case GL_TEXTURE_2D:
</ins><span class="cx">                 {
</span><ins>+                    gl::Texture2D *texture = context-&gt;getTexture2D();
</ins><span class="cx">                     texture-&gt;subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
</span><span class="cx">                 }
</span><del>-            }
-            else if (gl::IsCubemapTextureTarget(target))
-            {
-                gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
-                if (validateSubImageParamsCube(true, width, height, xoffset, yoffset, target, level, format, GL_NONE, texture))
</del><ins>+                break;
+
+              case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+              case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+              case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
</ins><span class="cx">                 {
</span><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
</ins><span class="cx">                     texture-&gt;subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
</span><span class="cx">                 }
</span><ins>+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
</ins><span class="cx">             }
</span><del>-            else
-            {
-                UNREACHABLE();
-            }
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -1261,186 +965,50 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (!validImageSize(level, width, height))
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        if (border != 0)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (level &gt; context-&gt;getMaximumTextureLevel())
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3 &amp;&amp;
+                !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
+                                                   0, 0, x, y, width, height, border))
</ins><span class="cx">             {
</span><del>-                return gl::error(GL_INVALID_VALUE);
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            if (context-&gt;getClientVersion() &gt;= 3 &amp;&amp;
+                !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
+                                                   0, 0, 0, x, y, width, height, border))
+            {
+                return;
+            }
+
+            gl::Framebuffer *framebuffer = context-&gt;getReadFramebuffer();
+
</ins><span class="cx">             switch (target)
</span><span class="cx">             {
</span><span class="cx">               case GL_TEXTURE_2D:
</span><del>-                if (width &gt; (context-&gt;getMaximumTextureDimension() &gt;&gt; level) ||
-                    height &gt; (context-&gt;getMaximumTextureDimension() &gt;&gt; level))
</del><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_VALUE);
</del><ins>+                    gl::Texture2D *texture = context-&gt;getTexture2D();
+                    texture-&gt;copyImage(level, internalformat, x, y, width, height, framebuffer);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><ins>+
</ins><span class="cx">               case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
</span><del>-                if (width != height)
</del><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_VALUE);
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;copyImage(target, level, internalformat, x, y, width, height, framebuffer);
</ins><span class="cx">                 }
</span><del>-
-                if (width &gt; (context-&gt;getMaximumCubeTextureDimension() &gt;&gt; level) ||
-                    height &gt; (context-&gt;getMaximumCubeTextureDimension() &gt;&gt; level))
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
</del><span class="cx">                 break;
</span><del>-              default:
-                return gl::error(GL_INVALID_ENUM);
-            }
</del><span class="cx"> 
</span><del>-            gl::Framebuffer *framebuffer = context-&gt;getReadFramebuffer();
-
-            if (framebuffer-&gt;completeness() != GL_FRAMEBUFFER_COMPLETE)
-            {
-                return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
-            }
-
-            if (context-&gt;getReadFramebufferHandle() != 0 &amp;&amp; framebuffer-&gt;getSamples() != 0)
-            {
-                return gl::error(GL_INVALID_OPERATION);
-            }
-
-            gl::Renderbuffer *source = framebuffer-&gt;getReadColorbuffer();
-            GLenum colorbufferFormat = source-&gt;getInternalFormat();
-
-            // [OpenGL ES 2.0.24] table 3.9
-            switch (internalformat)
-            {
-              case GL_ALPHA:
-                if (colorbufferFormat != GL_ALPHA8_EXT &amp;&amp;
-                    colorbufferFormat != GL_RGBA4 &amp;&amp;
-                    colorbufferFormat != GL_RGB5_A1 &amp;&amp;
-                    colorbufferFormat != GL_BGRA8_EXT &amp;&amp;
-                    colorbufferFormat != GL_RGBA8_OES)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                break;
-              case GL_LUMINANCE:
-              case GL_RGB:
-                if (colorbufferFormat != GL_RGB565 &amp;&amp;
-                    colorbufferFormat != GL_RGB8_OES &amp;&amp;
-                    colorbufferFormat != GL_RGBA4 &amp;&amp;
-                    colorbufferFormat != GL_RGB5_A1 &amp;&amp;
-                    colorbufferFormat != GL_BGRA8_EXT &amp;&amp;
-                    colorbufferFormat != GL_RGBA8_OES)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                break;
-              case GL_LUMINANCE_ALPHA:
-              case GL_RGBA:
-                if (colorbufferFormat != GL_RGBA4 &amp;&amp;
-                    colorbufferFormat != GL_RGB5_A1 &amp;&amp;
-                    colorbufferFormat != GL_BGRA8_EXT &amp;&amp;
-                    colorbufferFormat != GL_RGBA8_OES)
-                 {
-                     return gl::error(GL_INVALID_OPERATION);
-                 }
-                 break;
-              case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-              case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-                if (context-&gt;supportsDXT1Textures())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                else
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-                if (context-&gt;supportsDXT3Textures())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                else
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-                if (context-&gt;supportsDXT5Textures())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                else
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_DEPTH_COMPONENT:
-              case GL_DEPTH_COMPONENT16:
-              case GL_DEPTH_COMPONENT32_OES:
-              case GL_DEPTH_STENCIL_OES:
-              case GL_DEPTH24_STENCIL8_OES:
-                  if (context-&gt;supportsDepthTextures())
-                  {
-                      return gl::error(GL_INVALID_OPERATION);
-                  }
-                  else
-                  {
-                      return gl::error(GL_INVALID_ENUM);
-                  }
-              default:
</del><ins>+             default:
</ins><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><del>-
-            if (target == GL_TEXTURE_2D)
-            {
-                gl::Texture2D *texture = context-&gt;getTexture2D();
-
-                if (!texture)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                if (texture-&gt;isImmutable())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                texture-&gt;copyImage(level, internalformat, x, y, width, height, framebuffer);
-            }
-            else if (gl::IsCubemapTextureTarget(target))
-            {
-                gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
-
-                if (!texture)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                if (texture-&gt;isImmutable())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                texture-&gt;copyImage(target, level, internalformat, x, y, width, height, framebuffer);
-            }
-            else UNREACHABLE();
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -1457,121 +1025,50 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (!gl::IsInternalTextureTarget(target))
-        {
-            return gl::error(GL_INVALID_ENUM);
-        }
-
-        if (level &lt; 0 || xoffset &lt; 0 || yoffset &lt; 0 || width &lt; 0 || height &lt; 0)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        if (std::numeric_limits&lt;GLsizei&gt;::max() - xoffset &lt; width || std::numeric_limits&lt;GLsizei&gt;::max() - yoffset &lt; height)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        if (width == 0 || height == 0)
-        {
-            return;
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (level &gt; context-&gt;getMaximumTextureLevel())
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3 &amp;&amp;
+                !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
+                                                   xoffset, yoffset, x, y, width, height, 0))
</ins><span class="cx">             {
</span><del>-                return gl::error(GL_INVALID_VALUE);
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            gl::Framebuffer *framebuffer = context-&gt;getReadFramebuffer();
-
-            if (framebuffer-&gt;completeness() != GL_FRAMEBUFFER_COMPLETE)
</del><ins>+            if (context-&gt;getClientVersion() &gt;= 3 &amp;&amp;
+                !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
+                                                   xoffset, yoffset, 0, x, y, width, height, 0))
</ins><span class="cx">             {
</span><del>-                return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (context-&gt;getReadFramebufferHandle() != 0 &amp;&amp; framebuffer-&gt;getSamples() != 0)
-            {
-                return gl::error(GL_INVALID_OPERATION);
-            }
</del><ins>+            gl::Framebuffer *framebuffer = context-&gt;getReadFramebuffer();
</ins><span class="cx"> 
</span><del>-            gl::Renderbuffer *source = framebuffer-&gt;getReadColorbuffer();
-            GLenum colorbufferFormat = source-&gt;getInternalFormat();
-            gl::Texture *texture = NULL;
-            GLenum textureFormat = GL_RGBA;
-
-            if (target == GL_TEXTURE_2D)
</del><ins>+            switch (target)
</ins><span class="cx">             {
</span><del>-                gl::Texture2D *tex2d = context-&gt;getTexture2D();
-
-                if (!validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d))
</del><ins>+              case GL_TEXTURE_2D:
</ins><span class="cx">                 {
</span><del>-                    return; // error already registered by validateSubImageParams
</del><ins>+                    gl::Texture2D *texture = context-&gt;getTexture2D();
+                    texture-&gt;copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
</ins><span class="cx">                 }
</span><del>-                textureFormat = gl::ExtractFormat(tex2d-&gt;getInternalFormat(level));
-                texture = tex2d;
-            }
-            else if (gl::IsCubemapTextureTarget(target))
-            {
-                gl::TextureCubeMap *texcube = context-&gt;getTextureCubeMap();
</del><ins>+                break;
</ins><span class="cx"> 
</span><del>-                if (!validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube))
</del><ins>+              case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+              case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+              case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
</ins><span class="cx">                 {
</span><del>-                    return; // error already registered by validateSubImageParams
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
</ins><span class="cx">                 }
</span><del>-                textureFormat = gl::ExtractFormat(texcube-&gt;getInternalFormat(target, level));
-                texture = texcube;
-            }
-            else UNREACHABLE();
</del><ins>+                break;
</ins><span class="cx"> 
</span><del>-            // [OpenGL ES 2.0.24] table 3.9
-            switch (textureFormat)
-            {
-              case GL_ALPHA:
-                if (colorbufferFormat != GL_ALPHA8_EXT &amp;&amp;
-                    colorbufferFormat != GL_RGBA4 &amp;&amp;
-                    colorbufferFormat != GL_RGB5_A1 &amp;&amp;
-                    colorbufferFormat != GL_RGBA8_OES)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                break;
-              case GL_LUMINANCE:
-              case GL_RGB:
-                if (colorbufferFormat != GL_RGB565 &amp;&amp;
-                    colorbufferFormat != GL_RGB8_OES &amp;&amp;
-                    colorbufferFormat != GL_RGBA4 &amp;&amp;
-                    colorbufferFormat != GL_RGB5_A1 &amp;&amp;
-                    colorbufferFormat != GL_RGBA8_OES)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                break;
-              case GL_LUMINANCE_ALPHA:
-              case GL_RGBA:
-                if (colorbufferFormat != GL_RGBA4 &amp;&amp;
-                    colorbufferFormat != GL_RGB5_A1 &amp;&amp;
-                    colorbufferFormat != GL_RGBA8_OES)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                break;
-              case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-              case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-              case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-              case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-                return gl::error(GL_INVALID_OPERATION);
-              case GL_DEPTH_COMPONENT:
-              case GL_DEPTH_STENCIL_OES:
-                return gl::error(GL_INVALID_OPERATION);
</del><span class="cx">               default:
</span><del>-                return gl::error(GL_INVALID_OPERATION);
</del><ins>+                return gl::error(GL_INVALID_ENUM);
</ins><span class="cx">             }
</span><del>-
-            texture-&gt;copySubImage(target, level, xoffset, yoffset, x, y, width, height, framebuffer);
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1704,7 +1201,7 @@
</span><span class="cx">         {
</span><span class="cx">             for (int i = 0; i &lt; n; i++)
</span><span class="cx">             {
</span><del>-                context-&gt;deleteFence(fences[i]);
</del><ins>+                context-&gt;deleteFenceNV(fences[i]);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -1936,7 +1433,7 @@
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glDepthMask(GLboolean flag)
</span><span class="cx"> {
</span><del>-    EVENT(&quot;(GLboolean flag = %d)&quot;, flag);
</del><ins>+    EVENT(&quot;(GLboolean flag = %u)&quot;, flag);
</ins><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><span class="lines">@@ -2035,20 +1532,12 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            switch (cap)
</del><ins>+            if (!ValidCap(context, cap))
</ins><span class="cx">             {
</span><del>-              case GL_CULL_FACE:                context-&gt;setCullFace(false);              break;
-              case GL_POLYGON_OFFSET_FILL:      context-&gt;setPolygonOffsetFill(false);     break;
-              case GL_SAMPLE_ALPHA_TO_COVERAGE: context-&gt;setSampleAlphaToCoverage(false); break;
-              case GL_SAMPLE_COVERAGE:          context-&gt;setSampleCoverage(false);        break;
-              case GL_SCISSOR_TEST:             context-&gt;setScissorTest(false);           break;
-              case GL_STENCIL_TEST:             context-&gt;setStencilTest(false);           break;
-              case GL_DEPTH_TEST:               context-&gt;setDepthTest(false);             break;
-              case GL_BLEND:                    context-&gt;setBlend(false);                 break;
-              case GL_DITHER:                   context-&gt;setDither(false);                break;
-              default:
</del><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><ins>+
+            context-&gt;setCap(cap, false);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -2094,8 +1583,24 @@
</span><span class="cx"> 
</span><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><ins>+        // Check for mapped buffers
+        if (context-&gt;hasMappedBuffer(GL_ARRAY_BUFFER))
+        {
+            return gl::error(GL_INVALID_OPERATION);
+        }
+
</ins><span class="cx">         if (context)
</span><span class="cx">         {
</span><ins>+            gl::TransformFeedback *curTransformFeedback = context-&gt;getCurrentTransformFeedback();
+            if (curTransformFeedback &amp;&amp; curTransformFeedback-&gt;isStarted() &amp;&amp; !curTransformFeedback-&gt;isPaused() &amp;&amp;
+                curTransformFeedback-&gt;getDrawMode() != mode)
+            {
+                // It is an invalid operation to call DrawArrays or DrawArraysInstanced with a draw mode
+                // that does not match the current transform feedback object's draw mode (if transform feedback
+                // is active), (3.0.2, section 2.14, pg 86)
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
</ins><span class="cx">             context-&gt;drawArrays(mode, first, count, 0);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2120,8 +1625,24 @@
</span><span class="cx">         {
</span><span class="cx">             gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><ins>+            // Check for mapped buffers
+            if (context-&gt;hasMappedBuffer(GL_ARRAY_BUFFER))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
</ins><span class="cx">             if (context)
</span><span class="cx">             {
</span><ins>+                gl::TransformFeedback *curTransformFeedback = context-&gt;getCurrentTransformFeedback();
+                if (curTransformFeedback &amp;&amp; curTransformFeedback-&gt;isStarted() &amp;&amp; !curTransformFeedback-&gt;isPaused() &amp;&amp;
+                    curTransformFeedback-&gt;getDrawMode() != mode)
+                {
+                    // It is an invalid operation to call DrawArrays or DrawArraysInstanced with a draw mode
+                    // that does not match the current transform feedback object's draw mode (if transform feedback
+                    // is active), (3.0.2, section 2.14, pg 86)
+                    return gl::error(GL_INVALID_OPERATION);
+                }
+
</ins><span class="cx">                 context-&gt;drawArrays(mode, first, count, primcount);
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -2156,13 +1677,27 @@
</span><span class="cx">               case GL_UNSIGNED_INT:
</span><span class="cx">                 if (!context-&gt;supports32bitIndices())
</span><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_ENUM);    
</del><ins>+                    return gl::error(GL_INVALID_ENUM);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">               default:
</span><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><del>-        
</del><ins>+
+            gl::TransformFeedback *curTransformFeedback = context-&gt;getCurrentTransformFeedback();
+            if (curTransformFeedback &amp;&amp; curTransformFeedback-&gt;isStarted() &amp;&amp; !curTransformFeedback-&gt;isPaused())
+            {
+                // It is an invalid operation to call DrawElements, DrawRangeElements or DrawElementsInstanced
+                // while transform feedback is active, (3.0.2, section 2.14, pg 86)
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // Check for mapped buffers
+            if (context-&gt;hasMappedBuffer(GL_ARRAY_BUFFER) || context-&gt;hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
</ins><span class="cx">             context-&gt;drawElements(mode, count, type, indices, 0);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2198,13 +1733,27 @@
</span><span class="cx">                   case GL_UNSIGNED_INT:
</span><span class="cx">                     if (!context-&gt;supports32bitIndices())
</span><span class="cx">                     {
</span><del>-                        return gl::error(GL_INVALID_ENUM);    
</del><ins>+                        return gl::error(GL_INVALID_ENUM);
</ins><span class="cx">                     }
</span><span class="cx">                     break;
</span><span class="cx">                   default:
</span><span class="cx">                     return gl::error(GL_INVALID_ENUM);
</span><span class="cx">                 }
</span><del>-            
</del><ins>+
+                gl::TransformFeedback *curTransformFeedback = context-&gt;getCurrentTransformFeedback();
+                if (curTransformFeedback &amp;&amp; curTransformFeedback-&gt;isStarted() &amp;&amp; !curTransformFeedback-&gt;isPaused())
+                {
+                    // It is an invalid operation to call DrawElements, DrawRangeElements or DrawElementsInstanced
+                    // while transform feedback is active, (3.0.2, section 2.14, pg 86)
+                    return gl::error(GL_INVALID_OPERATION);
+                }
+
+                // Check for mapped buffers
+                if (context-&gt;hasMappedBuffer(GL_ARRAY_BUFFER) || context-&gt;hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER))
+                {
+                    return gl::error(GL_INVALID_OPERATION);
+                }
+
</ins><span class="cx">                 context-&gt;drawElements(mode, count, type, indices, primcount);
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -2225,20 +1774,12 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            switch (cap)
</del><ins>+            if (!ValidCap(context, cap))
</ins><span class="cx">             {
</span><del>-              case GL_CULL_FACE:                context-&gt;setCullFace(true);              break;
-              case GL_POLYGON_OFFSET_FILL:      context-&gt;setPolygonOffsetFill(true);     break;
-              case GL_SAMPLE_ALPHA_TO_COVERAGE: context-&gt;setSampleAlphaToCoverage(true); break;
-              case GL_SAMPLE_COVERAGE:          context-&gt;setSampleCoverage(true);        break;
-              case GL_SCISSOR_TEST:             context-&gt;setScissorTest(true);           break;
-              case GL_STENCIL_TEST:             context-&gt;setStencilTest(true);           break;
-              case GL_DEPTH_TEST:               context-&gt;setDepthTest(true);             break;
-              case GL_BLEND:                    context-&gt;setBlend(true);                 break;
-              case GL_DITHER:                   context-&gt;setDither(true);                break;
-              default:
</del><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><ins>+
+            context-&gt;setCap(cap, true);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -2277,19 +1818,15 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        switch (target)
-        {
-          case GL_ANY_SAMPLES_PASSED_EXT: 
-          case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
-              break;
-          default: 
-              return gl::error(GL_INVALID_ENUM);
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><ins>+            if (!ValidQueryType(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
</ins><span class="cx">             context-&gt;endQuery(target);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2309,13 +1846,18 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Fence* fenceObject = context-&gt;getFence(fence);
</del><ins>+            gl::FenceNV *fenceObject = context-&gt;getFenceNV(fence);
</ins><span class="cx"> 
</span><span class="cx">             if (fenceObject == NULL)
</span><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            if (fenceObject-&gt;isFence() != GL_TRUE)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
</ins><span class="cx">             fenceObject-&gt;finishFence();
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2370,8 +1912,7 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if ((target != GL_FRAMEBUFFER &amp;&amp; target != GL_DRAW_FRAMEBUFFER_ANGLE &amp;&amp; target != GL_READ_FRAMEBUFFER_ANGLE)
-            || (renderbuffertarget != GL_RENDERBUFFER &amp;&amp; renderbuffer != 0))
</del><ins>+        if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER &amp;&amp; renderbuffer != 0))
</ins><span class="cx">         {
</span><span class="cx">             return gl::error(GL_INVALID_ENUM);
</span><span class="cx">         }
</span><span class="lines">@@ -2380,47 +1921,35 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Framebuffer *framebuffer = NULL;
-            GLuint framebufferHandle = 0;
-            if (target == GL_READ_FRAMEBUFFER_ANGLE)
</del><ins>+            if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
</ins><span class="cx">             {
</span><del>-                framebuffer = context-&gt;getReadFramebuffer();
-                framebufferHandle = context-&gt;getReadFramebufferHandle();
</del><ins>+                return;
</ins><span class="cx">             }
</span><del>-            else
-            {
-                framebuffer = context-&gt;getDrawFramebuffer();
-                framebufferHandle = context-&gt;getDrawFramebufferHandle();
-            }
</del><span class="cx"> 
</span><del>-            if (!framebuffer || (framebufferHandle == 0 &amp;&amp; renderbuffer != 0))
-            {
-                return gl::error(GL_INVALID_OPERATION);
-            }
</del><ins>+            gl::Framebuffer *framebuffer = context-&gt;getTargetFramebuffer(target);
+            ASSERT(framebuffer);
</ins><span class="cx"> 
</span><span class="cx">             if (attachment &gt;= GL_COLOR_ATTACHMENT0_EXT &amp;&amp; attachment &lt;= GL_COLOR_ATTACHMENT15_EXT)
</span><span class="cx">             {
</span><del>-                const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
-
-                if (colorAttachment &gt;= context-&gt;getMaximumRenderTargets())
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
-
-                framebuffer-&gt;setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer);
</del><ins>+                unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
+                framebuffer-&gt;setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0);
</ins><span class="cx">             }
</span><span class="cx">             else
</span><span class="cx">             {
</span><span class="cx">                 switch (attachment)
</span><span class="cx">                 {
</span><span class="cx">                   case GL_DEPTH_ATTACHMENT:
</span><del>-                    framebuffer-&gt;setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
</del><ins>+                    framebuffer-&gt;setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
</ins><span class="cx">                     break;
</span><span class="cx">                   case GL_STENCIL_ATTACHMENT:
</span><del>-                    framebuffer-&gt;setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
</del><ins>+                    framebuffer-&gt;setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
</ins><span class="cx">                     break;
</span><ins>+                  case GL_DEPTH_STENCIL_ATTACHMENT:
+                    framebuffer-&gt;setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
+                    break;
</ins><span class="cx">                   default:
</span><del>-                    return gl::error(GL_INVALID_ENUM);
</del><ins>+                    UNREACHABLE();
+                    break;
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -2438,129 +1967,40 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (target != GL_FRAMEBUFFER &amp;&amp; target != GL_DRAW_FRAMEBUFFER_ANGLE &amp;&amp; target != GL_READ_FRAMEBUFFER_ANGLE)
-        {
-            return gl::error(GL_INVALID_ENUM);
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><del>-
</del><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (attachment &gt;= GL_COLOR_ATTACHMENT0_EXT &amp;&amp; attachment &lt;= GL_COLOR_ATTACHMENT15_EXT)
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3 &amp;&amp;
+                !ValidateES2FramebufferTextureParameters(context, target, attachment, textarget, texture, level))
</ins><span class="cx">             {
</span><del>-                const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
</del><ins>+                return;
+            }
</ins><span class="cx"> 
</span><del>-                if (colorAttachment &gt;= context-&gt;getMaximumRenderTargets())
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
-            }
-            else
</del><ins>+            if (context-&gt;getClientVersion() &gt;= 3 &amp;&amp;
+                !ValidateES3FramebufferTextureParameters(context, target, attachment, textarget, texture, level, 0, false))
</ins><span class="cx">             {
</span><del>-                switch (attachment)
-                {
-                  case GL_DEPTH_ATTACHMENT:
-                  case GL_STENCIL_ATTACHMENT:
-                    break;
-                  default:
-                    return gl::error(GL_INVALID_ENUM);
-                }
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             if (texture == 0)
</span><span class="cx">             {
</span><span class="cx">                 textarget = GL_NONE;
</span><span class="cx">             }
</span><del>-            else
-            {
-                gl::Texture *tex = context-&gt;getTexture(texture);
</del><span class="cx"> 
</span><del>-                if (tex == NULL)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
</del><ins>+            gl::Framebuffer *framebuffer = context-&gt;getTargetFramebuffer(target);
</ins><span class="cx"> 
</span><del>-                switch (textarget)
-                {
-                  case GL_TEXTURE_2D:
-                    {
-                        if (tex-&gt;getTarget() != GL_TEXTURE_2D)
-                        {
-                            return gl::error(GL_INVALID_OPERATION);
-                        }
-                        gl::Texture2D *tex2d = static_cast&lt;gl::Texture2D *&gt;(tex);
-                        if (tex2d-&gt;isCompressed(0))
-                        {
-                            return gl::error(GL_INVALID_OPERATION);
-                        }
-                        break;
-                    }
-
-                  case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-                  case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-                  case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-                  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-                  case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-                  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-                    {
-                        if (tex-&gt;getTarget() != GL_TEXTURE_CUBE_MAP)
-                        {
-                            return gl::error(GL_INVALID_OPERATION);
-                        }
-                        gl::TextureCubeMap *texcube = static_cast&lt;gl::TextureCubeMap *&gt;(tex);
-                        if (texcube-&gt;isCompressed(textarget, level))
-                        {
-                            return gl::error(GL_INVALID_OPERATION);
-                        }
-                        break;
-                    }
-
-                  default:
-                    return gl::error(GL_INVALID_ENUM);
-                }
-
-                if (level != 0)
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
-            }
-
-            gl::Framebuffer *framebuffer = NULL;
-            GLuint framebufferHandle = 0;
-            if (target == GL_READ_FRAMEBUFFER_ANGLE)
-            {
-                framebuffer = context-&gt;getReadFramebuffer();
-                framebufferHandle = context-&gt;getReadFramebufferHandle();
-            }
-            else
-            {
-                framebuffer = context-&gt;getDrawFramebuffer();
-                framebufferHandle = context-&gt;getDrawFramebufferHandle();
-            }
-
-            if (framebufferHandle == 0 || !framebuffer)
-            {
-                return gl::error(GL_INVALID_OPERATION);
-            }
-
</del><span class="cx">             if (attachment &gt;= GL_COLOR_ATTACHMENT0_EXT &amp;&amp; attachment &lt;= GL_COLOR_ATTACHMENT15_EXT)
</span><span class="cx">             {
</span><span class="cx">                 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
</span><del>-
-                if (colorAttachment &gt;= context-&gt;getMaximumRenderTargets())
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
-
-                framebuffer-&gt;setColorbuffer(colorAttachment, textarget, texture);
</del><ins>+                framebuffer-&gt;setColorbuffer(colorAttachment, textarget, texture, level, 0);
</ins><span class="cx">             }
</span><span class="cx">             else
</span><span class="cx">             {
</span><span class="cx">                 switch (attachment)
</span><span class="cx">                 {
</span><del>-                  case GL_DEPTH_ATTACHMENT:   framebuffer-&gt;setDepthbuffer(textarget, texture);   break;
-                  case GL_STENCIL_ATTACHMENT: framebuffer-&gt;setStencilbuffer(textarget, texture); break;
</del><ins>+                  case GL_DEPTH_ATTACHMENT:         framebuffer-&gt;setDepthbuffer(textarget, texture, level, 0);        break;
+                  case GL_STENCIL_ATTACHMENT:       framebuffer-&gt;setStencilbuffer(textarget, texture, level, 0);      break;
+                  case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer-&gt;setDepthStencilBuffer(textarget, texture, level, 0); break;
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -2637,41 +2077,52 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            switch (target)
</del><ins>+            if (!ValidTextureTarget(context, target))
</ins><span class="cx">             {
</span><del>-              case GL_TEXTURE_2D:
-                {
-                    gl::Texture2D *tex2d = context-&gt;getTexture2D();
</del><ins>+                return gl::error(GL_INVALID_ENUM);
+            }
</ins><span class="cx"> 
</span><del>-                    if (tex2d-&gt;isCompressed(0))
-                    {
-                        return gl::error(GL_INVALID_OPERATION);
-                    }
-                    if (tex2d-&gt;isDepth(0))
-                    {
-                        return gl::error(GL_INVALID_OPERATION);
-                    }
</del><ins>+            gl::Texture *texture = context-&gt;getTargetTexture(target);
</ins><span class="cx"> 
</span><del>-                    tex2d-&gt;generateMipmaps();
-                    break;
-                }
</del><ins>+            if (texture == NULL)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
</ins><span class="cx"> 
</span><del>-              case GL_TEXTURE_CUBE_MAP:
-                {
-                    gl::TextureCubeMap *texcube = context-&gt;getTextureCubeMap();
</del><ins>+            GLenum internalFormat = texture-&gt;getBaseLevelInternalFormat();
</ins><span class="cx"> 
</span><del>-                    if (texcube-&gt;isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0))
-                    {
-                        return gl::error(GL_INVALID_OPERATION);
-                    }
</del><ins>+            // Internally, all texture formats are sized so checking if the format
+            // is color renderable and filterable will not fail.
</ins><span class="cx"> 
</span><del>-                    texcube-&gt;generateMipmaps();
-                    break;
</del><ins>+            bool validRenderable = (gl::IsColorRenderingSupported(internalFormat, context) ||
+                                    gl::IsSizedInternalFormat(internalFormat, context-&gt;getClientVersion()));
+
+            if (gl::IsDepthRenderingSupported(internalFormat, context) ||
+                gl::IsFormatCompressed(internalFormat, context-&gt;getClientVersion()) ||
+                !gl::IsTextureFilteringSupported(internalFormat, context) ||
+                !validRenderable)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // Non-power of 2 ES2 check
+            if (!context-&gt;supportsNonPower2Texture() &amp;&amp; (!gl::isPow2(texture-&gt;getBaseLevelWidth()) || !gl::isPow2(texture-&gt;getBaseLevelHeight())))
+            {
+                ASSERT(context-&gt;getClientVersion() &lt;= 2 &amp;&amp; (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // Cube completeness check
+            if (target == GL_TEXTURE_CUBE_MAP)
+            {
+                gl::TextureCubeMap *textureCube = static_cast&lt;gl::TextureCubeMap *&gt;(texture);
+                if (!textureCube-&gt;isCubeComplete())
+                {
+                    return gl::error(GL_INVALID_OPERATION);
</ins><span class="cx">                 }
</span><ins>+            }
</ins><span class="cx"> 
</span><del>-              default:
-                return gl::error(GL_INVALID_ENUM);
-            }
</del><ins>+            texture-&gt;generateMipmaps();
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -2697,7 +2148,7 @@
</span><span class="cx">         {
</span><span class="cx">             for (int i = 0; i &lt; n; i++)
</span><span class="cx">             {
</span><del>-                fences[i] = context-&gt;createFence();
</del><ins>+                fences[i] = context-&gt;createFenceNV();
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2740,17 +2191,17 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (n &lt; 0)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            for (int i = 0; i &lt; n; i++)
</del><ins>+            if (n &lt; 0)
</ins><span class="cx">             {
</span><ins>+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            for (GLsizei i = 0; i &lt; n; i++)
+            {
</ins><span class="cx">                 ids[i] = context-&gt;createQuery();
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -2790,7 +2241,7 @@
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glGenTextures(GLsizei n, GLuint* textures)
</span><span class="cx"> {
</span><del>-    EVENT(&quot;(GLsizei n = %d, GLuint* textures =  0x%0.8p)&quot;, n, textures);
</del><ins>+    EVENT(&quot;(GLsizei n = %d, GLuint* textures = 0x%0.8p)&quot;, n, textures);
</ins><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><span class="lines">@@ -2996,51 +2447,23 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (!(context-&gt;getBooleanv(pname, params)))
-            {
-                GLenum nativeType;
-                unsigned int numParams = 0;
-                if (!context-&gt;getQueryParameterInfo(pname, &amp;nativeType, &amp;numParams))
-                    return gl::error(GL_INVALID_ENUM);
</del><ins>+            GLenum nativeType;
+            unsigned int numParams = 0;
+            if (!context-&gt;getQueryParameterInfo(pname, &amp;nativeType, &amp;numParams))
+                return gl::error(GL_INVALID_ENUM);
</ins><span class="cx"> 
</span><del>-                if (numParams == 0)
-                    return; // it is known that the pname is valid, but there are no parameters to return
</del><ins>+            // pname is valid, but there are no parameters to return
+            if (numParams == 0)
+                return;
</ins><span class="cx"> 
</span><del>-                if (nativeType == GL_FLOAT)
-                {
-                    GLfloat *floatParams = NULL;
-                    floatParams = new GLfloat[numParams];
-
-                    context-&gt;getFloatv(pname, floatParams);
-
-                    for (unsigned int i = 0; i &lt; numParams; ++i)
-                    {
-                        if (floatParams[i] == 0.0f)
-                            params[i] = GL_FALSE;
-                        else
-                            params[i] = GL_TRUE;
-                    }
-
-                    delete [] floatParams;
-                }
-                else if (nativeType == GL_INT)
-                {
-                    GLint *intParams = NULL;
-                    intParams = new GLint[numParams];
-
-                    context-&gt;getIntegerv(pname, intParams);
-
-                    for (unsigned int i = 0; i &lt; numParams; ++i)
-                    {
-                        if (intParams[i] == 0)
-                            params[i] = GL_FALSE;
-                        else
-                            params[i] = GL_TRUE;
-                    }
-
-                    delete [] intParams;
-                }
</del><ins>+            if (nativeType == GL_BOOL)
+            {
+                context-&gt;getBooleanv(pname, params);
</ins><span class="cx">             }
</span><ins>+            else
+            {
+                CastStateValues(context, nativeType, pname, numParams, params);
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -3059,19 +2482,18 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Buffer *buffer;
</del><ins>+            if (!gl::ValidBufferTarget(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
</ins><span class="cx"> 
</span><del>-            switch (target)
</del><ins>+            if (!gl::ValidBufferParameter(context, pname))
</ins><span class="cx">             {
</span><del>-              case GL_ARRAY_BUFFER:
-                buffer = context-&gt;getArrayBuffer();
-                break;
-              case GL_ELEMENT_ARRAY_BUFFER:
-                buffer = context-&gt;getElementArrayBuffer();
-                break;
-              default: return gl::error(GL_INVALID_ENUM);
</del><ins>+                return gl::error(GL_INVALID_ENUM);
</ins><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            gl::Buffer *buffer = context-&gt;getTargetBuffer(target);
+
</ins><span class="cx">             if (!buffer)
</span><span class="cx">             {
</span><span class="cx">                 // A null buffer means that &quot;0&quot; is bound to the requested buffer target
</span><span class="lines">@@ -3081,12 +2503,24 @@
</span><span class="cx">             switch (pname)
</span><span class="cx">             {
</span><span class="cx">               case GL_BUFFER_USAGE:
</span><del>-                *params = buffer-&gt;usage();
</del><ins>+                *params = static_cast&lt;GLint&gt;(buffer-&gt;usage());
</ins><span class="cx">                 break;
</span><span class="cx">               case GL_BUFFER_SIZE:
</span><del>-                *params = buffer-&gt;size();
</del><ins>+                *params = gl::clampCast&lt;GLint&gt;(buffer-&gt;size());
</ins><span class="cx">                 break;
</span><del>-              default: return gl::error(GL_INVALID_ENUM);
</del><ins>+              case GL_BUFFER_ACCESS_FLAGS:
+                *params = buffer-&gt;accessFlags();
+                break;
+              case GL_BUFFER_MAPPED:
+                *params = static_cast&lt;GLint&gt;(buffer-&gt;mapped());
+                break;
+              case GL_BUFFER_MAP_OFFSET:
+                *params = gl::clampCast&lt;GLint&gt;(buffer-&gt;mapOffset());
+                break;
+              case GL_BUFFER_MAP_LENGTH:
+                *params = gl::clampCast&lt;GLint&gt;(buffer-&gt;mapLength());
+                break;
+              default: UNREACHABLE(); break;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -3121,14 +2555,28 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Fence *fenceObject = context-&gt;getFence(fence);
</del><ins>+            gl::FenceNV *fenceObject = context-&gt;getFenceNV(fence);
</ins><span class="cx"> 
</span><span class="cx">             if (fenceObject == NULL)
</span><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            fenceObject-&gt;getFenceiv(pname, params);
</del><ins>+            if (fenceObject-&gt;isFence() != GL_TRUE)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (pname)
+            {
+              case GL_FENCE_STATUS_NV:
+              case GL_FENCE_CONDITION_NV:
+                break;
+
+              default: return gl::error(GL_INVALID_ENUM);
+            }
+
+            params[0] = fenceObject-&gt;getFencei(pname);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -3147,48 +2595,23 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (!(context-&gt;getFloatv(pname, params)))
-            {
-                GLenum nativeType;
-                unsigned int numParams = 0;
-                if (!context-&gt;getQueryParameterInfo(pname, &amp;nativeType, &amp;numParams))
-                    return gl::error(GL_INVALID_ENUM);
</del><ins>+            GLenum nativeType;
+            unsigned int numParams = 0;
+            if (!context-&gt;getQueryParameterInfo(pname, &amp;nativeType, &amp;numParams))
+                return gl::error(GL_INVALID_ENUM);
</ins><span class="cx"> 
</span><del>-                if (numParams == 0)
-                    return; // it is known that the pname is valid, but that there are no parameters to return.
</del><ins>+            // pname is valid, but that there are no parameters to return.
+            if (numParams == 0)
+                return;
</ins><span class="cx"> 
</span><del>-                if (nativeType == GL_BOOL)
-                {
-                    GLboolean *boolParams = NULL;
-                    boolParams = new GLboolean[numParams];
-
-                    context-&gt;getBooleanv(pname, boolParams);
-
-                    for (unsigned int i = 0; i &lt; numParams; ++i)
-                    {
-                        if (boolParams[i] == GL_FALSE)
-                            params[i] = 0.0f;
-                        else
-                            params[i] = 1.0f;
-                    }
-
-                    delete [] boolParams;
-                }
-                else if (nativeType == GL_INT)
-                {
-                    GLint *intParams = NULL;
-                    intParams = new GLint[numParams];
-
-                    context-&gt;getIntegerv(pname, intParams);
-
-                    for (unsigned int i = 0; i &lt; numParams; ++i)
-                    {
-                        params[i] = (GLfloat)intParams[i];
-                    }
-
-                    delete [] intParams;
-                }
</del><ins>+            if (nativeType == GL_FLOAT)
+            {
+                context-&gt;getFloatv(pname, params);
</ins><span class="cx">             }
</span><ins>+            else
+            {
+                CastStateValues(context, nativeType, pname, numParams, params);
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -3208,68 +2631,162 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (target != GL_FRAMEBUFFER &amp;&amp; target != GL_DRAW_FRAMEBUFFER_ANGLE &amp;&amp; target != GL_READ_FRAMEBUFFER_ANGLE)
</del><ins>+            if (!gl::ValidFramebufferTarget(target))
</ins><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            gl::Framebuffer *framebuffer = NULL;
-            if (target == GL_READ_FRAMEBUFFER_ANGLE)
</del><ins>+            switch (pname)
</ins><span class="cx">             {
</span><del>-                if(context-&gt;getReadFramebufferHandle() == 0)
</del><ins>+              case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
+              case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
+              case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
+              case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
+                break;
+              case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+              case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+              case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+              case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+              case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+              case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+              case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
+              case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
+              case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
+                if (context-&gt;getClientVersion() &gt;= 3)
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_OPERATION);
</del><ins>+                    break;
</ins><span class="cx">                 }
</span><ins>+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
</ins><span class="cx"> 
</span><del>-                framebuffer = context-&gt;getReadFramebuffer();
-            }
-            else 
</del><ins>+            // Determine if the attachment is a valid enum
+            switch (attachment)
</ins><span class="cx">             {
</span><del>-                if (context-&gt;getDrawFramebufferHandle() == 0)
</del><ins>+              case GL_BACK:
+              case GL_FRONT:
+              case GL_DEPTH:
+              case GL_STENCIL:
+              case GL_DEPTH_STENCIL_ATTACHMENT:
+                if (context-&gt;getClientVersion() &lt; 3)
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_OPERATION);
</del><ins>+                    return gl::error(GL_INVALID_ENUM);
</ins><span class="cx">                 }
</span><ins>+                break;
</ins><span class="cx"> 
</span><del>-                framebuffer = context-&gt;getDrawFramebuffer();
</del><ins>+              case GL_DEPTH_ATTACHMENT:
+              case GL_STENCIL_ATTACHMENT:
+                break;
+
+              default:
+                if (attachment &lt; GL_COLOR_ATTACHMENT0_EXT ||
+                    (attachment - GL_COLOR_ATTACHMENT0_EXT) &gt;= context-&gt;getMaximumRenderTargets())
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                break;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            GLuint framebufferHandle = context-&gt;getTargetFramebufferHandle(target);
+            ASSERT(framebufferHandle != GL_INVALID_INDEX);
+            gl::Framebuffer *framebuffer = context-&gt;getFramebuffer(framebufferHandle);
+
</ins><span class="cx">             GLenum attachmentType;
</span><span class="cx">             GLuint attachmentHandle;
</span><ins>+            GLuint attachmentLevel;
+            GLuint attachmentLayer;
+            gl::Renderbuffer *renderbuffer;
</ins><span class="cx"> 
</span><del>-            if (attachment &gt;= GL_COLOR_ATTACHMENT0_EXT &amp;&amp; attachment &lt;= GL_COLOR_ATTACHMENT15_EXT)
</del><ins>+            if(framebufferHandle == 0)
</ins><span class="cx">             {
</span><del>-                const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
-
-                if (colorAttachment &gt;= context-&gt;getMaximumRenderTargets())
</del><ins>+                if(context-&gt;getClientVersion() &lt; 3)
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_ENUM);
</del><ins>+                    return gl::error(GL_INVALID_OPERATION);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                attachmentType = framebuffer-&gt;getColorbufferType(colorAttachment);
-                attachmentHandle = framebuffer-&gt;getColorbufferHandle(colorAttachment);
-            }
-            else
-            {
</del><span class="cx">                 switch (attachment)
</span><span class="cx">                 {
</span><del>-                  case GL_DEPTH_ATTACHMENT:
</del><ins>+                  case GL_BACK:
+                    attachmentType = framebuffer-&gt;getColorbufferType(0);
+                    attachmentHandle = framebuffer-&gt;getColorbufferHandle(0);
+                    attachmentLevel = framebuffer-&gt;getColorbufferMipLevel(0);
+                    attachmentLayer = framebuffer-&gt;getColorbufferLayer(0);
+                    renderbuffer = framebuffer-&gt;getColorbuffer(0);
+                    break;
+                  case GL_DEPTH:
</ins><span class="cx">                     attachmentType = framebuffer-&gt;getDepthbufferType();
</span><span class="cx">                     attachmentHandle = framebuffer-&gt;getDepthbufferHandle();
</span><ins>+                    attachmentLevel = framebuffer-&gt;getDepthbufferMipLevel();
+                    attachmentLayer = framebuffer-&gt;getDepthbufferLayer();
+                    renderbuffer = framebuffer-&gt;getDepthbuffer();
</ins><span class="cx">                     break;
</span><del>-                  case GL_STENCIL_ATTACHMENT:
</del><ins>+                  case GL_STENCIL:
</ins><span class="cx">                     attachmentType = framebuffer-&gt;getStencilbufferType();
</span><span class="cx">                     attachmentHandle = framebuffer-&gt;getStencilbufferHandle();
</span><ins>+                    attachmentLevel = framebuffer-&gt;getStencilbufferMipLevel();
+                    attachmentLayer = framebuffer-&gt;getStencilbufferLayer();
+                    renderbuffer = framebuffer-&gt;getStencilbuffer();
</ins><span class="cx">                     break;
</span><del>-                  default: return gl::error(GL_INVALID_ENUM);
</del><ins>+                  default:
+                    return gl::error(GL_INVALID_OPERATION);
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><ins>+            else
+            {
+                if (attachment &gt;= GL_COLOR_ATTACHMENT0_EXT &amp;&amp; attachment &lt;= GL_COLOR_ATTACHMENT15_EXT)
+                {
+                    const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
+                    attachmentType = framebuffer-&gt;getColorbufferType(colorAttachment);
+                    attachmentHandle = framebuffer-&gt;getColorbufferHandle(colorAttachment);
+                    attachmentLevel = framebuffer-&gt;getColorbufferMipLevel(colorAttachment);
+                    attachmentLayer = framebuffer-&gt;getColorbufferLayer(colorAttachment);
+                    renderbuffer = framebuffer-&gt;getColorbuffer(colorAttachment);
+                }
+                else
+                {
+                    switch (attachment)
+                    {
+                      case GL_DEPTH_ATTACHMENT:
+                        attachmentType = framebuffer-&gt;getDepthbufferType();
+                        attachmentHandle = framebuffer-&gt;getDepthbufferHandle();
+                        attachmentLevel = framebuffer-&gt;getDepthbufferMipLevel();
+                        attachmentLayer = framebuffer-&gt;getDepthbufferLayer();
+                        renderbuffer = framebuffer-&gt;getDepthbuffer();
+                        break;
+                      case GL_STENCIL_ATTACHMENT:
+                        attachmentType = framebuffer-&gt;getStencilbufferType();
+                        attachmentHandle = framebuffer-&gt;getStencilbufferHandle();
+                        attachmentLevel = framebuffer-&gt;getStencilbufferMipLevel();
+                        attachmentLayer = framebuffer-&gt;getStencilbufferLayer();
+                        renderbuffer = framebuffer-&gt;getStencilbuffer();
+                        break;
+                      case GL_DEPTH_STENCIL_ATTACHMENT:
+                        if (framebuffer-&gt;getDepthbufferHandle() != framebuffer-&gt;getStencilbufferHandle())
+                        {
+                            return gl::error(GL_INVALID_OPERATION);
+                        }
+                        attachmentType = framebuffer-&gt;getDepthStencilbufferType();
+                        attachmentHandle = framebuffer-&gt;getDepthStencilbufferHandle();
+                        attachmentLevel = framebuffer-&gt;getDepthStencilbufferMipLevel();
+                        attachmentLayer = framebuffer-&gt;getDepthStencilbufferLayer();
+                        renderbuffer = framebuffer-&gt;getDepthStencilBuffer();
+                        break;
+                      default:
+                        return gl::error(GL_INVALID_OPERATION);
+                    }
+                }
+            }
</ins><span class="cx"> 
</span><span class="cx">             GLenum attachmentObjectType;   // Type category
</span><del>-            if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
</del><ins>+            if (framebufferHandle == 0)
</ins><span class="cx">             {
</span><ins>+                attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
+            }
+            else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
+            {
</ins><span class="cx">                 attachmentObjectType = attachmentType;
</span><span class="cx">             }
</span><del>-            else if (gl::IsInternalTextureTarget(attachmentType))
</del><ins>+            else if (gl::IsInternalTextureTarget(attachmentType, context-&gt;getClientVersion()))
</ins><span class="cx">             {
</span><span class="cx">                 attachmentObjectType = GL_TEXTURE;
</span><span class="cx">             }
</span><span class="lines">@@ -3279,50 +2796,124 @@
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            switch (pname)
</del><ins>+            if (attachmentObjectType == GL_NONE)
</ins><span class="cx">             {
</span><del>-              case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
-                *params = attachmentObjectType;
-                break;
-              case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
-                if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
</del><ins>+                // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
+                // is NONE, then querying any other pname will generate INVALID_ENUM.
+
+                // ES 3.0.2 spec pg 235 states that if the attachment type is none,
+                // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
+                // INVALID_OPERATION for all other pnames
+
+                switch (pname)
</ins><span class="cx">                 {
</span><del>-                    *params = attachmentHandle;
-                }
-                else
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
-                if (attachmentObjectType == GL_TEXTURE)
-                {
-                    *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
-                }
-                else
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
-                if (attachmentObjectType == GL_TEXTURE)
-                {
-                    if (gl::IsCubemapTextureTarget(attachmentType))
</del><ins>+                  case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
+                    *params = attachmentObjectType;
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
+                    if (context-&gt;getClientVersion() &lt; 3)
</ins><span class="cx">                     {
</span><del>-                        *params = attachmentType;
</del><ins>+                        return gl::error(GL_INVALID_ENUM);
</ins><span class="cx">                     }
</span><ins>+                    *params = 0;
+                    break;
+
+                  default:
+                    if (context-&gt;getClientVersion() &lt; 3)
+                    {
+                        return gl::error(GL_INVALID_ENUM);
+                    }
</ins><span class="cx">                     else
</span><span class="cx">                     {
</span><del>-                        *params = 0;
</del><ins>+                        gl::error(GL_INVALID_OPERATION);
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><del>-                else
</del><ins>+            }
+            else
+            {
+                ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
+                       attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
+                ASSERT(renderbuffer != NULL);
+
+                switch (pname)
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_ENUM);
</del><ins>+                  case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
+                    *params = attachmentObjectType;
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
+                    if (attachmentObjectType != GL_RENDERBUFFER &amp;&amp; attachmentObjectType != GL_TEXTURE)
+                    {
+                        return gl::error(GL_INVALID_ENUM);
+                    }
+                    *params = attachmentHandle;
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
+                    if (attachmentObjectType != GL_TEXTURE)
+                    {
+                        return gl::error(GL_INVALID_ENUM);
+                    }
+                    *params = attachmentLevel;
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
+                    if (attachmentObjectType != GL_TEXTURE)
+                    {
+                        return gl::error(GL_INVALID_ENUM);
+                    }
+                    *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+                    *params = renderbuffer-&gt;getRedSize();
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+                    *params = renderbuffer-&gt;getGreenSize();
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+                    *params = renderbuffer-&gt;getBlueSize();
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+                    *params = renderbuffer-&gt;getAlphaSize();
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+                    *params = renderbuffer-&gt;getDepthSize();
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+                    *params = renderbuffer-&gt;getStencilSize();
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
+                    if (attachment == GL_DEPTH_STENCIL)
+                    {
+                        gl::error(GL_INVALID_OPERATION);
+                    }
+                    *params = renderbuffer-&gt;getComponentType();
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
+                    *params = renderbuffer-&gt;getColorEncoding();
+                    break;
+
+                  case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
+                    if (attachmentObjectType != GL_TEXTURE)
+                    {
+                        return gl::error(GL_INVALID_ENUM);
+                    }
+                    *params = attachmentLayer;
+                    break;
+
+                  default:
+                    UNREACHABLE();
+                    break;
</ins><span class="cx">                 }
</span><del>-                break;
-              default:
-                return gl::error(GL_INVALID_ENUM);
</del><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -3363,53 +2954,23 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (!(context-&gt;getIntegerv(pname, params)))
-            {
-                GLenum nativeType;
-                unsigned int numParams = 0;
-                if (!context-&gt;getQueryParameterInfo(pname, &amp;nativeType, &amp;numParams))
-                    return gl::error(GL_INVALID_ENUM);
</del><ins>+            GLenum nativeType;
+            unsigned int numParams = 0;
+            if (!context-&gt;getQueryParameterInfo(pname, &amp;nativeType, &amp;numParams))
+                return gl::error(GL_INVALID_ENUM);
</ins><span class="cx"> 
</span><del>-                if (numParams == 0)
-                    return; // it is known that pname is valid, but there are no parameters to return
</del><ins>+            // pname is valid, but there are no parameters to return
+            if (numParams == 0)
+                return;
</ins><span class="cx"> 
</span><del>-                if (nativeType == GL_BOOL)
-                {
-                    GLboolean *boolParams = NULL;
-                    boolParams = new GLboolean[numParams];
-
-                    context-&gt;getBooleanv(pname, boolParams);
-
-                    for (unsigned int i = 0; i &lt; numParams; ++i)
-                    {
-                        if (boolParams[i] == GL_FALSE)
-                            params[i] = 0;
-                        else
-                            params[i] = 1;
-                    }
-
-                    delete [] boolParams;
-                }
-                else if (nativeType == GL_FLOAT)
-                {
-                    GLfloat *floatParams = NULL;
-                    floatParams = new GLfloat[numParams];
-
-                    context-&gt;getFloatv(pname, floatParams);
-
-                    for (unsigned int i = 0; i &lt; numParams; ++i)
-                    {
-                        if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR)
-                        {
-                            params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f);
-                        }
-                        else
-                            params[i] = (GLint)(floatParams[i] &gt; 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5));
-                    }
-
-                    delete [] floatParams;
-                }
</del><ins>+            if (nativeType == GL_INT)
+            {
+                context-&gt;getIntegerv(pname, params);
</ins><span class="cx">             }
</span><ins>+            else
+            {
+                CastStateValues(context, nativeType, pname, numParams, params);
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -3435,6 +2996,19 @@
</span><span class="cx">                 return gl::error(GL_INVALID_VALUE);
</span><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                switch (pname)
+                {
+                  case GL_ACTIVE_UNIFORM_BLOCKS:
+                  case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
+                  case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
+                  case GL_TRANSFORM_FEEDBACK_VARYINGS:
+                  case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
+                    return gl::error(GL_INVALID_ENUM);
+                }
+            }
+
</ins><span class="cx">             switch (pname)
</span><span class="cx">             {
</span><span class="cx">               case GL_DELETE_STATUS:
</span><span class="lines">@@ -3467,6 +3041,21 @@
</span><span class="cx">               case GL_PROGRAM_BINARY_LENGTH_OES:
</span><span class="cx">                 *params = programObject-&gt;getProgramBinaryLength();
</span><span class="cx">                 return;
</span><ins>+              case GL_ACTIVE_UNIFORM_BLOCKS:
+                *params = programObject-&gt;getActiveUniformBlockCount();
+                return;
+              case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
+                *params = programObject-&gt;getActiveUniformBlockMaxLength();
+                break;
+              case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
+                *params = programObject-&gt;getTransformFeedbackBufferMode();
+                break;
+              case GL_TRANSFORM_FEEDBACK_VARYINGS:
+                *params = programObject-&gt;getTransformFeedbackVaryingCount();
+                break;
+              case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
+                *params = programObject-&gt;getTransformFeedbackVaryingMaxLength();
+                break;
</ins><span class="cx">               default:
</span><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="lines">@@ -3516,19 +3105,24 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        switch (pname)
-        {
-          case GL_CURRENT_QUERY_EXT:
-            break;
-          default:
-            return gl::error(GL_INVALID_ENUM);
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            params[0] = context-&gt;getActiveQuery(target);
</del><ins>+            if (!ValidQueryType(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            switch (pname)
+            {
+              case GL_CURRENT_QUERY_EXT:
+                params[0] = context-&gt;getActiveQuery(target);
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -3543,14 +3137,6 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        switch (pname)
-        {
-          case GL_QUERY_RESULT_EXT:
-          case GL_QUERY_RESULT_AVAILABLE_EXT:
-            break;
-          default:
-            return gl::error(GL_INVALID_ENUM);
-        }
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="lines">@@ -3576,7 +3162,7 @@
</span><span class="cx">                 params[0] = queryObject-&gt;isResultAvailable();
</span><span class="cx">                 break;
</span><span class="cx">               default:
</span><del>-                ASSERT(false);
</del><ins>+                return gl::error(GL_INVALID_ENUM);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -3844,11 +3430,25 @@
</span><span class="cx">           case GL_RENDERER:
</span><span class="cx">             return (GLubyte*)((context != NULL) ? context-&gt;getRendererString() : &quot;ANGLE&quot;);
</span><span class="cx">           case GL_VERSION:
</span><del>-            return (GLubyte*)&quot;OpenGL ES 2.0 (ANGLE &quot; ANGLE_VERSION_STRING &quot;)&quot;;
</del><ins>+            if (context-&gt;getClientVersion() == 2)
+            {
+                return (GLubyte*)&quot;OpenGL ES 2.0 (ANGLE &quot; ANGLE_VERSION_STRING &quot;)&quot;;
+            }
+            else
+            {
+                return (GLubyte*)&quot;OpenGL ES 3.0 (ANGLE &quot; ANGLE_VERSION_STRING &quot;)&quot;;
+            }
</ins><span class="cx">           case GL_SHADING_LANGUAGE_VERSION:
</span><del>-            return (GLubyte*)&quot;OpenGL ES GLSL ES 1.00 (ANGLE &quot; ANGLE_VERSION_STRING &quot;)&quot;;
</del><ins>+            if (context-&gt;getClientVersion() == 2)
+            {
+                return (GLubyte*)&quot;OpenGL ES GLSL ES 1.00 (ANGLE &quot; ANGLE_VERSION_STRING &quot;)&quot;;
+            }
+            else
+            {
+                return (GLubyte*)&quot;OpenGL ES GLSL ES 3.00 (ANGLE &quot; ANGLE_VERSION_STRING &quot;)&quot;;
+            }
</ins><span class="cx">           case GL_EXTENSIONS:
</span><del>-            return (GLubyte*)((context != NULL) ? context-&gt;getExtensionString() : &quot;&quot;);
</del><ins>+            return (GLubyte*)((context != NULL) ? context-&gt;getCombinedExtensionsString() : &quot;&quot;);
</ins><span class="cx">           default:
</span><span class="cx">             return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL);
</span><span class="cx">         }
</span><span class="lines">@@ -3869,17 +3469,10 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Texture *texture;
</del><ins>+            gl::Texture *texture = context-&gt;getTargetTexture(target);
</ins><span class="cx"> 
</span><del>-            switch (target)
</del><ins>+            if (!texture)
</ins><span class="cx">             {
</span><del>-              case GL_TEXTURE_2D:
-                texture = context-&gt;getTexture2D();
-                break;
-              case GL_TEXTURE_CUBE_MAP:
-                texture = context-&gt;getTextureCubeMap();
-                break;
-              default:
</del><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="lines">@@ -3897,9 +3490,24 @@
</span><span class="cx">               case GL_TEXTURE_WRAP_T:
</span><span class="cx">                 *params = (GLfloat)texture-&gt;getWrapT();
</span><span class="cx">                 break;
</span><del>-              case GL_TEXTURE_IMMUTABLE_FORMAT_EXT:
</del><ins>+              case GL_TEXTURE_WRAP_R:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLfloat)texture-&gt;getWrapR();
+                break;
+              case GL_TEXTURE_IMMUTABLE_FORMAT:
+                // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
</ins><span class="cx">                 *params = (GLfloat)(texture-&gt;isImmutable() ? GL_TRUE : GL_FALSE);
</span><span class="cx">                 break;
</span><ins>+              case GL_TEXTURE_IMMUTABLE_LEVELS:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLfloat)texture-&gt;immutableLevelCount();
+                break;
</ins><span class="cx">               case GL_TEXTURE_USAGE_ANGLE:
</span><span class="cx">                 *params = (GLfloat)texture-&gt;getUsage();
</span><span class="cx">                 break;
</span><span class="lines">@@ -3910,6 +3518,62 @@
</span><span class="cx">                 }
</span><span class="cx">                 *params = (GLfloat)texture-&gt;getMaxAnisotropy();
</span><span class="cx">                 break;
</span><ins>+              case GL_TEXTURE_SWIZZLE_R:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLfloat)texture-&gt;getSwizzleRed();
+                break;
+              case GL_TEXTURE_SWIZZLE_G:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLfloat)texture-&gt;getSwizzleGreen();
+                break;
+              case GL_TEXTURE_SWIZZLE_B:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLfloat)texture-&gt;getSwizzleBlue();
+                break;
+              case GL_TEXTURE_SWIZZLE_A:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLfloat)texture-&gt;getSwizzleAlpha();
+                break;
+              case GL_TEXTURE_BASE_LEVEL:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLfloat)texture-&gt;getBaseLevel();
+                break;
+              case GL_TEXTURE_MAX_LEVEL:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLfloat)texture-&gt;getMaxLevel();
+                break;
+              case GL_TEXTURE_MIN_LOD:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;getMinLod();
+                break;
+              case GL_TEXTURE_MAX_LOD:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;getMaxLod();
+                break;
</ins><span class="cx">               default:
</span><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="lines">@@ -3931,17 +3595,10 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Texture *texture;
</del><ins>+            gl::Texture *texture = context-&gt;getTargetTexture(target);
</ins><span class="cx"> 
</span><del>-            switch (target)
</del><ins>+            if (!texture)
</ins><span class="cx">             {
</span><del>-              case GL_TEXTURE_2D:
-                texture = context-&gt;getTexture2D();
-                break;
-              case GL_TEXTURE_CUBE_MAP:
-                texture = context-&gt;getTextureCubeMap();
-                break;
-              default:
</del><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="lines">@@ -3959,9 +3616,24 @@
</span><span class="cx">               case GL_TEXTURE_WRAP_T:
</span><span class="cx">                 *params = texture-&gt;getWrapT();
</span><span class="cx">                 break;
</span><del>-              case GL_TEXTURE_IMMUTABLE_FORMAT_EXT:
</del><ins>+              case GL_TEXTURE_WRAP_R:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;getWrapR();
+                break;
+              case GL_TEXTURE_IMMUTABLE_FORMAT:
+                // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
</ins><span class="cx">                 *params = texture-&gt;isImmutable() ? GL_TRUE : GL_FALSE;
</span><span class="cx">                 break;
</span><ins>+              case GL_TEXTURE_IMMUTABLE_LEVELS:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;immutableLevelCount();
+                break;
</ins><span class="cx">               case GL_TEXTURE_USAGE_ANGLE:
</span><span class="cx">                 *params = texture-&gt;getUsage();
</span><span class="cx">                 break;
</span><span class="lines">@@ -3972,6 +3644,62 @@
</span><span class="cx">                 }
</span><span class="cx">                 *params = (GLint)texture-&gt;getMaxAnisotropy();
</span><span class="cx">                 break;
</span><ins>+              case GL_TEXTURE_SWIZZLE_R:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;getSwizzleRed();
+                break;
+              case GL_TEXTURE_SWIZZLE_G:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;getSwizzleGreen();
+                break;
+              case GL_TEXTURE_SWIZZLE_B:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;getSwizzleBlue();
+                break;
+              case GL_TEXTURE_SWIZZLE_A:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;getSwizzleAlpha();
+                break;
+              case GL_TEXTURE_BASE_LEVEL:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;getBaseLevel();
+                break;
+              case GL_TEXTURE_MAX_LEVEL:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = texture-&gt;getMaxLevel();
+                break;
+              case GL_TEXTURE_MIN_LOD:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLint)texture-&gt;getMinLod();
+                break;
+              case GL_TEXTURE_MAX_LOD:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                *params = (GLint)texture-&gt;getMaxLod();
+                break;
</ins><span class="cx">               default:
</span><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="lines">@@ -4218,37 +3946,23 @@
</span><span class="cx"> 
</span><span class="cx">             const gl::VertexAttribute &amp;attribState = context-&gt;getVertexAttribState(index);
</span><span class="cx"> 
</span><del>-            switch (pname)
</del><ins>+            if (!gl::ValidateGetVertexAttribParameters(pname, context-&gt;getClientVersion()))
</ins><span class="cx">             {
</span><del>-              case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
-                *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_SIZE:
-                *params = (GLfloat)attribState.mSize;
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
-                *params = (GLfloat)attribState.mStride;
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_TYPE:
-                *params = (GLfloat)attribState.mType;
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
-                *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE);
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
-                *params = (GLfloat)attribState.mBoundBuffer.id();
-                break;
-              case GL_CURRENT_VERTEX_ATTRIB:
</del><ins>+                return;
+            }
+
+            if (pname == GL_CURRENT_VERTEX_ATTRIB)
+            {
+                const gl::VertexAttribCurrentValueData &amp;currentValueData = context-&gt;getVertexAttribCurrentValue(index);
</ins><span class="cx">                 for (int i = 0; i &lt; 4; ++i)
</span><span class="cx">                 {
</span><del>-                    params[i] = attribState.mCurrentValue[i];
</del><ins>+                    params[i] = currentValueData.FloatValues[i];
</ins><span class="cx">                 }
</span><del>-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:
-                *params = (GLfloat)attribState.mDivisor;
-                break;
-              default: return gl::error(GL_INVALID_ENUM);
</del><span class="cx">             }
</span><ins>+            else
+            {
+                *params = attribState.querySingleParameter&lt;GLfloat&gt;(pname);
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -4274,38 +3988,24 @@
</span><span class="cx"> 
</span><span class="cx">             const gl::VertexAttribute &amp;attribState = context-&gt;getVertexAttribState(index);
</span><span class="cx"> 
</span><del>-            switch (pname)
</del><ins>+            if (!gl::ValidateGetVertexAttribParameters(pname, context-&gt;getClientVersion()))
</ins><span class="cx">             {
</span><del>-              case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
-                *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_SIZE:
-                *params = attribState.mSize;
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
-                *params = attribState.mStride;
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_TYPE:
-                *params = attribState.mType;
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
-                *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
-                *params = attribState.mBoundBuffer.id();
-                break;
-              case GL_CURRENT_VERTEX_ATTRIB:
</del><ins>+                return;
+            }
+
+            if (pname == GL_CURRENT_VERTEX_ATTRIB)
+            {
+                const gl::VertexAttribCurrentValueData &amp;currentValueData = context-&gt;getVertexAttribCurrentValue(index);
</ins><span class="cx">                 for (int i = 0; i &lt; 4; ++i)
</span><span class="cx">                 {
</span><del>-                    float currentValue = attribState.mCurrentValue[i];
-                    params[i] = (GLint)(currentValue &gt; 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
</del><ins>+                    float currentValue = currentValueData.FloatValues[i];
+                    params[i] = gl::iround&lt;GLint&gt;(currentValue);
</ins><span class="cx">                 }
</span><del>-                break;
-              case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:
-                *params = (GLint)attribState.mDivisor;
-                break;
-              default: return gl::error(GL_INVALID_ENUM);
</del><span class="cx">             }
</span><ins>+            else
+            {
+                *params = attribState.querySingleParameter&lt;GLint&gt;(pname);
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -4414,20 +4114,12 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            switch (cap)
</del><ins>+            if (!ValidCap(context, cap))
</ins><span class="cx">             {
</span><del>-              case GL_CULL_FACE:                return context-&gt;isCullFaceEnabled();
-              case GL_POLYGON_OFFSET_FILL:      return context-&gt;isPolygonOffsetFillEnabled();
-              case GL_SAMPLE_ALPHA_TO_COVERAGE: return context-&gt;isSampleAlphaToCoverageEnabled();
-              case GL_SAMPLE_COVERAGE:          return context-&gt;isSampleCoverageEnabled();
-              case GL_SCISSOR_TEST:             return context-&gt;isScissorTestEnabled();
-              case GL_STENCIL_TEST:             return context-&gt;isStencilTestEnabled();
-              case GL_DEPTH_TEST:               return context-&gt;isDepthTestEnabled();
-              case GL_BLEND:                    return context-&gt;isBlendEnabled();
-              case GL_DITHER:                   return context-&gt;isDitherEnabled();
-              default:
</del><span class="cx">                 return gl::error(GL_INVALID_ENUM, false);
</span><span class="cx">             }
</span><ins>+
+            return context-&gt;getCap(cap);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -4448,7 +4140,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Fence *fenceObject = context-&gt;getFence(fence);
</del><ins>+            gl::FenceNV *fenceObject = context-&gt;getFenceNV(fence);
</ins><span class="cx"> 
</span><span class="cx">             if (fenceObject == NULL)
</span><span class="cx">             {
</span><span class="lines">@@ -4524,21 +4216,11 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (id == 0)
-        {
-            return GL_FALSE;
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Query *queryObject = context-&gt;getQuery(id, false, GL_NONE);
-
-            if (queryObject)
-            {
-                return GL_TRUE;
-            }
</del><ins>+            return (context-&gt;getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -4718,6 +4400,21 @@
</span><span class="cx">                 context-&gt;setPackReverseRowOrder(param != 0);
</span><span class="cx">                 break;
</span><span class="cx"> 
</span><ins>+              case GL_UNPACK_IMAGE_HEIGHT:
+              case GL_UNPACK_SKIP_IMAGES:
+              case GL_UNPACK_ROW_LENGTH:
+              case GL_UNPACK_SKIP_ROWS:
+              case GL_UNPACK_SKIP_PIXELS:
+              case GL_PACK_ROW_LENGTH:
+              case GL_PACK_SKIP_ROWS:
+              case GL_PACK_SKIP_PIXELS:
+                if (context-&gt;getClientVersion() &lt; 3)
+                {
+                    return gl::error(GL_INVALID_ENUM);
+                }
+                UNIMPLEMENTED();
+                break;
+
</ins><span class="cx">               default:
</span><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="lines">@@ -4767,17 +4464,10 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            GLenum currentFormat, currentType;
-    
-            // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
-            // and attempting to read back if that's the case is an error. The error will be registered
-            // by getCurrentReadFormat.
-            if (!context-&gt;getCurrentReadFormatType(&amp;currentFormat, &amp;currentType))
</del><ins>+            if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
+                                                  format, type, &amp;bufSize, data))
+            {
</ins><span class="cx">                 return;
</span><del>-
-            if (!(currentFormat == format &amp;&amp; currentType == type) &amp;&amp; !validReadFormatType(format, type))
-            {
-                return gl::error(GL_INVALID_OPERATION);
</del><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             context-&gt;readPixels(x, y, width, height, format, type, &amp;bufSize, data);
</span><span class="lines">@@ -4807,17 +4497,10 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            GLenum currentFormat, currentType;
-    
-            // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
-            // and attempting to read back if that's the case is an error. The error will be registered
-            // by getCurrentReadFormat.
-            if (!context-&gt;getCurrentReadFormatType(&amp;currentFormat, &amp;currentType))
</del><ins>+            if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
+                                                  format, type, NULL, pixels))
+            {
</ins><span class="cx">                 return;
</span><del>-
-            if (!(currentFormat == format &amp;&amp; currentType == type) &amp;&amp; !validReadFormatType(format, type))
-            {
-                return gl::error(GL_INVALID_OPERATION);
</del><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             context-&gt;readPixels(x, y, width, height, format, type, NULL, pixels);
</span><span class="lines">@@ -4850,56 +4533,17 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        switch (target)
-        {
-          case GL_RENDERBUFFER:
-            break;
-          default:
-            return gl::error(GL_INVALID_ENUM);
-        }
-
-        if (!gl::IsColorRenderable(internalformat) &amp;&amp; !gl::IsDepthRenderable(internalformat) &amp;&amp; !gl::IsStencilRenderable(internalformat))
-        {
-            return gl::error(GL_INVALID_ENUM);
-        }
-
-        if (width &lt; 0 || height &lt; 0 || samples &lt; 0)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (width &gt; context-&gt;getMaximumRenderbufferDimension() || 
-                height &gt; context-&gt;getMaximumRenderbufferDimension() ||
-                samples &gt; context-&gt;getMaxSupportedSamples())
</del><ins>+            if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
+                                                       width, height, true))
</ins><span class="cx">             {
</span><del>-                return gl::error(GL_INVALID_VALUE);
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            GLuint handle = context-&gt;getRenderbufferHandle();
-            if (handle == 0)
-            {
-                return gl::error(GL_INVALID_OPERATION);
-            }
-
-            switch (internalformat)
-            {
-              case GL_DEPTH_COMPONENT16:
-              case GL_RGBA4:
-              case GL_RGB5_A1:
-              case GL_RGB565:
-              case GL_RGB8_OES:
-              case GL_RGBA8_OES:
-              case GL_STENCIL_INDEX8:
-              case GL_DEPTH24_STENCIL8_OES:
-                context-&gt;setRenderbufferStorage(width, height, internalformat, samples);
-                break;
-              default:
-                return gl::error(GL_INVALID_ENUM);
-            }
</del><ins>+            context-&gt;setRenderbufferStorage(width, height, internalformat, samples);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -4915,7 +4559,7 @@
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
</span><span class="cx"> {
</span><del>-    EVENT(&quot;(GLclampf value = %f, GLboolean invert = %d)&quot;, value, invert);
</del><ins>+    EVENT(&quot;(GLclampf value = %f, GLboolean invert = %u)&quot;, value, invert);
</ins><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><span class="lines">@@ -4947,7 +4591,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Fence *fenceObject = context-&gt;getFence(fence);
</del><ins>+            gl::FenceNV *fenceObject = context-&gt;getFenceNV(fence);
</ins><span class="cx"> 
</span><span class="cx">             if (fenceObject == NULL)
</span><span class="cx">             {
</span><span class="lines">@@ -5004,7 +4648,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length)
</del><ins>+void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
</ins><span class="cx"> {
</span><span class="cx">     EVENT(&quot;(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)&quot;,
</span><span class="cx">           shader, count, string, length);
</span><span class="lines">@@ -5240,13 +4884,18 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Fence *fenceObject = context-&gt;getFence(fence);
</del><ins>+            gl::FenceNV *fenceObject = context-&gt;getFenceNV(fence);
</ins><span class="cx"> 
</span><span class="cx">             if (fenceObject == NULL)
</span><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
</span><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            if (fenceObject-&gt;isFence() != GL_TRUE)
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_TRUE);
+            }
+
</ins><span class="cx">             return fenceObject-&gt;testFence();
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -5262,283 +4911,75 @@
</span><span class="cx">                             GLint border, GLenum format, GLenum type, const GLvoid* pixels)
</span><span class="cx"> {
</span><span class="cx">     EVENT(&quot;(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, &quot;
</span><del>-          &quot;GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels =  0x%0.8p)&quot;,
</del><ins>+          &quot;GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)&quot;,
</ins><span class="cx">           target, level, internalformat, width, height, border, format, type, pixels);
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (!validImageSize(level, width, height))
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
</del><ins>+        gl::Context *context = gl::getNonLostContext();
</ins><span class="cx"> 
</span><del>-        if (internalformat != GLint(format))
</del><ins>+        if (context)
</ins><span class="cx">         {
</span><del>-            return gl::error(GL_INVALID_OPERATION);
-        }
-
-        // validate &lt;type&gt; by itself (used as secondary key below)
-        switch (type)
-        {
-          case GL_UNSIGNED_BYTE:
-          case GL_UNSIGNED_SHORT_5_6_5:
-          case GL_UNSIGNED_SHORT_4_4_4_4:
-          case GL_UNSIGNED_SHORT_5_5_5_1:
-          case GL_UNSIGNED_SHORT:
-          case GL_UNSIGNED_INT:
-          case GL_UNSIGNED_INT_24_8_OES:
-          case GL_HALF_FLOAT_OES:
-          case GL_FLOAT:
-            break;
-          default:
-            return gl::error(GL_INVALID_ENUM);
-        }
-
-        // validate &lt;format&gt; + &lt;type&gt; combinations
-        // - invalid &lt;format&gt; -&gt; sets INVALID_ENUM
-        // - invalid &lt;format&gt;+&lt;type&gt; combination -&gt; sets INVALID_OPERATION
-        switch (format)
-        {
-          case GL_ALPHA:
-          case GL_LUMINANCE:
-          case GL_LUMINANCE_ALPHA:
-            switch (type)
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3 &amp;&amp;
+                !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
+                                               0, 0, width, height, border, format, type, pixels))
</ins><span class="cx">             {
</span><del>-              case GL_UNSIGNED_BYTE:
-              case GL_FLOAT:
-              case GL_HALF_FLOAT_OES:
-                break;
-              default:
-                return gl::error(GL_INVALID_OPERATION);
</del><ins>+                return;
</ins><span class="cx">             }
</span><del>-            break;
-          case GL_RGB:
-            switch (type)
-            {
-              case GL_UNSIGNED_BYTE:
-              case GL_UNSIGNED_SHORT_5_6_5:
-              case GL_FLOAT:
-              case GL_HALF_FLOAT_OES:
-                break;
-              default:
-                return gl::error(GL_INVALID_OPERATION);
-            }
-            break;
-          case GL_RGBA:
-            switch (type)
-            {
-              case GL_UNSIGNED_BYTE:
-              case GL_UNSIGNED_SHORT_4_4_4_4:
-              case GL_UNSIGNED_SHORT_5_5_5_1:
-              case GL_FLOAT:
-              case GL_HALF_FLOAT_OES:
-                break;
-              default:
-                return gl::error(GL_INVALID_OPERATION);
-            }
-            break;
-          case GL_BGRA_EXT:
-            switch (type)
-            {
-              case GL_UNSIGNED_BYTE:
-                break;
-              default:
-                return gl::error(GL_INVALID_OPERATION);
-            }
-            break;
-          case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:  // error cases for compressed textures are handled below
-          case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-          case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-          case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-            break; 
-          case GL_DEPTH_COMPONENT:
-            switch (type)
-            {
-              case GL_UNSIGNED_SHORT:
-              case GL_UNSIGNED_INT:
-                break;
-              default:
-                return gl::error(GL_INVALID_OPERATION);
-            }
-            break;
-          case GL_DEPTH_STENCIL_OES:
-            switch (type)
-            {
-              case GL_UNSIGNED_INT_24_8_OES:
-                break;
-              default:
-                return gl::error(GL_INVALID_OPERATION);
-            }
-            break;
-          default:
-            return gl::error(GL_INVALID_ENUM);
-        }
</del><span class="cx"> 
</span><del>-        if (border != 0)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        gl::Context *context = gl::getNonLostContext();
-
-        if (context)
-        {
-            if (level &gt; context-&gt;getMaximumTextureLevel())
</del><ins>+            if (context-&gt;getClientVersion() &gt;= 3 &amp;&amp;
+                !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
+                                               0, 0, 0, width, height, 1, border, format, type, pixels))
</ins><span class="cx">             {
</span><del>-                return gl::error(GL_INVALID_VALUE);
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             switch (target)
</span><span class="cx">             {
</span><span class="cx">               case GL_TEXTURE_2D:
</span><del>-                if (width &gt; (context-&gt;getMaximumTextureDimension() &gt;&gt; level) ||
-                    height &gt; (context-&gt;getMaximumTextureDimension() &gt;&gt; level))
</del><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_VALUE);
</del><ins>+                    gl::Texture2D *texture = context-&gt;getTexture2D();
+                    texture-&gt;setImage(level, width, height, internalformat, format, type, context-&gt;getUnpackState(), pixels);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">               case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
</span><del>-              case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-              case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-              case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-                if (width != height)
</del><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_VALUE);
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;setImagePosX(level, width, height, internalformat, format, type, context-&gt;getUnpackState(), pixels);
</ins><span class="cx">                 }
</span><del>-
-                if (width &gt; (context-&gt;getMaximumCubeTextureDimension() &gt;&gt; level) ||
-                    height &gt; (context-&gt;getMaximumCubeTextureDimension() &gt;&gt; level))
</del><ins>+                break;
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_VALUE);
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;setImageNegX(level, width, height, internalformat, format, type, context-&gt;getUnpackState(), pixels);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><del>-              default:
-                return gl::error(GL_INVALID_ENUM);
-            }
-
-            switch (format) {
-              case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-              case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-                if (context-&gt;supportsDXT1Textures())
</del><ins>+              case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_OPERATION);
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;setImagePosY(level, width, height, internalformat, format, type, context-&gt;getUnpackState(), pixels);
</ins><span class="cx">                 }
</span><del>-                else
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
</del><span class="cx">                 break;
</span><del>-              case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-                if (context-&gt;supportsDXT3Textures())
</del><ins>+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_OPERATION);
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;setImageNegY(level, width, height, internalformat, format, type, context-&gt;getUnpackState(), pixels);
</ins><span class="cx">                 }
</span><del>-                else
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
</del><span class="cx">                 break;
</span><del>-              case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-                if (context-&gt;supportsDXT5Textures())
</del><ins>+              case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_OPERATION);
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;setImagePosZ(level, width, height, internalformat, format, type, context-&gt;getUnpackState(), pixels);
</ins><span class="cx">                 }
</span><del>-                else
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
</del><span class="cx">                 break;
</span><del>-              case GL_DEPTH_COMPONENT:
-              case GL_DEPTH_STENCIL_OES:
-                if (!context-&gt;supportsDepthTextures())
</del><ins>+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_VALUE);
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;setImageNegZ(level, width, height, internalformat, format, type, context-&gt;getUnpackState(), pixels);
</ins><span class="cx">                 }
</span><del>-                if (target != GL_TEXTURE_2D)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                // OES_depth_texture supports loading depth data and multiple levels,
-                // but ANGLE_depth_texture does not
-                if (pixels != NULL || level != 0)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
</del><span class="cx">                 break;
</span><del>-              default:
-                break;
</del><ins>+              default: UNREACHABLE();
</ins><span class="cx">             }
</span><del>-
-            if (type == GL_FLOAT)
-            {
-                if (!context-&gt;supportsFloat32Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-            }
-            else if (type == GL_HALF_FLOAT_OES)
-            {
-                if (!context-&gt;supportsFloat16Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-            }
-
-            if (target == GL_TEXTURE_2D)
-            {
-                gl::Texture2D *texture = context-&gt;getTexture2D();
-
-                if (!texture)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                if (texture-&gt;isImmutable())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                texture-&gt;setImage(level, width, height, format, type, context-&gt;getUnpackAlignment(), pixels);
-            }
-            else
-            {
-                gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
-
-                if (!texture)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                if (texture-&gt;isImmutable())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                switch (target)
-                {
-                  case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-                    texture-&gt;setImagePosX(level, width, height, format, type, context-&gt;getUnpackAlignment(), pixels);
-                    break;
-                  case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-                    texture-&gt;setImageNegX(level, width, height, format, type, context-&gt;getUnpackAlignment(), pixels);
-                    break;
-                  case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-                    texture-&gt;setImagePosY(level, width, height, format, type, context-&gt;getUnpackAlignment(), pixels);
-                    break;
-                  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-                    texture-&gt;setImageNegY(level, width, height, format, type, context-&gt;getUnpackAlignment(), pixels);
-                    break;
-                  case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-                    texture-&gt;setImagePosZ(level, width, height, format, type, context-&gt;getUnpackAlignment(), pixels);
-                    break;
-                  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-                    texture-&gt;setImageNegZ(level, width, height, format, type, context-&gt;getUnpackAlignment(), pixels);
-                    break;
-                  default: UNREACHABLE();
-                }
-            }
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -5557,64 +4998,38 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Texture *texture;
</del><ins>+            if (!ValidateTexParamParameters(context, pname, static_cast&lt;GLint&gt;(param)))
+            {
+                return;
+            }
</ins><span class="cx"> 
</span><del>-            switch (target)
</del><ins>+            gl::Texture *texture = context-&gt;getTargetTexture(target);
+
+            if (!texture)
</ins><span class="cx">             {
</span><del>-              case GL_TEXTURE_2D:
-                texture = context-&gt;getTexture2D();
-                break;
-              case GL_TEXTURE_CUBE_MAP:
-                texture = context-&gt;getTextureCubeMap();
-                break;
-              default:
</del><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             switch (pname)
</span><span class="cx">             {
</span><del>-              case GL_TEXTURE_WRAP_S:
-                if (!texture-&gt;setWrapS((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_WRAP_T:
-                if (!texture-&gt;setWrapT((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_MIN_FILTER:
-                if (!texture-&gt;setMinFilter((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_MAG_FILTER:
-                if (!texture-&gt;setMagFilter((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_USAGE_ANGLE:
-                if (!texture-&gt;setUsage((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_MAX_ANISOTROPY_EXT:
-                if (!context-&gt;supportsTextureFilterAnisotropy())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                if (!texture-&gt;setMaxAnisotropy((float)param, context-&gt;getTextureMaxAnisotropy()))
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
-                break;
-              default:
-                return gl::error(GL_INVALID_ENUM);
</del><ins>+              case GL_TEXTURE_WRAP_S:               texture-&gt;setWrapS(gl::uiround&lt;GLenum&gt;(param));       break;
+              case GL_TEXTURE_WRAP_T:               texture-&gt;setWrapT(gl::uiround&lt;GLenum&gt;(param));       break;
+              case GL_TEXTURE_WRAP_R:               texture-&gt;setWrapR(gl::uiround&lt;GLenum&gt;(param));       break;
+              case GL_TEXTURE_MIN_FILTER:           texture-&gt;setMinFilter(gl::uiround&lt;GLenum&gt;(param));   break;
+              case GL_TEXTURE_MAG_FILTER:           texture-&gt;setMagFilter(gl::uiround&lt;GLenum&gt;(param));   break;
+              case GL_TEXTURE_USAGE_ANGLE:          texture-&gt;setUsage(gl::uiround&lt;GLenum&gt;(param));       break;
+              case GL_TEXTURE_MAX_ANISOTROPY_EXT:   texture-&gt;setMaxAnisotropy(param, context-&gt;getTextureMaxAnisotropy()); break;
+              case GL_TEXTURE_COMPARE_MODE:         texture-&gt;setCompareMode(gl::uiround&lt;GLenum&gt;(param)); break;
+              case GL_TEXTURE_COMPARE_FUNC:         texture-&gt;setCompareFunc(gl::uiround&lt;GLenum&gt;(param)); break;
+              case GL_TEXTURE_SWIZZLE_R:            texture-&gt;setSwizzleRed(gl::uiround&lt;GLenum&gt;(param));   break;
+              case GL_TEXTURE_SWIZZLE_G:            texture-&gt;setSwizzleGreen(gl::uiround&lt;GLenum&gt;(param)); break;
+              case GL_TEXTURE_SWIZZLE_B:            texture-&gt;setSwizzleBlue(gl::uiround&lt;GLenum&gt;(param));  break;
+              case GL_TEXTURE_SWIZZLE_A:            texture-&gt;setSwizzleAlpha(gl::uiround&lt;GLenum&gt;(param)); break;
+              case GL_TEXTURE_BASE_LEVEL:           texture-&gt;setBaseLevel(gl::iround&lt;GLint&gt;(param));      break;
+              case GL_TEXTURE_MAX_LEVEL:            texture-&gt;setMaxLevel(gl::iround&lt;GLint&gt;(param));       break;
+              case GL_TEXTURE_MIN_LOD:              texture-&gt;setMinLod(param);                            break;
+              case GL_TEXTURE_MAX_LOD:              texture-&gt;setMaxLod(param);                            break;
+              default: UNREACHABLE(); break;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -5639,64 +5054,38 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            gl::Texture *texture;
</del><ins>+            if (!ValidateTexParamParameters(context, pname, param))
+            {
+                return;
+            }
</ins><span class="cx"> 
</span><del>-            switch (target)
</del><ins>+            gl::Texture *texture = context-&gt;getTargetTexture(target);
+
+            if (!texture)
</ins><span class="cx">             {
</span><del>-              case GL_TEXTURE_2D:
-                texture = context-&gt;getTexture2D();
-                break;
-              case GL_TEXTURE_CUBE_MAP:
-                texture = context-&gt;getTextureCubeMap();
-                break;
-              default:
</del><span class="cx">                 return gl::error(GL_INVALID_ENUM);
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             switch (pname)
</span><span class="cx">             {
</span><del>-              case GL_TEXTURE_WRAP_S:
-                if (!texture-&gt;setWrapS((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_WRAP_T:
-                if (!texture-&gt;setWrapT((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_MIN_FILTER:
-                if (!texture-&gt;setMinFilter((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_MAG_FILTER:
-                if (!texture-&gt;setMagFilter((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_USAGE_ANGLE:
-                if (!texture-&gt;setUsage((GLenum)param))
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_TEXTURE_MAX_ANISOTROPY_EXT:
-                if (!context-&gt;supportsTextureFilterAnisotropy())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                if (!texture-&gt;setMaxAnisotropy((float)param, context-&gt;getTextureMaxAnisotropy()))
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
-                break;
-              default:
-                return gl::error(GL_INVALID_ENUM);
</del><ins>+              case GL_TEXTURE_WRAP_S:               texture-&gt;setWrapS((GLenum)param);       break;
+              case GL_TEXTURE_WRAP_T:               texture-&gt;setWrapT((GLenum)param);       break;
+              case GL_TEXTURE_WRAP_R:               texture-&gt;setWrapR((GLenum)param);       break;
+              case GL_TEXTURE_MIN_FILTER:           texture-&gt;setMinFilter((GLenum)param);   break;
+              case GL_TEXTURE_MAG_FILTER:           texture-&gt;setMagFilter((GLenum)param);   break;
+              case GL_TEXTURE_USAGE_ANGLE:          texture-&gt;setUsage((GLenum)param);       break;
+              case GL_TEXTURE_MAX_ANISOTROPY_EXT:   texture-&gt;setMaxAnisotropy((float)param, context-&gt;getTextureMaxAnisotropy()); break;
+              case GL_TEXTURE_COMPARE_MODE:         texture-&gt;setCompareMode((GLenum)param); break;
+              case GL_TEXTURE_COMPARE_FUNC:         texture-&gt;setCompareFunc((GLenum)param); break;
+              case GL_TEXTURE_SWIZZLE_R:            texture-&gt;setSwizzleRed((GLenum)param);   break;
+              case GL_TEXTURE_SWIZZLE_G:            texture-&gt;setSwizzleGreen((GLenum)param); break;
+              case GL_TEXTURE_SWIZZLE_B:            texture-&gt;setSwizzleBlue((GLenum)param);  break;
+              case GL_TEXTURE_SWIZZLE_A:            texture-&gt;setSwizzleAlpha((GLenum)param); break;
+              case GL_TEXTURE_BASE_LEVEL:           texture-&gt;setBaseLevel(param);            break;
+              case GL_TEXTURE_MAX_LEVEL:            texture-&gt;setMaxLevel(param);             break;
+              case GL_TEXTURE_MIN_LOD:              texture-&gt;setMinLod((GLfloat)param);      break;
+              case GL_TEXTURE_MAX_LOD:              texture-&gt;setMaxLod((GLfloat)param);      break;
+              default: UNREACHABLE(); break;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -5718,161 +5107,41 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (target != GL_TEXTURE_2D &amp;&amp; target != GL_TEXTURE_CUBE_MAP)
-        {
-            return gl::error(GL_INVALID_ENUM);
-        }
-
-        if (width &lt; 1 || height &lt; 1 || levels &lt; 1)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        if (target == GL_TEXTURE_CUBE_MAP &amp;&amp; width != height)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        if (levels != 1 &amp;&amp; levels != gl::log2(std::max(width, height)) + 1)
-        {
-            return gl::error(GL_INVALID_OPERATION);
-        }
-
-        GLenum format = gl::ExtractFormat(internalformat);
-        GLenum type = gl::ExtractType(internalformat);
-
-        if (format == GL_NONE || type == GL_NONE)
-        {
-            return gl::error(GL_INVALID_ENUM);
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            switch (target)
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3 &amp;&amp;
+                !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
</ins><span class="cx">             {
</span><del>-              case GL_TEXTURE_2D:
-                if (width &gt; context-&gt;getMaximumTextureDimension() ||
-                    height &gt; context-&gt;getMaximumTextureDimension())
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
-                break;
-              case GL_TEXTURE_CUBE_MAP:
-                if (width &gt; context-&gt;getMaximumCubeTextureDimension() ||
-                    height &gt; context-&gt;getMaximumCubeTextureDimension())
-                {
-                    return gl::error(GL_INVALID_VALUE);
-                }
-                break;
-              default:
-                return gl::error(GL_INVALID_ENUM);
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (levels != 1 &amp;&amp; !context-&gt;supportsNonPower2Texture())
</del><ins>+            if (context-&gt;getClientVersion() &gt;= 3 &amp;&amp;
+                !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
</ins><span class="cx">             {
</span><del>-                if (!gl::isPow2(width) || !gl::isPow2(height))
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            switch (internalformat)
</del><ins>+            switch (target)
</ins><span class="cx">             {
</span><del>-              case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-              case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-                if (!context-&gt;supportsDXT1Textures())
</del><ins>+              case GL_TEXTURE_2D:
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_ENUM);
</del><ins>+                    gl::Texture2D *texture2d = context-&gt;getTexture2D();
+                    texture2d-&gt;storage(levels, internalformat, width, height);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><del>-              case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-                if (!context-&gt;supportsDXT3Textures())
</del><ins>+
+              case GL_TEXTURE_CUBE_MAP:
</ins><span class="cx">                 {
</span><del>-                    return gl::error(GL_INVALID_ENUM);
</del><ins>+                    gl::TextureCubeMap *textureCube = context-&gt;getTextureCubeMap();
+                    textureCube-&gt;storage(levels, internalformat, width);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><del>-              case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-                if (!context-&gt;supportsDXT5Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_RGBA32F_EXT:
-              case GL_RGB32F_EXT:
-              case GL_ALPHA32F_EXT:
-              case GL_LUMINANCE32F_EXT:
-              case GL_LUMINANCE_ALPHA32F_EXT:
-                if (!context-&gt;supportsFloat32Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_RGBA16F_EXT:
-              case GL_RGB16F_EXT:
-              case GL_ALPHA16F_EXT:
-              case GL_LUMINANCE16F_EXT:
-              case GL_LUMINANCE_ALPHA16F_EXT:
-                if (!context-&gt;supportsFloat16Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                break;
-              case GL_DEPTH_COMPONENT16:
-              case GL_DEPTH_COMPONENT32_OES:
-              case GL_DEPTH24_STENCIL8_OES:
-                if (!context-&gt;supportsDepthTextures())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                if (target != GL_TEXTURE_2D)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                // ANGLE_depth_texture only supports 1-level textures
-                if (levels != 1)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                break;
</del><ins>+
</ins><span class="cx">               default:
</span><del>-                break;
</del><ins>+                return gl::error(GL_INVALID_ENUM);
</ins><span class="cx">             }
</span><del>-
-            if (target == GL_TEXTURE_2D)
-            {
-                gl::Texture2D *texture = context-&gt;getTexture2D();
-
-                if (!texture || texture-&gt;id() == 0)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                if (texture-&gt;isImmutable())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                texture-&gt;storage(levels, internalformat, width, height);
-            }
-            else if (target == GL_TEXTURE_CUBE_MAP)
-            {
-                gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
-
-                if (!texture || texture-&gt;id() == 0)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                if (texture-&gt;isImmutable())
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-
-                texture-&gt;storage(levels, internalformat, width);
-            }
-            else UNREACHABLE();
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -5891,86 +5160,52 @@
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (!gl::IsInternalTextureTarget(target))
-        {
-            return gl::error(GL_INVALID_ENUM);
-        }
-
-        if (level &lt; 0 || xoffset &lt; 0 || yoffset &lt; 0 || width &lt; 0 || height &lt; 0)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        if (std::numeric_limits&lt;GLsizei&gt;::max() - xoffset &lt; width || std::numeric_limits&lt;GLsizei&gt;::max() - yoffset &lt; height)
-        {
-            return gl::error(GL_INVALID_VALUE);
-        }
-
-        if (!checkTextureFormatType(format, type))
-        {
-            return; // error is set by helper function
-        }
-
</del><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (level &gt; context-&gt;getMaximumTextureLevel())
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3 &amp;&amp;
+                !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
+                                               xoffset, yoffset, width, height, 0, format, type, pixels))
</ins><span class="cx">             {
</span><del>-                return gl::error(GL_INVALID_VALUE);
</del><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (format == GL_FLOAT)
</del><ins>+            if (context-&gt;getClientVersion() &gt;= 3 &amp;&amp;
+                !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
+                                               xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
</ins><span class="cx">             {
</span><del>-                if (!context-&gt;supportsFloat32Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
</del><ins>+                return;
</ins><span class="cx">             }
</span><del>-            else if (format == GL_HALF_FLOAT_OES)
-            {
-                if (!context-&gt;supportsFloat16Textures())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-            }
-            else if (gl::IsDepthTexture(format))
-            {
-                if (!context-&gt;supportsDepthTextures())
-                {
-                    return gl::error(GL_INVALID_ENUM);
-                }
-                if (target != GL_TEXTURE_2D)
-                {
-                    return gl::error(GL_INVALID_OPERATION);
-                }
-                // OES_depth_texture supports loading depth data, but ANGLE_depth_texture does not
-                return gl::error(GL_INVALID_OPERATION);
-            }
</del><span class="cx"> 
</span><del>-            if (width == 0 || height == 0 || pixels == NULL)
</del><ins>+            // Zero sized uploads are valid but no-ops
+            if (width == 0 || height == 0)
</ins><span class="cx">             {
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (target == GL_TEXTURE_2D)
</del><ins>+            switch (target)
</ins><span class="cx">             {
</span><del>-                gl::Texture2D *texture = context-&gt;getTexture2D();
-                if (validateSubImageParams2D(false, width, height, xoffset, yoffset, level, format, type, texture))
</del><ins>+              case GL_TEXTURE_2D:
</ins><span class="cx">                 {
</span><del>-                    texture-&gt;subImage(level, xoffset, yoffset, width, height, format, type, context-&gt;getUnpackAlignment(), pixels);
</del><ins>+                    gl::Texture2D *texture = context-&gt;getTexture2D();
+                    texture-&gt;subImage(level, xoffset, yoffset, width, height, format, type, context-&gt;getUnpackState(), pixels);
</ins><span class="cx">                 }
</span><del>-            }
-            else if (gl::IsCubemapTextureTarget(target))
-            {
-                gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
-                if (validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, format, type, texture))
</del><ins>+                break;
+
+              case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+              case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+              case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+              case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
</ins><span class="cx">                 {
</span><del>-                    texture-&gt;subImage(target, level, xoffset, yoffset, width, height, format, type, context-&gt;getUnpackAlignment(), pixels);
</del><ins>+                    gl::TextureCubeMap *texture = context-&gt;getTextureCubeMap();
+                    texture-&gt;subImage(target, level, xoffset, yoffset, width, height, format, type, context-&gt;getUnpackState(), pixels);
</ins><span class="cx">                 }
</span><del>-            }
-            else
-            {
</del><ins>+                break;
+
+              default:
</ins><span class="cx">                 UNREACHABLE();
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -6071,7 +5306,7 @@
</span><span class="cx"> {
</span><span class="cx">     GLfloat xy[2] = {x, y};
</span><span class="cx"> 
</span><del>-    glUniform2fv(location, 1, (GLfloat*)&amp;xy);
</del><ins>+    glUniform2fv(location, 1, xy);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
</span><span class="lines">@@ -6114,9 +5349,9 @@
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniform2i(GLint location, GLint x, GLint y)
</span><span class="cx"> {
</span><del>-    GLint xy[4] = {x, y};
</del><ins>+    GLint xy[2] = {x, y};
</ins><span class="cx"> 
</span><del>-    glUniform2iv(location, 1, (GLint*)&amp;xy);
</del><ins>+    glUniform2iv(location, 1, xy);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
</span><span class="lines">@@ -6161,7 +5396,7 @@
</span><span class="cx"> {
</span><span class="cx">     GLfloat xyz[3] = {x, y, z};
</span><span class="cx"> 
</span><del>-    glUniform3fv(location, 1, (GLfloat*)&amp;xyz);
</del><ins>+    glUniform3fv(location, 1, xyz);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
</span><span class="lines">@@ -6206,7 +5441,7 @@
</span><span class="cx"> {
</span><span class="cx">     GLint xyz[3] = {x, y, z};
</span><span class="cx"> 
</span><del>-    glUniform3iv(location, 1, (GLint*)&amp;xyz);
</del><ins>+    glUniform3iv(location, 1, xyz);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
</span><span class="lines">@@ -6251,7 +5486,7 @@
</span><span class="cx"> {
</span><span class="cx">     GLfloat xyzw[4] = {x, y, z, w};
</span><span class="cx"> 
</span><del>-    glUniform4fv(location, 1, (GLfloat*)&amp;xyzw);
</del><ins>+    glUniform4fv(location, 1, xyzw);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
</span><span class="lines">@@ -6296,7 +5531,7 @@
</span><span class="cx"> {
</span><span class="cx">     GLint xyzw[4] = {x, y, z, w};
</span><span class="cx"> 
</span><del>-    glUniform4iv(location, 1, (GLint*)&amp;xyzw);
</del><ins>+    glUniform4iv(location, 1, xyzw);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
</span><span class="lines">@@ -6339,12 +5574,12 @@
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
</span><span class="cx"> {
</span><del>-    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)&quot;,
</del><ins>+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)&quot;,
</ins><span class="cx">           location, count, transpose, value);
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (count &lt; 0 || transpose != GL_FALSE)
</del><ins>+        if (count &lt; 0)
</ins><span class="cx">         {
</span><span class="cx">             return gl::error(GL_INVALID_VALUE);
</span><span class="cx">         }
</span><span class="lines">@@ -6358,13 +5593,18 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><ins>+            if (transpose != GL_FALSE &amp;&amp; context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
</ins><span class="cx">             gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
</span><span class="cx">             if (!programBinary)
</span><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (!programBinary-&gt;setUniformMatrix2fv(location, count, value))
</del><ins>+            if (!programBinary-&gt;setUniformMatrix2fv(location, count, transpose, value))
</ins><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="lines">@@ -6378,12 +5618,12 @@
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
</span><span class="cx"> {
</span><del>-    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)&quot;,
</del><ins>+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)&quot;,
</ins><span class="cx">           location, count, transpose, value);
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (count &lt; 0 || transpose != GL_FALSE)
</del><ins>+        if (count &lt; 0)
</ins><span class="cx">         {
</span><span class="cx">             return gl::error(GL_INVALID_VALUE);
</span><span class="cx">         }
</span><span class="lines">@@ -6397,13 +5637,18 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><ins>+            if (transpose != GL_FALSE &amp;&amp; context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
</ins><span class="cx">             gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
</span><span class="cx">             if (!programBinary)
</span><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (!programBinary-&gt;setUniformMatrix3fv(location, count, value))
</del><ins>+            if (!programBinary-&gt;setUniformMatrix3fv(location, count, transpose, value))
</ins><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="lines">@@ -6417,12 +5662,12 @@
</span><span class="cx"> 
</span><span class="cx"> void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
</span><span class="cx"> {
</span><del>-    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)&quot;,
</del><ins>+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)&quot;,
</ins><span class="cx">           location, count, transpose, value);
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        if (count &lt; 0 || transpose != GL_FALSE)
</del><ins>+        if (count &lt; 0)
</ins><span class="cx">         {
</span><span class="cx">             return gl::error(GL_INVALID_VALUE);
</span><span class="cx">         }
</span><span class="lines">@@ -6436,13 +5681,18 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><ins>+            if (transpose != GL_FALSE &amp;&amp; context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
</ins><span class="cx">             gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
</span><span class="cx">             if (!programBinary)
</span><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (!programBinary-&gt;setUniformMatrix4fv(location, count, value))
</del><ins>+            if (!programBinary-&gt;setUniformMatrix4fv(location, count, transpose, value))
</ins><span class="cx">             {
</span><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="lines">@@ -6541,7 +5791,7 @@
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             GLfloat vals[4] = { x, 0, 0, 1 };
</span><del>-            context-&gt;setVertexAttrib(index, vals);
</del><ins>+            context-&gt;setVertexAttribf(index, vals);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6566,7 +5816,7 @@
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             GLfloat vals[4] = { values[0], 0, 0, 1 };
</span><del>-            context-&gt;setVertexAttrib(index, vals);
</del><ins>+            context-&gt;setVertexAttribf(index, vals);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6591,7 +5841,7 @@
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             GLfloat vals[4] = { x, y, 0, 1 };
</span><del>-            context-&gt;setVertexAttrib(index, vals);
</del><ins>+            context-&gt;setVertexAttribf(index, vals);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6616,7 +5866,7 @@
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             GLfloat vals[4] = { values[0], values[1], 0, 1 };
</span><del>-            context-&gt;setVertexAttrib(index, vals);
</del><ins>+            context-&gt;setVertexAttribf(index, vals);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6641,7 +5891,7 @@
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             GLfloat vals[4] = { x, y, z, 1 };
</span><del>-            context-&gt;setVertexAttrib(index, vals);
</del><ins>+            context-&gt;setVertexAttribf(index, vals);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6666,7 +5916,7 @@
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             GLfloat vals[4] = { values[0], values[1], values[2], 1 };
</span><del>-            context-&gt;setVertexAttrib(index, vals);
</del><ins>+            context-&gt;setVertexAttribf(index, vals);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6691,7 +5941,7 @@
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             GLfloat vals[4] = { x, y, z, w };
</span><del>-            context-&gt;setVertexAttrib(index, vals);
</del><ins>+            context-&gt;setVertexAttribf(index, vals);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6715,7 +5965,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            context-&gt;setVertexAttrib(index, values);
</del><ins>+            context-&gt;setVertexAttribf(index, values);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6751,7 +6001,7 @@
</span><span class="cx"> void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
</span><span class="cx"> {
</span><span class="cx">     EVENT(&quot;(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, &quot;
</span><del>-          &quot;GLboolean normalized = %d, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)&quot;,
</del><ins>+          &quot;GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)&quot;,
</ins><span class="cx">           index, size, type, normalized, stride, ptr);
</span><span class="cx"> 
</span><span class="cx">     try
</span><span class="lines">@@ -6766,6 +6016,8 @@
</span><span class="cx">             return gl::error(GL_INVALID_VALUE);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        gl::Context *context = gl::getNonLostContext();
+
</ins><span class="cx">         switch (type)
</span><span class="cx">         {
</span><span class="cx">           case GL_BYTE:
</span><span class="lines">@@ -6775,6 +6027,19 @@
</span><span class="cx">           case GL_FIXED:
</span><span class="cx">           case GL_FLOAT:
</span><span class="cx">             break;
</span><ins>+          case GL_HALF_FLOAT:
+          case GL_INT:
+          case GL_UNSIGNED_INT:
+          case GL_INT_2_10_10_10_REV:
+          case GL_UNSIGNED_INT_2_10_10_10_REV:
+            if (context &amp;&amp; context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+            else
+            {
+                break;
+            }
</ins><span class="cx">           default:
</span><span class="cx">             return gl::error(GL_INVALID_ENUM);
</span><span class="cx">         }
</span><span class="lines">@@ -6784,11 +6049,24 @@
</span><span class="cx">             return gl::error(GL_INVALID_VALUE);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        gl::Context *context = gl::getNonLostContext();
</del><ins>+        if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) &amp;&amp; size != 4)
+        {
+            return gl::error(GL_INVALID_OPERATION);
+        }
</ins><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            context-&gt;setVertexAttribState(index, context-&gt;getArrayBuffer(), size, type, (normalized == GL_TRUE), stride, ptr);
</del><ins>+            // [OpenGL ES 3.0.2] Section 2.8 page 24:
+            // An INVALID_OPERATION error is generated when a non-zero vertex array object
+            // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
+            // and the pointer argument is not NULL.
+            if (context-&gt;getVertexArrayHandle() != 0 &amp;&amp; context-&gt;getArrayBufferHandle() == 0 &amp;&amp; ptr != NULL)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            context-&gt;setVertexAttribState(index, context-&gt;getArrayBuffer(), size, type,
+                                          normalized == GL_TRUE, false, stride, ptr);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6821,46 +6099,1720 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
-                                      GLbitfield mask, GLenum filter)
</del><ins>+// OpenGL ES 3.0 functions
+
+void __stdcall glReadBuffer(GLenum mode)
</ins><span class="cx"> {
</span><del>-    EVENT(&quot;(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, &quot;
-          &quot;GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, &quot;
-          &quot;GLbitfield mask = 0x%X, GLenum filter = 0x%X)&quot;,
-          srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
</del><ins>+    EVENT(&quot;(GLenum mode = 0x%X)&quot;, mode);
</ins><span class="cx"> 
</span><span class="cx">     try
</span><span class="cx">     {
</span><del>-        switch (filter)
</del><ins>+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
</ins><span class="cx">         {
</span><del>-          case GL_NEAREST:
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // glReadBuffer
+            UNIMPLEMENTED();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
+{
+    EVENT(&quot;(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, &quot;
+          &quot;const GLvoid* indices = 0x%0.8p)&quot;, mode, start, end, count, type, indices);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // glDrawRangeElements
+            UNIMPLEMENTED();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, &quot;
+          &quot;GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, &quot;
+          &quot;GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)&quot;,
+          target, level, internalformat, width, height, depth, border, format, type, pixels);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // validateES3TexImageFormat sets the error code if there is an error
+            if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
+                                               0, 0, 0, width, height, depth, border, format, type, pixels))
+            {
+                return;
+            }
+
+            switch(target)
+            {
+              case GL_TEXTURE_3D:
+                {
+                    gl::Texture3D *texture = context-&gt;getTexture3D();
+                    texture-&gt;setImage(level, width, height, depth, internalformat, format, type, context-&gt;getUnpackState(), pixels);
+                }
+                break;
+
+              case GL_TEXTURE_2D_ARRAY:
+                {
+                    gl::Texture2DArray *texture = context-&gt;getTexture2DArray();
+                    texture-&gt;setImage(level, width, height, depth, internalformat, format, type, context-&gt;getUnpackState(), pixels);
+                }
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, &quot;
+          &quot;GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, &quot;
+          &quot;GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)&quot;,
+          target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // validateES3TexImageFormat sets the error code if there is an error
+            if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
+                                               xoffset, yoffset, zoffset, width, height, depth, 0,
+                                               format, type, pixels))
+            {
+                return;
+            }
+
+            // Zero sized uploads are valid but no-ops
+            if (width == 0 || height == 0 || depth == 0)
+            {
+                return;
+            }
+
+            switch(target)
+            {
+              case GL_TEXTURE_3D:
+                {
+                    gl::Texture3D *texture = context-&gt;getTexture3D();
+                    texture-&gt;subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context-&gt;getUnpackState(), pixels);
+                }
+                break;
+
+              case GL_TEXTURE_2D_ARRAY:
+                {
+                    gl::Texture2DArray *texture = context-&gt;getTexture2DArray();
+                    texture-&gt;subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context-&gt;getUnpackState(), pixels);
+                }
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, &quot;
+          &quot;GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)&quot;,
+          target, level, xoffset, yoffset, zoffset, x, y, width, height);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset,
+                                                   x, y, width, height, 0))
+            {
+                return;
+            }
+
+            // Zero sized copies are valid but no-ops
+            if (width == 0 || height == 0)
+            {
+                return;
+            }
+
+            gl::Framebuffer *framebuffer = context-&gt;getReadFramebuffer();
+            gl::Texture *texture = NULL;
+            switch (target)
+            {
+              case GL_TEXTURE_3D:
+                texture = context-&gt;getTexture3D();
+                break;
+
+              case GL_TEXTURE_2D_ARRAY:
+                texture = context-&gt;getTexture2DArray();
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            texture-&gt;copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, &quot;
+          &quot;GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, &quot;
+          &quot;const GLvoid* data = 0x%0.8p)&quot;,
+          target, level, internalformat, width, height, depth, border, imageSize, data);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (imageSize &lt; 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context-&gt;getClientVersion(), width, height))
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            // validateES3TexImageFormat sets the error code if there is an error
+            if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
+                                               0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
+            {
+                return;
+            }
+
+            switch(target)
+            {
+              case GL_TEXTURE_3D:
+                {
+                    gl::Texture3D *texture = context-&gt;getTexture3D();
+                    texture-&gt;setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
+                }
+                break;
+
+              case GL_TEXTURE_2D_ARRAY:
+                {
+                    gl::Texture2DArray *texture = context-&gt;getTexture2DArray();
+                    texture-&gt;setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
+                }
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, &quot;
+        &quot;GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, &quot;
+        &quot;GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)&quot;,
+        target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (imageSize &lt; 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context-&gt;getClientVersion(), width, height))
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            if (!data)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            // validateES3TexImageFormat sets the error code if there is an error
+            if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
+                                               0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
+            {
+                return;
+            }
+
+            // Zero sized uploads are valid but no-ops
+            if (width == 0 || height == 0)
+            {
+                return;
+            }
+
+            switch(target)
+            {
+              case GL_TEXTURE_3D:
+                {
+                    gl::Texture3D *texture = context-&gt;getTexture3D();
+                    texture-&gt;subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
+                                                format, imageSize, data);
+                }
+                break;
+
+              case GL_TEXTURE_2D_ARRAY:
+                {
+                    gl::Texture2DArray *texture = context-&gt;getTexture2DArray();
+                    texture-&gt;subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
+                                                format, imageSize, data);
+                }
+                break;
+
+            default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGenQueries(GLsizei n, GLuint* ids)
+{
+    EVENT(&quot;(GLsizei n = %d, GLuint* ids = 0x%0.8p)&quot;, n, ids);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (n &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            for (GLsizei i = 0; i &lt; n; i++)
+            {
+                ids[i] = context-&gt;createQuery();
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids)
+{
+    EVENT(&quot;(GLsizei n = %d, GLuint* ids = 0x%0.8p)&quot;, n, ids);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (n &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            for (GLsizei i = 0; i &lt; n; i++)
+            {
+                context-&gt;deleteQuery(ids[i]);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLboolean __stdcall glIsQuery(GLuint id)
+{
+    EVENT(&quot;(GLuint id = %u)&quot;, id);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_FALSE);
+            }
+
+            return (context-&gt;getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
+    }
+
+    return GL_FALSE;
+}
+
+void __stdcall glBeginQuery(GLenum target, GLuint id)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLuint id = %u)&quot;, target, id);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidQueryType(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            if (id == 0)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            context-&gt;beginQuery(target, id);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glEndQuery(GLenum target)
+{
+    EVENT(&quot;(GLenum target = 0x%X)&quot;, target);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidQueryType(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            context-&gt;endQuery(target);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)&quot;, target, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidQueryType(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            switch (pname)
+            {
+              case GL_CURRENT_QUERY:
+                params[0] = context-&gt;getActiveQuery(target);
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
+{
+    EVENT(&quot;(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)&quot;, id, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::Query *queryObject = context-&gt;getQuery(id, false, GL_NONE);
+
+            if (!queryObject)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (context-&gt;getActiveQuery(queryObject-&gt;getType()) == id)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch(pname)
+            {
+              case GL_QUERY_RESULT:
+                params[0] = queryObject-&gt;getResult();
+                break;
+              case GL_QUERY_RESULT_AVAILABLE:
+                params[0] = queryObject-&gt;isResultAvailable();
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLboolean __stdcall glUnmapBuffer(GLenum target)
+{
+    EVENT(&quot;(GLenum target = 0x%X)&quot;, target);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_FALSE);
+            }
+
+            return glUnmapBufferOES(target);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
+    }
+
+    return GL_FALSE;
+}
+
+void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)&quot;, target, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            glGetBufferPointervOES(target, pname, params);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs)
+{
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            glDrawBuffersEXT(n, bufs);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)&quot;,
+          location, count, transpose, value);
+
+    try
+    {
+        if (count &lt; 0)
+        {
+            return gl::error(GL_INVALID_VALUE);
+        }
+
+        if (location == -1)
+        {
+            return;
+        }
+
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniformMatrix2x3fv(location, count, transpose, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)&quot;,
+          location, count, transpose, value);
+
+    try
+    {
+        if (count &lt; 0)
+        {
+            return gl::error(GL_INVALID_VALUE);
+        }
+
+        if (location == -1)
+        {
+            return;
+        }
+
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniformMatrix3x2fv(location, count, transpose, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)&quot;,
+          location, count, transpose, value);
+
+    try
+    {
+        if (count &lt; 0)
+        {
+            return gl::error(GL_INVALID_VALUE);
+        }
+
+        if (location == -1)
+        {
+            return;
+        }
+
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniformMatrix2x4fv(location, count, transpose, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)&quot;,
+          location, count, transpose, value);
+
+    try
+    {
+        if (count &lt; 0)
+        {
+            return gl::error(GL_INVALID_VALUE);
+        }
+
+        if (location == -1)
+        {
+            return;
+        }
+
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniformMatrix4x2fv(location, count, transpose, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)&quot;,
+          location, count, transpose, value);
+
+    try
+    {
+        if (count &lt; 0)
+        {
+            return gl::error(GL_INVALID_VALUE);
+        }
+
+        if (location == -1)
+        {
+            return;
+        }
+
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniformMatrix3x4fv(location, count, transpose, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)&quot;,
+          location, count, transpose, value);
+
+    try
+    {
+        if (count &lt; 0)
+        {
+            return gl::error(GL_INVALID_VALUE);
+        }
+
+        if (location == -1)
+        {
+            return;
+        }
+
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniformMatrix4x3fv(location, count, transpose, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
+{
+    EVENT(&quot;(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, &quot;
+          &quot;GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)&quot;,
+          srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
+                                                   dstX0, dstY0, dstX1, dstY1, mask, filter,
+                                                   false))
+            {
+                return;
+            }
+
+            context-&gt;blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
+                                     mask, filter);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)&quot;,
+        target, samples, internalformat, width, height);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
+                                                       width, height, false))
+            {
+                return;
+            }
+
+            context-&gt;setRenderbufferStorage(width, height, internalformat, samples);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)&quot;,
+        target, attachment, texture, level, layer);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidateES3FramebufferTextureParameters(context, target, attachment, GL_NONE, texture, level, layer, true))
+            {
+                return;
+            }
+
+            gl::Framebuffer *framebuffer = context-&gt;getTargetFramebuffer(target);
+            ASSERT(framebuffer);
+
+            gl::Texture *textureObject = context-&gt;getTexture(texture);
+            GLenum textarget = textureObject ? textureObject-&gt;getTarget() : GL_NONE;
+
+            if (attachment &gt;= GL_COLOR_ATTACHMENT0_EXT &amp;&amp; attachment &lt;= GL_COLOR_ATTACHMENT15_EXT)
+            {
+                const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
+                framebuffer-&gt;setColorbuffer(colorAttachment, textarget, texture, level, layer);
+            }
+            else
+            {
+                switch (attachment)
+                {
+                case GL_DEPTH_ATTACHMENT:         framebuffer-&gt;setDepthbuffer(textarget, texture, level, layer);        break;
+                case GL_STENCIL_ATTACHMENT:       framebuffer-&gt;setStencilbuffer(textarget, texture, level, layer);      break;
+                case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer-&gt;setDepthStencilBuffer(textarget, texture, level, layer); break;
+                }
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)&quot;,
+          target, offset, length, access);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            return glMapBufferRangeEXT(target, offset, length, access);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+    }
+
+    return NULL;
+}
+
+void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)&quot;, target, offset, length);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            glFlushMappedBufferRangeEXT(target, offset, length);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glBindVertexArray(GLuint array)
+{
+    EVENT(&quot;(GLuint array = %u)&quot;, array);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::VertexArray *vao = context-&gt;getVertexArray(array);
+
+            if (!vao)
+            {
+                // The default VAO should always exist
+                ASSERT(array != 0);
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            context-&gt;bindVertexArray(array);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
+{
+    EVENT(&quot;(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)&quot;, n, arrays);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (n &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            for (int arrayIndex = 0; arrayIndex &lt; n; arrayIndex++)
+            {
+                if (arrays[arrayIndex] != 0)
+                {
+                    context-&gt;deleteVertexArray(arrays[arrayIndex]);
+                }
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays)
+{
+    EVENT(&quot;(GLsizei n = %d, GLuint* arrays = 0x%0.8p)&quot;, n, arrays);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (n &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            for (int arrayIndex = 0; arrayIndex &lt; n; arrayIndex++)
+            {
+                arrays[arrayIndex] = context-&gt;createVertexArray();
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLboolean __stdcall glIsVertexArray(GLuint array)
+{
+    EVENT(&quot;(GLuint array = %u)&quot;, array);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_FALSE);
+            }
+
+            if (array == 0)
+            {
+                return GL_FALSE;
+            }
+
+            gl::VertexArray *vao = context-&gt;getVertexArray(array);
+
+            return (vao != NULL ? GL_TRUE : GL_FALSE);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
+    }
+
+    return GL_FALSE;
+}
+
+void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)&quot;,
+          target, index, data);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (target)
+            {
+              case GL_TRANSFORM_FEEDBACK_BUFFER_START:
+              case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
+              case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+                if (index &gt;= context-&gt;getMaxTransformFeedbackBufferBindings())
+                    return gl::error(GL_INVALID_VALUE);
+                break;
+              case GL_UNIFORM_BUFFER_START:
+              case GL_UNIFORM_BUFFER_SIZE:
+              case GL_UNIFORM_BUFFER_BINDING:
+                if (index &gt;= context-&gt;getMaximumCombinedUniformBufferBindings())
+                    return gl::error(GL_INVALID_VALUE);
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            if (!(context-&gt;getIndexedIntegerv(target, index, data)))
+            {
+                GLenum nativeType;
+                unsigned int numParams = 0;
+                if (!context-&gt;getIndexedQueryParameterInfo(target, &amp;nativeType, &amp;numParams))
+                    return gl::error(GL_INVALID_ENUM);
+
+                if (numParams == 0)
+                    return; // it is known that pname is valid, but there are no parameters to return
+
+                if (nativeType == GL_INT_64_ANGLEX)
+                {
+                    GLint64 minIntValue = static_cast&lt;GLint64&gt;(std::numeric_limits&lt;int&gt;::min());
+                    GLint64 maxIntValue = static_cast&lt;GLint64&gt;(std::numeric_limits&lt;int&gt;::max());
+                    GLint64 *int64Params = new GLint64[numParams];
+
+                    context-&gt;getIndexedInteger64v(target, index, int64Params);
+
+                    for (unsigned int i = 0; i &lt; numParams; ++i)
+                    {
+                        GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
+                        data[i] = static_cast&lt;GLint&gt;(clampedValue);
+                    }
+
+                    delete [] int64Params;
+                }
+                else
+                {
+                    UNREACHABLE();
+                }
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glBeginTransformFeedback(GLenum primitiveMode)
+{
+    EVENT(&quot;(GLenum primitiveMode = 0x%X)&quot;, primitiveMode);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (primitiveMode)
+            {
+              case GL_TRIANGLES:
+              case GL_LINES:
+              case GL_POINTS:
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            gl::TransformFeedback *transformFeedback = context-&gt;getCurrentTransformFeedback();
+            ASSERT(transformFeedback != NULL);
+
+            if (transformFeedback-&gt;isStarted())
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (transformFeedback-&gt;isPaused())
+            {
+                transformFeedback-&gt;resume();
+            }
+            else
+            {
+                transformFeedback-&gt;start(primitiveMode);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glEndTransformFeedback(void)
+{
+    EVENT(&quot;(void)&quot;);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::TransformFeedback *transformFeedback = context-&gt;getCurrentTransformFeedback();
+            ASSERT(transformFeedback != NULL);
+
+            if (!transformFeedback-&gt;isStarted())
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            transformFeedback-&gt;stop();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)&quot;,
+          target, index, buffer, offset, size);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (target)
+            {
+              case GL_TRANSFORM_FEEDBACK_BUFFER:
+                if (index &gt;= context-&gt;getMaxTransformFeedbackBufferBindings())
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+
+              case GL_UNIFORM_BUFFER:
+                if (index &gt;= context-&gt;getMaximumCombinedUniformBufferBindings())
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            if (buffer != 0 &amp;&amp; size &lt;= 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            switch (target)
+            {
+              case GL_TRANSFORM_FEEDBACK_BUFFER:
+
+                // size and offset must be a multiple of 4
+                if (buffer != 0 &amp;&amp; ((offset % 4) != 0 || (size % 4) != 0))
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+
+                context-&gt;bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
+                context-&gt;bindGenericTransformFeedbackBuffer(buffer);
+                break;
+
+              case GL_UNIFORM_BUFFER:
+
+                // it is an error to bind an offset not a multiple of the alignment
+                if (buffer != 0 &amp;&amp; (offset % context-&gt;getUniformBufferOffsetAlignment()) != 0)
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+
+                context-&gt;bindIndexedUniformBuffer(buffer, index, offset, size);
+                context-&gt;bindGenericUniformBuffer(buffer);
+                break;
+
+              default:
+                UNREACHABLE();
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)&quot;,
+          target, index, buffer);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (target)
+            {
+              case GL_TRANSFORM_FEEDBACK_BUFFER:
+                if (index &gt;= context-&gt;getMaxTransformFeedbackBufferBindings())
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+
+              case GL_UNIFORM_BUFFER:
+                if (index &gt;= context-&gt;getMaximumCombinedUniformBufferBindings())
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            switch (target)
+            {
+              case GL_TRANSFORM_FEEDBACK_BUFFER:
+                context-&gt;bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
+                context-&gt;bindGenericTransformFeedbackBuffer(buffer);
+                break;
+
+              case GL_UNIFORM_BUFFER:
+                context-&gt;bindIndexedUniformBuffer(buffer, index, 0, 0);
+                context-&gt;bindGenericUniformBuffer(buffer);
+                break;
+
+              default:
+                UNREACHABLE();
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
+{
+    EVENT(&quot;(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)&quot;,
+          program, count, varyings, bufferMode);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (count &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            switch (bufferMode)
+            {
+              case GL_INTERLEAVED_ATTRIBS:
+                break;
+              case GL_SEPARATE_ATTRIBS:
+                if (static_cast&lt;GLuint&gt;(count) &gt; context-&gt;getMaxTransformFeedbackBufferBindings())
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            if (!gl::ValidProgram(context, program))
+            {
+                return;
+            }
+
+            gl::Program *programObject = context-&gt;getProgram(program);
+            ASSERT(programObject);
+
+            programObject-&gt;setTransformFeedbackVaryings(count, varyings, bufferMode);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
+{
+    EVENT(&quot;(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, &quot;
+          &quot;GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)&quot;,
+          program, index, bufSize, length, size, type, name);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (bufSize &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            if (!gl::ValidProgram(context, program))
+            {
+                return;
+            }
+
+            gl::Program *programObject = context-&gt;getProgram(program);
+            ASSERT(programObject);
+
+            if (index &gt;= static_cast&lt;GLuint&gt;(programObject-&gt;getTransformFeedbackVaryingCount()))
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            programObject-&gt;getTransformFeedbackVarying(index, bufSize, length, size, type, name);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+    EVENT(&quot;(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)&quot;,
+          index, size, type, stride, pointer);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+
+        if (index &gt;= gl::MAX_VERTEX_ATTRIBS)
+        {
+            return gl::error(GL_INVALID_VALUE);
+        }
+
+        if (size &lt; 1 || size &gt; 4)
+        {
+            return gl::error(GL_INVALID_VALUE);
+        }
+
+        switch (type)
+        {
+          case GL_BYTE:
+          case GL_UNSIGNED_BYTE:
+          case GL_SHORT:
+          case GL_UNSIGNED_SHORT:
+          case GL_INT:
+          case GL_UNSIGNED_INT:
+          case GL_INT_2_10_10_10_REV:
+          case GL_UNSIGNED_INT_2_10_10_10_REV:
</ins><span class="cx">             break;
</span><span class="cx">           default:
</span><span class="cx">             return gl::error(GL_INVALID_ENUM);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ((mask &amp; ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
</del><ins>+        if (stride &lt; 0)
</ins><span class="cx">         {
</span><span class="cx">             return gl::error(GL_INVALID_VALUE);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
</del><ins>+        if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) &amp;&amp; size != 4)
</ins><span class="cx">         {
</span><del>-            ERR(&quot;Scaling and flipping in BlitFramebufferANGLE not supported by this implementation&quot;);
</del><span class="cx">             return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if (context)
+        {
+            // [OpenGL ES 3.0.2] Section 2.8 page 24:
+            // An INVALID_OPERATION error is generated when a non-zero vertex array object
+            // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
+            // and the pointer argument is not NULL.
+            if (context-&gt;getVertexArrayHandle() != 0 &amp;&amp; context-&gt;getArrayBufferHandle() == 0 &amp;&amp; pointer != NULL)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            context-&gt;setVertexAttribState(index, context-&gt;getArrayBuffer(), size, type, false, true,
+                                          stride, pointer);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
+{
+    EVENT(&quot;(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)&quot;,
+          index, pname, params);
+
+    try
+    {
</ins><span class="cx">         gl::Context *context = gl::getNonLostContext();
</span><span class="cx"> 
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><del>-            if (context-&gt;getReadFramebufferHandle() == context-&gt;getDrawFramebufferHandle())
</del><ins>+            if (context-&gt;getClientVersion() &lt; 3)
</ins><span class="cx">             {
</span><del>-                ERR(&quot;Blits with the same source and destination framebuffer are not supported by this implementation.&quot;);
</del><span class="cx">                 return gl::error(GL_INVALID_OPERATION);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            context-&gt;blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
</del><ins>+            if (index &gt;= gl::MAX_VERTEX_ATTRIBS)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            const gl::VertexAttribute &amp;attribState = context-&gt;getVertexAttribState(index);
+
+            if (!gl::ValidateGetVertexAttribParameters(pname, context-&gt;getClientVersion()))
+            {
+                return;
+            }
+
+            if (pname == GL_CURRENT_VERTEX_ATTRIB)
+            {
+                const gl::VertexAttribCurrentValueData &amp;currentValueData = context-&gt;getVertexAttribCurrentValue(index);
+                for (int i = 0; i &lt; 4; ++i)
+                {
+                    params[i] = currentValueData.IntValues[i];
+                }
+            }
+            else
+            {
+                *params = attribState.querySingleParameter&lt;GLint&gt;(pname);
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span><span class="lines">@@ -6869,6 +7821,2296 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
+{
+    EVENT(&quot;(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)&quot;,
+          index, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (index &gt;= gl::MAX_VERTEX_ATTRIBS)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            const gl::VertexAttribute &amp;attribState = context-&gt;getVertexAttribState(index);
+
+            if (!gl::ValidateGetVertexAttribParameters(pname, context-&gt;getClientVersion()))
+            {
+                return;
+            }
+
+            if (pname == GL_CURRENT_VERTEX_ATTRIB)
+            {
+                const gl::VertexAttribCurrentValueData &amp;currentValueData = context-&gt;getVertexAttribCurrentValue(index);
+                for (int i = 0; i &lt; 4; ++i)
+                {
+                    params[i] = currentValueData.UnsignedIntValues[i];
+                }
+            }
+            else
+            {
+                *params = attribState.querySingleParameter&lt;GLuint&gt;(pname);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
+{
+    EVENT(&quot;(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)&quot;,
+          index, x, y, z, w);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (index &gt;= gl::MAX_VERTEX_ATTRIBS)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            GLint vals[4] = { x, y, z, w };
+            context-&gt;setVertexAttribi(index, vals);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
+{
+    EVENT(&quot;(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)&quot;,
+          index, x, y, z, w);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (index &gt;= gl::MAX_VERTEX_ATTRIBS)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            GLuint vals[4] = { x, y, z, w };
+            context-&gt;setVertexAttribu(index, vals);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
+{
+    EVENT(&quot;(GLuint index = %u, const GLint* v = 0x%0.8p)&quot;, index, v);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (index &gt;= gl::MAX_VERTEX_ATTRIBS)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            context-&gt;setVertexAttribi(index, v);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v)
+{
+    EVENT(&quot;(GLuint index = %u, const GLuint* v = 0x%0.8p)&quot;, index, v);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (index &gt;= gl::MAX_VERTEX_ATTRIBS)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            context-&gt;setVertexAttribu(index, v);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
+{
+    EVENT(&quot;(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)&quot;,
+          program, location, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (program == 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            gl::Program *programObject = context-&gt;getProgram(program);
+
+            if (!programObject || !programObject-&gt;isLinked())
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = programObject-&gt;getProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;getUniformuiv(location, NULL, params))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
+{
+    EVENT(&quot;(GLuint program = %u, const GLchar *name = 0x%0.8p)&quot;,
+          program, name);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, -1);
+            }
+
+            if (program == 0)
+            {
+                return gl::error(GL_INVALID_VALUE, -1);
+            }
+
+            gl::Program *programObject = context-&gt;getProgram(program);
+
+            if (!programObject || !programObject-&gt;isLinked())
+            {
+                return gl::error(GL_INVALID_OPERATION, -1);
+            }
+
+            gl::ProgramBinary *programBinary = programObject-&gt;getProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION, -1);
+            }
+
+            return programBinary-&gt;getFragDataLocation(name);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, 0);
+    }
+
+    return 0;
+}
+
+void __stdcall glUniform1ui(GLint location, GLuint v0)
+{
+    glUniform1uiv(location, 1, &amp;v0);
+}
+
+void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1)
+{
+    const GLuint xy[] = { v0, v1 };
+    glUniform2uiv(location, 1, xy);
+}
+
+void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
+{
+    const GLuint xyz[] = { v0, v1, v2 };
+    glUniform3uiv(location, 1, xyz);
+}
+
+void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
+{
+    const GLuint xyzw[] = { v0, v1, v2, v3 };
+    glUniform4uiv(location, 1, xyzw);
+}
+
+void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)&quot;,
+          location, count, value);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniform1uiv(location, count, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)&quot;,
+          location, count, value);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniform2uiv(location, count, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, const GLuint* value)&quot;,
+          location, count, value);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniform3uiv(location, count, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
+{
+    EVENT(&quot;(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)&quot;,
+          location, count, value);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::ProgramBinary *programBinary = context-&gt;getCurrentProgramBinary();
+            if (!programBinary)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!programBinary-&gt;setUniform4uiv(location, count, value))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
+{
+    EVENT(&quot;(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)&quot;,
+          buffer, drawbuffer, value);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (buffer)
+            {
+              case GL_COLOR:
+                if (drawbuffer &lt; 0 || drawbuffer &gt;= static_cast&lt;GLint&gt;(context-&gt;getMaximumRenderTargets()))
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+              case GL_STENCIL:
+                if (drawbuffer != 0)
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            context-&gt;clearBufferiv(buffer, drawbuffer, value);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
+{
+    EVENT(&quot;(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)&quot;,
+          buffer, drawbuffer, value);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (buffer)
+            {
+              case GL_COLOR:
+                if (drawbuffer &lt; 0 || drawbuffer &gt;= static_cast&lt;GLint&gt;(context-&gt;getMaximumRenderTargets()))
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            context-&gt;clearBufferuiv(buffer, drawbuffer, value);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
+{
+    EVENT(&quot;(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)&quot;,
+          buffer, drawbuffer, value);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (buffer)
+            {
+              case GL_COLOR:
+                if (drawbuffer &lt; 0 || drawbuffer &gt;= static_cast&lt;GLint&gt;(context-&gt;getMaximumRenderTargets()))
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+              case GL_DEPTH:
+                if (drawbuffer != 0)
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            context-&gt;clearBufferfv(buffer, drawbuffer, value);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
+{
+    EVENT(&quot;(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)&quot;,
+          buffer, drawbuffer, depth, stencil);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (buffer)
+            {
+              case GL_DEPTH_STENCIL:
+                if (drawbuffer != 0)
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            context-&gt;clearBufferfi(buffer, drawbuffer, depth, stencil);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index)
+{
+    EVENT(&quot;(GLenum name = 0x%X, GLuint index = %u)&quot;, name, index);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLubyte*&gt;(NULL));
+            }
+
+            if (name != GL_EXTENSIONS)
+            {
+                return gl::error(GL_INVALID_ENUM, reinterpret_cast&lt;GLubyte*&gt;(NULL));
+            }
+
+            if (index &gt;= context-&gt;getNumExtensions())
+            {
+                return gl::error(GL_INVALID_VALUE, reinterpret_cast&lt;GLubyte*&gt;(NULL));
+            }
+            
+            return reinterpret_cast&lt;const GLubyte*&gt;(context-&gt;getExtensionString(index));
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast&lt;GLubyte*&gt;(NULL));
+    }
+
+    return NULL;
+}
+
+void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
+{
+    EVENT(&quot;(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)&quot;,
+          readTarget, writeTarget, readOffset, writeOffset, size);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, readTarget))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            gl::Buffer *readBuffer = context-&gt;getTargetBuffer(readTarget);
+            gl::Buffer *writeBuffer = context-&gt;getTargetBuffer(writeTarget);
+
+            if (!readBuffer || !writeBuffer)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (readBuffer-&gt;mapped() || writeBuffer-&gt;mapped())
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (readOffset &lt; 0 || writeOffset &lt; 0 || size &lt; 0 ||
+                static_cast&lt;unsigned int&gt;(readOffset + size) &gt; readBuffer-&gt;size() ||
+                static_cast&lt;unsigned int&gt;(writeOffset + size) &gt; writeBuffer-&gt;size())
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            if (readBuffer == writeBuffer &amp;&amp; abs(readOffset - writeOffset) &lt; size)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION)
+
+            // if size is zero, the copy is a successful no-op
+            if (size &gt; 0)
+            {
+                writeBuffer-&gt;copyBufferSubData(readBuffer, readOffset, writeOffset, size);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
+{
+    EVENT(&quot;(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)&quot;,
+          program, uniformCount, uniformNames, uniformIndices);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (uniformCount &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            gl::Program *programObject = context-&gt;getProgram(program);
+
+            if (!programObject)
+            {
+                if (context-&gt;getShader(program))
+                {
+                    return gl::error(GL_INVALID_OPERATION);
+                }
+                else
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+            }
+
+            gl::ProgramBinary *programBinary = programObject-&gt;getProgramBinary();
+            if (!programObject-&gt;isLinked() || !programBinary)
+            {
+                for (int uniformId = 0; uniformId &lt; uniformCount; uniformId++)
+                {
+                    uniformIndices[uniformId] = GL_INVALID_INDEX;
+                }
+            }
+            else
+            {
+                for (int uniformId = 0; uniformId &lt; uniformCount; uniformId++)
+                {
+                    uniformIndices[uniformId] = programBinary-&gt;getUniformIndex(uniformNames[uniformId]);
+                }
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
+{
+    EVENT(&quot;(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)&quot;,
+          program, uniformCount, uniformIndices, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (uniformCount &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            gl::Program *programObject = context-&gt;getProgram(program);
+
+            if (!programObject)
+            {
+                if (context-&gt;getShader(program))
+                {
+                    return gl::error(GL_INVALID_OPERATION);
+                }
+                else
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+            }
+
+            switch (pname)
+            {
+              case GL_UNIFORM_TYPE:
+              case GL_UNIFORM_SIZE:
+              case GL_UNIFORM_NAME_LENGTH:
+              case GL_UNIFORM_BLOCK_INDEX:
+              case GL_UNIFORM_OFFSET:
+              case GL_UNIFORM_ARRAY_STRIDE:
+              case GL_UNIFORM_MATRIX_STRIDE:
+              case GL_UNIFORM_IS_ROW_MAJOR:
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            gl::ProgramBinary *programBinary = programObject-&gt;getProgramBinary();
+
+            if (!programBinary &amp;&amp; uniformCount &gt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            for (int uniformId = 0; uniformId &lt; uniformCount; uniformId++)
+            {
+                const GLuint index = uniformIndices[uniformId];
+
+                if (index &gt;= (GLuint)programBinary-&gt;getActiveUniformCount())
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+            }
+
+            for (int uniformId = 0; uniformId &lt; uniformCount; uniformId++)
+            {
+                const GLuint index = uniformIndices[uniformId];
+                params[uniformId] = programBinary-&gt;getActiveUniformi(index, pname);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
+{
+    EVENT(&quot;(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)&quot;, program, uniformBlockName);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
+            }
+
+            gl::Program *programObject = context-&gt;getProgram(program);
+
+            if (!programObject)
+            {
+                if (context-&gt;getShader(program))
+                {
+                    return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
+                }
+                else
+                {
+                    return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX);
+                }
+            }
+
+            gl::ProgramBinary *programBinary = programObject-&gt;getProgramBinary();
+            if (!programBinary)
+            {
+                return GL_INVALID_INDEX;
+            }
+
+            return programBinary-&gt;getUniformBlockIndex(uniformBlockName);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, 0);
+    }
+
+    return 0;
+}
+
+void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
+{
+    EVENT(&quot;(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)&quot;,
+          program, uniformBlockIndex, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+            gl::Program *programObject = context-&gt;getProgram(program);
+
+            if (!programObject)
+            {
+                if (context-&gt;getShader(program))
+                {
+                    return gl::error(GL_INVALID_OPERATION);
+                }
+                else
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+            }
+
+            gl::ProgramBinary *programBinary = programObject-&gt;getProgramBinary();
+
+            if (!programBinary || uniformBlockIndex &gt;= programBinary-&gt;getActiveUniformBlockCount())
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            switch (pname)
+            {
+              case GL_UNIFORM_BLOCK_BINDING:
+                *params = static_cast&lt;GLint&gt;(programObject-&gt;getUniformBlockBinding(uniformBlockIndex));
+                break;
+
+              case GL_UNIFORM_BLOCK_DATA_SIZE:
+              case GL_UNIFORM_BLOCK_NAME_LENGTH:
+              case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
+              case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
+              case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
+              case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
+                programBinary-&gt;getActiveUniformBlockiv(uniformBlockIndex, pname, params);
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
+{
+    EVENT(&quot;(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)&quot;,
+          program, uniformBlockIndex, bufSize, length, uniformBlockName);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::Program *programObject = context-&gt;getProgram(program);
+
+            if (!programObject)
+            {
+                if (context-&gt;getShader(program))
+                {
+                    return gl::error(GL_INVALID_OPERATION);
+                }
+                else
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+            }
+
+            gl::ProgramBinary *programBinary = programObject-&gt;getProgramBinary();
+
+            if (!programBinary || uniformBlockIndex &gt;= programBinary-&gt;getActiveUniformBlockCount())
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            programBinary-&gt;getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
+{
+    EVENT(&quot;(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)&quot;,
+          program, uniformBlockIndex, uniformBlockBinding);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (uniformBlockBinding &gt;= context-&gt;getMaximumCombinedUniformBufferBindings())
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            gl::Program *programObject = context-&gt;getProgram(program);
+
+            if (!programObject)
+            {
+                if (context-&gt;getShader(program))
+                {
+                    return gl::error(GL_INVALID_OPERATION);
+                }
+                else
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+            }
+
+            gl::ProgramBinary *programBinary = programObject-&gt;getProgramBinary();
+
+            // if never linked, there won't be any uniform blocks
+            if (!programBinary || uniformBlockIndex &gt;= programBinary-&gt;getActiveUniformBlockCount())
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            programObject-&gt;bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
+{
+    EVENT(&quot;(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)&quot;,
+          mode, first, count, instanceCount);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // glDrawArraysInstanced
+            UNIMPLEMENTED();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
+{
+    EVENT(&quot;(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)&quot;,
+          mode, count, type, indices, instanceCount);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // glDrawElementsInstanced
+            UNIMPLEMENTED();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags)
+{
+    EVENT(&quot;(GLenum condition = 0x%X, GLbitfield flags = 0x%X)&quot;, condition, flags);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLsync&gt;(0));
+            }
+
+            if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
+            {
+                return gl::error(GL_INVALID_ENUM, reinterpret_cast&lt;GLsync&gt;(0));
+            }
+
+            if (flags != 0)
+            {
+                return gl::error(GL_INVALID_VALUE, reinterpret_cast&lt;GLsync&gt;(0));
+            }
+
+            return context-&gt;createFenceSync(condition);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast&lt;GLsync&gt;(NULL));
+    }
+
+    return NULL;
+}
+
+GLboolean __stdcall glIsSync(GLsync sync)
+{
+    EVENT(&quot;(GLsync sync = 0x%0.8p)&quot;, sync);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_FALSE);
+            }
+
+            return (context-&gt;getFenceSync(sync) != NULL);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
+    }
+
+    return GL_FALSE;
+}
+
+void __stdcall glDeleteSync(GLsync sync)
+{
+    EVENT(&quot;(GLsync sync = 0x%0.8p)&quot;, sync);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (sync != static_cast&lt;GLsync&gt;(0) &amp;&amp; !context-&gt;getFenceSync(sync))
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            context-&gt;deleteFenceSync(sync);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
+{
+    EVENT(&quot;(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)&quot;,
+          sync, flags, timeout);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_WAIT_FAILED);
+            }
+
+            if ((flags &amp; ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
+            {
+                return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED);
+            }
+
+            gl::FenceSync *fenceSync = context-&gt;getFenceSync(sync);
+
+            if (!fenceSync)
+            {
+                return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED);
+            }
+
+            return fenceSync-&gt;clientWait(flags, timeout);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
+    }
+
+    return GL_FALSE;
+}
+
+void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
+{
+    EVENT(&quot;(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)&quot;,
+          sync, flags, timeout);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (flags != 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            if (timeout != GL_TIMEOUT_IGNORED)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            gl::FenceSync *fenceSync = context-&gt;getFenceSync(sync);
+
+            if (!fenceSync)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            fenceSync-&gt;serverWait();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetInteger64v(GLenum pname, GLint64* params)
+{
+    EVENT(&quot;(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)&quot;,
+          pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            GLenum nativeType;
+            unsigned int numParams = 0;
+            if (!context-&gt;getQueryParameterInfo(pname, &amp;nativeType, &amp;numParams))
+                return gl::error(GL_INVALID_ENUM);
+
+            // pname is valid, but that there are no parameters to return.
+            if (numParams == 0)
+                return;
+
+            if (nativeType == GL_INT_64_ANGLEX)
+            {
+                context-&gt;getInteger64v(pname, params);
+            }
+            else
+            {
+                CastStateValues(context, nativeType, pname, numParams, params);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
+{
+    EVENT(&quot;(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)&quot;,
+          sync, pname, bufSize, length, values);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (bufSize &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            gl::FenceSync *fenceSync = context-&gt;getFenceSync(sync);
+
+            if (!fenceSync)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            switch (pname)
+            {
+              case GL_OBJECT_TYPE:     values[0] = static_cast&lt;GLint&gt;(GL_SYNC_FENCE);              break;
+              case GL_SYNC_STATUS:     values[0] = static_cast&lt;GLint&gt;(fenceSync-&gt;getStatus());     break;
+              case GL_SYNC_CONDITION:  values[0] = static_cast&lt;GLint&gt;(fenceSync-&gt;getCondition());  break;
+              case GL_SYNC_FLAGS:      values[0] = 0;                                              break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)&quot;,
+          target, index, data);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (target)
+            {
+              case GL_TRANSFORM_FEEDBACK_BUFFER_START:
+              case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
+              case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+                if (index &gt;= context-&gt;getMaxTransformFeedbackBufferBindings())
+                    return gl::error(GL_INVALID_VALUE);
+                break;
+              case GL_UNIFORM_BUFFER_START:
+              case GL_UNIFORM_BUFFER_SIZE:
+              case GL_UNIFORM_BUFFER_BINDING:
+                if (index &gt;= context-&gt;getMaximumCombinedUniformBufferBindings())
+                    return gl::error(GL_INVALID_VALUE);
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            if (!(context-&gt;getIndexedInteger64v(target, index, data)))
+            {
+                GLenum nativeType;
+                unsigned int numParams = 0;
+                if (!context-&gt;getIndexedQueryParameterInfo(target, &amp;nativeType, &amp;numParams))
+                    return gl::error(GL_INVALID_ENUM);
+
+                if (numParams == 0)
+                    return; // it is known that pname is valid, but there are no parameters to return
+
+                if (nativeType == GL_INT)
+                {
+                    GLint *intParams = new GLint[numParams];
+
+                    context-&gt;getIndexedIntegerv(target, index, intParams);
+
+                    for (unsigned int i = 0; i &lt; numParams; ++i)
+                    {
+                        data[i] = static_cast&lt;GLint64&gt;(intParams[i]);
+                    }
+
+                    delete [] intParams;
+                }
+                else
+                {
+                    UNREACHABLE();
+                }
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)&quot;,
+          target, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!gl::ValidBufferTarget(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            if (!gl::ValidBufferParameter(context, pname))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            gl::Buffer *buffer = context-&gt;getTargetBuffer(target);
+
+            if (!buffer)
+            {
+                // A null buffer means that &quot;0&quot; is bound to the requested buffer target
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (pname)
+            {
+              case GL_BUFFER_USAGE:
+                *params = static_cast&lt;GLint64&gt;(buffer-&gt;usage());
+                break;
+              case GL_BUFFER_SIZE:
+                *params = buffer-&gt;size();
+                break;
+              case GL_BUFFER_ACCESS_FLAGS:
+                *params = static_cast&lt;GLint64&gt;(buffer-&gt;accessFlags());
+                break;
+              case GL_BUFFER_MAPPED:
+                *params = static_cast&lt;GLint64&gt;(buffer-&gt;mapped());
+                break;
+              case GL_BUFFER_MAP_OFFSET:
+                *params = buffer-&gt;mapOffset();
+                break;
+              case GL_BUFFER_MAP_LENGTH:
+                *params = buffer-&gt;mapLength();
+                break;
+              default: UNREACHABLE(); break;
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGenSamplers(GLsizei count, GLuint* samplers)
+{
+    EVENT(&quot;(GLsizei count = %d, GLuint* samplers = 0x%0.8p)&quot;, count, samplers);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (count &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            for (int i = 0; i &lt; count; i++)
+            {
+                samplers[i] = context-&gt;createSampler();
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers)
+{
+    EVENT(&quot;(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)&quot;, count, samplers);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (count &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            for (int i = 0; i &lt; count; i++)
+            {
+                context-&gt;deleteSampler(samplers[i]);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLboolean __stdcall glIsSampler(GLuint sampler)
+{
+    EVENT(&quot;(GLuint sampler = %u)&quot;, sampler);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_FALSE);
+            }
+
+            return context-&gt;isSampler(sampler);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
+    }
+
+    return GL_FALSE;
+}
+
+void __stdcall glBindSampler(GLuint unit, GLuint sampler)
+{
+    EVENT(&quot;(GLuint unit = %u, GLuint sampler = %u)&quot;, unit, sampler);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (sampler != 0 &amp;&amp; !context-&gt;isSampler(sampler))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (unit &gt;= context-&gt;getMaximumCombinedTextureImageUnits())
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            context-&gt;bindSampler(unit, sampler);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
+{
+    EVENT(&quot;(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)&quot;, sampler, pname, param);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!gl::ValidateSamplerObjectParameter(pname))
+            {
+                return;
+            }
+
+            if (!gl::ValidateTexParamParameters(context, pname, param))
+            {
+                return;
+            }
+
+            if (!context-&gt;isSampler(sampler))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            context-&gt;samplerParameteri(sampler, pname, param);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
+{
+    glSamplerParameteri(sampler, pname, *param);
+}
+
+void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
+{
+    EVENT(&quot;(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)&quot;, sampler, pname, param);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!gl::ValidateSamplerObjectParameter(pname))
+            {
+                return;
+            }
+
+            if (!gl::ValidateTexParamParameters(context, pname, static_cast&lt;GLint&gt;(param)))
+            {
+                return;
+            }
+
+            if (!context-&gt;isSampler(sampler))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            context-&gt;samplerParameterf(sampler, pname, param);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
+{
+    glSamplerParameterf(sampler, pname, *param);
+}
+
+void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
+{
+    EVENT(&quot;(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)&quot;, sampler, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!gl::ValidateSamplerObjectParameter(pname))
+            {
+                return;
+            }
+
+            if (!context-&gt;isSampler(sampler))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            *params = context-&gt;getSamplerParameteri(sampler, pname);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
+{
+    EVENT(&quot;(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)&quot;, sampler, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!gl::ValidateSamplerObjectParameter(pname))
+            {
+                return;
+            }
+
+            if (!context-&gt;isSampler(sampler))
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            *params = context-&gt;getSamplerParameterf(sampler, pname);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor)
+{
+    EVENT(&quot;(GLuint index = %u, GLuint divisor = %u)&quot;, index, divisor);
+
+    try
+    {
+        if (index &gt;= gl::MAX_VERTEX_ATTRIBS)
+        {
+            return gl::error(GL_INVALID_VALUE);
+        }
+
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            context-&gt;setVertexAttribDivisor(index, divisor);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glBindTransformFeedback(GLenum target, GLuint id)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLuint id = %u)&quot;, target, id);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            switch (target)
+            {
+              case GL_TRANSFORM_FEEDBACK:
+                {
+                    // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
+                    gl::TransformFeedback *curTransformFeedback = context-&gt;getCurrentTransformFeedback();
+                    if (curTransformFeedback &amp;&amp; curTransformFeedback-&gt;isStarted() &amp;&amp; !curTransformFeedback-&gt;isPaused())
+                    {
+                        return gl::error(GL_INVALID_OPERATION);
+                    }
+
+                    // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
+                    if (context-&gt;getTransformFeedback(id) == NULL)
+                    {
+                        return gl::error(GL_INVALID_OPERATION);
+                    }
+
+                    context-&gt;bindTransformFeedback(id);
+                }
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
+{
+    EVENT(&quot;(GLsizei n = %d, const GLuint* ids = 0x%0.8p)&quot;, n, ids);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            for (int i = 0; i &lt; n; i++)
+            {
+                context-&gt;deleteTransformFeedback(ids[i]);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids)
+{
+    EVENT(&quot;(GLsizei n = %d, GLuint* ids = 0x%0.8p)&quot;, n, ids);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            for (int i = 0; i &lt; n; i++)
+            {
+                ids[i] = context-&gt;createTransformFeedback();
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+GLboolean __stdcall glIsTransformFeedback(GLuint id)
+{
+    EVENT(&quot;(GLuint id = %u)&quot;, id);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_FALSE);
+            }
+
+            return ((context-&gt;getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
+    }
+
+    return GL_FALSE;
+}
+
+void __stdcall glPauseTransformFeedback(void)
+{
+    EVENT(&quot;(void)&quot;);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::TransformFeedback *transformFeedback = context-&gt;getCurrentTransformFeedback();
+            ASSERT(transformFeedback != NULL);
+
+            // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
+            if (!transformFeedback-&gt;isStarted() || transformFeedback-&gt;isPaused())
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            transformFeedback-&gt;pause();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glResumeTransformFeedback(void)
+{
+    EVENT(&quot;(void)&quot;);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            gl::TransformFeedback *transformFeedback = context-&gt;getCurrentTransformFeedback();
+            ASSERT(transformFeedback != NULL);
+
+            // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
+            if (!transformFeedback-&gt;isStarted() || !transformFeedback-&gt;isPaused())
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            transformFeedback-&gt;resume();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
+{
+    EVENT(&quot;(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)&quot;,
+          program, bufSize, length, binaryFormat, binary);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // glGetProgramBinary
+            UNIMPLEMENTED();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
+{
+    EVENT(&quot;(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)&quot;,
+          program, binaryFormat, binary, length);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // glProgramBinary
+            UNIMPLEMENTED();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value)
+{
+    EVENT(&quot;(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)&quot;,
+          program, pname, value);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // glProgramParameteri
+            UNIMPLEMENTED();
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)&quot;,
+          target, numAttachments, attachments);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
+            {
+                return;
+            }
+
+            int maxDimension = context-&gt;getMaximumRenderbufferDimension();
+            context-&gt;invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, &quot;
+          &quot;GLint y = %d, GLsizei width = %d, GLsizei height = %d)&quot;,
+          target, numAttachments, attachments, x, y, width, height);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
+            {
+                return;
+            }
+
+            context-&gt;invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)&quot;,
+          target, levels, internalformat, width, height);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
+            {
+                return;
+            }
+
+            switch (target)
+            {
+              case GL_TEXTURE_2D:
+                {
+                    gl::Texture2D *texture2d = context-&gt;getTexture2D();
+                    texture2d-&gt;storage(levels, internalformat, width, height);
+                }
+                break;
+
+              case GL_TEXTURE_CUBE_MAP:
+                {
+                    gl::TextureCubeMap *textureCube = context-&gt;getTextureCubeMap();
+                    textureCube-&gt;storage(levels, internalformat, width);
+                }
+                break;
+
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, &quot;
+          &quot;GLsizei height = %d, GLsizei depth = %d)&quot;,
+          target, levels, internalformat, width, height, depth);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
+            {
+                return;
+            }
+
+            switch (target)
+            {
+              case GL_TEXTURE_3D:
+                {
+                    gl::Texture3D *texture3d = context-&gt;getTexture3D();
+                    texture3d-&gt;storage(levels, internalformat, width, height, depth);
+                }
+                break;
+
+              case GL_TEXTURE_2D_ARRAY:
+                {
+                    gl::Texture2DArray *texture2darray = context-&gt;getTexture2DArray();
+                    texture2darray-&gt;storage(levels, internalformat, width, height, depth);
+                }
+                break;
+
+              default:
+                UNREACHABLE();
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, &quot;
+          &quot;GLint* params = 0x%0.8p)&quot;,
+          target, internalformat, pname, bufSize, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (context-&gt;getClientVersion() &lt; 3)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!gl::IsColorRenderingSupported(internalformat, context) &amp;&amp;
+                !gl::IsDepthRenderingSupported(internalformat, context) &amp;&amp;
+                !gl::IsStencilRenderingSupported(internalformat, context))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            if (target != GL_RENDERBUFFER)
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            if (bufSize &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            switch (pname)
+            {
+              case GL_NUM_SAMPLE_COUNTS:
+                if (bufSize != 0)
+                    *params = context-&gt;getNumSampleCounts(internalformat);
+                break;
+              case GL_SAMPLES:
+                context-&gt;getSampleCounts(internalformat, bufSize, params);
+                break;
+              default:
+                return gl::error(GL_INVALID_ENUM);
+            }
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+// Extension functions
+
+void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+                                      GLbitfield mask, GLenum filter)
+{
+    EVENT(&quot;(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, &quot;
+          &quot;GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, &quot;
+          &quot;GLbitfield mask = 0x%X, GLenum filter = 0x%X)&quot;,
+          srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
+                                                   dstX0, dstY0, dstX1, dstY1, mask, filter,
+                                                   true))
+            {
+                return;
+            }
+
+            context-&gt;blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
+                                     mask, filter);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
</ins><span class="cx"> void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
</span><span class="cx">                                GLint border, GLenum format, GLenum type, const GLvoid* pixels)
</span><span class="cx"> {
</span><span class="lines">@@ -7018,6 +10260,265 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void __stdcall glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)&quot;, target, pname, params);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (!context-&gt;supportsPBOs())
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!gl::ValidBufferTarget(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            if (pname != GL_BUFFER_MAP_POINTER)
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            gl::Buffer *buffer = context-&gt;getTargetBuffer(target);
+
+            if (!buffer || !buffer-&gt;mapped())
+            {
+                *params = NULL;
+            }
+
+            *params = buffer-&gt;mapPointer();
+        }
+    }
+    catch (std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
+void * __stdcall glMapBufferOES(GLenum target, GLenum access)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLbitfield access = 0x%X)&quot;, target, access);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (!gl::ValidBufferTarget(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            gl::Buffer *buffer = context-&gt;getTargetBuffer(target);
+
+            if (buffer == NULL)
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            if (access != GL_WRITE_ONLY_OES)
+            {
+                return gl::error(GL_INVALID_ENUM, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            if (buffer-&gt;mapped())
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            return buffer-&gt;mapRange(0, buffer-&gt;size(), GL_MAP_WRITE_BIT);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+    }
+
+    return NULL;
+}
+
+GLboolean __stdcall glUnmapBufferOES(GLenum target)
+{
+    EVENT(&quot;(GLenum target = 0x%X)&quot;, target);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (!gl::ValidBufferTarget(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM, GL_FALSE);
+            }
+
+            gl::Buffer *buffer = context-&gt;getTargetBuffer(target);
+
+            if (buffer == NULL || !buffer-&gt;mapped())
+            {
+                return gl::error(GL_INVALID_OPERATION, GL_FALSE);
+            }
+
+            // TODO: detect if we had corruption. if so, throw an error and return false.
+
+            buffer-&gt;unmap();
+
+            return GL_TRUE;
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
+    }
+
+    return GL_FALSE;
+}
+
+void* __stdcall glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)&quot;,
+          target, offset, length, access);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (!gl::ValidBufferTarget(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            if (offset &lt; 0 || length &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            gl::Buffer *buffer = context-&gt;getTargetBuffer(target);
+
+            if (buffer == NULL)
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            // Check for buffer overflow
+            size_t offsetSize = static_cast&lt;size_t&gt;(offset);
+            size_t lengthSize = static_cast&lt;size_t&gt;(length);
+
+            if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
+                offsetSize + lengthSize &gt; static_cast&lt;size_t&gt;(buffer-&gt;size()))
+            {
+                return gl::error(GL_INVALID_VALUE, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            // Check for invalid bits in the mask
+            GLbitfield allAccessBits = GL_MAP_READ_BIT |
+                                       GL_MAP_WRITE_BIT |
+                                       GL_MAP_INVALIDATE_RANGE_BIT |
+                                       GL_MAP_INVALIDATE_BUFFER_BIT |
+                                       GL_MAP_FLUSH_EXPLICIT_BIT |
+                                       GL_MAP_UNSYNCHRONIZED_BIT;
+
+            if (access &amp; ~(allAccessBits))
+            {
+                return gl::error(GL_INVALID_VALUE, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            if (length == 0 || buffer-&gt;mapped())
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            // Check for invalid bit combinations
+            if ((access &amp; (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
+                                       GL_MAP_INVALIDATE_BUFFER_BIT |
+                                       GL_MAP_UNSYNCHRONIZED_BIT;
+
+            if ((access &amp; GL_MAP_READ_BIT) != 0 &amp;&amp; (access &amp; writeOnlyBits) != 0)
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            if ((access &amp; GL_MAP_WRITE_BIT) == 0 &amp;&amp; (access &amp; GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
+            {
+                return gl::error(GL_INVALID_OPERATION, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+            }
+
+            return buffer-&gt;mapRange(offset, length, access);
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast&lt;GLvoid*&gt;(NULL));
+    }
+
+    return NULL;
+}
+
+void __stdcall glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
+{
+    EVENT(&quot;(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)&quot;, target, offset, length);
+
+    try
+    {
+        gl::Context *context = gl::getNonLostContext();
+
+        if (context)
+        {
+            if (offset &lt; 0 || length &lt; 0)
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            if (!gl::ValidBufferTarget(context, target))
+            {
+                return gl::error(GL_INVALID_ENUM);
+            }
+
+            gl::Buffer *buffer = context-&gt;getTargetBuffer(target);
+
+            if (buffer == NULL)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            if (!buffer-&gt;mapped() || (buffer-&gt;accessFlags() &amp; GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
+            {
+                return gl::error(GL_INVALID_OPERATION);
+            }
+
+            // Check for buffer overflow
+            size_t offsetSize = static_cast&lt;size_t&gt;(offset);
+            size_t lengthSize = static_cast&lt;size_t&gt;(length);
+
+            if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
+                offsetSize + lengthSize &gt; static_cast&lt;size_t&gt;(buffer-&gt;mapLength()))
+            {
+                return gl::error(GL_INVALID_VALUE);
+            }
+
+            // We do not currently support a non-trivial implementation of FlushMappedBufferRange
+        }
+    }
+    catch(std::bad_alloc&amp;)
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+}
+
</ins><span class="cx"> __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
</span><span class="cx"> {
</span><span class="cx">     struct Extension
</span><span class="lines">@@ -7056,7 +10557,12 @@
</span><span class="cx">         {&quot;glDrawArraysInstancedANGLE&quot;, (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
</span><span class="cx">         {&quot;glDrawElementsInstancedANGLE&quot;, (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
</span><span class="cx">         {&quot;glGetProgramBinaryOES&quot;, (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
</span><del>-        {&quot;glProgramBinaryOES&quot;, (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},    };
</del><ins>+        {&quot;glProgramBinaryOES&quot;, (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
+        {&quot;glGetBufferPointervOES&quot;, (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
+        {&quot;glMapBufferOES&quot;, (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
+        {&quot;glUnmapBufferOES&quot;, (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
+        {&quot;glMapBufferRangeEXT&quot;, (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
+        {&quot;glFlushMappedBufferRangeEXT&quot;, (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT},    };
</ins><span class="cx"> 
</span><span class="cx">     for (unsigned int ext = 0; ext &lt; ArraySize(glExtensions); ext++)
</span><span class="cx">     {
</span><span class="lines">@@ -7083,16 +10589,14 @@
</span><span class="cx">         if (context)
</span><span class="cx">         {
</span><span class="cx">             gl::Texture2D *textureObject = context-&gt;getTexture2D();
</span><ins>+            ASSERT(textureObject != NULL);
</ins><span class="cx"> 
</span><span class="cx">             if (textureObject-&gt;isImmutable())
</span><span class="cx">             {
</span><span class="cx">                 return false;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (textureObject)
-            {
-                textureObject-&gt;bindTexImage(surface);
-            }
</del><ins>+            textureObject-&gt;bindTexImage(surface);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     catch(std::bad_alloc&amp;)
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2libGLESv2def"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.def (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.def        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.def        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -173,7 +173,118 @@
</span><span class="cx">     glProgramBinaryOES              @175
</span><span class="cx">     glGetProgramBinaryOES           @176
</span><span class="cx">     glDrawBuffersEXT                @179
</span><ins>+    glMapBufferOES                  @285
+    glUnmapBufferOES                @286
+    glGetBufferPointervOES          @287
+    glMapBufferRangeEXT             @288
+    glFlushMappedBufferRangeEXT     @289
</ins><span class="cx"> 
</span><ins>+    ; GLES 3.0 Functions
+    glReadBuffer                    @180
+    glDrawRangeElements             @181
+    glTexImage3D                    @182
+    glTexSubImage3D                 @183
+    glCopyTexSubImage3D             @184
+    glCompressedTexImage3D          @185
+    glCompressedTexSubImage3D       @186
+    glGenQueries                    @187
+    glDeleteQueries                 @188
+    glIsQuery                       @189
+    glBeginQuery                    @190
+    glEndQuery                      @191
+    glGetQueryiv                    @192
+    glGetQueryObjectuiv             @193
+    glUnmapBuffer                   @194
+    glGetBufferPointerv             @195
+    glDrawBuffers                   @196
+    glUniformMatrix2x3fv            @197
+    glUniformMatrix3x2fv            @198
+    glUniformMatrix2x4fv            @199
+    glUniformMatrix4x2fv            @200
+    glUniformMatrix3x4fv            @201
+    glUniformMatrix4x3fv            @202
+    glBlitFramebuffer               @203
+    glRenderbufferStorageMultisample @204
+    glFramebufferTextureLayer       @205
+    glMapBufferRange                @206
+    glFlushMappedBufferRange        @207
+    glBindVertexArray               @208
+    glDeleteVertexArrays            @209
+    glGenVertexArrays               @210
+    glIsVertexArray                 @211
+    glGetIntegeri_v                 @212
+    glBeginTransformFeedback        @213
+    glEndTransformFeedback          @214
+    glBindBufferRange               @215
+    glBindBufferBase                @216
+    glTransformFeedbackVaryings     @217
+    glGetTransformFeedbackVarying   @218
+    glVertexAttribIPointer          @219
+    glGetVertexAttribIiv            @220
+    glGetVertexAttribIuiv           @221
+    glVertexAttribI4i               @222
+    glVertexAttribI4ui              @223
+    glVertexAttribI4iv              @224
+    glVertexAttribI4uiv             @225
+    glGetUniformuiv                 @226
+    glGetFragDataLocation           @227
+    glUniform1ui                    @228
+    glUniform2ui                    @229
+    glUniform3ui                    @230
+    glUniform4ui                    @231
+    glUniform1uiv                   @232
+    glUniform2uiv                   @233
+    glUniform3uiv                   @234
+    glUniform4uiv                   @235
+    glClearBufferiv                 @236
+    glClearBufferuiv                @237
+    glClearBufferfv                 @238
+    glClearBufferfi                 @239
+    glGetStringi                    @240
+    glCopyBufferSubData             @241
+    glGetUniformIndices             @242
+    glGetActiveUniformsiv           @243
+    glGetUniformBlockIndex          @244
+    glGetActiveUniformBlockiv       @245
+    glGetActiveUniformBlockName     @246
+    glUniformBlockBinding           @247
+    glDrawArraysInstanced           @248
+    glDrawElementsInstanced         @249
+    glFenceSync                     @250
+    glIsSync                        @251
+    glDeleteSync                    @252
+    glClientWaitSync                @253
+    glWaitSync                      @254
+    glGetInteger64v                 @255
+    glGetSynciv                     @256
+    glGetInteger64i_v               @257
+    glGetBufferParameteri64v        @258
+    glGenSamplers                   @259
+    glDeleteSamplers                @260
+    glIsSampler                     @261
+    glBindSampler                   @262
+    glSamplerParameteri             @263
+    glSamplerParameteriv            @264
+    glSamplerParameterf             @265
+    glSamplerParameterfv            @266
+    glGetSamplerParameteriv         @267
+    glGetSamplerParameterfv         @268
+    glVertexAttribDivisor           @269
+    glBindTransformFeedback         @270
+    glDeleteTransformFeedbacks      @271
+    glGenTransformFeedbacks         @272
+    glIsTransformFeedback           @273
+    glPauseTransformFeedback        @274
+    glResumeTransformFeedback       @275
+    glGetProgramBinary              @276
+    glProgramBinary                 @277
+    glProgramParameteri             @278
+    glInvalidateFramebuffer         @279
+    glInvalidateSubFramebuffer      @280
+    glTexStorage2D                  @281
+    glTexStorage3D                  @282
+    glGetInternalformativ           @283
+
</ins><span class="cx">     ; EGL dependencies
</span><span class="cx">     glCreateContext                 @144 NONAME
</span><span class="cx">     glDestroyContext                @145 NONAME
</span><span class="lines">@@ -185,4 +296,4 @@
</span><span class="cx">     glDestroyRenderer               @178 NONAME
</span><span class="cx"> 
</span><span class="cx">     ; Setting up TRACE macro callbacks
</span><del>-    SetTraceFunctionPointers        @180
</del><ins>+    SetTraceFunctionPointers        @284
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2mainh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/main.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/main.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/main.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx"> extern &quot;C&quot;
</span><span class="cx"> {
</span><span class="cx"> // Exported functions for use by EGL
</span><del>-gl::Context *glCreateContext(const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess);
</del><ins>+gl::Context *glCreateContext(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess);
</ins><span class="cx"> void glDestroyContext(gl::Context *context);
</span><span class="cx"> void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface);
</span><span class="cx"> gl::Context *glGetCurrentContext();
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2precompiledh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/precompiled.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/precompiled.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/precompiled.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -7,7 +7,11 @@
</span><span class="cx"> // precompiled.h: Precompiled header file for libGLESv2.
</span><span class="cx"> 
</span><span class="cx"> #define GL_APICALL
</span><ins>+#include &lt;GLES3/gl3.h&gt;
+#include &lt;GLES3/gl3ext.h&gt;
</ins><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><ins>+
+#define GL_GLEXT_PROTOTYPES
</ins><span class="cx"> #include &lt;GLES2/gl2ext.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #define EGLAPI
</span><span class="lines">@@ -16,6 +20,7 @@
</span><span class="cx"> #include &lt;assert.h&gt;
</span><span class="cx"> #include &lt;cstddef&gt;
</span><span class="cx"> #include &lt;float.h&gt;
</span><ins>+#include &lt;stdint.h&gt;
</ins><span class="cx"> #include &lt;intrin.h&gt;
</span><span class="cx"> #include &lt;math.h&gt;
</span><span class="cx"> #include &lt;stdarg.h&gt;
</span><span class="lines">@@ -32,12 +37,15 @@
</span><span class="cx"> #include &lt;unordered_map&gt;
</span><span class="cx"> #include &lt;vector&gt;
</span><span class="cx"> 
</span><ins>+#if defined(ANGLE_ENABLE_D3D9)
</ins><span class="cx"> #include &lt;d3d9.h&gt;
</span><del>-#include &lt;d3d11.h&gt;
</del><ins>+#include &lt;D3Dcompiler.h&gt;
+#endif // ANGLE_ENABLE_D3D9
+
+#if defined(ANGLE_ENABLE_D3D11)
+#include &lt;D3D10_1.h&gt;
+#include &lt;D3D11.h&gt;
</ins><span class="cx"> #include &lt;dxgi.h&gt;
</span><span class="cx"> #include &lt;dxgi1_2.h&gt;
</span><del>-#include &lt;d3dcompiler.h&gt;
-
-#ifdef _MSC_VER
-#include &lt;hash_map&gt;
-#endif
</del><ins>+#include &lt;D3Dcompiler.h&gt;
+#endif // ANGLE_ENABLE_D3D11
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2queryconversionscpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/queryconversions.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/queryconversions.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/queryconversions.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,148 @@
</span><ins>+#include &quot;precompiled.h&quot;
+//
+// Copyright (c) 2014 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.
+//
+
+// queryconversions.cpp: Implementation of state query cast conversions
+
+#include &quot;libGLESv2/Context.h&quot;
+#include &quot;common/utilities.h&quot;
+
+namespace gl
+{
+
+// Helper class for converting a GL type to a GLenum:
+// We can't use CastStateValueEnum generally, because of GLboolean + GLubyte overlap.
+// We restrict our use to CastStateValue, where it eliminates duplicate parameters.
+
+template &lt;typename GLType&gt;
+struct CastStateValueEnum { static GLenum mEnumForType; };
+
+template &lt;&gt; GLenum CastStateValueEnum&lt;GLint&gt;::mEnumForType      = GL_INT;
+template &lt;&gt; GLenum CastStateValueEnum&lt;GLuint&gt;::mEnumForType     = GL_UNSIGNED_INT;
+template &lt;&gt; GLenum CastStateValueEnum&lt;GLboolean&gt;::mEnumForType  = GL_BOOL;
+template &lt;&gt; GLenum CastStateValueEnum&lt;GLint64&gt;::mEnumForType    = GL_INT_64_ANGLEX;
+template &lt;&gt; GLenum CastStateValueEnum&lt;GLfloat&gt;::mEnumForType    = GL_FLOAT;
+
+template &lt;typename QueryT, typename NativeT&gt;
+QueryT CastStateValueToInt(GLenum pname, NativeT value)
+{
+    GLenum queryType = CastStateValueEnum&lt;QueryT&gt;::mEnumForType;
+    GLenum nativeType = CastStateValueEnum&lt;NativeT&gt;::mEnumForType;
+
+    if (nativeType == GL_FLOAT)
+    {
+        // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5
+        if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR)
+        {
+            return static_cast&lt;QueryT&gt;((static_cast&lt;GLfloat&gt;(0xFFFFFFFF) * value - 1.0f) / 2.0f);
+        }
+        else
+        {
+            return gl::iround&lt;QueryT&gt;(value);
+        }
+    }
+
+    // Clamp 64-bit int values when casting to int
+    if (nativeType == GL_INT_64_ANGLEX &amp;&amp; queryType == GL_INT)
+    {
+        GLint64 minIntValue = static_cast&lt;GLint64&gt;(std::numeric_limits&lt;GLint&gt;::min());
+        GLint64 maxIntValue = static_cast&lt;GLint64&gt;(std::numeric_limits&lt;GLint&gt;::max());
+        GLint64 clampedValue = std::max(std::min(static_cast&lt;GLint64&gt;(value), maxIntValue), minIntValue);
+        return static_cast&lt;QueryT&gt;(clampedValue);
+    }
+
+    return static_cast&lt;QueryT&gt;(value);
+}
+
+template &lt;typename QueryT, typename NativeT&gt;
+QueryT CastStateValue(GLenum pname, NativeT value)
+{
+    GLenum queryType = CastStateValueEnum&lt;QueryT&gt;::mEnumForType;
+
+    switch (queryType)
+    {
+      case GL_INT:              return CastStateValueToInt&lt;QueryT, NativeT&gt;(pname, value);
+      case GL_INT_64_ANGLEX:    return CastStateValueToInt&lt;QueryT, NativeT&gt;(pname, value);
+      case GL_FLOAT:            return static_cast&lt;QueryT&gt;(value);
+      case GL_BOOL:             return (value == static_cast&lt;NativeT&gt;(0) ? GL_FALSE : GL_TRUE);
+      default: UNREACHABLE();   return 0;
+    }
+}
+
+template &lt;typename QueryT&gt;
+void CastStateValues(Context *context, GLenum nativeType, GLenum pname,
+                     unsigned int numParams, QueryT *outParams)
+{
+    if (nativeType == GL_INT)
+    {
+        GLint *intParams = NULL;
+        intParams = new GLint[numParams];
+
+        context-&gt;getIntegerv(pname, intParams);
+
+        for (unsigned int i = 0; i &lt; numParams; ++i)
+        {
+            outParams[i] = CastStateValue&lt;QueryT&gt;(pname, intParams[i]);
+        }
+
+        delete [] intParams;
+    }
+    else if (nativeType == GL_BOOL)
+    {
+        GLboolean *boolParams = NULL;
+        boolParams = new GLboolean[numParams];
+
+        context-&gt;getBooleanv(pname, boolParams);
+
+        for (unsigned int i = 0; i &lt; numParams; ++i)
+        {
+            outParams[i] = (boolParams[i] == GL_FALSE ? static_cast&lt;QueryT&gt;(0) : static_cast&lt;QueryT&gt;(1));
+        }
+
+        delete [] boolParams;
+    }
+    else if (nativeType == GL_FLOAT)
+    {
+        GLfloat *floatParams = NULL;
+        floatParams = new GLfloat[numParams];
+
+        context-&gt;getFloatv(pname, floatParams);
+
+        for (unsigned int i = 0; i &lt; numParams; ++i)
+        {
+            outParams[i] = CastStateValue&lt;QueryT&gt;(pname, floatParams[i]);
+        }
+
+        delete [] floatParams;
+    }
+    else if (nativeType == GL_INT_64_ANGLEX)
+    {
+        GLint64 *int64Params = NULL;
+        int64Params = new GLint64[numParams];
+
+        context-&gt;getInteger64v(pname, int64Params);
+
+        for (unsigned int i = 0; i &lt; numParams; ++i)
+        {
+            outParams[i] = CastStateValue&lt;QueryT&gt;(pname, int64Params[i]);
+        }
+
+        delete [] int64Params;
+    }
+    else UNREACHABLE();
+}
+
+// Explicit template instantiation (how we export template functions in different files)
+// The calls below will make CastStateValues successfully link with the GL state query types
+// The GL state query API types are: bool, int, uint, float, int64
+
+template void CastStateValues&lt;GLboolean&gt;(Context *, GLenum, GLenum, unsigned int, GLboolean *);
+template void CastStateValues&lt;GLint&gt;(Context *, GLenum, GLenum, unsigned int, GLint *);
+template void CastStateValues&lt;GLuint&gt;(Context *, GLenum, GLenum, unsigned int, GLuint *);
+template void CastStateValues&lt;GLfloat&gt;(Context *, GLenum, GLenum, unsigned int, GLfloat *);
+template void CastStateValues&lt;GLint64&gt;(Context *, GLenum, GLenum, unsigned int, GLint64 *);
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2queryconversionsh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/queryconversions.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/queryconversions.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/queryconversions.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+//
+// Copyright (c) 2014 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.
+//
+
+// queryconversions.h: Declaration of state query cast conversions
+
+namespace gl
+{
+
+// The GL state query API types are: bool, int, uint, float, int64
+template &lt;typename QueryT&gt;
+void CastStateValues(Context *context, GLenum nativeType, GLenum pname,
+                     unsigned int numParams, QueryT *outParams);
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererBufferStoragecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/BufferStorage.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/BufferStorage.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/BufferStorage.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -33,8 +33,4 @@
</span><span class="cx">     mSerial = mNextSerial++;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void BufferStorage::markBufferUsage()
-{
</del><span class="cx"> }
</span><del>-
-}
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererBufferStorageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/BufferStorage.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/BufferStorage.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/BufferStorage.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -23,12 +23,18 @@
</span><span class="cx">     // The data returned is only guaranteed valid until next non-const method.
</span><span class="cx">     virtual void *getData() = 0;
</span><span class="cx">     virtual void setData(const void* data, unsigned int size, unsigned int offset) = 0;
</span><ins>+    virtual void copyData(BufferStorage* sourceStorage, unsigned int size,
+                          unsigned int sourceOffset, unsigned int destOffset) = 0;
</ins><span class="cx">     virtual void clear() = 0;
</span><ins>+    virtual void markTransformFeedbackUsage() = 0;
</ins><span class="cx">     virtual unsigned int getSize() const = 0;
</span><span class="cx">     virtual bool supportsDirectBinding() const = 0;
</span><del>-    virtual void markBufferUsage();
</del><span class="cx">     unsigned int getSerial() const;
</span><span class="cx"> 
</span><ins>+    virtual bool isMapped() const = 0;
+    virtual void *map(GLbitfield access) = 0;
+    virtual void unmap() = 0;
+
</ins><span class="cx">   protected:
</span><span class="cx">     void updateSerial();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererFenceImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/FenceImpl.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/FenceImpl.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/FenceImpl.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -17,27 +17,16 @@
</span><span class="cx"> class FenceImpl
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    FenceImpl() : mStatus(GL_FALSE), mCondition(GL_NONE) { };
</del><ins>+    FenceImpl() { };
</ins><span class="cx">     virtual ~FenceImpl() { };
</span><span class="cx"> 
</span><del>-    virtual GLboolean isFence() = 0;
-    virtual void setFence(GLenum condition) = 0;
-    virtual GLboolean testFence() = 0;
-    virtual void finishFence() = 0;
-    virtual void getFenceiv(GLenum pname, GLint *params) = 0;
</del><ins>+    virtual bool isSet() const = 0;
+    virtual void set() = 0;
+    virtual bool test(bool flushCommandBuffer) = 0;
+    virtual bool hasError() const = 0;
</ins><span class="cx"> 
</span><del>-  protected:
-    void setStatus(GLboolean status) { mStatus = status; }
-    GLboolean getStatus() const { return mStatus; }
-
-    void setCondition(GLuint condition) { mCondition = condition; }
-    GLuint getCondition() const { return mCondition; }
-
</del><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(FenceImpl);
</span><del>-
-    GLboolean mStatus;
-    GLenum mCondition;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Image.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Image.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Image.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -18,531 +18,12 @@
</span><span class="cx"> {
</span><span class="cx">     mWidth = 0; 
</span><span class="cx">     mHeight = 0;
</span><ins>+    mDepth = 0;
</ins><span class="cx">     mInternalFormat = GL_NONE;
</span><span class="cx">     mActualFormat = GL_NONE;
</span><ins>+    mTarget = GL_NONE;
+    mRenderable = false;
+    mDirty = false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height,
-                                int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned char *source = NULL;
-    unsigned char *dest = NULL;
-    
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch;
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = 0;
-            dest[4 * x + 1] = 0;
-            dest[4 * x + 2] = 0;
-            dest[4 * x + 3] = source[x];
-        }
-    }
</del><span class="cx"> }
</span><del>-
-void Image::loadAlphaDataToNative(GLsizei width, GLsizei height,
-                                  int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned char *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch;
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        memcpy(dest, source, width);
-    }
-}
-
-void Image::loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height,
-                                     int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const float *source = NULL;
-    float *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const float*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;float*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = 0;
-            dest[4 * x + 1] = 0;
-            dest[4 * x + 2] = 0;
-            dest[4 * x + 3] = source[x];
-        }
-    }
-}
-
-void Image::loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                         int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned short *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;unsigned short*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = 0;
-            dest[4 * x + 1] = 0;
-            dest[4 * x + 2] = 0;
-            dest[4 * x + 3] = source[x];
-        }
-    }
-}
-
-void Image::loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height,
-                                            int inputPitch, const void *input, size_t outputPitch, void *output, bool native)
-{
-    const unsigned char *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch;
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-
-        if (!native)   // BGRA8 destination format
-        {
-            for (int x = 0; x &lt; width; x++)
-            {
-                dest[4 * x + 0] = source[x];
-                dest[4 * x + 1] = source[x];
-                dest[4 * x + 2] = source[x];
-                dest[4 * x + 3] = 0xFF;
-            }
-        }
-        else   // L8 destination format
-        {
-            memcpy(dest, source, width);
-        }
-    }
-}
-
-void Image::loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height,
-                                         int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const float *source = NULL;
-    float *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const float*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;float*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = source[x];
-            dest[4 * x + 1] = source[x];
-            dest[4 * x + 2] = source[x];
-            dest[4 * x + 3] = 1.0f;
-        }
-    }
-}
-
-void Image::loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height,
-                                        int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const float *source = NULL;
-    float *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const float*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;float*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[3 * x + 0] = source[x];
-            dest[3 * x + 1] = source[x];
-            dest[3 * x + 2] = source[x];
-        }
-    }
-}
-
-void Image::loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                             int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned short *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;unsigned short*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = source[x];
-            dest[4 * x + 1] = source[x];
-            dest[4 * x + 2] = source[x];
-            dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1
-        }
-    }
-}
-
-void Image::loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height,
-                                                 int inputPitch, const void *input, size_t outputPitch, void *output, bool native)
-{
-    const unsigned char *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch;
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        
-        if (!native)   // BGRA8 destination format
-        {
-            for (int x = 0; x &lt; width; x++)
-            {
-                dest[4 * x + 0] = source[2*x+0];
-                dest[4 * x + 1] = source[2*x+0];
-                dest[4 * x + 2] = source[2*x+0];
-                dest[4 * x + 3] = source[2*x+1];
-            }
-        }
-        else
-        {
-            memcpy(dest, source, width * 2);
-        }
-    }
-}
-
-void Image::loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height,
-                                              int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const float *source = NULL;
-    float *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const float*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;float*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = source[2*x+0];
-            dest[4 * x + 1] = source[2*x+0];
-            dest[4 * x + 2] = source[2*x+0];
-            dest[4 * x + 3] = source[2*x+1];
-        }
-    }
-}
-
-void Image::loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                                  int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned short *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;unsigned short*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = source[2*x+0];
-            dest[4 * x + 1] = source[2*x+0];
-            dest[4 * x + 2] = source[2*x+0];
-            dest[4 * x + 3] = source[2*x+1];
-        }
-    }
-}
-
-void Image::loadRGBUByteDataToBGRX(GLsizei width, GLsizei height,
-                                   int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned char *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch;
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = source[x * 3 + 2];
-            dest[4 * x + 1] = source[x * 3 + 1];
-            dest[4 * x + 2] = source[x * 3 + 0];
-            dest[4 * x + 3] = 0xFF;
-        }
-    }
-}
-
-void Image::loadRGBUByteDataToRGBA(GLsizei width, GLsizei height,
-                                   int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned char *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch;
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = source[x * 3 + 0];
-            dest[4 * x + 1] = source[x * 3 + 1];
-            dest[4 * x + 2] = source[x * 3 + 2];
-            dest[4 * x + 3] = 0xFF;
-        }
-    }
-}
-
-void Image::loadRGB565DataToBGRA(GLsizei width, GLsizei height,
-                                 int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        for (int x = 0; x &lt; width; x++)
-        {
-            unsigned short rgba = source[x];
-            dest[4 * x + 0] = ((rgba &amp; 0x001F) &lt;&lt; 3) | ((rgba &amp; 0x001F) &gt;&gt; 2);
-            dest[4 * x + 1] = ((rgba &amp; 0x07E0) &gt;&gt; 3) | ((rgba &amp; 0x07E0) &gt;&gt; 9);
-            dest[4 * x + 2] = ((rgba &amp; 0xF800) &gt;&gt; 8) | ((rgba &amp; 0xF800) &gt;&gt; 13);
-            dest[4 * x + 3] = 0xFF;
-        }
-    }
-}
-
-void Image::loadRGB565DataToRGBA(GLsizei width, GLsizei height,
-                                 int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        for (int x = 0; x &lt; width; x++)
-        {
-            unsigned short rgba = source[x];
-            dest[4 * x + 0] = ((rgba &amp; 0xF800) &gt;&gt; 8) | ((rgba &amp; 0xF800) &gt;&gt; 13);
-            dest[4 * x + 1] = ((rgba &amp; 0x07E0) &gt;&gt; 3) | ((rgba &amp; 0x07E0) &gt;&gt; 9);
-            dest[4 * x + 2] = ((rgba &amp; 0x001F) &lt;&lt; 3) | ((rgba &amp; 0x001F) &gt;&gt; 2);
-            dest[4 * x + 3] = 0xFF;
-        }
-    }
-}
-
-void Image::loadRGBFloatDataToRGBA(GLsizei width, GLsizei height,
-                                   int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const float *source = NULL;
-    float *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const float*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;float*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = source[x * 3 + 0];
-            dest[4 * x + 1] = source[x * 3 + 1];
-            dest[4 * x + 2] = source[x * 3 + 2];
-            dest[4 * x + 3] = 1.0f;
-        }
-    }
-}
-
-void Image::loadRGBFloatDataToNative(GLsizei width, GLsizei height,
-                                     int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const float *source = NULL;
-    float *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const float*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;float*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        memcpy(dest, source, width * 12);
-    }
-}
-
-void Image::loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                       int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned short *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;unsigned short*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        for (int x = 0; x &lt; width; x++)
-        {
-            dest[4 * x + 0] = source[x * 3 + 0];
-            dest[4 * x + 1] = source[x * 3 + 1];
-            dest[4 * x + 2] = source[x * 3 + 2];
-            dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1
-        }
-    }
-}
-
-void Image::loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height,
-                                    int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned int *source = NULL;
-    unsigned int *dest = NULL;
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned int*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;unsigned int*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-
-        for (int x = 0; x &lt; width; x++)
-        {
-            unsigned int rgba = source[x];
-            dest[x] = (_rotl(rgba, 16) &amp; 0x00ff00ff) | (rgba &amp; 0xff00ff00);
-        }
-    }
-}
-
-void Image::loadRGBAUByteDataToNative(GLsizei width, GLsizei height,
-                                      int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned int *source = NULL;
-    unsigned int *dest = NULL;
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned int*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;unsigned int*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-
-        memcpy(dest, source, width * 4);
-    }
-}
-
-void Image::loadRGBA4444DataToBGRA(GLsizei width, GLsizei height,
-                                   int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        for (int x = 0; x &lt; width; x++)
-        {
-            unsigned short rgba = source[x];
-            dest[4 * x + 0] = ((rgba &amp; 0x00F0) &lt;&lt; 0) | ((rgba &amp; 0x00F0) &gt;&gt; 4);
-            dest[4 * x + 1] = ((rgba &amp; 0x0F00) &gt;&gt; 4) | ((rgba &amp; 0x0F00) &gt;&gt; 8);
-            dest[4 * x + 2] = ((rgba &amp; 0xF000) &gt;&gt; 8) | ((rgba &amp; 0xF000) &gt;&gt; 12);
-            dest[4 * x + 3] = ((rgba &amp; 0x000F) &lt;&lt; 4) | ((rgba &amp; 0x000F) &gt;&gt; 0);
-        }
-    }
-}
-
-void Image::loadRGBA4444DataToRGBA(GLsizei width, GLsizei height,
-                                   int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        for (int x = 0; x &lt; width; x++)
-        {
-            unsigned short rgba = source[x];
-            dest[4 * x + 0] = ((rgba &amp; 0xF000) &gt;&gt; 8) | ((rgba &amp; 0xF000) &gt;&gt; 12);
-            dest[4 * x + 1] = ((rgba &amp; 0x0F00) &gt;&gt; 4) | ((rgba &amp; 0x0F00) &gt;&gt; 8);
-            dest[4 * x + 2] = ((rgba &amp; 0x00F0) &lt;&lt; 0) | ((rgba &amp; 0x00F0) &gt;&gt; 4);
-            dest[4 * x + 3] = ((rgba &amp; 0x000F) &lt;&lt; 4) | ((rgba &amp; 0x000F) &gt;&gt; 0);
-        }
-    }
-}
-
-void Image::loadRGBA5551DataToBGRA(GLsizei width, GLsizei height,
-                                   int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        for (int x = 0; x &lt; width; x++)
-        {
-            unsigned short rgba = source[x];
-            dest[4 * x + 0] = ((rgba &amp; 0x003E) &lt;&lt; 2) | ((rgba &amp; 0x003E) &gt;&gt; 3);
-            dest[4 * x + 1] = ((rgba &amp; 0x07C0) &gt;&gt; 3) | ((rgba &amp; 0x07C0) &gt;&gt; 8);
-            dest[4 * x + 2] = ((rgba &amp; 0xF800) &gt;&gt; 8) | ((rgba &amp; 0xF800) &gt;&gt; 13);
-            dest[4 * x + 3] = (rgba &amp; 0x0001) ? 0xFF : 0;
-        }
-    }
-}
-
-void Image::loadRGBA5551DataToRGBA(GLsizei width, GLsizei height,
-                                   int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned short *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const unsigned short*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        for (int x = 0; x &lt; width; x++)
-        {
-            unsigned short rgba = source[x];
-            dest[4 * x + 0] = ((rgba &amp; 0xF800) &gt;&gt; 8) | ((rgba &amp; 0xF800) &gt;&gt; 13);
-            dest[4 * x + 1] = ((rgba &amp; 0x07C0) &gt;&gt; 3) | ((rgba &amp; 0x07C0) &gt;&gt; 8);
-            dest[4 * x + 2] = ((rgba &amp; 0x003E) &lt;&lt; 2) | ((rgba &amp; 0x003E) &gt;&gt; 3);
-            dest[4 * x + 3] = (rgba &amp; 0x0001) ? 0xFF : 0;
-        }
-    }
-}
-
-void Image::loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height,
-                                    int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const float *source = NULL;
-    float *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = reinterpret_cast&lt;const float*&gt;(static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch);
-        dest = reinterpret_cast&lt;float*&gt;(static_cast&lt;unsigned char*&gt;(output) + y * outputPitch);
-        memcpy(dest, source, width * 16);
-    }
-}
-
-void Image::loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                        int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned char *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch;
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        memcpy(dest, source, width * 8);
-    }
-}
-
-void Image::loadBGRADataToBGRA(GLsizei width, GLsizei height,
-                               int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned char *source = NULL;
-    unsigned char *dest = NULL;
-
-    for (int y = 0; y &lt; height; y++)
-    {
-        source = static_cast&lt;const unsigned char*&gt;(input) + y * inputPitch;
-        dest = static_cast&lt;unsigned char*&gt;(output) + y * outputPitch;
-        memcpy(dest, source, width*4);
-    }
-}
-
-}
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Image.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Image.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Image.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -23,6 +23,8 @@
</span><span class="cx"> class Renderer;
</span><span class="cx"> class TextureStorageInterface2D;
</span><span class="cx"> class TextureStorageInterfaceCube;
</span><ins>+class TextureStorageInterface3D;
+class TextureStorageInterface2DArray;
</ins><span class="cx"> 
</span><span class="cx"> class Image
</span><span class="cx"> {
</span><span class="lines">@@ -32,8 +34,11 @@
</span><span class="cx"> 
</span><span class="cx">     GLsizei getWidth() const { return mWidth; }
</span><span class="cx">     GLsizei getHeight() const { return mHeight; }
</span><ins>+    GLsizei getDepth() const { return mDepth; }
</ins><span class="cx">     GLenum getInternalFormat() const { return mInternalFormat; }
</span><span class="cx">     GLenum getActualFormat() const { return mActualFormat; }
</span><ins>+    GLenum getTarget() const { return mTarget; }
+    bool isRenderableFormat() const { return mRenderable; }
</ins><span class="cx"> 
</span><span class="cx">     void markDirty() {mDirty = true;}
</span><span class="cx">     void markClean() {mDirty = false;}
</span><span class="lines">@@ -41,84 +46,30 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void setManagedSurface(TextureStorageInterface2D *storage, int level) {};
</span><span class="cx">     virtual void setManagedSurface(TextureStorageInterfaceCube *storage, int face, int level) {};
</span><del>-    virtual bool updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
-    virtual bool updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
</del><ins>+    virtual void setManagedSurface(TextureStorageInterface3D *storage, int level) {};
+    virtual void setManagedSurface(TextureStorageInterface2DArray *storage, int layer, int level) {};
+    virtual bool copyToStorage(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
+    virtual bool copyToStorage(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
+    virtual bool copyToStorage(TextureStorageInterface3D *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) = 0;
+    virtual bool copyToStorage(TextureStorageInterface2DArray *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height) = 0;
</ins><span class="cx"> 
</span><del>-    virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease) = 0;
</del><ins>+    virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) = 0;
</ins><span class="cx"> 
</span><del>-    virtual bool isRenderableFormat() const = 0;
-    
-    virtual void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
-                  GLint unpackAlignment, const void *input) = 0;
-    virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
</del><ins>+    virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                          GLint unpackAlignment, GLenum type, const void *input) = 0;
+    virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
</ins><span class="cx">                                     const void *input) = 0;
</span><span class="cx"> 
</span><del>-    virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
</del><ins>+    virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
</ins><span class="cx"> 
</span><del>-    static void loadAlphaDataToBGRA(GLsizei width, GLsizei height,
-                                    int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadAlphaDataToNative(GLsizei width, GLsizei height,
-                                      int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height,
-                                        int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height,
-                                         int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                             int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height,
-                                        int inputPitch, const void *input, size_t outputPitch, void *output, bool native);
-    static void loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height,
-                                             int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height,
-                                            int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                                 int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height,
-                                             int inputPitch, const void *input, size_t outputPitch, void *output, bool native);
-    static void loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height,
-                                                  int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                                      int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBUByteDataToBGRX(GLsizei width, GLsizei height,
-                                       int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBUByteDataToRGBA(GLsizei width, GLsizei height,
-                                       int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGB565DataToBGRA(GLsizei width, GLsizei height,
-                                     int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGB565DataToRGBA(GLsizei width, GLsizei height,
-                                     int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBFloatDataToRGBA(GLsizei width, GLsizei height,
-                                       int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBFloatDataToNative(GLsizei width, GLsizei height,
-                                         int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                           int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height,
-                                            int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height,
-                                        int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBAUByteDataToNative(GLsizei width, GLsizei height,
-                                          int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBA4444DataToBGRA(GLsizei width, GLsizei height,
-                                       int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBA4444DataToRGBA(GLsizei width, GLsizei height,
-                                       int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBA5551DataToBGRA(GLsizei width, GLsizei height,
-                                       int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBA5551DataToRGBA(GLsizei width, GLsizei height,
-                                       int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height,
-                                        int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height,
-                                            int inputPitch, const void *input, size_t outputPitch, void *output);
-    static void loadBGRADataToBGRA(GLsizei width, GLsizei height,
-                                   int inputPitch, const void *input, size_t outputPitch, void *output);
-
</del><span class="cx">   protected:
</span><span class="cx">     GLsizei mWidth;
</span><span class="cx">     GLsizei mHeight;
</span><del>-    GLint mInternalFormat;
</del><ins>+    GLsizei mDepth;
+    GLenum mInternalFormat;
</ins><span class="cx">     GLenum mActualFormat;
</span><ins>+    bool mRenderable;
+    GLenum mTarget;
</ins><span class="cx"> 
</span><span class="cx">     bool mDirty;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererIndexBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexBuffer.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexBuffer.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexBuffer.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -194,4 +194,3 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span><del>-
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererIndexDataManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexDataManager.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexDataManager.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexDataManager.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/Buffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;libGLESv2/formatutils.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/IndexBuffer.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">           default: UNREACHABLE(); alignedOffset = false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        unsigned int typeSize = gl::ComputeTypeSize(type);
</del><ins>+        unsigned int typeSize = gl::GetTypeBytes(type);
</ins><span class="cx"> 
</span><span class="cx">         // check for integer overflows
</span><span class="cx">         if (static_cast&lt;unsigned int&gt;(count) &gt; (std::numeric_limits&lt;unsigned int&gt;::max() / typeSize) ||
</span><span class="lines">@@ -167,7 +167,6 @@
</span><span class="cx">     {
</span><span class="cx">         indexBuffer = streamingBuffer;
</span><span class="cx">         streamOffset = offset;
</span><del>-        storage-&gt;markBufferUsage();
</del><span class="cx"> 
</span><span class="cx">         if (!buffer-&gt;getIndexRangeCache()-&gt;findRange(type, offset, count, &amp;translated-&gt;minIndex,
</span><span class="cx">                                                      &amp;translated-&gt;maxIndex, NULL))
</span><span class="lines">@@ -180,10 +179,11 @@
</span><span class="cx">     else if (staticBuffer &amp;&amp; staticBuffer-&gt;getBufferSize() != 0 &amp;&amp; staticBuffer-&gt;getIndexType() == type &amp;&amp; alignedOffset)
</span><span class="cx">     {
</span><span class="cx">         indexBuffer = staticBuffer;
</span><ins>+
</ins><span class="cx">         if (!staticBuffer-&gt;getIndexRangeCache()-&gt;findRange(type, offset, count, &amp;translated-&gt;minIndex,
</span><span class="cx">                                                            &amp;translated-&gt;maxIndex, &amp;streamOffset))
</span><span class="cx">         {
</span><del>-            streamOffset = (offset / gl::ComputeTypeSize(type)) * gl::ComputeTypeSize(destinationIndexType);
</del><ins>+            streamOffset = (offset / gl::GetTypeBytes(type)) * gl::GetTypeBytes(destinationIndexType);
</ins><span class="cx">             computeRange(type, indices, count, &amp;translated-&gt;minIndex, &amp;translated-&gt;maxIndex);
</span><span class="cx">             staticBuffer-&gt;getIndexRangeCache()-&gt;addRange(type, offset, count, translated-&gt;minIndex,
</span><span class="cx">                                                          translated-&gt;maxIndex, streamOffset);
</span><span class="lines">@@ -198,7 +198,7 @@
</span><span class="cx">             if (staticBuffer-&gt;getBufferSize() == 0 &amp;&amp; alignedOffset)
</span><span class="cx">             {
</span><span class="cx">                 indexBuffer = staticBuffer;
</span><del>-                convertCount = storage-&gt;getSize() / gl::ComputeTypeSize(type);
</del><ins>+                convertCount = storage-&gt;getSize() / gl::GetTypeBytes(type);
</ins><span class="cx">             }
</span><span class="cx">             else
</span><span class="cx">             {
</span><span class="lines">@@ -213,7 +213,7 @@
</span><span class="cx">             return GL_INVALID_OPERATION;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        unsigned int indexTypeSize = gl::ComputeTypeSize(destinationIndexType);
</del><ins>+        unsigned int indexTypeSize = gl::GetTypeBytes(destinationIndexType);
</ins><span class="cx">         if (convertCount &gt; std::numeric_limits&lt;unsigned int&gt;::max() / indexTypeSize)
</span><span class="cx">         {
</span><span class="cx">             ERR(&quot;Reserving %u indicies of %u bytes each exceeds the maximum buffer size.&quot;, convertCount, indexTypeSize);
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (staticBuffer)
</span><span class="cx">         {
</span><del>-            streamOffset = (offset / gl::ComputeTypeSize(type)) * gl::ComputeTypeSize(destinationIndexType);
</del><ins>+            streamOffset = (offset / gl::GetTypeBytes(type)) * gl::GetTypeBytes(destinationIndexType);
</ins><span class="cx">             staticBuffer-&gt;getIndexRangeCache()-&gt;addRange(type, offset, count, translated-&gt;minIndex,
</span><span class="cx">                                                          translated-&gt;maxIndex, streamOffset);
</span><span class="cx">         }
</span><span class="lines">@@ -255,12 +255,12 @@
</span><span class="cx">     translated-&gt;storage = directStorage ? storage : NULL;
</span><span class="cx">     translated-&gt;indexBuffer = indexBuffer-&gt;getIndexBuffer();
</span><span class="cx">     translated-&gt;serial = directStorage ? storage-&gt;getSerial() : indexBuffer-&gt;getSerial();
</span><del>-    translated-&gt;startIndex = streamOffset / gl::ComputeTypeSize(destinationIndexType);
</del><ins>+    translated-&gt;startIndex = streamOffset / gl::GetTypeBytes(destinationIndexType);
</ins><span class="cx">     translated-&gt;startOffset = streamOffset;
</span><span class="cx"> 
</span><span class="cx">     if (buffer)
</span><span class="cx">     {
</span><del>-        buffer-&gt;promoteStaticUsage(count * gl::ComputeTypeSize(type));
</del><ins>+        buffer-&gt;promoteStaticUsage(count * gl::GetTypeBytes(type));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return GL_NO_ERROR;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererIndexRangeCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexRangeCache.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexRangeCache.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexRangeCache.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -9,8 +9,8 @@
</span><span class="cx"> // ranges of indices.
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/IndexRangeCache.h&quot;
</span><ins>+#include &quot;libGLESv2/formatutils.h&quot;
</ins><span class="cx"> #include &quot;common/debug.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><span class="cx"> #include &lt;tuple&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx">     while (i != mIndexRangeCache.end())
</span><span class="cx">     {
</span><span class="cx">         unsigned int rangeStart = i-&gt;second.streamOffset;
</span><del>-        unsigned int rangeEnd = i-&gt;second.streamOffset + (gl::ComputeTypeSize(i-&gt;first.type) * i-&gt;first.count);
</del><ins>+        unsigned int rangeEnd = i-&gt;second.streamOffset + (gl::GetTypeBytes(i-&gt;first.type) * i-&gt;first.count);
</ins><span class="cx"> 
</span><span class="cx">         if (invalidateEnd &lt; rangeStart || invalidateStart &gt; rangeEnd)
</span><span class="cx">         {
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererIndexRangeCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexRangeCache.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexRangeCache.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/IndexRangeCache.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -11,6 +11,7 @@
</span><span class="cx"> #define LIBGLESV2_RENDERER_INDEXRANGECACHE_H_
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><ins>+#include &lt;map&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererRenderTargeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/RenderTarget.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/RenderTarget.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/RenderTarget.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -11,6 +11,7 @@
</span><span class="cx"> #define LIBGLESV2_RENDERER_RENDERTARGET_H_
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><ins>+#include &quot;libGLESv2/angletypes.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -21,6 +22,7 @@
</span><span class="cx">     {
</span><span class="cx">         mWidth = 0;
</span><span class="cx">         mHeight = 0;
</span><ins>+        mDepth = 0;
</ins><span class="cx">         mInternalFormat = GL_NONE;
</span><span class="cx">         mActualFormat = GL_NONE;
</span><span class="cx">         mSamples = 0;
</span><span class="lines">@@ -28,21 +30,27 @@
</span><span class="cx"> 
</span><span class="cx">     virtual ~RenderTarget() {};
</span><span class="cx"> 
</span><del>-    GLsizei getWidth() { return mWidth; }
-    GLsizei getHeight() { return mHeight; }
-    GLenum getInternalFormat() { return mInternalFormat; }
-    GLenum getActualFormat() { return mActualFormat; }
-    GLsizei getSamples() { return mSamples; }
-    
</del><ins>+    GLsizei getWidth() const { return mWidth; }
+    GLsizei getHeight() const { return mHeight; }
+    GLsizei getDepth() const { return mDepth; }
+    GLenum getInternalFormat() const { return mInternalFormat; }
+    GLenum getActualFormat() const { return mActualFormat; }
+    GLsizei getSamples() const { return mSamples; }
+    gl::Extents getExtents() const { return gl::Extents(mWidth, mHeight, mDepth); }
+
+    virtual void invalidate(GLint x, GLint y, GLsizei width, GLsizei height) = 0;
+
</ins><span class="cx">     struct Desc {
</span><span class="cx">         GLsizei width;
</span><span class="cx">         GLsizei height;
</span><ins>+        GLsizei depth;
</ins><span class="cx">         GLenum  format;
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">   protected:
</span><span class="cx">     GLsizei mWidth;
</span><span class="cx">     GLsizei mHeight;
</span><ins>+    GLsizei mDepth;
</ins><span class="cx">     GLenum mInternalFormat;
</span><span class="cx">     GLenum mActualFormat;
</span><span class="cx">     GLsizei mSamples;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererRenderercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Renderer.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Renderer.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Renderer.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -11,14 +11,21 @@
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Program.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><ins>+#include &quot;common/utilities.h&quot;
+#include &quot;third_party/trace_event/trace_event.h&quot;
+#include &quot;libGLESv2/Shader.h&quot;
+
+#if defined (ANGLE_ENABLE_D3D9)
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/Renderer9.h&quot;
</span><ins>+#endif // ANGLE_ENABLE_D3D9
+
+#if defined (ANGLE_ENABLE_D3D11)
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Renderer11.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
-#include &quot;third_party/trace_event/trace_event.h&quot;
</del><ins>+#endif // ANGLE_ENABLE_D3D11
</ins><span class="cx"> 
</span><del>-#if !defined(ANGLE_ENABLE_D3D11)
</del><ins>+#if !defined(ANGLE_DEFAULT_D3D11)
</ins><span class="cx"> // Enables use of the Direct3D 11 API for a default display, when available
</span><del>-#define ANGLE_ENABLE_D3D11 0
</del><ins>+#define ANGLE_DEFAULT_D3D11 0
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="lines">@@ -26,194 +33,55 @@
</span><span class="cx"> 
</span><span class="cx"> Renderer::Renderer(egl::Display *display) : mDisplay(display)
</span><span class="cx"> {
</span><del>-    mD3dCompilerModule = NULL;
-    mD3DCompileFunc = NULL;
</del><ins>+    mCurrentClientVersion = 2;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Renderer::~Renderer()
</span><span class="cx"> {
</span><del>-    if (mD3dCompilerModule)
-    {
-        FreeLibrary(mD3dCompilerModule);
-        mD3dCompilerModule = NULL;
-    }
</del><ins>+    gl::Shader::releaseCompiler();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer::initializeCompiler()
-{
-    TRACE_EVENT0(&quot;gpu&quot;, &quot;initializeCompiler&quot;);
-#if defined(ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES)
-    // Find a D3DCompiler module that had already been loaded based on a predefined list of versions.
-    static TCHAR* d3dCompilerNames[] = ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES;
-
-    for (size_t i = 0; i &lt; ArraySize(d3dCompilerNames); ++i)
-    {
-        if (GetModuleHandleEx(0, d3dCompilerNames[i], &amp;mD3dCompilerModule))
-        {
-            break;
-        }
-    }
-#endif  // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
-
-    if (!mD3dCompilerModule)
-    {
-        // Load the version of the D3DCompiler DLL associated with the Direct3D version ANGLE was built with.
-        mD3dCompilerModule = LoadLibrary(D3DCOMPILER_DLL);
-    }
-
-    if (!mD3dCompilerModule)
-    {
-        ERR(&quot;No D3D compiler module found - aborting!\n&quot;);
-        return false;
-    }
-
-    mD3DCompileFunc = reinterpret_cast&lt;pCompileFunc&gt;(GetProcAddress(mD3dCompilerModule, &quot;D3DCompile&quot;));
-    ASSERT(mD3DCompileFunc);
-
-    return mD3DCompileFunc != NULL;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Compiles HLSL code into executable binaries
-ShaderBlob *Renderer::compileToBinary(gl::InfoLog &amp;infoLog, const char *hlsl, const char *profile, UINT optimizationFlags, bool alternateFlags)
</del><ins>+extern &quot;C&quot;
</ins><span class="cx"> {
</span><del>-    if (!hlsl)
-    {
-        return NULL;
-    }
</del><span class="cx"> 
</span><del>-    HRESULT result = S_OK;
-    UINT flags = 0;
-    std::string sourceText;
-    if (gl::perfActive())
</del><ins>+rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, EGLNativeDisplayType displayId)
+{
+#if defined(ANGLE_ENABLE_D3D11)
+    if (ANGLE_DEFAULT_D3D11 ||
+        displayId == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
+        displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
</ins><span class="cx">     {
</span><del>-        flags |= D3DCOMPILE_DEBUG;
-
-#ifdef NDEBUG
-        flags |= optimizationFlags;
-#else
-        flags |= D3DCOMPILE_SKIP_OPTIMIZATION;
-#endif
-
-        std::string sourcePath = getTempPath();
-        sourceText = std::string(&quot;#line 2 \&quot;&quot;) + sourcePath + std::string(&quot;\&quot;\n\n&quot;) + std::string(hlsl);
-        writeFile(sourcePath.c_str(), sourceText.c_str(), sourceText.size());
-    }
-    else
-    {
-        flags |= optimizationFlags;
-        sourceText = hlsl;
-    }
-
-    // Sometimes D3DCompile will fail with the default compilation flags for complicated shaders when it would otherwise pass with alternative options.
-    // Try the default flags first and if compilation fails, try some alternatives.
-    const static UINT extraFlags[] =
-    {
-        0,
-        D3DCOMPILE_AVOID_FLOW_CONTROL,
-        D3DCOMPILE_PREFER_FLOW_CONTROL
-    };
-
-    const static char * const extraFlagNames[] =
-    {
-        &quot;default&quot;,
-        &quot;avoid flow control&quot;,
-        &quot;prefer flow control&quot;
-    };
-
-    int attempts = alternateFlags ? ArraySize(extraFlags) : 1;
-    pD3DCompile compileFunc = reinterpret_cast&lt;pD3DCompile&gt;(mD3DCompileFunc);
-    for (int i = 0; i &lt; attempts; ++i)
-    {
-        ID3DBlob *errorMessage = NULL;
-        ID3DBlob *binary = NULL;
-
-        result = compileFunc(hlsl, strlen(hlsl), gl::g_fakepath, NULL, NULL,
-                             &quot;main&quot;, profile, flags | extraFlags[i], 0, &amp;binary, &amp;errorMessage);
-        if (errorMessage)
</del><ins>+        rx::Renderer11 *renderer = new rx::Renderer11(display, hDc);
+        if (renderer-&gt;initialize() == EGL_SUCCESS)
</ins><span class="cx">         {
</span><del>-            const char *message = (const char*)errorMessage-&gt;GetBufferPointer();
-
-            infoLog.appendSanitized(message);
-            TRACE(&quot;\n%s&quot;, hlsl);
-            TRACE(&quot;\n%s&quot;, message);
-
-            errorMessage-&gt;Release();
-            errorMessage = NULL;
</del><ins>+            return renderer;
</ins><span class="cx">         }
</span><del>-
-        if (SUCCEEDED(result))
-        {
-            return (ShaderBlob*)binary;
-        }
</del><span class="cx">         else
</span><span class="cx">         {
</span><del>-            if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
-            {
-                return gl::error(GL_OUT_OF_MEMORY, (ShaderBlob*) NULL);
-            }
-
-            infoLog.append(&quot;Warning: D3D shader compilation failed with &quot;);
-            infoLog.append(extraFlagNames[i]);
-            infoLog.append(&quot; flags.&quot;);
-            if (i + 1 &lt; attempts)
-            {
-                infoLog.append(&quot; Retrying with &quot;);
-                infoLog.append(extraFlagNames[i + 1]);
-                infoLog.append(&quot;.\n&quot;);
-            }
</del><ins>+            // Failed to create a D3D11 renderer, try D3D9
+            SafeDelete(renderer);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><ins>+#endif
</ins><span class="cx"> 
</span><del>-    return NULL;
-}
-
-}
-
-extern &quot;C&quot;
-{
-
-rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, EGLNativeDisplayType displayId)
-{
-    rx::Renderer *renderer = NULL;
-    EGLint status = EGL_BAD_ALLOC;
-    
-    if (ANGLE_ENABLE_D3D11 ||
-        displayId == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
-        displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
</del><ins>+#if defined(ANGLE_ENABLE_D3D9)
+    if (displayId != EGL_D3D11_ONLY_DISPLAY_ANGLE)
</ins><span class="cx">     {
</span><del>-        renderer = new rx::Renderer11(display, hDc);
-    
-        if (renderer)
</del><ins>+        bool softwareDevice = (displayId == EGL_SOFTWARE_DISPLAY_ANGLE);
+        rx::Renderer9 *renderer = new rx::Renderer9(display, hDc, softwareDevice);
+        if (renderer-&gt;initialize() == EGL_SUCCESS)
</ins><span class="cx">         {
</span><del>-            status = renderer-&gt;initialize();
-        }
-
-        if (status == EGL_SUCCESS)
-        {
</del><span class="cx">             return renderer;
</span><span class="cx">         }
</span><del>-        else if (displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
</del><ins>+        else
</ins><span class="cx">         {
</span><del>-            return NULL;
</del><ins>+            SafeDelete(renderer);
</ins><span class="cx">         }
</span><del>-
-        // Failed to create a D3D11 renderer, try creating a D3D9 renderer
-        delete renderer;
</del><span class="cx">     }
</span><ins>+#endif
</ins><span class="cx"> 
</span><del>-    bool softwareDevice = (displayId == EGL_SOFTWARE_DISPLAY_ANGLE);
-    renderer = new rx::Renderer9(display, hDc, softwareDevice);
-    
-    if (renderer)
-    {
-        status = renderer-&gt;initialize();
-    }
-
-    if (status == EGL_SUCCESS)
-    {
-        return renderer;
-    }
-
</del><span class="cx">     return NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -222,4 +90,4 @@
</span><span class="cx">     delete renderer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererRendererh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Renderer.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Renderer.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/Renderer.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -14,7 +14,9 @@
</span><span class="cx"> #include &quot;libGLESv2/angletypes.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL)
</span><del>-#define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL3
</del><ins>+// WARNING: D3DCOMPILE_OPTIMIZATION_LEVEL3 may lead to a DX9 shader compiler hang.
+// It should only be used selectively to work around specific bugs.
+#define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL1
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> const int versionWindowsVista = MAKEWORD(0x00, 0x06);
</span><span class="lines">@@ -39,38 +41,40 @@
</span><span class="cx"> {
</span><span class="cx"> class InfoLog;
</span><span class="cx"> class ProgramBinary;
</span><ins>+struct LinkedVarying;
</ins><span class="cx"> class VertexAttribute;
</span><span class="cx"> class Buffer;
</span><span class="cx"> class Texture;
</span><span class="cx"> class Framebuffer;
</span><ins>+struct VertexAttribCurrentValueData;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> class TextureStorageInterface2D;
</span><span class="cx"> class TextureStorageInterfaceCube;
</span><ins>+class TextureStorageInterface3D;
+class TextureStorageInterface2DArray;
</ins><span class="cx"> class VertexBuffer;
</span><span class="cx"> class IndexBuffer;
</span><span class="cx"> class QueryImpl;
</span><span class="cx"> class FenceImpl;
</span><span class="cx"> class BufferStorage;
</span><del>-class Blit;
</del><span class="cx"> struct TranslatedIndexData;
</span><span class="cx"> class ShaderExecutable;
</span><span class="cx"> class SwapChain;
</span><span class="cx"> class RenderTarget;
</span><span class="cx"> class Image;
</span><span class="cx"> class TextureStorage;
</span><ins>+class UniformStorage;
</ins><span class="cx"> 
</span><del>-typedef void * ShaderBlob;
-typedef void (*pCompileFunc)();
-
</del><span class="cx"> struct ConfigDesc
</span><span class="cx"> {
</span><span class="cx">     GLenum  renderTargetFormat;
</span><span class="cx">     GLenum  depthStencilFormat;
</span><span class="cx">     GLint   multiSample;
</span><span class="cx">     bool    fastConfig;
</span><ins>+    bool    es3Capable;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct dx_VertexConstants
</span><span class="lines">@@ -93,12 +97,6 @@
</span><span class="cx">     SHADER_GEOMETRY
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-enum D3DWorkaroundType
-{
-    ANGLE_D3D_WORKAROUND_NONE,
-    ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER
-};
-
</del><span class="cx"> class Renderer
</span><span class="cx"> {
</span><span class="cx">   public:
</span><span class="lines">@@ -115,11 +113,14 @@
</span><span class="cx"> 
</span><span class="cx">     virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0;
</span><span class="cx"> 
</span><ins>+    virtual void generateSwizzle(gl::Texture *texture) = 0;
</ins><span class="cx">     virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &amp;sampler) = 0;
</span><span class="cx">     virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0;
</span><span class="cx"> 
</span><ins>+    virtual bool setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]) = 0;
+
</ins><span class="cx">     virtual void setRasterizerState(const gl::RasterizerState &amp;rasterState) = 0;
</span><del>-    virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::Color &amp;blendColor,
</del><ins>+    virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::ColorF &amp;blendColor,
</ins><span class="cx">                                unsigned int sampleMask) = 0;
</span><span class="cx">     virtual void setDepthStencilState(const gl::DepthStencilState &amp;depthStencilState, int stencilRef,
</span><span class="cx">                                       int stencilBackRef, bool frontFaceCCW) = 0;
</span><span class="lines">@@ -129,14 +130,17 @@
</span><span class="cx">                              bool ignoreViewport) = 0;
</span><span class="cx"> 
</span><span class="cx">     virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer) = 0;
</span><del>-    virtual void applyShaders(gl::ProgramBinary *programBinary) = 0;
-    virtual void applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray *uniformArray) = 0;
</del><ins>+    virtual void applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[]) = 0;
+    virtual void applyUniforms(const gl::ProgramBinary &amp;programBinary) = 0;
</ins><span class="cx">     virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0;
</span><del>-    virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances) = 0;
</del><ins>+    virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
+                                     GLint first, GLsizei count, GLsizei instances) = 0;
</ins><span class="cx">     virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) = 0;
</span><ins>+    virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]) = 0;
</ins><span class="cx"> 
</span><del>-    virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances) = 0;
-    virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei instances) = 0;
</del><ins>+    virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive) = 0;
+    virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
+                              gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei instances) = 0;
</ins><span class="cx"> 
</span><span class="cx">     virtual void clear(const gl::ClearParameters &amp;clearParams, gl::Framebuffer *frameBuffer) = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -154,14 +158,20 @@
</span><span class="cx">     virtual GUID getAdapterIdentifier() const = 0;
</span><span class="cx"> 
</span><span class="cx">     virtual bool getBGRATextureSupport() const = 0;
</span><del>-    virtual bool getDXT1TextureSupport() = 0;
-    virtual bool getDXT3TextureSupport() = 0;
-    virtual bool getDXT5TextureSupport() = 0;
-    virtual bool getEventQuerySupport() = 0;
-    virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable) = 0;
-    virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable) = 0;
-    virtual bool getLuminanceTextureSupport() = 0;
-    virtual bool getLuminanceAlphaTextureSupport() = 0;
</del><ins>+    virtual bool getDXT1TextureSupport() const = 0;
+    virtual bool getDXT3TextureSupport() const = 0;
+    virtual bool getDXT5TextureSupport() const = 0;
+    virtual bool getEventQuerySupport() const = 0;
+    virtual bool getFloat32TextureSupport() const = 0;
+    virtual bool getFloat32TextureFilteringSupport() const= 0;
+    virtual bool getFloat32TextureRenderingSupport() const= 0;
+    virtual bool getFloat16TextureSupport()  const= 0;
+    virtual bool getFloat16TextureFilteringSupport() const= 0;
+    virtual bool getFloat16TextureRenderingSupport() const = 0;
+    virtual bool getRGB565TextureSupport() const = 0;
+    virtual bool getLuminanceTextureSupport() const = 0;
+    virtual bool getLuminanceAlphaTextureSupport() const = 0;
+    virtual bool getRGTextureSupport() const = 0;
</ins><span class="cx">     bool getVertexTextureSupport() const { return getMaxVertexTextureImageUnits() &gt; 0; }
</span><span class="cx">     virtual unsigned int getMaxVertexTextureImageUnits() const = 0;
</span><span class="cx">     virtual unsigned int getMaxCombinedTextureImageUnits() const = 0;
</span><span class="lines">@@ -170,57 +180,86 @@
</span><span class="cx">     virtual unsigned int getMaxVertexUniformVectors() const = 0;
</span><span class="cx">     virtual unsigned int getMaxFragmentUniformVectors() const = 0;
</span><span class="cx">     virtual unsigned int getMaxVaryingVectors() const = 0;
</span><ins>+    virtual unsigned int getMaxVertexShaderUniformBuffers() const = 0;
+    virtual unsigned int getMaxFragmentShaderUniformBuffers() const = 0;
+    virtual unsigned int getReservedVertexUniformBuffers() const = 0;
+    virtual unsigned int getReservedFragmentUniformBuffers() const = 0;
+    virtual unsigned int getMaxTransformFeedbackBuffers() const = 0;
+    virtual unsigned int getMaxTransformFeedbackSeparateComponents() const = 0;
+    virtual unsigned int getMaxTransformFeedbackInterleavedComponents() const = 0;
+    virtual unsigned int getMaxUniformBufferSize() const = 0;
</ins><span class="cx">     virtual bool getNonPower2TextureSupport() const = 0;
</span><span class="cx">     virtual bool getDepthTextureSupport() const = 0;
</span><span class="cx">     virtual bool getOcclusionQuerySupport() const = 0;
</span><span class="cx">     virtual bool getInstancingSupport() const = 0;
</span><span class="cx">     virtual bool getTextureFilterAnisotropySupport() const = 0;
</span><ins>+    virtual bool getPBOSupport() const = 0;
</ins><span class="cx">     virtual float getTextureMaxAnisotropy() const = 0;
</span><span class="cx">     virtual bool getShareHandleSupport() const = 0;
</span><span class="cx">     virtual bool getDerivativeInstructionSupport() const = 0;
</span><span class="cx">     virtual bool getPostSubBufferSupport() const = 0;
</span><ins>+    virtual int getMaxRecommendedElementsIndices() const = 0;
+    virtual int getMaxRecommendedElementsVertices() const = 0;
</ins><span class="cx"> 
</span><span class="cx">     virtual int getMajorShaderModel() const = 0;
</span><span class="cx">     virtual float getMaxPointSize() const = 0;
</span><span class="cx">     virtual int getMaxViewportDimension() const = 0;
</span><span class="cx">     virtual int getMaxTextureWidth() const = 0;
</span><span class="cx">     virtual int getMaxTextureHeight() const = 0;
</span><ins>+    virtual int getMaxTextureDepth() const = 0;
+    virtual int getMaxTextureArrayLayers() const = 0;
</ins><span class="cx">     virtual bool get32BitIndexSupport() const = 0;
</span><span class="cx">     virtual int getMinSwapInterval() const = 0;
</span><span class="cx">     virtual int getMaxSwapInterval() const = 0;
</span><span class="cx"> 
</span><span class="cx">     virtual GLsizei getMaxSupportedSamples() const = 0;
</span><ins>+    virtual GLsizei getMaxSupportedFormatSamples(GLenum internalFormat) const = 0;
+    virtual GLsizei getNumSampleCounts(GLenum internalFormat) const = 0;
+    virtual void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const = 0;
</ins><span class="cx"> 
</span><span class="cx">     virtual unsigned int getMaxRenderTargets() const = 0;
</span><span class="cx"> 
</span><span class="cx">     // Pixel operations
</span><span class="cx">     virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source) = 0;
</span><span class="cx">     virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source) = 0;
</span><ins>+    virtual bool copyToRenderTarget(TextureStorageInterface3D *dest, TextureStorageInterface3D *source) = 0;
+    virtual bool copyToRenderTarget(TextureStorageInterface2DArray *dest, TextureStorageInterface2DArray *source) = 0;
</ins><span class="cx"> 
</span><span class="cx">     virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
</span><span class="cx">                            GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level) = 0;
</span><span class="cx">     virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
</span><span class="cx">                            GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level) = 0;
</span><ins>+    virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                           GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface3D *storage, GLint level) = 0;
+    virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                           GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface2DArray *storage, GLint level) = 0;
</ins><span class="cx"> 
</span><span class="cx">     virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &amp;readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &amp;drawRect,
</span><del>-                          bool blitRenderTarget, bool blitDepthStencil) = 0;
-    virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
-                            GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels) = 0;
</del><ins>+                          const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) = 0;
+    virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
+                            GLenum type, GLuint outputPitch, const gl::PixelPackState &amp;pack, void* pixels) = 0;
</ins><span class="cx"> 
</span><span class="cx">     // RenderTarget creation
</span><span class="cx">     virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0;
</span><del>-    virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth) = 0;
</del><ins>+    virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples) = 0;
</ins><span class="cx"> 
</span><span class="cx">     // Shader operations
</span><del>-    virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type) = 0;
-    virtual ShaderExecutable *compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround) = 0;
</del><ins>+    virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type,
+                                             const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                             bool separatedOutputBuffers) = 0;
+    virtual ShaderExecutable *compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type,
+                                                  const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                                  bool separatedOutputBuffers, D3DWorkaroundType workaround) = 0;
+    virtual UniformStorage *createUniformStorage(size_t storageSize) = 0;
</ins><span class="cx"> 
</span><span class="cx">     // Image operations
</span><span class="cx">     virtual Image *createImage() = 0;
</span><span class="cx">     virtual void generateMipmap(Image *dest, Image *source) = 0;
</span><span class="cx">     virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain) = 0;
</span><del>-    virtual TextureStorage *createTextureStorage2D(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height) = 0;
-    virtual TextureStorage *createTextureStorageCube(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size) = 0;
</del><ins>+    virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels) = 0;
+    virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels) = 0;
+    virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) = 0;
+    virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) = 0;
</ins><span class="cx"> 
</span><span class="cx">     // Buffer creation
</span><span class="cx">     virtual VertexBuffer *createVertexBuffer() = 0;
</span><span class="lines">@@ -231,19 +270,27 @@
</span><span class="cx">     virtual QueryImpl *createQuery(GLenum type) = 0;
</span><span class="cx">     virtual FenceImpl *createFence() = 0;
</span><span class="cx"> 
</span><ins>+    // Current GLES client version
+    void setCurrentClientVersion(int clientVersion) { mCurrentClientVersion = clientVersion; }
+    int getCurrentClientVersion() const { return mCurrentClientVersion; }
+
+    // Buffer-to-texture and Texture-to-buffer copies
+    virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const = 0;
+    virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &amp;unpack, unsigned int offset, RenderTarget *destRenderTarget,
+                                         GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &amp;destArea) = 0;
+
</ins><span class="cx">     virtual bool getLUID(LUID *adapterLuid) const = 0;
</span><ins>+    virtual GLenum getNativeTextureFormat(GLenum internalFormat) const = 0;
+    virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &amp;vertexFormat) const = 0;
+    virtual GLenum getVertexComponentType(const gl::VertexFormat &amp;vertexFormat) const = 0;
</ins><span class="cx"> 
</span><span class="cx">   protected:
</span><del>-    bool initializeCompiler();
-    ShaderBlob *compileToBinary(gl::InfoLog &amp;infoLog, const char *hlsl, const char *profile, UINT optimizationFlags, bool alternateFlags);
-
</del><span class="cx">     egl::Display *mDisplay;
</span><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Renderer);
</span><span class="cx"> 
</span><del>-    HMODULE mD3dCompilerModule;
-    pCompileFunc mD3DCompileFunc;
</del><ins>+    int mCurrentClientVersion;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererShaderExecutableh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/ShaderExecutable.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/ShaderExecutable.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/ShaderExecutable.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -11,6 +11,7 @@
</span><span class="cx"> #define LIBGLESV2_RENDERER_SHADEREXECUTABLE_H_
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><ins>+#include &quot;common/debug.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -46,6 +47,22 @@
</span><span class="cx">     const size_t mLength;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class UniformStorage
+{
+  public:
+    UniformStorage(size_t initialSize)
+        : mSize(initialSize)
+    {
+    }
+
+    virtual ~UniformStorage() {}
+
+    size_t size() const { return mSize; }
+
+  private:
+    size_t mSize;
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif // LIBGLESV2_RENDERER_SHADEREXECUTABLE9_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererTextureStoragecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/TextureStorage.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/TextureStorage.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/TextureStorage.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -15,6 +15,7 @@
</span><span class="cx"> #include &quot;libGLESv2/Texture.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/debug.h&quot;
</span><ins>+#include &quot;common/mathutil.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -36,7 +37,6 @@
</span><span class="cx">     return mInstance-&gt;isRenderTarget();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> bool TextureStorageInterface::isManaged() const
</span><span class="cx"> {
</span><span class="cx">     return mInstance-&gt;isManaged();
</span><span class="lines">@@ -52,36 +52,36 @@
</span><span class="cx">     return mCurrentTextureSerial++;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int TextureStorageInterface::getLodOffset() const
</del><ins>+int TextureStorageInterface::getTopLevel() const
</ins><span class="cx"> {
</span><del>-    return mInstance-&gt;getLodOffset();
</del><ins>+    return mInstance-&gt;getTopLevel();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
-int TextureStorageInterface::levelCount()
</del><ins>+int TextureStorageInterface::getLevelCount() const
</ins><span class="cx"> {
</span><del>-    return mInstance-&gt;levelCount();
</del><ins>+    return mInstance-&gt;getLevelCount();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, SwapChain *swapchain) 
-    : mRenderTargetSerial(gl::RenderbufferStorage::issueSerial())
</del><ins>+TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, SwapChain *swapchain)
</ins><span class="cx"> {
</span><ins>+    mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(1);
+
</ins><span class="cx">     mInstance = renderer-&gt;createTextureStorage2D(swapchain);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height)
-    : mRenderTargetSerial(gl::RenderbufferStorage::issueSerial())
</del><ins>+TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
</ins><span class="cx"> {
</span><del>-    mInstance = renderer-&gt;createTextureStorage2D(levels, internalformat, usage, forceRenderable, width, height);
</del><ins>+    mInstance = renderer-&gt;createTextureStorage2D(internalformat, renderTarget, width, height, levels);
+    mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(static_cast&lt;GLuint&gt;(mInstance-&gt;getLevelCount()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureStorageInterface2D::~TextureStorageInterface2D()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget *TextureStorageInterface2D::getRenderTarget() const
</del><ins>+RenderTarget *TextureStorageInterface2D::getRenderTarget(GLint level) const
</ins><span class="cx"> {
</span><del>-    return mInstance-&gt;getRenderTarget();
</del><ins>+    return mInstance-&gt;getRenderTarget(level);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureStorageInterface2D::generateMipmap(int level)
</span><span class="lines">@@ -89,34 +89,92 @@
</span><span class="cx">     mInstance-&gt;generateMipmap(level);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned int TextureStorageInterface2D::getRenderTargetSerial(GLenum target) const
</del><ins>+unsigned int TextureStorageInterface2D::getRenderTargetSerial(GLint level) const
</ins><span class="cx"> {
</span><del>-    return mRenderTargetSerial;
</del><ins>+    return mFirstRenderTargetSerial + level;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorageInterfaceCube::TextureStorageInterfaceCube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size)
-    : mFirstRenderTargetSerial(gl::RenderbufferStorage::issueCubeSerials())
</del><ins>+TextureStorageInterfaceCube::TextureStorageInterfaceCube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels)
</ins><span class="cx"> {
</span><del>-    mInstance = renderer-&gt;createTextureStorageCube(levels, internalformat, usage, forceRenderable, size);
</del><ins>+    mInstance = renderer-&gt;createTextureStorageCube(internalformat, renderTarget, size, levels);
+    mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(static_cast&lt;GLuint&gt;(mInstance-&gt;getLevelCount() * 6));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureStorageInterfaceCube::~TextureStorageInterfaceCube()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget *TextureStorageInterfaceCube::getRenderTarget(GLenum faceTarget) const
</del><ins>+RenderTarget *TextureStorageInterfaceCube::getRenderTarget(GLenum faceTarget, GLint level) const
</ins><span class="cx"> {
</span><del>-    return mInstance-&gt;getRenderTarget(faceTarget);
</del><ins>+    return mInstance-&gt;getRenderTargetFace(faceTarget, level);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureStorageInterfaceCube::generateMipmap(int face, int level)
</del><ins>+void TextureStorageInterfaceCube::generateMipmap(int faceIndex, int level)
</ins><span class="cx"> {
</span><del>-    mInstance-&gt;generateMipmap(face, level);
</del><ins>+    mInstance-&gt;generateMipmap(faceIndex, level);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned int TextureStorageInterfaceCube::getRenderTargetSerial(GLenum target) const
</del><ins>+unsigned int TextureStorageInterfaceCube::getRenderTargetSerial(GLenum target, GLint level) const
</ins><span class="cx"> {
</span><del>-    return mFirstRenderTargetSerial + gl::TextureCubeMap::faceIndex(target);
</del><ins>+    return mFirstRenderTargetSerial + (level * 6) + gl::TextureCubeMap::targetToIndex(target);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+TextureStorageInterface3D::TextureStorageInterface3D(Renderer *renderer, GLenum internalformat, bool renderTarget,
+                                                     GLsizei width, GLsizei height, GLsizei depth, int levels)
+{
+
+    mInstance = renderer-&gt;createTextureStorage3D(internalformat, renderTarget, width, height, depth, levels);
+    mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(static_cast&lt;GLuint&gt;(mInstance-&gt;getLevelCount() * depth));
+}
+
+TextureStorageInterface3D::~TextureStorageInterface3D()
+{
+}
+
+void TextureStorageInterface3D::generateMipmap(int level)
+{
+    mInstance-&gt;generateMipmap(level);
+}
+
+RenderTarget *TextureStorageInterface3D::getRenderTarget(GLint level) const
+{
+    return mInstance-&gt;getRenderTarget(level);
+}
+
+RenderTarget *TextureStorageInterface3D::getRenderTarget(GLint level, GLint layer) const
+{
+    return mInstance-&gt;getRenderTargetLayer(level, layer);
+}
+
+unsigned int TextureStorageInterface3D::getRenderTargetSerial(GLint level, GLint layer) const
+{
+    return mFirstRenderTargetSerial + static_cast&lt;unsigned int&gt;((layer * mInstance-&gt;getLevelCount()) + level);
+}
+
+TextureStorageInterface2DArray::TextureStorageInterface2DArray(Renderer *renderer, GLenum internalformat, bool renderTarget,
+                                                               GLsizei width, GLsizei height, GLsizei depth, int levels)
+{
+    mInstance = renderer-&gt;createTextureStorage2DArray(internalformat, renderTarget, width, height, depth, levels);
+    mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(static_cast&lt;GLuint&gt;(mInstance-&gt;getLevelCount() * depth));
+}
+
+TextureStorageInterface2DArray::~TextureStorageInterface2DArray()
+{
+}
+
+void TextureStorageInterface2DArray::generateMipmap(int level)
+{
+    mInstance-&gt;generateMipmap(level);
+}
+
+RenderTarget *TextureStorageInterface2DArray::getRenderTarget(GLint level, GLint layer) const
+{
+    return mInstance-&gt;getRenderTargetLayer(level, layer);
+}
+
+unsigned int TextureStorageInterface2DArray::getRenderTargetSerial(GLint level, GLint layer) const
+{
+    return mFirstRenderTargetSerial + static_cast&lt;unsigned int&gt;((layer * mInstance-&gt;getLevelCount()) + level);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererTextureStorageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/TextureStorage.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/TextureStorage.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/TextureStorage.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -18,7 +18,6 @@
</span><span class="cx"> class Renderer;
</span><span class="cx"> class SwapChain;
</span><span class="cx"> class RenderTarget;
</span><del>-class Blit;
</del><span class="cx"> 
</span><span class="cx"> class TextureStorage
</span><span class="cx"> {
</span><span class="lines">@@ -26,13 +25,14 @@
</span><span class="cx">     TextureStorage() {};
</span><span class="cx">     virtual ~TextureStorage() {};
</span><span class="cx"> 
</span><del>-    virtual int getLodOffset() const = 0;
</del><ins>+    virtual int getTopLevel() const = 0;
</ins><span class="cx">     virtual bool isRenderTarget() const = 0;
</span><span class="cx">     virtual bool isManaged() const = 0;
</span><del>-    virtual int levelCount() = 0;
</del><ins>+    virtual int getLevelCount() const = 0;
</ins><span class="cx"> 
</span><del>-    virtual RenderTarget *getRenderTarget() = 0;
-    virtual RenderTarget *getRenderTarget(GLenum faceTarget) = 0;
</del><ins>+    virtual RenderTarget *getRenderTarget(int level) = 0;
+    virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level) = 0;
+    virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer) = 0;
</ins><span class="cx">     virtual void generateMipmap(int level) = 0;
</span><span class="cx">     virtual void generateMipmap(int face, int level) = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -50,12 +50,11 @@
</span><span class="cx">     TextureStorage *getStorageInstance() { return mInstance; }
</span><span class="cx"> 
</span><span class="cx">     unsigned int getTextureSerial() const;
</span><del>-    virtual unsigned int getRenderTargetSerial(GLenum target) const = 0;
</del><span class="cx"> 
</span><del>-    virtual int getLodOffset() const;
</del><ins>+    virtual int getTopLevel() const;
</ins><span class="cx">     virtual bool isRenderTarget() const;
</span><span class="cx">     virtual bool isManaged() const;
</span><del>-    virtual int levelCount();
</del><ins>+    virtual int getLevelCount() const;
</ins><span class="cx"> 
</span><span class="cx">   protected:
</span><span class="cx">     TextureStorage *mInstance;
</span><span class="lines">@@ -73,38 +72,74 @@
</span><span class="cx"> {
</span><span class="cx">   public:
</span><span class="cx">     TextureStorageInterface2D(Renderer *renderer, SwapChain *swapchain);
</span><del>-    TextureStorageInterface2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height);
</del><ins>+    TextureStorageInterface2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
</ins><span class="cx">     virtual ~TextureStorageInterface2D();
</span><span class="cx"> 
</span><span class="cx">     void generateMipmap(int level);
</span><del>-    RenderTarget *getRenderTarget() const;
</del><ins>+    RenderTarget *getRenderTarget(GLint level) const;
</ins><span class="cx"> 
</span><del>-    virtual unsigned int getRenderTargetSerial(GLenum target) const;
</del><ins>+    unsigned int getRenderTargetSerial(GLint level) const;
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TextureStorageInterface2D);
</span><span class="cx"> 
</span><del>-    const unsigned int mRenderTargetSerial;
</del><ins>+    unsigned int mFirstRenderTargetSerial;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class TextureStorageInterfaceCube : public TextureStorageInterface
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    TextureStorageInterfaceCube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size);
</del><ins>+    TextureStorageInterfaceCube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels);
</ins><span class="cx">     virtual ~TextureStorageInterfaceCube();
</span><span class="cx"> 
</span><del>-    void generateMipmap(int face, int level);
-    RenderTarget *getRenderTarget(GLenum faceTarget) const;
</del><ins>+    void generateMipmap(int faceIndex, int level);
+    RenderTarget *getRenderTarget(GLenum faceTarget, GLint level) const;
</ins><span class="cx"> 
</span><del>-    virtual unsigned int getRenderTargetSerial(GLenum target) const;
</del><ins>+    virtual unsigned int getRenderTargetSerial(GLenum target, GLint level) const;
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TextureStorageInterfaceCube);
</span><span class="cx"> 
</span><del>-    const unsigned int mFirstRenderTargetSerial;
</del><ins>+    unsigned int mFirstRenderTargetSerial;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class TextureStorageInterface3D : public TextureStorageInterface
+{
+  public:
+    TextureStorageInterface3D(Renderer *renderer, GLenum internalformat, bool renderTarget,
+                              GLsizei width, GLsizei height, GLsizei depth, int levels);
+    virtual ~TextureStorageInterface3D();
+
+    void generateMipmap(int level);
+    RenderTarget *getRenderTarget(GLint level) const;
+    RenderTarget *getRenderTarget(GLint level, GLint layer) const;
+
+    virtual unsigned int getRenderTargetSerial(GLint level, GLint layer) const;
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(TextureStorageInterface3D);
+
+    unsigned int mFirstRenderTargetSerial;
+};
+
+class TextureStorageInterface2DArray : public TextureStorageInterface
+{
+  public:
+    TextureStorageInterface2DArray(Renderer *renderer, GLenum internalformat, bool renderTarget,
+                                   GLsizei width, GLsizei height, GLsizei depth, int levels);
+    virtual ~TextureStorageInterface2DArray();
+
+    void generateMipmap(int level);
+    RenderTarget *getRenderTarget(GLint level, GLint layer) const;
+
+    virtual unsigned int getRenderTargetSerial(GLint level, GLint layer) const;
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(TextureStorageInterface2DArray);
+
+    unsigned int mFirstRenderTargetSerial;
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif // LIBGLESV2_RENDERER_TEXTURESTORAGE_H_
</span><del>-
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererVertexBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexBuffer.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexBuffer.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexBuffer.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -10,7 +10,9 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/VertexBuffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><del>-#include &quot;libGLESv2/Context.h&quot;
</del><ins>+#include &quot;libGLESv2/VertexAttribute.h&quot;
+#include &quot;libGLESv2/renderer/BufferStorage.h&quot;
+#include &quot;common/mathutil.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -87,8 +89,8 @@
</span><span class="cx">     return mVertexBuffer-&gt;discard();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool VertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &amp;attrib,  GLint start, GLsizei count, GLsizei instances,
-                                                  unsigned int *outStreamOffset)
</del><ins>+bool VertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &amp;attrib, const gl::VertexAttribCurrentValueData &amp;currentValue,
+                                                  GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset)
</ins><span class="cx"> {
</span><span class="cx">     unsigned int spaceRequired;
</span><span class="cx">     if (!mVertexBuffer-&gt;getSpaceRequired(attrib, count, instances, &amp;spaceRequired))
</span><span class="lines">@@ -107,7 +109,7 @@
</span><span class="cx">     }
</span><span class="cx">     mReservedSpace = 0;
</span><span class="cx"> 
</span><del>-    if (!mVertexBuffer-&gt;storeVertexAttributes(attrib, start, count, instances, mWritePosition))
</del><ins>+    if (!mVertexBuffer-&gt;storeVertexAttributes(attrib, currentValue, start, count, instances, mWritePosition))
</ins><span class="cx">     {
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -119,34 +121,9 @@
</span><span class="cx"> 
</span><span class="cx">     mWritePosition += spaceRequired;
</span><span class="cx"> 
</span><del>-    return true;
-}
</del><ins>+    // Align to 16-byte boundary
+    mWritePosition = rx::roundUp(mWritePosition, 16u);
</ins><span class="cx"> 
</span><del>-bool VertexBufferInterface::storeRawData(const void* data, unsigned int size, unsigned int *outStreamOffset)
-{
-    if (mWritePosition + size &lt; mWritePosition)
-    {
-        return false;
-    }
-
-    if (!reserveSpace(mReservedSpace))
-    {
-        return false;
-    }
-    mReservedSpace = 0;
-
-    if (!mVertexBuffer-&gt;storeRawData(data, size, mWritePosition))
-    {
-        return false;
-    }
-
-    if (outStreamOffset)
-    {
-        *outStreamOffset = mWritePosition;
-    }
-
-    mWritePosition += size;
-
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -165,18 +142,10 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     mReservedSpace += requiredSpace;
</span><del>-    return true;
-}
</del><span class="cx"> 
</span><del>-bool VertexBufferInterface::reserveRawDataSpace(unsigned int size)
-{
-    // Protect against integer overflow
-    if (mReservedSpace + size &lt; mReservedSpace)
-    {
-         return false;
-    }
</del><ins>+    // Align to 16-byte boundary
+    mReservedSpace = rx::roundUp(mReservedSpace, 16u);
</ins><span class="cx"> 
</span><del>-    mReservedSpace += size;
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -185,7 +154,27 @@
</span><span class="cx">     return mVertexBuffer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &amp;attrib,
+                                                  const gl::VertexAttribCurrentValueData &amp;currentValue) const
+{
+    gl::Buffer *buffer = attrib.mBoundBuffer.get();
+    BufferStorage *storage = buffer ? buffer-&gt;getStorage() : NULL;
+    gl::VertexFormat vertexFormat(attrib, currentValue.Type);
</ins><span class="cx"> 
</span><ins>+    // Alignment restrictions: In D3D, vertex data must be aligned to
+    //  the format stride, or to a 4-byte boundary, whichever is smaller.
+    //  (Undocumented, and experimentally confirmed)
+    unsigned int outputElementSize;
+    getVertexBuffer()-&gt;getSpaceRequired(attrib, 1, 0, &amp;outputElementSize);
+    size_t alignment = std::min(static_cast&lt;size_t&gt;(outputElementSize), 4u);
+
+    bool isAligned = (static_cast&lt;size_t&gt;(attrib.stride()) % alignment == 0) &amp;&amp;
+                     (static_cast&lt;size_t&gt;(attrib.mOffset) % alignment == 0);
+    bool requiresConversion = (mRenderer-&gt;getVertexConversionType(vertexFormat) &amp; VERTEX_CONVERT_CPU) &gt; 0;
+
+    return storage &amp;&amp; storage-&gt;supportsDirectBinding() &amp;&amp; !requiresConversion &amp;&amp; isAligned;
+}
+
</ins><span class="cx"> StreamingVertexBufferInterface::StreamingVertexBufferInterface(rx::Renderer *renderer, std::size_t initialSize) : VertexBufferInterface(renderer, true)
</span><span class="cx"> {
</span><span class="cx">     setBufferSize(initialSize);
</span><span class="lines">@@ -231,7 +220,8 @@
</span><span class="cx">         if (mCache[element].type == attribute.mType &amp;&amp;
</span><span class="cx">             mCache[element].size == attribute.mSize &amp;&amp;
</span><span class="cx">             mCache[element].stride == attribute.stride() &amp;&amp;
</span><del>-            mCache[element].normalized == attribute.mNormalized)
</del><ins>+            mCache[element].normalized == attribute.mNormalized &amp;&amp;
+            mCache[element].pureInteger == attribute.mPureInteger)
</ins><span class="cx">         {
</span><span class="cx">             if (mCache[element].attributeOffset == attribute.mOffset % attribute.stride())
</span><span class="cx">             {
</span><span class="lines">@@ -266,14 +256,14 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool StaticVertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &amp;attrib, GLint start, GLsizei count, GLsizei instances,
-                                                        unsigned int *outStreamOffset)
</del><ins>+bool StaticVertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &amp;attrib, const gl::VertexAttribCurrentValueData &amp;currentValue,
+                                                       GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset)
</ins><span class="cx"> {
</span><span class="cx">     unsigned int streamOffset;
</span><del>-    if (VertexBufferInterface::storeVertexAttributes(attrib, start, count, instances, &amp;streamOffset))
</del><ins>+    if (VertexBufferInterface::storeVertexAttributes(attrib, currentValue, start, count, instances, &amp;streamOffset))
</ins><span class="cx">     {
</span><span class="cx">         int attributeOffset = attrib.mOffset % attrib.stride();
</span><del>-        VertexElement element = { attrib.mType, attrib.mSize, attrib.stride(), attrib.mNormalized, attributeOffset, streamOffset };
</del><ins>+        VertexElement element = { attrib.mType, attrib.mSize, attrib.stride(), attrib.mNormalized, attrib.mPureInteger, attributeOffset, streamOffset };
</ins><span class="cx">         mCache.push_back(element);
</span><span class="cx"> 
</span><span class="cx">         if (outStreamOffset)
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererVertexBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexBuffer.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexBuffer.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexBuffer.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -15,6 +15,7 @@
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="cx"> class VertexAttribute;
</span><ins>+struct VertexAttribCurrentValueData;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="lines">@@ -29,15 +30,11 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool initialize(unsigned int size, bool dynamicUsage) = 0;
</span><span class="cx"> 
</span><del>-    virtual bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, GLint start, GLsizei count,
-                                       GLsizei instances, unsigned int offset) = 0;
-    virtual bool storeRawData(const void* data, unsigned int size, unsigned int offset) = 0;
-
</del><ins>+    virtual bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, const gl::VertexAttribCurrentValueData &amp;currentValue,
+                                       GLint start, GLsizei count, GLsizei instances, unsigned int offset) = 0;
</ins><span class="cx">     virtual bool getSpaceRequired(const gl::VertexAttribute &amp;attrib, GLsizei count, GLsizei instances,
</span><span class="cx">                                   unsigned int *outSpaceRequired) const = 0;
</span><span class="cx"> 
</span><del>-    virtual bool requiresConversion(const gl::VertexAttribute &amp;attrib) const = 0;
-
</del><span class="cx">     virtual unsigned int getBufferSize() const = 0;
</span><span class="cx">     virtual bool setBufferSize(unsigned int size) = 0;
</span><span class="cx">     virtual bool discard() = 0;
</span><span class="lines">@@ -61,16 +58,17 @@
</span><span class="cx">     virtual ~VertexBufferInterface();
</span><span class="cx"> 
</span><span class="cx">     bool reserveVertexSpace(const gl::VertexAttribute &amp;attribute, GLsizei count, GLsizei instances);
</span><del>-    bool reserveRawDataSpace(unsigned int size);
</del><span class="cx"> 
</span><span class="cx">     unsigned int getBufferSize() const;
</span><span class="cx"> 
</span><span class="cx">     unsigned int getSerial() const;
</span><span class="cx"> 
</span><del>-    virtual bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, GLint start, GLsizei count, GLsizei instances,
-                                      unsigned int *outStreamOffset);
-    virtual bool storeRawData(const void* data, unsigned int size, unsigned int *outStreamOffset);
</del><ins>+    virtual bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, const gl::VertexAttribCurrentValueData &amp;currentValue,
+                                      GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset);
</ins><span class="cx"> 
</span><ins>+    bool directStoragePossible(const gl::VertexAttribute &amp;attrib,
+                               const gl::VertexAttribCurrentValueData &amp;currentValue) const;
+
</ins><span class="cx">     VertexBuffer* getVertexBuffer() const;
</span><span class="cx"> 
</span><span class="cx">   protected:
</span><span class="lines">@@ -111,10 +109,10 @@
</span><span class="cx">     explicit StaticVertexBufferInterface(rx::Renderer *renderer);
</span><span class="cx">     ~StaticVertexBufferInterface();
</span><span class="cx"> 
</span><del>-    bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, GLint start, GLsizei count, GLsizei instances,
-                               unsigned int *outStreamOffset);
</del><ins>+    bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, const gl::VertexAttribCurrentValueData &amp;currentValue,
+                              GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset);
</ins><span class="cx"> 
</span><del>-    bool lookupAttribute(const gl::VertexAttribute &amp;attribute, unsigned int* outStreamOffset);
</del><ins>+    bool lookupAttribute(const gl::VertexAttribute &amp;attribute, unsigned int* outStreamFffset);
</ins><span class="cx"> 
</span><span class="cx">   protected:
</span><span class="cx">     bool reserveSpace(unsigned int size);
</span><span class="lines">@@ -126,6 +124,7 @@
</span><span class="cx">         GLint size;
</span><span class="cx">         GLsizei stride;
</span><span class="cx">         bool normalized;
</span><ins>+        bool pureInteger;
</ins><span class="cx">         int attributeOffset;
</span><span class="cx"> 
</span><span class="cx">         unsigned int streamOffset;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererVertexDataManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexDataManager.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexDataManager.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexDataManager.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -13,8 +13,9 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/Buffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/ProgramBinary.h&quot;
</span><del>-#include &quot;libGLESv2/Context.h&quot;
</del><ins>+#include &quot;libGLESv2/VertexAttribute.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/VertexBuffer.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/Renderer.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace
</span><span class="cx"> {
</span><span class="lines">@@ -26,7 +27,7 @@
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-static int elementsInBuffer(const gl::VertexAttribute &amp;attribute, unsigned int size)
</del><ins>+static int ElementsInBuffer(const gl::VertexAttribute &amp;attribute, unsigned int size)
</ins><span class="cx"> {
</span><span class="cx">     // Size cannot be larger than a GLsizei
</span><span class="cx">     if (size &gt; static_cast&lt;unsigned int&gt;(std::numeric_limits&lt;int&gt;::max()))
</span><span class="lines">@@ -56,10 +57,11 @@
</span><span class="cx"> {
</span><span class="cx">     for (int i = 0; i &lt; gl::MAX_VERTEX_ATTRIBS; i++)
</span><span class="cx">     {
</span><del>-        mCurrentValue[i][0] = std::numeric_limits&lt;float&gt;::quiet_NaN();
-        mCurrentValue[i][1] = std::numeric_limits&lt;float&gt;::quiet_NaN();
-        mCurrentValue[i][2] = std::numeric_limits&lt;float&gt;::quiet_NaN();
-        mCurrentValue[i][3] = std::numeric_limits&lt;float&gt;::quiet_NaN();
</del><ins>+        mCurrentValue[i].FloatValues[0] = std::numeric_limits&lt;float&gt;::quiet_NaN();
+        mCurrentValue[i].FloatValues[1] = std::numeric_limits&lt;float&gt;::quiet_NaN();
+        mCurrentValue[i].FloatValues[2] = std::numeric_limits&lt;float&gt;::quiet_NaN();
+        mCurrentValue[i].FloatValues[3] = std::numeric_limits&lt;float&gt;::quiet_NaN();
+        mCurrentValue[i].Type = GL_FLOAT;
</ins><span class="cx">         mCurrentValueBuffer[i] = NULL;
</span><span class="cx">         mCurrentValueOffsets[i] = 0;
</span><span class="cx">     }
</span><span class="lines">@@ -82,18 +84,9 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool directStoragePossible(VertexBufferInterface* vb, const gl::VertexAttribute&amp; attrib)
</del><ins>+GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], const gl::VertexAttribCurrentValueData currentValues[],
+                                            gl::ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *translated, GLsizei instances)
</ins><span class="cx"> {
</span><del>-    gl::Buffer *buffer = attrib.mBoundBuffer.get();
-    BufferStorage *storage = buffer ? buffer-&gt;getStorage() : NULL;
-
-    const bool isAligned = (attrib.stride() % 4 == 0) &amp;&amp; (attrib.mOffset % 4 == 0);
-
-    return storage &amp;&amp; storage-&gt;supportsDirectBinding() &amp;&amp; !vb-&gt;getVertexBuffer()-&gt;requiresConversion(attrib) &amp;&amp; isAligned;
-}
-
-GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], gl::ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *translated, GLsizei instances)
-{
</del><span class="cx">     if (!mStreamingBuffer)
</span><span class="cx">     {
</span><span class="cx">         return GL_OUT_OF_MEMORY;
</span><span class="lines">@@ -113,7 +106,7 @@
</span><span class="cx">             StaticVertexBufferInterface *staticBuffer = buffer ? buffer-&gt;getStaticVertexBuffer() : NULL;
</span><span class="cx"> 
</span><span class="cx">             if (staticBuffer &amp;&amp; staticBuffer-&gt;getBufferSize() &gt; 0 &amp;&amp; !staticBuffer-&gt;lookupAttribute(attribs[i], NULL) &amp;&amp;
</span><del>-                !directStoragePossible(staticBuffer, attribs[i]))
</del><ins>+                !staticBuffer-&gt;directStoragePossible(attribs[i], currentValues[i]))
</ins><span class="cx">             {
</span><span class="cx">                 buffer-&gt;invalidateStaticData();
</span><span class="cx">             }
</span><span class="lines">@@ -129,13 +122,13 @@
</span><span class="cx">             StaticVertexBufferInterface *staticBuffer = buffer ? buffer-&gt;getStaticVertexBuffer() : NULL;
</span><span class="cx">             VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast&lt;VertexBufferInterface*&gt;(mStreamingBuffer);
</span><span class="cx"> 
</span><del>-            if (!directStoragePossible(vertexBuffer, attribs[i]))
</del><ins>+            if (!vertexBuffer-&gt;directStoragePossible(attribs[i], currentValues[i]))
</ins><span class="cx">             {
</span><span class="cx">                 if (staticBuffer)
</span><span class="cx">                 {
</span><span class="cx">                     if (staticBuffer-&gt;getBufferSize() == 0)
</span><span class="cx">                     {
</span><del>-                        int totalCount = elementsInBuffer(attribs[i], buffer-&gt;size());
</del><ins>+                        int totalCount = ElementsInBuffer(attribs[i], buffer-&gt;size());
</ins><span class="cx">                         if (!staticBuffer-&gt;reserveVertexSpace(attribs[i], totalCount, 0))
</span><span class="cx">                         {
</span><span class="cx">                             return GL_OUT_OF_MEMORY;
</span><span class="lines">@@ -146,9 +139,9 @@
</span><span class="cx">                 {
</span><span class="cx">                     int totalCount = StreamingBufferElementCount(attribs[i], count, instances);
</span><span class="cx"> 
</span><del>-                    // Undefined behaviour:
</del><ins>+                    // [OpenGL ES 3.0.2] section 2.9.4 page 40:
</ins><span class="cx">                     // We can return INVALID_OPERATION if our vertex attribute does not have enough backing data.
</span><del>-                    if (buffer &amp;&amp; elementsInBuffer(attribs[i], buffer-&gt;size()) &lt; totalCount)
</del><ins>+                    if (buffer &amp;&amp; ElementsInBuffer(attribs[i], buffer-&gt;size()) &lt; totalCount)
</ins><span class="cx">                     {
</span><span class="cx">                         return GL_INVALID_OPERATION;
</span><span class="cx">                     }
</span><span class="lines">@@ -182,7 +175,7 @@
</span><span class="cx">                 VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast&lt;VertexBufferInterface*&gt;(mStreamingBuffer);
</span><span class="cx"> 
</span><span class="cx">                 BufferStorage *storage = buffer ? buffer-&gt;getStorage() : NULL;
</span><del>-                bool directStorage = directStoragePossible(vertexBuffer, attribs[i]);
</del><ins>+                bool directStorage = vertexBuffer-&gt;directStoragePossible(attribs[i], currentValues[i]);
</ins><span class="cx"> 
</span><span class="cx">                 unsigned int streamOffset = 0;
</span><span class="cx">                 unsigned int outputElementSize = 0;
</span><span class="lines">@@ -191,7 +184,6 @@
</span><span class="cx">                 {
</span><span class="cx">                     outputElementSize = attribs[i].stride();
</span><span class="cx">                     streamOffset = attribs[i].mOffset + outputElementSize * start;
</span><del>-                    storage-&gt;markBufferUsage();
</del><span class="cx">                 }
</span><span class="cx">                 else if (staticBuffer)
</span><span class="cx">                 {
</span><span class="lines">@@ -203,10 +195,11 @@
</span><span class="cx">                     if (!staticBuffer-&gt;lookupAttribute(attribs[i], &amp;streamOffset))
</span><span class="cx">                     {
</span><span class="cx">                         // Convert the entire buffer
</span><del>-                        int totalCount = elementsInBuffer(attribs[i], storage-&gt;getSize());
</del><ins>+                        int totalCount = ElementsInBuffer(attribs[i], storage-&gt;getSize());
</ins><span class="cx">                         int startIndex = attribs[i].mOffset / attribs[i].stride();
</span><span class="cx"> 
</span><del>-                        if (!staticBuffer-&gt;storeVertexAttributes(attribs[i], -startIndex, totalCount, 0, &amp;streamOffset))
</del><ins>+                        if (!staticBuffer-&gt;storeVertexAttributes(attribs[i], currentValues[i], -startIndex, totalCount,
+                                                                 0, &amp;streamOffset))
</ins><span class="cx">                         {
</span><span class="cx">                             return GL_OUT_OF_MEMORY;
</span><span class="cx">                         }
</span><span class="lines">@@ -225,7 +218,8 @@
</span><span class="cx">                 {
</span><span class="cx">                     int totalCount = StreamingBufferElementCount(attribs[i], count, instances);
</span><span class="cx">                     if (!mStreamingBuffer-&gt;getVertexBuffer()-&gt;getSpaceRequired(attribs[i], 1, 0, &amp;outputElementSize) ||
</span><del>-                        !mStreamingBuffer-&gt;storeVertexAttributes(attribs[i], start, totalCount, instances, &amp;streamOffset))
</del><ins>+                        !mStreamingBuffer-&gt;storeVertexAttributes(attribs[i], currentValues[i], start, totalCount, instances,
+                                                                 &amp;streamOffset))
</ins><span class="cx">                     {
</span><span class="cx">                         return GL_OUT_OF_MEMORY;
</span><span class="cx">                     }
</span><span class="lines">@@ -237,6 +231,7 @@
</span><span class="cx">                 translated[i].divisor = attribs[i].mDivisor;
</span><span class="cx"> 
</span><span class="cx">                 translated[i].attribute = &amp;attribs[i];
</span><ins>+                translated[i].currentValueType = currentValues[i].Type;
</ins><span class="cx">                 translated[i].stride = outputElementSize;
</span><span class="cx">                 translated[i].offset = streamOffset;
</span><span class="cx">             }
</span><span class="lines">@@ -249,27 +244,20 @@
</span><span class="cx"> 
</span><span class="cx">                 StreamingVertexBufferInterface *buffer = mCurrentValueBuffer[i];
</span><span class="cx"> 
</span><del>-                if (mCurrentValue[i][0] != attribs[i].mCurrentValue[0] ||
-                    mCurrentValue[i][1] != attribs[i].mCurrentValue[1] ||
-                    mCurrentValue[i][2] != attribs[i].mCurrentValue[2] ||
-                    mCurrentValue[i][3] != attribs[i].mCurrentValue[3])
</del><ins>+                if (mCurrentValue[i] != currentValues[i])
</ins><span class="cx">                 {
</span><del>-                    unsigned int requiredSpace = sizeof(float) * 4;
-                    if (!buffer-&gt;reserveRawDataSpace(requiredSpace))
</del><ins>+                    if (!buffer-&gt;reserveVertexSpace(attribs[i], 1, 0))
</ins><span class="cx">                     {
</span><span class="cx">                         return GL_OUT_OF_MEMORY;
</span><span class="cx">                     }
</span><span class="cx"> 
</span><span class="cx">                     unsigned int streamOffset;
</span><del>-                    if (!buffer-&gt;storeRawData(attribs[i].mCurrentValue, requiredSpace, &amp;streamOffset))
</del><ins>+                    if (!buffer-&gt;storeVertexAttributes(attribs[i], currentValues[i], 0, 1, 0, &amp;streamOffset))
</ins><span class="cx">                     {
</span><span class="cx">                         return GL_OUT_OF_MEMORY;
</span><span class="cx">                     }
</span><span class="cx"> 
</span><del>-                    mCurrentValue[i][0] = attribs[i].mCurrentValue[0];
-                    mCurrentValue[i][1] = attribs[i].mCurrentValue[1];
-                    mCurrentValue[i][2] = attribs[i].mCurrentValue[2];
-                    mCurrentValue[i][3] = attribs[i].mCurrentValue[3];
</del><ins>+                    mCurrentValue[i] = currentValues[i];
</ins><span class="cx">                     mCurrentValueOffsets[i] = streamOffset;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -279,6 +267,7 @@
</span><span class="cx">                 translated[i].divisor = 0;
</span><span class="cx"> 
</span><span class="cx">                 translated[i].attribute = &amp;attribs[i];
</span><ins>+                translated[i].currentValueType = currentValues[i].Type;
</ins><span class="cx">                 translated[i].stride = 0;
</span><span class="cx">                 translated[i].offset = mCurrentValueOffsets[i];
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererVertexDataManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexDataManager.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexDataManager.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/VertexDataManager.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -11,12 +11,14 @@
</span><span class="cx"> #define LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/Constants.h&quot;
</span><ins>+#include &quot;libGLESv2/VertexAttribute.h&quot;
</ins><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace gl
</span><span class="cx"> {
</span><span class="cx"> class VertexAttribute;
</span><span class="cx"> class ProgramBinary;
</span><ins>+struct VertexAttribCurrentValueData;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="lines">@@ -31,6 +33,7 @@
</span><span class="cx">     bool active;
</span><span class="cx"> 
</span><span class="cx">     const gl::VertexAttribute *attribute;
</span><ins>+    GLenum currentValueType;
</ins><span class="cx">     unsigned int offset;
</span><span class="cx">     unsigned int stride;   // 0 means not to advance the read pointer at all
</span><span class="cx"> 
</span><span class="lines">@@ -46,7 +49,8 @@
</span><span class="cx">     VertexDataManager(rx::Renderer *renderer);
</span><span class="cx">     virtual ~VertexDataManager();
</span><span class="cx"> 
</span><del>-    GLenum prepareVertexData(const gl::VertexAttribute attribs[], gl::ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *outAttribs, GLsizei instances);
</del><ins>+    GLenum prepareVertexData(const gl::VertexAttribute attribs[], const gl::VertexAttribCurrentValueData currentValues[],
+                             gl::ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *outAttribs, GLsizei instances);
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(VertexDataManager);
</span><span class="lines">@@ -55,7 +59,8 @@
</span><span class="cx"> 
</span><span class="cx">     StreamingVertexBufferInterface *mStreamingBuffer;
</span><span class="cx"> 
</span><del>-    float mCurrentValue[gl::MAX_VERTEX_ATTRIBS][4];
</del><ins>+    gl::VertexAttribCurrentValueData mCurrentValue[gl::MAX_VERTEX_ATTRIBS];
+
</ins><span class="cx">     StreamingVertexBufferInterface *mCurrentValueBuffer[gl::MAX_VERTEX_ATTRIBS];
</span><span class="cx">     std::size_t mCurrentValueOffsets[gl::MAX_VERTEX_ATTRIBS];
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2renderercopyimagecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyimage.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyimage.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyimage.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+#include &quot;precompiled.h&quot;
+//
+// 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.
+//
+
+// copyimage.cpp: Defines image copying functions
+
+#include &quot;libGLESv2/renderer/copyImage.h&quot;
+
+namespace rx
+{
+
+void CopyBGRAUByteToRGBAUByte(const void *source, void *dest)
+{
+    unsigned int argb = *(unsigned int*)source;
+    *(unsigned int*)dest = (argb &amp; 0xFF00FF00) |       // Keep alpha and green
+                           (argb &amp; 0x00FF0000) &gt;&gt; 16 | // Move red to blue
+                           (argb &amp; 0x000000FF) &lt;&lt; 16;  // Move blue to red
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2renderercopyimageh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyimage.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyimage.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyimage.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+//
+// 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.
+//
+
+// copyimage.h: Defines image copying functions
+
+#ifndef LIBGLESV2_RENDERER_COPYIMAGE_H_
+#define LIBGLESV2_RENDERER_COPYIMAGE_H_
+
+#include &quot;common/mathutil.h&quot;
+#include &quot;libGLESv2/angletypes.h&quot;
+
+namespace rx
+{
+
+template &lt;typename sourceType, typename colorDataType&gt;
+void ReadColor(const void *source, void *dest)
+{
+    sourceType::readColor(reinterpret_cast&lt;gl::Color&lt;colorDataType&gt;*&gt;(dest), reinterpret_cast&lt;const sourceType*&gt;(source));
+}
+
+template &lt;typename destType, typename colorDataType&gt;
+void WriteColor(const void *source, void *dest)
+{
+    destType::writeColor(reinterpret_cast&lt;destType*&gt;(dest), reinterpret_cast&lt;const gl::Color&lt;colorDataType&gt;*&gt;(source));
+}
+
+template &lt;typename sourceType, typename destType, typename colorDataType&gt;
+void CopyPixel(const void *source, void *dest)
+{
+    colorType temp;
+    ReadColor&lt;sourceType, colorDataType&gt;(source, &amp;temp);
+    WriteColor&lt;destType, colorDataType&gt;(&amp;temp, dest);
+}
+
+void CopyBGRAUByteToRGBAUByte(const void *source, void *dest);
+
+}
+
+#endif // LIBGLESV2_RENDERER_COPYIMAGE_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2renderercopyvertexh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyvertex.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyvertex.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/copyvertex.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,309 @@
</span><ins>+//
+// 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.
+//
+
+// copyvertex.h: Defines vertex buffer copying and conversion functions
+
+#ifndef LIBGLESV2_RENDERER_COPYVERTEX_H_
+#define LIBGLESV2_RENDERER_COPYVERTEX_H_
+
+#include &quot;common/mathutil.h&quot;
+
+// 'widenDefaultValueBits' gives the default value for the alpha channel (4th component)
+//  the sentinel value 0 means we do not want to widen the input or add an alpha channel
+template &lt;typename T, unsigned int componentCount, unsigned int widenDefaultValueBits&gt;
+inline void copyVertexData(const void *input, size_t stride, size_t count, void *output)
+{
+    const unsigned int attribSize = sizeof(T) * componentCount;
+    const T defaultValue = gl::bitCast&lt;T&gt;(widenDefaultValueBits);
+    const bool widen = (widenDefaultValueBits != 0);
+
+    if (attribSize == stride &amp;&amp; !widen)
+    {
+        memcpy(output, input, count * attribSize);
+    }
+    else
+    {
+        unsigned int outputStride = widen ? 4 : componentCount;
+
+        for (unsigned int i = 0; i &lt; count; i++)
+        {
+            const T *offsetInput = reinterpret_cast&lt;const T*&gt;(reinterpret_cast&lt;const char*&gt;(input) + i * stride);
+            T *offsetOutput = reinterpret_cast&lt;T*&gt;(output) + i * outputStride;
+
+            for (unsigned int j = 0; j &lt; componentCount; j++)
+            {
+                offsetOutput[j] = offsetInput[j];
+            }
+
+            if (widen)
+            {
+                offsetOutput[3] = defaultValue;
+            }
+        }
+    }
+}
+
+template &lt;unsigned int componentCount&gt;
+inline void copyFixedVertexData(const void* input, size_t stride, size_t count, void* output)
+{
+    static const float divisor = 1.0f / (1 &lt;&lt; 16);
+
+    for (unsigned int i = 0; i &lt; count; i++)
+    {
+        const GLfixed* offsetInput = reinterpret_cast&lt;const GLfixed*&gt;(reinterpret_cast&lt;const char*&gt;(input) + stride * i);
+        float* offsetOutput = reinterpret_cast&lt;float*&gt;(output) + i * componentCount;
+
+        for (unsigned int j = 0; j &lt; componentCount; j++)
+        {
+            offsetOutput[j] = static_cast&lt;float&gt;(offsetInput[j]) * divisor;
+        }
+    }
+}
+
+template &lt;typename T, unsigned int componentCount, bool normalized&gt;
+inline void copyToFloatVertexData(const void* input, size_t stride, size_t count, void* output)
+{
+    typedef std::numeric_limits&lt;T&gt; NL;
+
+    for (unsigned int i = 0; i &lt; count; i++)
+    {
+        const T *offsetInput = reinterpret_cast&lt;const T*&gt;(reinterpret_cast&lt;const char*&gt;(input) + stride * i);
+        float *offsetOutput = reinterpret_cast&lt;float*&gt;(output) + i * componentCount;
+
+        for (unsigned int j = 0; j &lt; componentCount; j++)
+        {
+            if (normalized)
+            {
+                if (NL::is_signed)
+                {
+                    const float divisor = 1.0f / (2 * static_cast&lt;float&gt;(NL::max()) + 1);
+                    offsetOutput[j] = (2 * static_cast&lt;float&gt;(offsetInput[j]) + 1) * divisor;
+                }
+                else
+                {
+                    offsetOutput[j] =  static_cast&lt;float&gt;(offsetInput[j]) / NL::max();
+                }
+            }
+            else
+            {
+                offsetOutput[j] =  static_cast&lt;float&gt;(offsetInput[j]);
+            }
+        }
+    }
+}
+
+inline void copyPackedUnsignedVertexData(const void* input, size_t stride, size_t count, void* output)
+{
+    const unsigned int attribSize = 4;
+
+    if (attribSize == stride)
+    {
+        memcpy(output, input, count * attribSize);
+    }
+    else
+    {
+        for (unsigned int i = 0; i &lt; count; i++)
+        {
+            const GLuint *offsetInput = reinterpret_cast&lt;const GLuint*&gt;(reinterpret_cast&lt;const char*&gt;(input) + (i * stride));
+            GLuint *offsetOutput = reinterpret_cast&lt;GLuint*&gt;(output) + (i * attribSize);
+
+            offsetOutput[i] = offsetInput[i];
+        }
+    }
+}
+
+template &lt;bool isSigned, bool normalized, bool toFloat&gt;
+static inline void copyPackedRGB(unsigned int data, void *output)
+{
+    const unsigned int rgbSignMask = 0x200;       // 1 set at the 9 bit
+    const unsigned int negativeMask = 0xFFFFFC00; // All bits from 10 to 31 set to 1
+
+    if (toFloat)
+    {
+        GLfloat *floatOutput = reinterpret_cast&lt;GLfloat*&gt;(output);
+        if (isSigned)
+        {
+            GLfloat finalValue = 0;
+            if (data &amp; rgbSignMask)
+            {
+                int negativeNumber = data | negativeMask;
+                finalValue = static_cast&lt;GLfloat&gt;(negativeNumber);
+            }
+            else
+            {
+                finalValue = static_cast&lt;GLfloat&gt;(data);
+            }
+
+            if (normalized)
+            {
+                const int maxValue = 0x1FF;      // 1 set in bits 0 through 8
+                const int minValue = 0xFFFFFE01; // Inverse of maxValue
+
+                // A 10-bit two's complement number has the possibility of being minValue - 1 but
+                // OpenGL's normalization rules dictate that it should be clamped to minValue in this
+                // case.
+                if (finalValue &lt; minValue)
+                {
+                    finalValue = minValue;
+                }
+
+                const int halfRange = (maxValue - minValue) &gt;&gt; 1;
+                *floatOutput = ((finalValue - minValue) / halfRange) - 1.0f;
+            }
+            else
+            {
+                *floatOutput = finalValue;
+            }
+        }
+        else
+        {
+            if (normalized)
+            {
+                const unsigned int maxValue = 0x3FF; // 1 set in bits 0 through 9
+                *floatOutput = static_cast&lt;GLfloat&gt;(data) / static_cast&lt;GLfloat&gt;(maxValue);
+            }
+            else
+            {
+                *floatOutput = static_cast&lt;GLfloat&gt;(data);
+            }
+        }
+    }
+    else
+    {
+        if (isSigned)
+        {
+            GLshort *intOutput = reinterpret_cast&lt;GLshort*&gt;(output);
+
+            if (data &amp; rgbSignMask)
+            {
+                *intOutput = data | negativeMask;
+            }
+            else
+            {
+                *intOutput = data;
+            }
+        }
+        else
+        {
+            GLushort *uintOutput = reinterpret_cast&lt;GLushort*&gt;(output);
+            *uintOutput = data;
+        }
+    }
+}
+
+template &lt;bool isSigned, bool normalized, bool toFloat&gt;
+inline void copyPackedAlpha(unsigned int data, void *output)
+{
+    if (toFloat)
+    {
+        GLfloat *floatOutput = reinterpret_cast&lt;GLfloat*&gt;(output);
+        if (isSigned)
+        {
+            if (normalized)
+            {
+                switch (data)
+                {
+                  case 0x0: *floatOutput =  0.0f; break;
+                  case 0x1: *floatOutput =  1.0f; break;
+                  case 0x2: *floatOutput = -1.0f; break;
+                  case 0x3: *floatOutput = -1.0f; break;
+                  default: UNREACHABLE();
+                }
+            }
+            else
+            {
+                switch (data)
+                {
+                  case 0x0: *floatOutput =  0.0f; break;
+                  case 0x1: *floatOutput =  1.0f; break;
+                  case 0x2: *floatOutput = -2.0f; break;
+                  case 0x3: *floatOutput = -1.0f; break;
+                  default: UNREACHABLE();
+                }
+            }
+        }
+        else
+        {
+            if (normalized)
+            {
+                switch (data)
+                {
+                  case 0x0: *floatOutput = 0.0f / 3.0f; break;
+                  case 0x1: *floatOutput = 1.0f / 3.0f; break;
+                  case 0x2: *floatOutput = 2.0f / 3.0f; break;
+                  case 0x3: *floatOutput = 3.0f / 3.0f; break;
+                  default: UNREACHABLE();
+                }
+            }
+            else
+            {
+                switch (data)
+                {
+                  case 0x0: *floatOutput = 0.0f; break;
+                  case 0x1: *floatOutput = 1.0f; break;
+                  case 0x2: *floatOutput = 2.0f; break;
+                  case 0x3: *floatOutput = 3.0f; break;
+                  default: UNREACHABLE();
+                }
+            }
+        }
+    }
+    else
+    {
+        if (isSigned)
+        {
+            GLshort *intOutput = reinterpret_cast&lt;GLshort*&gt;(output);
+            switch (data)
+            {
+              case 0x0: *intOutput =  0; break;
+              case 0x1: *intOutput =  1; break;
+              case 0x2: *intOutput = -2; break;
+              case 0x3: *intOutput = -1; break;
+              default: UNREACHABLE();
+            }
+        }
+        else
+        {
+            GLushort *uintOutput = reinterpret_cast&lt;GLushort*&gt;(output);
+            switch (data)
+            {
+              case 0x0: *uintOutput = 0; break;
+              case 0x1: *uintOutput = 1; break;
+              case 0x2: *uintOutput = 2; break;
+              case 0x3: *uintOutput = 3; break;
+              default: UNREACHABLE();
+            }
+        }
+    }
+}
+
+template &lt;bool isSigned, bool normalized, bool toFloat&gt;
+inline void copyPackedVertexData(const void* input, size_t stride, size_t count, void* output)
+{
+    const unsigned int outputComponentSize = toFloat ? 4 : 2;
+    const unsigned int componentCount = 4;
+
+    const unsigned int rgbMask = 0x3FF; // 1 set in bits 0 through 9
+    const unsigned int redShift = 0;    // red is bits 0 through 9
+    const unsigned int greenShift = 10; // green is bits 10 through 19
+    const unsigned int blueShift = 20;  // blue is bits 20 through 29
+
+    const unsigned int alphaMask = 0x3; // 1 set in bits 0 and 1
+    const unsigned int alphaShift = 30; // Alpha is the 30 and 31 bits
+
+    for (unsigned int i = 0; i &lt; count; i++)
+    {
+        GLuint packedValue = *reinterpret_cast&lt;const GLuint*&gt;(reinterpret_cast&lt;const char*&gt;(input) + (i * stride));
+        GLbyte *offsetOutput = reinterpret_cast&lt;GLbyte*&gt;(output) + (i * outputComponentSize * componentCount);
+
+        copyPackedRGB&lt;isSigned, normalized, toFloat&gt;(  (packedValue &gt;&gt; redShift) &amp; rgbMask,     offsetOutput + (0 * outputComponentSize));
+        copyPackedRGB&lt;isSigned, normalized, toFloat&gt;(  (packedValue &gt;&gt; greenShift) &amp; rgbMask,   offsetOutput + (1 * outputComponentSize));
+        copyPackedRGB&lt;isSigned, normalized, toFloat&gt;(  (packedValue &gt;&gt; blueShift) &amp; rgbMask,    offsetOutput + (2 * outputComponentSize));
+        copyPackedAlpha&lt;isSigned, normalized, toFloat&gt;((packedValue &gt;&gt; alphaShift) &amp; alphaMask, offsetOutput + (3* outputComponentSize));
+    }
+}
+
+#endif // LIBGLESV2_RENDERER_COPYVERTEX_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3dHLSLCompilercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,163 @@
</span><ins>+#include &quot;precompiled.h&quot;
+#include &quot;libGLESv2/renderer/d3d/HLSLCompiler.h&quot;
+#include &quot;libGLESv2/Program.h&quot;
+#include &quot;libGLESv2/main.h&quot;
+
+#include &quot;common/utilities.h&quot;
+
+#include &quot;third_party/trace_event/trace_event.h&quot;
+
+namespace rx
+{
+
+HLSLCompiler::HLSLCompiler()
+    : mD3DCompilerModule(NULL),
+      mD3DCompileFunc(NULL)
+{
+}
+
+HLSLCompiler::~HLSLCompiler()
+{
+    release();
+}
+
+bool HLSLCompiler::initialize()
+{
+    TRACE_EVENT0(&quot;gpu&quot;, &quot;initializeCompiler&quot;);
+#if defined(ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES)
+    // Find a D3DCompiler module that had already been loaded based on a predefined list of versions.
+    static TCHAR* d3dCompilerNames[] = ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES;
+
+    for (size_t i = 0; i &lt; ArraySize(d3dCompilerNames); ++i)
+    {
+        if (GetModuleHandleEx(0, d3dCompilerNames[i], &amp;mD3DCompilerModule))
+        {
+            break;
+        }
+    }
+#endif  // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
+
+    if (!mD3DCompilerModule)
+    {
+        // Load the version of the D3DCompiler DLL associated with the Direct3D version ANGLE was built with.
+        mD3DCompilerModule = LoadLibrary(D3DCOMPILER_DLL);
+    }
+
+    if (!mD3DCompilerModule)
+    {
+        ERR(&quot;No D3D compiler module found - aborting!\n&quot;);
+        return false;
+    }
+
+    mD3DCompileFunc = reinterpret_cast&lt;CompileFuncPtr&gt;(GetProcAddress(mD3DCompilerModule, &quot;D3DCompile&quot;));
+    ASSERT(mD3DCompileFunc);
+
+    return mD3DCompileFunc != NULL;
+}
+
+void HLSLCompiler::release()
+{
+    if (mD3DCompilerModule)
+    {
+        FreeLibrary(mD3DCompilerModule);
+        mD3DCompilerModule = NULL;
+        mD3DCompileFunc = NULL;
+    }
+}
+
+ShaderBlob *HLSLCompiler::compileToBinary(gl::InfoLog &amp;infoLog, const char *hlsl, const char *profile,
+                                         unsigned int optimizationFlags, bool alternateFlags) const
+{
+    ASSERT(mD3DCompilerModule &amp;&amp; mD3DCompileFunc);
+
+    if (!hlsl)
+    {
+        return NULL;
+    }
+
+    HRESULT result = S_OK;
+    UINT flags = 0;
+    std::string sourceText;
+    if (gl::perfActive())
+    {
+        flags |= D3DCOMPILE_DEBUG;
+
+#ifdef NDEBUG
+        flags |= optimizationFlags;
+#else
+        flags |= D3DCOMPILE_SKIP_OPTIMIZATION;
+#endif
+
+        std::string sourcePath = getTempPath();
+        sourceText = std::string(&quot;#line 2 \&quot;&quot;) + sourcePath + std::string(&quot;\&quot;\n\n&quot;) + std::string(hlsl);
+        writeFile(sourcePath.c_str(), sourceText.c_str(), sourceText.size());
+    }
+    else
+    {
+        flags |= optimizationFlags;
+        sourceText = hlsl;
+    }
+
+    // Sometimes D3DCompile will fail with the default compilation flags for complicated shaders when it would otherwise pass with alternative options.
+    // Try the default flags first and if compilation fails, try some alternatives.
+    const static UINT extraFlags[] =
+    {
+        0,
+        D3DCOMPILE_AVOID_FLOW_CONTROL,
+        D3DCOMPILE_PREFER_FLOW_CONTROL
+    };
+
+    const static char * const extraFlagNames[] =
+    {
+        &quot;default&quot;,
+        &quot;avoid flow control&quot;,
+        &quot;prefer flow control&quot;
+    };
+
+    int attempts = alternateFlags ? ArraySize(extraFlags) : 1;
+    pD3DCompile compileFunc = reinterpret_cast&lt;pD3DCompile&gt;(mD3DCompileFunc);
+    for (int i = 0; i &lt; attempts; ++i)
+    {
+        ID3DBlob *errorMessage = NULL;
+        ID3DBlob *binary = NULL;
+
+        result = compileFunc(hlsl, strlen(hlsl), gl::g_fakepath, NULL, NULL,
+            &quot;main&quot;, profile, flags | extraFlags[i], 0, &amp;binary, &amp;errorMessage);
+        if (errorMessage)
+        {
+            const char *message = (const char*)errorMessage-&gt;GetBufferPointer();
+
+            infoLog.appendSanitized(message);
+            TRACE(&quot;\n%s&quot;, hlsl);
+            TRACE(&quot;\n%s&quot;, message);
+
+            SafeRelease(errorMessage);
+        }
+
+        if (SUCCEEDED(result))
+        {
+            return (ShaderBlob*)binary;
+        }
+        else
+        {
+            if (result == E_OUTOFMEMORY)
+            {
+                return gl::error(GL_OUT_OF_MEMORY, (ShaderBlob*)NULL);
+            }
+
+            infoLog.append(&quot;Warning: D3D shader compilation failed with &quot;);
+            infoLog.append(extraFlagNames[i]);
+            infoLog.append(&quot; flags.&quot;);
+            if (i + 1 &lt; attempts)
+            {
+                infoLog.append(&quot; Retrying with &quot;);
+                infoLog.append(extraFlagNames[i + 1]);
+                infoLog.append(&quot;.\n&quot;);
+            }
+        }
+    }
+
+    return NULL;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3dHLSLCompilerh"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d/HLSLCompiler.h (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d/HLSLCompiler.h                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d/HLSLCompiler.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+#ifndef LIBGLESV2_RENDERER_HLSL_D3DCOMPILER_H_
+#define LIBGLESV2_RENDERER_HLSL_D3DCOMPILER_H_
+
+#include &quot;common/angleutils.h&quot;
+
+#include &lt;windows.h&gt;
+
+namespace gl
+{
+class InfoLog;
+}
+
+namespace rx
+{
+
+typedef void* ShaderBlob;
+typedef void(*CompileFuncPtr)();
+
+class HLSLCompiler
+{
+  public:
+    HLSLCompiler();
+    ~HLSLCompiler();
+
+    bool initialize();
+    void release();
+
+    ShaderBlob *compileToBinary(gl::InfoLog &amp;infoLog, const char *hlsl, const char *profile,
+                                unsigned int optimizationFlags, bool alternateFlags) const;
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(HLSLCompiler);
+
+    HMODULE mD3DCompilerModule;
+    CompileFuncPtr mD3DCompileFunc;
+};
+
+}
+
+#endif // LIBGLESV2_RENDERER_HLSL_D3DCOMPILER_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11BufferStorage11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -10,38 +10,159 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/BufferStorage11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Renderer11.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d11/formatutils11.h&quot;
+#include &quot;libGLESv2/Buffer.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-BufferStorage11::BufferStorage11(Renderer11 *renderer)
</del><ins>+PackPixelsParams::PackPixelsParams()
+  : format(GL_NONE),
+    type(GL_NONE),
+    outputPitch(0),
+    packBuffer(NULL),
+    offset(0)
+{}
+
+PackPixelsParams::PackPixelsParams(const gl::Rectangle &amp;areaIn, GLenum formatIn, GLenum typeIn, GLuint outputPitchIn,
+                                   const gl::PixelPackState &amp;packIn, ptrdiff_t offsetIn)
+  : area(areaIn),
+    format(formatIn),
+    type(typeIn),
+    outputPitch(outputPitchIn),
+    packBuffer(packIn.pixelBuffer.get()),
+    pack(packIn.alignment, packIn.reverseRowOrder),
+    offset(offsetIn)
+{}
+
+namespace gl_d3d11
</ins><span class="cx"> {
</span><del>-    mRenderer = renderer;
</del><span class="cx"> 
</span><del>-    mStagingBuffer = NULL;
-    mStagingBufferSize = 0;
</del><ins>+D3D11_MAP GetD3DMapTypeFromBits(GLbitfield access)
+{
+    bool readBit = ((access &amp; GL_MAP_READ_BIT) != 0);
+    bool writeBit = ((access &amp; GL_MAP_WRITE_BIT) != 0);
</ins><span class="cx"> 
</span><del>-    mSize = 0;
</del><ins>+    ASSERT(readBit || writeBit);
</ins><span class="cx"> 
</span><del>-    mResolvedData = NULL;
-    mResolvedDataSize = 0;
-    mResolvedDataValid = false;
</del><ins>+    // Note : we ignore the discard bit, because in D3D11, staging buffers
+    //  don't accept the map-discard flag (discard only works for DYNAMIC usage)
</ins><span class="cx"> 
</span><del>-    mReadUsageCount = 0;
-    mWriteUsageCount = 0;
</del><ins>+    if (readBit &amp;&amp; !writeBit)
+    {
+        return D3D11_MAP_READ;
+    }
+    else if (writeBit &amp;&amp; !readBit)
+    {
+        return D3D11_MAP_WRITE;
+    }
+    else if (writeBit &amp;&amp; readBit)
+    {
+        return D3D11_MAP_READ_WRITE;
+    }
+    else
+    {
+        UNREACHABLE();
+        return D3D11_MAP_READ;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-BufferStorage11::~BufferStorage11()
</del><ins>+}
+
+// Each instance of BufferStorageD3DBuffer11 is specialized for a class of D3D binding points
+// - vertex/transform feedback buffers
+// - index buffers
+// - pixel unpack buffers
+// - uniform buffers
+class BufferStorage11::TypedBufferStorage11
</ins><span class="cx"> {
</span><del>-    SafeRelease(mStagingBuffer);
</del><ins>+  public:
+    virtual ~TypedBufferStorage11() {}
</ins><span class="cx"> 
</span><del>-    if (mResolvedData)
-    {
-        free(mResolvedData);
-        mResolvedData = NULL;
-    }
</del><ins>+    DataRevision getDataRevision() const { return mRevision; }
+    BufferUsage getUsage() const { return mUsage; }
+    size_t getSize() const { return mBufferSize; }
</ins><span class="cx"> 
</span><del>-    for (auto it = mDirectBuffers.begin(); it != mDirectBuffers.end(); it++)
</del><ins>+    void setDataRevision(DataRevision rev) { mRevision = rev; }
+
+    virtual bool copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset,
+                                 size_t size, size_t destOffset) = 0;
+    virtual void resize(size_t size, bool preserveData) = 0;
+
+    virtual void *map(GLbitfield access) = 0;
+    virtual void unmap() = 0;
+
+  protected:
+    TypedBufferStorage11(Renderer11 *renderer, BufferUsage usage);
+
+    Renderer11 *mRenderer;
+    DataRevision mRevision;
+    const BufferUsage mUsage;
+    size_t mBufferSize;
+};
+
+// A native buffer storage represents an underlying D3D11 buffer for a particular
+// type of storage.
+class BufferStorage11::NativeBuffer11 : public BufferStorage11::TypedBufferStorage11
+{
+  public:
+    NativeBuffer11(Renderer11 *renderer, BufferUsage usage);
+    ~NativeBuffer11();
+
+    ID3D11Buffer *getNativeBuffer() const { return mNativeBuffer; }
+
+    virtual bool copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset,
+                                 size_t size, size_t destOffset);
+    virtual void resize(size_t size, bool preserveData);
+
+    virtual void *map(GLbitfield access);
+    virtual void unmap();
+
+  private:
+    ID3D11Buffer *mNativeBuffer;
+
+    static void fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer, BufferUsage usage, unsigned int bufferSize);
+};
+
+// Pack storage represents internal storage for pack buffers. We implement pack buffers
+// as CPU memory, tied to a staging texture, for asynchronous texture readback.
+class BufferStorage11::PackStorage11 : public BufferStorage11::TypedBufferStorage11
+{
+  public:
+    PackStorage11(Renderer11 *renderer);
+    ~PackStorage11();
+
+    virtual bool copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset,
+                                 size_t size, size_t destOffset);
+    virtual void resize(size_t size, bool preserveData);
+
+    virtual void *map(GLbitfield access);
+    virtual void unmap();
+
+    void packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &amp;params);
+
+  private:
+    ID3D11Texture2D *mStagingTexture;
+    DXGI_FORMAT mTextureFormat;
+    gl::Extents mTextureSize;
+    unsigned char *mMemoryBuffer;
+    PackPixelsParams mPackParams;
+    bool mDataModified;
+};
+
+BufferStorage11::BufferStorage11(Renderer11 *renderer)
+    : mRenderer(renderer),
+      mMappedStorage(NULL),
+      mResolvedDataRevision(0),
+      mReadUsageCount(0),
+      mWriteUsageCount(0),
+      mSize(0)
+{
+}
+
+BufferStorage11::~BufferStorage11()
+{
+    for (auto it = mTypedBuffers.begin(); it != mTypedBuffers.end(); it++)
</ins><span class="cx">     {
</span><span class="cx">         SafeDelete(it-&gt;second);
</span><span class="cx">     }
</span><span class="lines">@@ -55,109 +176,55 @@
</span><span class="cx"> 
</span><span class="cx"> void *BufferStorage11::getData()
</span><span class="cx"> {
</span><del>-    ASSERT(mStagingBuffer);
-
-    if (!mResolvedDataValid)
</del><ins>+    NativeBuffer11 *stagingBuffer = getStagingBuffer();
+    if (stagingBuffer-&gt;getDataRevision() &gt; mResolvedDataRevision)
</ins><span class="cx">     {
</span><del>-        ID3D11Device *device = mRenderer-&gt;getDevice();
-        ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
-        HRESULT result;
-
-        if (!mResolvedData || mResolvedDataSize &lt; mStagingBufferSize)
</del><ins>+        if (stagingBuffer-&gt;getSize() &gt; mResolvedData.size())
</ins><span class="cx">         {
</span><del>-            free(mResolvedData);
-            mResolvedData = malloc(mSize);
-            mResolvedDataSize = mSize;
</del><ins>+            mResolvedData.resize(stagingBuffer-&gt;getSize());
</ins><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
+
</ins><span class="cx">         D3D11_MAPPED_SUBRESOURCE mappedResource;
</span><del>-        result = context-&gt;Map(mStagingBuffer, 0, D3D11_MAP_READ, 0, &amp;mappedResource);
</del><ins>+        HRESULT result = context-&gt;Map(stagingBuffer-&gt;getNativeBuffer(), 0, D3D11_MAP_READ, 0, &amp;mappedResource);
</ins><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="cx">             return gl::error(GL_OUT_OF_MEMORY, (void*)NULL);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        memcpy(mResolvedData, mappedResource.pData, mSize);
</del><ins>+        memcpy(mResolvedData.data(), mappedResource.pData, stagingBuffer-&gt;getSize());
</ins><span class="cx"> 
</span><del>-        context-&gt;Unmap(mStagingBuffer, 0);
</del><ins>+        context-&gt;Unmap(stagingBuffer-&gt;getNativeBuffer(), 0);
</ins><span class="cx"> 
</span><del>-        mResolvedDataValid = true;
</del><ins>+        mResolvedDataRevision = stagingBuffer-&gt;getDataRevision();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mReadUsageCount = 0;
-
-    return mResolvedData;
</del><ins>+    return mResolvedData.data();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void BufferStorage11::setData(const void* data, unsigned int size, unsigned int offset)
</span><span class="cx"> {
</span><del>-    ID3D11Device *device = mRenderer-&gt;getDevice();
-    ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
-    HRESULT result;
</del><ins>+    size_t requiredSize = size + offset;
+    mWriteUsageCount = 0;
+    mSize = std::max(mSize, requiredSize);
</ins><span class="cx"> 
</span><del>-    const unsigned int requiredStagingBufferSize = size + offset;
-    const bool createStagingBuffer = !mStagingBuffer || mStagingBufferSize &lt; requiredStagingBufferSize;
-
-    if (createStagingBuffer)
</del><ins>+    if (data)
</ins><span class="cx">     {
</span><del>-        D3D11_BUFFER_DESC bufferDesc;
-        bufferDesc.ByteWidth = requiredStagingBufferSize;
-        bufferDesc.Usage = D3D11_USAGE_STAGING;
-        bufferDesc.BindFlags = 0;
-        bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
-        bufferDesc.MiscFlags = 0;
-        bufferDesc.StructureByteStride = 0;
</del><ins>+        NativeBuffer11 *stagingBuffer = getStagingBuffer();
</ins><span class="cx"> 
</span><del>-        HRESULT result;
-        ID3D11Device *device = mRenderer-&gt;getDevice();
-        ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
-        ID3D11Buffer *newStagingBuffer;
-
-        if (data &amp;&amp; offset == 0)
</del><ins>+        // Explicitly resize the staging buffer, preserving data if the new data will not
+        // completely fill the buffer
+        if (stagingBuffer-&gt;getSize() &lt; requiredSize)
</ins><span class="cx">         {
</span><del>-            D3D11_SUBRESOURCE_DATA initialData;
-            initialData.pSysMem = data;
-            initialData.SysMemPitch = requiredStagingBufferSize;
-            initialData.SysMemSlicePitch = 0;
-
-            result = device-&gt;CreateBuffer(&amp;bufferDesc, &amp;initialData, &amp;newStagingBuffer);
</del><ins>+            bool preserveData = (offset &gt; 0);
+            stagingBuffer-&gt;resize(requiredSize, preserveData);
</ins><span class="cx">         }
</span><del>-        else
-        {
-            result = device-&gt;CreateBuffer(&amp;bufferDesc, NULL, &amp;newStagingBuffer);
-        }
</del><span class="cx"> 
</span><del>-        if (FAILED(result))
-        {
-            mStagingBufferSize = 0;
-            return gl::error(GL_OUT_OF_MEMORY);
-        }
</del><ins>+        ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
</ins><span class="cx"> 
</span><del>-        mStagingBufferSize = requiredStagingBufferSize;
-
-        if (mStagingBuffer &amp;&amp; offset &gt; 0)
-        {
-            // If offset is greater than zero and the buffer is non-null, need to preserve the data from
-            // the old buffer up to offset
-            D3D11_BOX srcBox;
-            srcBox.left = 0;
-            srcBox.right = std::min(offset, requiredStagingBufferSize);
-            srcBox.top = 0;
-            srcBox.bottom = 1;
-            srcBox.front = 0;
-            srcBox.back = 1;
-
-            context-&gt;CopySubresourceRegion(newStagingBuffer, 0, 0, 0, 0, mStagingBuffer, 0, &amp;srcBox);
-        }
-
-        SafeRelease(mStagingBuffer);
-        mStagingBuffer = newStagingBuffer;
-    }
-
-    if (data &amp;&amp; (offset != 0 || !createStagingBuffer))
-    {
</del><span class="cx">         D3D11_MAPPED_SUBRESOURCE mappedResource;
</span><del>-        result = context-&gt;Map(mStagingBuffer, 0, D3D11_MAP_WRITE, 0, &amp;mappedResource);
</del><ins>+        HRESULT result = context-&gt;Map(stagingBuffer-&gt;getNativeBuffer(), 0, D3D11_MAP_WRITE, 0, &amp;mappedResource);
</ins><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="cx">             return gl::error(GL_OUT_OF_MEMORY);
</span><span class="lines">@@ -166,47 +233,47 @@
</span><span class="cx">         unsigned char *offsetBufferPointer = reinterpret_cast&lt;unsigned char *&gt;(mappedResource.pData) + offset;
</span><span class="cx">         memcpy(offsetBufferPointer, data, size);
</span><span class="cx"> 
</span><del>-        context-&gt;Unmap(mStagingBuffer, 0);
-    }
</del><ins>+        context-&gt;Unmap(stagingBuffer-&gt;getNativeBuffer(), 0);
</ins><span class="cx"> 
</span><del>-    for (auto it = mDirectBuffers.begin(); it != mDirectBuffers.end(); it++)
-    {
-        it-&gt;second-&gt;markDirty();
</del><ins>+        stagingBuffer-&gt;setDataRevision(stagingBuffer-&gt;getDataRevision() + 1);
</ins><span class="cx">     }
</span><del>-
-    mSize = std::max(mSize, requiredStagingBufferSize);
-    mWriteUsageCount = 0;
-
-    mResolvedDataValid = false;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void BufferStorage11::copyData(BufferStorage* sourceStorage, unsigned int size,
</span><span class="cx">                                unsigned int sourceOffset, unsigned int destOffset)
</span><span class="cx"> {
</span><del>-    BufferStorage11* source = makeBufferStorage11(sourceStorage);
-    if (source)
</del><ins>+    BufferStorage11* sourceStorage11 = makeBufferStorage11(sourceStorage);
+    if (sourceStorage11)
</ins><span class="cx">     {
</span><del>-        ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
</del><ins>+        TypedBufferStorage11 *dest = getLatestStorage();
+        if (!dest)
+        {
+            dest = getStagingBuffer();
+        }
</ins><span class="cx"> 
</span><del>-        D3D11_BOX srcBox;
-        srcBox.left = sourceOffset;
-        srcBox.right = sourceOffset + size;
-        srcBox.top = 0;
-        srcBox.bottom = 1;
-        srcBox.front = 0;
-        srcBox.back = 1;
</del><ins>+        TypedBufferStorage11 *source = sourceStorage11-&gt;getLatestStorage();
+        if (source &amp;&amp; dest)
+        {
+            dest-&gt;copyFromStorage(source, sourceOffset, size, destOffset);
+            dest-&gt;setDataRevision(dest-&gt;getDataRevision() + 1);
+        }
</ins><span class="cx"> 
</span><del>-        ASSERT(mStagingBuffer &amp;&amp; source-&gt;mStagingBuffer);
-        context-&gt;CopySubresourceRegion(mStagingBuffer, 0, destOffset, 0, 0, source-&gt;mStagingBuffer, 0, &amp;srcBox);
</del><ins>+        mSize = std::max(mSize, destOffset + size);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void BufferStorage11::clear()
</span><span class="cx"> {
</span><del>-    mResolvedDataValid = false;
</del><span class="cx">     mSize = 0;
</span><ins>+    mResolvedDataRevision = 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void BufferStorage11::markTransformFeedbackUsage()
+{
+    TypedBufferStorage11 *transformFeedbackStorage = getStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK);
+    transformFeedbackStorage-&gt;setDataRevision(transformFeedbackStorage-&gt;getDataRevision() + 1);
+}
+
</ins><span class="cx"> unsigned int BufferStorage11::getSize() const
</span><span class="cx"> {
</span><span class="cx">     return mSize;
</span><span class="lines">@@ -224,12 +291,10 @@
</span><span class="cx"> 
</span><span class="cx">     const unsigned int usageLimit = 5;
</span><span class="cx"> 
</span><del>-    if (mReadUsageCount &gt; usageLimit &amp;&amp; mResolvedData)
</del><ins>+    if (mReadUsageCount &gt; usageLimit &amp;&amp; mResolvedData.size() &gt; 0)
</ins><span class="cx">     {
</span><del>-        free(mResolvedData);
-        mResolvedData = NULL;
-        mResolvedDataSize = 0;
-        mResolvedDataValid = false;
</del><ins>+        mResolvedData.resize(0);
+        mResolvedDataRevision = 0;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -237,118 +302,287 @@
</span><span class="cx"> {
</span><span class="cx">     markBufferUsage();
</span><span class="cx"> 
</span><del>-    DirectBufferStorage11 *directBuffer = NULL;
</del><ins>+    TypedBufferStorage11 *typedBuffer = getStorage(usage);
+    ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, typedBuffer));
</ins><span class="cx"> 
</span><del>-    auto directBufferIt = mDirectBuffers.find(usage);
-    if (directBufferIt != mDirectBuffers.end())
</del><ins>+    return static_cast&lt;NativeBuffer11*&gt;(typedBuffer)-&gt;getNativeBuffer();
+}
+
+ID3D11ShaderResourceView *BufferStorage11::getSRV(DXGI_FORMAT srvFormat)
+{
+    TypedBufferStorage11 *storage = getStorage(BUFFER_USAGE_PIXEL_UNPACK);
+    ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, storage));
+    ID3D11Buffer *buffer = static_cast&lt;NativeBuffer11*&gt;(storage)-&gt;getNativeBuffer();
+
+    auto bufferSRVIt = mBufferResourceViews.find(srvFormat);
+
+    if (bufferSRVIt != mBufferResourceViews.end())
</ins><span class="cx">     {
</span><ins>+        if (bufferSRVIt-&gt;second.first == buffer)
+        {
+            return bufferSRVIt-&gt;second.second;
+        }
+        else
+        {
+            // The underlying buffer has changed since the SRV was created: recreate the SRV.
+            SafeRelease(bufferSRVIt-&gt;second.second);
+        }
+    }
+
+    ID3D11Device *device = mRenderer-&gt;getDevice();
+    ID3D11ShaderResourceView *bufferSRV = NULL;
+
+    D3D11_SHADER_RESOURCE_VIEW_DESC bufferSRVDesc;
+    bufferSRVDesc.Buffer.ElementOffset = 0;
+    bufferSRVDesc.Buffer.ElementWidth = mSize / d3d11::GetFormatPixelBytes(srvFormat);
+    bufferSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
+    bufferSRVDesc.Format = srvFormat;
+
+    HRESULT result = device-&gt;CreateShaderResourceView(buffer, &amp;bufferSRVDesc, &amp;bufferSRV);
+    ASSERT(SUCCEEDED(result));
+
+    mBufferResourceViews[srvFormat] = BufferSRVPair(buffer, bufferSRV);
+
+    return bufferSRV;
+}
+
+void BufferStorage11::packPixels(ID3D11Texture2D *srcTexture, UINT srcSubresource, const PackPixelsParams &amp;params)
+{
+    PackStorage11 *packStorage = getPackStorage();
+
+    TypedBufferStorage11 *latestStorage = getLatestStorage();
+
+    packStorage-&gt;packPixels(srcTexture, srcSubresource, params);
+    packStorage-&gt;setDataRevision(latestStorage ? latestStorage-&gt;getDataRevision() + 1 : 1);
+}
+
+BufferStorage11::TypedBufferStorage11 *BufferStorage11::getStorage(BufferUsage usage)
+{
+    TypedBufferStorage11 *directBuffer = NULL;
+    auto directBufferIt = mTypedBuffers.find(usage);
+    if (directBufferIt != mTypedBuffers.end())
+    {
</ins><span class="cx">         directBuffer = directBufferIt-&gt;second;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (directBuffer)
</del><ins>+    if (!directBuffer)
</ins><span class="cx">     {
</span><del>-        if (directBuffer-&gt;isDirty())
</del><ins>+        if (usage == BUFFER_USAGE_PIXEL_PACK)
</ins><span class="cx">         {
</span><del>-            // if updateFromStagingBuffer returns true, the D3D buffer has been recreated
-            // and we should update our serial
-            if (directBuffer-&gt;updateFromStagingBuffer(mStagingBuffer, mSize, 0))
-            {
-                updateSerial();
-            }
</del><ins>+            directBuffer = new PackStorage11(mRenderer);
</ins><span class="cx">         }
</span><ins>+        else
+        {
+            // buffer is not allocated, create it
+            directBuffer = new NativeBuffer11(mRenderer, usage);
+        }
+
+        mTypedBuffers.insert(std::make_pair(usage, directBuffer));
</ins><span class="cx">     }
</span><del>-    else
</del><ins>+
+    // resize buffer
+    if (directBuffer-&gt;getSize() &lt; mSize)
</ins><span class="cx">     {
</span><del>-        // buffer is not allocated, create it
-        directBuffer = new DirectBufferStorage11(mRenderer, usage);
-        directBuffer-&gt;updateFromStagingBuffer(mStagingBuffer, mSize, 0);
</del><ins>+        directBuffer-&gt;resize(mSize, true);
+    }
</ins><span class="cx"> 
</span><del>-        mDirectBuffers.insert(std::make_pair(usage, directBuffer));
-        updateSerial();
</del><ins>+    TypedBufferStorage11 *latestBuffer = getLatestStorage();
+    if (latestBuffer &amp;&amp; latestBuffer-&gt;getDataRevision() &gt; directBuffer-&gt;getDataRevision())
+    {
+        // if copyFromStorage returns true, the D3D buffer has been recreated
+        // and we should update our serial
+        if (directBuffer-&gt;copyFromStorage(latestBuffer, 0, latestBuffer-&gt;getSize(), 0))
+        {
+            updateSerial();
+        }
+        directBuffer-&gt;setDataRevision(latestBuffer-&gt;getDataRevision());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return directBuffer-&gt;getD3DBuffer();
</del><ins>+    return directBuffer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-DirectBufferStorage11::DirectBufferStorage11(Renderer11 *renderer, BufferUsage usage)
</del><ins>+BufferStorage11::TypedBufferStorage11 *BufferStorage11::getLatestStorage() const
+{
+    // Even though we iterate over all the direct buffers, it is expected that only
+    // 1 or 2 will be present.
+    TypedBufferStorage11 *latestStorage = NULL;
+    DataRevision latestRevision = 0;
+    for (auto it = mTypedBuffers.begin(); it != mTypedBuffers.end(); it++)
+    {
+        TypedBufferStorage11 *storage = it-&gt;second;
+        if (storage-&gt;getDataRevision() &gt; latestRevision)
+        {
+            latestStorage = storage;
+            latestRevision = storage-&gt;getDataRevision();
+        }
+    }
+
+    return latestStorage;
+}
+
+bool BufferStorage11::isMapped() const
+{
+    return mMappedStorage != NULL;
+}
+
+void *BufferStorage11::map(GLbitfield access)
+{
+    ASSERT(!mMappedStorage);
+
+    TypedBufferStorage11 *latestStorage = getLatestStorage();
+
+    if (latestStorage-&gt;getUsage() == BUFFER_USAGE_PIXEL_PACK ||
+        latestStorage-&gt;getUsage() == BUFFER_USAGE_STAGING)
+    {
+        mMappedStorage = latestStorage;
+    }
+    else
+    {
+        mMappedStorage = getStagingBuffer();
+    }
+
+    return mMappedStorage-&gt;map(access);
+}
+
+void BufferStorage11::unmap()
+{
+    ASSERT(mMappedStorage);
+    mMappedStorage-&gt;unmap();
+    mMappedStorage = NULL;
+}
+
+BufferStorage11::NativeBuffer11 *BufferStorage11::getStagingBuffer()
+{
+    TypedBufferStorage11 *stagingStorage = getStorage(BUFFER_USAGE_STAGING);
+    ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, stagingStorage));
+    return static_cast&lt;NativeBuffer11*&gt;(stagingStorage);
+}
+
+BufferStorage11::PackStorage11 *BufferStorage11::getPackStorage()
+{
+    TypedBufferStorage11 *packStorage = getStorage(BUFFER_USAGE_PIXEL_PACK);
+    ASSERT(HAS_DYNAMIC_TYPE(PackStorage11*, packStorage));
+    return static_cast&lt;PackStorage11*&gt;(packStorage);
+}
+
+BufferStorage11::TypedBufferStorage11::TypedBufferStorage11(Renderer11 *renderer, BufferUsage usage)
</ins><span class="cx">     : mRenderer(renderer),
</span><span class="cx">       mUsage(usage),
</span><del>-      mDirectBuffer(NULL),
-      mBufferSize(0),
-      mDirty(false)
</del><ins>+      mRevision(0),
+      mBufferSize(0)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DirectBufferStorage11::~DirectBufferStorage11()
</del><ins>+BufferStorage11::NativeBuffer11::NativeBuffer11(Renderer11 *renderer, BufferUsage usage)
+    : TypedBufferStorage11(renderer, usage),
+      mNativeBuffer(NULL)
</ins><span class="cx"> {
</span><del>-    SafeRelease(mDirectBuffer);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-BufferUsage DirectBufferStorage11::getUsage() const
</del><ins>+BufferStorage11::NativeBuffer11::~NativeBuffer11()
</ins><span class="cx"> {
</span><del>-    return mUsage;
</del><ins>+    SafeRelease(mNativeBuffer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Returns true if it recreates the direct buffer
</span><del>-bool DirectBufferStorage11::updateFromStagingBuffer(ID3D11Buffer *stagingBuffer, size_t size, size_t offset)
</del><ins>+bool BufferStorage11::NativeBuffer11::copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset,
+                                                      size_t size, size_t destOffset)
</ins><span class="cx"> {
</span><del>-    ID3D11Device *device = mRenderer-&gt;getDevice();
</del><ins>+    if (source-&gt;getUsage() == BUFFER_USAGE_PIXEL_PACK)
+    {
+        UNIMPLEMENTED();
+        return false;
+    }
+
+    ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, source));
+
+    if (source-&gt;getUsage() == BUFFER_USAGE_PIXEL_PACK)
+    {
+        return false;
+    }
+
</ins><span class="cx">     ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
</span><span class="cx"> 
</span><del>-    // unused for now
-    ASSERT(offset == 0);
</del><ins>+    size_t requiredSize = sourceOffset + size;
+    bool createBuffer = !mNativeBuffer || mBufferSize &lt; requiredSize;
</ins><span class="cx"> 
</span><del>-    unsigned int requiredBufferSize = size + offset;
-    bool createBuffer = !mDirectBuffer || mBufferSize &lt; requiredBufferSize;
-
</del><span class="cx">     // (Re)initialize D3D buffer if needed
</span><span class="cx">     if (createBuffer)
</span><span class="cx">     {
</span><del>-        D3D11_BUFFER_DESC bufferDesc;
-        fillBufferDesc(&amp;bufferDesc, mRenderer, mUsage, requiredBufferSize);
-
-        ID3D11Buffer *newBuffer;
-        HRESULT result = device-&gt;CreateBuffer(&amp;bufferDesc, NULL, &amp;newBuffer);
-
-        if (FAILED(result))
-        {
-            return gl::error(GL_OUT_OF_MEMORY, false);
-        }
-
-        // No longer need the old buffer
-        SafeRelease(mDirectBuffer);
-        mDirectBuffer = newBuffer;
-
-        mBufferSize = bufferDesc.ByteWidth;
</del><ins>+        bool preserveData = (destOffset &gt; 0);
+        resize(source-&gt;getSize(), preserveData);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Copy data via staging buffer
</del><span class="cx">     D3D11_BOX srcBox;
</span><del>-    srcBox.left = 0;
-    srcBox.right = size;
</del><ins>+    srcBox.left = sourceOffset;
+    srcBox.right = sourceOffset + size;
</ins><span class="cx">     srcBox.top = 0;
</span><span class="cx">     srcBox.bottom = 1;
</span><span class="cx">     srcBox.front = 0;
</span><span class="cx">     srcBox.back = 1;
</span><span class="cx"> 
</span><del>-    context-&gt;CopySubresourceRegion(mDirectBuffer, 0, offset, 0, 0, stagingBuffer, 0, &amp;srcBox);
</del><ins>+    ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, source));
+    ID3D11Buffer *sourceBuffer = static_cast&lt;NativeBuffer11*&gt;(source)-&gt;getNativeBuffer();
</ins><span class="cx"> 
</span><del>-    mDirty = false;
</del><ins>+    context-&gt;CopySubresourceRegion(mNativeBuffer, 0, destOffset, 0, 0, sourceBuffer, 0, &amp;srcBox);
</ins><span class="cx"> 
</span><span class="cx">     return createBuffer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DirectBufferStorage11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer, BufferUsage usage, unsigned int bufferSize)
</del><ins>+void BufferStorage11::NativeBuffer11::resize(size_t size, bool preserveData)
</ins><span class="cx"> {
</span><ins>+    ID3D11Device *device = mRenderer-&gt;getDevice();
+    ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
+
+    D3D11_BUFFER_DESC bufferDesc;
+    fillBufferDesc(&amp;bufferDesc, mRenderer, mUsage, size);
+
+    ID3D11Buffer *newBuffer;
+    HRESULT result = device-&gt;CreateBuffer(&amp;bufferDesc, NULL, &amp;newBuffer);
+
+    if (FAILED(result))
+    {
+        return gl::error(GL_OUT_OF_MEMORY);
+    }
+
+    if (mNativeBuffer &amp;&amp; preserveData)
+    {
+        D3D11_BOX srcBox;
+        srcBox.left = 0;
+        srcBox.right = size;
+        srcBox.top = 0;
+        srcBox.bottom = 1;
+        srcBox.front = 0;
+        srcBox.back = 1;
+
+        context-&gt;CopySubresourceRegion(newBuffer, 0, 0, 0, 0, mNativeBuffer, 0, &amp;srcBox);
+    }
+
+    // No longer need the old buffer
+    SafeRelease(mNativeBuffer);
+    mNativeBuffer = newBuffer;
+
+    mBufferSize = bufferDesc.ByteWidth;
+}
+
+void BufferStorage11::NativeBuffer11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer,
+                                                     BufferUsage usage, unsigned int bufferSize)
+{
</ins><span class="cx">     bufferDesc-&gt;ByteWidth = bufferSize;
</span><span class="cx">     bufferDesc-&gt;MiscFlags = 0;
</span><span class="cx">     bufferDesc-&gt;StructureByteStride = 0;
</span><span class="cx"> 
</span><span class="cx">     switch (usage)
</span><span class="cx">     {
</span><del>-      case BUFFER_USAGE_VERTEX:
</del><ins>+      case BUFFER_USAGE_STAGING:
+        bufferDesc-&gt;Usage = D3D11_USAGE_STAGING;
+        bufferDesc-&gt;BindFlags = 0;
+        bufferDesc-&gt;CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
+        break;
+
+      case BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK:
</ins><span class="cx">         bufferDesc-&gt;Usage = D3D11_USAGE_DEFAULT;
</span><del>-        bufferDesc-&gt;BindFlags = D3D11_BIND_VERTEX_BUFFER;
</del><ins>+        bufferDesc-&gt;BindFlags = D3D11_BIND_VERTEX_BUFFER | D3D11_BIND_STREAM_OUTPUT;
</ins><span class="cx">         bufferDesc-&gt;CPUAccessFlags = 0;
</span><span class="cx">         break;
</span><span class="cx"> 
</span><span class="lines">@@ -358,9 +592,161 @@
</span><span class="cx">         bufferDesc-&gt;CPUAccessFlags = 0;
</span><span class="cx">         break;
</span><span class="cx"> 
</span><ins>+      case BUFFER_USAGE_PIXEL_UNPACK:
+        bufferDesc-&gt;Usage = D3D11_USAGE_DEFAULT;
+        bufferDesc-&gt;BindFlags = D3D11_BIND_SHADER_RESOURCE;
+        bufferDesc-&gt;CPUAccessFlags = 0;
+        break;
+
+      case BUFFER_USAGE_UNIFORM:
+        bufferDesc-&gt;Usage = D3D11_USAGE_DYNAMIC;
+        bufferDesc-&gt;BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+        bufferDesc-&gt;CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+
+        // Constant buffers must be of a limited size, and aligned to 16 byte boundaries
+        // For our purposes we ignore any buffer data past the maximum constant buffer size
+        bufferDesc-&gt;ByteWidth = roundUp(bufferDesc-&gt;ByteWidth, 16u);
+        bufferDesc-&gt;ByteWidth = std::min(bufferDesc-&gt;ByteWidth, renderer-&gt;getMaxUniformBufferSize());
+        break;
+
</ins><span class="cx">     default:
</span><span class="cx">         UNREACHABLE();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void *BufferStorage11::NativeBuffer11::map(GLbitfield access)
+{
+    ASSERT(mUsage == BUFFER_USAGE_STAGING);
+
+    D3D11_MAPPED_SUBRESOURCE mappedResource;
+    ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
+    D3D11_MAP d3dMapType = gl_d3d11::GetD3DMapTypeFromBits(access);
+    UINT d3dMapFlag = ((access &amp; GL_MAP_UNSYNCHRONIZED_BIT) != 0 ? D3D11_MAP_FLAG_DO_NOT_WAIT : 0);
+
+    HRESULT result = context-&gt;Map(mNativeBuffer, 0, d3dMapType, d3dMapFlag, &amp;mappedResource);
+    ASSERT(SUCCEEDED(result));
+
+    return mappedResource.pData;
</ins><span class="cx"> }
</span><ins>+
+void BufferStorage11::NativeBuffer11::unmap()
+{
+    ASSERT(mUsage == BUFFER_USAGE_STAGING);
+    ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
+    context-&gt;Unmap(mNativeBuffer, 0);
+}
+
+BufferStorage11::PackStorage11::PackStorage11(Renderer11 *renderer)
+    : TypedBufferStorage11(renderer, BUFFER_USAGE_PIXEL_PACK),
+      mStagingTexture(NULL),
+      mTextureFormat(DXGI_FORMAT_UNKNOWN),
+      mMemoryBuffer(NULL),
+      mDataModified(false)
+{
+}
+
+BufferStorage11::PackStorage11::~PackStorage11()
+{
+    SafeRelease(mStagingTexture);
+    SafeDeleteArray(mMemoryBuffer);
+}
+
+bool BufferStorage11::PackStorage11::copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset,
+                                                     size_t size, size_t destOffset)
+{
+    UNIMPLEMENTED();
+    return false;
+}
+
+void BufferStorage11::PackStorage11::resize(size_t size, bool preserveData)
+{
+    UNIMPLEMENTED();
+}
+
+void *BufferStorage11::PackStorage11::map(GLbitfield access)
+{
+    ASSERT(!mMemoryBuffer);
+
+    // TODO: fast path
+    //  We might be able to optimize out one or more memcpy calls by detecting when
+    //  and if D3D packs the staging texture memory identically to how we would fill
+    //  the pack buffer according to the current pack state.
+
+    mMemoryBuffer = new unsigned char[mBufferSize];
+    mRenderer-&gt;packPixels(mStagingTexture, mPackParams, mMemoryBuffer);
+    mDataModified = (mDataModified || (access &amp; GL_MAP_WRITE_BIT) != 0);
+
+    return mMemoryBuffer;
+}
+
+void BufferStorage11::PackStorage11::unmap()
+{
+    ASSERT(mMemoryBuffer);
+    SafeDeleteArray(mMemoryBuffer);
+}
+
+void BufferStorage11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &amp;params)
+{
+    mPackParams = params;
+    mBufferSize = mPackParams.outputPitch * mPackParams.area.height;
+
+    D3D11_TEXTURE2D_DESC textureDesc;
+    srcTexure-&gt;GetDesc(&amp;textureDesc);
+
+    if (mStagingTexture != NULL &amp;&amp;
+        (mTextureFormat != textureDesc.Format ||
+         mTextureSize.width != params.area.width ||
+         mTextureSize.height != params.area.height))
+    {
+        SafeRelease(mStagingTexture);
+        mTextureSize.width = 0;
+        mTextureSize.height = 0;
+        mTextureFormat = DXGI_FORMAT_UNKNOWN;
+    }
+
+    if (mStagingTexture == NULL)
+    {
+        ID3D11Device *device = mRenderer-&gt;getDevice();
+        HRESULT hr;
+
+        mTextureSize.width = params.area.width;
+        mTextureSize.height = params.area.height;
+        mTextureFormat = textureDesc.Format;
+
+        D3D11_TEXTURE2D_DESC stagingDesc;
+        stagingDesc.Width = params.area.width;
+        stagingDesc.Height = params.area.height;
+        stagingDesc.MipLevels = 1;
+        stagingDesc.ArraySize = 1;
+        stagingDesc.Format = mTextureFormat;
+        stagingDesc.SampleDesc.Count = 1;
+        stagingDesc.SampleDesc.Quality = 0;
+        stagingDesc.Usage = D3D11_USAGE_STAGING;
+        stagingDesc.BindFlags = 0;
+        stagingDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
+        stagingDesc.MiscFlags = 0;
+
+        hr = device-&gt;CreateTexture2D(&amp;stagingDesc, NULL, &amp;mStagingTexture);
+        ASSERT(SUCCEEDED(hr));
+    }
+
+    ID3D11Texture2D* srcTex = NULL;
+    if (textureDesc.SampleDesc.Count &gt; 1)
+    {
+        UNIMPLEMENTED();
+    }
+
+    ID3D11DeviceContext *immediateContext = mRenderer-&gt;getDeviceContext();
+    D3D11_BOX srcBox;
+    srcBox.left   = params.area.x;
+    srcBox.right  = params.area.x + params.area.width;
+    srcBox.top    = params.area.y;
+    srcBox.bottom = params.area.y + params.area.height;
+    srcBox.front  = 0;
+    srcBox.back   = 1;
+
+    // Asynchronous copy
+    immediateContext-&gt;CopySubresourceRegion(mStagingTexture, 0, 0, 0, 0, srcTexure, srcSubresource, &amp;srcBox);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11BufferStorage11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/BufferStorage11.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/BufferStorage11.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/BufferStorage11.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -10,19 +10,40 @@
</span><span class="cx"> #define LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/BufferStorage.h&quot;
</span><ins>+#include &quot;libGLESv2/angletypes.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> class Renderer;
</span><span class="cx"> class Renderer11;
</span><del>-class DirectBufferStorage11;
</del><span class="cx"> 
</span><span class="cx"> enum BufferUsage
</span><span class="cx"> {
</span><del>-    BUFFER_USAGE_VERTEX,
</del><ins>+    BUFFER_USAGE_STAGING,
+    BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK,
</ins><span class="cx">     BUFFER_USAGE_INDEX,
</span><ins>+    BUFFER_USAGE_PIXEL_UNPACK,
+    BUFFER_USAGE_PIXEL_PACK,
+    BUFFER_USAGE_UNIFORM,
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+struct PackPixelsParams
+{
+    PackPixelsParams();
+    PackPixelsParams(const gl::Rectangle &amp;area, GLenum format, GLenum type, GLuint outputPitch,
+                     const gl::PixelPackState &amp;pack, ptrdiff_t offset);
+
+    gl::Rectangle area;
+    GLenum format;
+    GLenum type;
+    GLuint outputPitch;
+    gl::Buffer *packBuffer;
+    gl::PixelPackState pack;
+    ptrdiff_t offset;
+};
+
+typedef size_t DataRevision;
+
</ins><span class="cx"> class BufferStorage11 : public BufferStorage
</span><span class="cx"> {
</span><span class="cx">   public:
</span><span class="lines">@@ -36,55 +57,45 @@
</span><span class="cx">     virtual void copyData(BufferStorage* sourceStorage, unsigned int size,
</span><span class="cx">                           unsigned int sourceOffset, unsigned int destOffset);
</span><span class="cx">     virtual void clear();
</span><ins>+    virtual void markTransformFeedbackUsage();
</ins><span class="cx">     virtual unsigned int getSize() const;
</span><span class="cx">     virtual bool supportsDirectBinding() const;
</span><span class="cx"> 
</span><span class="cx">     ID3D11Buffer *getBuffer(BufferUsage usage);
</span><ins>+    ID3D11ShaderResourceView *getSRV(DXGI_FORMAT srvFormat);
+    void packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &amp;params);
</ins><span class="cx"> 
</span><ins>+    virtual bool isMapped() const;
+    virtual void *map(GLbitfield access);
+    virtual void unmap();
+
</ins><span class="cx">   private:
</span><ins>+    class TypedBufferStorage11;
+    class NativeBuffer11;
+    class PackStorage11;
+
</ins><span class="cx">     Renderer11 *mRenderer;
</span><ins>+    TypedBufferStorage11 *mMappedStorage;
</ins><span class="cx"> 
</span><del>-    ID3D11Buffer *mStagingBuffer;
-    unsigned int mStagingBufferSize;
</del><ins>+    std::map&lt;BufferUsage, TypedBufferStorage11*&gt; mTypedBuffers;
</ins><span class="cx"> 
</span><del>-    std::map&lt;BufferUsage, DirectBufferStorage11*&gt; mDirectBuffers;
</del><ins>+    typedef std::pair&lt;ID3D11Buffer *, ID3D11ShaderResourceView *&gt; BufferSRVPair;
+    std::map&lt;DXGI_FORMAT, BufferSRVPair&gt; mBufferResourceViews;
</ins><span class="cx"> 
</span><del>-    unsigned int mSize;
</del><ins>+    std::vector&lt;unsigned char&gt; mResolvedData;
+    DataRevision mResolvedDataRevision;
</ins><span class="cx"> 
</span><del>-    void *mResolvedData;
-    unsigned int mResolvedDataSize;
-    bool mResolvedDataValid;
-
</del><span class="cx">     unsigned int mReadUsageCount;
</span><span class="cx">     unsigned int mWriteUsageCount;
</span><span class="cx"> 
</span><ins>+    size_t mSize;
+
</ins><span class="cx">     void markBufferUsage();
</span><del>-};
</del><ins>+    NativeBuffer11 *getStagingBuffer();
+    PackStorage11 *getPackStorage();
</ins><span class="cx"> 
</span><del>-// Each instance of BufferStorageD3DBuffer11 is specialized for a class of D3D binding points
-// - vertex buffers
-// - index buffers
-class DirectBufferStorage11
-{
-  public:
-    DirectBufferStorage11(Renderer11 *renderer, BufferUsage usage);
-    ~DirectBufferStorage11();
-
-    BufferUsage getUsage() const;
-    bool updateFromStagingBuffer(ID3D11Buffer *stagingBuffer, size_t size, size_t offset);
-
-    ID3D11Buffer *getD3DBuffer() { return mDirectBuffer; }
-    bool isDirty() const { return mDirty; }
-    void markDirty() { mDirty = true; }
-
-  private:
-    Renderer11 *mRenderer;
-    const BufferUsage mUsage;
-    ID3D11Buffer *mDirectBuffer;
-    size_t mBufferSize;
-    bool mDirty;
-
-    static void fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer, BufferUsage usage, unsigned int bufferSize);
</del><ins>+    TypedBufferStorage11 *getStorage(BufferUsage usage);
+    TypedBufferStorage11 *getLatestStorage() const;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Fence11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Fence11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Fence11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Fence11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -22,21 +22,15 @@
</span><span class="cx"> 
</span><span class="cx"> Fence11::~Fence11()
</span><span class="cx"> {
</span><del>-    if (mQuery)
-    {
-        mQuery-&gt;Release();
-        mQuery = NULL;
-    }
</del><ins>+    SafeRelease(mQuery);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLboolean Fence11::isFence()
</del><ins>+bool Fence11::isSet() const
</ins><span class="cx"> {
</span><del>-    // GL_NV_fence spec:
-    // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence.
</del><span class="cx">     return mQuery != NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Fence11::setFence(GLenum condition)
</del><ins>+void Fence11::set()
</ins><span class="cx"> {
</span><span class="cx">     if (!mQuery)
</span><span class="cx">     {
</span><span class="lines">@@ -51,84 +45,27 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     mRenderer-&gt;getDeviceContext()-&gt;End(mQuery);
</span><del>-
-    setCondition(condition);
-    setStatus(GL_FALSE);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLboolean Fence11::testFence()
</del><ins>+bool Fence11::test(bool flushCommandBuffer)
</ins><span class="cx"> {
</span><del>-    if (mQuery == NULL)
-    {
-        return gl::error(GL_INVALID_OPERATION, GL_TRUE);
-    }
</del><ins>+    ASSERT(mQuery);
</ins><span class="cx"> 
</span><del>-    HRESULT result = mRenderer-&gt;getDeviceContext()-&gt;GetData(mQuery, NULL, 0, 0);
</del><ins>+    UINT getDataFlags = (flushCommandBuffer ? 0 : D3D11_ASYNC_GETDATA_DONOTFLUSH);
+    HRESULT result = mRenderer-&gt;getDeviceContext()-&gt;GetData(mQuery, NULL, 0, getDataFlags);
</ins><span class="cx"> 
</span><span class="cx">     if (mRenderer-&gt;isDeviceLost())
</span><span class="cx">     {
</span><del>-       return gl::error(GL_OUT_OF_MEMORY, GL_TRUE);
</del><ins>+       return gl::error(GL_OUT_OF_MEMORY, true);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT(result == S_OK || result == S_FALSE);
</span><del>-    setStatus(result == S_OK);
-    return getStatus();
</del><ins>+    return (result == S_OK);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Fence11::finishFence()
</del><ins>+bool Fence11::hasError() const
</ins><span class="cx"> {
</span><del>-    if (mQuery == NULL)
-    {
-        return gl::error(GL_INVALID_OPERATION);
-    }
-
-    while (!testFence())
-    {
-        Sleep(0);
-    }
</del><ins>+    return mRenderer-&gt;isDeviceLost();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Fence11::getFenceiv(GLenum pname, GLint *params)
-{
-    if (mQuery == NULL)
-    {
-        return gl::error(GL_INVALID_OPERATION);
-    }
-
-    switch (pname)
-    {
-      case GL_FENCE_STATUS_NV:
-        {
-            // GL_NV_fence spec:
-            // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
-            // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
-            if (getStatus())
-            {
-                params[0] = GL_TRUE;
-                return;
-            }
-
-            HRESULT result = mRenderer-&gt;getDeviceContext()-&gt;GetData(mQuery, NULL, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH);
-
-            if (mRenderer-&gt;isDeviceLost())
-            {
-                params[0] = GL_TRUE;
-                return gl::error(GL_OUT_OF_MEMORY);
-            }
-
-            ASSERT(result == S_OK || result == S_FALSE);
-            setStatus(result == S_OK);
-            params[0] = getStatus();
-
-            break;
-        }
-      case GL_FENCE_CONDITION_NV:
-        params[0] = getCondition();
-        break;
-      default:
-        return gl::error(GL_INVALID_ENUM);
-        break;
-    }
</del><span class="cx"> }
</span><del>-
-}
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Fence11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Fence11.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Fence11.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Fence11.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -21,11 +21,10 @@
</span><span class="cx">     explicit Fence11(rx::Renderer11 *renderer);
</span><span class="cx">     virtual ~Fence11();
</span><span class="cx"> 
</span><del>-    GLboolean isFence();
-    void setFence(GLenum condition);
-    GLboolean testFence();
-    void finishFence();
-    void getFenceiv(GLenum pname, GLint *params);
</del><ins>+    bool isSet() const;
+    void set();
+    bool test(bool flushCommandBuffer);
+    bool hasError() const;
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Fence11);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Image11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Image11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Image11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Image11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -15,9 +15,9 @@
</span><span class="cx"> #include &quot;libGLESv2/Renderbuffer.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;common/utilities.h&quot;
+#include &quot;libGLESv2/renderer/d3d11/formatutils11.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/renderer11_utils.h&quot;
</span><del>-#include &quot;libGLESv2/renderer/generatemip.h&quot;
</del><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -31,10 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> Image11::~Image11()
</span><span class="cx"> {
</span><del>-    if (mStagingTexture)
-    {
-        mStagingTexture-&gt;Release();
-    }
</del><ins>+    SafeRelease(mStagingTexture);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Image11 *Image11::makeImage11(Image *img)
</span><span class="lines">@@ -43,125 +40,106 @@
</span><span class="cx">     return static_cast&lt;rx::Image11*&gt;(img);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Image11::generateMipmap(Image11 *dest, Image11 *src)
</del><ins>+void Image11::generateMipmap(GLuint clientVersion, Image11 *dest, Image11 *src)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(src-&gt;getDXGIFormat() == dest-&gt;getDXGIFormat());
</span><span class="cx">     ASSERT(src-&gt;getWidth() == 1 || src-&gt;getWidth() / 2 == dest-&gt;getWidth());
</span><span class="cx">     ASSERT(src-&gt;getHeight() == 1 || src-&gt;getHeight() / 2 == dest-&gt;getHeight());
</span><span class="cx"> 
</span><del>-    D3D11_MAPPED_SUBRESOURCE destMapped, srcMapped;
-    dest-&gt;map(D3D11_MAP_WRITE, &amp;destMapped);
-    src-&gt;map(D3D11_MAP_READ, &amp;srcMapped);
</del><ins>+    MipGenerationFunction mipFunction = d3d11::GetMipGenerationFunction(src-&gt;getDXGIFormat());
+    ASSERT(mipFunction != NULL);
</ins><span class="cx"> 
</span><del>-    const unsigned char *sourceData = reinterpret_cast&lt;const unsigned char*&gt;(srcMapped.pData);
-    unsigned char *destData = reinterpret_cast&lt;unsigned char*&gt;(destMapped.pData);
</del><ins>+    D3D11_MAPPED_SUBRESOURCE destMapped;
+    HRESULT destMapResult = dest-&gt;map(D3D11_MAP_WRITE, &amp;destMapped);
+    if (FAILED(destMapResult))
+    {
+        ERR(&quot;Failed to map destination image for mip map generation. HRESULT:0x%X&quot;, destMapResult);
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    if (sourceData &amp;&amp; destData)
</del><ins>+    D3D11_MAPPED_SUBRESOURCE srcMapped;
+    HRESULT srcMapResult = src-&gt;map(D3D11_MAP_READ, &amp;srcMapped);
+    if (FAILED(srcMapResult))
</ins><span class="cx">     {
</span><del>-        switch (src-&gt;getDXGIFormat())
-        {
-          case DXGI_FORMAT_R8G8B8A8_UNORM:
-          case DXGI_FORMAT_B8G8R8A8_UNORM:
-            GenerateMip&lt;R8G8B8A8&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_A8_UNORM:
-            GenerateMip&lt;A8&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_R8_UNORM:
-            GenerateMip&lt;R8&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_R32G32B32A32_FLOAT:
-            GenerateMip&lt;A32B32G32R32F&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_R32G32B32_FLOAT:
-            GenerateMip&lt;R32G32B32F&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_R16G16B16A16_FLOAT:
-            GenerateMip&lt;A16B16G16R16F&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_R8G8_UNORM:
-            GenerateMip&lt;R8G8&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_R16_FLOAT:
-            GenerateMip&lt;R16F&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_R16G16_FLOAT:
-            GenerateMip&lt;R16G16F&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_R32_FLOAT:
-            GenerateMip&lt;R32F&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          case DXGI_FORMAT_R32G32_FLOAT:
-            GenerateMip&lt;R32G32F&gt;(src-&gt;getWidth(), src-&gt;getHeight(), sourceData, srcMapped.RowPitch, destData, destMapped.RowPitch);
-            break;
-          default:
-            UNREACHABLE();
-            break;
-        }
</del><ins>+        ERR(&quot;Failed to map source image for mip map generation. HRESULT:0x%X&quot;, srcMapResult);
</ins><span class="cx"> 
</span><span class="cx">         dest-&gt;unmap();
</span><del>-        src-&gt;unmap();
</del><ins>+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    const unsigned char *sourceData = reinterpret_cast&lt;const unsigned char*&gt;(srcMapped.pData);
+    unsigned char *destData = reinterpret_cast&lt;unsigned char*&gt;(destMapped.pData);
+
+    mipFunction(src-&gt;getWidth(), src-&gt;getHeight(), src-&gt;getDepth(), sourceData, srcMapped.RowPitch, srcMapped.DepthPitch,
+                destData, destMapped.RowPitch, destMapped.DepthPitch);
+
+    dest-&gt;unmap();
+    src-&gt;unmap();
+
</ins><span class="cx">     dest-&gt;markDirty();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool FormatRequiresInitialization(DXGI_FORMAT dxgiFormat, GLenum internalFormat)
-{
-    return (dxgiFormat == DXGI_FORMAT_R8G8B8A8_UNORM &amp;&amp; gl::GetAlphaSize(internalFormat) == 0) ||
-           (dxgiFormat == DXGI_FORMAT_R32G32B32A32_FLOAT &amp;&amp; gl::GetAlphaSize(internalFormat) == 0);
-}
-
</del><span class="cx"> bool Image11::isDirty() const
</span><span class="cx"> {
</span><del>-    return ((mStagingTexture || FormatRequiresInitialization(mDXGIFormat, mInternalFormat)) &amp;&amp; mDirty);
</del><ins>+    // Make sure that this image is marked as dirty even if the staging texture hasn't been created yet
+    // if initialization is required before use.
+    return (mDirty &amp;&amp; (mStagingTexture || gl_d3d11::RequiresTextureDataInitialization(mInternalFormat)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Image11::updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</del><ins>+bool Image11::copyToStorage(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</ins><span class="cx"> {
</span><span class="cx">     TextureStorage11_2D *storage11 = TextureStorage11_2D::makeTextureStorage11_2D(storage-&gt;getStorageInstance());
</span><del>-    return storage11-&gt;updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, 0, xoffset, yoffset, width, height);
</del><ins>+    return storage11-&gt;updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, 0, xoffset, yoffset, 0, width, height, 1);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Image11::updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</del><ins>+bool Image11::copyToStorage(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</ins><span class="cx"> {
</span><span class="cx">     TextureStorage11_Cube *storage11 = TextureStorage11_Cube::makeTextureStorage11_Cube(storage-&gt;getStorageInstance());
</span><del>-    return storage11-&gt;updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, face, xoffset, yoffset, width, height);
</del><ins>+    return storage11-&gt;updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, face, xoffset, yoffset, 0, width, height, 1);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Image11::redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease)
</del><ins>+bool Image11::copyToStorage(TextureStorageInterface3D *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth)
</ins><span class="cx"> {
</span><ins>+    TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage-&gt;getStorageInstance());
+    return storage11-&gt;updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, 0, xoffset, yoffset, zoffset, width, height, depth);
+}
+
+bool Image11::copyToStorage(TextureStorageInterface2DArray *storage, int level, GLint xoffset, GLint yoffset, GLint arrayLayer, GLsizei width, GLsizei height)
+{
+    TextureStorage11_2DArray *storage11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(storage-&gt;getStorageInstance());
+    return storage11-&gt;updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, arrayLayer, xoffset, yoffset, 0, width, height, 1);
+}
+
+bool Image11::redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease)
+{
</ins><span class="cx">     if (mWidth != width ||
</span><span class="cx">         mHeight != height ||
</span><span class="cx">         mInternalFormat != internalformat ||
</span><span class="cx">         forceRelease)
</span><span class="cx">     {
</span><span class="cx">         mRenderer = Renderer11::makeRenderer11(renderer);
</span><ins>+        GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
</ins><span class="cx"> 
</span><span class="cx">         mWidth = width;
</span><span class="cx">         mHeight = height;
</span><ins>+        mDepth = depth;
</ins><span class="cx">         mInternalFormat = internalformat;
</span><ins>+        mTarget = target;
+
</ins><span class="cx">         // compute the d3d format that will be used
</span><del>-        mDXGIFormat = gl_d3d11::ConvertTextureFormat(internalformat);
-        mActualFormat = d3d11_gl::ConvertTextureInternalFormat(mDXGIFormat);
</del><ins>+        mDXGIFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion);
+        mActualFormat = d3d11_gl::GetInternalFormat(mDXGIFormat, clientVersion);
+        mRenderable = gl_d3d11::GetRTVFormat(internalformat, clientVersion) != DXGI_FORMAT_UNKNOWN;
</ins><span class="cx"> 
</span><del>-        if (mStagingTexture)
-        {
-            mStagingTexture-&gt;Release();
-            mStagingTexture = NULL;
-        }
-        
</del><ins>+        SafeRelease(mStagingTexture);
+        mDirty = gl_d3d11::RequiresTextureDataInitialization(mInternalFormat);
+
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Image11::isRenderableFormat() const
-{
-    return TextureStorage11::IsTextureFormatRenderable(mDXGIFormat);
-}
-
</del><span class="cx"> DXGI_FORMAT Image11::getDXGIFormat() const
</span><span class="cx"> {
</span><span class="cx">     // this should only happen if the image hasn't been redefined first
</span><span class="lines">@@ -173,9 +151,17 @@
</span><span class="cx"> 
</span><span class="cx"> // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
</span><span class="cx"> // into the target pixel rectangle.
</span><del>-void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
-                       GLint unpackAlignment, const void *input)
</del><ins>+void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                       GLint unpackAlignment, GLenum type, const void *input)
</ins><span class="cx"> {
</span><ins>+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, clientVersion, width, unpackAlignment);
+    GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, type, clientVersion, width, height, unpackAlignment);
+    GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat);
+
+    LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, type, clientVersion);
+    ASSERT(loadFunction != NULL);
+
</ins><span class="cx">     D3D11_MAPPED_SUBRESOURCE mappedImage;
</span><span class="cx">     HRESULT result = map(D3D11_MAP_WRITE, &amp;mappedImage);
</span><span class="cx">     if (FAILED(result))
</span><span class="lines">@@ -183,82 +169,30 @@
</span><span class="cx">         ERR(&quot;Could not map image for loading.&quot;);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    
-    GLsizei inputPitch = gl::ComputePitch(width, mInternalFormat, unpackAlignment);
-    size_t pixelSize = d3d11::ComputePixelSizeBits(mDXGIFormat) / 8;
-    void* offsetMappedData = (void*)((BYTE *)mappedImage.pData + (yoffset * mappedImage.RowPitch + xoffset * pixelSize));
</del><span class="cx"> 
</span><del>-    switch (mInternalFormat)
-    {
-      case GL_ALPHA8_EXT:
-        loadAlphaDataToNative(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_LUMINANCE8_EXT:
-        loadLuminanceDataToNativeOrBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData, false);
-        break;
-      case GL_ALPHA32F_EXT:
-        loadAlphaFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_LUMINANCE32F_EXT:
-        loadLuminanceFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_ALPHA16F_EXT:
-        loadAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_LUMINANCE16F_EXT:
-        loadLuminanceHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_LUMINANCE8_ALPHA8_EXT:
-        loadLuminanceAlphaDataToNativeOrBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData, false);
-        break;
-      case GL_LUMINANCE_ALPHA32F_EXT:
-        loadLuminanceAlphaFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_LUMINANCE_ALPHA16F_EXT:
-        loadLuminanceAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_RGB8_OES:
-        loadRGBUByteDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_RGB565:
-        loadRGB565DataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_RGBA8_OES:
-        loadRGBAUByteDataToNative(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_RGBA4:
-        loadRGBA4444DataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_RGB5_A1:
-        loadRGBA5551DataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_BGRA8_EXT:
-        loadBGRADataToBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_RGB32F_EXT:
-        loadRGBFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_RGB16F_EXT:
-        loadRGBHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_RGBA32F_EXT:
-        loadRGBAFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      case GL_RGBA16F_EXT:
-        loadRGBAHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
-        break;
-      default: UNREACHABLE(); 
-    }
</del><ins>+    void* offsetMappedData = (void*)((BYTE *)mappedImage.pData + (yoffset * mappedImage.RowPitch + xoffset * outputPixelSize + zoffset * mappedImage.DepthPitch));
+    loadFunction(width, height, depth, input, inputRowPitch, inputDepthPitch, offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
</ins><span class="cx"> 
</span><span class="cx">     unmap();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
-                                const void *input)
</del><ins>+void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                                 const void *input)
</ins><span class="cx"> {
</span><del>-    ASSERT(xoffset % 4 == 0);
-    ASSERT(yoffset % 4 == 0);
</del><ins>+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, 1);
+    GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
</ins><span class="cx"> 
</span><ins>+    GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat);
+    GLuint outputBlockWidth = d3d11::GetBlockWidth(mDXGIFormat);
+    GLuint outputBlockHeight = d3d11::GetBlockHeight(mDXGIFormat);
+
+    ASSERT(xoffset % outputBlockWidth == 0);
+    ASSERT(yoffset % outputBlockHeight == 0);
+
+    LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion);
+    ASSERT(loadFunction != NULL);
+
</ins><span class="cx">     D3D11_MAPPED_SUBRESOURCE mappedImage;
</span><span class="cx">     HRESULT result = map(D3D11_MAP_WRITE, &amp;mappedImage);
</span><span class="cx">     if (FAILED(result))
</span><span class="lines">@@ -267,26 +201,21 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Size computation assumes a 4x4 block compressed texture format
-    size_t blockSize = d3d11::ComputeBlockSizeBits(mDXGIFormat) / 8;
-    void* offsetMappedData = (void*)((BYTE *)mappedImage.pData + ((yoffset / 4) * mappedImage.RowPitch + (xoffset / 4) * blockSize));
</del><ins>+    void* offsetMappedData = (void*)((BYTE*)mappedImage.pData + ((yoffset / outputBlockHeight) * mappedImage.RowPitch +
+                                                                 (xoffset / outputBlockWidth) * outputPixelSize +
+                                                                 zoffset * mappedImage.DepthPitch));
</ins><span class="cx"> 
</span><del>-    GLsizei inputSize = gl::ComputeCompressedSize(width, height, mInternalFormat);
-    GLsizei inputPitch = gl::ComputeCompressedPitch(width, mInternalFormat);
-    int rows = inputSize / inputPitch;
-    for (int i = 0; i &lt; rows; ++i)
-    {
-        memcpy((void*)((BYTE*)offsetMappedData + i * mappedImage.RowPitch), (void*)((BYTE*)input + i * inputPitch), inputPitch);
-    }
</del><ins>+    loadFunction(width, height, depth, input, inputRowPitch, inputDepthPitch,
+                 offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
</ins><span class="cx"> 
</span><span class="cx">     unmap();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Image11::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source)
</del><ins>+void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source)
</ins><span class="cx"> {
</span><span class="cx">     gl::Renderbuffer *colorbuffer = source-&gt;getReadColorbuffer();
</span><span class="cx"> 
</span><del>-    if (colorbuffer &amp;&amp; colorbuffer-&gt;getActualFormat() == (GLuint)mActualFormat)
</del><ins>+    if (colorbuffer &amp;&amp; colorbuffer-&gt;getActualFormat() == mActualFormat)
</ins><span class="cx">     {
</span><span class="cx">         // No conversion needed-- use copyback fastpath
</span><span class="cx">         ID3D11Texture2D *colorBufferTexture = NULL;
</span><span class="lines">@@ -340,10 +269,10 @@
</span><span class="cx">             srcBox.front = 0;
</span><span class="cx">             srcBox.back = 1;
</span><span class="cx"> 
</span><del>-            deviceContext-&gt;CopySubresourceRegion(mStagingTexture, 0, xoffset, yoffset, 0, srcTex, subresourceIndex, &amp;srcBox);
</del><ins>+            deviceContext-&gt;CopySubresourceRegion(mStagingTexture, 0, xoffset, yoffset, zoffset, srcTex, subresourceIndex, &amp;srcBox);
</ins><span class="cx"> 
</span><del>-            srcTex-&gt;Release();
-            colorBufferTexture-&gt;Release();
</del><ins>+            SafeRelease(srcTex);
+            SafeRelease(colorBufferTexture);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="lines">@@ -351,19 +280,27 @@
</span><span class="cx">         // This format requires conversion, so we must copy the texture to staging and manually convert via readPixels
</span><span class="cx">         D3D11_MAPPED_SUBRESOURCE mappedImage;
</span><span class="cx">         HRESULT result = map(D3D11_MAP_WRITE, &amp;mappedImage);
</span><ins>+        if (FAILED(result))
+        {
+            ERR(&quot;Failed to map texture for Image11::copy, HRESULT: 0x%X.&quot;, result);
+            return;
+        }
</ins><span class="cx"> 
</span><span class="cx">         // determine the offset coordinate into the destination buffer
</span><del>-        GLsizei rowOffset = gl::ComputePixelSize(mActualFormat) * xoffset;
-        void *dataOffset = static_cast&lt;unsigned char*&gt;(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset;
</del><ins>+        GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+        GLsizei rowOffset = gl::GetPixelBytes(mActualFormat, clientVersion) * xoffset;
+        void *dataOffset = static_cast&lt;unsigned char*&gt;(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch;
</ins><span class="cx"> 
</span><del>-        mRenderer-&gt;readPixels(source, x, y, width, height, gl::ExtractFormat(mInternalFormat), 
-                              gl::ExtractType(mInternalFormat), mappedImage.RowPitch, false, 4, dataOffset);
</del><ins>+        GLenum format = gl::GetFormat(mInternalFormat, clientVersion);
+        GLenum type = gl::GetType(mInternalFormat, clientVersion);
</ins><span class="cx"> 
</span><ins>+        mRenderer-&gt;readPixels(source, x, y, width, height, format, type, mappedImage.RowPitch, gl::PixelPackState(), dataOffset);
+
</ins><span class="cx">         unmap();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ID3D11Texture2D *Image11::getStagingTexture()
</del><ins>+ID3D11Resource *Image11::getStagingTexture()
</ins><span class="cx"> {
</span><span class="cx">     createStagingTexture();
</span><span class="cx"> 
</span><span class="lines">@@ -377,27 +314,6 @@
</span><span class="cx">     return mStagingSubresource;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template &lt;typename T, size_t N&gt;
-static void setDefaultData(ID3D11DeviceContext *deviceContext, ID3D11Texture2D *texture, UINT subresource,
-                           GLsizei width, GLsizei height, const T (&amp;defaultData)[N])
-{
-    D3D11_MAPPED_SUBRESOURCE map;
-    deviceContext-&gt;Map(texture, subresource, D3D11_MAP_WRITE, 0, &amp;map);
-
-    unsigned char* ptr = reinterpret_cast&lt;unsigned char*&gt;(map.pData);
-    size_t pixelSize = sizeof(T) * N;
-
-    for (GLsizei y = 0; y &lt; height; y++)
-    {
-        for (GLsizei x = 0; x &lt; width; x++)
-        {
-            memcpy(ptr + (y * map.RowPitch) + (x * pixelSize), defaultData, pixelSize);
-        }
-    }
-
-    deviceContext-&gt;Unmap(texture, subresource);
-}
-
</del><span class="cx"> void Image11::createStagingTexture()
</span><span class="cx"> {
</span><span class="cx">     if (mStagingTexture)
</span><span class="lines">@@ -405,57 +321,107 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ID3D11Texture2D *newTexture = NULL;
-    int lodOffset = 1;
</del><span class="cx">     const DXGI_FORMAT dxgiFormat = getDXGIFormat();
</span><del>-    ASSERT(!d3d11::IsDepthStencilFormat(dxgiFormat)); // We should never get here for depth textures
</del><span class="cx"> 
</span><del>-    if (mWidth != 0 &amp;&amp; mHeight != 0)
</del><ins>+    if (mWidth &gt; 0 &amp;&amp; mHeight &gt; 0 &amp;&amp; mDepth &gt; 0)
</ins><span class="cx">     {
</span><ins>+        ID3D11Device *device = mRenderer-&gt;getDevice();
+        HRESULT result;
+
+        int lodOffset = 1;
</ins><span class="cx">         GLsizei width = mWidth;
</span><span class="cx">         GLsizei height = mHeight;
</span><span class="cx"> 
</span><span class="cx">         // adjust size if needed for compressed textures
</span><del>-        gl::MakeValidSize(false, d3d11::IsCompressed(dxgiFormat), &amp;width, &amp;height, &amp;lodOffset);
-        ID3D11Device *device = mRenderer-&gt;getDevice();
</del><ins>+        d3d11::MakeValidSize(false, dxgiFormat, &amp;width, &amp;height, &amp;lodOffset);
</ins><span class="cx"> 
</span><del>-        D3D11_TEXTURE2D_DESC desc;
-        desc.Width = width;
-        desc.Height = height;
-        desc.MipLevels = lodOffset + 1;
-        desc.ArraySize = 1;
-        desc.Format = dxgiFormat;
-        desc.SampleDesc.Count = 1;
-        desc.SampleDesc.Quality = 0;
-        desc.Usage = D3D11_USAGE_STAGING;
-        desc.BindFlags = 0;
-        desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
-        desc.MiscFlags = 0;
</del><ins>+        if (mTarget == GL_TEXTURE_3D)
+        {
+            ID3D11Texture3D *newTexture = NULL;
</ins><span class="cx"> 
</span><del>-        HRESULT result = device-&gt;CreateTexture2D(&amp;desc, NULL, &amp;newTexture);
</del><ins>+            D3D11_TEXTURE3D_DESC desc;
+            desc.Width = width;
+            desc.Height = height;
+            desc.Depth = mDepth;
+            desc.MipLevels = lodOffset + 1;
+            desc.Format = dxgiFormat;
+            desc.Usage = D3D11_USAGE_STAGING;
+            desc.BindFlags = 0;
+            desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
+            desc.MiscFlags = 0;
</ins><span class="cx"> 
</span><del>-        if (FAILED(result))
</del><ins>+            if (gl_d3d11::RequiresTextureDataInitialization(mInternalFormat))
+            {
+                std::vector&lt;D3D11_SUBRESOURCE_DATA&gt; initialData;
+                std::vector&lt; std::vector&lt;BYTE&gt; &gt; textureData;
+                d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer-&gt;getCurrentClientVersion(), width, height,
+                                                  mDepth, lodOffset + 1, &amp;initialData, &amp;textureData);
+
+                result = device-&gt;CreateTexture3D(&amp;desc, initialData.data(), &amp;newTexture);
+            }
+            else
+            {
+                result = device-&gt;CreateTexture3D(&amp;desc, NULL, &amp;newTexture);
+            }
+
+            if (FAILED(result))
+            {
+                ASSERT(result == E_OUTOFMEMORY);
+                ERR(&quot;Creating image failed.&quot;);
+                return gl::error(GL_OUT_OF_MEMORY);
+            }
+
+            mStagingTexture = newTexture;
+            mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
+        }
+        else if (mTarget == GL_TEXTURE_2D || mTarget == GL_TEXTURE_2D_ARRAY || mTarget == GL_TEXTURE_CUBE_MAP)
</ins><span class="cx">         {
</span><del>-            ASSERT(result == E_OUTOFMEMORY);
-            ERR(&quot;Creating image failed.&quot;);
-            return gl::error(GL_OUT_OF_MEMORY);
</del><ins>+            ID3D11Texture2D *newTexture = NULL;
+
+            D3D11_TEXTURE2D_DESC desc;
+            desc.Width = width;
+            desc.Height = height;
+            desc.MipLevels = lodOffset + 1;
+            desc.ArraySize = 1;
+            desc.Format = dxgiFormat;
+            desc.SampleDesc.Count = 1;
+            desc.SampleDesc.Quality = 0;
+            desc.Usage = D3D11_USAGE_STAGING;
+            desc.BindFlags = 0;
+            desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
+            desc.MiscFlags = 0;
+
+            if (gl_d3d11::RequiresTextureDataInitialization(mInternalFormat))
+            {
+                std::vector&lt;D3D11_SUBRESOURCE_DATA&gt; initialData;
+                std::vector&lt; std::vector&lt;BYTE&gt; &gt; textureData;
+                d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer-&gt;getCurrentClientVersion(), width, height,
+                                                  1, lodOffset + 1, &amp;initialData, &amp;textureData);
+
+                result = device-&gt;CreateTexture2D(&amp;desc, initialData.data(), &amp;newTexture);
+            }
+            else
+            {
+                result = device-&gt;CreateTexture2D(&amp;desc, NULL, &amp;newTexture);
+            }
+
+            if (FAILED(result))
+            {
+                ASSERT(result == E_OUTOFMEMORY);
+                ERR(&quot;Creating image failed.&quot;);
+                return gl::error(GL_OUT_OF_MEMORY);
+            }
+
+            mStagingTexture = newTexture;
+            mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
</ins><span class="cx">         }
</span><ins>+        else
+        {
+            UNREACHABLE();
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mStagingTexture = newTexture;
-    mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
</del><span class="cx">     mDirty = false;
</span><del>-
-    if (mDXGIFormat == DXGI_FORMAT_R8G8B8A8_UNORM &amp;&amp; gl::GetAlphaSize(mInternalFormat) == 0)
-    {
-        unsigned char defaultPixel[4] = { 0, 0, 0, 255 };
-        setDefaultData(mRenderer-&gt;getDeviceContext(), mStagingTexture, mStagingSubresource, mWidth, mHeight, defaultPixel);
-    }
-    else if (mDXGIFormat == DXGI_FORMAT_R32G32B32A32_FLOAT &amp;&amp; gl::GetAlphaSize(mInternalFormat) == 0)
-    {
-        float defaultPixel[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
-        setDefaultData(mRenderer-&gt;getDeviceContext(), mStagingTexture, mStagingSubresource, mWidth, mHeight, defaultPixel);
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> HRESULT Image11::map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map)
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Image11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Image11.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Image11.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Image11.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -34,24 +34,25 @@
</span><span class="cx"> 
</span><span class="cx">     static Image11 *makeImage11(Image *img);
</span><span class="cx"> 
</span><del>-    static void generateMipmap(Image11 *dest, Image11 *src);
</del><ins>+    static void generateMipmap(GLuint clientVersion, Image11 *dest, Image11 *src);
</ins><span class="cx"> 
</span><span class="cx">     virtual bool isDirty() const;
</span><span class="cx"> 
</span><del>-    virtual bool updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
-    virtual bool updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
</del><ins>+    virtual bool copyToStorage(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
+    virtual bool copyToStorage(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
+    virtual bool copyToStorage(TextureStorageInterface3D *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
+    virtual bool copyToStorage(TextureStorageInterface2DArray *storage, int level, GLint xoffset, GLint yoffset, GLint arrayLayer, GLsizei width, GLsizei height);
</ins><span class="cx"> 
</span><del>-    virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease);
</del><ins>+    virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease);
</ins><span class="cx"> 
</span><del>-    virtual bool isRenderableFormat() const;
</del><span class="cx">     DXGI_FORMAT getDXGIFormat() const;
</span><span class="cx">     
</span><del>-    virtual void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
-                  GLint unpackAlignment, const void *input);
-    virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
</del><ins>+    virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                          GLint unpackAlignment, GLenum type, const void *input);
+    virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
</ins><span class="cx">                                     const void *input);
</span><span class="cx"> 
</span><del>-    virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
</del><ins>+    virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
</ins><span class="cx"> 
</span><span class="cx">   protected:
</span><span class="cx">     HRESULT map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map);
</span><span class="lines">@@ -60,14 +61,14 @@
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Image11);
</span><span class="cx"> 
</span><del>-    ID3D11Texture2D *getStagingTexture();
</del><ins>+    ID3D11Resource *getStagingTexture();
</ins><span class="cx">     unsigned int getStagingSubresource();
</span><span class="cx">     void createStagingTexture();
</span><span class="cx"> 
</span><span class="cx">     Renderer11 *mRenderer;
</span><span class="cx"> 
</span><span class="cx">     DXGI_FORMAT mDXGIFormat;
</span><del>-    ID3D11Texture2D *mStagingTexture;
</del><ins>+    ID3D11Resource *mStagingTexture;
</ins><span class="cx">     unsigned int mStagingSubresource;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11IndexBuffer11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -22,20 +22,12 @@
</span><span class="cx"> 
</span><span class="cx"> IndexBuffer11::~IndexBuffer11()
</span><span class="cx"> {
</span><del>-    if (mBuffer)
-    {
-        mBuffer-&gt;Release();
-        mBuffer = NULL;
-    }
</del><ins>+    SafeRelease(mBuffer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool IndexBuffer11::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic)
</span><span class="cx"> {
</span><del>-    if (mBuffer)
-    {
-        mBuffer-&gt;Release();
-        mBuffer = NULL;
-    }
</del><ins>+    SafeRelease(mBuffer);
</ins><span class="cx"> 
</span><span class="cx">     updateSerial();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11InputLayoutCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -13,14 +13,30 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/BufferStorage11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/ShaderExecutable11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/ProgramBinary.h&quot;
</span><del>-#include &quot;libGLESv2/Context.h&quot;
</del><ins>+#include &quot;libGLESv2/VertexAttribute.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/VertexDataManager.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d11/formatutils11.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;third_party/murmurhash/MurmurHash3.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><ins>+static void GetInputLayout(const TranslatedAttribute translatedAttributes[gl::MAX_VERTEX_ATTRIBS],
+                           gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS])
+{
+    for (unsigned int attributeIndex = 0; attributeIndex &lt; gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
+    {
+        const TranslatedAttribute &amp;translatedAttribute = translatedAttributes[attributeIndex];
+
+        if (translatedAttributes[attributeIndex].active)
+        {
+            inputLayout[attributeIndex] = gl::VertexFormat(*translatedAttribute.attribute,
+                                                           translatedAttribute.currentValueType);
+        }
+    }
+}
+
</ins><span class="cx"> const unsigned int InputLayoutCache::kMaxInputLayouts = 1024;
</span><span class="cx"> 
</span><span class="cx"> InputLayoutCache::InputLayoutCache() : mInputLayoutMap(kMaxInputLayouts, hashInputLayout, compareInputLayouts)
</span><span class="lines">@@ -31,7 +47,7 @@
</span><span class="cx">     mCurrentIL = NULL;
</span><span class="cx">     for (unsigned int i = 0; i &lt; gl::MAX_VERTEX_ATTRIBS; i++)
</span><span class="cx">     {
</span><del>-        mCurrentBuffers[i] = -1;
</del><ins>+        mCurrentBuffers[i] = NULL;
</ins><span class="cx">         mCurrentVertexStrides[i] = -1;
</span><span class="cx">         mCurrentVertexOffsets[i] = -1;
</span><span class="cx">     }
</span><span class="lines">@@ -53,7 +69,7 @@
</span><span class="cx"> {
</span><span class="cx">     for (InputLayoutMap::iterator i = mInputLayoutMap.begin(); i != mInputLayoutMap.end(); i++)
</span><span class="cx">     {
</span><del>-        i-&gt;second.inputLayout-&gt;Release();
</del><ins>+        SafeRelease(i-&gt;second.inputLayout);
</ins><span class="cx">     }
</span><span class="cx">     mInputLayoutMap.clear();
</span><span class="cx">     markDirty();
</span><span class="lines">@@ -64,7 +80,7 @@
</span><span class="cx">     mCurrentIL = NULL;
</span><span class="cx">     for (unsigned int i = 0; i &lt; gl::MAX_VERTEX_ATTRIBS; i++)
</span><span class="cx">     {
</span><del>-        mCurrentBuffers[i] = -1;
</del><ins>+        mCurrentBuffers[i] = NULL;
</ins><span class="cx">         mCurrentVertexStrides[i] = -1;
</span><span class="cx">         mCurrentVertexOffsets[i] = -1;
</span><span class="cx">     }
</span><span class="lines">@@ -85,7 +101,6 @@
</span><span class="cx">     InputLayoutKey ilKey = { 0 };
</span><span class="cx"> 
</span><span class="cx">     ID3D11Buffer *vertexBuffers[gl::MAX_VERTEX_ATTRIBS] = { NULL };
</span><del>-    unsigned int vertexBufferSerials[gl::MAX_VERTEX_ATTRIBS] = { 0 };
</del><span class="cx">     UINT vertexStrides[gl::MAX_VERTEX_ATTRIBS] = { 0 };
</span><span class="cx">     UINT vertexOffsets[gl::MAX_VERTEX_ATTRIBS] = { 0 };
</span><span class="cx"> 
</span><span class="lines">@@ -100,6 +115,9 @@
</span><span class="cx"> 
</span><span class="cx">             D3D11_INPUT_CLASSIFICATION inputClass = attributes[i].divisor &gt; 0 ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA;
</span><span class="cx"> 
</span><ins>+            gl::VertexFormat vertexFormat(*attributes[i].attribute, attributes[i].currentValueType);
+            DXGI_FORMAT dxgiFormat = gl_d3d11::GetNativeVertexFormat(vertexFormat);
+
</ins><span class="cx">             // Record the type of the associated vertex shader vector in our key
</span><span class="cx">             // This will prevent mismatched vertex shaders from using the same input layout
</span><span class="cx">             GLint attributeSize;
</span><span class="lines">@@ -107,15 +125,15 @@
</span><span class="cx"> 
</span><span class="cx">             ilKey.elements[ilKey.elementCount].desc.SemanticName = semanticName;
</span><span class="cx">             ilKey.elements[ilKey.elementCount].desc.SemanticIndex = sortedSemanticIndices[i];
</span><del>-            ilKey.elements[ilKey.elementCount].desc.Format = attributes[i].attribute-&gt;mArrayEnabled ? vertexBuffer-&gt;getDXGIFormat(*attributes[i].attribute) : DXGI_FORMAT_R32G32B32A32_FLOAT;
</del><ins>+            ilKey.elements[ilKey.elementCount].desc.Format = dxgiFormat;
</ins><span class="cx">             ilKey.elements[ilKey.elementCount].desc.InputSlot = i;
</span><span class="cx">             ilKey.elements[ilKey.elementCount].desc.AlignedByteOffset = 0;
</span><span class="cx">             ilKey.elements[ilKey.elementCount].desc.InputSlotClass = inputClass;
</span><span class="cx">             ilKey.elements[ilKey.elementCount].desc.InstanceDataStepRate = attributes[i].divisor;
</span><span class="cx">             ilKey.elementCount++;
</span><span class="cx"> 
</span><del>-            vertexBuffers[i] = bufferStorage ? bufferStorage-&gt;getBuffer(BUFFER_USAGE_VERTEX) : vertexBuffer-&gt;getBuffer();
-            vertexBufferSerials[i] = bufferStorage ? bufferStorage-&gt;getSerial() : vertexBuffer-&gt;getSerial();
</del><ins>+            vertexBuffers[i] = bufferStorage ? bufferStorage-&gt;getBuffer(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK)
+                                             : vertexBuffer-&gt;getBuffer();
</ins><span class="cx">             vertexStrides[i] = attributes[i].stride;
</span><span class="cx">             vertexOffsets[i] = attributes[i].offset;
</span><span class="cx">         }
</span><span class="lines">@@ -123,15 +141,17 @@
</span><span class="cx"> 
</span><span class="cx">     ID3D11InputLayout *inputLayout = NULL;
</span><span class="cx"> 
</span><del>-    InputLayoutMap::iterator i = mInputLayoutMap.find(ilKey);
-    if (i != mInputLayoutMap.end())
</del><ins>+    InputLayoutMap::iterator keyIter = mInputLayoutMap.find(ilKey);
+    if (keyIter != mInputLayoutMap.end())
</ins><span class="cx">     {
</span><del>-        inputLayout = i-&gt;second.inputLayout;
-        i-&gt;second.lastUsedTime = mCounter++;
</del><ins>+        inputLayout = keyIter-&gt;second.inputLayout;
+        keyIter-&gt;second.lastUsedTime = mCounter++;
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        ShaderExecutable11 *shader = ShaderExecutable11::makeShaderExecutable11(programBinary-&gt;getVertexExecutable());
</del><ins>+        gl::VertexFormat shaderInputLayout[gl::MAX_VERTEX_ATTRIBS];
+        GetInputLayout(attributes, shaderInputLayout);
+        ShaderExecutable11 *shader = ShaderExecutable11::makeShaderExecutable11(programBinary-&gt;getVertexExecutableForInputLayout(shaderInputLayout));
</ins><span class="cx"> 
</span><span class="cx">         D3D11_INPUT_ELEMENT_DESC descs[gl::MAX_VERTEX_ATTRIBS];
</span><span class="cx">         for (unsigned int j = 0; j &lt; ilKey.elementCount; ++j)
</span><span class="lines">@@ -159,7 +179,7 @@
</span><span class="cx">                     leastRecentlyUsed = i;
</span><span class="cx">                 }
</span><span class="cx">             }
</span><del>-            leastRecentlyUsed-&gt;second.inputLayout-&gt;Release();
</del><ins>+            SafeRelease(leastRecentlyUsed-&gt;second.inputLayout);
</ins><span class="cx">             mInputLayoutMap.erase(leastRecentlyUsed);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -178,11 +198,11 @@
</span><span class="cx"> 
</span><span class="cx">     for (unsigned int i = 0; i &lt; gl::MAX_VERTEX_ATTRIBS; i++)
</span><span class="cx">     {
</span><del>-        if (vertexBufferSerials[i] != mCurrentBuffers[i] || vertexStrides[i] != mCurrentVertexStrides[i] ||
</del><ins>+        if (vertexBuffers[i] != mCurrentBuffers[i] || vertexStrides[i] != mCurrentVertexStrides[i] ||
</ins><span class="cx">             vertexOffsets[i] != mCurrentVertexOffsets[i])
</span><span class="cx">         {
</span><span class="cx">             mDeviceContext-&gt;IASetVertexBuffers(i, 1, &amp;vertexBuffers[i], &amp;vertexStrides[i], &amp;vertexOffsets[i]);
</span><del>-            mCurrentBuffers[i] = vertexBufferSerials[i];
</del><ins>+            mCurrentBuffers[i] = vertexBuffers[i];
</ins><span class="cx">             mCurrentVertexStrides[i] = vertexStrides[i];
</span><span class="cx">             mCurrentVertexOffsets[i] = vertexOffsets[i];
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11InputLayoutCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/InputLayoutCache.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/InputLayoutCache.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/InputLayoutCache.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     ID3D11InputLayout *mCurrentIL;
</span><del>-    unsigned int mCurrentBuffers[gl::MAX_VERTEX_ATTRIBS];
</del><ins>+    ID3D11Buffer *mCurrentBuffers[gl::MAX_VERTEX_ATTRIBS];
</ins><span class="cx">     UINT mCurrentVertexStrides[gl::MAX_VERTEX_ATTRIBS];
</span><span class="cx">     UINT mCurrentVertexOffsets[gl::MAX_VERTEX_ATTRIBS];
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Query11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Query11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Query11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Query11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -9,11 +9,26 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Query11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Renderer11.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d11/renderer11_utils.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><ins>+static bool checkOcclusionQuery(ID3D11DeviceContext *context, ID3D11Query *query, UINT64 *numPixels)
+{
+    HRESULT result = context-&gt;GetData(query, numPixels, sizeof(UINT64), 0);
+    return (result == S_OK);
+}
+
+static bool checkStreamOutPrimitivesWritten(ID3D11DeviceContext *context, ID3D11Query *query, UINT64 *numPrimitives)
+{
+    D3D11_QUERY_DATA_SO_STATISTICS soStats = { 0 };
+    HRESULT result = context-&gt;GetData(query, &amp;soStats, sizeof(D3D11_QUERY_DATA_SO_STATISTICS), 0);
+    *numPrimitives = soStats.NumPrimitivesWritten;
+    return (result == S_OK);
+}
+
</ins><span class="cx"> Query11::Query11(rx::Renderer11 *renderer, GLenum type) : QueryImpl(type)
</span><span class="cx"> {
</span><span class="cx">     mRenderer = renderer;
</span><span class="lines">@@ -22,11 +37,7 @@
</span><span class="cx"> 
</span><span class="cx"> Query11::~Query11()
</span><span class="cx"> {
</span><del>-    if (mQuery)
-    {
-        mQuery-&gt;Release();
-        mQuery = NULL;
-    }
</del><ins>+    SafeRelease(mQuery);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Query11::begin()
</span><span class="lines">@@ -34,7 +45,7 @@
</span><span class="cx">     if (mQuery == NULL)
</span><span class="cx">     {
</span><span class="cx">         D3D11_QUERY_DESC queryDesc;
</span><del>-        queryDesc.Query = D3D11_QUERY_OCCLUSION;
</del><ins>+        queryDesc.Query = gl_d3d11::ConvertQueryType(getType());
</ins><span class="cx">         queryDesc.MiscFlags = 0;
</span><span class="cx"> 
</span><span class="cx">         if (FAILED(mRenderer-&gt;getDevice()-&gt;CreateQuery(&amp;queryDesc, &amp;mQuery)))
</span><span class="lines">@@ -92,22 +103,43 @@
</span><span class="cx"> {
</span><span class="cx">     if (mQuery != NULL &amp;&amp; mStatus != GL_TRUE)
</span><span class="cx">     {
</span><del>-        UINT64 numPixels = 0;
-        HRESULT result = mRenderer-&gt;getDeviceContext()-&gt;GetData(mQuery, &amp;numPixels, sizeof(UINT64), 0);
-        if (result == S_OK)
</del><ins>+        ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
+
+        bool queryFinished = false;
+        switch (getType())
</ins><span class="cx">         {
</span><del>-            mStatus = GL_TRUE;
</del><ins>+          case GL_ANY_SAMPLES_PASSED_EXT:
+          case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
+            {
+                UINT64 numPixels = 0;
+                queryFinished = checkOcclusionQuery(context, mQuery, &amp;numPixels);
+                if (queryFinished)
+                {
+                    mResult = (numPixels &gt; 0) ? GL_TRUE : GL_FALSE;
+                }
+            }
+            break;
</ins><span class="cx"> 
</span><del>-            switch (getType())
</del><ins>+          case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
</ins><span class="cx">             {
</span><del>-              case GL_ANY_SAMPLES_PASSED_EXT:
-              case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
-                mResult = (numPixels &gt; 0) ? GL_TRUE : GL_FALSE;
-                break;
-              default:
-                UNREACHABLE();
</del><ins>+                UINT64 numPrimitives = 0;
+                queryFinished = checkStreamOutPrimitivesWritten(context, mQuery, &amp;numPrimitives);
+                if (queryFinished)
+                {
+                    mResult = static_cast&lt;GLuint&gt;(numPrimitives);
+                }
</ins><span class="cx">             }
</span><ins>+            break;
+
+        default:
+            UNREACHABLE();
+            break;
</ins><span class="cx">         }
</span><ins>+
+        if (queryFinished)
+        {
+            mStatus = GL_TRUE;
+        }
</ins><span class="cx">         else if (mRenderer-&gt;testDeviceLost(true))
</span><span class="cx">         {
</span><span class="cx">             return gl::error(GL_OUT_OF_MEMORY, GL_TRUE);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11RenderStateCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -10,16 +10,26 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/RenderStateCache.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/renderer11_utils.h&quot;
</span><del>-
</del><ins>+#include &quot;libGLESv2/renderer/Renderer.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/Framebuffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Renderbuffer.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+
</ins><span class="cx"> #include &quot;common/debug.h&quot;
</span><span class="cx"> #include &quot;third_party/murmurhash/MurmurHash3.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><ins>+template &lt;typename mapType&gt;
+static void ClearStateMap(mapType &amp;map)
+{
+    for (mapType::iterator i = map.begin(); i != map.end(); i++)
+    {
+        SafeRelease(i-&gt;second.first);
+    }
+    map.clear();
+}
+
</ins><span class="cx"> // MSDN's documentation of ID3D11Device::CreateBlendState, ID3D11Device::CreateRasterizerState,
</span><span class="cx"> // ID3D11Device::CreateDepthStencilState and ID3D11Device::CreateSamplerState claims the maximum
</span><span class="cx"> // number of unique states of each type an application can create is 4096
</span><span class="lines">@@ -49,29 +59,10 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderStateCache::clear()
</span><span class="cx"> {
</span><del>-    for (BlendStateMap::iterator i = mBlendStateCache.begin(); i != mBlendStateCache.end(); i++)
-    {
-        i-&gt;second.first-&gt;Release();
-    }
-    mBlendStateCache.clear();
-
-    for (RasterizerStateMap::iterator i = mRasterizerStateCache.begin(); i != mRasterizerStateCache.end(); i++)
-    {
-        i-&gt;second.first-&gt;Release();
-    }
-    mRasterizerStateCache.clear();
-
-    for (DepthStencilStateMap::iterator i = mDepthStencilStateCache.begin(); i != mDepthStencilStateCache.end(); i++)
-    {
-        i-&gt;second.first-&gt;Release();
-    }
-    mDepthStencilStateCache.clear();
-
-    for (SamplerStateMap::iterator i = mSamplerStateCache.begin(); i != mSamplerStateCache.end(); i++)
-    {
-        i-&gt;second.first-&gt;Release();
-    }
-    mSamplerStateCache.clear();
</del><ins>+    ClearStateMap(mBlendStateCache);
+    ClearStateMap(mRasterizerStateCache);
+    ClearStateMap(mDepthStencilStateCache);
+    ClearStateMap(mSamplerStateCache);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::size_t RenderStateCache::hashBlendState(const BlendStateKey &amp;blendState)
</span><span class="lines">@@ -79,16 +70,16 @@
</span><span class="cx">     static const unsigned int seed = 0xABCDEF98;
</span><span class="cx"> 
</span><span class="cx">     std::size_t hash = 0;
</span><del>-    MurmurHash3_x86_32(&amp;blendState, sizeof(BlendStateKey), seed, &amp;hash);
</del><ins>+    MurmurHash3_x86_32(&amp;blendState, sizeof(gl::BlendState), seed, &amp;hash);
</ins><span class="cx">     return hash;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderStateCache::compareBlendStates(const BlendStateKey &amp;a, const BlendStateKey &amp;b)
</span><span class="cx"> {
</span><del>-    return memcmp(&amp;a, &amp;b, sizeof(gl::BlendState)) == 0;
</del><ins>+    return memcmp(&amp;a, &amp;b, sizeof(BlendStateKey)) == 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ID3D11BlendState *RenderStateCache::getBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState)
</del><ins>+ID3D11BlendState *RenderStateCache::getBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState)
</ins><span class="cx"> {
</span><span class="cx">     if (!mDevice)
</span><span class="cx">     {
</span><span class="lines">@@ -110,11 +101,10 @@
</span><span class="cx">                 mrt = true;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            GLenum internalFormat = renderBuffer-&gt;getInternalFormat();
-            key.rtChannels[i][0] = gl::GetRedSize(internalFormat) &gt; 0;
-            key.rtChannels[i][1] = gl::GetGreenSize(internalFormat) &gt; 0;
-            key.rtChannels[i][2] = gl::GetBlueSize(internalFormat) &gt; 0;;
-            key.rtChannels[i][3] = gl::GetAlphaSize(internalFormat) &gt; 0;
</del><ins>+            key.rtChannels[i][0] = renderBuffer-&gt;getRedSize()   &gt; 0;
+            key.rtChannels[i][1] = renderBuffer-&gt;getGreenSize() &gt; 0;
+            key.rtChannels[i][2] = renderBuffer-&gt;getBlueSize()  &gt; 0;
+            key.rtChannels[i][3] = renderBuffer-&gt;getAlphaSize() &gt; 0;
</ins><span class="cx">         }
</span><span class="cx">         else
</span><span class="cx">         {
</span><span class="lines">@@ -125,10 +115,10 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    BlendStateMap::iterator i = mBlendStateCache.find(key);
-    if (i != mBlendStateCache.end())
</del><ins>+    BlendStateMap::iterator keyIter = mBlendStateCache.find(key);
+    if (keyIter != mBlendStateCache.end())
</ins><span class="cx">     {
</span><del>-        BlendStateCounterPair &amp;state = i-&gt;second;
</del><ins>+        BlendStateCounterPair &amp;state = keyIter-&gt;second;
</ins><span class="cx">         state.second = mCounter++;
</span><span class="cx">         return state.first;
</span><span class="cx">     }
</span><span class="lines">@@ -147,7 +137,7 @@
</span><span class="cx">                     leastRecentlyUsed = i;
</span><span class="cx">                 }
</span><span class="cx">             }
</span><del>-            leastRecentlyUsed-&gt;second.first-&gt;Release();
</del><ins>+            SafeRelease(leastRecentlyUsed-&gt;second.first);
</ins><span class="cx">             mBlendStateCache.erase(leastRecentlyUsed);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -215,15 +205,15 @@
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RasterizerStateKey key;
</del><ins>+    RasterizerStateKey key = { 0 };
</ins><span class="cx">     key.rasterizerState = rasterState;
</span><span class="cx">     key.scissorEnabled = scissorEnabled;
</span><span class="cx">     key.depthSize = depthSize;
</span><span class="cx"> 
</span><del>-    RasterizerStateMap::iterator i = mRasterizerStateCache.find(key);
-    if (i != mRasterizerStateCache.end())
</del><ins>+    RasterizerStateMap::iterator keyIter = mRasterizerStateCache.find(key);
+    if (keyIter != mRasterizerStateCache.end())
</ins><span class="cx">     {
</span><del>-        RasterizerStateCounterPair &amp;state = i-&gt;second;
</del><ins>+        RasterizerStateCounterPair &amp;state = keyIter-&gt;second;
</ins><span class="cx">         state.second = mCounter++;
</span><span class="cx">         return state.first;
</span><span class="cx">     }
</span><span class="lines">@@ -242,7 +232,7 @@
</span><span class="cx">                     leastRecentlyUsed = i;
</span><span class="cx">                 }
</span><span class="cx">             }
</span><del>-            leastRecentlyUsed-&gt;second.first-&gt;Release();
</del><ins>+            SafeRelease(leastRecentlyUsed-&gt;second.first);
</ins><span class="cx">             mRasterizerStateCache.erase(leastRecentlyUsed);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -302,10 +292,10 @@
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    DepthStencilStateMap::iterator i = mDepthStencilStateCache.find(dsState);
-    if (i != mDepthStencilStateCache.end())
</del><ins>+    DepthStencilStateMap::iterator keyIter = mDepthStencilStateCache.find(dsState);
+    if (keyIter != mDepthStencilStateCache.end())
</ins><span class="cx">     {
</span><del>-        DepthStencilStateCounterPair &amp;state = i-&gt;second;
</del><ins>+        DepthStencilStateCounterPair &amp;state = keyIter-&gt;second;
</ins><span class="cx">         state.second = mCounter++;
</span><span class="cx">         return state.first;
</span><span class="cx">     }
</span><span class="lines">@@ -324,7 +314,7 @@
</span><span class="cx">                     leastRecentlyUsed = i;
</span><span class="cx">                 }
</span><span class="cx">             }
</span><del>-            leastRecentlyUsed-&gt;second.first-&gt;Release();
</del><ins>+            SafeRelease(leastRecentlyUsed-&gt;second.first);
</ins><span class="cx">             mDepthStencilStateCache.erase(leastRecentlyUsed);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -380,10 +370,10 @@
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    SamplerStateMap::iterator i = mSamplerStateCache.find(samplerState);
-    if (i != mSamplerStateCache.end())
</del><ins>+    SamplerStateMap::iterator keyIter = mSamplerStateCache.find(samplerState);
+    if (keyIter != mSamplerStateCache.end())
</ins><span class="cx">     {
</span><del>-        SamplerStateCounterPair &amp;state = i-&gt;second;
</del><ins>+        SamplerStateCounterPair &amp;state = keyIter-&gt;second;
</ins><span class="cx">         state.second = mCounter++;
</span><span class="cx">         return state.first;
</span><span class="cx">     }
</span><span class="lines">@@ -402,24 +392,25 @@
</span><span class="cx">                     leastRecentlyUsed = i;
</span><span class="cx">                 }
</span><span class="cx">             }
</span><del>-            leastRecentlyUsed-&gt;second.first-&gt;Release();
</del><ins>+            SafeRelease(leastRecentlyUsed-&gt;second.first);
</ins><span class="cx">             mSamplerStateCache.erase(leastRecentlyUsed);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         D3D11_SAMPLER_DESC samplerDesc;
</span><del>-        samplerDesc.Filter = gl_d3d11::ConvertFilter(samplerState.minFilter, samplerState.magFilter, samplerState.maxAnisotropy);
</del><ins>+        samplerDesc.Filter = gl_d3d11::ConvertFilter(samplerState.minFilter, samplerState.magFilter,
+                                                     samplerState.maxAnisotropy, samplerState.compareMode);
</ins><span class="cx">         samplerDesc.AddressU = gl_d3d11::ConvertTextureWrap(samplerState.wrapS);
</span><span class="cx">         samplerDesc.AddressV = gl_d3d11::ConvertTextureWrap(samplerState.wrapT);
</span><del>-        samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
-        samplerDesc.MipLODBias = static_cast&lt;float&gt;(samplerState.lodOffset);
</del><ins>+        samplerDesc.AddressW = gl_d3d11::ConvertTextureWrap(samplerState.wrapR);
+        samplerDesc.MipLODBias = 0;
</ins><span class="cx">         samplerDesc.MaxAnisotropy = samplerState.maxAnisotropy;
</span><del>-        samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
</del><ins>+        samplerDesc.ComparisonFunc = gl_d3d11::ConvertComparison(samplerState.compareFunc);
</ins><span class="cx">         samplerDesc.BorderColor[0] = 0.0f;
</span><span class="cx">         samplerDesc.BorderColor[1] = 0.0f;
</span><span class="cx">         samplerDesc.BorderColor[2] = 0.0f;
</span><span class="cx">         samplerDesc.BorderColor[3] = 0.0f;
</span><del>-        samplerDesc.MinLOD = gl_d3d11::ConvertMinLOD(samplerState.minFilter, samplerState.lodOffset);
-        samplerDesc.MaxLOD = gl_d3d11::ConvertMaxLOD(samplerState.minFilter, samplerState.lodOffset);
</del><ins>+        samplerDesc.MinLOD = samplerState.minLod;
+        samplerDesc.MaxLOD = samplerState.maxLod;
</ins><span class="cx"> 
</span><span class="cx">         ID3D11SamplerState *dx11SamplerState = NULL;
</span><span class="cx">         HRESULT result = mDevice-&gt;CreateSamplerState(&amp;samplerDesc, &amp;dx11SamplerState);
</span><span class="lines">@@ -435,4 +426,4 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11RenderStateCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderStateCache.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderStateCache.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderStateCache.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -30,8 +30,7 @@
</span><span class="cx">     void initialize(ID3D11Device *device);
</span><span class="cx">     void clear();
</span><span class="cx"> 
</span><del>-    // Increments refcount on the returned blend state, Release() must be called.
-    ID3D11BlendState *getBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState);
</del><ins>+    ID3D11BlendState *getBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState);
</ins><span class="cx">     ID3D11RasterizerState *getRasterizerState(const gl::RasterizerState &amp;rasterState,
</span><span class="cx">                                               bool scissorEnabled, unsigned int depthSize);
</span><span class="cx">     ID3D11DepthStencilState *getDepthStencilState(const gl::DepthStencilState &amp;dsState);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11RenderTarget11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -12,22 +12,63 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Renderer11.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/renderer11_utils.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d11/formatutils11.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-static unsigned int getRTVSubresourceIndex(ID3D11Texture2D *texture, ID3D11RenderTargetView *view)
</del><ins>+static bool getTextureProperties(ID3D11Resource *resource, unsigned int *mipLevels, unsigned int *samples)
</ins><span class="cx"> {
</span><ins>+    ID3D11Texture1D *texture1D = d3d11::DynamicCastComObject&lt;ID3D11Texture1D&gt;(resource);
+    if (texture1D)
+    {
+        D3D11_TEXTURE1D_DESC texDesc;
+        texture1D-&gt;GetDesc(&amp;texDesc);
+        SafeRelease(texture1D);
+
+        *mipLevels = texDesc.MipLevels;
+        *samples = 0;
+
+        return true;
+    }
+
+    ID3D11Texture2D *texture2D = d3d11::DynamicCastComObject&lt;ID3D11Texture2D&gt;(resource);
+    if (texture2D)
+    {
+        D3D11_TEXTURE2D_DESC texDesc;
+        texture2D-&gt;GetDesc(&amp;texDesc);
+        SafeRelease(texture2D);
+
+        *mipLevels = texDesc.MipLevels;
+        *samples = texDesc.SampleDesc.Count &gt; 1 ? texDesc.SampleDesc.Count : 0;
+
+        return true;
+    }
+
+    ID3D11Texture3D *texture3D = d3d11::DynamicCastComObject&lt;ID3D11Texture3D&gt;(resource);
+    if (texture3D)
+    {
+        D3D11_TEXTURE3D_DESC texDesc;
+        texture3D-&gt;GetDesc(&amp;texDesc);
+        SafeRelease(texture3D);
+
+        *mipLevels = texDesc.MipLevels;
+        *samples = 0;
+
+        return true;
+    }
+
+    return false;
+}
+
+static unsigned int getRTVSubresourceIndex(ID3D11Resource *resource, ID3D11RenderTargetView *view)
+{
</ins><span class="cx">     D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
</span><span class="cx">     view-&gt;GetDesc(&amp;rtvDesc);
</span><span class="cx"> 
</span><del>-    D3D11_TEXTURE2D_DESC texDesc;
-    texture-&gt;GetDesc(&amp;texDesc);
-
</del><span class="cx">     unsigned int mipSlice = 0;
</span><span class="cx">     unsigned int arraySlice = 0;
</span><del>-    unsigned int mipLevels = texDesc.MipLevels;
</del><span class="cx"> 
</span><span class="cx">     switch (rtvDesc.ViewDimension)
</span><span class="cx">     {
</span><span class="lines">@@ -76,20 +117,19 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    unsigned int mipLevels, samples;
+    getTextureProperties(resource,  &amp;mipLevels, &amp;samples);
+
</ins><span class="cx">     return D3D11CalcSubresource(mipSlice, arraySlice, mipLevels);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static unsigned int getDSVSubresourceIndex(ID3D11Texture2D *texture, ID3D11DepthStencilView *view)
</del><ins>+static unsigned int getDSVSubresourceIndex(ID3D11Resource *resource, ID3D11DepthStencilView *view)
</ins><span class="cx"> {
</span><span class="cx">     D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
</span><span class="cx">     view-&gt;GetDesc(&amp;dsvDesc);
</span><span class="cx"> 
</span><del>-    D3D11_TEXTURE2D_DESC texDesc;
-    texture-&gt;GetDesc(&amp;texDesc);
-
</del><span class="cx">     unsigned int mipSlice = 0;
</span><span class="cx">     unsigned int arraySlice = 0;
</span><del>-    unsigned int mipLevels = texDesc.MipLevels;
</del><span class="cx"> 
</span><span class="cx">     switch (dsvDesc.ViewDimension)
</span><span class="cx">     {
</span><span class="lines">@@ -123,7 +163,7 @@
</span><span class="cx">         arraySlice = dsvDesc.Texture2DMSArray.FirstArraySlice;
</span><span class="cx">         break;
</span><span class="cx"> 
</span><del>-      case D3D11_RTV_DIMENSION_UNKNOWN:
</del><ins>+      case D3D11_DSV_DIMENSION_UNKNOWN:
</ins><span class="cx">         UNIMPLEMENTED();
</span><span class="cx">         break;
</span><span class="cx"> 
</span><span class="lines">@@ -132,16 +172,37 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    unsigned int mipLevels, samples;
+    getTextureProperties(resource, &amp;mipLevels, &amp;samples);
+
</ins><span class="cx">     return D3D11CalcSubresource(mipSlice, arraySlice, mipLevels);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11RenderTargetView *rtv, ID3D11Texture2D *tex, ID3D11ShaderResourceView *srv, GLsizei width, GLsizei height)
</del><ins>+RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11RenderTargetView *rtv, ID3D11Resource *resource,
+                               ID3D11ShaderResourceView *srv, GLsizei width, GLsizei height, GLsizei depth)
</ins><span class="cx"> {
</span><span class="cx">     mRenderer = Renderer11::makeRenderer11(renderer);
</span><del>-    mTexture = tex;
</del><ins>+
+    mTexture = resource;
+    if (mTexture)
+    {
+        mTexture-&gt;AddRef();
+    }
+
</ins><span class="cx">     mRenderTarget = rtv;
</span><ins>+    if (mRenderTarget)
+    {
+        mRenderTarget-&gt;AddRef();
+    }
+
</ins><span class="cx">     mDepthStencil = NULL;
</span><ins>+
</ins><span class="cx">     mShaderResource = srv;
</span><ins>+    if (mShaderResource)
+    {
+        mShaderResource-&gt;AddRef();
+    }
+
</ins><span class="cx">     mSubresourceIndex = 0;
</span><span class="cx"> 
</span><span class="cx">     if (mRenderTarget &amp;&amp; mTexture)
</span><span class="lines">@@ -149,26 +210,45 @@
</span><span class="cx">         D3D11_RENDER_TARGET_VIEW_DESC desc;
</span><span class="cx">         mRenderTarget-&gt;GetDesc(&amp;desc);
</span><span class="cx"> 
</span><del>-        D3D11_TEXTURE2D_DESC texDesc;
-        mTexture-&gt;GetDesc(&amp;texDesc);
</del><ins>+        unsigned int mipLevels, samples;
+        getTextureProperties(mTexture, &amp;mipLevels, &amp;samples);
</ins><span class="cx"> 
</span><span class="cx">         mSubresourceIndex = getRTVSubresourceIndex(mTexture, mRenderTarget);
</span><span class="cx">         mWidth = width;
</span><span class="cx">         mHeight = height;
</span><del>-        mSamples = (texDesc.SampleDesc.Count &gt; 1) ? texDesc.SampleDesc.Count : 0;
</del><ins>+        mDepth = depth;
+        mSamples = samples;
</ins><span class="cx"> 
</span><del>-        mInternalFormat = d3d11_gl::ConvertTextureInternalFormat(desc.Format);
-        mActualFormat = d3d11_gl::ConvertTextureInternalFormat(desc.Format);
</del><ins>+        mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer-&gt;getCurrentClientVersion());
+        mActualFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer-&gt;getCurrentClientVersion());
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11DepthStencilView *dsv, ID3D11Texture2D *tex, ID3D11ShaderResourceView *srv, GLsizei width, GLsizei height)
</del><ins>+RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11DepthStencilView *dsv, ID3D11Resource *resource,
+                               ID3D11ShaderResourceView *srv, GLsizei width, GLsizei height, GLsizei depth)
</ins><span class="cx"> {
</span><span class="cx">     mRenderer = Renderer11::makeRenderer11(renderer);
</span><del>-    mTexture = tex;
</del><ins>+
+    mTexture = resource;
+    if (mTexture)
+    {
+        mTexture-&gt;AddRef();
+    }
+
</ins><span class="cx">     mRenderTarget = NULL;
</span><ins>+
</ins><span class="cx">     mDepthStencil = dsv;
</span><ins>+    if (mDepthStencil)
+    {
+        mDepthStencil-&gt;AddRef();
+    }
+
</ins><span class="cx">     mShaderResource = srv;
</span><ins>+    if (mShaderResource)
+    {
+        mShaderResource-&gt;AddRef();
+    }
+
</ins><span class="cx">     mSubresourceIndex = 0;
</span><span class="cx"> 
</span><span class="cx">     if (mDepthStencil &amp;&amp; mTexture)
</span><span class="lines">@@ -176,20 +256,21 @@
</span><span class="cx">         D3D11_DEPTH_STENCIL_VIEW_DESC desc;
</span><span class="cx">         mDepthStencil-&gt;GetDesc(&amp;desc);
</span><span class="cx"> 
</span><del>-        D3D11_TEXTURE2D_DESC texDesc;
-        mTexture-&gt;GetDesc(&amp;texDesc);
</del><ins>+        unsigned int mipLevels, samples;
+        getTextureProperties(mTexture, &amp;mipLevels, &amp;samples);
</ins><span class="cx"> 
</span><span class="cx">         mSubresourceIndex = getDSVSubresourceIndex(mTexture, mDepthStencil);
</span><span class="cx">         mWidth = width;
</span><span class="cx">         mHeight = height;
</span><del>-        mSamples = (texDesc.SampleDesc.Count &gt; 1) ? texDesc.SampleDesc.Count : 0;
</del><ins>+        mDepth = depth;
+        mSamples = samples;
</ins><span class="cx"> 
</span><del>-        mInternalFormat = d3d11_gl::ConvertTextureInternalFormat(desc.Format);
-        mActualFormat = d3d11_gl::ConvertTextureInternalFormat(desc.Format);
</del><ins>+        mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer-&gt;getCurrentClientVersion());
+        mActualFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer-&gt;getCurrentClientVersion());
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height, GLenum format, GLsizei samples, bool depth)
</del><ins>+RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height, GLenum internalFormat, GLsizei samples)
</ins><span class="cx"> {
</span><span class="cx">     mRenderer = Renderer11::makeRenderer11(renderer);
</span><span class="cx">     mTexture = NULL;
</span><span class="lines">@@ -197,9 +278,15 @@
</span><span class="cx">     mDepthStencil = NULL;
</span><span class="cx">     mShaderResource = NULL;
</span><span class="cx"> 
</span><del>-    DXGI_FORMAT requestedFormat = gl_d3d11::ConvertRenderbufferFormat(format);
</del><ins>+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
</ins><span class="cx"> 
</span><del>-    int supportedSamples = mRenderer-&gt;getNearestSupportedSamples(requestedFormat, samples);
</del><ins>+    DXGI_FORMAT texFormat = gl_d3d11::GetTexFormat(internalFormat, clientVersion);
+    DXGI_FORMAT srvFormat = gl_d3d11::GetSRVFormat(internalFormat, clientVersion);
+    DXGI_FORMAT rtvFormat = gl_d3d11::GetRTVFormat(internalFormat, clientVersion);
+    DXGI_FORMAT dsvFormat = gl_d3d11::GetDSVFormat(internalFormat, clientVersion);
+
+    DXGI_FORMAT multisampleFormat = (dsvFormat != DXGI_FORMAT_UNKNOWN ? dsvFormat : rtvFormat);
+    int supportedSamples = mRenderer-&gt;getNearestSupportedSamples(multisampleFormat, samples);
</ins><span class="cx">     if (supportedSamples &lt; 0)
</span><span class="cx">     {
</span><span class="cx">         gl::error(GL_OUT_OF_MEMORY);
</span><span class="lines">@@ -214,16 +301,20 @@
</span><span class="cx">         desc.Height = height;
</span><span class="cx">         desc.MipLevels = 1;
</span><span class="cx">         desc.ArraySize = 1;
</span><del>-        desc.Format = requestedFormat;
</del><ins>+        desc.Format = texFormat;
</ins><span class="cx">         desc.SampleDesc.Count = (supportedSamples == 0) ? 1 : supportedSamples;
</span><span class="cx">         desc.SampleDesc.Quality = 0;
</span><span class="cx">         desc.Usage = D3D11_USAGE_DEFAULT;
</span><span class="cx">         desc.CPUAccessFlags = 0;
</span><span class="cx">         desc.MiscFlags = 0;
</span><del>-        desc.BindFlags = (depth ? D3D11_BIND_DEPTH_STENCIL : (D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE));
</del><ins>+        desc.BindFlags = ((srvFormat != DXGI_FORMAT_UNKNOWN) ? D3D11_BIND_SHADER_RESOURCE : 0) |
+                         ((dsvFormat != DXGI_FORMAT_UNKNOWN) ? D3D11_BIND_DEPTH_STENCIL   : 0) |
+                         ((rtvFormat != DXGI_FORMAT_UNKNOWN) ? D3D11_BIND_RENDER_TARGET   : 0);
</ins><span class="cx"> 
</span><span class="cx">         ID3D11Device *device = mRenderer-&gt;getDevice();
</span><del>-        HRESULT result = device-&gt;CreateTexture2D(&amp;desc, NULL, &amp;mTexture);
</del><ins>+        ID3D11Texture2D *texture = NULL;
+        HRESULT result = device-&gt;CreateTexture2D(&amp;desc, NULL, &amp;texture);
+        mTexture = texture;
</ins><span class="cx"> 
</span><span class="cx">         if (result == E_OUTOFMEMORY)
</span><span class="cx">         {
</span><span class="lines">@@ -232,10 +323,28 @@
</span><span class="cx">         }
</span><span class="cx">         ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-        if (depth)
</del><ins>+        if (srvFormat != DXGI_FORMAT_UNKNOWN)
</ins><span class="cx">         {
</span><ins>+            D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+            srvDesc.Format = srvFormat;
+            srvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_SRV_DIMENSION_TEXTURE2D : D3D11_SRV_DIMENSION_TEXTURE2DMS;
+            srvDesc.Texture2D.MostDetailedMip = 0;
+            srvDesc.Texture2D.MipLevels = 1;
+            result = device-&gt;CreateShaderResourceView(mTexture, &amp;srvDesc, &amp;mShaderResource);
+
+            if (result == E_OUTOFMEMORY)
+            {
+                SafeRelease(mTexture);
+                gl::error(GL_OUT_OF_MEMORY);
+                return;
+            }
+            ASSERT(SUCCEEDED(result));
+        }
+
+        if (dsvFormat != DXGI_FORMAT_UNKNOWN)
+        {
</ins><span class="cx">             D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
</span><del>-            dsvDesc.Format = requestedFormat;
</del><ins>+            dsvDesc.Format = dsvFormat;
</ins><span class="cx">             dsvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_DSV_DIMENSION_TEXTURE2D : D3D11_DSV_DIMENSION_TEXTURE2DMS;
</span><span class="cx">             dsvDesc.Texture2D.MipSlice = 0;
</span><span class="cx">             dsvDesc.Flags = 0;
</span><span class="lines">@@ -243,82 +352,57 @@
</span><span class="cx"> 
</span><span class="cx">             if (result == E_OUTOFMEMORY)
</span><span class="cx">             {
</span><del>-                mTexture-&gt;Release();
-                mTexture = NULL;
</del><ins>+                SafeRelease(mTexture);
+                SafeRelease(mShaderResource);
</ins><span class="cx">                 gl::error(GL_OUT_OF_MEMORY);
</span><ins>+                return;
</ins><span class="cx">             }
</span><span class="cx">             ASSERT(SUCCEEDED(result));
</span><span class="cx">         }
</span><del>-        else
</del><ins>+
+        if (rtvFormat != DXGI_FORMAT_UNKNOWN)
</ins><span class="cx">         {
</span><span class="cx">             D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
</span><del>-            rtvDesc.Format = requestedFormat;
</del><ins>+            rtvDesc.Format = rtvFormat;
</ins><span class="cx">             rtvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_RTV_DIMENSION_TEXTURE2D : D3D11_RTV_DIMENSION_TEXTURE2DMS;
</span><span class="cx">             rtvDesc.Texture2D.MipSlice = 0;
</span><span class="cx">             result = device-&gt;CreateRenderTargetView(mTexture, &amp;rtvDesc, &amp;mRenderTarget);
</span><span class="cx"> 
</span><span class="cx">             if (result == E_OUTOFMEMORY)
</span><span class="cx">             {
</span><del>-                mTexture-&gt;Release();
-                mTexture = NULL;
</del><ins>+                SafeRelease(mTexture);
+                SafeRelease(mShaderResource);
+                SafeRelease(mDepthStencil);
</ins><span class="cx">                 gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx">             ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-            D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
-            srvDesc.Format = requestedFormat;
-            srvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_SRV_DIMENSION_TEXTURE2D : D3D11_SRV_DIMENSION_TEXTURE2DMS;
-            srvDesc.Texture2D.MostDetailedMip = 0;
-            srvDesc.Texture2D.MipLevels = 1;
-            result = device-&gt;CreateShaderResourceView(mTexture, &amp;srvDesc, &amp;mShaderResource);
</del><ins>+            if (gl_d3d11::RequiresTextureDataInitialization(internalFormat))
+            {
+                ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
</ins><span class="cx"> 
</span><del>-            if (result == E_OUTOFMEMORY)
-            {
-                mTexture-&gt;Release();
-                mTexture = NULL;
-                mRenderTarget-&gt;Release();
-                mRenderTarget = NULL;
-                gl::error(GL_OUT_OF_MEMORY);
-                return;
</del><ins>+                const float clearValues[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
+                context-&gt;ClearRenderTargetView(mRenderTarget, clearValues);
</ins><span class="cx">             }
</span><del>-            ASSERT(SUCCEEDED(result));
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     mWidth = width;
</span><span class="cx">     mHeight = height;
</span><del>-    mInternalFormat = format;
</del><ins>+    mDepth = 1;
+    mInternalFormat = internalFormat;
</ins><span class="cx">     mSamples = supportedSamples;
</span><del>-    mActualFormat = d3d11_gl::ConvertTextureInternalFormat(requestedFormat);
</del><ins>+    mActualFormat = d3d11_gl::GetInternalFormat(texFormat, renderer-&gt;getCurrentClientVersion());
</ins><span class="cx">     mSubresourceIndex = D3D11CalcSubresource(0, 0, 1);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderTarget11::~RenderTarget11()
</span><span class="cx"> {
</span><del>-    if (mTexture)
-    {
-        mTexture-&gt;Release();
-        mTexture = NULL;
-    }
-
-    if (mRenderTarget)
-    {
-        mRenderTarget-&gt;Release();
-        mRenderTarget = NULL;
-    }
-
-    if (mDepthStencil)
-    {
-        mDepthStencil-&gt;Release();
-        mDepthStencil = NULL;
-    }
-
-    if (mShaderResource)
-    {
-        mShaderResource-&gt;Release();
-        mShaderResource = NULL;
-    }
</del><ins>+    SafeRelease(mTexture);
+    SafeRelease(mRenderTarget);
+    SafeRelease(mDepthStencil);
+    SafeRelease(mShaderResource);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderTarget11 *RenderTarget11::makeRenderTarget11(RenderTarget *target)
</span><span class="lines">@@ -327,8 +411,13 @@
</span><span class="cx">     return static_cast&lt;rx::RenderTarget11*&gt;(target);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ID3D11Texture2D *RenderTarget11::getTexture() const
</del><ins>+void RenderTarget11::invalidate(GLint x, GLint y, GLsizei width, GLsizei height)
</ins><span class="cx"> {
</span><ins>+    // Currently a no-op
+}
+
+ID3D11Resource *RenderTarget11::getTexture() const
+{
</ins><span class="cx">     return mTexture;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11RenderTarget11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderTarget11.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderTarget11.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/RenderTarget11.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -20,14 +20,17 @@
</span><span class="cx"> class RenderTarget11 : public RenderTarget
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    RenderTarget11(Renderer *renderer, ID3D11RenderTargetView *rtv, ID3D11Texture2D *tex, ID3D11ShaderResourceView *srv, GLsizei width, GLsizei height);
-    RenderTarget11(Renderer *renderer, ID3D11DepthStencilView *dsv, ID3D11Texture2D *tex, ID3D11ShaderResourceView *srv, GLsizei width, GLsizei height);
-    RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height, GLenum format, GLsizei samples, bool depth);
</del><ins>+    // RenderTarget11 takes ownership of any D3D11 resources it is given and will AddRef them
+    RenderTarget11(Renderer *renderer, ID3D11RenderTargetView *rtv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv, GLsizei width, GLsizei height, GLsizei depth);
+    RenderTarget11(Renderer *renderer, ID3D11DepthStencilView *dsv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv, GLsizei width, GLsizei height, GLsizei depth);
+    RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height, GLenum internalFormat, GLsizei samples);
</ins><span class="cx">     virtual ~RenderTarget11();
</span><span class="cx"> 
</span><span class="cx">     static RenderTarget11 *makeRenderTarget11(RenderTarget *renderTarget);
</span><span class="cx"> 
</span><del>-    ID3D11Texture2D *getTexture() const;
</del><ins>+    virtual void invalidate(GLint x, GLint y, GLsizei width, GLsizei height);
+
+    ID3D11Resource *getTexture() const;
</ins><span class="cx">     ID3D11RenderTargetView *getRenderTargetView() const;
</span><span class="cx">     ID3D11DepthStencilView *getDepthStencilView() const;
</span><span class="cx">     ID3D11ShaderResourceView *getShaderResourceView() const;
</span><span class="lines">@@ -38,7 +41,7 @@
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(RenderTarget11);
</span><span class="cx"> 
</span><span class="cx">     unsigned int mSubresourceIndex;
</span><del>-    ID3D11Texture2D *mTexture;
</del><ins>+    ID3D11Resource *mTexture;
</ins><span class="cx">     ID3D11RenderTargetView *mRenderTarget;
</span><span class="cx">     ID3D11DepthStencilView *mDepthStencil;
</span><span class="cx">     ID3D11ShaderResourceView *mShaderResource;
</span><span class="lines">@@ -48,4 +51,4 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#endif LIBGLESV2_RENDERER_RENDERTARGET11_H_
</del><span class="cx">\ No newline at end of file
</span><ins>+#endif LIBGLESV2_RENDERER_RENDERTARGET11_H_
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Renderer11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Renderer11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Renderer11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Renderer11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -8,14 +8,15 @@
</span><span class="cx"> // Renderer11.cpp: Implements a back-end specific class for the D3D11 renderer.
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;common/utilities.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/Buffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/ProgramBinary.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Framebuffer.h&quot;
</span><del>-#include &quot;libGLESv2/Renderbuffer.h&quot;
</del><ins>+#include &quot;libGLESv2/RenderBuffer.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Renderer11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/RenderTarget11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/renderer11_utils.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d11/formatutils11.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/ShaderExecutable11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/SwapChain11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Image11.h&quot;
</span><span class="lines">@@ -27,17 +28,9 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/TextureStorage11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Query11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Fence11.h&quot;
</span><del>-
-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/passthrough11vs.h&quot;
-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba11ps.h&quot;
-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb11ps.h&quot;
-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum11ps.h&quot;
-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha11ps.h&quot;
-
-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/clear11vs.h&quot;
-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/clearsingle11ps.h&quot;
-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/clearmultiple11ps.h&quot;
-
</del><ins>+#include &quot;libGLESv2/renderer/d3d11/Blit11.h&quot;
+#include &quot;libGLESv2/renderer/d3d11/Clear11.h&quot;
+#include &quot;libGLESv2/renderer/d3d11/PixelTransfer11.h&quot;
</ins><span class="cx"> #include &quot;libEGL/Display.h&quot;
</span><span class="cx"> 
</span><span class="cx"> // Enable ANGLE_SKIP_DXGI_1_2_CHECK if there is not a possibility of using cross-process
</span><span class="lines">@@ -80,24 +73,10 @@
</span><span class="cx">     mLineLoopIB = NULL;
</span><span class="cx">     mTriangleFanIB = NULL;
</span><span class="cx"> 
</span><del>-    mCopyResourcesInitialized = false;
-    mCopyVB = NULL;
-    mCopySampler = NULL;
-    mCopyIL = NULL;
-    mCopyVS = NULL;
-    mCopyRGBAPS = NULL;
-    mCopyRGBPS = NULL;
-    mCopyLumPS = NULL;
-    mCopyLumAlphaPS = NULL;
</del><ins>+    mBlit = NULL;
+    mPixelTransfer = NULL;
</ins><span class="cx"> 
</span><del>-    mClearResourcesInitialized = false;
-    mClearVB = NULL;
-    mClearIL = NULL;
-    mClearVS = NULL;
-    mClearSinglePS = NULL;
-    mClearMultiplePS = NULL;
-    mClearScissorRS = NULL;
-    mClearNoScissorRS = NULL;
</del><ins>+    mClear = NULL;
</ins><span class="cx"> 
</span><span class="cx">     mSyncQuery = NULL;
</span><span class="cx"> 
</span><span class="lines">@@ -118,7 +97,10 @@
</span><span class="cx"> 
</span><span class="cx">     mBGRATextureSupport = false;
</span><span class="cx"> 
</span><del>-    mIsGeometryShaderActive = false;
</del><ins>+    mAppliedVertexShader = NULL;
+    mAppliedGeometryShader = NULL;
+    mCurPointGeometryShader = NULL;
+    mAppliedPixelShader = NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Renderer11::~Renderer11()
</span><span class="lines">@@ -138,7 +120,7 @@
</span><span class="cx"> 
</span><span class="cx"> EGLint Renderer11::initialize()
</span><span class="cx"> {
</span><del>-    if (!initializeCompiler())
</del><ins>+    if (!mCompiler.initialize())
</ins><span class="cx">     {
</span><span class="cx">         return EGL_NOT_INITIALIZED;
</span><span class="cx">     }
</span><span class="lines">@@ -256,7 +238,7 @@
</span><span class="cx">         return EGL_NOT_INITIALIZED;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    dxgiDevice-&gt;Release();
</del><ins>+    SafeRelease(dxgiDevice);
</ins><span class="cx"> 
</span><span class="cx">     mDxgiAdapter-&gt;GetDesc(&amp;mAdapterDescription);
</span><span class="cx">     memset(mDescription, 0, sizeof(mDescription));
</span><span class="lines">@@ -287,43 +269,19 @@
</span><span class="cx">         filter.DenyList.pIDList = hideMessages;
</span><span class="cx"> 
</span><span class="cx">         infoQueue-&gt;AddStorageFilterEntries(&amp;filter);
</span><del>-
-        infoQueue-&gt;Release();
</del><ins>+        SafeRelease(infoQueue);
</ins><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    unsigned int maxSupportedSamples = 0;
-    unsigned int rtFormatCount = ArraySize(RenderTargetFormats);
-    unsigned int dsFormatCount = ArraySize(DepthStencilFormats);
-    for (unsigned int i = 0; i &lt; rtFormatCount + dsFormatCount; ++i)
</del><ins>+    mMaxSupportedSamples = 0;
+
+    const d3d11::DXGIFormatSet &amp;dxgiFormats = d3d11::GetAllUsedDXGIFormats();
+    for (d3d11::DXGIFormatSet::const_iterator i = dxgiFormats.begin(); i != dxgiFormats.end(); ++i)
</ins><span class="cx">     {
</span><del>-        DXGI_FORMAT format = (i &lt; rtFormatCount) ? RenderTargetFormats[i] : DepthStencilFormats[i - rtFormatCount];
-        if (format != DXGI_FORMAT_UNKNOWN)
-        {
-            UINT formatSupport;
-            result = mDevice-&gt;CheckFormatSupport(format, &amp;formatSupport);
-            if (SUCCEEDED(result) &amp;&amp; (formatSupport &amp; D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET))
-            {
-                MultisampleSupportInfo supportInfo;
-
-                for (unsigned int j = 1; j &lt;= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; j++)
-                {
-                    result = mDevice-&gt;CheckMultisampleQualityLevels(format, j, &amp;supportInfo.qualityLevels[j - 1]);
-                    if (SUCCEEDED(result) &amp;&amp; supportInfo.qualityLevels[j - 1] &gt; 0)
-                    {
-                        maxSupportedSamples = std::max(j, maxSupportedSamples);
-                    }
-                    else
-                    {
-                        supportInfo.qualityLevels[j - 1] = 0;
-                    }
-                }
-
-                mMultisampleSupportMap.insert(std::make_pair(format, supportInfo));
-            }
-        }
</del><ins>+        MultisampleSupportInfo support = getMultisampleSupportInfo(*i);
+        mMultisampleSupportMap.insert(std::make_pair(*i, support));
+        mMaxSupportedSamples = std::max(mMaxSupportedSamples, support.maxSupportedSamples);
</ins><span class="cx">     }
</span><del>-    mMaxSupportedSamples = maxSupportedSamples;
</del><span class="cx"> 
</span><span class="cx">     initializeDevice();
</span><span class="cx"> 
</span><span class="lines">@@ -397,6 +355,31 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    DXGI_FORMAT rgTextureFormats[] =
+    {
+        DXGI_FORMAT_R8_UNORM,
+        DXGI_FORMAT_R8G8_UNORM,
+        DXGI_FORMAT_R16_FLOAT,
+        DXGI_FORMAT_R16G16_FLOAT,
+        DXGI_FORMAT_R32_FLOAT,
+        DXGI_FORMAT_R32G32_FLOAT,
+    };
+
+    mRGTextureSupport = true;
+    for (unsigned int i = 0; i &lt; ArraySize(rgTextureFormats); i++)
+    {
+        if (SUCCEEDED(mDevice-&gt;CheckFormatSupport(rgTextureFormats[i], &amp;formatSupport)))
+        {
+            mRGTextureSupport = mRGTextureSupport &amp;&amp; (formatSupport &amp; requiredTextureFlags) == requiredTextureFlags;
+            mRGTextureSupport = mRGTextureSupport &amp;&amp; (formatSupport &amp; requiredFilterFlags) == requiredFilterFlags;
+            mRGTextureSupport = mRGTextureSupport &amp;&amp; (formatSupport &amp; requiredRenderableFlags) == requiredRenderableFlags;
+        }
+        else
+        {
+            mRGTextureSupport = false;
+        }
+    }
+
</ins><span class="cx">     // Check compressed texture support
</span><span class="cx">     const unsigned int requiredCompressedTextureFlags = D3D11_FORMAT_SUPPORT_TEXTURE2D;
</span><span class="cx"> 
</span><span class="lines">@@ -465,6 +448,15 @@
</span><span class="cx">     mVertexDataManager = new VertexDataManager(this);
</span><span class="cx">     mIndexDataManager = new IndexDataManager(this);
</span><span class="cx"> 
</span><ins>+    ASSERT(!mBlit);
+    mBlit = new Blit11(this);
+
+    ASSERT(!mClear);
+    mClear = new Clear11(this);
+
+    ASSERT(!mPixelTransfer);
+    mPixelTransfer = new PixelTransfer11(this);
+
</ins><span class="cx">     markAllStateDirty();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -492,18 +484,23 @@
</span><span class="cx"> 
</span><span class="cx">                 if (depthStencilFormat != DXGI_FORMAT_UNKNOWN)
</span><span class="cx">                 {
</span><del>-                    UINT formatSupport = 0;
-                    result = mDevice-&gt;CheckFormatSupport(depthStencilFormat, &amp;formatSupport);
-                    depthStencilFormatOK = SUCCEEDED(result) &amp;&amp; (formatSupport &amp; D3D11_FORMAT_SUPPORT_DEPTH_STENCIL);
</del><ins>+                    UINT depthStencilSupport = 0;
+                    result = mDevice-&gt;CheckFormatSupport(depthStencilFormat, &amp;depthStencilSupport);
+                    depthStencilFormatOK = SUCCEEDED(result) &amp;&amp; (depthStencilSupport &amp; D3D11_FORMAT_SUPPORT_DEPTH_STENCIL);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (depthStencilFormatOK)
</span><span class="cx">                 {
</span><ins>+                    // FIXME: parse types from context version
+                    ASSERT(d3d11_gl::GetInternalFormat(renderTargetFormat, 2) == d3d11_gl::GetInternalFormat(renderTargetFormat, 3));
+                    ASSERT(d3d11_gl::GetInternalFormat(depthStencilFormat, 2) == d3d11_gl::GetInternalFormat(depthStencilFormat, 3));
+
</ins><span class="cx">                     ConfigDesc newConfig;
</span><del>-                    newConfig.renderTargetFormat = d3d11_gl::ConvertBackBufferFormat(renderTargetFormat);
-                    newConfig.depthStencilFormat = d3d11_gl::ConvertDepthStencilFormat(depthStencilFormat);
</del><ins>+                    newConfig.renderTargetFormat = d3d11_gl::GetInternalFormat(renderTargetFormat, getCurrentClientVersion());
+                    newConfig.depthStencilFormat = d3d11_gl::GetInternalFormat(depthStencilFormat, getCurrentClientVersion());
</ins><span class="cx">                     newConfig.multiSample = 0;     // FIXME: enumerate multi-sampling
</span><span class="cx">                     newConfig.fastConfig = true;   // Assume all DX11 format conversions to be fast
</span><ins>+                    newConfig.es3Capable = true;
</ins><span class="cx"> 
</span><span class="cx">                     (*configDescList)[numConfigs++] = newConfig;
</span><span class="cx">                 }
</span><span class="lines">@@ -563,6 +560,21 @@
</span><span class="cx">     return new rx::SwapChain11(this, window, shareHandle, backBufferFormat, depthBufferFormat);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Renderer11::generateSwizzle(gl::Texture *texture)
+{
+    if (texture)
+    {
+        TextureStorageInterface *texStorage = texture-&gt;getNativeTexture();
+        if (texStorage)
+        {
+            TextureStorage11 *storage11 = TextureStorage11::makeTextureStorage11(texStorage-&gt;getStorageInstance());
+
+            storage11-&gt;generateSwizzles(texture-&gt;getSwizzleRed(), texture-&gt;getSwizzleGreen(), texture-&gt;getSwizzleBlue(),
+                                        texture-&gt;getSwizzleAlpha());
+        }
+    }
+}
+
</ins><span class="cx"> void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &amp;samplerState)
</span><span class="cx"> {
</span><span class="cx">     if (type == gl::SAMPLER_PIXEL)
</span><span class="lines">@@ -621,7 +633,6 @@
</span><span class="cx"> void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
</span><span class="cx"> {
</span><span class="cx">     ID3D11ShaderResourceView *textureSRV = NULL;
</span><del>-    unsigned int serial = 0;
</del><span class="cx">     bool forceSetTexture = false;
</span><span class="cx"> 
</span><span class="cx">     if (texture)
</span><span class="lines">@@ -630,14 +641,15 @@
</span><span class="cx">         if (texStorage)
</span><span class="cx">         {
</span><span class="cx">             TextureStorage11 *storage11 = TextureStorage11::makeTextureStorage11(texStorage-&gt;getStorageInstance());
</span><del>-            textureSRV = storage11-&gt;getSRV();
</del><ins>+            gl::SamplerState samplerState;
+            texture-&gt;getSamplerState(&amp;samplerState);
+            textureSRV = storage11-&gt;getSRV(samplerState);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // If we get NULL back from getSRV here, something went wrong in the texture class and we're unexpectedly
</span><span class="cx">         // missing the shader resource view
</span><span class="cx">         ASSERT(textureSRV != NULL);
</span><span class="cx"> 
</span><del>-        serial = texture-&gt;getTextureSerial();
</del><span class="cx">         forceSetTexture = texture-&gt;hasDirtyImages();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -649,12 +661,12 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (forceSetTexture || mCurPixelTextureSerials[index] != serial)
</del><ins>+        if (forceSetTexture || mCurPixelSRVs[index] != textureSRV)
</ins><span class="cx">         {
</span><span class="cx">             mDeviceContext-&gt;PSSetShaderResources(index, 1, &amp;textureSRV);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        mCurPixelTextureSerials[index] = serial;
</del><ins>+        mCurPixelSRVs[index] = textureSRV;
</ins><span class="cx">     }
</span><span class="cx">     else if (type == gl::SAMPLER_VERTEX)
</span><span class="cx">     {
</span><span class="lines">@@ -664,16 +676,65 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (forceSetTexture || mCurVertexTextureSerials[index] != serial)
</del><ins>+        if (forceSetTexture || mCurVertexSRVs[index] != textureSRV)
</ins><span class="cx">         {
</span><span class="cx">             mDeviceContext-&gt;VSSetShaderResources(index, 1, &amp;textureSRV);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        mCurVertexTextureSerials[index] = serial;
</del><ins>+        mCurVertexSRVs[index] = textureSRV;
</ins><span class="cx">     }
</span><span class="cx">     else UNREACHABLE();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer11::setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[])
+{
+    for (unsigned int uniformBufferIndex = 0; uniformBufferIndex &lt; gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS; uniformBufferIndex++)
+    {
+        const gl::Buffer *uniformBuffer = vertexUniformBuffers[uniformBufferIndex];
+        if (uniformBuffer)
+        {
+            BufferStorage11 *bufferStorage = BufferStorage11::makeBufferStorage11(uniformBuffer-&gt;getStorage());
+            ID3D11Buffer *constantBuffer = bufferStorage-&gt;getBuffer(BUFFER_USAGE_UNIFORM);
+
+            if (!constantBuffer)
+            {
+                return false;
+            }
+
+            if (mCurrentConstantBufferVS[uniformBufferIndex] != bufferStorage-&gt;getSerial())
+            {
+                mDeviceContext-&gt;VSSetConstantBuffers(getReservedVertexUniformBuffers() + uniformBufferIndex,
+                                                     1, &amp;constantBuffer);
+                mCurrentConstantBufferVS[uniformBufferIndex] = bufferStorage-&gt;getSerial();
+            }
+        }
+    }
+
+    for (unsigned int uniformBufferIndex = 0; uniformBufferIndex &lt; gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS; uniformBufferIndex++)
+    {
+        const gl::Buffer *uniformBuffer = fragmentUniformBuffers[uniformBufferIndex];
+        if (uniformBuffer)
+        {
+            BufferStorage11 *bufferStorage = BufferStorage11::makeBufferStorage11(uniformBuffer-&gt;getStorage());
+            ID3D11Buffer *constantBuffer = bufferStorage-&gt;getBuffer(BUFFER_USAGE_UNIFORM);
+
+            if (!constantBuffer)
+            {
+                return false;
+            }
+
+            if (mCurrentConstantBufferPS[uniformBufferIndex] != bufferStorage-&gt;getSerial())
+            {
+                mDeviceContext-&gt;PSSetConstantBuffers(getReservedFragmentUniformBuffers() + uniformBufferIndex,
+                                                     1, &amp;constantBuffer);
+                mCurrentConstantBufferPS[uniformBufferIndex] = bufferStorage-&gt;getSerial();
+            }
+        }
+    }
+
+    return true;
+}
+
</ins><span class="cx"> void Renderer11::setRasterizerState(const gl::RasterizerState &amp;rasterState)
</span><span class="cx"> {
</span><span class="cx">     if (mForceSetRasterState || memcmp(&amp;rasterState, &amp;mCurRasterState, sizeof(gl::RasterizerState)) != 0)
</span><span class="lines">@@ -694,12 +755,12 @@
</span><span class="cx">     mForceSetRasterState = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer11::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::Color &amp;blendColor,
</del><ins>+void Renderer11::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::ColorF &amp;blendColor,
</ins><span class="cx">                                unsigned int sampleMask)
</span><span class="cx"> {
</span><span class="cx">     if (mForceSetBlendState ||
</span><span class="cx">         memcmp(&amp;blendState, &amp;mCurBlendState, sizeof(gl::BlendState)) != 0 ||
</span><del>-        memcmp(&amp;blendColor, &amp;mCurBlendColor, sizeof(gl::Color)) != 0 ||
</del><ins>+        memcmp(&amp;blendColor, &amp;mCurBlendColor, sizeof(gl::ColorF)) != 0 ||
</ins><span class="cx">         sampleMask != mCurSampleMask)
</span><span class="cx">     {
</span><span class="cx">         ID3D11BlendState *dxBlendState = mStateCache.getBlendState(framebuffer, blendState);
</span><span class="lines">@@ -759,8 +820,14 @@
</span><span class="cx">                 &quot;setting the default depth stencil state.&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        mDeviceContext-&gt;OMSetDepthStencilState(dxDepthStencilState, static_cast&lt;UINT&gt;(stencilRef));
</del><ins>+        // Max D3D11 stencil reference value is 0xFF, corresponding to the max 8 bits in a stencil buffer
+        // GL specifies we should clamp the ref value to the nearest bit depth when doing stencil ops
+        META_ASSERT(D3D11_DEFAULT_STENCIL_READ_MASK == 0xFF);
+        META_ASSERT(D3D11_DEFAULT_STENCIL_WRITE_MASK == 0xFF);
+        UINT dxStencilRef = std::min&lt;UINT&gt;(stencilRef, 0xFFu);
</ins><span class="cx"> 
</span><ins>+        mDeviceContext-&gt;OMSetDepthStencilState(dxDepthStencilState, dxStencilRef);
+
</ins><span class="cx">         mCurDepthStencilState = depthStencilState;
</span><span class="cx">         mCurStencilRef = stencilRef;
</span><span class="cx">         mCurStencilBackRef = stencilBackRef;
</span><span class="lines">@@ -954,24 +1021,8 @@
</span><span class="cx">                 missingColorRenderTarget = false;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-#ifdef _DEBUG
-            // Workaround for Debug SETSHADERRESOURCES_HAZARD D3D11 warnings
-            for (unsigned int vertexSerialIndex = 0; vertexSerialIndex &lt; gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; vertexSerialIndex++)
-            {
-                if (colorbuffer-&gt;getTextureSerial() != 0 &amp;&amp; mCurVertexTextureSerials[vertexSerialIndex] == colorbuffer-&gt;getTextureSerial())
-                {
-                    setTexture(gl::SAMPLER_VERTEX, vertexSerialIndex, NULL);
-                }
-            }
-
-            for (unsigned int pixelSerialIndex = 0; pixelSerialIndex &lt; gl::MAX_TEXTURE_IMAGE_UNITS; pixelSerialIndex++)
-            {
-                if (colorbuffer-&gt;getTextureSerial() != 0 &amp;&amp; mCurPixelTextureSerials[pixelSerialIndex] == colorbuffer-&gt;getTextureSerial())
-                {
-                    setTexture(gl::SAMPLER_PIXEL, pixelSerialIndex, NULL);
-                }
-            }
-#endif
</del><ins>+            // TODO: Detect if this color buffer is already bound as a texture and unbind it first to prevent
+            //       D3D11 warnings.
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1052,6 +1103,7 @@
</span><span class="cx">         mRenderTargetDesc.format = renderTargetFormat;
</span><span class="cx">         mForceSetViewport = true;
</span><span class="cx">         mForceSetScissor = true;
</span><ins>+        mForceSetBlendState = true;
</ins><span class="cx"> 
</span><span class="cx">         if (!mDepthStencilInitialized || depthSize != mCurDepthSize)
</span><span class="cx">         {
</span><span class="lines">@@ -1071,13 +1123,16 @@
</span><span class="cx">         mDepthStencilInitialized = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    invalidateFramebufferSwizzles(framebuffer);
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLenum Renderer11::applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances)
</del><ins>+GLenum Renderer11::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
+                                     GLint first, GLsizei count, GLsizei instances)
</ins><span class="cx"> {
</span><span class="cx">     TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS];
</span><del>-    GLenum err = mVertexDataManager-&gt;prepareVertexData(vertexAttributes, programBinary, first, count, attributes, instances);
</del><ins>+    GLenum err = mVertexDataManager-&gt;prepareVertexData(vertexAttributes, currentValues, programBinary, first, count, attributes, instances);
</ins><span class="cx">     if (err != GL_NO_ERROR)
</span><span class="cx">     {
</span><span class="cx">         return err;
</span><span class="lines">@@ -1092,28 +1147,27 @@
</span><span class="cx"> 
</span><span class="cx">     if (err == GL_NO_ERROR)
</span><span class="cx">     {
</span><ins>+        IndexBuffer11* indexBuffer = IndexBuffer11::makeIndexBuffer11(indexInfo-&gt;indexBuffer);
+
+        ID3D11Buffer *buffer = NULL;
+        DXGI_FORMAT bufferFormat = indexBuffer-&gt;getIndexFormat();
+
</ins><span class="cx">         if (indexInfo-&gt;storage)
</span><span class="cx">         {
</span><del>-            if (indexInfo-&gt;serial != mAppliedStorageIBSerial || indexInfo-&gt;startOffset != mAppliedIBOffset)
-            {
-                BufferStorage11 *storage = BufferStorage11::makeBufferStorage11(indexInfo-&gt;storage);
-                IndexBuffer11* indexBuffer = IndexBuffer11::makeIndexBuffer11(indexInfo-&gt;indexBuffer);
-
-                mDeviceContext-&gt;IASetIndexBuffer(storage-&gt;getBuffer(BUFFER_USAGE_INDEX), indexBuffer-&gt;getIndexFormat(), indexInfo-&gt;startOffset);
-
-                mAppliedIBSerial = 0;
-                mAppliedStorageIBSerial = storage-&gt;getSerial();
-                mAppliedIBOffset = indexInfo-&gt;startOffset;
-            }
</del><ins>+            BufferStorage11 *storage = BufferStorage11::makeBufferStorage11(indexInfo-&gt;storage);
+            buffer = storage-&gt;getBuffer(BUFFER_USAGE_INDEX);
</ins><span class="cx">         }
</span><del>-        else if (indexInfo-&gt;serial != mAppliedIBSerial || indexInfo-&gt;startOffset != mAppliedIBOffset)
</del><ins>+        else
</ins><span class="cx">         {
</span><del>-            IndexBuffer11* indexBuffer = IndexBuffer11::makeIndexBuffer11(indexInfo-&gt;indexBuffer);
</del><ins>+            buffer = indexBuffer-&gt;getBuffer();
+        }
</ins><span class="cx"> 
</span><del>-            mDeviceContext-&gt;IASetIndexBuffer(indexBuffer-&gt;getBuffer(), indexBuffer-&gt;getIndexFormat(), indexInfo-&gt;startOffset);
</del><ins>+        if (buffer != mAppliedIB || bufferFormat != mAppliedIBFormat || indexInfo-&gt;startOffset != mAppliedIBOffset)
+        {
+            mDeviceContext-&gt;IASetIndexBuffer(buffer, bufferFormat, indexInfo-&gt;startOffset);
</ins><span class="cx"> 
</span><del>-            mAppliedIBSerial = indexInfo-&gt;serial;
-            mAppliedStorageIBSerial = 0;
</del><ins>+            mAppliedIB = buffer;
+            mAppliedIBFormat = bufferFormat;
</ins><span class="cx">             mAppliedIBOffset = indexInfo-&gt;startOffset;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -1121,10 +1175,80 @@
</span><span class="cx">     return err;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer11::drawArrays(GLenum mode, GLsizei count, GLsizei instances)
</del><ins>+void Renderer11::applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[])
</ins><span class="cx"> {
</span><del>-    if (mode == GL_LINE_LOOP)
</del><ins>+    ID3D11Buffer* d3dBuffers[gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
+    UINT d3dOffsets[gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
+    bool requiresUpdate = false;
+    for (size_t i = 0; i &lt; gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
</ins><span class="cx">     {
</span><ins>+        if (transformFeedbackBuffers[i])
+        {
+            BufferStorage11 *storage = BufferStorage11::makeBufferStorage11(transformFeedbackBuffers[i]-&gt;getStorage());
+            ID3D11Buffer *buffer = storage-&gt;getBuffer(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK);
+
+            d3dBuffers[i] = buffer;
+            d3dOffsets[i] = (mAppliedTFBuffers[i] != buffer) ? static_cast&lt;UINT&gt;(offsets[i]) : -1;
+        }
+        else
+        {
+            d3dBuffers[i] = NULL;
+            d3dOffsets[i] = 0;
+        }
+
+        if (d3dBuffers[i] != mAppliedTFBuffers[i] || offsets[i] != mAppliedTFOffsets[i])
+        {
+            requiresUpdate = true;
+        }
+    }
+
+    if (requiresUpdate)
+    {
+        mDeviceContext-&gt;SOSetTargets(ArraySize(d3dBuffers), d3dBuffers, d3dOffsets);
+        for (size_t i = 0; i &lt; gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
+        {
+            mAppliedTFBuffers[i] = d3dBuffers[i];
+            mAppliedTFOffsets[i] = offsets[i];
+        }
+    }
+}
+
+void Renderer11::drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive)
+{
+    if (mode == GL_POINTS &amp;&amp; transformFeedbackActive)
+    {
+        // Since point sprites are generated with a geometry shader, too many vertices will
+        // be written if transform feedback is active.  To work around this, draw only the points
+        // with the stream out shader and no pixel shader to feed the stream out buffers and then 
+        // draw again with the point sprite geometry shader to rasterize the point sprites.
+
+        mDeviceContext-&gt;PSSetShader(NULL, NULL, 0);
+
+        if (instances &gt; 0)
+        {
+            mDeviceContext-&gt;DrawInstanced(count, instances, 0, 0);
+        }
+        else
+        {
+            mDeviceContext-&gt;Draw(count, 0);
+        }
+
+        mDeviceContext-&gt;GSSetShader(mCurPointGeometryShader, NULL, 0);
+        mDeviceContext-&gt;PSSetShader(mAppliedPixelShader, NULL, 0);
+
+        if (instances &gt; 0)
+        {
+            mDeviceContext-&gt;DrawInstanced(count, instances, 0, 0);
+        }
+        else
+        {
+            mDeviceContext-&gt;Draw(count, 0);
+        }
+
+        mDeviceContext-&gt;GSSetShader(mAppliedGeometryShader, NULL, 0);
+    }
+    else if (mode == GL_LINE_LOOP)
+    {
</ins><span class="cx">         drawLineLoop(count, GL_NONE, NULL, 0, NULL);
</span><span class="cx">     }
</span><span class="cx">     else if (mode == GL_TRIANGLE_FAN)
</span><span class="lines">@@ -1141,7 +1265,8 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer11::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei instances)
</del><ins>+void Renderer11::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
+                              gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei instances)
</ins><span class="cx"> {
</span><span class="cx">     if (mode == GL_LINE_LOOP)
</span><span class="cx">     {
</span><span class="lines">@@ -1251,13 +1376,15 @@
</span><span class="cx">         return gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mAppliedIBSerial != mLineLoopIB-&gt;getSerial() || mAppliedIBOffset != indexBufferOffset)
</del><ins>+    IndexBuffer11 *indexBuffer = IndexBuffer11::makeIndexBuffer11(mLineLoopIB-&gt;getIndexBuffer());
+    ID3D11Buffer *d3dIndexBuffer = indexBuffer-&gt;getBuffer();
+    DXGI_FORMAT indexFormat = indexBuffer-&gt;getIndexFormat();
+
+    if (mAppliedIB != d3dIndexBuffer || mAppliedIBFormat != indexFormat || mAppliedIBOffset != indexBufferOffset)
</ins><span class="cx">     {
</span><del>-        IndexBuffer11 *indexBuffer = IndexBuffer11::makeIndexBuffer11(mLineLoopIB-&gt;getIndexBuffer());
-
</del><span class="cx">         mDeviceContext-&gt;IASetIndexBuffer(indexBuffer-&gt;getBuffer(), indexBuffer-&gt;getIndexFormat(), indexBufferOffset);
</span><del>-        mAppliedIBSerial = mLineLoopIB-&gt;getSerial();
-        mAppliedStorageIBSerial = 0;
</del><ins>+        mAppliedIB = d3dIndexBuffer;
+        mAppliedIBFormat = indexFormat;
</ins><span class="cx">         mAppliedIBOffset = indexBufferOffset;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1360,13 +1487,15 @@
</span><span class="cx">         return gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mAppliedIBSerial != mTriangleFanIB-&gt;getSerial() || mAppliedIBOffset != indexBufferOffset)
</del><ins>+    IndexBuffer11 *indexBuffer = IndexBuffer11::makeIndexBuffer11(mTriangleFanIB-&gt;getIndexBuffer());
+    ID3D11Buffer *d3dIndexBuffer = indexBuffer-&gt;getBuffer();
+    DXGI_FORMAT indexFormat = indexBuffer-&gt;getIndexFormat();
+
+    if (mAppliedIB != d3dIndexBuffer || mAppliedIBFormat != indexFormat || mAppliedIBOffset != indexBufferOffset)
</ins><span class="cx">     {
</span><del>-        IndexBuffer11 *indexBuffer = IndexBuffer11::makeIndexBuffer11(mTriangleFanIB-&gt;getIndexBuffer());
-
</del><span class="cx">         mDeviceContext-&gt;IASetIndexBuffer(indexBuffer-&gt;getBuffer(), indexBuffer-&gt;getIndexFormat(), indexBufferOffset);
</span><del>-        mAppliedIBSerial = mTriangleFanIB-&gt;getSerial();
-        mAppliedStorageIBSerial = 0;
</del><ins>+        mAppliedIB = d3dIndexBuffer;
+        mAppliedIBFormat = indexFormat;
</ins><span class="cx">         mAppliedIBOffset = indexBufferOffset;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1380,54 +1509,72 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer11::applyShaders(gl::ProgramBinary *programBinary)
</del><ins>+void Renderer11::applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[])
</ins><span class="cx"> {
</span><del>-    unsigned int programBinarySerial = programBinary-&gt;getSerial();
-    const bool updateProgramState = (programBinarySerial != mAppliedProgramBinarySerial);
</del><ins>+    ShaderExecutable *vertexExe = programBinary-&gt;getVertexExecutableForInputLayout(inputLayout);
+    ShaderExecutable *pixelExe = programBinary-&gt;getPixelExecutable();
+    ShaderExecutable *geometryExe = programBinary-&gt;getGeometryExecutable();
</ins><span class="cx"> 
</span><del>-    if (updateProgramState)
</del><ins>+    ID3D11VertexShader *vertexShader = (vertexExe ? ShaderExecutable11::makeShaderExecutable11(vertexExe)-&gt;getVertexShader() : NULL);
+
+    ID3D11PixelShader *pixelShader = NULL;
+    // Skip pixel shader if we're doing rasterizer discard.
+    if (!rasterizerDiscard)
</ins><span class="cx">     {
</span><del>-        ShaderExecutable *vertexExe = programBinary-&gt;getVertexExecutable();
-        ShaderExecutable *pixelExe = programBinary-&gt;getPixelExecutable();
</del><ins>+        pixelShader = (pixelExe ? ShaderExecutable11::makeShaderExecutable11(pixelExe)-&gt;getPixelShader() : NULL);
+    }
</ins><span class="cx"> 
</span><del>-        ID3D11VertexShader *vertexShader = NULL;
-        if (vertexExe) vertexShader = ShaderExecutable11::makeShaderExecutable11(vertexExe)-&gt;getVertexShader();
</del><ins>+    ID3D11GeometryShader *geometryShader = NULL;
+    if (transformFeedbackActive)
+    {
+        geometryShader = (vertexExe ? ShaderExecutable11::makeShaderExecutable11(vertexExe)-&gt;getStreamOutShader() : NULL);
+    }
+    else if (mCurRasterState.pointDrawMode)
+    {
+        geometryShader = (geometryExe ? ShaderExecutable11::makeShaderExecutable11(geometryExe)-&gt;getGeometryShader() : NULL);
+    }
</ins><span class="cx"> 
</span><del>-        ID3D11PixelShader *pixelShader = NULL;
-        if (pixelExe) pixelShader = ShaderExecutable11::makeShaderExecutable11(pixelExe)-&gt;getPixelShader();
</del><ins>+    bool dirtyUniforms = false;
</ins><span class="cx"> 
</span><del>-        mDeviceContext-&gt;PSSetShader(pixelShader, NULL, 0);
</del><ins>+    if (vertexShader != mAppliedVertexShader)
+    {
</ins><span class="cx">         mDeviceContext-&gt;VSSetShader(vertexShader, NULL, 0);
</span><ins>+        mAppliedVertexShader = vertexShader;
+        dirtyUniforms = true;
+    }
</ins><span class="cx"> 
</span><del>-        programBinary-&gt;dirtyAllUniforms();
</del><ins>+    if (geometryShader != mAppliedGeometryShader)
+    {
+        mDeviceContext-&gt;GSSetShader(geometryShader, NULL, 0);
+        mAppliedGeometryShader = geometryShader;
+        dirtyUniforms = true;
+    }
</ins><span class="cx"> 
</span><del>-        mAppliedProgramBinarySerial = programBinarySerial;
</del><ins>+    if (geometryExe &amp;&amp; mCurRasterState.pointDrawMode)
+    {
+        mCurPointGeometryShader = ShaderExecutable11::makeShaderExecutable11(geometryExe)-&gt;getGeometryShader();
</ins><span class="cx">     }
</span><ins>+    else
+    {
+        mCurPointGeometryShader = NULL;
+    }
</ins><span class="cx"> 
</span><del>-    // Only use the geometry shader currently for point sprite drawing
-    const bool usesGeometryShader = (programBinary-&gt;usesGeometryShader() &amp;&amp; mCurRasterState.pointDrawMode);
</del><ins>+    if (pixelShader != mAppliedPixelShader)
+    {
+        mDeviceContext-&gt;PSSetShader(pixelShader, NULL, 0);
+        mAppliedPixelShader = pixelShader;
+        dirtyUniforms = true;
+    }
</ins><span class="cx"> 
</span><del>-    if (updateProgramState || usesGeometryShader != mIsGeometryShaderActive)
</del><ins>+    if (dirtyUniforms)
</ins><span class="cx">     {
</span><del>-        if (usesGeometryShader)
-        {
-            ShaderExecutable *geometryExe = programBinary-&gt;getGeometryExecutable();
-            ID3D11GeometryShader *geometryShader = ShaderExecutable11::makeShaderExecutable11(geometryExe)-&gt;getGeometryShader();
-            mDeviceContext-&gt;GSSetShader(geometryShader, NULL, 0);
-        }
-        else
-        {
-            mDeviceContext-&gt;GSSetShader(NULL, NULL, 0);
-        }
-
-        mIsGeometryShaderActive = usesGeometryShader;
</del><ins>+        programBinary-&gt;dirtyAllUniforms();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray *uniformArray)
</del><ins>+void Renderer11::applyUniforms(const gl::ProgramBinary &amp;programBinary)
</ins><span class="cx"> {
</span><del>-    ShaderExecutable11 *vertexExecutable = ShaderExecutable11::makeShaderExecutable11(programBinary-&gt;getVertexExecutable());
-    ShaderExecutable11 *pixelExecutable = ShaderExecutable11::makeShaderExecutable11(programBinary-&gt;getPixelExecutable());
</del><ins>+    const std::vector&lt;gl::LinkedUniform*&gt; &amp;uniformArray = programBinary.getUniforms();
</ins><span class="cx"> 
</span><span class="cx">     unsigned int totalRegisterCountVS = 0;
</span><span class="cx">     unsigned int totalRegisterCountPS = 0;
</span><span class="lines">@@ -1435,26 +1582,31 @@
</span><span class="cx">     bool vertexUniformsDirty = false;
</span><span class="cx">     bool pixelUniformsDirty = false;
</span><span class="cx"> 
</span><del>-    for (gl::UniformArray::const_iterator uniform_iterator = uniformArray-&gt;begin(); uniform_iterator != uniformArray-&gt;end(); uniform_iterator++)
</del><ins>+    for (size_t uniformIndex = 0; uniformIndex &lt; uniformArray.size(); uniformIndex++)
</ins><span class="cx">     {
</span><del>-        const gl::Uniform *uniform = *uniform_iterator;
</del><ins>+        const gl::LinkedUniform &amp;uniform = *uniformArray[uniformIndex];
</ins><span class="cx"> 
</span><del>-        if (uniform-&gt;vsRegisterIndex &gt;= 0)
</del><ins>+        if (uniform.isReferencedByVertexShader() &amp;&amp; !uniform.isSampler())
</ins><span class="cx">         {
</span><del>-            totalRegisterCountVS += uniform-&gt;registerCount;
-            vertexUniformsDirty = vertexUniformsDirty || uniform-&gt;dirty;
</del><ins>+            totalRegisterCountVS += uniform.registerCount;
+            vertexUniformsDirty = (vertexUniformsDirty || uniform.dirty);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (uniform-&gt;psRegisterIndex &gt;= 0)
</del><ins>+        if (uniform.isReferencedByFragmentShader() &amp;&amp; !uniform.isSampler())
</ins><span class="cx">         {
</span><del>-            totalRegisterCountPS += uniform-&gt;registerCount;
-            pixelUniformsDirty = pixelUniformsDirty || uniform-&gt;dirty;
</del><ins>+            totalRegisterCountPS += uniform.registerCount;
+            pixelUniformsDirty = (pixelUniformsDirty || uniform.dirty);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ID3D11Buffer *vertexConstantBuffer = vertexExecutable-&gt;getConstantBuffer(mDevice, totalRegisterCountVS);
-    ID3D11Buffer *pixelConstantBuffer = pixelExecutable-&gt;getConstantBuffer(mDevice, totalRegisterCountPS);
</del><ins>+    const UniformStorage11 *vertexUniformStorage = UniformStorage11::makeUniformStorage11(&amp;programBinary.getVertexUniformStorage());
+    const UniformStorage11 *fragmentUniformStorage = UniformStorage11::makeUniformStorage11(&amp;programBinary.getFragmentUniformStorage());
+    ASSERT(vertexUniformStorage);
+    ASSERT(fragmentUniformStorage);
</ins><span class="cx"> 
</span><ins>+    ID3D11Buffer *vertexConstantBuffer = vertexUniformStorage-&gt;getConstantBuffer();
+    ID3D11Buffer *pixelConstantBuffer = fragmentUniformStorage-&gt;getConstantBuffer();
+
</ins><span class="cx">     float (*mapVS)[4] = NULL;
</span><span class="cx">     float (*mapPS)[4] = NULL;
</span><span class="cx"> 
</span><span class="lines">@@ -1474,24 +1626,27 @@
</span><span class="cx">         mapPS = (float(*)[4])map.pData;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (gl::UniformArray::iterator uniform_iterator = uniformArray-&gt;begin(); uniform_iterator != uniformArray-&gt;end(); uniform_iterator++)
</del><ins>+    for (size_t uniformIndex = 0; uniformIndex &lt; uniformArray.size(); uniformIndex++)
</ins><span class="cx">     {
</span><del>-        gl::Uniform *uniform = *uniform_iterator;
</del><ins>+        gl::LinkedUniform *uniform = uniformArray[uniformIndex];
</ins><span class="cx"> 
</span><del>-        if (uniform-&gt;type !=  GL_SAMPLER_2D &amp;&amp; uniform-&gt;type != GL_SAMPLER_CUBE)
</del><ins>+        if (!uniform-&gt;isSampler())
</ins><span class="cx">         {
</span><del>-            if (uniform-&gt;vsRegisterIndex &gt;= 0 &amp;&amp; mapVS)
</del><ins>+            unsigned int componentCount = (4 - uniform-&gt;registerElement);
+
+            // we assume that uniforms from structs are arranged in struct order in our uniforms list. otherwise we would
+            // overwrite previously written regions of memory.
+
+            if (uniform-&gt;isReferencedByVertexShader() &amp;&amp; mapVS)
</ins><span class="cx">             {
</span><del>-                memcpy(mapVS + uniform-&gt;vsRegisterIndex, uniform-&gt;data, uniform-&gt;registerCount * sizeof(float[4]));
</del><ins>+                memcpy(&amp;mapVS[uniform-&gt;vsRegisterIndex][uniform-&gt;registerElement], uniform-&gt;data, uniform-&gt;registerCount * sizeof(float) * componentCount);
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (uniform-&gt;psRegisterIndex &gt;= 0 &amp;&amp; mapPS)
</del><ins>+            if (uniform-&gt;isReferencedByFragmentShader() &amp;&amp; mapPS)
</ins><span class="cx">             {
</span><del>-                memcpy(mapPS + uniform-&gt;psRegisterIndex, uniform-&gt;data, uniform-&gt;registerCount * sizeof(float[4]));
</del><ins>+                memcpy(&amp;mapPS[uniform-&gt;psRegisterIndex][uniform-&gt;registerElement], uniform-&gt;data, uniform-&gt;registerCount * sizeof(float) * componentCount);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><del>-
-        uniform-&gt;dirty = false;
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (mapVS)
</span><span class="lines">@@ -1571,273 +1726,10 @@
</span><span class="cx"> 
</span><span class="cx"> void Renderer11::clear(const gl::ClearParameters &amp;clearParams, gl::Framebuffer *frameBuffer)
</span><span class="cx"> {
</span><del>-     gl::Renderbuffer *firstRenderbuffer = frameBuffer-&gt;getFirstColorbuffer();
-     GLenum internalFormat = firstRenderbuffer ? firstRenderbuffer-&gt;getInternalFormat() : GL_NONE;
-
-     bool needMaskedColorClear = (clearParams.mask &amp; GL_COLOR_BUFFER_BIT) &amp;&amp;
-                                 ((!clearParams.colorMaskRed &amp;&amp; gl::GetRedSize(internalFormat) &gt; 0) ||
-                                  (!clearParams.colorMaskGreen &amp;&amp; gl::GetGreenSize(internalFormat) &gt; 0) ||
-                                  (!clearParams.colorMaskBlue &amp;&amp; gl::GetBlueSize(internalFormat) &gt; 0) ||
-                                  (!clearParams.colorMaskAlpha &amp;&amp; gl::GetAlphaSize(internalFormat) &gt; 0));
-
-     unsigned int stencilUnmasked = 0x0;
-     if (frameBuffer-&gt;hasStencil())
-     {
-         unsigned int stencilSize = gl::GetStencilSize(frameBuffer-&gt;getStencilbuffer()-&gt;getActualFormat());
-         stencilUnmasked = (0x1 &lt;&lt; stencilSize) - 1;
-     }
-     bool needMaskedStencilClear = (clearParams.mask &amp; GL_STENCIL_BUFFER_BIT) &amp;&amp;
-                                   (clearParams.stencilWriteMask &amp; stencilUnmasked) != stencilUnmasked;
-
-     bool needScissoredClear = mScissorEnabled &amp;&amp; (mCurScissor.x &gt; 0 || mCurScissor.y &gt; 0 ||
-                                                   mCurScissor.x + mCurScissor.width &lt; mRenderTargetDesc.width ||
-                                                   mCurScissor.y + mCurScissor.height &lt; mRenderTargetDesc.height);
-
-     if (needMaskedColorClear || needMaskedStencilClear || needScissoredClear)
-     {
-         maskedClear(clearParams, frameBuffer);
-     }
-     else
-     {
-         if (clearParams.mask &amp; GL_COLOR_BUFFER_BIT)
-         {
-             for (unsigned int colorAttachment = 0; colorAttachment &lt; gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
-             {
-                 if (frameBuffer-&gt;isEnabledColorAttachment(colorAttachment))
-                 {
-                     gl::Renderbuffer *renderbufferObject = frameBuffer-&gt;getColorbuffer(colorAttachment);
-                     if (renderbufferObject)
-                     {
-                        RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbufferObject-&gt;getRenderTarget());
-                        if (!renderTarget)
-                        {
-                            ERR(&quot;render target pointer unexpectedly null.&quot;);
-                            return;
-                        }
-
-                        ID3D11RenderTargetView *framebufferRTV = renderTarget-&gt;getRenderTargetView();
-                        if (!framebufferRTV)
-                        {
-                            ERR(&quot;render target view pointer unexpectedly null.&quot;);
-                            return;
-                        }
-
-                        GLenum format = renderbufferObject-&gt;getInternalFormat();
-
-                        const float clearValues[4] = { (gl::GetRedSize(format) &gt; 0)   ? clearParams.colorClearValue.red   : 0.0f,
-                                                       (gl::GetGreenSize(format) &gt; 0) ? clearParams.colorClearValue.green : 0.0f,
-                                                       (gl::GetBlueSize(format) &gt; 0)  ? clearParams.colorClearValue.blue  : 0.0f,
-                                                       (gl::GetAlphaSize(format) &gt; 0) ? clearParams.colorClearValue.alpha : 1.0f };
-                        mDeviceContext-&gt;ClearRenderTargetView(framebufferRTV, clearValues);
-                    }
-                 }
-             }
-        }
-        if (clearParams.mask &amp; GL_DEPTH_BUFFER_BIT || clearParams.mask &amp; GL_STENCIL_BUFFER_BIT)
-        {
-            gl::Renderbuffer *renderbufferObject = frameBuffer-&gt;getDepthOrStencilbuffer();
-            if (renderbufferObject)
-            {
-                RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbufferObject-&gt;getDepthStencil());
-                if (!renderTarget)
-                {
-                    ERR(&quot;render target pointer unexpectedly null.&quot;);
-                    return;
-                }
-
-                ID3D11DepthStencilView *framebufferDSV = renderTarget-&gt;getDepthStencilView();
-                if (!framebufferDSV)
-                {
-                    ERR(&quot;depth stencil view pointer unexpectedly null.&quot;);
-                    return;
-                }
-
-                UINT clearFlags = 0;
-                if (clearParams.mask &amp; GL_DEPTH_BUFFER_BIT)
-                {
-                    clearFlags |= D3D11_CLEAR_DEPTH;
-                }
-                if (clearParams.mask &amp; GL_STENCIL_BUFFER_BIT)
-                {
-                    clearFlags |= D3D11_CLEAR_STENCIL;
-                }
-
-                float depthClear = gl::clamp01(clearParams.depthClearValue);
-                UINT8 stencilClear = clearParams.stencilClearValue &amp; 0x000000FF;
-
-                mDeviceContext-&gt;ClearDepthStencilView(framebufferDSV, clearFlags, depthClear, stencilClear);
-            }
-        }
-    }
</del><ins>+    mClear-&gt;clearFramebuffer(clearParams, frameBuffer);
+    invalidateFramebufferSwizzles(frameBuffer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer11::maskedClear(const gl::ClearParameters &amp;clearParams, gl::Framebuffer *frameBuffer)
-{
-    HRESULT result;
-
-    if (!mClearResourcesInitialized)
-    {
-        ASSERT(!mClearVB &amp;&amp; !mClearVS &amp;&amp; !mClearSinglePS &amp;&amp; !mClearMultiplePS &amp;&amp; !mClearScissorRS &amp;&amp; !mClearNoScissorRS);
-
-        D3D11_BUFFER_DESC vbDesc;
-        vbDesc.ByteWidth = sizeof(d3d11::PositionDepthColorVertex) * 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 = mDevice-&gt;CreateBuffer(&amp;vbDesc, NULL, &amp;mClearVB);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mClearVB, &quot;Renderer11 masked clear vertex buffer&quot;);
-
-        D3D11_INPUT_ELEMENT_DESC quadLayout[] =
-        {
-            { &quot;POSITION&quot;, 0, DXGI_FORMAT_R32G32B32_FLOAT,    0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
-            { &quot;COLOR&quot;,    0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
-        };
-
-        result = mDevice-&gt;CreateInputLayout(quadLayout, 2, g_VS_Clear, sizeof(g_VS_Clear), &amp;mClearIL);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mClearIL, &quot;Renderer11 masked clear input layout&quot;);
-
-        result = mDevice-&gt;CreateVertexShader(g_VS_Clear, sizeof(g_VS_Clear), NULL, &amp;mClearVS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mClearVS, &quot;Renderer11 masked clear vertex shader&quot;);
-
-        result = mDevice-&gt;CreatePixelShader(g_PS_ClearSingle, sizeof(g_PS_ClearSingle), NULL, &amp;mClearSinglePS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mClearSinglePS, &quot;Renderer11 masked clear pixel shader (1 RT)&quot;);
-
-        result = mDevice-&gt;CreatePixelShader(g_PS_ClearMultiple, sizeof(g_PS_ClearMultiple), NULL, &amp;mClearMultiplePS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mClearMultiplePS, &quot;Renderer11 masked clear pixel shader (MRT)&quot;);
-
-        D3D11_RASTERIZER_DESC rsScissorDesc;
-        rsScissorDesc.FillMode = D3D11_FILL_SOLID;
-        rsScissorDesc.CullMode = D3D11_CULL_NONE;
-        rsScissorDesc.FrontCounterClockwise = FALSE;
-        rsScissorDesc.DepthBias = 0;
-        rsScissorDesc.DepthBiasClamp = 0.0f;
-        rsScissorDesc.SlopeScaledDepthBias = 0.0f;
-        rsScissorDesc.DepthClipEnable = FALSE;
-        rsScissorDesc.ScissorEnable = TRUE;
-        rsScissorDesc.MultisampleEnable = FALSE;
-        rsScissorDesc.AntialiasedLineEnable = FALSE;
-
-        result = mDevice-&gt;CreateRasterizerState(&amp;rsScissorDesc, &amp;mClearScissorRS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mClearScissorRS, &quot;Renderer11 masked clear scissor rasterizer state&quot;);
-
-        D3D11_RASTERIZER_DESC rsNoScissorDesc;
-        rsNoScissorDesc.FillMode = D3D11_FILL_SOLID;
-        rsNoScissorDesc.CullMode = D3D11_CULL_NONE;
-        rsNoScissorDesc.FrontCounterClockwise = FALSE;
-        rsNoScissorDesc.DepthBias = 0;
-        rsNoScissorDesc.DepthBiasClamp = 0.0f;
-        rsNoScissorDesc.SlopeScaledDepthBias = 0.0f;
-        rsNoScissorDesc.DepthClipEnable = FALSE;
-        rsNoScissorDesc.ScissorEnable = FALSE;
-        rsNoScissorDesc.MultisampleEnable = FALSE;
-        rsNoScissorDesc.AntialiasedLineEnable = FALSE;
-
-        result = mDevice-&gt;CreateRasterizerState(&amp;rsNoScissorDesc, &amp;mClearNoScissorRS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mClearNoScissorRS, &quot;Renderer11 masked clear no scissor rasterizer state&quot;);
-
-        mClearResourcesInitialized = true;
-    }
-
-    // Prepare the depth stencil state to write depth values if the depth should be cleared
-    // and stencil values if the stencil should be cleared
-    gl::DepthStencilState glDSState;
-    glDSState.depthTest = (clearParams.mask &amp; GL_DEPTH_BUFFER_BIT) != 0;
-    glDSState.depthFunc = GL_ALWAYS;
-    glDSState.depthMask = (clearParams.mask &amp; GL_DEPTH_BUFFER_BIT) != 0;
-    glDSState.stencilTest = (clearParams.mask &amp; GL_STENCIL_BUFFER_BIT) != 0;
-    glDSState.stencilFunc = GL_ALWAYS;
-    glDSState.stencilMask = 0;
-    glDSState.stencilFail = GL_REPLACE;
-    glDSState.stencilPassDepthFail = GL_REPLACE;
-    glDSState.stencilPassDepthPass = GL_REPLACE;
-    glDSState.stencilWritemask = clearParams.stencilWriteMask;
-    glDSState.stencilBackFunc = GL_ALWAYS;
-    glDSState.stencilBackMask = 0;
-    glDSState.stencilBackFail = GL_REPLACE;
-    glDSState.stencilBackPassDepthFail = GL_REPLACE;
-    glDSState.stencilBackPassDepthPass = GL_REPLACE;
-    glDSState.stencilBackWritemask = clearParams.stencilWriteMask;
-
-    int stencilClear = clearParams.stencilClearValue &amp; 0x000000FF;
-
-    ID3D11DepthStencilState *dsState = mStateCache.getDepthStencilState(glDSState);
-
-    // Prepare the blend state to use a write mask if the color buffer should be cleared
-    gl::BlendState glBlendState;
-    glBlendState.blend = false;
-    glBlendState.sourceBlendRGB = GL_ONE;
-    glBlendState.destBlendRGB = GL_ZERO;
-    glBlendState.sourceBlendAlpha = GL_ONE;
-    glBlendState.destBlendAlpha = GL_ZERO;
-    glBlendState.blendEquationRGB = GL_FUNC_ADD;
-    glBlendState.blendEquationAlpha = GL_FUNC_ADD;
-    glBlendState.colorMaskRed = (clearParams.mask &amp; GL_COLOR_BUFFER_BIT) ? clearParams.colorMaskRed : false;
-    glBlendState.colorMaskGreen = (clearParams.mask &amp; GL_COLOR_BUFFER_BIT) ? clearParams.colorMaskGreen : false;
-    glBlendState.colorMaskBlue = (clearParams.mask &amp; GL_COLOR_BUFFER_BIT) ? clearParams.colorMaskBlue : false;
-    glBlendState.colorMaskAlpha = (clearParams.mask &amp; GL_COLOR_BUFFER_BIT) ? clearParams.colorMaskAlpha : false;
-    glBlendState.sampleAlphaToCoverage = false;
-    glBlendState.dither = false;
-
-    static const float blendFactors[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
-    static const UINT sampleMask = 0xFFFFFFFF;
-
-    ID3D11BlendState *blendState = mStateCache.getBlendState(frameBuffer, glBlendState);
-
-    // Set the vertices
-    D3D11_MAPPED_SUBRESOURCE mappedResource;
-    result = mDeviceContext-&gt;Map(mClearVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &amp;mappedResource);
-    if (FAILED(result))
-    {
-        ERR(&quot;Failed to map masked clear vertex buffer, HRESULT: 0x%X.&quot;, result);
-        return;
-    }
-
-    d3d11::PositionDepthColorVertex *vertices = reinterpret_cast&lt;d3d11::PositionDepthColorVertex*&gt;(mappedResource.pData);
-
-    float depthClear = gl::clamp01(clearParams.depthClearValue);
-    d3d11::SetPositionDepthColorVertex(&amp;vertices[0], -1.0f,  1.0f, depthClear, clearParams.colorClearValue);
-    d3d11::SetPositionDepthColorVertex(&amp;vertices[1], -1.0f, -1.0f, depthClear, clearParams.colorClearValue);
-    d3d11::SetPositionDepthColorVertex(&amp;vertices[2],  1.0f,  1.0f, depthClear, clearParams.colorClearValue);
-    d3d11::SetPositionDepthColorVertex(&amp;vertices[3],  1.0f, -1.0f, depthClear, clearParams.colorClearValue);
-
-    mDeviceContext-&gt;Unmap(mClearVB, 0);
-
-    // Apply state
-    mDeviceContext-&gt;OMSetBlendState(blendState, blendFactors, sampleMask);
-    mDeviceContext-&gt;OMSetDepthStencilState(dsState, stencilClear);
-    mDeviceContext-&gt;RSSetState(mScissorEnabled ? mClearScissorRS : mClearNoScissorRS);
-
-    // Apply shaders
-    ID3D11PixelShader *pixelShader = frameBuffer-&gt;usingExtendedDrawBuffers() ? mClearMultiplePS : mClearSinglePS;
-
-    mDeviceContext-&gt;IASetInputLayout(mClearIL);
-    mDeviceContext-&gt;VSSetShader(mClearVS, NULL, 0);
-    mDeviceContext-&gt;PSSetShader(pixelShader, NULL, 0);
-    mDeviceContext-&gt;GSSetShader(NULL, NULL, 0);
-
-    // Apply vertex buffer
-    static UINT stride = sizeof(d3d11::PositionDepthColorVertex);
-    static UINT startIdx = 0;
-    mDeviceContext-&gt;IASetVertexBuffers(0, 1, &amp;mClearVB, &amp;stride, &amp;startIdx);
-    mDeviceContext-&gt;IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-
-    // Draw the clear quad
-    mDeviceContext-&gt;Draw(4, 0);
-
-    // Clean up
-    markAllStateDirty();
-}
-
</del><span class="cx"> void Renderer11::markAllStateDirty()
</span><span class="cx"> {
</span><span class="cx">     for (unsigned int rtIndex = 0; rtIndex &lt; gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++)
</span><span class="lines">@@ -1852,12 +1744,12 @@
</span><span class="cx">     for (int i = 0; i &lt; gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; i++)
</span><span class="cx">     {
</span><span class="cx">         mForceSetVertexSamplerStates[i] = true;
</span><del>-        mCurVertexTextureSerials[i] = 0;
</del><ins>+        mCurVertexSRVs[i] = NULL;
</ins><span class="cx">     }
</span><span class="cx">     for (int i = 0; i &lt; gl::MAX_TEXTURE_IMAGE_UNITS; i++)
</span><span class="cx">     {
</span><span class="cx">         mForceSetPixelSamplerStates[i] = true;
</span><del>-        mCurPixelTextureSerials[i] = 0;
</del><ins>+        mCurPixelSRVs[i] = NULL;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     mForceSetBlendState = true;
</span><span class="lines">@@ -1866,16 +1758,32 @@
</span><span class="cx">     mForceSetScissor = true;
</span><span class="cx">     mForceSetViewport = true;
</span><span class="cx"> 
</span><del>-    mAppliedIBSerial = 0;
-    mAppliedStorageIBSerial = 0;
</del><ins>+    mAppliedIB = NULL;
+    mAppliedIBFormat = DXGI_FORMAT_UNKNOWN;
</ins><span class="cx">     mAppliedIBOffset = 0;
</span><span class="cx"> 
</span><del>-    mAppliedProgramBinarySerial = 0;
</del><ins>+    mAppliedVertexShader = NULL;
+    mAppliedGeometryShader = NULL;
+    mCurPointGeometryShader = NULL;
+    mAppliedPixelShader = NULL;
+
+    for (size_t i = 0; i &lt; gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
+    {
+        mAppliedTFBuffers[i] = NULL;
+        mAppliedTFOffsets[i] = 0;
+    }
+
</ins><span class="cx">     memset(&amp;mAppliedVertexConstants, 0, sizeof(dx_VertexConstants));
</span><span class="cx">     memset(&amp;mAppliedPixelConstants, 0, sizeof(dx_PixelConstants));
</span><span class="cx"> 
</span><span class="cx">     mInputLayoutCache.markDirty();
</span><span class="cx"> 
</span><ins>+    for (unsigned int i = 0; i &lt; gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS; i++)
+    {
+        mCurrentConstantBufferVS[i] = -1;
+        mCurrentConstantBufferPS[i] = -1;
+    }
+
</ins><span class="cx">     mCurrentVertexConstantBuffer = NULL;
</span><span class="cx">     mCurrentPixelConstantBuffer = NULL;
</span><span class="cx">     mCurrentGeometryConstantBuffer = NULL;
</span><span class="lines">@@ -1888,40 +1796,14 @@
</span><span class="cx">     mStateCache.clear();
</span><span class="cx">     mInputLayoutCache.clear();
</span><span class="cx"> 
</span><del>-    delete mVertexDataManager;
-    mVertexDataManager = NULL;
</del><ins>+    SafeDelete(mVertexDataManager);
+    SafeDelete(mIndexDataManager);
+    SafeDelete(mLineLoopIB);
+    SafeDelete(mTriangleFanIB);
+    SafeDelete(mBlit);
+    SafeDelete(mClear);
+    SafeDelete(mPixelTransfer);
</ins><span class="cx"> 
</span><del>-    delete mIndexDataManager;
-    mIndexDataManager = NULL;
-
-    delete mLineLoopIB;
-    mLineLoopIB = NULL;
-
-    delete mTriangleFanIB;
-    mTriangleFanIB = NULL;
-
-    SafeRelease(mCopyVB);
-    SafeRelease(mCopySampler);
-    SafeRelease(mCopyIL);
-    SafeRelease(mCopyIL);
-    SafeRelease(mCopyVS);
-    SafeRelease(mCopyRGBAPS);
-    SafeRelease(mCopyRGBPS);
-    SafeRelease(mCopyLumPS);
-    SafeRelease(mCopyLumAlphaPS);
-
-    mCopyResourcesInitialized = false;
-
-    SafeRelease(mClearVB);
-    SafeRelease(mClearIL);
-    SafeRelease(mClearVS);
-    SafeRelease(mClearSinglePS);
-    SafeRelease(mClearMultiplePS);
-    SafeRelease(mClearScissorRS);
-    SafeRelease(mClearNoScissorRS);
-
-    mClearResourcesInitialized = false;
-
</del><span class="cx">     SafeRelease(mDriverConstantBufferVS);
</span><span class="cx">     SafeRelease(mDriverConstantBufferPS);
</span><span class="cx">     SafeRelease(mSyncQuery);
</span><span class="lines">@@ -2011,8 +1893,8 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    dummyContext-&gt;Release();
-    dummyDevice-&gt;Release();
</del><ins>+    SafeRelease(dummyContext);
+    SafeRelease(dummyDevice);
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -2021,31 +1903,17 @@
</span><span class="cx"> {
</span><span class="cx">     releaseDeviceResources();
</span><span class="cx"> 
</span><del>-    if (mDxgiFactory)
-    {
-        mDxgiFactory-&gt;Release();
-        mDxgiFactory = NULL;
-    }
</del><ins>+    SafeRelease(mDxgiFactory);
+    SafeRelease(mDxgiAdapter);
</ins><span class="cx"> 
</span><del>-    if (mDxgiAdapter)
-    {
-        mDxgiAdapter-&gt;Release();
-        mDxgiAdapter = NULL;
-    }
-
</del><span class="cx">     if (mDeviceContext)
</span><span class="cx">     {
</span><span class="cx">         mDeviceContext-&gt;ClearState();
</span><span class="cx">         mDeviceContext-&gt;Flush();
</span><del>-        mDeviceContext-&gt;Release();
-        mDeviceContext = NULL;
</del><ins>+        SafeRelease(mDeviceContext);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mDevice)
-    {
-        mDevice-&gt;Release();
-        mDevice = NULL;
-    }
</del><ins>+    SafeRelease(mDevice);
</ins><span class="cx"> 
</span><span class="cx">     if (mD3d11Module)
</span><span class="cx">     {
</span><span class="lines">@@ -2058,6 +1926,8 @@
</span><span class="cx">         FreeLibrary(mDxgiModule);
</span><span class="cx">         mDxgiModule = NULL;
</span><span class="cx">     }
</span><ins>+
+    mCompiler.release();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Renderer11::resetDevice()
</span><span class="lines">@@ -2110,17 +1980,17 @@
</span><span class="cx">     return mBGRATextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::getDXT1TextureSupport()
</del><ins>+bool Renderer11::getDXT1TextureSupport() const
</ins><span class="cx"> {
</span><span class="cx">     return mDXT1TextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::getDXT3TextureSupport()
</del><ins>+bool Renderer11::getDXT3TextureSupport() const
</ins><span class="cx"> {
</span><span class="cx">     return mDXT3TextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::getDXT5TextureSupport()
</del><ins>+bool Renderer11::getDXT5TextureSupport() const
</ins><span class="cx"> {
</span><span class="cx">     return mDXT5TextureSupport;
</span><span class="cx"> }
</span><span class="lines">@@ -2130,35 +2000,66 @@
</span><span class="cx">     return mDepthTextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::getFloat32TextureSupport(bool *filtering, bool *renderable)
</del><ins>+bool Renderer11::getFloat32TextureSupport() const
</ins><span class="cx"> {
</span><del>-    *renderable = mFloat32RenderSupport;
-    *filtering = mFloat32FilterSupport;
</del><span class="cx">     return mFloat32TextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::getFloat16TextureSupport(bool *filtering, bool *renderable)
</del><ins>+bool Renderer11::getFloat32TextureFilteringSupport() const
</ins><span class="cx"> {
</span><del>-    *renderable = mFloat16RenderSupport;
-    *filtering = mFloat16FilterSupport;
</del><ins>+    return mFloat32FilterSupport;
+}
+
+bool Renderer11::getFloat32TextureRenderingSupport() const
+{
+    return mFloat32RenderSupport;
+}
+
+bool Renderer11::getFloat16TextureSupport() const
+{
</ins><span class="cx">     return mFloat16TextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::getLuminanceTextureSupport()
</del><ins>+bool Renderer11::getFloat16TextureFilteringSupport() const
</ins><span class="cx"> {
</span><ins>+    return mFloat16FilterSupport;
+}
+
+bool Renderer11::getFloat16TextureRenderingSupport() const
+{
+    return mFloat16RenderSupport;
+}
+
+bool Renderer11::getRGB565TextureSupport() const
+{
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::getLuminanceAlphaTextureSupport()
</del><ins>+bool Renderer11::getLuminanceTextureSupport() const
</ins><span class="cx"> {
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer11::getLuminanceAlphaTextureSupport() const
+{
+    return false;
+}
+
+bool Renderer11::getRGTextureSupport() const
+{
+    return mRGTextureSupport;
+}
+
</ins><span class="cx"> bool Renderer11::getTextureFilterAnisotropySupport() const
</span><span class="cx"> {
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer11::getPBOSupport() const
+{
+    return true;
+}
+
</ins><span class="cx"> float Renderer11::getTextureMaxAnisotropy() const
</span><span class="cx"> {
</span><span class="cx">     switch (mFeatureLevel)
</span><span class="lines">@@ -2173,7 +2074,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::getEventQuerySupport()
</del><ins>+bool Renderer11::getEventQuerySupport() const
</ins><span class="cx"> {
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -2238,18 +2139,130 @@
</span><span class="cx"> unsigned int Renderer11::getMaxVaryingVectors() const
</span><span class="cx"> {
</span><span class="cx">     META_ASSERT(gl::IMPLEMENTATION_MAX_VARYING_VECTORS == D3D11_VS_OUTPUT_REGISTER_COUNT);
</span><ins>+    META_ASSERT(D3D11_VS_OUTPUT_REGISTER_COUNT &lt;= D3D11_PS_INPUT_REGISTER_COUNT);
+    META_ASSERT(D3D10_VS_OUTPUT_REGISTER_COUNT &lt;= D3D10_PS_INPUT_REGISTER_COUNT);
</ins><span class="cx">     switch (mFeatureLevel)
</span><span class="cx">     {
</span><span class="cx">       case D3D_FEATURE_LEVEL_11_0:
</span><del>-        return D3D11_VS_OUTPUT_REGISTER_COUNT;
</del><ins>+        return D3D11_VS_OUTPUT_REGISTER_COUNT - getReservedVaryings();
</ins><span class="cx">       case D3D_FEATURE_LEVEL_10_1:
</span><ins>+        return D3D10_1_VS_OUTPUT_REGISTER_COUNT - getReservedVaryings();
</ins><span class="cx">       case D3D_FEATURE_LEVEL_10_0:
</span><del>-        return D3D10_VS_OUTPUT_REGISTER_COUNT;
</del><ins>+        return D3D10_VS_OUTPUT_REGISTER_COUNT - getReservedVaryings();
</ins><span class="cx">       default: UNREACHABLE();
</span><span class="cx">         return 0;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+unsigned int Renderer11::getMaxVertexShaderUniformBuffers() const
+{
+    META_ASSERT(gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS &gt;= D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT &amp;&amp;
+                gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS &gt;= D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT);
+
+    switch (mFeatureLevel)
+    {
+      case D3D_FEATURE_LEVEL_11_0:
+        return D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - getReservedVertexUniformBuffers();
+      case D3D_FEATURE_LEVEL_10_1:
+      case D3D_FEATURE_LEVEL_10_0:
+        return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - getReservedVertexUniformBuffers();
+      default: UNREACHABLE();
+        return 0;
+    }
+}
+
+unsigned int Renderer11::getMaxFragmentShaderUniformBuffers() const
+{
+    META_ASSERT(gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS &gt;= D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT &amp;&amp;
+                gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS &gt;= D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT);
+
+    switch (mFeatureLevel)
+    {
+      case D3D_FEATURE_LEVEL_11_0:
+        return D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - getReservedFragmentUniformBuffers();
+      case D3D_FEATURE_LEVEL_10_1:
+      case D3D_FEATURE_LEVEL_10_0:
+        return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - getReservedFragmentUniformBuffers();
+      default: UNREACHABLE();
+        return 0;
+    }
+}
+
+unsigned int Renderer11::getReservedVertexUniformBuffers() const
+{
+    // we reserve one buffer for the application uniforms, and one for driver uniforms
+    return 2;
+}
+
+unsigned int Renderer11::getReservedFragmentUniformBuffers() const
+{
+    // we reserve one buffer for the application uniforms, and one for driver uniforms
+    return 2;
+}
+
+unsigned int Renderer11::getReservedVaryings() const
+{
+    // We potentially reserve varyings for gl_Position, _dx_Position, gl_FragCoord and gl_PointSize
+    return 4;
+}
+
+
+unsigned int Renderer11::getMaxTransformFeedbackBuffers() const
+{
+    META_ASSERT(gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS &gt;= D3D11_SO_BUFFER_SLOT_COUNT &amp;&amp;
+                gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS &gt;= D3D10_SO_BUFFER_SLOT_COUNT);
+
+    switch (mFeatureLevel)
+    {
+      case D3D_FEATURE_LEVEL_11_0:
+        return D3D11_SO_BUFFER_SLOT_COUNT;
+      case D3D_FEATURE_LEVEL_10_1:
+        return D3D10_1_SO_BUFFER_SLOT_COUNT;
+      case D3D_FEATURE_LEVEL_10_0:
+        return D3D10_SO_BUFFER_SLOT_COUNT;
+      default: UNREACHABLE();
+        return 0;
+    }
+}
+
+unsigned int Renderer11::getMaxTransformFeedbackSeparateComponents() const
+{
+    switch (mFeatureLevel)
+    {
+      case D3D_FEATURE_LEVEL_11_0:
+        return getMaxTransformFeedbackInterleavedComponents() / getMaxTransformFeedbackBuffers();
+      case D3D_FEATURE_LEVEL_10_1:
+      case D3D_FEATURE_LEVEL_10_0:
+        // D3D 10 and 10.1 only allow one output per output slot if an output slot other than zero
+        // is used.
+        return 4;
+      default: UNREACHABLE();
+        return 0;
+    }
+}
+
+unsigned int Renderer11::getMaxTransformFeedbackInterleavedComponents() const
+{
+    return (getMaxVaryingVectors() * 4);
+}
+
+unsigned int Renderer11::getMaxUniformBufferSize() const
+{
+    // Each component is a 4-element vector of 4-byte units (floats)
+    const unsigned int bytesPerComponent = 4 * sizeof(float);
+
+    switch (mFeatureLevel)
+    {
+      case D3D_FEATURE_LEVEL_11_0:
+        return D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * bytesPerComponent;
+      case D3D_FEATURE_LEVEL_10_1:
+      case D3D_FEATURE_LEVEL_10_0:
+        return D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * bytesPerComponent;
+      default: UNREACHABLE();
+        return 0;
+    }
+}
+
</ins><span class="cx"> bool Renderer11::getNonPower2TextureSupport() const
</span><span class="cx"> {
</span><span class="cx">     switch (mFeatureLevel)
</span><span class="lines">@@ -2316,6 +2329,24 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int Renderer11::getMaxRecommendedElementsIndices() const
+{
+    META_ASSERT(D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32);
+    META_ASSERT(D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32);
+
+    // D3D11 allows up to 2^32 elements, but we report max signed int for convenience.
+    return std::numeric_limits&lt;GLint&gt;::max();
+}
+
+int Renderer11::getMaxRecommendedElementsVertices() const
+{
+    META_ASSERT(D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP == 32);
+    META_ASSERT(D3D10_REQ_DRAW_VERTEX_COUNT_2_TO_EXP == 32);
+
+    // D3D11 allows up to 2^32 elements, but we report max signed int for convenience.
+    return std::numeric_limits&lt;GLint&gt;::max();
+}
+
</ins><span class="cx"> int Renderer11::getMajorShaderModel() const
</span><span class="cx"> {
</span><span class="cx">     switch (mFeatureLevel)
</span><span class="lines">@@ -2386,6 +2417,28 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int Renderer11::getMaxTextureDepth() const
+{
+    switch (mFeatureLevel)
+    {
+      case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION;   // 2048
+      case D3D_FEATURE_LEVEL_10_1:
+      case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION;   // 2048
+      default: UNREACHABLE();      return 0;
+    }
+}
+
+int Renderer11::getMaxTextureArrayLayers() const
+{
+    switch (mFeatureLevel)
+    {
+      case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION;   // 2048
+      case D3D_FEATURE_LEVEL_10_1:
+      case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION;   // 512
+      default: UNREACHABLE();      return 0;
+    }
+}
+
</ins><span class="cx"> bool Renderer11::get32BitIndexSupport() const
</span><span class="cx"> {
</span><span class="cx">     switch (mFeatureLevel)
</span><span class="lines">@@ -2412,6 +2465,66 @@
</span><span class="cx">     return mMaxSupportedSamples;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLsizei Renderer11::getMaxSupportedFormatSamples(GLenum internalFormat) const
+{
+    DXGI_FORMAT format = gl_d3d11::GetRenderableFormat(internalFormat, getCurrentClientVersion());
+    MultisampleSupportMap::const_iterator iter = mMultisampleSupportMap.find(format);
+    return (iter != mMultisampleSupportMap.end()) ? iter-&gt;second.maxSupportedSamples : 0;
+}
+
+GLsizei Renderer11::getNumSampleCounts(GLenum internalFormat) const
+{
+    unsigned int numCounts = 0;
+
+    // D3D11 supports multisampling for signed and unsigned format, but ES 3.0 does not
+    GLenum componentType = gl::GetComponentType(internalFormat, getCurrentClientVersion());
+    if (componentType != GL_INT &amp;&amp; componentType != GL_UNSIGNED_INT)
+    {
+        DXGI_FORMAT format = gl_d3d11::GetRenderableFormat(internalFormat, getCurrentClientVersion());
+        MultisampleSupportMap::const_iterator iter = mMultisampleSupportMap.find(format);
+
+        if (iter != mMultisampleSupportMap.end())
+        {
+            const MultisampleSupportInfo&amp; info = iter-&gt;second;
+            for (int i = 0; i &lt; D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; i++)
+            {
+                if (info.qualityLevels[i] &gt; 0)
+                {
+                    numCounts++;
+                }
+            }
+        }
+    }
+
+    return numCounts;
+}
+
+void Renderer11::getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const
+{
+    // D3D11 supports multisampling for signed and unsigned format, but ES 3.0 does not
+    GLenum componentType = gl::GetComponentType(internalFormat, getCurrentClientVersion());
+    if (componentType == GL_INT || componentType == GL_UNSIGNED_INT)
+    {
+        return;
+    }
+
+    DXGI_FORMAT format = gl_d3d11::GetRenderableFormat(internalFormat, getCurrentClientVersion());
+    MultisampleSupportMap::const_iterator iter = mMultisampleSupportMap.find(format);
+
+    if (iter != mMultisampleSupportMap.end())
+    {
+        const MultisampleSupportInfo&amp; info = iter-&gt;second;
+        int bufPos = 0;
+        for (int i = D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT - 1; i &gt;= 0 &amp;&amp; bufPos &lt; bufSize; i--)
+        {
+            if (info.qualityLevels[i] &gt; 0)
+            {
+                params[bufPos++] = i + 1;
+            }
+        }
+    }
+}
+
</ins><span class="cx"> int Renderer11::getNearestSupportedSamples(DXGI_FORMAT format, unsigned int requested) const
</span><span class="cx"> {
</span><span class="cx">     if (requested == 0)
</span><span class="lines">@@ -2463,7 +2576,10 @@
</span><span class="cx">         TextureStorage11_2D *source11 = TextureStorage11_2D::makeTextureStorage11_2D(source-&gt;getStorageInstance());
</span><span class="cx">         TextureStorage11_2D *dest11 = TextureStorage11_2D::makeTextureStorage11_2D(dest-&gt;getStorageInstance());
</span><span class="cx"> 
</span><del>-        mDeviceContext-&gt;CopyResource(dest11-&gt;getBaseTexture(), source11-&gt;getBaseTexture());
</del><ins>+        mDeviceContext-&gt;CopyResource(dest11-&gt;getResource(), source11-&gt;getResource());
+
+        dest11-&gt;invalidateSwizzleCache();
+
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2477,13 +2593,50 @@
</span><span class="cx">         TextureStorage11_Cube *source11 = TextureStorage11_Cube::makeTextureStorage11_Cube(source-&gt;getStorageInstance());
</span><span class="cx">         TextureStorage11_Cube *dest11 = TextureStorage11_Cube::makeTextureStorage11_Cube(dest-&gt;getStorageInstance());
</span><span class="cx"> 
</span><del>-        mDeviceContext-&gt;CopyResource(dest11-&gt;getBaseTexture(), source11-&gt;getBaseTexture());
</del><ins>+        mDeviceContext-&gt;CopyResource(dest11-&gt;getResource(), source11-&gt;getResource());
+
+        dest11-&gt;invalidateSwizzleCache();
+
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer11::copyToRenderTarget(TextureStorageInterface3D *dest, TextureStorageInterface3D *source)
+{
+    if (source &amp;&amp; dest)
+    {
+        TextureStorage11_3D *source11 = TextureStorage11_3D::makeTextureStorage11_3D(source-&gt;getStorageInstance());
+        TextureStorage11_3D *dest11 = TextureStorage11_3D::makeTextureStorage11_3D(dest-&gt;getStorageInstance());
+
+        mDeviceContext-&gt;CopyResource(dest11-&gt;getResource(), source11-&gt;getResource());
+
+        dest11-&gt;invalidateSwizzleCache();
+
+        return true;
+    }
+
+    return false;
+}
+
+bool Renderer11::copyToRenderTarget(TextureStorageInterface2DArray *dest, TextureStorageInterface2DArray *source)
+{
+    if (source &amp;&amp; dest)
+    {
+        TextureStorage11_2DArray *source11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(source-&gt;getStorageInstance());
+        TextureStorage11_2DArray *dest11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(dest-&gt;getStorageInstance());
+
+        mDeviceContext-&gt;CopyResource(dest11-&gt;getResource(), source11-&gt;getResource());
+
+        dest11-&gt;invalidateSwizzleCache();
+
+        return true;
+    }
+
+    return false;
+}
+
</ins><span class="cx"> bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
</span><span class="cx">                            GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level)
</span><span class="cx"> {
</span><span class="lines">@@ -2529,15 +2682,19 @@
</span><span class="cx">         return gl::error(GL_OUT_OF_MEMORY, false);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gl::Rectangle destRect;
-    destRect.x = xoffset;
-    destRect.y = yoffset;
-    destRect.width = sourceRect.width;
-    destRect.height = sourceRect.height;
</del><ins>+    gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
+    gl::Extents sourceSize(sourceRenderTarget-&gt;getWidth(), sourceRenderTarget-&gt;getHeight(), 1);
</ins><span class="cx"> 
</span><del>-    bool ret = copyTexture(source, sourceRect, sourceRenderTarget-&gt;getWidth(), sourceRenderTarget-&gt;getHeight(),
-                           dest, destRect, destRenderTarget-&gt;getWidth(), destRenderTarget-&gt;getHeight(), destFormat);
</del><ins>+    gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1);
+    gl::Extents destSize(destRenderTarget-&gt;getWidth(), destRenderTarget-&gt;getHeight(), 1);
</ins><span class="cx"> 
</span><ins>+    // Use nearest filtering because source and destination are the same size for the direct
+    // copy
+    bool ret = mBlit-&gt;copyTexture(source, sourceArea, sourceSize, dest, destArea, destSize, NULL,
+                                  destFormat, GL_NEAREST);
+
+    storage11-&gt;invalidateSwizzleCacheLevel(level);
+
</ins><span class="cx">     return ret;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2572,7 +2729,7 @@
</span><span class="cx">         return gl::error(GL_OUT_OF_MEMORY, false);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RenderTarget11 *destRenderTarget = RenderTarget11::makeRenderTarget11(storage11-&gt;getRenderTarget(target, level));
</del><ins>+    RenderTarget11 *destRenderTarget = RenderTarget11::makeRenderTarget11(storage11-&gt;getRenderTargetFace(target, level));
</ins><span class="cx">     if (!destRenderTarget)
</span><span class="cx">     {
</span><span class="cx">         ERR(&quot;Failed to retrieve the render target from the destination storage.&quot;);
</span><span class="lines">@@ -2586,194 +2743,144 @@
</span><span class="cx">         return gl::error(GL_OUT_OF_MEMORY, false);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gl::Rectangle destRect;
-    destRect.x = xoffset;
-    destRect.y = yoffset;
-    destRect.width = sourceRect.width;
-    destRect.height = sourceRect.height;
</del><ins>+    gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
+    gl::Extents sourceSize(sourceRenderTarget-&gt;getWidth(), sourceRenderTarget-&gt;getHeight(), 1);
</ins><span class="cx"> 
</span><del>-    bool ret = copyTexture(source, sourceRect, sourceRenderTarget-&gt;getWidth(), sourceRenderTarget-&gt;getHeight(),
-                           dest, destRect, destRenderTarget-&gt;getWidth(), destRenderTarget-&gt;getHeight(), destFormat);
</del><ins>+    gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1);
+    gl::Extents destSize(destRenderTarget-&gt;getWidth(), destRenderTarget-&gt;getHeight(), 1);
</ins><span class="cx"> 
</span><ins>+    // Use nearest filtering because source and destination are the same size for the direct
+    // copy
+    bool ret = mBlit-&gt;copyTexture(source, sourceArea, sourceSize, dest, destArea, destSize, NULL,
+                                  destFormat, GL_NEAREST);
+
+    storage11-&gt;invalidateSwizzleCacheLevel(level);
+
</ins><span class="cx">     return ret;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::copyTexture(ID3D11ShaderResourceView *source, const gl::Rectangle &amp;sourceArea, unsigned int sourceWidth, unsigned int sourceHeight,
-                             ID3D11RenderTargetView *dest, const gl::Rectangle &amp;destArea, unsigned int destWidth, unsigned int destHeight, GLenum destFormat)
</del><ins>+bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                           GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface3D *storage, GLint level)
</ins><span class="cx"> {
</span><del>-    HRESULT result;
</del><ins>+    gl::Renderbuffer *colorbuffer = framebuffer-&gt;getReadColorbuffer();
+    if (!colorbuffer)
+    {
+        ERR(&quot;Failed to retrieve the color buffer from the frame buffer.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
+    }
</ins><span class="cx"> 
</span><del>-    if (!mCopyResourcesInitialized)
</del><ins>+    RenderTarget11 *sourceRenderTarget = RenderTarget11::makeRenderTarget11(colorbuffer-&gt;getRenderTarget());
+    if (!sourceRenderTarget)
</ins><span class="cx">     {
</span><del>-        ASSERT(!mCopyVB &amp;&amp; !mCopySampler &amp;&amp; !mCopyIL &amp;&amp; !mCopyVS &amp;&amp; !mCopyRGBAPS &amp;&amp; !mCopyRGBPS &amp;&amp; !mCopyLumPS &amp;&amp; !mCopyLumAlphaPS);
</del><ins>+        ERR(&quot;Failed to retrieve the render target from the frame buffer.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
+    }
</ins><span class="cx"> 
</span><del>-        D3D11_BUFFER_DESC vbDesc;
-        vbDesc.ByteWidth = sizeof(d3d11::PositionTexCoordVertex) * 4;
-        vbDesc.Usage = D3D11_USAGE_DYNAMIC;
-        vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
-        vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
-        vbDesc.MiscFlags = 0;
-        vbDesc.StructureByteStride = 0;
</del><ins>+    ID3D11ShaderResourceView *source = sourceRenderTarget-&gt;getShaderResourceView();
+    if (!source)
+    {
+        ERR(&quot;Failed to retrieve the render target view from the render target.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
+    }
</ins><span class="cx"> 
</span><del>-        result = mDevice-&gt;CreateBuffer(&amp;vbDesc, NULL, &amp;mCopyVB);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mCopyVB, &quot;Renderer11 copy texture vertex buffer&quot;);
</del><ins>+    TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage-&gt;getStorageInstance());
+    if (!storage11)
+    {
+        ERR(&quot;Failed to retrieve the texture storage from the destination.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
+    }
</ins><span class="cx"> 
</span><del>-        D3D11_SAMPLER_DESC samplerDesc;
-        samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
-        samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
-        samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
-        samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
-        samplerDesc.MipLODBias = 0.0f;
-        samplerDesc.MaxAnisotropy = 0;
-        samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
-        samplerDesc.BorderColor[0] = 0.0f;
-        samplerDesc.BorderColor[1] = 0.0f;
-        samplerDesc.BorderColor[2] = 0.0f;
-        samplerDesc.BorderColor[3] = 0.0f;
-        samplerDesc.MinLOD = 0.0f;
-        samplerDesc.MaxLOD = 0.0f;
</del><ins>+    RenderTarget11 *destRenderTarget = RenderTarget11::makeRenderTarget11(storage11-&gt;getRenderTargetLayer(level, zOffset));
+    if (!destRenderTarget)
+    {
+        ERR(&quot;Failed to retrieve the render target from the destination storage.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
+    }
</ins><span class="cx"> 
</span><del>-        result = mDevice-&gt;CreateSamplerState(&amp;samplerDesc, &amp;mCopySampler);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mCopySampler, &quot;Renderer11 copy sampler&quot;);
</del><ins>+    ID3D11RenderTargetView *dest = destRenderTarget-&gt;getRenderTargetView();
+    if (!dest)
+    {
+        ERR(&quot;Failed to retrieve the render target view from the destination render target.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
+    }
</ins><span class="cx"> 
</span><del>-        D3D11_INPUT_ELEMENT_DESC quadLayout[] =
-        {
-            { &quot;POSITION&quot;, 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
-            { &quot;TEXCOORD&quot;, 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
-        };
</del><ins>+    gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
+    gl::Extents sourceSize(sourceRenderTarget-&gt;getWidth(), sourceRenderTarget-&gt;getHeight(), 1);
</ins><span class="cx"> 
</span><del>-        result = mDevice-&gt;CreateInputLayout(quadLayout, 2, g_VS_Passthrough, sizeof(g_VS_Passthrough), &amp;mCopyIL);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mCopyIL, &quot;Renderer11 copy texture input layout&quot;);
</del><ins>+    gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1);
+    gl::Extents destSize(destRenderTarget-&gt;getWidth(), destRenderTarget-&gt;getHeight(), 1);
</ins><span class="cx"> 
</span><del>-        result = mDevice-&gt;CreateVertexShader(g_VS_Passthrough, sizeof(g_VS_Passthrough), NULL, &amp;mCopyVS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mCopyVS, &quot;Renderer11 copy texture vertex shader&quot;);
</del><ins>+    // Use nearest filtering because source and destination are the same size for the direct
+    // copy
+    bool ret = mBlit-&gt;copyTexture(source, sourceArea, sourceSize, dest, destArea, destSize, NULL,
+                                  destFormat, GL_NEAREST);
</ins><span class="cx"> 
</span><del>-        result = mDevice-&gt;CreatePixelShader(g_PS_PassthroughRGBA, sizeof(g_PS_PassthroughRGBA), NULL, &amp;mCopyRGBAPS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mCopyRGBAPS, &quot;Renderer11 copy texture RGBA pixel shader&quot;);
</del><ins>+    storage11-&gt;invalidateSwizzleCacheLevel(level);
</ins><span class="cx"> 
</span><del>-        result = mDevice-&gt;CreatePixelShader(g_PS_PassthroughRGB, sizeof(g_PS_PassthroughRGB), NULL, &amp;mCopyRGBPS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mCopyRGBPS, &quot;Renderer11 copy texture RGB pixel shader&quot;);
</del><ins>+    return ret;
+}
</ins><span class="cx"> 
</span><del>-        result = mDevice-&gt;CreatePixelShader(g_PS_PassthroughLum, sizeof(g_PS_PassthroughLum), NULL, &amp;mCopyLumPS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mCopyLumPS, &quot;Renderer11 copy texture luminance pixel shader&quot;);
</del><ins>+bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                           GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface2DArray *storage, GLint level)
+{
+    gl::Renderbuffer *colorbuffer = framebuffer-&gt;getReadColorbuffer();
+    if (!colorbuffer)
+    {
+        ERR(&quot;Failed to retrieve the color buffer from the frame buffer.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
+    }
</ins><span class="cx"> 
</span><del>-        result = mDevice-&gt;CreatePixelShader(g_PS_PassthroughLumAlpha, sizeof(g_PS_PassthroughLumAlpha), NULL, &amp;mCopyLumAlphaPS);
-        ASSERT(SUCCEEDED(result));
-        d3d11::SetDebugName(mCopyLumAlphaPS, &quot;Renderer11 copy texture luminance alpha pixel shader&quot;);
</del><ins>+    RenderTarget11 *sourceRenderTarget = RenderTarget11::makeRenderTarget11(colorbuffer-&gt;getRenderTarget());
+    if (!sourceRenderTarget)
+    {
+        ERR(&quot;Failed to retrieve the render target from the frame buffer.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
+    }
</ins><span class="cx"> 
</span><del>-        mCopyResourcesInitialized = true;
</del><ins>+    ID3D11ShaderResourceView *source = sourceRenderTarget-&gt;getShaderResourceView();
+    if (!source)
+    {
+        ERR(&quot;Failed to retrieve the render target view from the render target.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Verify the source and destination area sizes
-    if (sourceArea.x &lt; 0 || sourceArea.x + sourceArea.width &gt; static_cast&lt;int&gt;(sourceWidth) ||
-        sourceArea.y &lt; 0 || sourceArea.y + sourceArea.height &gt; static_cast&lt;int&gt;(sourceHeight) ||
-        destArea.x &lt; 0 || destArea.x + destArea.width &gt; static_cast&lt;int&gt;(destWidth) ||
-        destArea.y &lt; 0 || destArea.y + destArea.height &gt; static_cast&lt;int&gt;(destHeight))
</del><ins>+    TextureStorage11_2DArray *storage11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(storage-&gt;getStorageInstance());
+    if (!storage11)
</ins><span class="cx">     {
</span><del>-        return gl::error(GL_INVALID_VALUE, false);
</del><ins>+        SafeRelease(source);
+        ERR(&quot;Failed to retrieve the texture storage from the destination.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Set vertices
-    D3D11_MAPPED_SUBRESOURCE mappedResource;
-    result = mDeviceContext-&gt;Map(mCopyVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &amp;mappedResource);
-    if (FAILED(result))
</del><ins>+    RenderTarget11 *destRenderTarget = RenderTarget11::makeRenderTarget11(storage11-&gt;getRenderTargetLayer(level, zOffset));
+    if (!destRenderTarget)
</ins><span class="cx">     {
</span><del>-        ERR(&quot;Failed to map vertex buffer for texture copy, HRESULT: 0x%X.&quot;, result);
</del><ins>+        SafeRelease(source);
+        ERR(&quot;Failed to retrieve the render target from the destination storage.&quot;);
</ins><span class="cx">         return gl::error(GL_OUT_OF_MEMORY, false);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    d3d11::PositionTexCoordVertex *vertices = static_cast&lt;d3d11::PositionTexCoordVertex*&gt;(mappedResource.pData);
-
-    // Create a quad in homogeneous coordinates
-    float x1 = (destArea.x / float(destWidth)) * 2.0f - 1.0f;
-    float y1 = ((destHeight - destArea.y - destArea.height) / float(destHeight)) * 2.0f - 1.0f;
-    float x2 = ((destArea.x + destArea.width) / float(destWidth)) * 2.0f - 1.0f;
-    float y2 = ((destHeight - destArea.y) / float(destHeight)) * 2.0f - 1.0f;
-
-    float u1 = sourceArea.x / float(sourceWidth);
-    float v1 = sourceArea.y / float(sourceHeight);
-    float u2 = (sourceArea.x + sourceArea.width) / float(sourceWidth);
-    float v2 = (sourceArea.y + sourceArea.height) / float(sourceHeight);
-
-    d3d11::SetPositionTexCoordVertex(&amp;vertices[0], x1, y1, u1, v2);
-    d3d11::SetPositionTexCoordVertex(&amp;vertices[1], x1, y2, u1, v1);
-    d3d11::SetPositionTexCoordVertex(&amp;vertices[2], x2, y1, u2, v2);
-    d3d11::SetPositionTexCoordVertex(&amp;vertices[3], x2, y2, u2, v1);
-
-    mDeviceContext-&gt;Unmap(mCopyVB, 0);
-
-    static UINT stride = sizeof(d3d11::PositionTexCoordVertex);
-    static UINT startIdx = 0;
-    mDeviceContext-&gt;IASetVertexBuffers(0, 1, &amp;mCopyVB, &amp;stride, &amp;startIdx);
-
-    // Apply state
-    mDeviceContext-&gt;OMSetBlendState(NULL, NULL, 0xFFFFFFF);
-    mDeviceContext-&gt;OMSetDepthStencilState(NULL, 0xFFFFFFFF);
-    mDeviceContext-&gt;RSSetState(NULL);
-
-    // Apply shaders
-    mDeviceContext-&gt;IASetInputLayout(mCopyIL);
-    mDeviceContext-&gt;IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-    mDeviceContext-&gt;VSSetShader(mCopyVS, NULL, 0);
-
-    ID3D11PixelShader *ps = NULL;
-    switch(destFormat)
</del><ins>+    ID3D11RenderTargetView *dest = destRenderTarget-&gt;getRenderTargetView();
+    if (!dest)
</ins><span class="cx">     {
</span><del>-      case GL_RGBA:            ps = mCopyRGBAPS;     break;
-      case GL_RGB:             ps = mCopyRGBPS;      break;
-      case GL_ALPHA:           ps = mCopyRGBAPS;     break;
-      case GL_BGRA_EXT:        ps = mCopyRGBAPS;     break;
-      case GL_LUMINANCE:       ps = mCopyLumPS;      break;
-      case GL_LUMINANCE_ALPHA: ps = mCopyLumAlphaPS; break;
-      default: UNREACHABLE();  ps = NULL;            break;
</del><ins>+        ERR(&quot;Failed to retrieve the render target view from the destination render target.&quot;);
+        return gl::error(GL_OUT_OF_MEMORY, false);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mDeviceContext-&gt;PSSetShader(ps, NULL, 0);
-    mDeviceContext-&gt;GSSetShader(NULL, NULL, 0);
</del><ins>+    gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
+    gl::Extents sourceSize(sourceRenderTarget-&gt;getWidth(), sourceRenderTarget-&gt;getHeight(), 1);
</ins><span class="cx"> 
</span><del>-    // Unset the currently bound shader resource to avoid conflicts
-    static ID3D11ShaderResourceView *const nullSRV = NULL;
-    mDeviceContext-&gt;PSSetShaderResources(0, 1, &amp;nullSRV);
</del><ins>+    gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1);
+    gl::Extents destSize(destRenderTarget-&gt;getWidth(), destRenderTarget-&gt;getHeight(), 1);
</ins><span class="cx"> 
</span><del>-    // Apply render target
-    setOneTimeRenderTarget(dest);
</del><ins>+    // Use nearest filtering because source and destination are the same size for the direct
+    // copy
+    bool ret = mBlit-&gt;copyTexture(source, sourceArea, sourceSize, dest, destArea, destSize, NULL,
+                                  destFormat, GL_NEAREST);
</ins><span class="cx"> 
</span><del>-    // Set the viewport
-    D3D11_VIEWPORT viewport;
-    viewport.TopLeftX = 0;
-    viewport.TopLeftY = 0;
-    viewport.Width = destWidth;
-    viewport.Height = destHeight;
-    viewport.MinDepth = 0.0f;
-    viewport.MaxDepth = 1.0f;
-    mDeviceContext-&gt;RSSetViewports(1, &amp;viewport);
</del><ins>+    storage11-&gt;invalidateSwizzleCacheLevel(level);
</ins><span class="cx"> 
</span><del>-    // Apply textures
-    mDeviceContext-&gt;PSSetShaderResources(0, 1, &amp;source);
-    mDeviceContext-&gt;PSSetSamplers(0, 1, &amp;mCopySampler);
-
-    // Draw the quad
-    mDeviceContext-&gt;Draw(4, 0);
-
-    // Unbind textures and render targets and vertex buffer
-    mDeviceContext-&gt;PSSetShaderResources(0, 1, &amp;nullSRV);
-
-    unapplyRenderTargets();
-
-    UINT zero = 0;
-    ID3D11Buffer *const nullBuffer = NULL;
-    mDeviceContext-&gt;IASetVertexBuffers(0, 1, &amp;nullBuffer, &amp;zero, &amp;zero);
-
-    markAllStateDirty();
-
-    return true;
</del><ins>+    return ret;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Renderer11::unapplyRenderTargets()
</span><span class="lines">@@ -2805,8 +2912,9 @@
</span><span class="cx">     {
</span><span class="cx">         // Note: depth stencil may be NULL for 0 sized surfaces
</span><span class="cx">         renderTarget = new RenderTarget11(this, swapChain11-&gt;getDepthStencil(),
</span><del>-                                          swapChain11-&gt;getDepthStencilTexture(), NULL,
-                                          swapChain11-&gt;getWidth(), swapChain11-&gt;getHeight());
</del><ins>+                                          swapChain11-&gt;getDepthStencilTexture(),
+                                          swapChain11-&gt;getDepthStencilShaderResource(),
+                                          swapChain11-&gt;getWidth(), swapChain11-&gt;getHeight(), 1);
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="lines">@@ -2814,56 +2922,87 @@
</span><span class="cx">         renderTarget = new RenderTarget11(this, swapChain11-&gt;getRenderTarget(),
</span><span class="cx">                                           swapChain11-&gt;getOffscreenTexture(),
</span><span class="cx">                                           swapChain11-&gt;getRenderTargetShaderResource(),
</span><del>-                                          swapChain11-&gt;getWidth(), swapChain11-&gt;getHeight());
</del><ins>+                                          swapChain11-&gt;getWidth(), swapChain11-&gt;getHeight(), 1);
</ins><span class="cx">     }
</span><span class="cx">     return renderTarget;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget *Renderer11::createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth)
</del><ins>+RenderTarget *Renderer11::createRenderTarget(int width, int height, GLenum format, GLsizei samples)
</ins><span class="cx"> {
</span><del>-    RenderTarget11 *renderTarget = new RenderTarget11(this, width, height, format, samples, depth);
</del><ins>+    RenderTarget11 *renderTarget = new RenderTarget11(this, width, height, format, samples);
</ins><span class="cx">     return renderTarget;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ShaderExecutable *Renderer11::loadExecutable(const void *function, size_t length, rx::ShaderType type)
</del><ins>+ShaderExecutable *Renderer11::loadExecutable(const void *function, size_t length, rx::ShaderType type,
+                                             const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                             bool separatedOutputBuffers)
</ins><span class="cx"> {
</span><span class="cx">     ShaderExecutable11 *executable = NULL;
</span><ins>+    HRESULT result;
</ins><span class="cx"> 
</span><span class="cx">     switch (type)
</span><span class="cx">     {
</span><span class="cx">       case rx::SHADER_VERTEX:
</span><span class="cx">         {
</span><del>-            ID3D11VertexShader *vshader = NULL;
-            HRESULT result = mDevice-&gt;CreateVertexShader(function, length, NULL, &amp;vshader);
</del><ins>+            ID3D11VertexShader *vertexShader = NULL;
+            ID3D11GeometryShader *streamOutShader = NULL;
+
+            result = mDevice-&gt;CreateVertexShader(function, length, NULL, &amp;vertexShader);
</ins><span class="cx">             ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-            if (vshader)
</del><ins>+            if (transformFeedbackVaryings.size() &gt; 0)
</ins><span class="cx">             {
</span><del>-                executable = new ShaderExecutable11(function, length, vshader);
</del><ins>+                std::vector&lt;D3D11_SO_DECLARATION_ENTRY&gt; soDeclaration;
+                for (size_t i = 0; i &lt; transformFeedbackVaryings.size(); i++)
+                {
+                    const gl::LinkedVarying &amp;varying = transformFeedbackVaryings[i];
+                    for (size_t j = 0; j &lt; varying.semanticIndexCount; j++)
+                    {
+                        D3D11_SO_DECLARATION_ENTRY entry = { 0 };
+                        entry.Stream = 0;
+                        entry.SemanticName = varying.semanticName.c_str();
+                        entry.SemanticIndex = varying.semanticIndex + j;
+                        entry.StartComponent = 0;
+                        entry.ComponentCount = gl::VariableRowCount(type);
+                        entry.OutputSlot = (separatedOutputBuffers ? i : 0);
+                        soDeclaration.push_back(entry);
+                    }
+                }
+
+                result = mDevice-&gt;CreateGeometryShaderWithStreamOutput(function, length, soDeclaration.data(), soDeclaration.size(),
+                                                                       NULL, 0, 0, NULL, &amp;streamOutShader);
+                ASSERT(SUCCEEDED(result));
</ins><span class="cx">             }
</span><ins>+
+            if (vertexShader)
+            {
+                executable = new ShaderExecutable11(function, length, vertexShader, streamOutShader);
+            }
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">       case rx::SHADER_PIXEL:
</span><span class="cx">         {
</span><del>-            ID3D11PixelShader *pshader = NULL;
-            HRESULT result = mDevice-&gt;CreatePixelShader(function, length, NULL, &amp;pshader);
</del><ins>+            ID3D11PixelShader *pixelShader = NULL;
+
+            result = mDevice-&gt;CreatePixelShader(function, length, NULL, &amp;pixelShader);
</ins><span class="cx">             ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-            if (pshader)
</del><ins>+            if (pixelShader)
</ins><span class="cx">             {
</span><del>-                executable = new ShaderExecutable11(function, length, pshader);
</del><ins>+                executable = new ShaderExecutable11(function, length, pixelShader);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">       case rx::SHADER_GEOMETRY:
</span><span class="cx">         {
</span><del>-            ID3D11GeometryShader *gshader = NULL;
-            HRESULT result = mDevice-&gt;CreateGeometryShader(function, length, NULL, &amp;gshader);
</del><ins>+            ID3D11GeometryShader *geometryShader = NULL;
+
+            result = mDevice-&gt;CreateGeometryShader(function, length, NULL, &amp;geometryShader);
</ins><span class="cx">             ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-            if (gshader)
</del><ins>+            if (geometryShader)
</ins><span class="cx">             {
</span><del>-                executable = new ShaderExecutable11(function, length, gshader);
</del><ins>+                executable = new ShaderExecutable11(function, length, geometryShader);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="lines">@@ -2875,36 +3014,65 @@
</span><span class="cx">     return executable;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround)
</del><ins>+ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type,
+                                                  const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                                  bool separatedOutputBuffers, D3DWorkaroundType workaround)
</ins><span class="cx"> {
</span><del>-    const char *profile = NULL;
-
</del><ins>+    const char *profileType = NULL;
</ins><span class="cx">     switch (type)
</span><span class="cx">     {
</span><span class="cx">       case rx::SHADER_VERTEX:
</span><del>-        profile = &quot;vs_4_0&quot;;
</del><ins>+        profileType = &quot;vs&quot;;
</ins><span class="cx">         break;
</span><span class="cx">       case rx::SHADER_PIXEL:
</span><del>-        profile = &quot;ps_4_0&quot;;
</del><ins>+        profileType = &quot;ps&quot;;
</ins><span class="cx">         break;
</span><span class="cx">       case rx::SHADER_GEOMETRY:
</span><del>-        profile = &quot;gs_4_0&quot;;
</del><ins>+        profileType = &quot;gs&quot;;
</ins><span class="cx">         break;
</span><span class="cx">       default:
</span><span class="cx">         UNREACHABLE();
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ID3DBlob *binary = (ID3DBlob*)compileToBinary(infoLog, shaderHLSL, profile, D3DCOMPILE_OPTIMIZATION_LEVEL0, false);
</del><ins>+    const char *profileVersion = NULL;
+    switch (mFeatureLevel)
+    {
+      case D3D_FEATURE_LEVEL_11_0:
+        profileVersion = &quot;5_0&quot;;
+        break;
+      case D3D_FEATURE_LEVEL_10_1:
+        profileVersion = &quot;4_1&quot;;
+        break;
+      case D3D_FEATURE_LEVEL_10_0:
+        profileVersion = &quot;4_0&quot;;
+        break;
+      default:
+        UNREACHABLE();
+        return NULL;
+    }
+
+    char profile[32];
+    snprintf(profile, ArraySize(profile), &quot;%s_%s&quot;, profileType, profileVersion);
+
+    ID3DBlob *binary = (ID3DBlob*)mCompiler.compileToBinary(infoLog, shaderHLSL, profile, D3DCOMPILE_OPTIMIZATION_LEVEL0, false);
</ins><span class="cx">     if (!binary)
</span><ins>+    {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    ShaderExecutable *executable = loadExecutable((DWORD *)binary-&gt;GetBufferPointer(), binary-&gt;GetBufferSize(), type);
-    binary-&gt;Release();
</del><ins>+    ShaderExecutable *executable = loadExecutable((DWORD *)binary-&gt;GetBufferPointer(), binary-&gt;GetBufferSize(), type,
+                                                  transformFeedbackVaryings, separatedOutputBuffers);
+    SafeRelease(binary);
</ins><span class="cx"> 
</span><span class="cx">     return executable;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+rx::UniformStorage *Renderer11::createUniformStorage(size_t storageSize)
+{
+    return new UniformStorage11(this, storageSize);
+}
+
</ins><span class="cx"> VertexBuffer *Renderer11::createVertexBuffer()
</span><span class="cx"> {
</span><span class="cx">     return new VertexBuffer11(this);
</span><span class="lines">@@ -2930,6 +3098,50 @@
</span><span class="cx">     return new Fence11(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
+{
+    int clientVersion = getCurrentClientVersion();
+
+    // We only support buffer to texture copies in ES3
+    if (clientVersion &lt;= 2)
+    {
+        return false;
+    }
+
+    // sRGB formats do not work with D3D11 buffer SRVs
+    if (gl::GetColorEncoding(internalFormat, clientVersion) == GL_SRGB)
+    {
+        return false;
+    }
+
+    // We cannot support direct copies to non-color-renderable formats
+    if (!gl::IsColorRenderingSupported(internalFormat, this))
+    {
+        return false;
+    }
+
+    // We skip all 3-channel formats since sometimes format support is missing
+    if (gl::GetComponentCount(internalFormat, clientVersion) == 3)
+    {
+        return false;
+    }
+
+    // We don't support formats which we can't represent without conversion
+    if (getNativeTextureFormat(internalFormat) != internalFormat)
+    {
+        return false;
+    }
+
+    return true;
+}
+
+bool Renderer11::fastCopyBufferToTexture(const gl::PixelUnpackState &amp;unpack, unsigned int offset, RenderTarget *destRenderTarget,
+                                         GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &amp;destArea)
+{
+    ASSERT(supportsFastCopyBufferToTexture(destinationFormat));
+    return mPixelTransfer-&gt;copyBufferToTexture(unpack, offset, destRenderTarget, destinationFormat, sourcePixelsType, destArea);
+}
+
</ins><span class="cx"> bool Renderer11::getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(colorbuffer != NULL);
</span><span class="lines">@@ -2947,8 +3159,8 @@
</span><span class="cx"> 
</span><span class="cx">             if (textureResource)
</span><span class="cx">             {
</span><del>-                HRESULT result = textureResource-&gt;QueryInterface(IID_ID3D11Texture2D, (void**)resource);
-                textureResource-&gt;Release();
</del><ins>+                HRESULT result = textureResource-&gt;QueryInterface(__uuidof(ID3D11Texture2D), (void**)resource);
+                SafeRelease(textureResource);
</ins><span class="cx"> 
</span><span class="cx">                 if (SUCCEEDED(result))
</span><span class="cx">                 {
</span><span class="lines">@@ -2967,7 +3179,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &amp;readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &amp;drawRect,
</span><del>-                          bool blitRenderTarget, bool blitDepthStencil)
</del><ins>+                          const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter)
</ins><span class="cx"> {
</span><span class="cx">     if (blitRenderTarget)
</span><span class="cx">     {
</span><span class="lines">@@ -2995,7 +3207,8 @@
</span><span class="cx"> 
</span><span class="cx">                 RenderTarget *drawRenderTarget = drawBuffer-&gt;getRenderTarget();
</span><span class="cx"> 
</span><del>-                if (!blitRenderbufferRect(readRect, drawRect, readRenderTarget, drawRenderTarget, false))
</del><ins>+                if (!blitRenderbufferRect(readRect, drawRect, readRenderTarget, drawRenderTarget, filter, scissor,
+                                          blitRenderTarget, false, false))
</ins><span class="cx">                 {
</span><span class="cx">                     return false;
</span><span class="cx">                 }
</span><span class="lines">@@ -3003,7 +3216,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (blitDepthStencil)
</del><ins>+    if (blitDepth || blitStencil)
</ins><span class="cx">     {
</span><span class="cx">         gl::Renderbuffer *readBuffer = readTarget-&gt;getDepthOrStencilbuffer();
</span><span class="cx">         gl::Renderbuffer *drawBuffer = drawTarget-&gt;getDepthOrStencilbuffer();
</span><span class="lines">@@ -3023,17 +3236,20 @@
</span><span class="cx">         RenderTarget *readRenderTarget = readBuffer-&gt;getDepthStencil();
</span><span class="cx">         RenderTarget *drawRenderTarget = drawBuffer-&gt;getDepthStencil();
</span><span class="cx"> 
</span><del>-        if (!blitRenderbufferRect(readRect, drawRect, readRenderTarget, drawRenderTarget, true))
</del><ins>+        if (!blitRenderbufferRect(readRect, drawRect, readRenderTarget, drawRenderTarget, filter, scissor,
+                                  false, blitDepth, blitStencil))
</ins><span class="cx">         {
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    invalidateFramebufferSwizzles(drawTarget);
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
-                            GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels)
</del><ins>+void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
+                            GLenum type, GLuint outputPitch, const gl::PixelPackState &amp;pack, void* pixels)
</ins><span class="cx"> {
</span><span class="cx">     ID3D11Texture2D *colorBufferTexture = NULL;
</span><span class="cx">     unsigned int subresourceIndex = 0;
</span><span class="lines">@@ -3048,11 +3264,9 @@
</span><span class="cx">         area.width = width;
</span><span class="cx">         area.height = height;
</span><span class="cx"> 
</span><del>-        readTextureData(colorBufferTexture, subresourceIndex, area, colorbuffer-&gt;getActualFormat(), format, type, outputPitch,
-                        packReverseRowOrder, packAlignment, pixels);
</del><ins>+        readTextureData(colorBufferTexture, subresourceIndex, area, format, type, outputPitch, pack, pixels);
</ins><span class="cx"> 
</span><del>-        colorBufferTexture-&gt;Release();
-        colorBufferTexture = NULL;
</del><ins>+        SafeRelease(colorBufferTexture);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3065,7 +3279,7 @@
</span><span class="cx"> {
</span><span class="cx">     Image11 *dest11 = Image11::makeImage11(dest);
</span><span class="cx">     Image11 *src11 = Image11::makeImage11(src);
</span><del>-    Image11::generateMipmap(dest11, src11);
</del><ins>+    Image11::generateMipmap(getCurrentClientVersion(), dest11, src11);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureStorage *Renderer11::createTextureStorage2D(SwapChain *swapChain)
</span><span class="lines">@@ -3074,305 +3288,58 @@
</span><span class="cx">     return new TextureStorage11_2D(this, swapChain11);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorage *Renderer11::createTextureStorage2D(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height)
</del><ins>+TextureStorage *Renderer11::createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
</ins><span class="cx"> {
</span><del>-    return new TextureStorage11_2D(this, levels, internalformat, usage, forceRenderable, width, height);
</del><ins>+    return new TextureStorage11_2D(this, internalformat, renderTarget, width, height, levels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorage *Renderer11::createTextureStorageCube(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size)
</del><ins>+TextureStorage *Renderer11::createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels)
</ins><span class="cx"> {
</span><del>-    return new TextureStorage11_Cube(this, levels, internalformat, usage, forceRenderable, size);
</del><ins>+    return new TextureStorage11_Cube(this, internalformat, renderTarget, size, levels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline unsigned int getFastPixelCopySize(DXGI_FORMAT sourceFormat, GLenum sourceGLFormat, GLenum destFormat, GLenum destType)
</del><ins>+TextureStorage *Renderer11::createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels)
</ins><span class="cx"> {
</span><del>-    if (sourceFormat == DXGI_FORMAT_A8_UNORM &amp;&amp;
-        destFormat   == GL_ALPHA &amp;&amp;
-        destType     == GL_UNSIGNED_BYTE)
-    {
-        return 1;
-    }
-    else if (sourceFormat   == DXGI_FORMAT_R8G8B8A8_UNORM &amp;&amp;
-             sourceGLFormat == GL_RGBA8_OES &amp;&amp;
-             destFormat     == GL_RGBA &amp;&amp;
-             destType       == GL_UNSIGNED_BYTE)
-    {
-        return 4;
-    }
-    else if (sourceFormat == DXGI_FORMAT_B8G8R8A8_UNORM &amp;&amp;
-             destFormat   == GL_BGRA_EXT &amp;&amp;
-             destType     == GL_UNSIGNED_BYTE)
-    {
-        return 4;
-    }
-    else if (sourceFormat   == DXGI_FORMAT_R16G16B16A16_FLOAT &amp;&amp;
-             sourceGLFormat == GL_RGBA16F_EXT &amp;&amp;
-             destFormat     == GL_RGBA &amp;&amp;
-             destType       == GL_HALF_FLOAT_OES)
-    {
-        return 8;
-    }
-    else if (sourceFormat == DXGI_FORMAT_R32G32B32_FLOAT &amp;&amp;
-             destFormat   == GL_RGB &amp;&amp;
-             destType     == GL_FLOAT)
-    {
-        return 12;
-    }
-    else if (sourceFormat   == DXGI_FORMAT_R32G32B32A32_FLOAT &amp;&amp;
-             sourceGLFormat == GL_RGBA32F_EXT &amp;&amp;
-             destFormat     == GL_RGBA &amp;&amp;
-             destType       == GL_FLOAT)
-    {
-        return 16;
-    }
-    else
-    {
-        return 0;
-    }
</del><ins>+    return new TextureStorage11_3D(this, internalformat, renderTarget, width, height, depth, levels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline void readPixelColor(const unsigned char *data, DXGI_FORMAT format, GLenum glFormat, unsigned int x,
-                                  unsigned int y, int inputPitch, gl::Color *outColor)
</del><ins>+TextureStorage *Renderer11::createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels)
</ins><span class="cx"> {
</span><del>-    switch (format)
-    {
-      case DXGI_FORMAT_R8G8B8A8_UNORM:
-        {
-            unsigned int rgba = *reinterpret_cast&lt;const unsigned int*&gt;(data + 4 * x + y * inputPitch);
-            outColor-&gt;red =   (rgba &amp; 0x000000FF) * (1.0f / 0x000000FF);
-            outColor-&gt;green = (rgba &amp; 0x0000FF00) * (1.0f / 0x0000FF00);
-            outColor-&gt;blue =  (rgba &amp; 0x00FF0000) * (1.0f / 0x00FF0000);
-
-            if (gl::GetAlphaSize(glFormat) &gt; 0)
-            {
-                outColor-&gt;alpha = (rgba &amp; 0xFF000000) * (1.0f / 0xFF000000);
-            }
-            else
-            {
-                outColor-&gt;alpha = 1.0f;
-            }
-        }
-        break;
-
-      case DXGI_FORMAT_A8_UNORM:
-        {
-            outColor-&gt;red =   0.0f;
-            outColor-&gt;green = 0.0f;
-            outColor-&gt;blue =  0.0f;
-            outColor-&gt;alpha = *(data + x + y * inputPitch) / 255.0f;
-        }
-        break;
-
-      case DXGI_FORMAT_R32G32B32A32_FLOAT:
-        {
-            outColor-&gt;red =   *(reinterpret_cast&lt;const float*&gt;(data + 16 * x + y * inputPitch) + 0);
-            outColor-&gt;green = *(reinterpret_cast&lt;const float*&gt;(data + 16 * x + y * inputPitch) + 1);
-            outColor-&gt;blue =  *(reinterpret_cast&lt;const float*&gt;(data + 16 * x + y * inputPitch) + 2);
-
-            if (gl::GetAlphaSize(glFormat) &gt; 0)
-            {
-                outColor-&gt;alpha = *(reinterpret_cast&lt;const float*&gt;(data + 16 * x + y * inputPitch) + 3);
-            }
-            else
-            {
-                outColor-&gt;alpha = 1.0f;
-            }
-        }
-        break;
-
-      case DXGI_FORMAT_R32G32B32_FLOAT:
-        {
-            outColor-&gt;red =   *(reinterpret_cast&lt;const float*&gt;(data + 12 * x + y * inputPitch) + 0);
-            outColor-&gt;green = *(reinterpret_cast&lt;const float*&gt;(data + 12 * x + y * inputPitch) + 1);
-            outColor-&gt;blue =  *(reinterpret_cast&lt;const float*&gt;(data + 12 * x + y * inputPitch) + 2);
-            outColor-&gt;alpha = 1.0f;
-        }
-        break;
-
-      case DXGI_FORMAT_R16G16B16A16_FLOAT:
-        {
-            outColor-&gt;red =   gl::float16ToFloat32(*(reinterpret_cast&lt;const unsigned short*&gt;(data + 8 * x + y * inputPitch) + 0));
-            outColor-&gt;green = gl::float16ToFloat32(*(reinterpret_cast&lt;const unsigned short*&gt;(data + 8 * x + y * inputPitch) + 1));
-            outColor-&gt;blue =  gl::float16ToFloat32(*(reinterpret_cast&lt;const unsigned short*&gt;(data + 8 * x + y * inputPitch) + 2));
-
-            if (gl::GetAlphaSize(glFormat) &gt; 0)
-            {
-                outColor-&gt;alpha = gl::float16ToFloat32(*(reinterpret_cast&lt;const unsigned short*&gt;(data + 8 * x + y * inputPitch) + 3));
-            }
-            else
-            {
-                outColor-&gt;alpha = 1.0f;
-            }
-        }
-        break;
-
-      case DXGI_FORMAT_B8G8R8A8_UNORM:
-        {
-            unsigned int bgra = *reinterpret_cast&lt;const unsigned int*&gt;(data + 4 * x + y * inputPitch);
-            outColor-&gt;red =   (bgra &amp; 0x00FF0000) * (1.0f / 0x00FF0000);
-            outColor-&gt;blue =  (bgra &amp; 0x000000FF) * (1.0f / 0x000000FF);
-            outColor-&gt;green = (bgra &amp; 0x0000FF00) * (1.0f / 0x0000FF00);
-            outColor-&gt;alpha = (bgra &amp; 0xFF000000) * (1.0f / 0xFF000000);
-        }
-        break;
-
-      case DXGI_FORMAT_R8_UNORM:
-        {
-            outColor-&gt;red =   *(data + x + y * inputPitch) / 255.0f;
-            outColor-&gt;green = 0.0f;
-            outColor-&gt;blue =  0.0f;
-            outColor-&gt;alpha = 1.0f;
-        }
-        break;
-
-      case DXGI_FORMAT_R8G8_UNORM:
-        {
-            unsigned short rg = *reinterpret_cast&lt;const unsigned short*&gt;(data + 2 * x + y * inputPitch);
-
-            outColor-&gt;red =   (rg &amp; 0xFF00) * (1.0f / 0xFF00);
-            outColor-&gt;green = (rg &amp; 0x00FF) * (1.0f / 0x00FF);
-            outColor-&gt;blue =  0.0f;
-            outColor-&gt;alpha = 1.0f;
-        }
-        break;
-
-      case DXGI_FORMAT_R16_FLOAT:
-        {
-            outColor-&gt;red =   gl::float16ToFloat32(*reinterpret_cast&lt;const unsigned short*&gt;(data + 2 * x + y * inputPitch));
-            outColor-&gt;green = 0.0f;
-            outColor-&gt;blue =  0.0f;
-            outColor-&gt;alpha = 1.0f;
-        }
-        break;
-
-      case DXGI_FORMAT_R16G16_FLOAT:
-        {
-            outColor-&gt;red =   gl::float16ToFloat32(*(reinterpret_cast&lt;const unsigned short*&gt;(data + 4 * x + y * inputPitch) + 0));
-            outColor-&gt;green = gl::float16ToFloat32(*(reinterpret_cast&lt;const unsigned short*&gt;(data + 4 * x + y * inputPitch) + 1));
-            outColor-&gt;blue =  0.0f;
-            outColor-&gt;alpha = 1.0f;
-        }
-        break;
-
-      default:
-        ERR(&quot;ReadPixelColor not implemented for DXGI format %u.&quot;, format);
-        UNIMPLEMENTED();
-        break;
-    }
</del><ins>+    return new TextureStorage11_2DArray(this, internalformat, renderTarget, width, height, depth, levels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline void writePixelColor(const gl::Color &amp;color, GLenum format, GLenum type, unsigned int x,
-                                   unsigned int y, int outputPitch, void *outData)
</del><ins>+void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &amp;area, GLenum format,
+                                 GLenum type, GLuint outputPitch, const gl::PixelPackState &amp;pack, void *pixels)
</ins><span class="cx"> {
</span><del>-    unsigned char* byteData = reinterpret_cast&lt;unsigned char*&gt;(outData);
-    unsigned short* shortData = reinterpret_cast&lt;unsigned short*&gt;(outData);
</del><ins>+    ASSERT(area.width &gt;= 0);
+    ASSERT(area.height &gt;= 0);
</ins><span class="cx"> 
</span><del>-    switch (format)
-    {
-      case GL_RGBA:
-        switch (type)
-        {
-          case GL_UNSIGNED_BYTE:
-            byteData[4 * x + y * outputPitch + 0] = static_cast&lt;unsigned char&gt;(255 * color.red   + 0.5f);
-            byteData[4 * x + y * outputPitch + 1] = static_cast&lt;unsigned char&gt;(255 * color.green + 0.5f);
-            byteData[4 * x + y * outputPitch + 2] = static_cast&lt;unsigned char&gt;(255 * color.blue  + 0.5f);
-            byteData[4 * x + y * outputPitch + 3] = static_cast&lt;unsigned char&gt;(255 * color.alpha + 0.5f);
-            break;
</del><ins>+    D3D11_TEXTURE2D_DESC textureDesc;
+    texture-&gt;GetDesc(&amp;textureDesc);
</ins><span class="cx"> 
</span><del>-          default:
-            ERR(&quot;WritePixelColor not implemented for format GL_RGBA and type 0x%X.&quot;, type);
-            UNIMPLEMENTED();
-            break;
-        }
-        break;
</del><ins>+    // Clamp read region to the defined texture boundaries, preventing out of bounds reads
+    // and reads of uninitialized data.
+    gl::Rectangle safeArea;
+    safeArea.x      = gl::clamp(area.x, 0, static_cast&lt;int&gt;(textureDesc.Width));
+    safeArea.y      = gl::clamp(area.y, 0, static_cast&lt;int&gt;(textureDesc.Height));
+    safeArea.width  = gl::clamp(area.width + std::min(area.x, 0), 0,
+                                static_cast&lt;int&gt;(textureDesc.Width) - safeArea.x);
+    safeArea.height = gl::clamp(area.height + std::min(area.y, 0), 0,
+                                static_cast&lt;int&gt;(textureDesc.Height) - safeArea.y);
</ins><span class="cx"> 
</span><del>-      case GL_BGRA_EXT:
-        switch (type)
-        {
-          case GL_UNSIGNED_BYTE:
-            byteData[4 * x + y * outputPitch + 0] = static_cast&lt;unsigned char&gt;(255 * color.blue  + 0.5f);
-            byteData[4 * x + y * outputPitch + 1] = static_cast&lt;unsigned char&gt;(255 * color.green + 0.5f);
-            byteData[4 * x + y * outputPitch + 2] = static_cast&lt;unsigned char&gt;(255 * color.red   + 0.5f);
-            byteData[4 * x + y * outputPitch + 3] = static_cast&lt;unsigned char&gt;(255 * color.alpha + 0.5f);
-            break;
</del><ins>+    ASSERT(safeArea.x &gt;= 0 &amp;&amp; safeArea.y &gt;= 0);
+    ASSERT(safeArea.x + safeArea.width  &lt;= static_cast&lt;int&gt;(textureDesc.Width));
+    ASSERT(safeArea.y + safeArea.height &lt;= static_cast&lt;int&gt;(textureDesc.Height));
</ins><span class="cx"> 
</span><del>-          case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
-            // According to the desktop GL spec in the &quot;Transfer of Pixel Rectangles&quot; section
-            // this type is packed as follows:
-            //   15   14   13   12   11   10    9    8    7    6    5    4    3    2    1    0
-            //  --------------------------------------------------------------------------------
-            // |       4th         |        3rd         |        2nd        |   1st component   |
-            //  --------------------------------------------------------------------------------
-            // in the case of BGRA_EXT, B is the first component, G the second, and so forth.
-            shortData[x + y * outputPitch / sizeof(unsigned short)] =
-                (static_cast&lt;unsigned short&gt;(15 * color.alpha + 0.5f) &lt;&lt; 12) |
-                (static_cast&lt;unsigned short&gt;(15 * color.red   + 0.5f) &lt;&lt;  8) |
-                (static_cast&lt;unsigned short&gt;(15 * color.green + 0.5f) &lt;&lt;  4) |
-                (static_cast&lt;unsigned short&gt;(15 * color.blue  + 0.5f) &lt;&lt;  0);
-            break;
-
-          case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
-            // According to the desktop GL spec in the &quot;Transfer of Pixel Rectangles&quot; section
-            // this type is packed as follows:
-            //   15   14   13   12   11   10    9    8    7    6    5    4    3    2    1    0
-            //  --------------------------------------------------------------------------------
-            // | 4th |          3rd           |           2nd          |      1st component     |
-            //  --------------------------------------------------------------------------------
-            // in the case of BGRA_EXT, B is the first component, G the second, and so forth.
-            shortData[x + y * outputPitch / sizeof(unsigned short)] =
-                (static_cast&lt;unsigned short&gt;(     color.alpha + 0.5f) &lt;&lt; 15) |
-                (static_cast&lt;unsigned short&gt;(31 * color.red   + 0.5f) &lt;&lt; 10) |
-                (static_cast&lt;unsigned short&gt;(31 * color.green + 0.5f) &lt;&lt;  5) |
-                (static_cast&lt;unsigned short&gt;(31 * color.blue  + 0.5f) &lt;&lt;  0);
-            break;
-
-          default:
-            ERR(&quot;WritePixelColor not implemented for format GL_BGRA_EXT and type 0x%X.&quot;, type);
-            UNIMPLEMENTED();
-            break;
-        }
-        break;
-
-      case GL_RGB:
-        switch (type)
-        {
-          case GL_UNSIGNED_SHORT_5_6_5:
-            shortData[x + y * outputPitch / sizeof(unsigned short)] =
-                (static_cast&lt;unsigned short&gt;(31 * color.blue  + 0.5f) &lt;&lt;  0) |
-                (static_cast&lt;unsigned short&gt;(63 * color.green + 0.5f) &lt;&lt;  5) |
-                (static_cast&lt;unsigned short&gt;(31 * color.red   + 0.5f) &lt;&lt; 11);
-            break;
-
-          case GL_UNSIGNED_BYTE:
-            byteData[3 * x + y * outputPitch + 0] = static_cast&lt;unsigned char&gt;(255 * color.red +   0.5f);
-            byteData[3 * x + y * outputPitch + 1] = static_cast&lt;unsigned char&gt;(255 * color.green + 0.5f);
-            byteData[3 * x + y * outputPitch + 2] = static_cast&lt;unsigned char&gt;(255 * color.blue +  0.5f);
-            break;
-
-          default:
-            ERR(&quot;WritePixelColor not implemented for format GL_RGB and type 0x%X.&quot;, type);
-            UNIMPLEMENTED();
-            break;
-        }
-        break;
-
-      default:
-        ERR(&quot;WritePixelColor not implemented for format 0x%X.&quot;, format);
-        UNIMPLEMENTED();
-        break;
</del><ins>+    if (safeArea.width == 0 || safeArea.height == 0)
+    {
+        // no work to do
+        return;
</ins><span class="cx">     }
</span><del>-}
</del><span class="cx"> 
</span><del>-void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &amp;area,
-                                 GLenum sourceFormat, GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder,
-                                 GLint packAlignment, void *pixels)
-{
-    D3D11_TEXTURE2D_DESC textureDesc;
-    texture-&gt;GetDesc(&amp;textureDesc);
-
</del><span class="cx">     D3D11_TEXTURE2D_DESC stagingDesc;
</span><del>-    stagingDesc.Width = area.width;
-    stagingDesc.Height = area.height;
</del><ins>+    stagingDesc.Width = safeArea.width;
+    stagingDesc.Height = safeArea.height;
</ins><span class="cx">     stagingDesc.MipLevels = 1;
</span><span class="cx">     stagingDesc.ArraySize = 1;
</span><span class="cx">     stagingDesc.Format = textureDesc.Format;
</span><span class="lines">@@ -3411,7 +3378,7 @@
</span><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="cx">             ERR(&quot;Failed to create resolve texture for readPixels, HRESULT: 0x%X.&quot;, result);
</span><del>-            stagingTex-&gt;Release();
</del><ins>+            SafeRelease(stagingTex);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -3425,26 +3392,37 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     D3D11_BOX srcBox;
</span><del>-    srcBox.left = area.x;
-    srcBox.right = area.x + area.width;
-    srcBox.top = area.y;
-    srcBox.bottom = area.y + area.height;
-    srcBox.front = 0;
-    srcBox.back = 1;
</del><ins>+    srcBox.left   = static_cast&lt;UINT&gt;(safeArea.x);
+    srcBox.right  = static_cast&lt;UINT&gt;(safeArea.x + safeArea.width);
+    srcBox.top    = static_cast&lt;UINT&gt;(safeArea.y);
+    srcBox.bottom = static_cast&lt;UINT&gt;(safeArea.y + safeArea.height);
+    srcBox.front  = 0;
+    srcBox.back   = 1;
</ins><span class="cx"> 
</span><span class="cx">     mDeviceContext-&gt;CopySubresourceRegion(stagingTex, 0, 0, 0, 0, srcTex, subResource, &amp;srcBox);
</span><span class="cx"> 
</span><del>-    srcTex-&gt;Release();
-    srcTex = NULL;
</del><ins>+    SafeRelease(srcTex);
</ins><span class="cx"> 
</span><ins>+    PackPixelsParams packParams(safeArea, format, type, outputPitch, pack, 0);
+    packPixels(stagingTex, packParams, pixels);
+
+    SafeRelease(stagingTex);
+}
+
+void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &amp;params, void *pixelsOut)
+{
+    D3D11_TEXTURE2D_DESC textureDesc;
+    readTexture-&gt;GetDesc(&amp;textureDesc);
+
</ins><span class="cx">     D3D11_MAPPED_SUBRESOURCE mapping;
</span><del>-    mDeviceContext-&gt;Map(stagingTex, 0, D3D11_MAP_READ, 0, &amp;mapping);
</del><ins>+    HRESULT hr = mDeviceContext-&gt;Map(readTexture, 0, D3D11_MAP_READ, 0, &amp;mapping);
+    ASSERT(SUCCEEDED(hr));
</ins><span class="cx"> 
</span><span class="cx">     unsigned char *source;
</span><span class="cx">     int inputPitch;
</span><del>-    if (packReverseRowOrder)
</del><ins>+    if (params.pack.reverseRowOrder)
</ins><span class="cx">     {
</span><del>-        source = static_cast&lt;unsigned char*&gt;(mapping.pData) + mapping.RowPitch * (area.height - 1);
</del><ins>+        source = static_cast&lt;unsigned char*&gt;(mapping.pData) + mapping.RowPitch * (params.area.height - 1);
</ins><span class="cx">         inputPitch = -static_cast&lt;int&gt;(mapping.RowPitch);
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="lines">@@ -3453,58 +3431,82 @@
</span><span class="cx">         inputPitch = static_cast&lt;int&gt;(mapping.RowPitch);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned int fastPixelSize = getFastPixelCopySize(textureDesc.Format, sourceFormat, format, type);
-    if (fastPixelSize != 0)
</del><ins>+    GLuint clientVersion = getCurrentClientVersion();
+
+    GLenum sourceInternalFormat = d3d11_gl::GetInternalFormat(textureDesc.Format, clientVersion);
+    GLenum sourceFormat = gl::GetFormat(sourceInternalFormat, clientVersion);
+    GLenum sourceType = gl::GetType(sourceInternalFormat, clientVersion);
+
+    GLuint sourcePixelSize = gl::GetPixelBytes(sourceInternalFormat, clientVersion);
+
+    if (sourceFormat == params.format &amp;&amp; sourceType == params.type)
</ins><span class="cx">     {
</span><del>-        unsigned char *dest = static_cast&lt;unsigned char*&gt;(pixels);
-        for (int j = 0; j &lt; area.height; j++)
</del><ins>+        unsigned char *dest = static_cast&lt;unsigned char*&gt;(pixelsOut) + params.offset;
+        for (int y = 0; y &lt; params.area.height; y++)
</ins><span class="cx">         {
</span><del>-            memcpy(dest + j * outputPitch, source + j * inputPitch, area.width * fastPixelSize);
</del><ins>+            memcpy(dest + y * params.outputPitch, source + y * inputPitch, params.area.width * sourcePixelSize);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else if (textureDesc.Format == DXGI_FORMAT_B8G8R8A8_UNORM &amp;&amp;
-             format == GL_RGBA &amp;&amp;
-             type == GL_UNSIGNED_BYTE)
</del><ins>+    else
</ins><span class="cx">     {
</span><del>-        // Fast path for swapping red with blue
-        unsigned char *dest = static_cast&lt;unsigned char*&gt;(pixels);
</del><ins>+        GLenum destInternalFormat = gl::GetSizedInternalFormat(params.format, params.type, clientVersion);
+        GLuint destPixelSize = gl::GetPixelBytes(destInternalFormat, clientVersion);
</ins><span class="cx"> 
</span><del>-        for (int j = 0; j &lt; area.height; j++)
</del><ins>+        ColorCopyFunction fastCopyFunc = d3d11::GetFastCopyFunction(textureDesc.Format, params.format, params.type);
+        if (fastCopyFunc)
</ins><span class="cx">         {
</span><del>-            for (int i = 0; i &lt; area.width; i++)
</del><ins>+            // Fast copy is possible through some special function
+            for (int y = 0; y &lt; params.area.height; y++)
</ins><span class="cx">             {
</span><del>-                unsigned int argb = *(unsigned int*)(source + 4 * i + j * inputPitch);
-                *(unsigned int*)(dest + 4 * i + j * outputPitch) =
-                    (argb &amp; 0xFF00FF00) |       // Keep alpha and green
-                    (argb &amp; 0x00FF0000) &gt;&gt; 16 | // Move red to blue
-                    (argb &amp; 0x000000FF) &lt;&lt; 16;  // Move blue to red
</del><ins>+                for (int x = 0; x &lt; params.area.width; x++)
+                {
+                    void *dest = static_cast&lt;unsigned char*&gt;(pixelsOut) + params.offset + y * params.outputPitch + x * destPixelSize;
+                    void *src = static_cast&lt;unsigned char*&gt;(source) + y * inputPitch + x * sourcePixelSize;
+
+                    fastCopyFunc(src, dest);
+                }
</ins><span class="cx">             }
</span><span class="cx">         }
</span><del>-    }
-    else
-    {
-        gl::Color pixelColor;
-        for (int j = 0; j &lt; area.height; j++)
</del><ins>+        else
</ins><span class="cx">         {
</span><del>-            for (int i = 0; i &lt; area.width; i++)
</del><ins>+            ColorReadFunction readFunc = d3d11::GetColorReadFunction(textureDesc.Format);
+            ColorWriteFunction writeFunc = gl::GetColorWriteFunction(params.format, params.type, clientVersion);
+
+            unsigned char temp[16]; // Maximum size of any Color&lt;T&gt; type used.
+            META_ASSERT(sizeof(temp) &gt;= sizeof(gl::ColorF)  &amp;&amp;
+                        sizeof(temp) &gt;= sizeof(gl::ColorUI) &amp;&amp;
+                        sizeof(temp) &gt;= sizeof(gl::ColorI));
+
+            for (int y = 0; y &lt; params.area.height; y++)
</ins><span class="cx">             {
</span><del>-                readPixelColor(source, textureDesc.Format, sourceFormat, i, j, inputPitch, &amp;pixelColor);
-                writePixelColor(pixelColor, format, type, i, j, outputPitch, pixels);
</del><ins>+                for (int x = 0; x &lt; params.area.width; x++)
+                {
+                    void *dest = static_cast&lt;unsigned char*&gt;(pixelsOut) + params.offset + y * params.outputPitch + x * destPixelSize;
+                    void *src = static_cast&lt;unsigned char*&gt;(source) + y * inputPitch + x * sourcePixelSize;
+
+                    // readFunc and writeFunc will be using the same type of color, CopyTexImage
+                    // will not allow the copy otherwise.
+                    readFunc(src, temp);
+                    writeFunc(temp, dest);
+                }
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mDeviceContext-&gt;Unmap(stagingTex, 0);
-
-    stagingTex-&gt;Release();
-    stagingTex = NULL;
</del><ins>+    mDeviceContext-&gt;Unmap(readTexture, 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer11::blitRenderbufferRect(const gl::Rectangle &amp;readRect, const gl::Rectangle &amp;drawRect, RenderTarget *readRenderTarget, 
-                                      RenderTarget *drawRenderTarget, bool wholeBufferCopy)
</del><ins>+bool Renderer11::blitRenderbufferRect(const gl::Rectangle &amp;readRect, const gl::Rectangle &amp;drawRect, RenderTarget *readRenderTarget,
+                                      RenderTarget *drawRenderTarget, GLenum filter, const gl::Rectangle *scissor,
+                                      bool colorBlit, bool depthBlit, bool stencilBlit)
</ins><span class="cx"> {
</span><del>-    ASSERT(readRect.width == drawRect.width &amp;&amp; readRect.height == drawRect.height);
</del><ins>+    // Since blitRenderbufferRect is called for each render buffer that needs to be blitted,
+    // it should never be the case that both color and depth/stencil need to be blitted at
+    // at the same time.
+    ASSERT(colorBlit != (depthBlit || stencilBlit));
</ins><span class="cx"> 
</span><ins>+    bool result = true;
+
</ins><span class="cx">     RenderTarget11 *drawRenderTarget11 = RenderTarget11::makeRenderTarget11(drawRenderTarget);
</span><span class="cx">     if (!drawRenderTarget)
</span><span class="cx">     {
</span><span class="lines">@@ -3512,8 +3514,10 @@
</span><span class="cx">         return gl::error(GL_OUT_OF_MEMORY, false);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ID3D11Texture2D *drawTexture = drawRenderTarget11-&gt;getTexture();
</del><ins>+    ID3D11Resource *drawTexture = drawRenderTarget11-&gt;getTexture();
</ins><span class="cx">     unsigned int drawSubresource = drawRenderTarget11-&gt;getSubresourceIndex();
</span><ins>+    ID3D11RenderTargetView *drawRTV = drawRenderTarget11-&gt;getRenderTargetView();
+    ID3D11DepthStencilView *drawDSV = drawRenderTarget11-&gt;getDepthStencilView();
</ins><span class="cx"> 
</span><span class="cx">     RenderTarget11 *readRenderTarget11 = RenderTarget11::makeRenderTarget11(readRenderTarget);
</span><span class="cx">     if (!readRenderTarget)
</span><span class="lines">@@ -3522,44 +3526,152 @@
</span><span class="cx">         return gl::error(GL_OUT_OF_MEMORY, false);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ID3D11Texture2D *readTexture = NULL;
</del><ins>+    ID3D11Resource *readTexture = NULL;
+    ID3D11ShaderResourceView *readSRV = NULL;
</ins><span class="cx">     unsigned int readSubresource = 0;
</span><span class="cx">     if (readRenderTarget-&gt;getSamples() &gt; 0)
</span><span class="cx">     {
</span><del>-        readTexture = resolveMultisampledTexture(readRenderTarget11-&gt;getTexture(), readRenderTarget11-&gt;getSubresourceIndex());
-        readSubresource = 0;
</del><ins>+        ID3D11Resource *unresolvedResource = readRenderTarget11-&gt;getTexture();
+        ID3D11Texture2D *unresolvedTexture = d3d11::DynamicCastComObject&lt;ID3D11Texture2D&gt;(unresolvedResource);
+
+        if (unresolvedTexture)
+        {
+            readTexture = resolveMultisampledTexture(unresolvedTexture, readRenderTarget11-&gt;getSubresourceIndex());
+            readSubresource = 0;
+
+            SafeRelease(unresolvedTexture);
+
+            HRESULT hresult = mDevice-&gt;CreateShaderResourceView(readTexture, NULL, &amp;readSRV);
+            if (FAILED(hresult))
+            {
+                SafeRelease(readTexture);
+                return gl::error(GL_OUT_OF_MEMORY, false);
+            }
+        }
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="cx">         readTexture = readRenderTarget11-&gt;getTexture();
</span><span class="cx">         readTexture-&gt;AddRef();
</span><span class="cx">         readSubresource = readRenderTarget11-&gt;getSubresourceIndex();
</span><ins>+        readSRV = readRenderTarget11-&gt;getShaderResourceView();
+        readSRV-&gt;AddRef();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!readTexture)
</del><ins>+    if (!readTexture || !readSRV)
</ins><span class="cx">     {
</span><ins>+        SafeRelease(readTexture);
+        SafeRelease(readSRV);
</ins><span class="cx">         ERR(&quot;Failed to retrieve the read render target view from the read render target.&quot;);
</span><span class="cx">         return gl::error(GL_OUT_OF_MEMORY, false);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    D3D11_BOX readBox;
-    readBox.left = readRect.x;
-    readBox.right = readRect.x + readRect.width;
-    readBox.top = readRect.y;
-    readBox.bottom = readRect.y + readRect.height;
-    readBox.front = 0;
-    readBox.back = 1;
</del><ins>+    gl::Extents readSize(readRenderTarget-&gt;getWidth(), readRenderTarget-&gt;getHeight(), 1);
+    gl::Extents drawSize(drawRenderTarget-&gt;getWidth(), drawRenderTarget-&gt;getHeight(), 1);
</ins><span class="cx"> 
</span><del>-    // D3D11 needs depth-stencil CopySubresourceRegions to have a NULL pSrcBox
-    // We also require complete framebuffer copies for depth-stencil blit.
-    D3D11_BOX *pSrcBox = wholeBufferCopy ? NULL : &amp;readBox;
</del><ins>+    bool scissorNeeded = scissor &amp;&amp; gl::ClipRectangle(drawRect, *scissor, NULL);
</ins><span class="cx"> 
</span><del>-    mDeviceContext-&gt;CopySubresourceRegion(drawTexture, drawSubresource, drawRect.x, drawRect.y, 0,
-                                          readTexture, readSubresource, pSrcBox);
</del><ins>+    bool wholeBufferCopy = !scissorNeeded &amp;&amp;
+                           readRect.x == 0 &amp;&amp; readRect.width == readSize.width &amp;&amp;
+                           readRect.y == 0 &amp;&amp; readRect.height == readSize.height &amp;&amp;
+                           drawRect.x == 0 &amp;&amp; drawRect.width == drawSize.width &amp;&amp;
+                           drawRect.y == 0 &amp;&amp; drawRect.height == drawSize.height;
</ins><span class="cx"> 
</span><ins>+    bool stretchRequired = readRect.width != drawRect.width || readRect.height != drawRect.height;
+
+    bool flipRequired = readRect.width &lt; 0 || readRect.height &lt; 0 || drawRect.width &lt; 0 || drawRect.height &lt; 0;
+
+    bool outOfBounds = readRect.x &lt; 0 || readRect.x + readRect.width &gt; readSize.width ||
+                       readRect.y &lt; 0 || readRect.y + readRect.height &gt; readSize.height ||
+                       drawRect.x &lt; 0 || drawRect.x + drawRect.width &gt; drawSize.width ||
+                       drawRect.y &lt; 0 || drawRect.y + drawRect.height &gt; drawSize.height;
+
+    bool hasDepth = gl::GetDepthBits(drawRenderTarget11-&gt;getActualFormat(), getCurrentClientVersion()) &gt; 0;
+    bool hasStencil = gl::GetStencilBits(drawRenderTarget11-&gt;getActualFormat(), getCurrentClientVersion()) &gt; 0;
+    bool partialDSBlit = (hasDepth &amp;&amp; depthBlit) != (hasStencil &amp;&amp; stencilBlit);
+
+    if (readRenderTarget11-&gt;getActualFormat() == drawRenderTarget-&gt;getActualFormat() &amp;&amp;
+        !stretchRequired &amp;&amp; !outOfBounds &amp;&amp; !flipRequired &amp;&amp; !partialDSBlit &amp;&amp;
+        (!(depthBlit || stencilBlit) || wholeBufferCopy))
+    {
+        UINT dstX = drawRect.x;
+        UINT dstY = drawRect.y;
+
+        D3D11_BOX readBox;
+        readBox.left = readRect.x;
+        readBox.right = readRect.x + readRect.width;
+        readBox.top = readRect.y;
+        readBox.bottom = readRect.y + readRect.height;
+        readBox.front = 0;
+        readBox.back = 1;
+
+        if (scissorNeeded)
+        {
+            // drawRect is guaranteed to have positive width and height because stretchRequired is false.
+            ASSERT(drawRect.width &gt;= 0 || drawRect.height &gt;= 0);
+
+            if (drawRect.x &lt; scissor-&gt;x)
+            {
+                dstX = scissor-&gt;x;
+                readBox.left += (scissor-&gt;x - drawRect.x);
+            }
+            if (drawRect.y &lt; scissor-&gt;y)
+            {
+                dstY = scissor-&gt;y;
+                readBox.top += (scissor-&gt;y - drawRect.y);
+            }
+            if (drawRect.x + drawRect.width &gt; scissor-&gt;x + scissor-&gt;width)
+            {
+                readBox.right -= ((drawRect.x + drawRect.width) - (scissor-&gt;x + scissor-&gt;width));
+            }
+            if (drawRect.y + drawRect.height &gt; scissor-&gt;y + scissor-&gt;height)
+            {
+                readBox.bottom -= ((drawRect.y + drawRect.height) - (scissor-&gt;y + scissor-&gt;height));
+            }
+        }
+
+        // D3D11 needs depth-stencil CopySubresourceRegions to have a NULL pSrcBox
+        // We also require complete framebuffer copies for depth-stencil blit.
+        D3D11_BOX *pSrcBox = wholeBufferCopy ? NULL : &amp;readBox;
+
+        mDeviceContext-&gt;CopySubresourceRegion(drawTexture, drawSubresource, dstX, dstY, 0,
+                                              readTexture, readSubresource, pSrcBox);
+        result = true;
+    }
+    else
+    {
+        gl::Box readArea(readRect.x, readRect.y, 0, readRect.width, readRect.height, 1);
+        gl::Box drawArea(drawRect.x, drawRect.y, 0, drawRect.width, drawRect.height, 1);
+
+        if (depthBlit &amp;&amp; stencilBlit)
+        {
+            result = mBlit-&gt;copyDepthStencil(readTexture, readSubresource, readArea, readSize,
+                                             drawTexture, drawSubresource, drawArea, drawSize,
+                                             scissor);
+        }
+        else if (depthBlit)
+        {
+            result = mBlit-&gt;copyDepth(readSRV, readArea, readSize, drawDSV, drawArea, drawSize,
+                                      scissor);
+        }
+        else if (stencilBlit)
+        {
+            result = mBlit-&gt;copyStencil(readTexture, readSubresource, readArea, readSize,
+                                        drawTexture, drawSubresource, drawArea, drawSize,
+                                        scissor);
+        }
+        else
+        {
+            GLenum format = gl::GetFormat(drawRenderTarget-&gt;getInternalFormat(), getCurrentClientVersion());
+            result = mBlit-&gt;copyTexture(readSRV, readArea, readSize, drawRTV, drawArea, drawSize,
+                                        scissor, format, filter);
+        }
+    }
+
</ins><span class="cx">     SafeRelease(readTexture);
</span><ins>+    SafeRelease(readSRV);
</ins><span class="cx"> 
</span><del>-    return true;
</del><ins>+    return result;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ID3D11Texture2D *Renderer11::resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource)
</span><span class="lines">@@ -3600,6 +3712,46 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Renderer11::invalidateRenderbufferSwizzles(gl::Renderbuffer *renderBuffer, int mipLevel)
+{
+    TextureStorage *texStorage = renderBuffer-&gt;getTextureStorage();
+    if (texStorage)
+    {
+        TextureStorage11 *texStorage11 = TextureStorage11::makeTextureStorage11(texStorage);
+        if (!texStorage11)
+        {
+            ERR(&quot;texture storage pointer unexpectedly null.&quot;);
+            return;
+        }
+
+        texStorage11-&gt;invalidateSwizzleCacheLevel(mipLevel);
+    }
+}
+
+void Renderer11::invalidateFramebufferSwizzles(gl::Framebuffer *framebuffer)
+{
+    for (unsigned int colorAttachment = 0; colorAttachment &lt; gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
+    {
+        gl::Renderbuffer *colorbuffer = framebuffer-&gt;getColorbuffer(colorAttachment);
+        if (colorbuffer)
+        {
+            invalidateRenderbufferSwizzles(colorbuffer, framebuffer-&gt;getColorbufferMipLevel(colorAttachment));
+        }
+    }
+
+    gl::Renderbuffer *depthBuffer = framebuffer-&gt;getDepthbuffer();
+    if (depthBuffer)
+    {
+        invalidateRenderbufferSwizzles(depthBuffer, framebuffer-&gt;getDepthbufferMipLevel());
+    }
+
+    gl::Renderbuffer *stencilBuffer = framebuffer-&gt;getStencilbuffer();
+    if (stencilBuffer)
+    {
+        invalidateRenderbufferSwizzles(stencilBuffer, framebuffer-&gt;getStencilbufferMipLevel());
+    }
+}
+
</ins><span class="cx"> bool Renderer11::getLUID(LUID *adapterLuid) const
</span><span class="cx"> {
</span><span class="cx">     adapterLuid-&gt;HighPart = 0;
</span><span class="lines">@@ -3620,4 +3772,47 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLenum Renderer11::getNativeTextureFormat(GLenum internalFormat) const
+{
+    int clientVersion = getCurrentClientVersion();
+    return d3d11_gl::GetInternalFormat(gl_d3d11::GetTexFormat(internalFormat, clientVersion), clientVersion);
</ins><span class="cx"> }
</span><ins>+
+rx::VertexConversionType Renderer11::getVertexConversionType(const gl::VertexFormat &amp;vertexFormat) const
+{
+    return gl_d3d11::GetVertexConversionType(vertexFormat);
+}
+
+GLenum Renderer11::getVertexComponentType(const gl::VertexFormat &amp;vertexFormat) const
+{
+    return d3d11::GetComponentType(gl_d3d11::GetNativeVertexFormat(vertexFormat));
+}
+
+Renderer11::MultisampleSupportInfo Renderer11::getMultisampleSupportInfo(DXGI_FORMAT format)
+{
+    MultisampleSupportInfo supportInfo = { 0 };
+
+    UINT formatSupport;
+    HRESULT result;
+
+    result = mDevice-&gt;CheckFormatSupport(format, &amp;formatSupport);
+    if (SUCCEEDED(result) &amp;&amp; (formatSupport &amp; D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET))
+    {
+        for (unsigned int i = 1; i &lt;= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; i++)
+        {
+            result = mDevice-&gt;CheckMultisampleQualityLevels(format, i, &amp;supportInfo.qualityLevels[i - 1]);
+            if (SUCCEEDED(result) &amp;&amp; supportInfo.qualityLevels[i - 1] &gt; 0)
+            {
+                supportInfo.maxSupportedSamples = std::max(supportInfo.maxSupportedSamples, i);
+            }
+            else
+            {
+                supportInfo.qualityLevels[i - 1] = 0;
+            }
+        }
+    }
+
+    return supportInfo;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11Renderer11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Renderer11.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Renderer11.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Renderer11.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -11,9 +11,10 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/angletypes.h&quot;
</span><del>-#include &quot;libGLESv2/mathutil.h&quot;
</del><ins>+#include &quot;common/mathutil.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d/HLSLCompiler.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/RenderStateCache.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/InputLayoutCache.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/RenderTarget.h&quot;
</span><span class="lines">@@ -29,6 +30,10 @@
</span><span class="cx"> class VertexDataManager;
</span><span class="cx"> class IndexDataManager;
</span><span class="cx"> class StreamingIndexBufferInterface;
</span><ins>+class Blit11;
+class Clear11;
+class PixelTransfer11;
+struct PackPixelsParams;
</ins><span class="cx"> 
</span><span class="cx"> enum
</span><span class="cx"> {
</span><span class="lines">@@ -54,11 +59,14 @@
</span><span class="cx"> 
</span><span class="cx">     virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
</span><span class="cx"> 
</span><ins>+    virtual void generateSwizzle(gl::Texture *texture);
</ins><span class="cx">     virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &amp;sampler);
</span><span class="cx">     virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
</span><span class="cx"> 
</span><ins>+    virtual bool setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]);
+
</ins><span class="cx">     virtual void setRasterizerState(const gl::RasterizerState &amp;rasterState);
</span><del>-    virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::Color &amp;blendColor,
</del><ins>+    virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::ColorF &amp;blendColor,
</ins><span class="cx">                                unsigned int sampleMask);
</span><span class="cx">     virtual void setDepthStencilState(const gl::DepthStencilState &amp;depthStencilState, int stencilRef,
</span><span class="cx">                                       int stencilBackRef, bool frontFaceCCW);
</span><span class="lines">@@ -69,13 +77,16 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool applyPrimitiveType(GLenum mode, GLsizei count);
</span><span class="cx">     virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer);
</span><del>-    virtual void applyShaders(gl::ProgramBinary *programBinary);
-    virtual void applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray *uniformArray);
-    virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances);
</del><ins>+    virtual void applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[]);
+    virtual void applyUniforms(const gl::ProgramBinary &amp;programBinary);
+    virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
+                                     GLint first, GLsizei count, GLsizei instances);
</ins><span class="cx">     virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
</span><ins>+    virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]);
</ins><span class="cx"> 
</span><del>-    virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances);
-    virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei instances);
</del><ins>+    virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive);
+    virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
+                              gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei instances);
</ins><span class="cx"> 
</span><span class="cx">     virtual void clear(const gl::ClearParameters &amp;clearParams, gl::Framebuffer *frameBuffer);
</span><span class="cx"> 
</span><span class="lines">@@ -93,14 +104,20 @@
</span><span class="cx">     virtual GUID getAdapterIdentifier() const;
</span><span class="cx"> 
</span><span class="cx">     virtual bool getBGRATextureSupport() const;
</span><del>-    virtual bool getDXT1TextureSupport();
-    virtual bool getDXT3TextureSupport();
-    virtual bool getDXT5TextureSupport();
-    virtual bool getEventQuerySupport();
-    virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable);
-    virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable);
-    virtual bool getLuminanceTextureSupport();
-    virtual bool getLuminanceAlphaTextureSupport();
</del><ins>+    virtual bool getDXT1TextureSupport() const;
+    virtual bool getDXT3TextureSupport() const;
+    virtual bool getDXT5TextureSupport() const;
+    virtual bool getEventQuerySupport() const;
+    virtual bool getFloat32TextureSupport() const;
+    virtual bool getFloat32TextureFilteringSupport() const;
+    virtual bool getFloat32TextureRenderingSupport() const;
+    virtual bool getFloat16TextureSupport() const;
+    virtual bool getFloat16TextureFilteringSupport() const;
+    virtual bool getFloat16TextureRenderingSupport() const;
+    virtual bool getRGB565TextureSupport() const;
+    virtual bool getLuminanceTextureSupport() const;
+    virtual bool getLuminanceAlphaTextureSupport() const;
+    virtual bool getRGTextureSupport() const;
</ins><span class="cx">     virtual unsigned int getMaxVertexTextureImageUnits() const;
</span><span class="cx">     virtual unsigned int getMaxCombinedTextureImageUnits() const;
</span><span class="cx">     virtual unsigned int getReservedVertexUniformVectors() const;
</span><span class="lines">@@ -108,26 +125,43 @@
</span><span class="cx">     virtual unsigned int getMaxVertexUniformVectors() const;
</span><span class="cx">     virtual unsigned int getMaxFragmentUniformVectors() const;
</span><span class="cx">     virtual unsigned int getMaxVaryingVectors() const;
</span><ins>+    virtual unsigned int getMaxVertexShaderUniformBuffers() const;
+    virtual unsigned int getMaxFragmentShaderUniformBuffers() const;
+    virtual unsigned int getReservedVertexUniformBuffers() const;
+    virtual unsigned int getReservedFragmentUniformBuffers() const;
+    unsigned int getReservedVaryings() const;
+    virtual unsigned int getMaxTransformFeedbackBuffers() const;
+    virtual unsigned int getMaxTransformFeedbackSeparateComponents() const;
+    virtual unsigned int getMaxTransformFeedbackInterleavedComponents() const;
+    virtual unsigned int getMaxUniformBufferSize() const;
</ins><span class="cx">     virtual bool getNonPower2TextureSupport() const;
</span><span class="cx">     virtual bool getDepthTextureSupport() const;
</span><span class="cx">     virtual bool getOcclusionQuerySupport() const;
</span><span class="cx">     virtual bool getInstancingSupport() const;
</span><span class="cx">     virtual bool getTextureFilterAnisotropySupport() const;
</span><ins>+    virtual bool getPBOSupport() const;
</ins><span class="cx">     virtual float getTextureMaxAnisotropy() const;
</span><span class="cx">     virtual bool getShareHandleSupport() const;
</span><span class="cx">     virtual bool getDerivativeInstructionSupport() const;
</span><span class="cx">     virtual bool getPostSubBufferSupport() const;
</span><ins>+    virtual int getMaxRecommendedElementsIndices() const;
+    virtual int getMaxRecommendedElementsVertices() const;
</ins><span class="cx"> 
</span><span class="cx">     virtual int getMajorShaderModel() const;
</span><span class="cx">     virtual float getMaxPointSize() const;
</span><span class="cx">     virtual int getMaxViewportDimension() const;
</span><span class="cx">     virtual int getMaxTextureWidth() const;
</span><span class="cx">     virtual int getMaxTextureHeight() const;
</span><ins>+    virtual int getMaxTextureDepth() const;
+    virtual int getMaxTextureArrayLayers() const;
</ins><span class="cx">     virtual bool get32BitIndexSupport() const;
</span><span class="cx">     virtual int getMinSwapInterval() const;
</span><span class="cx">     virtual int getMaxSwapInterval() const;
</span><span class="cx"> 
</span><span class="cx">     virtual GLsizei getMaxSupportedSamples() const;
</span><ins>+    virtual GLsizei getMaxSupportedFormatSamples(GLenum internalFormat) const;
+    virtual GLsizei getNumSampleCounts(GLenum internalFormat) const;
+    virtual void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const;
</ins><span class="cx">     int getNearestSupportedSamples(DXGI_FORMAT format, unsigned int requested) const;
</span><span class="cx"> 
</span><span class="cx">     virtual unsigned int getMaxRenderTargets() const;
</span><span class="lines">@@ -135,34 +169,44 @@
</span><span class="cx">     // Pixel operations
</span><span class="cx">     virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source);
</span><span class="cx">     virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source);
</span><ins>+    virtual bool copyToRenderTarget(TextureStorageInterface3D *dest, TextureStorageInterface3D *source);
+    virtual bool copyToRenderTarget(TextureStorageInterface2DArray *dest, TextureStorageInterface2DArray *source);
</ins><span class="cx"> 
</span><span class="cx">     virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
</span><span class="cx">                            GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level);
</span><span class="cx">     virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
</span><span class="cx">                            GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level);
</span><ins>+    virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                           GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface3D *storage, GLint level);
+    virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                           GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface2DArray *storage, GLint level);
</ins><span class="cx"> 
</span><del>-    bool copyTexture(ID3D11ShaderResourceView *source, const gl::Rectangle &amp;sourceArea, unsigned int sourceWidth, unsigned int sourceHeight,
-                     ID3D11RenderTargetView *dest, const gl::Rectangle &amp;destArea, unsigned int destWidth, unsigned int destHeight, GLenum destFormat);
-
</del><span class="cx">     virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &amp;readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &amp;drawRect,
</span><del>-                          bool blitRenderTarget, bool blitDepthStencil);
-    virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
-                            GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels);
</del><ins>+                          const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
+    virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
+                            GLenum type, GLuint outputPitch, const gl::PixelPackState &amp;pack, void* pixels);
</ins><span class="cx"> 
</span><span class="cx">     // RenderTarget creation
</span><span class="cx">     virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
</span><del>-    virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth);
</del><ins>+    virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples);
</ins><span class="cx"> 
</span><span class="cx">     // Shader operations
</span><del>-    virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type);
-    virtual ShaderExecutable *compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround);
</del><ins>+    virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type,
+                                             const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                             bool separatedOutputBuffers);
+    virtual ShaderExecutable *compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type,
+                                                  const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                                  bool separatedOutputBuffers, D3DWorkaroundType workaround);
+    virtual UniformStorage *createUniformStorage(size_t storageSize);
</ins><span class="cx"> 
</span><span class="cx">     // Image operations
</span><span class="cx">     virtual Image *createImage();
</span><span class="cx">     virtual void generateMipmap(Image *dest, Image *source);
</span><span class="cx">     virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain);
</span><del>-    virtual TextureStorage *createTextureStorage2D(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height);
-    virtual TextureStorage *createTextureStorageCube(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size);
</del><ins>+    virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
+    virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels);
+    virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
+    virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
</ins><span class="cx"> 
</span><span class="cx">     // Buffer creation
</span><span class="cx">     virtual VertexBuffer *createVertexBuffer();
</span><span class="lines">@@ -178,11 +222,22 @@
</span><span class="cx">     ID3D11DeviceContext *getDeviceContext() { return mDeviceContext; };
</span><span class="cx">     IDXGIFactory *getDxgiFactory() { return mDxgiFactory; };
</span><span class="cx"> 
</span><ins>+    Blit11 *getBlitter() { return mBlit; }
+
+    // Buffer-to-texture and Texture-to-buffer copies
+    virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const;
+    virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &amp;unpack, unsigned int offset, RenderTarget *destRenderTarget,
+                                         GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &amp;destArea);
+
</ins><span class="cx">     bool getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource);
</span><span class="cx">     void unapplyRenderTargets();
</span><span class="cx">     void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView);
</span><ins>+    void packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &amp;params, void *pixelsOut);
</ins><span class="cx"> 
</span><span class="cx">     virtual bool getLUID(LUID *adapterLuid) const;
</span><ins>+    virtual GLenum getNativeTextureFormat(GLenum internalFormat) const;
+    virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &amp;vertexFormat) const;
+    virtual GLenum getVertexComponentType(const gl::VertexFormat &amp;vertexFormat) const;
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Renderer11);
</span><span class="lines">@@ -190,21 +245,25 @@
</span><span class="cx">     void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
</span><span class="cx">     void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
</span><span class="cx"> 
</span><del>-    void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &amp;area,
-                         GLenum sourceFormat, GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder,
-                         GLint packAlignment, void *pixels);
</del><ins>+    void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &amp;area, GLenum format,
+                         GLenum type, GLuint outputPitch, const gl::PixelPackState &amp;pack, void *pixels);
</ins><span class="cx"> 
</span><del>-    void maskedClear(const gl::ClearParameters &amp;clearParams, gl::Framebuffer *frameBuffer);
</del><span class="cx">     rx::Range getViewportBounds() const;
</span><span class="cx"> 
</span><del>-    bool blitRenderbufferRect(const gl::Rectangle &amp;readRect, const gl::Rectangle &amp;drawRect, RenderTarget *readRenderTarget, 
-                              RenderTarget *drawRenderTarget, bool wholeBufferCopy);
</del><ins>+    bool blitRenderbufferRect(const gl::Rectangle &amp;readRect, const gl::Rectangle &amp;drawRect, RenderTarget *readRenderTarget,
+                              RenderTarget *drawRenderTarget, GLenum filter, const gl::Rectangle *scissor,
+                              bool colorBlit, bool depthBlit, bool stencilBlit);
</ins><span class="cx">     ID3D11Texture2D *resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource);
</span><span class="cx"> 
</span><ins>+    static void invalidateRenderbufferSwizzles(gl::Renderbuffer *renderBuffer, int mipLevel);
+    static void invalidateFramebufferSwizzles(gl::Framebuffer *framebuffer);
+
</ins><span class="cx">     HMODULE mD3d11Module;
</span><span class="cx">     HMODULE mDxgiModule;
</span><span class="cx">     HDC mDc;
</span><span class="cx"> 
</span><ins>+    HLSLCompiler mCompiler;
+
</ins><span class="cx">     bool mDeviceLost;
</span><span class="cx"> 
</span><span class="cx">     void initializeDevice();
</span><span class="lines">@@ -227,15 +286,19 @@
</span><span class="cx">     bool mDXT3TextureSupport;
</span><span class="cx">     bool mDXT5TextureSupport;
</span><span class="cx"> 
</span><ins>+    bool mRGTextureSupport;
+
</ins><span class="cx">     bool mDepthTextureSupport;
</span><span class="cx"> 
</span><span class="cx">     // Multisample format support
</span><span class="cx">     struct MultisampleSupportInfo
</span><span class="cx">     {
</span><span class="cx">         unsigned int qualityLevels[D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT];
</span><ins>+        unsigned int maxSupportedSamples;
</ins><span class="cx">     };
</span><ins>+    MultisampleSupportInfo getMultisampleSupportInfo(DXGI_FORMAT format);
</ins><span class="cx"> 
</span><del>-    typedef std::unordered_map&lt;DXGI_FORMAT, MultisampleSupportInfo, std::hash&lt;int&gt; &gt; MultisampleSupportMap;
</del><ins>+    typedef std::unordered_map&lt;DXGI_FORMAT, MultisampleSupportInfo&gt; MultisampleSupportMap;
</ins><span class="cx">     MultisampleSupportMap mMultisampleSupportMap;
</span><span class="cx"> 
</span><span class="cx">     unsigned int mMaxSupportedSamples;
</span><span class="lines">@@ -258,13 +321,13 @@
</span><span class="cx">     gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
</span><span class="cx"> 
</span><span class="cx">     // Currently applied textures
</span><del>-    unsigned int mCurVertexTextureSerials[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
-    unsigned int mCurPixelTextureSerials[gl::MAX_TEXTURE_IMAGE_UNITS];
</del><ins>+    ID3D11ShaderResourceView *mCurVertexSRVs[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
+    ID3D11ShaderResourceView *mCurPixelSRVs[gl::MAX_TEXTURE_IMAGE_UNITS];
</ins><span class="cx"> 
</span><span class="cx">     // Currently applied blend state
</span><span class="cx">     bool mForceSetBlendState;
</span><span class="cx">     gl::BlendState mCurBlendState;
</span><del>-    gl::Color mCurBlendColor;
</del><ins>+    gl::ColorF mCurBlendColor;
</ins><span class="cx">     unsigned int mCurSampleMask;
</span><span class="cx"> 
</span><span class="cx">     // Currently applied rasterizer state
</span><span class="lines">@@ -291,22 +354,32 @@
</span><span class="cx">     // Currently applied primitive topology
</span><span class="cx">     D3D11_PRIMITIVE_TOPOLOGY mCurrentPrimitiveTopology;
</span><span class="cx"> 
</span><del>-    unsigned int mAppliedIBSerial;
-    unsigned int mAppliedStorageIBSerial;
</del><ins>+    // Currently applied index buffer
+    ID3D11Buffer *mAppliedIB;
+    DXGI_FORMAT mAppliedIBFormat;
</ins><span class="cx">     unsigned int mAppliedIBOffset;
</span><span class="cx"> 
</span><del>-    unsigned int mAppliedProgramBinarySerial;
-    bool mIsGeometryShaderActive;
</del><ins>+    // Currently applied transform feedback buffers
+    ID3D11Buffer *mAppliedTFBuffers[gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
+    GLintptr mAppliedTFOffsets[gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
</ins><span class="cx"> 
</span><ins>+    // Currently applied shaders
+    ID3D11VertexShader *mAppliedVertexShader;
+    ID3D11GeometryShader *mAppliedGeometryShader;
+    ID3D11GeometryShader *mCurPointGeometryShader;
+    ID3D11PixelShader *mAppliedPixelShader;
+
</ins><span class="cx">     dx_VertexConstants mVertexConstants;
</span><span class="cx">     dx_VertexConstants mAppliedVertexConstants;
</span><span class="cx">     ID3D11Buffer *mDriverConstantBufferVS;
</span><span class="cx">     ID3D11Buffer *mCurrentVertexConstantBuffer;
</span><ins>+    unsigned int mCurrentConstantBufferVS[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS];
</ins><span class="cx"> 
</span><span class="cx">     dx_PixelConstants mPixelConstants;
</span><span class="cx">     dx_PixelConstants mAppliedPixelConstants;
</span><span class="cx">     ID3D11Buffer *mDriverConstantBufferPS;
</span><span class="cx">     ID3D11Buffer *mCurrentPixelConstantBuffer;
</span><ins>+    unsigned int mCurrentConstantBufferPS[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS];
</ins><span class="cx"> 
</span><span class="cx">     ID3D11Buffer *mCurrentGeometryConstantBuffer;
</span><span class="cx"> 
</span><span class="lines">@@ -319,25 +392,11 @@
</span><span class="cx">     StreamingIndexBufferInterface *mTriangleFanIB;
</span><span class="cx"> 
</span><span class="cx">     // Texture copy resources
</span><del>-    bool mCopyResourcesInitialized;
-    ID3D11Buffer *mCopyVB;
-    ID3D11SamplerState *mCopySampler;
-    ID3D11InputLayout *mCopyIL;
-    ID3D11VertexShader *mCopyVS;
-    ID3D11PixelShader *mCopyRGBAPS;
-    ID3D11PixelShader *mCopyRGBPS;
-    ID3D11PixelShader *mCopyLumPS;
-    ID3D11PixelShader *mCopyLumAlphaPS;
</del><ins>+    Blit11 *mBlit;
+    PixelTransfer11 *mPixelTransfer;
</ins><span class="cx"> 
</span><span class="cx">     // Masked clear resources
</span><del>-    bool mClearResourcesInitialized;
-    ID3D11Buffer *mClearVB;
-    ID3D11InputLayout *mClearIL;
-    ID3D11VertexShader *mClearVS;
-    ID3D11PixelShader *mClearSinglePS;
-    ID3D11PixelShader *mClearMultiplePS;
-    ID3D11RasterizerState *mClearScissorRS;
-    ID3D11RasterizerState *mClearNoScissorRS;
</del><ins>+    Clear11 *mClear;
</ins><span class="cx"> 
</span><span class="cx">     // Sync query
</span><span class="cx">     ID3D11Query *mSyncQuery;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11ShaderExecutable11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -10,7 +10,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/ShaderExecutable11.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;common/debug.h&quot;
</del><ins>+#include &quot;libGLESv2/renderer/d3d11/Renderer11.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -21,18 +21,16 @@
</span><span class="cx">     mPixelExecutable = executable;
</span><span class="cx">     mVertexExecutable = NULL;
</span><span class="cx">     mGeometryExecutable = NULL;
</span><del>-
-    mConstantBuffer = NULL;
</del><ins>+    mStreamOutExecutable = NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11VertexShader *executable)
</del><ins>+ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11VertexShader *executable, ID3D11GeometryShader *streamOut)
</ins><span class="cx">     : ShaderExecutable(function, length)
</span><span class="cx"> {
</span><span class="cx">     mVertexExecutable = executable;
</span><span class="cx">     mPixelExecutable = NULL;
</span><span class="cx">     mGeometryExecutable = NULL;
</span><del>-
-    mConstantBuffer = NULL;
</del><ins>+    mStreamOutExecutable = streamOut;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11GeometryShader *executable)
</span><span class="lines">@@ -41,29 +39,15 @@
</span><span class="cx">     mGeometryExecutable = executable;
</span><span class="cx">     mVertexExecutable = NULL;
</span><span class="cx">     mPixelExecutable = NULL;
</span><del>-
-    mConstantBuffer = NULL;
</del><ins>+    mStreamOutExecutable = NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ShaderExecutable11::~ShaderExecutable11()
</span><span class="cx"> {
</span><del>-    if (mVertexExecutable)
-    {
-        mVertexExecutable-&gt;Release();
-    }
-    if (mPixelExecutable)
-    {
-        mPixelExecutable-&gt;Release();
-    }
-    if (mGeometryExecutable)
-    {
-        mGeometryExecutable-&gt;Release();
-    }
-    
-    if (mConstantBuffer)
-    {
-        mConstantBuffer-&gt;Release();
-    }
</del><ins>+    SafeRelease(mVertexExecutable);
+    SafeRelease(mPixelExecutable);
+    SafeRelease(mGeometryExecutable);
+    SafeRelease(mStreamOutExecutable);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ShaderExecutable11 *ShaderExecutable11::makeShaderExecutable11(ShaderExecutable *executable)
</span><span class="lines">@@ -87,23 +71,41 @@
</span><span class="cx">     return mGeometryExecutable;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ID3D11Buffer *ShaderExecutable11::getConstantBuffer(ID3D11Device *device, unsigned int registerCount)
</del><ins>+ID3D11GeometryShader *ShaderExecutable11::getStreamOutShader() const
</ins><span class="cx"> {
</span><del>-    if (!mConstantBuffer &amp;&amp; registerCount &gt; 0)
</del><ins>+    return mStreamOutExecutable;
+}
+
+UniformStorage11::UniformStorage11(Renderer11 *renderer, size_t initialSize)
+    : UniformStorage(initialSize),
+      mConstantBuffer(NULL)
+{
+    ID3D11Device *d3d11Device = renderer-&gt;getDevice();
+
+    if (initialSize &gt; 0)
</ins><span class="cx">     {
</span><span class="cx">         D3D11_BUFFER_DESC constantBufferDescription = {0};
</span><del>-        constantBufferDescription.ByteWidth = registerCount * sizeof(float[4]);
</del><ins>+        constantBufferDescription.ByteWidth = initialSize;
</ins><span class="cx">         constantBufferDescription.Usage = D3D11_USAGE_DYNAMIC;
</span><span class="cx">         constantBufferDescription.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
</span><span class="cx">         constantBufferDescription.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
</span><span class="cx">         constantBufferDescription.MiscFlags = 0;
</span><span class="cx">         constantBufferDescription.StructureByteStride = 0;
</span><span class="cx"> 
</span><del>-        HRESULT result = device-&gt;CreateBuffer(&amp;constantBufferDescription, NULL, &amp;mConstantBuffer);
</del><ins>+        HRESULT result = d3d11Device-&gt;CreateBuffer(&amp;constantBufferDescription, NULL, &amp;mConstantBuffer);
</ins><span class="cx">         ASSERT(SUCCEEDED(result));
</span><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    return mConstantBuffer;
</del><ins>+UniformStorage11::~UniformStorage11()
+{
+    SafeRelease(mConstantBuffer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+const UniformStorage11 *UniformStorage11::makeUniformStorage11(const UniformStorage *uniformStorage)
+{
+    ASSERT(HAS_DYNAMIC_TYPE(const UniformStorage11*, uniformStorage));
+    return static_cast&lt;const UniformStorage11*&gt;(uniformStorage);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11ShaderExecutable11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/ShaderExecutable11.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/ShaderExecutable11.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/ShaderExecutable11.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -14,12 +14,14 @@
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><ins>+class Renderer11;
+class UniformStorage11;
</ins><span class="cx"> 
</span><span class="cx"> class ShaderExecutable11 : public ShaderExecutable
</span><span class="cx"> {
</span><span class="cx">   public:
</span><span class="cx">     ShaderExecutable11(const void *function, size_t length, ID3D11PixelShader *executable);
</span><del>-    ShaderExecutable11(const void *function, size_t length, ID3D11VertexShader *executable);
</del><ins>+    ShaderExecutable11(const void *function, size_t length, ID3D11VertexShader *executable, ID3D11GeometryShader *streamOut);
</ins><span class="cx">     ShaderExecutable11(const void *function, size_t length, ID3D11GeometryShader *executable);
</span><span class="cx"> 
</span><span class="cx">     virtual ~ShaderExecutable11();
</span><span class="lines">@@ -29,16 +31,28 @@
</span><span class="cx">     ID3D11PixelShader *getPixelShader() const;
</span><span class="cx">     ID3D11VertexShader *getVertexShader() const;
</span><span class="cx">     ID3D11GeometryShader *getGeometryShader() const;
</span><ins>+    ID3D11GeometryShader *getStreamOutShader() const;
</ins><span class="cx"> 
</span><del>-    ID3D11Buffer *getConstantBuffer(ID3D11Device *device, unsigned int registerCount);
-
</del><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(ShaderExecutable11);
</span><span class="cx"> 
</span><span class="cx">     ID3D11PixelShader *mPixelExecutable;
</span><span class="cx">     ID3D11VertexShader *mVertexExecutable;
</span><span class="cx">     ID3D11GeometryShader *mGeometryExecutable;
</span><ins>+    ID3D11GeometryShader *mStreamOutExecutable;
+};
</ins><span class="cx"> 
</span><ins>+class UniformStorage11 : public UniformStorage
+{
+  public:
+    UniformStorage11(Renderer11 *renderer, size_t initialSize);
+    virtual ~UniformStorage11();
+
+    static const UniformStorage11 *makeUniformStorage11(const UniformStorage *uniformStorage);
+
+    ID3D11Buffer *getConstantBuffer() const { return mConstantBuffer; }
+
+  private:
</ins><span class="cx">     ID3D11Buffer *mConstantBuffer;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11SwapChain11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/SwapChain11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/SwapChain11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/SwapChain11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -10,11 +10,11 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/SwapChain11.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/renderer11_utils.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d11/formatutils11.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Renderer11.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h&quot;
+#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h&quot;
</ins><span class="cx"> 
</span><del>-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/passthrough11vs.h&quot;
-#include &quot;libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba11ps.h&quot;
-
</del><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx">     mOffscreenSRView = NULL;
</span><span class="cx">     mDepthStencilTexture = NULL;
</span><span class="cx">     mDepthStencilDSView = NULL;
</span><ins>+    mDepthStencilSRView = NULL;
</ins><span class="cx">     mQuadVB = NULL;
</span><span class="cx">     mPassThroughSampler = NULL;
</span><span class="cx">     mPassThroughIL = NULL;
</span><span class="lines">@@ -57,6 +58,7 @@
</span><span class="cx">     SafeRelease(mOffscreenSRView);
</span><span class="cx">     SafeRelease(mDepthStencilTexture);
</span><span class="cx">     SafeRelease(mDepthStencilDSView);
</span><ins>+    SafeRelease(mDepthStencilSRView);
</ins><span class="cx">     SafeRelease(mQuadVB);
</span><span class="cx">     SafeRelease(mPassThroughSampler);
</span><span class="cx">     SafeRelease(mPassThroughIL);
</span><span class="lines">@@ -76,6 +78,7 @@
</span><span class="cx">     SafeRelease(mOffscreenSRView);
</span><span class="cx">     SafeRelease(mDepthStencilTexture);
</span><span class="cx">     SafeRelease(mDepthStencilDSView);
</span><ins>+    SafeRelease(mDepthStencilSRView);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHeight)
</span><span class="lines">@@ -114,7 +117,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         result = tempResource11-&gt;QueryInterface(__uuidof(ID3D11Texture2D), (void**)&amp;mOffscreenTexture);
</span><del>-        tempResource11-&gt;Release();
</del><ins>+        SafeRelease(tempResource11);
</ins><span class="cx"> 
</span><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="lines">@@ -129,7 +132,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (offscreenTextureDesc.Width != (UINT)backbufferWidth
</span><span class="cx">             || offscreenTextureDesc.Height != (UINT)backbufferHeight
</span><del>-            || offscreenTextureDesc.Format != gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat)
</del><ins>+            || offscreenTextureDesc.Format != gl_d3d11::GetTexFormat(mBackBufferFormat, mRenderer-&gt;getCurrentClientVersion())
</ins><span class="cx">             || offscreenTextureDesc.MipLevels != 1
</span><span class="cx">             || offscreenTextureDesc.ArraySize != 1)
</span><span class="cx">         {
</span><span class="lines">@@ -145,7 +148,7 @@
</span><span class="cx">         D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0};
</span><span class="cx">         offscreenTextureDesc.Width = backbufferWidth;
</span><span class="cx">         offscreenTextureDesc.Height = backbufferHeight;
</span><del>-        offscreenTextureDesc.Format = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
</del><ins>+        offscreenTextureDesc.Format = gl_d3d11::GetTexFormat(mBackBufferFormat, mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx">         offscreenTextureDesc.MipLevels = 1;
</span><span class="cx">         offscreenTextureDesc.ArraySize = 1;
</span><span class="cx">         offscreenTextureDesc.SampleDesc.Count = 1;
</span><span class="lines">@@ -172,7 +175,7 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        d3d11::SetDebugName(mOffscreenTexture, &quot;Offscreen texture&quot;);
</del><ins>+        d3d11::SetDebugName(mOffscreenTexture, &quot;Offscreen back buffer texture&quot;);
</ins><span class="cx"> 
</span><span class="cx">         // EGL_ANGLE_surface_d3d_texture_2d_share_handle requires that we store a share handle for the client
</span><span class="cx">         if (useSharedResource)
</span><span class="lines">@@ -188,7 +191,7 @@
</span><span class="cx">             else
</span><span class="cx">             {
</span><span class="cx">                 result = offscreenTextureResource-&gt;GetSharedHandle(&amp;mShareHandle);
</span><del>-                offscreenTextureResource-&gt;Release();
</del><ins>+                SafeRelease(offscreenTextureResource);
</ins><span class="cx"> 
</span><span class="cx">                 if (FAILED(result))
</span><span class="cx">                 {
</span><span class="lines">@@ -198,32 +201,43 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-        
-    HRESULT result = device-&gt;CreateRenderTargetView(mOffscreenTexture, NULL, &amp;mOffscreenRTView);
</del><span class="cx"> 
</span><ins>+
+    D3D11_RENDER_TARGET_VIEW_DESC offscreenRTVDesc;
+    offscreenRTVDesc.Format = gl_d3d11::GetRTVFormat(mBackBufferFormat, mRenderer-&gt;getCurrentClientVersion());
+    offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
+    offscreenRTVDesc.Texture2D.MipSlice = 0;
+
+    HRESULT result = device-&gt;CreateRenderTargetView(mOffscreenTexture, &amp;offscreenRTVDesc, &amp;mOffscreenRTView);
</ins><span class="cx">     ASSERT(SUCCEEDED(result));
</span><del>-    d3d11::SetDebugName(mOffscreenRTView, &quot;Offscreen render target&quot;);
</del><ins>+    d3d11::SetDebugName(mOffscreenRTView, &quot;Offscreen back buffer render target&quot;);
</ins><span class="cx"> 
</span><del>-    result = device-&gt;CreateShaderResourceView(mOffscreenTexture, NULL, &amp;mOffscreenSRView);
</del><ins>+    D3D11_SHADER_RESOURCE_VIEW_DESC offscreenSRVDesc;
+    offscreenSRVDesc.Format = gl_d3d11::GetSRVFormat(mBackBufferFormat, mRenderer-&gt;getCurrentClientVersion());
+    offscreenSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
+    offscreenSRVDesc.Texture2D.MostDetailedMip = 0;
+    offscreenSRVDesc.Texture2D.MipLevels = -1;
+
+    result = device-&gt;CreateShaderResourceView(mOffscreenTexture, &amp;offscreenSRVDesc, &amp;mOffscreenSRView);
</ins><span class="cx">     ASSERT(SUCCEEDED(result));
</span><del>-    d3d11::SetDebugName(mOffscreenSRView, &quot;Offscreen shader resource&quot;);
</del><ins>+    d3d11::SetDebugName(mOffscreenSRView, &quot;Offscreen back buffer shader resource&quot;);
</ins><span class="cx"> 
</span><span class="cx">     if (mDepthBufferFormat != GL_NONE)
</span><span class="cx">     {
</span><del>-        D3D11_TEXTURE2D_DESC depthStencilDesc = {0};
-        depthStencilDesc.Width = backbufferWidth;
-        depthStencilDesc.Height = backbufferHeight;
-        depthStencilDesc.Format = gl_d3d11::ConvertRenderbufferFormat(mDepthBufferFormat);
-        depthStencilDesc.MipLevels = 1;
-        depthStencilDesc.ArraySize = 1;
-        depthStencilDesc.SampleDesc.Count = 1;
-        depthStencilDesc.SampleDesc.Quality = 0;
-        depthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
-        depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
-        depthStencilDesc.CPUAccessFlags = 0;
-        depthStencilDesc.MiscFlags = 0;
</del><ins>+        D3D11_TEXTURE2D_DESC depthStencilTextureDesc;
+        depthStencilTextureDesc.Width = backbufferWidth;
+        depthStencilTextureDesc.Height = backbufferHeight;
+        depthStencilTextureDesc.Format = gl_d3d11::GetTexFormat(mDepthBufferFormat, mRenderer-&gt;getCurrentClientVersion());
+        depthStencilTextureDesc.MipLevels = 1;
+        depthStencilTextureDesc.ArraySize = 1;
+        depthStencilTextureDesc.SampleDesc.Count = 1;
+        depthStencilTextureDesc.SampleDesc.Quality = 0;
+        depthStencilTextureDesc.Usage = D3D11_USAGE_DEFAULT;
+        depthStencilTextureDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
+        depthStencilTextureDesc.CPUAccessFlags = 0;
+        depthStencilTextureDesc.MiscFlags = 0;
</ins><span class="cx"> 
</span><del>-        result = device-&gt;CreateTexture2D(&amp;depthStencilDesc, NULL, &amp;mDepthStencilTexture);
</del><ins>+        result = device-&gt;CreateTexture2D(&amp;depthStencilTextureDesc, NULL, &amp;mDepthStencilTexture);
</ins><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="cx">             ERR(&quot;Could not create depthstencil surface for new swap chain: 0x%08X&quot;, result);
</span><span class="lines">@@ -238,11 +252,27 @@
</span><span class="cx">                 return EGL_BAD_ALLOC;
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-        d3d11::SetDebugName(mDepthStencilTexture, &quot;Depth stencil texture&quot;);
</del><ins>+        d3d11::SetDebugName(mDepthStencilTexture, &quot;Offscreen depth stencil texture&quot;);
</ins><span class="cx"> 
</span><del>-        result = device-&gt;CreateDepthStencilView(mDepthStencilTexture, NULL, &amp;mDepthStencilDSView);
</del><ins>+        D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilDesc;
+        depthStencilDesc.Format = gl_d3d11::GetDSVFormat(mDepthBufferFormat, mRenderer-&gt;getCurrentClientVersion());
+        depthStencilDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
+        depthStencilDesc.Flags = 0;
+        depthStencilDesc.Texture2D.MipSlice = 0;
+
+        result = device-&gt;CreateDepthStencilView(mDepthStencilTexture, &amp;depthStencilDesc, &amp;mDepthStencilDSView);
</ins><span class="cx">         ASSERT(SUCCEEDED(result));
</span><del>-        d3d11::SetDebugName(mDepthStencilDSView, &quot;Depth stencil view&quot;);
</del><ins>+        d3d11::SetDebugName(mDepthStencilDSView, &quot;Offscreen depth stencil view&quot;);
+
+        D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSRVDesc;
+        depthStencilSRVDesc.Format = gl_d3d11::GetSRVFormat(mDepthBufferFormat, mRenderer-&gt;getCurrentClientVersion());
+        depthStencilSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
+        depthStencilSRVDesc.Texture2D.MostDetailedMip = 0;
+        depthStencilSRVDesc.Texture2D.MipLevels = -1;
+
+        result = device-&gt;CreateShaderResourceView(mDepthStencilTexture, &amp;depthStencilSRVDesc, &amp;mDepthStencilSRView);
+        ASSERT(SUCCEEDED(result));
+        d3d11::SetDebugName(mDepthStencilSRView, &quot;Offscreen depth stencil shader resource&quot;);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     mWidth = backbufferWidth;
</span><span class="lines">@@ -262,7 +292,7 @@
</span><span class="cx">         const int yoffset = std::max(mHeight - previousHeight, 0);
</span><span class="cx">         deviceContext-&gt;CopySubresourceRegion(mOffscreenTexture, 0, 0, yoffset, 0, previousOffscreenTexture, 0, &amp;sourceBox);
</span><span class="cx"> 
</span><del>-        previousOffscreenTexture-&gt;Release();
</del><ins>+        SafeRelease(previousOffscreenTexture);
</ins><span class="cx"> 
</span><span class="cx">         if (mSwapChain)
</span><span class="cx">         {
</span><span class="lines">@@ -295,7 +325,7 @@
</span><span class="cx">     SafeRelease(mBackBufferRTView);
</span><span class="cx"> 
</span><span class="cx">     // Resize swap chain
</span><del>-    DXGI_FORMAT backbufferDXGIFormat = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
</del><ins>+    DXGI_FORMAT backbufferDXGIFormat = gl_d3d11::GetTexFormat(mBackBufferFormat, mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx">     HRESULT result = mSwapChain-&gt;ResizeBuffers(2, backbufferWidth, backbufferHeight, backbufferDXGIFormat, 0);
</span><span class="cx"> 
</span><span class="cx">     if (FAILED(result))
</span><span class="lines">@@ -365,7 +395,7 @@
</span><span class="cx"> 
</span><span class="cx">         DXGI_SWAP_CHAIN_DESC swapChainDesc = {0};
</span><span class="cx">         swapChainDesc.BufferCount = 2;
</span><del>-        swapChainDesc.BufferDesc.Format = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
</del><ins>+        swapChainDesc.BufferDesc.Format = gl_d3d11::GetTexFormat(mBackBufferFormat, mRenderer-&gt;getCurrentClientVersion());
</ins><span class="cx">         swapChainDesc.BufferDesc.Width = backbufferWidth;
</span><span class="cx">         swapChainDesc.BufferDesc.Height = backbufferHeight;
</span><span class="cx">         swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
</span><span class="lines">@@ -462,15 +492,15 @@
</span><span class="cx">         { &quot;TEXCOORD&quot;, 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    result = device-&gt;CreateInputLayout(quadLayout, 2, g_VS_Passthrough, sizeof(g_VS_Passthrough), &amp;mPassThroughIL);
</del><ins>+    result = device-&gt;CreateInputLayout(quadLayout, 2, g_VS_Passthrough2D, sizeof(g_VS_Passthrough2D), &amp;mPassThroughIL);
</ins><span class="cx">     ASSERT(SUCCEEDED(result));
</span><span class="cx">     d3d11::SetDebugName(mPassThroughIL, &quot;Swap chain pass through layout&quot;);
</span><span class="cx"> 
</span><del>-    result = device-&gt;CreateVertexShader(g_VS_Passthrough, sizeof(g_VS_Passthrough), NULL, &amp;mPassThroughVS);
</del><ins>+    result = device-&gt;CreateVertexShader(g_VS_Passthrough2D, sizeof(g_VS_Passthrough2D), NULL, &amp;mPassThroughVS);
</ins><span class="cx">     ASSERT(SUCCEEDED(result));
</span><span class="cx">     d3d11::SetDebugName(mPassThroughVS, &quot;Swap chain pass through vertex shader&quot;);
</span><span class="cx"> 
</span><del>-    result = device-&gt;CreatePixelShader(g_PS_PassthroughRGBA, sizeof(g_PS_PassthroughRGBA), NULL, &amp;mPassThroughPS);
</del><ins>+    result = device-&gt;CreatePixelShader(g_PS_PassthroughRGBA2D, sizeof(g_PS_PassthroughRGBA2D), NULL, &amp;mPassThroughPS);
</ins><span class="cx">     ASSERT(SUCCEEDED(result));
</span><span class="cx">     d3d11::SetDebugName(mPassThroughPS, &quot;Swap chain pass through pixel shader&quot;);
</span><span class="cx"> }
</span><span class="lines">@@ -585,61 +615,33 @@
</span><span class="cx">     return EGL_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Increments refcount on texture.
-// caller must Release() the returned texture
</del><span class="cx"> ID3D11Texture2D *SwapChain11::getOffscreenTexture()
</span><span class="cx"> {
</span><del>-    if (mOffscreenTexture)
-    {
-        mOffscreenTexture-&gt;AddRef();
-    }
-
</del><span class="cx">     return mOffscreenTexture;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Increments refcount on view.
-// caller must Release() the returned view
</del><span class="cx"> ID3D11RenderTargetView *SwapChain11::getRenderTarget()
</span><span class="cx"> {
</span><del>-    if (mOffscreenRTView)
-    {
-        mOffscreenRTView-&gt;AddRef();
-    }
-
</del><span class="cx">     return mOffscreenRTView;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Increments refcount on view.
-// caller must Release() the returned view
</del><span class="cx"> ID3D11ShaderResourceView *SwapChain11::getRenderTargetShaderResource()
</span><span class="cx"> {
</span><del>-    if (mOffscreenSRView)
-    {
-        mOffscreenSRView-&gt;AddRef();
-    }
-
</del><span class="cx">     return mOffscreenSRView;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Increments refcount on view.
-// caller must Release() the returned view
</del><span class="cx"> ID3D11DepthStencilView *SwapChain11::getDepthStencil()
</span><span class="cx"> {
</span><del>-    if (mDepthStencilDSView)
-    {
-        mDepthStencilDSView-&gt;AddRef();
-    }
-
</del><span class="cx">     return mDepthStencilDSView;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ID3D11ShaderResourceView * SwapChain11::getDepthStencilShaderResource()
+{
+    return mDepthStencilSRView;
+}
+
</ins><span class="cx"> ID3D11Texture2D *SwapChain11::getDepthStencilTexture()
</span><span class="cx"> {
</span><del>-    if (mDepthStencilTexture)
-    {
-        mDepthStencilTexture-&gt;AddRef();
-    }
-
</del><span class="cx">     return mDepthStencilTexture;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11SwapChain11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/SwapChain11.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/SwapChain11.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/SwapChain11.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual ID3D11Texture2D *getDepthStencilTexture();
</span><span class="cx">     virtual ID3D11DepthStencilView *getDepthStencil();
</span><ins>+    virtual ID3D11ShaderResourceView *getDepthStencilShaderResource();
</ins><span class="cx"> 
</span><span class="cx">     EGLint getWidth() const { return mWidth; }
</span><span class="cx">     EGLint getHeight() const { return mHeight; }
</span><span class="lines">@@ -66,6 +67,7 @@
</span><span class="cx"> 
</span><span class="cx">     ID3D11Texture2D *mDepthStencilTexture;
</span><span class="cx">     ID3D11DepthStencilView *mDepthStencilDSView;
</span><ins>+    ID3D11ShaderResourceView *mDepthStencilSRView;
</ins><span class="cx"> 
</span><span class="cx">     ID3D11Buffer *mQuadVB;
</span><span class="cx">     ID3D11SamplerState *mPassThroughSampler;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11TextureStorage11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -14,31 +14,105 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/RenderTarget11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/SwapChain11.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/renderer11_utils.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d11/Blit11.h&quot;
+#include &quot;libGLESv2/renderer/d3d11/formatutils11.h&quot;
</ins><span class="cx"> 
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;common/utilities.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><ins>+TextureStorage11::SwizzleCacheValue::SwizzleCacheValue()
+    : swizzleRed(GL_NONE), swizzleGreen(GL_NONE), swizzleBlue(GL_NONE), swizzleAlpha(GL_NONE)
+{
+}
+
+TextureStorage11::SwizzleCacheValue::SwizzleCacheValue(GLenum red, GLenum green, GLenum blue, GLenum alpha)
+    : swizzleRed(red), swizzleGreen(green), swizzleBlue(blue), swizzleAlpha(alpha)
+{
+}
+
+bool TextureStorage11::SwizzleCacheValue::operator==(const SwizzleCacheValue &amp;other) const
+{
+    return swizzleRed == other.swizzleRed &amp;&amp;
+           swizzleGreen == other.swizzleGreen &amp;&amp;
+           swizzleBlue == other.swizzleBlue &amp;&amp;
+           swizzleAlpha == other.swizzleAlpha;
+}
+
+bool TextureStorage11::SwizzleCacheValue::operator!=(const SwizzleCacheValue &amp;other) const
+{
+    return !(*this == other);
+}
+
+TextureStorage11::SRVKey::SRVKey(int baseLevel, int mipLevels, bool swizzle)
+    : baseLevel(baseLevel), mipLevels(mipLevels), swizzle(swizzle)
+{
+}
+
+bool TextureStorage11::SRVKey::operator==(const SRVKey &amp;rhs) const
+{
+    return baseLevel == rhs.baseLevel &amp;&amp;
+           mipLevels == rhs.mipLevels &amp;&amp;
+           swizzle == rhs.swizzle;
+}
+
+TextureStorage11::SRVCache::~SRVCache()
+{
+    for (size_t i = 0; i &lt; cache.size(); i++)
+    {
+        SafeRelease(cache[i].srv);
+    }
+}
+
+ID3D11ShaderResourceView *TextureStorage11::SRVCache::find(const SRVKey &amp;key) const
+{
+    for (size_t i = 0; i &lt; cache.size(); i++)
+    {
+        if (cache[i].key == key)
+        {
+            return cache[i].srv;
+        }
+    }
+
+    return NULL;
+}
+
+ID3D11ShaderResourceView *TextureStorage11::SRVCache::add(const SRVKey &amp;key, ID3D11ShaderResourceView *srv)
+{
+    SRVPair pair = {key, srv};
+    cache.push_back(pair);
+
+    return srv;
+}
+
</ins><span class="cx"> TextureStorage11::TextureStorage11(Renderer *renderer, UINT bindFlags)
</span><span class="cx">     : mBindFlags(bindFlags),
</span><del>-      mLodOffset(0),
</del><ins>+      mTopLevel(0),
</ins><span class="cx">       mMipLevels(0),
</span><del>-      mTexture(NULL),
</del><span class="cx">       mTextureFormat(DXGI_FORMAT_UNKNOWN),
</span><span class="cx">       mShaderResourceFormat(DXGI_FORMAT_UNKNOWN),
</span><span class="cx">       mRenderTargetFormat(DXGI_FORMAT_UNKNOWN),
</span><span class="cx">       mDepthStencilFormat(DXGI_FORMAT_UNKNOWN),
</span><del>-      mSRV(NULL),
</del><span class="cx">       mTextureWidth(0),
</span><del>-      mTextureHeight(0)
</del><ins>+      mTextureHeight(0),
+      mTextureDepth(0)
</ins><span class="cx"> {
</span><span class="cx">     mRenderer = Renderer11::makeRenderer11(renderer);
</span><ins>+
+    for (unsigned int i = 0; i &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
+    {
+        mLevelSRVs[i] = NULL;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureStorage11::~TextureStorage11()
</span><span class="cx"> {
</span><ins>+    for (unsigned int level = 0; level &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
+    {
+        SafeRelease(mLevelSRVs[level]);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureStorage11 *TextureStorage11::makeTextureStorage11(TextureStorage *storage)
</span><span class="lines">@@ -47,116 +121,217 @@
</span><span class="cx">     return static_cast&lt;TextureStorage11*&gt;(storage);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DWORD TextureStorage11::GetTextureBindFlags(DXGI_FORMAT format, GLenum glusage, bool forceRenderable)
</del><ins>+DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat, GLuint clientVersion, bool renderTarget)
</ins><span class="cx"> {
</span><del>-    UINT bindFlags = D3D11_BIND_SHADER_RESOURCE;
-    
-    if (d3d11::IsDepthStencilFormat(format))
</del><ins>+    UINT bindFlags = 0;
+
+    if (gl_d3d11::GetSRVFormat(internalFormat, clientVersion) != DXGI_FORMAT_UNKNOWN)
</ins><span class="cx">     {
</span><ins>+        bindFlags |= D3D11_BIND_SHADER_RESOURCE;
+    }
+    if (gl_d3d11::GetDSVFormat(internalFormat, clientVersion) != DXGI_FORMAT_UNKNOWN)
+    {
</ins><span class="cx">         bindFlags |= D3D11_BIND_DEPTH_STENCIL;
</span><span class="cx">     }
</span><del>-    else if(forceRenderable || (TextureStorage11::IsTextureFormatRenderable(format) &amp;&amp; (glusage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE)))
</del><ins>+    if (gl_d3d11::GetRTVFormat(internalFormat, clientVersion) != DXGI_FORMAT_UNKNOWN &amp;&amp; renderTarget)
</ins><span class="cx">     {
</span><span class="cx">         bindFlags |= D3D11_BIND_RENDER_TARGET;
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     return bindFlags;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool TextureStorage11::IsTextureFormatRenderable(DXGI_FORMAT format)
</del><ins>+UINT TextureStorage11::getBindFlags() const
</ins><span class="cx"> {
</span><del>-    switch(format)
-    {
-      case DXGI_FORMAT_R8G8B8A8_UNORM:
-      case DXGI_FORMAT_A8_UNORM:
-      case DXGI_FORMAT_R32G32B32A32_FLOAT:
-      case DXGI_FORMAT_R16G16B16A16_FLOAT:
-      case DXGI_FORMAT_B8G8R8A8_UNORM:
-      case DXGI_FORMAT_R8_UNORM:
-      case DXGI_FORMAT_R8G8_UNORM:
-      case DXGI_FORMAT_R16_FLOAT:
-      case DXGI_FORMAT_R16G16_FLOAT:
-        return true;
-      case DXGI_FORMAT_BC1_UNORM:
-      case DXGI_FORMAT_BC2_UNORM: 
-      case DXGI_FORMAT_BC3_UNORM:
-      case DXGI_FORMAT_R32G32B32_FLOAT: // not renderable on all devices
-        return false;
-      default:
-        UNREACHABLE();
-        return false;
-    }
</del><ins>+    return mBindFlags;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-UINT TextureStorage11::getBindFlags() const
</del><ins>+int TextureStorage11::getTopLevel() const
</ins><span class="cx"> {
</span><del>-    return mBindFlags;
</del><ins>+    return mTopLevel;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ID3D11Texture2D *TextureStorage11::getBaseTexture() const
</del><ins>+bool TextureStorage11::isRenderTarget() const
</ins><span class="cx"> {
</span><del>-    return mTexture;
</del><ins>+    return (mBindFlags &amp; (D3D11_BIND_RENDER_TARGET | D3D11_BIND_DEPTH_STENCIL)) != 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int TextureStorage11::getLodOffset() const
</del><ins>+bool TextureStorage11::isManaged() const
</ins><span class="cx"> {
</span><del>-    return mLodOffset;
</del><ins>+    return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool TextureStorage11::isRenderTarget() const
</del><ins>+int TextureStorage11::getLevelCount() const
</ins><span class="cx"> {
</span><del>-    return (mBindFlags &amp; (D3D11_BIND_RENDER_TARGET | D3D11_BIND_DEPTH_STENCIL)) != 0;
</del><ins>+    return mMipLevels - mTopLevel;
</ins><span class="cx"> }
</span><ins>+
+int TextureStorage11::getLevelWidth(int mipLevel) const
+{
+    return std::max(static_cast&lt;int&gt;(mTextureWidth) &gt;&gt; mipLevel, 1);
+}
+
+int TextureStorage11::getLevelHeight(int mipLevel) const
+{
+    return std::max(static_cast&lt;int&gt;(mTextureHeight) &gt;&gt; mipLevel, 1);
+}
+
+int TextureStorage11::getLevelDepth(int mipLevel) const
+{
+    return std::max(static_cast&lt;int&gt;(mTextureDepth) &gt;&gt; mipLevel, 1);
+}
+
+UINT TextureStorage11::getSubresourceIndex(int mipLevel, int layerTarget) const
+{
+    UINT index = 0;
+    if (getResource())
+    {
+        index = D3D11CalcSubresource(mipLevel, layerTarget, mMipLevels);
+    }
+    return index;
+}
+
+ID3D11ShaderResourceView *TextureStorage11::getSRV(const gl::SamplerState &amp;samplerState)
+{
+    bool swizzleRequired = samplerState.swizzleRequired();
+    bool mipmapping = gl::IsMipmapFiltered(samplerState);
+    unsigned int mipLevels = mipmapping ? (samplerState.maxLevel - samplerState.baseLevel) : 1;
+
+    // Make sure there's 'mipLevels' mipmap levels below the base level (offset by the top level,  which corresponds to GL level 0)
+    mipLevels = std::min(mipLevels, mMipLevels - mTopLevel - samplerState.baseLevel);
+
+    if (swizzleRequired)
+    {
+        verifySwizzleExists(samplerState.swizzleRed, samplerState.swizzleGreen, samplerState.swizzleBlue, samplerState.swizzleAlpha);
+    }
</ins><span class="cx">     
</span><del>-bool TextureStorage11::isManaged() const
</del><ins>+    SRVKey key(samplerState.baseLevel, mipLevels, swizzleRequired);
+    ID3D11ShaderResourceView *srv = srvCache.find(key);
+
+    if(srv)
+    {
+        return srv;
+    }
+
+    DXGI_FORMAT format = (swizzleRequired ? mSwizzleShaderResourceFormat : mShaderResourceFormat);
+    ID3D11Resource *texture = swizzleRequired ? getSwizzleTexture() : getResource();
+
+    srv = createSRV(samplerState.baseLevel, mipLevels, format, texture);
+    
+    return srvCache.add(key, srv);
+}
+
+ID3D11ShaderResourceView *TextureStorage11::getSRVLevel(int mipLevel)
</ins><span class="cx"> {
</span><del>-    return false;
</del><ins>+    if (mipLevel &gt;= 0 &amp;&amp; mipLevel &lt; getLevelCount())
+    {
+        if (!mLevelSRVs[mipLevel])
+        {
+            mLevelSRVs[mipLevel] = createSRV(mipLevel, 1, mShaderResourceFormat, getResource());
+        }
+
+        return mLevelSRVs[mipLevel];
+    }
+    else
+    {
+        return NULL;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int TextureStorage11::levelCount()
</del><ins>+void TextureStorage11::generateSwizzles(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha)
</ins><span class="cx"> {
</span><del>-    int levels = 0;
-    if (getBaseTexture())
</del><ins>+    SwizzleCacheValue swizzleTarget(swizzleRed, swizzleGreen, swizzleBlue, swizzleAlpha);
+    for (int level = 0; level &lt; getLevelCount(); level++)
</ins><span class="cx">     {
</span><del>-        levels = mMipLevels - getLodOffset();
</del><ins>+        // Check if the swizzle for this level is out of date
+        if (mSwizzleCache[level] != swizzleTarget)
+        {
+            // Need to re-render the swizzle for this level
+            ID3D11ShaderResourceView *sourceSRV = getSRVLevel(level);
+            ID3D11RenderTargetView *destRTV = getSwizzleRenderTarget(level);
+
+            gl::Extents size(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
+
+            Blit11 *blitter = mRenderer-&gt;getBlitter();
+
+            if (blitter-&gt;swizzleTexture(sourceSRV, destRTV, size, swizzleRed, swizzleGreen, swizzleBlue, swizzleAlpha))
+            {
+                mSwizzleCache[level] = swizzleTarget;
+            }
+            else
+            {
+                ERR(&quot;Failed to swizzle texture.&quot;);
+            }
+        }
</ins><span class="cx">     }
</span><del>-    return levels;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-UINT TextureStorage11::getSubresourceIndex(int level, int faceIndex)
</del><ins>+void TextureStorage11::invalidateSwizzleCacheLevel(int mipLevel)
</ins><span class="cx"> {
</span><del>-    UINT index = 0;
-    if (getBaseTexture())
</del><ins>+    if (mipLevel &gt;= 0 &amp;&amp; static_cast&lt;unsigned int&gt;(mipLevel) &lt; ArraySize(mSwizzleCache))
</ins><span class="cx">     {
</span><del>-        index = D3D11CalcSubresource(level, faceIndex, mMipLevels);
</del><ins>+        // The default constructor of SwizzleCacheValue has GL_NONE for all channels which is not a
+        // valid swizzle combination
+        mSwizzleCache[mipLevel] = SwizzleCacheValue();
</ins><span class="cx">     }
</span><del>-    return index;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool TextureStorage11::updateSubresourceLevel(ID3D11Texture2D *srcTexture, unsigned int sourceSubresource,
-                                              int level, int face, GLint xoffset, GLint yoffset,
-                                              GLsizei width, GLsizei height)
</del><ins>+void TextureStorage11::invalidateSwizzleCache()
</ins><span class="cx"> {
</span><ins>+    for (unsigned int mipLevel = 0; mipLevel &lt; ArraySize(mSwizzleCache); mipLevel++)
+    {
+        invalidateSwizzleCacheLevel(mipLevel);
+    }
+}
+
+bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsigned int sourceSubresource,
+                                              int level, int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset,
+                                              GLsizei width, GLsizei height, GLsizei depth)
+{
</ins><span class="cx">     if (srcTexture)
</span><span class="cx">     {
</span><del>-        // Round up the width and height to the nearest multiple of dimension alignment
-        unsigned int dimensionAlignment = d3d11::GetTextureFormatDimensionAlignment(mTextureFormat);
-        width = width + dimensionAlignment - 1 - (width - 1) % dimensionAlignment;
-        height = height + dimensionAlignment - 1 - (height - 1) % dimensionAlignment;
</del><ins>+        invalidateSwizzleCacheLevel(level);
</ins><span class="cx"> 
</span><del>-        D3D11_BOX srcBox;
-        srcBox.left = xoffset;
-        srcBox.top = yoffset;
-        srcBox.right = xoffset + width;
-        srcBox.bottom = yoffset + height;
-        srcBox.front = 0;
-        srcBox.back = 1;
</del><ins>+        gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
+        gl::Box copyArea(xoffset, yoffset, zoffset, width, height, depth);
</ins><span class="cx"> 
</span><del>-        ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
-        
-        ASSERT(getBaseTexture());
-        context-&gt;CopySubresourceRegion(getBaseTexture(), getSubresourceIndex(level + mLodOffset, face),
-                                       xoffset, yoffset, 0, srcTexture, sourceSubresource, &amp;srcBox);
-        return true;
</del><ins>+        bool fullCopy = copyArea.x == 0 &amp;&amp;
+                        copyArea.y == 0 &amp;&amp;
+                        copyArea.z == 0 &amp;&amp;
+                        copyArea.width  == texSize.width &amp;&amp;
+                        copyArea.height == texSize.height &amp;&amp;
+                        copyArea.depth  == texSize.depth;
+
+        ID3D11Resource *dstTexture = getResource();
+        unsigned int dstSubresource = getSubresourceIndex(level + mTopLevel, layerTarget);
+
+        ASSERT(dstTexture);
+
+        if (!fullCopy &amp;&amp; (d3d11::GetDepthBits(mTextureFormat) &gt; 0 || d3d11::GetStencilBits(mTextureFormat) &gt; 0))
+        {
+            // CopySubresourceRegion cannot copy partial depth stencils, use the blitter instead
+            Blit11 *blitter = mRenderer-&gt;getBlitter();
+
+            return blitter-&gt;copyDepthStencil(srcTexture, sourceSubresource, copyArea, texSize,
+                                             dstTexture, dstSubresource, copyArea, texSize,
+                                             NULL);
+        }
+        else
+        {
+            D3D11_BOX srcBox;
+            srcBox.left = copyArea.x;
+            srcBox.top = copyArea.y;
+            srcBox.right = copyArea.x + roundUp((unsigned int)width, d3d11::GetBlockWidth(mTextureFormat));
+            srcBox.bottom = copyArea.y + roundUp((unsigned int)height, d3d11::GetBlockHeight(mTextureFormat));
+            srcBox.front = copyArea.z;
+            srcBox.back = copyArea.z + copyArea.depth;
+
+            ID3D11DeviceContext *context = mRenderer-&gt;getDeviceContext();
+
+            context-&gt;CopySubresourceRegion(dstTexture, dstSubresource, copyArea.x, copyArea.y, copyArea.z,
+                                           srcTexture, sourceSubresource, fullCopy ? NULL : &amp;srcBox);
+            return true;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return false;
</span><span class="lines">@@ -171,34 +346,41 @@
</span><span class="cx"> 
</span><span class="cx">         if (sourceSRV &amp;&amp; destRTV)
</span><span class="cx">         {
</span><del>-            gl::Rectangle sourceArea;
-            sourceArea.x = 0;
-            sourceArea.y = 0;
-            sourceArea.width = source-&gt;getWidth();
-            sourceArea.height = source-&gt;getHeight();
</del><ins>+            gl::Box sourceArea(0, 0, 0, source-&gt;getWidth(), source-&gt;getHeight(), source-&gt;getDepth());
+            gl::Extents sourceSize(source-&gt;getWidth(), source-&gt;getHeight(), source-&gt;getDepth());
</ins><span class="cx"> 
</span><del>-            gl::Rectangle destArea;
-            destArea.x = 0;
-            destArea.y = 0;
-            destArea.width = dest-&gt;getWidth();
-            destArea.height = dest-&gt;getHeight();
</del><ins>+            gl::Box destArea(0, 0, 0, dest-&gt;getWidth(), dest-&gt;getHeight(), dest-&gt;getDepth());
+            gl::Extents destSize(dest-&gt;getWidth(), dest-&gt;getHeight(), dest-&gt;getDepth());
</ins><span class="cx"> 
</span><del>-            mRenderer-&gt;copyTexture(sourceSRV, sourceArea, source-&gt;getWidth(), source-&gt;getHeight(),
-                                   destRTV, destArea, dest-&gt;getWidth(), dest-&gt;getHeight(),
-                                   GL_RGBA);
</del><ins>+            Blit11 *blitter = mRenderer-&gt;getBlitter();
+
+            blitter-&gt;copyTexture(sourceSRV, sourceArea, sourceSize, destRTV, destArea, destSize, NULL,
+                                 gl::GetFormat(source-&gt;getInternalFormat(), mRenderer-&gt;getCurrentClientVersion()),
+                                 GL_LINEAR);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TextureStorage11::verifySwizzleExists(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha)
+{
+    SwizzleCacheValue swizzleTarget(swizzleRed, swizzleGreen, swizzleBlue, swizzleAlpha);
+    for (unsigned int level = 0; level &lt; mMipLevels; level++)
+    {
+        ASSERT(mSwizzleCache[level] == swizzleTarget);
+    }
+}
+
</ins><span class="cx"> TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, SwapChain11 *swapchain)
</span><span class="cx">     : TextureStorage11(renderer, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE)
</span><span class="cx"> {
</span><span class="cx">     mTexture = swapchain-&gt;getOffscreenTexture();
</span><del>-    mSRV = swapchain-&gt;getRenderTargetShaderResource();
</del><ins>+    mTexture-&gt;AddRef();
+    mSwizzleTexture = NULL;
</ins><span class="cx"> 
</span><span class="cx">     for (unsigned int i = 0; i &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
</span><span class="cx">     {
</span><span class="cx">         mRenderTarget[i] = NULL;
</span><ins>+        mSwizzleRenderTargets[i] = NULL;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     D3D11_TEXTURE2D_DESC texDesc;
</span><span class="lines">@@ -207,57 +389,61 @@
</span><span class="cx">     mTextureFormat = texDesc.Format;
</span><span class="cx">     mTextureWidth = texDesc.Width;
</span><span class="cx">     mTextureHeight = texDesc.Height;
</span><ins>+    mTextureDepth = 1;
</ins><span class="cx"> 
</span><ins>+    ID3D11ShaderResourceView *srv = swapchain-&gt;getRenderTargetShaderResource();
</ins><span class="cx">     D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
</span><del>-    mSRV-&gt;GetDesc(&amp;srvDesc);
</del><ins>+    srv-&gt;GetDesc(&amp;srvDesc);
</ins><span class="cx">     mShaderResourceFormat = srvDesc.Format;
</span><span class="cx"> 
</span><span class="cx">     ID3D11RenderTargetView* offscreenRTV = swapchain-&gt;getRenderTarget();
</span><span class="cx">     D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
</span><span class="cx">     offscreenRTV-&gt;GetDesc(&amp;rtvDesc);
</span><span class="cx">     mRenderTargetFormat = rtvDesc.Format;
</span><del>-    offscreenRTV-&gt;Release();
</del><span class="cx"> 
</span><ins>+    GLint internalFormat = d3d11_gl::GetInternalFormat(mTextureFormat, renderer-&gt;getCurrentClientVersion());
+    mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalFormat, renderer);
+    mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalFormat, renderer);
+    mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalFormat, renderer);
+
</ins><span class="cx">     mDepthStencilFormat = DXGI_FORMAT_UNKNOWN;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height)
-    : TextureStorage11(renderer, GetTextureBindFlags(gl_d3d11::ConvertTextureFormat(internalformat), usage, forceRenderable))
</del><ins>+TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
+    : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderer-&gt;getCurrentClientVersion(), renderTarget))
</ins><span class="cx"> {
</span><ins>+    mTexture = NULL;
+    mSwizzleTexture = NULL;
+
</ins><span class="cx">     for (unsigned int i = 0; i &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
</span><span class="cx">     {
</span><span class="cx">         mRenderTarget[i] = NULL;
</span><ins>+        mSwizzleRenderTargets[i] = NULL;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    DXGI_FORMAT convertedFormat = gl_d3d11::ConvertTextureFormat(internalformat);
-    if (d3d11::IsDepthStencilFormat(convertedFormat))
-    {
-        mTextureFormat = d3d11::GetDepthTextureFormat(convertedFormat);
-        mShaderResourceFormat = d3d11::GetDepthShaderResourceFormat(convertedFormat);
-        mDepthStencilFormat = convertedFormat;
-        mRenderTargetFormat = DXGI_FORMAT_UNKNOWN;
-    }
-    else
-    {
-        mTextureFormat = convertedFormat;
-        mShaderResourceFormat = convertedFormat;
-        mDepthStencilFormat = DXGI_FORMAT_UNKNOWN;
-        mRenderTargetFormat = convertedFormat;
-    }
</del><ins>+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
</ins><span class="cx"> 
</span><ins>+    mTextureFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion);
+    mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat, clientVersion);
+    mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat, clientVersion);
+    mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat, clientVersion);
+    mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat, renderer);
+    mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat, renderer);
+    mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat, renderer);
+
</ins><span class="cx">     // if the width or height is not positive this should be treated as an incomplete texture
</span><span class="cx">     // we handle that here by skipping the d3d texture creation
</span><span class="cx">     if (width &gt; 0 &amp;&amp; height &gt; 0)
</span><span class="cx">     {
</span><span class="cx">         // adjust size if needed for compressed textures
</span><del>-        gl::MakeValidSize(false, gl::IsCompressed(internalformat), &amp;width, &amp;height, &amp;mLodOffset);
</del><ins>+        d3d11::MakeValidSize(false, mTextureFormat, &amp;width, &amp;height, &amp;mTopLevel);
</ins><span class="cx"> 
</span><span class="cx">         ID3D11Device *device = mRenderer-&gt;getDevice();
</span><span class="cx"> 
</span><span class="cx">         D3D11_TEXTURE2D_DESC desc;
</span><span class="cx">         desc.Width = width;      // Compressed texture size constraints?
</span><span class="cx">         desc.Height = height;
</span><del>-        desc.MipLevels = (levels &gt; 0) ? levels + mLodOffset : 0;
</del><ins>+        desc.MipLevels = ((levels &gt; 0) ? (mTopLevel + levels) : 0);
</ins><span class="cx">         desc.ArraySize = 1;
</span><span class="cx">         desc.Format = mTextureFormat;
</span><span class="cx">         desc.SampleDesc.Count = 1;
</span><span class="lines">@@ -287,28 +473,20 @@
</span><span class="cx">             mMipLevels = desc.MipLevels;
</span><span class="cx">             mTextureWidth = desc.Width;
</span><span class="cx">             mTextureHeight = desc.Height;
</span><ins>+            mTextureDepth = 1;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureStorage11_2D::~TextureStorage11_2D()
</span><span class="cx"> {
</span><del>-    if (mTexture)
-    {
-        mTexture-&gt;Release();
-        mTexture = NULL;
-    }
</del><ins>+    SafeRelease(mTexture);
+    SafeRelease(mSwizzleTexture);
</ins><span class="cx"> 
</span><del>-    if (mSRV)
-    {
-        mSRV-&gt;Release();
-        mSRV = NULL;
-    }
-
</del><span class="cx">     for (unsigned int i = 0; i &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
</span><span class="cx">     {
</span><del>-        delete mRenderTarget[i];
-        mRenderTarget[i] = NULL;
</del><ins>+        SafeDelete(mRenderTarget[i]);
+        SafeRelease(mSwizzleRenderTargets[i]);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -318,80 +496,70 @@
</span><span class="cx">     return static_cast&lt;TextureStorage11_2D*&gt;(storage);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ID3D11Resource *TextureStorage11_2D::getResource() const
+{
+    return mTexture;
+}
+
</ins><span class="cx"> RenderTarget *TextureStorage11_2D::getRenderTarget(int level)
</span><span class="cx"> {
</span><del>-    if (level &gt;= 0 &amp;&amp; level &lt; static_cast&lt;int&gt;(mMipLevels))
</del><ins>+    if (level &gt;= 0 &amp;&amp; level &lt; getLevelCount())
</ins><span class="cx">     {
</span><span class="cx">         if (!mRenderTarget[level])
</span><span class="cx">         {
</span><del>-            ID3D11Device *device = mRenderer-&gt;getDevice();
-            HRESULT result;
-
-            D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
-            srvDesc.Format = mShaderResourceFormat;
-            srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
-            srvDesc.Texture2D.MostDetailedMip = level;
-            srvDesc.Texture2D.MipLevels = 1;
-
-            ID3D11ShaderResourceView *srv;
-            result = device-&gt;CreateShaderResourceView(mTexture, &amp;srvDesc, &amp;srv);
-
-            if (result == E_OUTOFMEMORY)
</del><ins>+            ID3D11ShaderResourceView *srv = getSRVLevel(level);
+            if (!srv)
</ins><span class="cx">             {
</span><del>-                return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;RenderTarget*&gt;(NULL));
</del><ins>+                return NULL;
</ins><span class="cx">             }
</span><del>-            ASSERT(SUCCEEDED(result));
</del><span class="cx"> 
</span><span class="cx">             if (mRenderTargetFormat != DXGI_FORMAT_UNKNOWN)
</span><span class="cx">             {
</span><ins>+                ID3D11Device *device = mRenderer-&gt;getDevice();
+
</ins><span class="cx">                 D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
</span><span class="cx">                 rtvDesc.Format = mRenderTargetFormat;
</span><span class="cx">                 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
</span><del>-                rtvDesc.Texture2D.MipSlice = level;
</del><ins>+                rtvDesc.Texture2D.MipSlice = mTopLevel + level;
</ins><span class="cx"> 
</span><span class="cx">                 ID3D11RenderTargetView *rtv;
</span><del>-                result = device-&gt;CreateRenderTargetView(mTexture, &amp;rtvDesc, &amp;rtv);
</del><ins>+                HRESULT result = device-&gt;CreateRenderTargetView(mTexture, &amp;rtvDesc, &amp;rtv);
</ins><span class="cx"> 
</span><span class="cx">                 if (result == E_OUTOFMEMORY)
</span><span class="cx">                 {
</span><del>-                    srv-&gt;Release();
</del><span class="cx">                     return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;RenderTarget*&gt;(NULL));
</span><span class="cx">                 }
</span><span class="cx">                 ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-                // RenderTarget11 expects to be the owner of the resources it is given but TextureStorage11
-                // also needs to keep a reference to the texture.
-                mTexture-&gt;AddRef();
</del><ins>+                mRenderTarget[level] = new RenderTarget11(mRenderer, rtv, mTexture, srv, getLevelWidth(level), getLevelHeight(level), 1);
</ins><span class="cx"> 
</span><del>-                mRenderTarget[level] = new RenderTarget11(mRenderer, rtv, mTexture, srv,
-                                                          std::max(mTextureWidth &gt;&gt; level, 1U),
-                                                          std::max(mTextureHeight &gt;&gt; level, 1U));
</del><ins>+                // RenderTarget will take ownership of these resources
+                SafeRelease(rtv);
</ins><span class="cx">             }
</span><span class="cx">             else if (mDepthStencilFormat != DXGI_FORMAT_UNKNOWN)
</span><span class="cx">             {
</span><ins>+                ID3D11Device *device = mRenderer-&gt;getDevice();
+
</ins><span class="cx">                 D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
</span><span class="cx">                 dsvDesc.Format = mDepthStencilFormat;
</span><span class="cx">                 dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
</span><del>-                dsvDesc.Texture2D.MipSlice = level;
</del><ins>+                dsvDesc.Texture2D.MipSlice = mTopLevel + level;
</ins><span class="cx">                 dsvDesc.Flags = 0;
</span><span class="cx"> 
</span><span class="cx">                 ID3D11DepthStencilView *dsv;
</span><del>-                result = device-&gt;CreateDepthStencilView(mTexture, &amp;dsvDesc, &amp;dsv);
</del><ins>+                HRESULT result = device-&gt;CreateDepthStencilView(mTexture, &amp;dsvDesc, &amp;dsv);
</ins><span class="cx"> 
</span><span class="cx">                 if (result == E_OUTOFMEMORY)
</span><span class="cx">                 {
</span><del>-                    srv-&gt;Release();
</del><ins>+                    SafeRelease(srv);
</ins><span class="cx">                     return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;RenderTarget*&gt;(NULL));
</span><span class="cx">                 }
</span><span class="cx">                 ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-                // RenderTarget11 expects to be the owner of the resources it is given but TextureStorage11
-                // also needs to keep a reference to the texture.
-                mTexture-&gt;AddRef();
</del><ins>+                mRenderTarget[level] = new RenderTarget11(mRenderer, dsv, mTexture, srv, getLevelWidth(level), getLevelHeight(level), 1);
</ins><span class="cx"> 
</span><del>-                mRenderTarget[level] = new RenderTarget11(mRenderer, dsv, mTexture, srv,
-                                                          std::max(mTextureWidth &gt;&gt; level, 1U),
-                                                          std::max(mTextureHeight &gt;&gt; level, 1U));
</del><ins>+                // RenderTarget will take ownership of these resources
+                SafeRelease(dsv);
</ins><span class="cx">             }
</span><span class="cx">             else
</span><span class="cx">             {
</span><span class="lines">@@ -407,79 +575,148 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ID3D11ShaderResourceView *TextureStorage11_2D::getSRV()
</del><ins>+ID3D11ShaderResourceView *TextureStorage11_2D::createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture)
</ins><span class="cx"> {
</span><del>-    if (!mSRV)
-    {
-        ID3D11Device *device = mRenderer-&gt;getDevice();
</del><ins>+    D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+    srvDesc.Format = format;
+    srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
+    srvDesc.Texture2D.MostDetailedMip = mTopLevel + baseLevel;
+    srvDesc.Texture2D.MipLevels = mipLevels;
</ins><span class="cx"> 
</span><del>-        D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
-        srvDesc.Format = mShaderResourceFormat;
-        srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
-        srvDesc.Texture2D.MipLevels = (mMipLevels == 0 ? -1 : mMipLevels);
-        srvDesc.Texture2D.MostDetailedMip = 0;
</del><ins>+    ID3D11ShaderResourceView *SRV = NULL;
</ins><span class="cx"> 
</span><del>-        HRESULT result = device-&gt;CreateShaderResourceView(mTexture, &amp;srvDesc, &amp;mSRV);
</del><ins>+    ID3D11Device *device = mRenderer-&gt;getDevice();
+    HRESULT result = device-&gt;CreateShaderResourceView(texture, &amp;srvDesc, &amp;SRV);
</ins><span class="cx"> 
</span><del>-        if (result == E_OUTOFMEMORY)
-        {
-            return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11ShaderResourceView*&gt;(NULL));
-        }
-        ASSERT(SUCCEEDED(result));
</del><ins>+    if (result == E_OUTOFMEMORY)
+    {
+        gl::error(GL_OUT_OF_MEMORY);
</ins><span class="cx">     }
</span><ins>+    ASSERT(SUCCEEDED(result));
</ins><span class="cx"> 
</span><del>-    return mSRV;
</del><ins>+    return SRV;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureStorage11_2D::generateMipmap(int level)
</span><span class="cx"> {
</span><ins>+    invalidateSwizzleCacheLevel(level);
+
</ins><span class="cx">     RenderTarget11 *source = RenderTarget11::makeRenderTarget11(getRenderTarget(level - 1));
</span><span class="cx">     RenderTarget11 *dest = RenderTarget11::makeRenderTarget11(getRenderTarget(level));
</span><span class="cx"> 
</span><span class="cx">     generateMipmapLayer(source, dest);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size)
-    : TextureStorage11(renderer, GetTextureBindFlags(gl_d3d11::ConvertTextureFormat(internalformat), usage, forceRenderable))
</del><ins>+ID3D11Resource *TextureStorage11_2D::getSwizzleTexture()
</ins><span class="cx"> {
</span><del>-    for (unsigned int i = 0; i &lt; 6; i++)
</del><ins>+    if (!mSwizzleTexture)
</ins><span class="cx">     {
</span><del>-        for (unsigned int j = 0; j &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; j++)
</del><ins>+        ID3D11Device *device = mRenderer-&gt;getDevice();
+
+        D3D11_TEXTURE2D_DESC desc;
+        desc.Width = mTextureWidth;
+        desc.Height = mTextureHeight;
+        desc.MipLevels = mMipLevels;
+        desc.ArraySize = 1;
+        desc.Format = mSwizzleTextureFormat;
+        desc.SampleDesc.Count = 1;
+        desc.SampleDesc.Quality = 0;
+        desc.Usage = D3D11_USAGE_DEFAULT;
+        desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
+        desc.CPUAccessFlags = 0;
+        desc.MiscFlags = 0;
+
+        HRESULT result = device-&gt;CreateTexture2D(&amp;desc, NULL, &amp;mSwizzleTexture);
+
+        if (result == E_OUTOFMEMORY)
</ins><span class="cx">         {
</span><del>-            mRenderTarget[i][j] = NULL;
</del><ins>+            return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11Texture2D*&gt;(NULL));
</ins><span class="cx">         }
</span><ins>+        ASSERT(SUCCEEDED(result));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    DXGI_FORMAT convertedFormat = gl_d3d11::ConvertTextureFormat(internalformat);
-    if (d3d11::IsDepthStencilFormat(convertedFormat))
</del><ins>+    return mSwizzleTexture;
+}
+
+ID3D11RenderTargetView *TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel)
+{
+    if (mipLevel &gt;= 0 &amp;&amp; mipLevel &lt; getLevelCount())
</ins><span class="cx">     {
</span><del>-        mTextureFormat = d3d11::GetDepthTextureFormat(convertedFormat);
-        mShaderResourceFormat = d3d11::GetDepthShaderResourceFormat(convertedFormat);
-        mDepthStencilFormat = convertedFormat;
-        mRenderTargetFormat = DXGI_FORMAT_UNKNOWN;
</del><ins>+        if (!mSwizzleRenderTargets[mipLevel])
+        {
+            ID3D11Resource *swizzleTexture = getSwizzleTexture();
+            if (!swizzleTexture)
+            {
+                return NULL;
+            }
+
+            ID3D11Device *device = mRenderer-&gt;getDevice();
+
+            D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
+            rtvDesc.Format = mSwizzleRenderTargetFormat;
+            rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
+            rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel;
+
+            HRESULT result = device-&gt;CreateRenderTargetView(mSwizzleTexture, &amp;rtvDesc, &amp;mSwizzleRenderTargets[mipLevel]);
+            if (result == E_OUTOFMEMORY)
+            {
+                return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11RenderTargetView*&gt;(NULL));
+            }
+            ASSERT(SUCCEEDED(result));
+        }
+
+        return mSwizzleRenderTargets[mipLevel];
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        mTextureFormat = convertedFormat;
-        mShaderResourceFormat = convertedFormat;
-        mDepthStencilFormat = DXGI_FORMAT_UNKNOWN;
-        mRenderTargetFormat = convertedFormat;
</del><ins>+        return NULL;
</ins><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><ins>+unsigned int TextureStorage11_2D::getTextureLevelDepth(int mipLevel) const
+{
+    return 1;
+}
+
+TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels)
+    : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderer-&gt;getCurrentClientVersion(), renderTarget))
+{
+    mTexture = NULL;
+    mSwizzleTexture = NULL;
+
+    for (unsigned int level = 0; level &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
+    {
+        mSwizzleRenderTargets[level] = NULL;
+        for (unsigned int face = 0; face &lt; 6; face++)
+        {
+            mRenderTarget[face][level] = NULL;
+        }
+    }
+
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+
+    mTextureFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion);
+    mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat, clientVersion);
+    mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat, clientVersion);
+    mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat, clientVersion);
+    mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat, renderer);
+    mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat, renderer);
+    mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat, renderer);
+
</ins><span class="cx">     // if the size is not positive this should be treated as an incomplete texture
</span><span class="cx">     // we handle that here by skipping the d3d texture creation
</span><span class="cx">     if (size &gt; 0)
</span><span class="cx">     {
</span><span class="cx">         // adjust size if needed for compressed textures
</span><span class="cx">         int height = size;
</span><del>-        gl::MakeValidSize(false, gl::IsCompressed(internalformat), &amp;size, &amp;height, &amp;mLodOffset);
</del><ins>+        d3d11::MakeValidSize(false, mTextureFormat, &amp;size, &amp;height, &amp;mTopLevel);
</ins><span class="cx"> 
</span><span class="cx">         ID3D11Device *device = mRenderer-&gt;getDevice();
</span><span class="cx"> 
</span><span class="cx">         D3D11_TEXTURE2D_DESC desc;
</span><span class="cx">         desc.Width = size;
</span><span class="cx">         desc.Height = size;
</span><del>-        desc.MipLevels = (levels &gt; 0) ? levels + mLodOffset : 0;
</del><ins>+        desc.MipLevels = ((levels &gt; 0) ? (mTopLevel + levels) : 0);
</ins><span class="cx">         desc.ArraySize = 6;
</span><span class="cx">         desc.Format = mTextureFormat;
</span><span class="cx">         desc.SampleDesc.Count = 1;
</span><span class="lines">@@ -503,30 +740,22 @@
</span><span class="cx">             mMipLevels = desc.MipLevels;
</span><span class="cx">             mTextureWidth = desc.Width;
</span><span class="cx">             mTextureHeight = desc.Height;
</span><ins>+            mTextureDepth = 1;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureStorage11_Cube::~TextureStorage11_Cube()
</span><span class="cx"> {
</span><del>-    if (mTexture)
-    {
-        mTexture-&gt;Release();
-        mTexture = NULL;
-    }
</del><ins>+    SafeRelease(mTexture);
+    SafeRelease(mSwizzleTexture);
</ins><span class="cx"> 
</span><del>-    if (mSRV)
</del><ins>+    for (unsigned int level = 0; level &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
</ins><span class="cx">     {
</span><del>-        mSRV-&gt;Release();
-        mSRV = NULL;
-    }
-
-    for (unsigned int i = 0; i &lt; 6; i++)
-    {
-        for (unsigned int j = 0; j &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; j++)
</del><ins>+        SafeRelease(mSwizzleRenderTargets[level]);
+        for (unsigned int face = 0; face &lt; 6; face++)
</ins><span class="cx">         {
</span><del>-            delete mRenderTarget[i][j];
-            mRenderTarget[i][j] = NULL;
</del><ins>+            SafeDelete(mRenderTarget[face][level]);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -537,12 +766,17 @@
</span><span class="cx">     return static_cast&lt;TextureStorage11_Cube*&gt;(storage);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget *TextureStorage11_Cube::getRenderTarget(GLenum faceTarget, int level)
</del><ins>+ID3D11Resource *TextureStorage11_Cube::getResource() const
</ins><span class="cx"> {
</span><del>-    unsigned int faceIdx = gl::TextureCubeMap::faceIndex(faceTarget);
-    if (level &gt;= 0 &amp;&amp; level &lt; static_cast&lt;int&gt;(mMipLevels))
</del><ins>+    return mTexture;
+}
+
+RenderTarget *TextureStorage11_Cube::getRenderTargetFace(GLenum faceTarget, int level)
+{
+    if (level &gt;= 0 &amp;&amp; level &lt; getLevelCount())
</ins><span class="cx">     {
</span><del>-        if (!mRenderTarget[faceIdx][level])
</del><ins>+        int faceIndex = gl::TextureCubeMap::targetToIndex(faceTarget);
+        if (!mRenderTarget[faceIndex][level])
</ins><span class="cx">         {
</span><span class="cx">             ID3D11Device *device = mRenderer-&gt;getDevice();
</span><span class="cx">             HRESULT result;
</span><span class="lines">@@ -550,9 +784,9 @@
</span><span class="cx">             D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
</span><span class="cx">             srvDesc.Format = mShaderResourceFormat;
</span><span class="cx">             srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; // Will be used with Texture2D sampler, not TextureCube
</span><del>-            srvDesc.Texture2DArray.MostDetailedMip = level;
</del><ins>+            srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + level;
</ins><span class="cx">             srvDesc.Texture2DArray.MipLevels = 1;
</span><del>-            srvDesc.Texture2DArray.FirstArraySlice = faceIdx;
</del><ins>+            srvDesc.Texture2DArray.FirstArraySlice = faceIndex;
</ins><span class="cx">             srvDesc.Texture2DArray.ArraySize = 1;
</span><span class="cx"> 
</span><span class="cx">             ID3D11ShaderResourceView *srv;
</span><span class="lines">@@ -569,8 +803,8 @@
</span><span class="cx">                 D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
</span><span class="cx">                 rtvDesc.Format = mRenderTargetFormat;
</span><span class="cx">                 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
</span><del>-                rtvDesc.Texture2DArray.MipSlice = level;
-                rtvDesc.Texture2DArray.FirstArraySlice = faceIdx;
</del><ins>+                rtvDesc.Texture2DArray.MipSlice = mTopLevel + level;
+                rtvDesc.Texture2DArray.FirstArraySlice = faceIndex;
</ins><span class="cx">                 rtvDesc.Texture2DArray.ArraySize = 1;
</span><span class="cx"> 
</span><span class="cx">                 ID3D11RenderTargetView *rtv;
</span><span class="lines">@@ -578,26 +812,25 @@
</span><span class="cx"> 
</span><span class="cx">                 if (result == E_OUTOFMEMORY)
</span><span class="cx">                 {
</span><del>-                    srv-&gt;Release();
</del><ins>+                    SafeRelease(srv);
</ins><span class="cx">                     return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;RenderTarget*&gt;(NULL));
</span><span class="cx">                 }
</span><span class="cx">                 ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-                // RenderTarget11 expects to be the owner of the resources it is given but TextureStorage11
-                // also needs to keep a reference to the texture.
-                mTexture-&gt;AddRef();
</del><ins>+                mRenderTarget[faceIndex][level] = new RenderTarget11(mRenderer, rtv, mTexture, srv, getLevelWidth(level), getLevelHeight(level), 1);
</ins><span class="cx"> 
</span><del>-                mRenderTarget[faceIdx][level] = new RenderTarget11(mRenderer, rtv, mTexture, srv,
-                                                                   std::max(mTextureWidth &gt;&gt; level, 1U),
-                                                                   std::max(mTextureHeight &gt;&gt; level, 1U));
</del><ins>+                // RenderTarget will take ownership of these resources
+                SafeRelease(rtv);
+                SafeRelease(srv);
</ins><span class="cx">             }
</span><span class="cx">             else if (mDepthStencilFormat != DXGI_FORMAT_UNKNOWN)
</span><span class="cx">             {
</span><span class="cx">                 D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
</span><del>-                dsvDesc.Format = mRenderTargetFormat;
</del><ins>+                dsvDesc.Format = mDepthStencilFormat;
</ins><span class="cx">                 dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
</span><del>-                dsvDesc.Texture2DArray.MipSlice = level;
-                dsvDesc.Texture2DArray.FirstArraySlice = faceIdx;
</del><ins>+                dsvDesc.Flags = 0;
+                dsvDesc.Texture2DArray.MipSlice = mTopLevel + level;
+                dsvDesc.Texture2DArray.FirstArraySlice = faceIndex;
</ins><span class="cx">                 dsvDesc.Texture2DArray.ArraySize = 1;
</span><span class="cx"> 
</span><span class="cx">                 ID3D11DepthStencilView *dsv;
</span><span class="lines">@@ -605,18 +838,16 @@
</span><span class="cx"> 
</span><span class="cx">                 if (result == E_OUTOFMEMORY)
</span><span class="cx">                 {
</span><del>-                    srv-&gt;Release();
</del><ins>+                    SafeRelease(srv);
</ins><span class="cx">                     return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;RenderTarget*&gt;(NULL));
</span><span class="cx">                 }
</span><span class="cx">                 ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-                // RenderTarget11 expects to be the owner of the resources it is given but TextureStorage11
-                // also needs to keep a reference to the texture.
-                mTexture-&gt;AddRef();
</del><ins>+                mRenderTarget[faceIndex][level] = new RenderTarget11(mRenderer, dsv, mTexture, srv, getLevelWidth(level), getLevelHeight(level), 1);
</ins><span class="cx"> 
</span><del>-                mRenderTarget[faceIdx][level] = new RenderTarget11(mRenderer, dsv, mTexture, srv,
-                                                                   std::max(mTextureWidth &gt;&gt; level, 1U),
-                                                                   std::max(mTextureHeight &gt;&gt; level, 1U));
</del><ins>+                // RenderTarget will take ownership of these resources
+                SafeRelease(dsv);
+                SafeRelease(srv);
</ins><span class="cx">             }
</span><span class="cx">             else
</span><span class="cx">             {
</span><span class="lines">@@ -624,7 +855,7 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return mRenderTarget[faceIdx][level];
</del><ins>+        return mRenderTarget[faceIndex][level];
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="lines">@@ -632,36 +863,705 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ID3D11ShaderResourceView *TextureStorage11_Cube::getSRV()
</del><ins>+ID3D11ShaderResourceView *TextureStorage11_Cube::createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture)
</ins><span class="cx"> {
</span><del>-    if (!mSRV)
</del><ins>+    D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+    srvDesc.Format = format;
+
+    // Unnormalized integer cube maps are not supported by DX11; we emulate them as an array of six 2D textures
+    bool unnormalizedInteger = (d3d11::GetComponentType(mTextureFormat) == GL_INT ||
+                                d3d11::GetComponentType(mTextureFormat) == GL_UNSIGNED_INT);
+
+    if(unnormalizedInteger)
</ins><span class="cx">     {
</span><ins>+        srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
+        srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + baseLevel;
+        srvDesc.Texture2DArray.MipLevels = 1;
+        srvDesc.Texture2DArray.FirstArraySlice = 0;
+        srvDesc.Texture2DArray.ArraySize = 6;
+    }
+    else
+    {
+        srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
+        srvDesc.TextureCube.MipLevels = mipLevels;
+        srvDesc.TextureCube.MostDetailedMip = mTopLevel + baseLevel;
+    }
+
+    ID3D11ShaderResourceView *SRV = NULL;
+
+    ID3D11Device *device = mRenderer-&gt;getDevice();
+    HRESULT result = device-&gt;CreateShaderResourceView(texture, &amp;srvDesc, &amp;SRV);
+
+    if (result == E_OUTOFMEMORY)
+    {
+        gl::error(GL_OUT_OF_MEMORY);
+    }
+    ASSERT(SUCCEEDED(result));
+
+    return SRV;
+}
+
+void TextureStorage11_Cube::generateMipmap(int faceIndex, int level)
+{
+    invalidateSwizzleCacheLevel(level);
+
+    RenderTarget11 *source = RenderTarget11::makeRenderTarget11(getRenderTargetFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level - 1));
+    RenderTarget11 *dest = RenderTarget11::makeRenderTarget11(getRenderTargetFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level));
+
+    generateMipmapLayer(source, dest);
+}
+
+ID3D11Resource *TextureStorage11_Cube::getSwizzleTexture()
+{
+    if (!mSwizzleTexture)
+    {
</ins><span class="cx">         ID3D11Device *device = mRenderer-&gt;getDevice();
</span><span class="cx"> 
</span><del>-        D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
-        srvDesc.Format = mShaderResourceFormat;
-        srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
-        srvDesc.TextureCube.MipLevels = (mMipLevels == 0 ? -1 : mMipLevels);
-        srvDesc.TextureCube.MostDetailedMip = 0;
</del><ins>+        D3D11_TEXTURE2D_DESC desc;
+        desc.Width = mTextureWidth;
+        desc.Height = mTextureHeight;
+        desc.MipLevels = mMipLevels;
+        desc.ArraySize = 6;
+        desc.Format = mSwizzleTextureFormat;
+        desc.SampleDesc.Count = 1;
+        desc.SampleDesc.Quality = 0;
+        desc.Usage = D3D11_USAGE_DEFAULT;
+        desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
+        desc.CPUAccessFlags = 0;
+        desc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
</ins><span class="cx"> 
</span><del>-        HRESULT result = device-&gt;CreateShaderResourceView(mTexture, &amp;srvDesc, &amp;mSRV);
</del><ins>+        HRESULT result = device-&gt;CreateTexture2D(&amp;desc, NULL, &amp;mSwizzleTexture);
</ins><span class="cx"> 
</span><span class="cx">         if (result == E_OUTOFMEMORY)
</span><span class="cx">         {
</span><del>-            return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11ShaderResourceView*&gt;(NULL));
</del><ins>+            return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11Texture2D*&gt;(NULL));
</ins><span class="cx">         }
</span><span class="cx">         ASSERT(SUCCEEDED(result));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return mSRV;
</del><ins>+    return mSwizzleTexture;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureStorage11_Cube::generateMipmap(int face, int level)
</del><ins>+ID3D11RenderTargetView *TextureStorage11_Cube::getSwizzleRenderTarget(int mipLevel)
</ins><span class="cx"> {
</span><del>-    RenderTarget11 *source = RenderTarget11::makeRenderTarget11(getRenderTarget(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level - 1));
-    RenderTarget11 *dest = RenderTarget11::makeRenderTarget11(getRenderTarget(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level));
</del><ins>+    if (mipLevel &gt;= 0 &amp;&amp; mipLevel &lt; getLevelCount())
+    {
+        if (!mSwizzleRenderTargets[mipLevel])
+        {
+            ID3D11Resource *swizzleTexture = getSwizzleTexture();
+            if (!swizzleTexture)
+            {
+                return NULL;
+            }
</ins><span class="cx"> 
</span><ins>+            ID3D11Device *device = mRenderer-&gt;getDevice();
+
+            D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
+            rtvDesc.Format = mSwizzleRenderTargetFormat;
+            rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
+            rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
+            rtvDesc.Texture2DArray.FirstArraySlice = 0;
+            rtvDesc.Texture2DArray.ArraySize = 6;
+
+            HRESULT result = device-&gt;CreateRenderTargetView(mSwizzleTexture, &amp;rtvDesc, &amp;mSwizzleRenderTargets[mipLevel]);
+
+            if (result == E_OUTOFMEMORY)
+            {
+                return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11RenderTargetView*&gt;(NULL));
+            }
+            ASSERT(SUCCEEDED(result));
+        }
+
+        return mSwizzleRenderTargets[mipLevel];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+unsigned int TextureStorage11_Cube::getTextureLevelDepth(int mipLevel) const
+{
+    return 6;
+}
+
+TextureStorage11_3D::TextureStorage11_3D(Renderer *renderer, GLenum internalformat, bool renderTarget,
+                                         GLsizei width, GLsizei height, GLsizei depth, int levels)
+    : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderer-&gt;getCurrentClientVersion(), renderTarget))
+{
+    mTexture = NULL;
+    mSwizzleTexture = NULL;
+
+    for (unsigned int i = 0; i &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
+    {
+        mLevelRenderTargets[i] = NULL;
+        mSwizzleRenderTargets[i] = NULL;
+    }
+
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+
+    mTextureFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion);
+    mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat, clientVersion);
+    mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat, clientVersion);
+    mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat, clientVersion);
+    mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat, renderer);
+    mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat, renderer);
+    mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat, renderer);
+
+    // If the width, height or depth are not positive this should be treated as an incomplete texture
+    // we handle that here by skipping the d3d texture creation
+    if (width &gt; 0 &amp;&amp; height &gt; 0 &amp;&amp; depth &gt; 0)
+    {
+        // adjust size if needed for compressed textures
+        d3d11::MakeValidSize(false, mTextureFormat, &amp;width, &amp;height, &amp;mTopLevel);
+
+        ID3D11Device *device = mRenderer-&gt;getDevice();
+
+        D3D11_TEXTURE3D_DESC desc;
+        desc.Width = width;
+        desc.Height = height;
+        desc.Depth = depth;
+        desc.MipLevels = ((levels &gt; 0) ? (mTopLevel + levels) : 0);
+        desc.Format = mTextureFormat;
+        desc.Usage = D3D11_USAGE_DEFAULT;
+        desc.BindFlags = getBindFlags();
+        desc.CPUAccessFlags = 0;
+        desc.MiscFlags = 0;
+
+        HRESULT result = device-&gt;CreateTexture3D(&amp;desc, NULL, &amp;mTexture);
+
+        // this can happen from windows TDR
+        if (d3d11::isDeviceLostError(result))
+        {
+            mRenderer-&gt;notifyDeviceLost();
+            gl::error(GL_OUT_OF_MEMORY);
+        }
+        else if (FAILED(result))
+        {
+            ASSERT(result == E_OUTOFMEMORY);
+            ERR(&quot;Creating image failed.&quot;);
+            gl::error(GL_OUT_OF_MEMORY);
+        }
+        else
+        {
+            mTexture-&gt;GetDesc(&amp;desc);
+            mMipLevels = desc.MipLevels;
+            mTextureWidth = desc.Width;
+            mTextureHeight = desc.Height;
+            mTextureDepth = desc.Depth;
+        }
+    }
+}
+
+TextureStorage11_3D::~TextureStorage11_3D()
+{
+    SafeRelease(mTexture);
+    SafeRelease(mSwizzleTexture);
+
+    for (RenderTargetMap::iterator i = mLevelLayerRenderTargets.begin(); i != mLevelLayerRenderTargets.end(); i++)
+    {
+        SafeDelete(i-&gt;second);
+    }
+    mLevelLayerRenderTargets.clear();
+
+    for (unsigned int i = 0; i &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
+    {
+        SafeDelete(mLevelRenderTargets[i]);
+        SafeRelease(mSwizzleRenderTargets[i]);
+    }
+}
+
+TextureStorage11_3D *TextureStorage11_3D::makeTextureStorage11_3D(TextureStorage *storage)
+{
+    ASSERT(HAS_DYNAMIC_TYPE(TextureStorage11_3D*, storage));
+    return static_cast&lt;TextureStorage11_3D*&gt;(storage);
+}
+
+ID3D11Resource *TextureStorage11_3D::getResource() const
+{
+    return mTexture;
+}
+
+ID3D11ShaderResourceView *TextureStorage11_3D::createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture)
+{
+    D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+    srvDesc.Format = format;
+    srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
+    srvDesc.Texture3D.MostDetailedMip = baseLevel;
+    srvDesc.Texture3D.MipLevels = mipLevels;
+
+    ID3D11ShaderResourceView *SRV = NULL;
+
+    ID3D11Device *device = mRenderer-&gt;getDevice();
+    HRESULT result = device-&gt;CreateShaderResourceView(texture, &amp;srvDesc, &amp;SRV);
+
+    if (result == E_OUTOFMEMORY)
+    {
+        gl::error(GL_OUT_OF_MEMORY);
+    }
+    ASSERT(SUCCEEDED(result));
+
+    return SRV;
+}
+
+RenderTarget *TextureStorage11_3D::getRenderTarget(int mipLevel)
+{
+    if (mipLevel &gt;= 0 &amp;&amp; mipLevel &lt; getLevelCount())
+    {
+        if (!mLevelRenderTargets[mipLevel])
+        {
+            ID3D11ShaderResourceView *srv = getSRVLevel(mipLevel);
+            if (!srv)
+            {
+                return NULL;
+            }
+
+            if (mRenderTargetFormat != DXGI_FORMAT_UNKNOWN)
+            {
+                ID3D11Device *device = mRenderer-&gt;getDevice();
+
+                D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
+                rtvDesc.Format = mRenderTargetFormat;
+                rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
+                rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
+                rtvDesc.Texture3D.FirstWSlice = 0;
+                rtvDesc.Texture3D.WSize = -1;
+
+                ID3D11RenderTargetView *rtv;
+                HRESULT result = device-&gt;CreateRenderTargetView(mTexture, &amp;rtvDesc, &amp;rtv);
+
+                if (result == E_OUTOFMEMORY)
+                {
+                    SafeRelease(srv);
+                    return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;RenderTarget*&gt;(NULL));
+                }
+                ASSERT(SUCCEEDED(result));
+
+                mLevelRenderTargets[mipLevel] = new RenderTarget11(mRenderer, rtv, mTexture, srv, getLevelWidth(mipLevel), getLevelHeight(mipLevel), getLevelDepth(mipLevel));
+
+                // RenderTarget will take ownership of these resources
+                SafeRelease(rtv);
+            }
+            else
+            {
+                UNREACHABLE();
+            }
+        }
+
+        return mLevelRenderTargets[mipLevel];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+RenderTarget *TextureStorage11_3D::getRenderTargetLayer(int mipLevel, int layer)
+{
+    if (mipLevel &gt;= 0 &amp;&amp; mipLevel &lt; getLevelCount())
+    {
+        LevelLayerKey key(mipLevel, layer);
+        if (mLevelLayerRenderTargets.find(key) == mLevelLayerRenderTargets.end())
+        {
+            ID3D11Device *device = mRenderer-&gt;getDevice();
+            HRESULT result;
+
+            // TODO, what kind of SRV is expected here?
+            ID3D11ShaderResourceView *srv = NULL;
+
+            if (mRenderTargetFormat != DXGI_FORMAT_UNKNOWN)
+            {
+                D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
+                rtvDesc.Format = mRenderTargetFormat;
+                rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
+                rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
+                rtvDesc.Texture3D.FirstWSlice = layer;
+                rtvDesc.Texture3D.WSize = 1;
+
+                ID3D11RenderTargetView *rtv;
+                result = device-&gt;CreateRenderTargetView(mTexture, &amp;rtvDesc, &amp;rtv);
+
+                if (result == E_OUTOFMEMORY)
+                {
+                    SafeRelease(srv);
+                    return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;RenderTarget*&gt;(NULL));
+                }
+                ASSERT(SUCCEEDED(result));
+
+                mLevelLayerRenderTargets[key] = new RenderTarget11(mRenderer, rtv, mTexture, srv, getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1);
+
+                // RenderTarget will take ownership of these resources
+                SafeRelease(rtv);
+                SafeRelease(srv);
+            }
+            else
+            {
+                UNREACHABLE();
+            }
+        }
+
+        return mLevelLayerRenderTargets[key];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+void TextureStorage11_3D::generateMipmap(int level)
+{
+    invalidateSwizzleCacheLevel(level);
+
+    RenderTarget11 *source = RenderTarget11::makeRenderTarget11(getRenderTarget(level - 1));
+    RenderTarget11 *dest = RenderTarget11::makeRenderTarget11(getRenderTarget(level));
+
</ins><span class="cx">     generateMipmapLayer(source, dest);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ID3D11Resource *TextureStorage11_3D::getSwizzleTexture()
+{
+    if (!mSwizzleTexture)
+    {
+        ID3D11Device *device = mRenderer-&gt;getDevice();
+
+        D3D11_TEXTURE3D_DESC desc;
+        desc.Width = mTextureWidth;
+        desc.Height = mTextureHeight;
+        desc.Depth = mTextureDepth;
+        desc.MipLevels = mMipLevels;
+        desc.Format = mSwizzleTextureFormat;
+        desc.Usage = D3D11_USAGE_DEFAULT;
+        desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
+        desc.CPUAccessFlags = 0;
+        desc.MiscFlags = 0;
+
+        HRESULT result = device-&gt;CreateTexture3D(&amp;desc, NULL, &amp;mSwizzleTexture);
+
+        if (result == E_OUTOFMEMORY)
+        {
+            return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11Texture3D*&gt;(NULL));
+        }
+        ASSERT(SUCCEEDED(result));
+    }
+
+    return mSwizzleTexture;
</ins><span class="cx"> }
</span><ins>+
+ID3D11RenderTargetView *TextureStorage11_3D::getSwizzleRenderTarget(int mipLevel)
+{
+    if (mipLevel &gt;= 0 &amp;&amp; mipLevel &lt; getLevelCount())
+    {
+        if (!mSwizzleRenderTargets[mipLevel])
+        {
+            ID3D11Resource *swizzleTexture = getSwizzleTexture();
+            if (!swizzleTexture)
+            {
+                return NULL;
+            }
+
+            ID3D11Device *device = mRenderer-&gt;getDevice();
+
+            D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
+            rtvDesc.Format = mSwizzleRenderTargetFormat;
+            rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
+            rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
+            rtvDesc.Texture3D.FirstWSlice = 0;
+            rtvDesc.Texture3D.WSize = -1;
+
+            HRESULT result = device-&gt;CreateRenderTargetView(mSwizzleTexture, &amp;rtvDesc, &amp;mSwizzleRenderTargets[mipLevel]);
+
+            if (result == E_OUTOFMEMORY)
+            {
+                return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11RenderTargetView*&gt;(NULL));
+            }
+            ASSERT(SUCCEEDED(result));
+        }
+
+        return mSwizzleRenderTargets[mipLevel];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+unsigned int TextureStorage11_3D::getTextureLevelDepth(int mipLevel) const
+{
+    return std::max(mTextureDepth &gt;&gt; mipLevel, 1U);
+}
+
+
+TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer *renderer, GLenum internalformat, bool renderTarget,
+                                                   GLsizei width, GLsizei height, GLsizei depth, int levels)
+    : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderer-&gt;getCurrentClientVersion(), renderTarget))
+{
+    mTexture = NULL;
+    mSwizzleTexture = NULL;
+
+    for (unsigned int level = 0; level &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
+    {
+        mSwizzleRenderTargets[level] = NULL;
+    }
+
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+
+    mTextureFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion);
+    mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat, clientVersion);
+    mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat, clientVersion);
+    mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat, clientVersion);
+    mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat, renderer);
+    mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat, renderer);
+    mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat, renderer);
+
+    // if the width, height or depth is not positive this should be treated as an incomplete texture
+    // we handle that here by skipping the d3d texture creation
+    if (width &gt; 0 &amp;&amp; height &gt; 0 &amp;&amp; depth &gt; 0)
+    {
+        // adjust size if needed for compressed textures
+        d3d11::MakeValidSize(false, mTextureFormat, &amp;width, &amp;height, &amp;mTopLevel);
+
+        ID3D11Device *device = mRenderer-&gt;getDevice();
+
+        D3D11_TEXTURE2D_DESC desc;
+        desc.Width = width;
+        desc.Height = height;
+        desc.MipLevels = ((levels &gt; 0) ? (mTopLevel + levels) : 0);
+        desc.ArraySize = depth;
+        desc.Format = mTextureFormat;
+        desc.SampleDesc.Count = 1;
+        desc.SampleDesc.Quality = 0;
+        desc.Usage = D3D11_USAGE_DEFAULT;
+        desc.BindFlags = getBindFlags();
+        desc.CPUAccessFlags = 0;
+        desc.MiscFlags = 0;
+
+        HRESULT result = device-&gt;CreateTexture2D(&amp;desc, NULL, &amp;mTexture);
+
+        // this can happen from windows TDR
+        if (d3d11::isDeviceLostError(result))
+        {
+            mRenderer-&gt;notifyDeviceLost();
+            gl::error(GL_OUT_OF_MEMORY);
+        }
+        else if (FAILED(result))
+        {
+            ASSERT(result == E_OUTOFMEMORY);
+            ERR(&quot;Creating image failed.&quot;);
+            gl::error(GL_OUT_OF_MEMORY);
+        }
+        else
+        {
+            mTexture-&gt;GetDesc(&amp;desc);
+            mMipLevels = desc.MipLevels;
+            mTextureWidth = desc.Width;
+            mTextureHeight = desc.Height;
+            mTextureDepth = desc.ArraySize;
+        }
+    }
+}
+
+TextureStorage11_2DArray::~TextureStorage11_2DArray()
+{
+    SafeRelease(mTexture);
+    SafeRelease(mSwizzleTexture);
+
+    for (unsigned int level = 0; level &lt; gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
+    {
+        SafeRelease(mSwizzleRenderTargets[level]);
+    }
+
+    for (RenderTargetMap::iterator i = mRenderTargets.begin(); i != mRenderTargets.end(); i++)
+    {
+        SafeDelete(i-&gt;second);
+    }
+    mRenderTargets.clear();
+}
+
+TextureStorage11_2DArray *TextureStorage11_2DArray::makeTextureStorage11_2DArray(TextureStorage *storage)
+{
+    ASSERT(HAS_DYNAMIC_TYPE(TextureStorage11_2DArray*, storage));
+    return static_cast&lt;TextureStorage11_2DArray*&gt;(storage);
+}
+
+ID3D11Resource *TextureStorage11_2DArray::getResource() const
+{
+    return mTexture;
+}
+
+ID3D11ShaderResourceView *TextureStorage11_2DArray::createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture)
+{
+    D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+    srvDesc.Format = format;
+    srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
+    srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + baseLevel;
+    srvDesc.Texture2DArray.MipLevels = mipLevels;
+    srvDesc.Texture2DArray.FirstArraySlice = 0;
+    srvDesc.Texture2DArray.ArraySize = mTextureDepth;
+
+    ID3D11ShaderResourceView *SRV = NULL;
+
+    ID3D11Device *device = mRenderer-&gt;getDevice();
+    HRESULT result = device-&gt;CreateShaderResourceView(texture, &amp;srvDesc, &amp;SRV);
+
+    if (result == E_OUTOFMEMORY)
+    {
+        gl::error(GL_OUT_OF_MEMORY);
+    }
+    ASSERT(SUCCEEDED(result));
+
+    return SRV;
+}
+
+RenderTarget *TextureStorage11_2DArray::getRenderTargetLayer(int mipLevel, int layer)
+{
+    if (mipLevel &gt;= 0 &amp;&amp; mipLevel &lt; getLevelCount())
+    {
+        LevelLayerKey key(mipLevel, layer);
+        if (mRenderTargets.find(key) == mRenderTargets.end())
+        {
+            ID3D11Device *device = mRenderer-&gt;getDevice();
+            HRESULT result;
+
+            D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+            srvDesc.Format = mShaderResourceFormat;
+            srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
+            srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + mipLevel;
+            srvDesc.Texture2DArray.MipLevels = 1;
+            srvDesc.Texture2DArray.FirstArraySlice = layer;
+            srvDesc.Texture2DArray.ArraySize = 1;
+
+            ID3D11ShaderResourceView *srv;
+            result = device-&gt;CreateShaderResourceView(mTexture, &amp;srvDesc, &amp;srv);
+
+            if (result == E_OUTOFMEMORY)
+            {
+                return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;RenderTarget*&gt;(NULL));
+            }
+            ASSERT(SUCCEEDED(result));
+
+            if (mRenderTargetFormat != DXGI_FORMAT_UNKNOWN)
+            {
+                D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
+                rtvDesc.Format = mRenderTargetFormat;
+                rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
+                rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
+                rtvDesc.Texture2DArray.FirstArraySlice = layer;
+                rtvDesc.Texture2DArray.ArraySize = 1;
+
+                ID3D11RenderTargetView *rtv;
+                result = device-&gt;CreateRenderTargetView(mTexture, &amp;rtvDesc, &amp;rtv);
+
+                if (result == E_OUTOFMEMORY)
+                {
+                    SafeRelease(srv);
+                    return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;RenderTarget*&gt;(NULL));
+                }
+                ASSERT(SUCCEEDED(result));
+
+                mRenderTargets[key] = new RenderTarget11(mRenderer, rtv, mTexture, srv, getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1);
+
+                // RenderTarget will take ownership of these resources
+                SafeRelease(rtv);
+                SafeRelease(srv);
+            }
+            else
+            {
+                UNREACHABLE();
+            }
+        }
+
+        return mRenderTargets[key];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+void TextureStorage11_2DArray::generateMipmap(int level)
+{
+    invalidateSwizzleCacheLevel(level);
+    for (unsigned int layer = 0; layer &lt; mTextureDepth; layer++)
+    {
+        RenderTarget11 *source = RenderTarget11::makeRenderTarget11(getRenderTargetLayer(level - 1, layer));
+        RenderTarget11 *dest = RenderTarget11::makeRenderTarget11(getRenderTargetLayer(level, layer));
+
+        generateMipmapLayer(source, dest);
+    }
+}
+
+ID3D11Resource *TextureStorage11_2DArray::getSwizzleTexture()
+{
+    if (!mSwizzleTexture)
+    {
+        ID3D11Device *device = mRenderer-&gt;getDevice();
+
+        D3D11_TEXTURE2D_DESC desc;
+        desc.Width = mTextureWidth;
+        desc.Height = mTextureHeight;
+        desc.MipLevels = mMipLevels;
+        desc.ArraySize = mTextureDepth;
+        desc.Format = mSwizzleTextureFormat;
+        desc.SampleDesc.Count = 1;
+        desc.SampleDesc.Quality = 0;
+        desc.Usage = D3D11_USAGE_DEFAULT;
+        desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
+        desc.CPUAccessFlags = 0;
+        desc.MiscFlags = 0;
+
+        HRESULT result = device-&gt;CreateTexture2D(&amp;desc, NULL, &amp;mSwizzleTexture);
+
+        if (result == E_OUTOFMEMORY)
+        {
+            return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11Texture2D*&gt;(NULL));
+        }
+        ASSERT(SUCCEEDED(result));
+    }
+
+    return mSwizzleTexture;
+}
+
+ID3D11RenderTargetView *TextureStorage11_2DArray::getSwizzleRenderTarget(int mipLevel)
+{
+    if (mipLevel &gt;= 0 &amp;&amp; mipLevel &lt; getLevelCount())
+    {
+        if (!mSwizzleRenderTargets[mipLevel])
+        {
+            ID3D11Resource *swizzleTexture = getSwizzleTexture();
+            if (!swizzleTexture)
+            {
+                return NULL;
+            }
+
+            ID3D11Device *device = mRenderer-&gt;getDevice();
+
+            D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
+            rtvDesc.Format = mSwizzleRenderTargetFormat;
+            rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
+            rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
+            rtvDesc.Texture2DArray.FirstArraySlice = 0;
+            rtvDesc.Texture2DArray.ArraySize = mTextureDepth;
+
+            HRESULT result = device-&gt;CreateRenderTargetView(mSwizzleTexture, &amp;rtvDesc, &amp;mSwizzleRenderTargets[mipLevel]);
+
+            if (result == E_OUTOFMEMORY)
+            {
+                return gl::error(GL_OUT_OF_MEMORY, static_cast&lt;ID3D11RenderTargetView*&gt;(NULL));
+            }
+            ASSERT(SUCCEEDED(result));
+        }
+
+        return mSwizzleRenderTargets[mipLevel];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+unsigned int TextureStorage11_2DArray::getTextureLevelDepth(int mipLevel) const
+{
+    return mTextureDepth;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11TextureStorage11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/TextureStorage11.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/TextureStorage11.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/TextureStorage11.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -24,97 +24,255 @@
</span><span class="cx"> class TextureStorage11 : public TextureStorage
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    TextureStorage11(Renderer *renderer, UINT bindFlags);
</del><span class="cx">     virtual ~TextureStorage11();
</span><span class="cx"> 
</span><span class="cx">     static TextureStorage11 *makeTextureStorage11(TextureStorage *storage);
</span><span class="cx"> 
</span><del>-    static DWORD GetTextureBindFlags(DXGI_FORMAT d3dfmt, GLenum glusage, bool forceRenderable);
-    static bool IsTextureFormatRenderable(DXGI_FORMAT format);
</del><ins>+    static DWORD GetTextureBindFlags(GLenum internalFormat, GLuint clientVersion, bool renderTarget);
</ins><span class="cx"> 
</span><span class="cx">     UINT getBindFlags() const;
</span><span class="cx"> 
</span><del>-    virtual ID3D11Texture2D *getBaseTexture() const;
-    virtual ID3D11ShaderResourceView *getSRV() = 0;
-    virtual RenderTarget *getRenderTarget() { return getRenderTarget(0); }
</del><ins>+    virtual ID3D11Resource *getResource() const = 0;
+    virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &amp;samplerState);
</ins><span class="cx">     virtual RenderTarget *getRenderTarget(int level) { return NULL; }
</span><del>-    virtual RenderTarget *getRenderTarget(GLenum faceTarget) { return getRenderTarget(faceTarget, 0); }
-    virtual RenderTarget *getRenderTarget(GLenum faceTarget, int level) { return NULL; }
</del><ins>+    virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level) { return NULL; }
+    virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer) { return NULL; }
</ins><span class="cx"> 
</span><span class="cx">     virtual void generateMipmap(int level) {};
</span><span class="cx">     virtual void generateMipmap(int face, int level) {};
</span><span class="cx"> 
</span><del>-    virtual int getLodOffset() const;
</del><ins>+    virtual int getTopLevel() const;
</ins><span class="cx">     virtual bool isRenderTarget() const;
</span><span class="cx">     virtual bool isManaged() const;
</span><del>-    virtual int levelCount();
-    UINT getSubresourceIndex(int level, int faceTarget);
</del><ins>+    virtual int getLevelCount() const;
+    UINT getSubresourceIndex(int mipLevel, int layerTarget) const;
</ins><span class="cx"> 
</span><del>-    bool updateSubresourceLevel(ID3D11Texture2D *texture, unsigned int sourceSubresource, int level,
-                                int faceTarget, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
</del><ins>+    void generateSwizzles(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
+    void invalidateSwizzleCacheLevel(int mipLevel);
+    void invalidateSwizzleCache();
</ins><span class="cx"> 
</span><ins>+    bool updateSubresourceLevel(ID3D11Resource *texture, unsigned int sourceSubresource, int level,
+                                int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset,
+                                GLsizei width, GLsizei height, GLsizei depth);
+
</ins><span class="cx">   protected:
</span><ins>+    TextureStorage11(Renderer *renderer, UINT bindFlags);
</ins><span class="cx">     void generateMipmapLayer(RenderTarget11 *source, RenderTarget11 *dest);
</span><ins>+    int getLevelWidth(int mipLevel) const;
+    int getLevelHeight(int mipLevel) const;
+    int getLevelDepth(int mipLevel) const;
</ins><span class="cx"> 
</span><ins>+    virtual ID3D11Resource *getSwizzleTexture() = 0;
+    virtual ID3D11RenderTargetView *getSwizzleRenderTarget(int mipLevel) = 0;
+    ID3D11ShaderResourceView *getSRVLevel(int mipLevel);
+
+    virtual ID3D11ShaderResourceView *createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture) = 0;
+
+    void verifySwizzleExists(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
+
+    virtual unsigned int getTextureLevelDepth(int mipLevel) const = 0;
+
</ins><span class="cx">     Renderer11 *mRenderer;
</span><del>-    int mLodOffset;
</del><ins>+    int mTopLevel;
</ins><span class="cx">     unsigned int mMipLevels;
</span><span class="cx"> 
</span><del>-    ID3D11Texture2D *mTexture;
</del><span class="cx">     DXGI_FORMAT mTextureFormat;
</span><span class="cx">     DXGI_FORMAT mShaderResourceFormat;
</span><span class="cx">     DXGI_FORMAT mRenderTargetFormat;
</span><span class="cx">     DXGI_FORMAT mDepthStencilFormat;
</span><ins>+    DXGI_FORMAT mSwizzleTextureFormat;
+    DXGI_FORMAT mSwizzleShaderResourceFormat;
+    DXGI_FORMAT mSwizzleRenderTargetFormat;
</ins><span class="cx">     unsigned int mTextureWidth;
</span><span class="cx">     unsigned int mTextureHeight;
</span><ins>+    unsigned int mTextureDepth;
</ins><span class="cx"> 
</span><del>-    ID3D11ShaderResourceView *mSRV;
</del><ins>+    struct SwizzleCacheValue
+    {
+        GLenum swizzleRed;
+        GLenum swizzleGreen;
+        GLenum swizzleBlue;
+        GLenum swizzleAlpha;
</ins><span class="cx"> 
</span><ins>+        SwizzleCacheValue();
+        SwizzleCacheValue(GLenum red, GLenum green, GLenum blue, GLenum alpha);
+
+        bool operator ==(const SwizzleCacheValue &amp;other) const;
+        bool operator !=(const SwizzleCacheValue &amp;other) const;
+    };
+    SwizzleCacheValue mSwizzleCache[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
+
+    struct SRVKey
+    {
+        SRVKey(int baseLevel = 0, int mipLevels = 0, bool swizzle = false);
+
+        bool operator==(const SRVKey &amp;rhs) const;
+
+        int baseLevel;
+        int mipLevels;
+        bool swizzle;
+    };
+
+    struct SRVPair
+    {
+        SRVKey key;
+        ID3D11ShaderResourceView *srv;
+    };
+
+    struct SRVCache
+    {
+        ~SRVCache();
+
+        ID3D11ShaderResourceView *find(const SRVKey &amp;key) const;
+        ID3D11ShaderResourceView *add(const SRVKey &amp;key, ID3D11ShaderResourceView *srv);
+
+        std::vector&lt;SRVPair&gt; cache;
+    };
+
</ins><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TextureStorage11);
</span><span class="cx"> 
</span><span class="cx">     const UINT mBindFlags;
</span><ins>+
+    SRVCache srvCache;
+    ID3D11ShaderResourceView *mLevelSRVs[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class TextureStorage11_2D : public TextureStorage11
</span><span class="cx"> {
</span><span class="cx">   public:
</span><span class="cx">     TextureStorage11_2D(Renderer *renderer, SwapChain11 *swapchain);
</span><del>-    TextureStorage11_2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height);
</del><ins>+    TextureStorage11_2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
</ins><span class="cx">     virtual ~TextureStorage11_2D();
</span><span class="cx"> 
</span><span class="cx">     static TextureStorage11_2D *makeTextureStorage11_2D(TextureStorage *storage);
</span><span class="cx"> 
</span><del>-    virtual ID3D11ShaderResourceView *getSRV();
</del><ins>+    virtual ID3D11Resource *getResource() const;
</ins><span class="cx">     virtual RenderTarget *getRenderTarget(int level);
</span><span class="cx"> 
</span><span class="cx">     virtual void generateMipmap(int level);
</span><span class="cx"> 
</span><ins>+  protected:
+    virtual ID3D11Resource *getSwizzleTexture();
+    virtual ID3D11RenderTargetView *getSwizzleRenderTarget(int mipLevel);
+
+    virtual unsigned int getTextureLevelDepth(int mipLevel) const;
+
</ins><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TextureStorage11_2D);
</span><span class="cx"> 
</span><ins>+    virtual ID3D11ShaderResourceView *createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture);
+
+    ID3D11Texture2D *mTexture;
</ins><span class="cx">     RenderTarget11 *mRenderTarget[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
</span><ins>+
+    ID3D11Texture2D *mSwizzleTexture;
+    ID3D11RenderTargetView *mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class TextureStorage11_Cube : public TextureStorage11
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    TextureStorage11_Cube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size);
</del><ins>+    TextureStorage11_Cube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels);
</ins><span class="cx">     virtual ~TextureStorage11_Cube();
</span><span class="cx"> 
</span><span class="cx">     static TextureStorage11_Cube *makeTextureStorage11_Cube(TextureStorage *storage);
</span><span class="cx"> 
</span><del>-    virtual ID3D11ShaderResourceView *getSRV();
-    virtual RenderTarget *getRenderTarget(GLenum faceTarget, int level);
</del><ins>+    virtual ID3D11Resource *getResource() const;
+    virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level);
</ins><span class="cx"> 
</span><del>-    virtual void generateMipmap(int face, int level);
</del><ins>+    virtual void generateMipmap(int faceIndex, int level);
</ins><span class="cx"> 
</span><ins>+  protected:
+    virtual ID3D11Resource *getSwizzleTexture();
+    virtual ID3D11RenderTargetView *getSwizzleRenderTarget(int mipLevel);
+
+    virtual unsigned int getTextureLevelDepth(int mipLevel) const;
+
</ins><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TextureStorage11_Cube);
</span><span class="cx"> 
</span><ins>+    virtual ID3D11ShaderResourceView *createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture);
+
+    ID3D11Texture2D *mTexture;
</ins><span class="cx">     RenderTarget11 *mRenderTarget[6][gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
</span><ins>+
+    ID3D11Texture2D *mSwizzleTexture;
+    ID3D11RenderTargetView *mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class TextureStorage11_3D : public TextureStorage11
+{
+  public:
+    TextureStorage11_3D(Renderer *renderer, GLenum internalformat, bool renderTarget,
+                        GLsizei width, GLsizei height, GLsizei depth, int levels);
+    virtual ~TextureStorage11_3D();
+
+    static TextureStorage11_3D *makeTextureStorage11_3D(TextureStorage *storage);
+
+    virtual ID3D11Resource *getResource() const;
+    virtual RenderTarget *getRenderTarget(int mipLevel);
+    virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer);
+
+    virtual void generateMipmap(int level);
+
+  protected:
+    virtual ID3D11Resource *getSwizzleTexture();
+    virtual ID3D11RenderTargetView *getSwizzleRenderTarget(int mipLevel);
+
+    virtual unsigned int getTextureLevelDepth(int mipLevel) const;
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(TextureStorage11_3D);
+
+    virtual ID3D11ShaderResourceView *createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture);
+
+    typedef std::pair&lt;int, int&gt; LevelLayerKey;
+    typedef std::map&lt;LevelLayerKey, RenderTarget11*&gt; RenderTargetMap;
+    RenderTargetMap mLevelLayerRenderTargets;
+
+    RenderTarget11 *mLevelRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
+
+    ID3D11Texture3D *mTexture;
+    ID3D11Texture3D *mSwizzleTexture;
+    ID3D11RenderTargetView *mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
+};
+
+class TextureStorage11_2DArray : public TextureStorage11
+{
+  public:
+    TextureStorage11_2DArray(Renderer *renderer, GLenum internalformat, bool renderTarget,
+                             GLsizei width, GLsizei height, GLsizei depth, int levels);
+    virtual ~TextureStorage11_2DArray();
+
+    static TextureStorage11_2DArray *makeTextureStorage11_2DArray(TextureStorage *storage);
+
+    virtual ID3D11Resource *getResource() const;
+    virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer);
+
+    virtual void generateMipmap(int level);
+
+  protected:
+    virtual ID3D11Resource *getSwizzleTexture();
+    virtual ID3D11RenderTargetView *getSwizzleRenderTarget(int mipLevel);
+
+    virtual unsigned int getTextureLevelDepth(int mipLevel) const;
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(TextureStorage11_2DArray);
+
+    virtual ID3D11ShaderResourceView *createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture);
+
+    typedef std::pair&lt;int, int&gt; LevelLayerKey;
+    typedef std::map&lt;LevelLayerKey, RenderTarget11*&gt; RenderTargetMap;
+    RenderTargetMap mRenderTargets;
+
+    ID3D11Texture2D *mTexture;
+
+    ID3D11Texture2D *mSwizzleTexture;
+    ID3D11RenderTargetView *mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif // LIBGLESV2_RENDERER_TEXTURESTORAGE11_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11VertexBuffer11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -12,7 +12,8 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/Buffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/Renderer11.h&quot;
</span><del>-#include &quot;libGLESv2/Context.h&quot;
</del><ins>+#include &quot;libGLESv2/VertexAttribute.h&quot;
+#include &quot;libGLESv2/renderer/d3d11/formatutils11.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -26,20 +27,12 @@
</span><span class="cx"> 
</span><span class="cx"> VertexBuffer11::~VertexBuffer11()
</span><span class="cx"> {
</span><del>-    if (mBuffer)
-    {
-        mBuffer-&gt;Release();
-        mBuffer = NULL;
-    }
</del><ins>+    SafeRelease(mBuffer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool VertexBuffer11::initialize(unsigned int size, bool dynamicUsage)
</span><span class="cx"> {
</span><del>-    if (mBuffer)
-    {
-        mBuffer-&gt;Release();
-        mBuffer = NULL;
-    }
</del><ins>+    SafeRelease(mBuffer);
</ins><span class="cx"> 
</span><span class="cx">     updateSerial();
</span><span class="cx"> 
</span><span class="lines">@@ -73,16 +66,13 @@
</span><span class="cx">     return static_cast&lt;VertexBuffer11*&gt;(vetexBuffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &amp;attrib, GLint start, GLsizei count,
-                                           GLsizei instances, unsigned int offset)
</del><ins>+bool VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &amp;attrib, const gl::VertexAttribCurrentValueData &amp;currentValue,
+                                           GLint start, GLsizei count, GLsizei instances, unsigned int offset)
</ins><span class="cx"> {
</span><span class="cx">     if (mBuffer)
</span><span class="cx">     {
</span><span class="cx">         gl::Buffer *buffer = attrib.mBoundBuffer.get();
</span><del>-
</del><span class="cx">         int inputStride = attrib.stride();
</span><del>-        const VertexConverter &amp;converter = getVertexConversion(attrib);
-
</del><span class="cx">         ID3D11DeviceContext *dxContext = mRenderer-&gt;getDeviceContext();
</span><span class="cx"> 
</span><span class="cx">         D3D11_MAPPED_SUBRESOURCE mappedResource;
</span><span class="lines">@@ -96,14 +86,21 @@
</span><span class="cx">         char* output = reinterpret_cast&lt;char*&gt;(mappedResource.pData) + offset;
</span><span class="cx"> 
</span><span class="cx">         const char *input = NULL;
</span><del>-        if (buffer)
</del><ins>+        if (attrib.mArrayEnabled)
</ins><span class="cx">         {
</span><del>-            BufferStorage *storage = buffer-&gt;getStorage();
-            input = static_cast&lt;const char*&gt;(storage-&gt;getData()) + static_cast&lt;int&gt;(attrib.mOffset);
</del><ins>+            if (buffer)
+            {
+                BufferStorage *storage = buffer-&gt;getStorage();
+                input = static_cast&lt;const char*&gt;(storage-&gt;getData()) + static_cast&lt;int&gt;(attrib.mOffset);
+            }
+            else
+            {
+                input = static_cast&lt;const char*&gt;(attrib.mPointer);
+            }
</ins><span class="cx">         }
</span><span class="cx">         else
</span><span class="cx">         {
</span><del>-            input = static_cast&lt;const char*&gt;(attrib.mPointer);
</del><ins>+            input = reinterpret_cast&lt;const char*&gt;(currentValue.FloatValues);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (instances == 0 || attrib.mDivisor == 0)
</span><span class="lines">@@ -111,7 +108,10 @@
</span><span class="cx">             input += inputStride * start;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        converter.conversionFunc(input, inputStride, count, output);
</del><ins>+        gl::VertexFormat vertexFormat(attrib, currentValue.Type);
+        VertexCopyFunction conversionFunc = gl_d3d11::GetVertexCopyFunction(vertexFormat);
+        ASSERT(conversionFunc != NULL);
+        conversionFunc(input, inputStride, count, output);
</ins><span class="cx"> 
</span><span class="cx">         dxContext-&gt;Unmap(mBuffer, 0);
</span><span class="cx"> 
</span><span class="lines">@@ -124,76 +124,55 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool VertexBuffer11::storeRawData(const void* data, unsigned int size, unsigned int offset)
-{
-    if (mBuffer)
-    {
-        ID3D11DeviceContext *dxContext = mRenderer-&gt;getDeviceContext();
-
-        D3D11_MAPPED_SUBRESOURCE mappedResource;
-        HRESULT result = dxContext-&gt;Map(mBuffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &amp;mappedResource);
-        if (FAILED(result))
-        {
-            ERR(&quot;Vertex buffer map failed with error 0x%08x&quot;, result);
-            return false;
-        }
-
-        char* bufferData = static_cast&lt;char*&gt;(mappedResource.pData);
-        memcpy(bufferData + offset, data, size);
-
-        dxContext-&gt;Unmap(mBuffer, 0);
-
-        return true;
-    }
-    else
-    {
-        ERR(&quot;Vertex buffer not initialized.&quot;);
-        return false;
-    }
-}
-
</del><span class="cx"> bool VertexBuffer11::getSpaceRequired(const gl::VertexAttribute &amp;attrib, GLsizei count,
</span><span class="cx">                                       GLsizei instances, unsigned int *outSpaceRequired) const
</span><span class="cx"> {
</span><del>-    unsigned int elementSize = getVertexConversion(attrib).outputElementSize;
-
</del><span class="cx">     unsigned int elementCount = 0;
</span><del>-    if (instances == 0 || attrib.mDivisor == 0)
</del><ins>+    if (attrib.mArrayEnabled)
</ins><span class="cx">     {
</span><del>-        elementCount = count;
-    }
-    else
-    {
-        if (static_cast&lt;unsigned int&gt;(instances) &lt; std::numeric_limits&lt;unsigned int&gt;::max() - (attrib.mDivisor - 1))
</del><ins>+        if (instances == 0 || attrib.mDivisor == 0)
</ins><span class="cx">         {
</span><del>-            // Round up
-            elementCount = (static_cast&lt;unsigned int&gt;(instances) + (attrib.mDivisor - 1)) / attrib.mDivisor;
</del><ins>+            elementCount = count;
</ins><span class="cx">         }
</span><span class="cx">         else
</span><span class="cx">         {
</span><del>-            elementCount = instances / attrib.mDivisor;
</del><ins>+            if (static_cast&lt;unsigned int&gt;(instances) &lt; std::numeric_limits&lt;unsigned int&gt;::max() - (attrib.mDivisor - 1))
+            {
+                // Round up
+                elementCount = rx::roundUp(static_cast&lt;unsigned int&gt;(instances), attrib.mDivisor);
+            }
+            else
+            {
+                elementCount = instances / attrib.mDivisor;
+            }
</ins><span class="cx">         }
</span><del>-    }
</del><span class="cx"> 
</span><del>-    if (elementSize &lt;= std::numeric_limits&lt;unsigned int&gt;::max() / elementCount)
</del><ins>+        gl::VertexFormat vertexFormat(attrib);
+        unsigned int elementSize = static_cast&lt;unsigned int&gt;(gl_d3d11::GetVertexElementSize(vertexFormat));
+        if (elementSize &lt;= std::numeric_limits&lt;unsigned int&gt;::max() / elementCount)
+        {
+            if (outSpaceRequired)
+            {
+                *outSpaceRequired = elementSize * elementCount;
+            }
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    else
</ins><span class="cx">     {
</span><ins>+        const unsigned int elementSize = 4;
</ins><span class="cx">         if (outSpaceRequired)
</span><span class="cx">         {
</span><del>-            *outSpaceRequired = elementSize * elementCount;
</del><ins>+            *outSpaceRequired = elementSize * 4;
</ins><span class="cx">         }
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><del>-    else
-    {
-        return false;
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool VertexBuffer11::requiresConversion(const gl::VertexAttribute &amp;attrib) const
-{
-    return !getVertexConversion(attrib).identity;
-}
-
</del><span class="cx"> unsigned int VertexBuffer11::getBufferSize() const
</span><span class="cx"> {
</span><span class="cx">     return mBufferSize;
</span><span class="lines">@@ -236,205 +215,9 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned int VertexBuffer11::getVertexSize(const gl::VertexAttribute &amp;attrib) const
-{
-    return getVertexConversion(attrib).outputElementSize;
-}
-
-DXGI_FORMAT VertexBuffer11::getDXGIFormat(const gl::VertexAttribute &amp;attrib) const
-{
-    return getVertexConversion(attrib).dxgiFormat;
-}
-
</del><span class="cx"> ID3D11Buffer *VertexBuffer11::getBuffer() const
</span><span class="cx"> {
</span><span class="cx">     return mBuffer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template &lt;typename T, unsigned int componentCount, bool widen, bool normalized&gt;
-static void copyVertexData(const void *input, unsigned int stride, unsigned int count, void *output)
-{
-    unsigned int attribSize = sizeof(T) * componentCount;
-
-    if (attribSize == stride &amp;&amp; !widen)
-    {
-        memcpy(output, input, count * attribSize);
-    }
-    else
-    {
-        unsigned int outputStride = widen ? 4 : componentCount;
-        T defaultVal = normalized ? std::numeric_limits&lt;T&gt;::max() : T(1);
-
-        for (unsigned int i = 0; i &lt; count; i++)
-        {
-            const T *offsetInput = reinterpret_cast&lt;const T*&gt;(reinterpret_cast&lt;const char*&gt;(input) + i * stride);
-            T *offsetOutput = reinterpret_cast&lt;T*&gt;(output) + i * outputStride;
-
-            for (unsigned int j = 0; j &lt; componentCount; j++)
-            {
-                offsetOutput[j] = offsetInput[j];
-            }
-
-            if (widen)
-            {
-                offsetOutput[3] = defaultVal;
-            }
-        }
-    }
</del><span class="cx"> }
</span><del>-
-template &lt;unsigned int componentCount&gt;
-static void copyFixedVertexData(const void* input, unsigned int stride, unsigned int count, void* output)
-{
-    static const float divisor = 1.0f / (1 &lt;&lt; 16);
-
-    for (unsigned int i = 0; i &lt; count; i++)
-    {
-        const GLfixed* offsetInput = reinterpret_cast&lt;const GLfixed*&gt;(reinterpret_cast&lt;const char*&gt;(input) + stride * i);
-        float* offsetOutput = reinterpret_cast&lt;float*&gt;(output) + i * componentCount;
-
-        for (unsigned int j = 0; j &lt; componentCount; j++)
-        {
-            offsetOutput[j] = static_cast&lt;float&gt;(offsetInput[j]) * divisor;
-        }
-    }
-}
-
-template &lt;typename T, unsigned int componentCount, bool normalized&gt;
-static void copyToFloatVertexData(const void* input, unsigned int stride, unsigned int count, void* output)
-{
-    typedef std::numeric_limits&lt;T&gt; NL;
-
-    for (unsigned int i = 0; i &lt; count; i++)
-    {
-        const T *offsetInput = reinterpret_cast&lt;const T*&gt;(reinterpret_cast&lt;const char*&gt;(input) + stride * i);
-        float *offsetOutput = reinterpret_cast&lt;float*&gt;(output) + i * componentCount;
-
-        for (unsigned int j = 0; j &lt; componentCount; j++)
-        {
-            if (normalized)
-            {
-                if (NL::is_signed)
-                {
-                    const float divisor = 1.0f / (2 * static_cast&lt;float&gt;(NL::max()) + 1);
-                    offsetOutput[j] = (2 * static_cast&lt;float&gt;(offsetInput[j]) + 1) * divisor;
-                }
-                else
-                {
-                    offsetOutput[j] =  static_cast&lt;float&gt;(offsetInput[j]) / NL::max();
-                }
-            }
-            else
-            {
-                offsetOutput[j] =  static_cast&lt;float&gt;(offsetInput[j]);
-            }
-        }
-    }
-}
-
-const VertexBuffer11::VertexConverter VertexBuffer11::mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4] =
-{
-    { // GL_BYTE
-        { // unnormalized
-            { &amp;copyToFloatVertexData&lt;GLbyte, 1, false&gt;, false, DXGI_FORMAT_R32_FLOAT, 4 },
-            { &amp;copyToFloatVertexData&lt;GLbyte, 2, false&gt;, false, DXGI_FORMAT_R32G32_FLOAT, 8 },
-            { &amp;copyToFloatVertexData&lt;GLbyte, 3, false&gt;, false, DXGI_FORMAT_R32G32B32_FLOAT, 12 },
-            { &amp;copyToFloatVertexData&lt;GLbyte, 4, false&gt;, false, DXGI_FORMAT_R32G32B32A32_FLOAT, 16 },
-        },
-        { // normalized
-            { &amp;copyVertexData&lt;GLbyte, 1, false, true&gt;, true, DXGI_FORMAT_R8_SNORM, 1 },
-            { &amp;copyVertexData&lt;GLbyte, 2, false, true&gt;, true, DXGI_FORMAT_R8G8_SNORM, 2 },
-            { &amp;copyVertexData&lt;GLbyte, 3, true, true&gt;, false, DXGI_FORMAT_R8G8B8A8_SNORM, 4 },
-            { &amp;copyVertexData&lt;GLbyte, 4, false, true&gt;, true, DXGI_FORMAT_R8G8B8A8_SNORM, 4 },
-        },
-    },
-    { // GL_UNSIGNED_BYTE
-        { // unnormalized
-            { &amp;copyToFloatVertexData&lt;GLubyte, 1, false&gt;, false, DXGI_FORMAT_R32_FLOAT, 4 },
-            { &amp;copyToFloatVertexData&lt;GLubyte, 2, false&gt;, false, DXGI_FORMAT_R32G32_FLOAT, 8 },
-            { &amp;copyToFloatVertexData&lt;GLubyte, 3, false&gt;, false, DXGI_FORMAT_R32G32B32_FLOAT, 12 },
-            { &amp;copyToFloatVertexData&lt;GLubyte, 4, false&gt;, false, DXGI_FORMAT_R32G32B32A32_FLOAT, 16 },
-        },
-        { // normalized
-            { &amp;copyVertexData&lt;GLubyte, 1, false, true&gt;, true, DXGI_FORMAT_R8_UNORM, 1 },
-            { &amp;copyVertexData&lt;GLubyte, 2, false, true&gt;, true, DXGI_FORMAT_R8G8_UNORM, 2 },
-            { &amp;copyVertexData&lt;GLubyte, 3, true, true&gt;, false, DXGI_FORMAT_R8G8B8A8_UNORM, 4 },
-            { &amp;copyVertexData&lt;GLubyte, 4, false, true&gt;, true, DXGI_FORMAT_R8G8B8A8_UNORM, 4 },
-        },
-    },
-    { // GL_SHORT
-        { // unnormalized
-            { &amp;copyToFloatVertexData&lt;GLshort, 1, false&gt;, false, DXGI_FORMAT_R32_FLOAT, 4 },
-            { &amp;copyToFloatVertexData&lt;GLshort, 2, false&gt;, false, DXGI_FORMAT_R32G32_FLOAT, 8 },
-            { &amp;copyToFloatVertexData&lt;GLshort, 3, false&gt;, false, DXGI_FORMAT_R32G32B32_FLOAT, 12 },
-            { &amp;copyToFloatVertexData&lt;GLshort, 4, false&gt;, false, DXGI_FORMAT_R32G32B32A32_FLOAT, 16 },
-        },
-        { // normalized
-            { &amp;copyVertexData&lt;GLshort, 1, false, true&gt;, true, DXGI_FORMAT_R16_SNORM, 2 },
-            { &amp;copyVertexData&lt;GLshort, 2, false, true&gt;, true, DXGI_FORMAT_R16G16_SNORM, 4 },
-            { &amp;copyVertexData&lt;GLshort, 3, true, true&gt;, false, DXGI_FORMAT_R16G16B16A16_SNORM, 8 },
-            { &amp;copyVertexData&lt;GLshort, 4, false, true&gt;, true, DXGI_FORMAT_R16G16B16A16_SNORM, 8 },
-        },
-    },
-    { // GL_UNSIGNED_SHORT
-        { // unnormalized
-            { &amp;copyToFloatVertexData&lt;GLushort, 1, false&gt;, false, DXGI_FORMAT_R32_FLOAT, 4 },
-            { &amp;copyToFloatVertexData&lt;GLushort, 2, false&gt;, false, DXGI_FORMAT_R32G32_FLOAT, 8 },
-            { &amp;copyToFloatVertexData&lt;GLushort, 3, false&gt;, false, DXGI_FORMAT_R32G32B32_FLOAT, 12 },
-            { &amp;copyToFloatVertexData&lt;GLushort, 4, false&gt;, false, DXGI_FORMAT_R32G32B32A32_FLOAT, 16 },
-        },
-        { // normalized
-            { &amp;copyVertexData&lt;GLushort, 1, false, true&gt;, true, DXGI_FORMAT_R16_UNORM, 2 },
-            { &amp;copyVertexData&lt;GLushort, 2, false, true&gt;, true, DXGI_FORMAT_R16G16_UNORM, 4 },
-            { &amp;copyVertexData&lt;GLushort, 3, true, true&gt;, false, DXGI_FORMAT_R16G16B16A16_UNORM, 8 },
-            { &amp;copyVertexData&lt;GLushort, 4, false, true&gt;, true, DXGI_FORMAT_R16G16B16A16_UNORM, 8 },
-        },
-    },
-    { // GL_FIXED
-        { // unnormalized
-            { &amp;copyFixedVertexData&lt;1&gt;, false, DXGI_FORMAT_R32_FLOAT, 4 },
-            { &amp;copyFixedVertexData&lt;2&gt;, false, DXGI_FORMAT_R32G32_FLOAT, 8 },
-            { &amp;copyFixedVertexData&lt;3&gt;, false, DXGI_FORMAT_R32G32B32_FLOAT, 12 },
-            { &amp;copyFixedVertexData&lt;4&gt;, false, DXGI_FORMAT_R32G32B32A32_FLOAT, 16 },
-        },
-        { // normalized
-            { &amp;copyFixedVertexData&lt;1&gt;, false, DXGI_FORMAT_R32_FLOAT, 4 },
-            { &amp;copyFixedVertexData&lt;2&gt;, false, DXGI_FORMAT_R32G32_FLOAT, 8 },
-            { &amp;copyFixedVertexData&lt;3&gt;, false, DXGI_FORMAT_R32G32B32_FLOAT, 12 },
-            { &amp;copyFixedVertexData&lt;4&gt;, false, DXGI_FORMAT_R32G32B32A32_FLOAT, 16 },
-        },
-    },
-    { // GL_FLOAT
-        { // unnormalized
-            { &amp;copyVertexData&lt;GLfloat, 1, false, false&gt;, true, DXGI_FORMAT_R32_FLOAT, 4 },
-            { &amp;copyVertexData&lt;GLfloat, 2, false, false&gt;, true, DXGI_FORMAT_R32G32_FLOAT, 8 },
-            { &amp;copyVertexData&lt;GLfloat, 3, false, false&gt;, true, DXGI_FORMAT_R32G32B32_FLOAT, 12 },
-            { &amp;copyVertexData&lt;GLfloat, 4, false, false&gt;, true, DXGI_FORMAT_R32G32B32A32_FLOAT, 16 },
-        },
-        { // normalized
-            { &amp;copyVertexData&lt;GLfloat, 1, false, false&gt;, true, DXGI_FORMAT_R32_FLOAT, 4 },
-            { &amp;copyVertexData&lt;GLfloat, 2, false, false&gt;, true, DXGI_FORMAT_R32G32_FLOAT, 8 },
-            { &amp;copyVertexData&lt;GLfloat, 3, false, false&gt;, true, DXGI_FORMAT_R32G32B32_FLOAT, 12 },
-            { &amp;copyVertexData&lt;GLfloat, 4, false, false&gt;, true, DXGI_FORMAT_R32G32B32A32_FLOAT, 16 },
-        },
-    },
-};
-
-const VertexBuffer11::VertexConverter &amp;VertexBuffer11::getVertexConversion(const gl::VertexAttribute &amp;attribute)
-{
-    unsigned int typeIndex = 0;
-    switch (attribute.mType)
-    {
-      case GL_BYTE:             typeIndex = 0; break;
-      case GL_UNSIGNED_BYTE:    typeIndex = 1; break;
-      case GL_SHORT:            typeIndex = 2; break;
-      case GL_UNSIGNED_SHORT:   typeIndex = 3; break;
-      case GL_FIXED:            typeIndex = 4; break;
-      case GL_FLOAT:            typeIndex = 5; break;
-      default:                  UNREACHABLE(); break;
-    }
-
-    return mPossibleTranslations[typeIndex][attribute.mNormalized ? 1 : 0][attribute.mSize - 1];
-}
-
-}
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11VertexBuffer11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/VertexBuffer11.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/VertexBuffer11.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/VertexBuffer11.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -25,22 +25,16 @@
</span><span class="cx"> 
</span><span class="cx">     static VertexBuffer11 *makeVertexBuffer11(VertexBuffer *vetexBuffer);
</span><span class="cx"> 
</span><del>-    virtual bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, GLint start, GLsizei count, GLsizei instances,
-                                       unsigned int offset);
-    virtual bool storeRawData(const void* data, unsigned int size, unsigned int offset);
</del><ins>+    virtual bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, const gl::VertexAttribCurrentValueData &amp;currentValue,
+                                       GLint start, GLsizei count, GLsizei instances, unsigned int offset);
</ins><span class="cx"> 
</span><span class="cx">     virtual bool getSpaceRequired(const gl::VertexAttribute &amp;attrib, GLsizei count, GLsizei instances,
</span><span class="cx">                                   unsigned int *outSpaceRequired) const;
</span><span class="cx"> 
</span><del>-    virtual bool requiresConversion(const gl::VertexAttribute &amp;attrib) const;
-
</del><span class="cx">     virtual unsigned int getBufferSize() const;
</span><span class="cx">     virtual bool setBufferSize(unsigned int size);
</span><span class="cx">     virtual bool discard();
</span><span class="cx"> 
</span><del>-    unsigned int getVertexSize(const gl::VertexAttribute &amp;attrib) const;
-    DXGI_FORMAT getDXGIFormat(const gl::VertexAttribute &amp;attrib) const;
-
</del><span class="cx">     ID3D11Buffer *getBuffer() const;
</span><span class="cx"> 
</span><span class="cx">   private:
</span><span class="lines">@@ -51,22 +45,6 @@
</span><span class="cx">     ID3D11Buffer *mBuffer;
</span><span class="cx">     unsigned int mBufferSize;
</span><span class="cx">     bool mDynamicUsage;
</span><del>-
-    typedef void (*VertexConversionFunction)(const void *, unsigned int, unsigned int, void *);
-    struct VertexConverter
-    {
-        VertexConversionFunction conversionFunc;
-        bool identity;
-        DXGI_FORMAT dxgiFormat;
-        unsigned int outputElementSize;
-    };
-
-    enum { NUM_GL_VERTEX_ATTRIB_TYPES = 6 };
-
-    // This table is used to generate mAttributeTypes.
-    static const VertexConverter mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size - 1]
-
-    static const VertexConverter &amp;getVertexConversion(const gl::VertexAttribute &amp;attribute);
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11renderer11_utilscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -9,9 +9,12 @@
</span><span class="cx"> // specific to the D3D11 renderer.
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d11/renderer11_utils.h&quot;
</span><del>-
</del><ins>+#include &quot;libGLESv2/renderer/d3d11/formatutils11.h&quot;
</ins><span class="cx"> #include &quot;common/debug.h&quot;
</span><span class="cx"> 
</span><ins>+namespace rx
+{
+
</ins><span class="cx"> namespace gl_d3d11
</span><span class="cx"> {
</span><span class="cx"> 
</span><span class="lines">@@ -51,6 +54,8 @@
</span><span class="cx">       case GL_FUNC_ADD:              d3dBlendOp = D3D11_BLEND_OP_ADD;           break;
</span><span class="cx">       case GL_FUNC_SUBTRACT:         d3dBlendOp = D3D11_BLEND_OP_SUBTRACT;      break;
</span><span class="cx">       case GL_FUNC_REVERSE_SUBTRACT: d3dBlendOp = D3D11_BLEND_OP_REV_SUBTRACT;  break;
</span><ins>+      case GL_MIN:                   d3dBlendOp = D3D11_BLEND_OP_MIN;           break;
+      case GL_MAX:                   d3dBlendOp = D3D11_BLEND_OP_MAX;           break;
</ins><span class="cx">       default: UNREACHABLE();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -150,11 +155,13 @@
</span><span class="cx">     return d3dStencilOp;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy)
</del><ins>+D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy, GLenum comparisonMode)
</ins><span class="cx"> {
</span><ins>+    bool comparison = comparisonMode != GL_NONE;
+
</ins><span class="cx">     if (maxAnisotropy &gt; 1.0f)
</span><span class="cx">     {
</span><del>-        return D3D11_ENCODE_ANISOTROPIC_FILTER(false);
</del><ins>+        return D3D11_ENCODE_ANISOTROPIC_FILTER(comparison);
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="lines">@@ -179,7 +186,7 @@
</span><span class="cx">           default:         UNREACHABLE();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return D3D11_ENCODE_BASIC_FILTER(dxMin, dxMag, dxMip, false);
</del><ins>+        return D3D11_ENCODE_BASIC_FILTER(dxMin, dxMag, dxMip, comparison);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -196,202 +203,50 @@
</span><span class="cx">     return D3D11_TEXTURE_ADDRESS_WRAP;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FLOAT ConvertMinLOD(GLenum minFilter, unsigned int lodOffset)
</del><ins>+D3D11_QUERY ConvertQueryType(GLenum queryType)
</ins><span class="cx"> {
</span><del>-    return (minFilter == GL_NEAREST || minFilter == GL_LINEAR) ? static_cast&lt;float&gt;(lodOffset) : -FLT_MAX;
-}
-
-FLOAT ConvertMaxLOD(GLenum minFilter, unsigned int lodOffset)
-{
-    return (minFilter == GL_NEAREST || minFilter == GL_LINEAR) ? static_cast&lt;float&gt;(lodOffset) : FLT_MAX;
-}
-
-}
-
-namespace d3d11_gl
-{
-
-GLenum ConvertBackBufferFormat(DXGI_FORMAT format)
-{
-    switch (format)
</del><ins>+    switch (queryType)
</ins><span class="cx">     {
</span><del>-      case DXGI_FORMAT_R8G8B8A8_UNORM: return GL_RGBA8_OES;
-      case DXGI_FORMAT_B8G8R8A8_UNORM: return GL_BGRA8_EXT;
-      default:
-        UNREACHABLE();
</del><ins>+      case GL_ANY_SAMPLES_PASSED_EXT:
+      case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:   return D3D11_QUERY_OCCLUSION;
+      case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: return D3D11_QUERY_SO_STATISTICS;
+      default: UNREACHABLE();                        return D3D11_QUERY_EVENT;
</ins><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    return GL_RGBA8_OES;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLenum ConvertDepthStencilFormat(DXGI_FORMAT format)
</del><ins>+namespace d3d11
</ins><span class="cx"> {
</span><del>-    switch (format)
-    {
-      case DXGI_FORMAT_UNKNOWN: return GL_NONE;
-      case DXGI_FORMAT_D16_UNORM: return GL_DEPTH_COMPONENT16;
-      case DXGI_FORMAT_D24_UNORM_S8_UINT: return GL_DEPTH24_STENCIL8_OES;
-      default:
-        UNREACHABLE();
-    }
</del><span class="cx"> 
</span><del>-    return GL_DEPTH24_STENCIL8_OES;
-}
-
-GLenum ConvertRenderbufferFormat(DXGI_FORMAT format)
</del><ins>+void GenerateInitialTextureData(GLint internalFormat, GLuint clientVersion, GLuint width, GLuint height, GLuint depth,
+                                GLuint mipLevels, std::vector&lt;D3D11_SUBRESOURCE_DATA&gt; *outSubresourceData,
+                                std::vector&lt; std::vector&lt;BYTE&gt; &gt; *outData)
</ins><span class="cx"> {
</span><del>-    switch (format)
-    {
-      case DXGI_FORMAT_B8G8R8A8_UNORM:
-        return GL_BGRA8_EXT;
-      case DXGI_FORMAT_R8G8B8A8_UNORM:
-        return GL_RGBA8_OES;
-      case DXGI_FORMAT_D16_UNORM:
-        return GL_DEPTH_COMPONENT16;
-      case DXGI_FORMAT_D24_UNORM_S8_UINT:
-        return GL_DEPTH24_STENCIL8_OES;
-      default:
-        UNREACHABLE();
-    }
</del><ins>+    InitializeTextureDataFunction initializeFunc = gl_d3d11::GetTextureDataInitializationFunction(internalFormat);
+    DXGI_FORMAT dxgiFormat = gl_d3d11::GetTexFormat(internalFormat, clientVersion);
</ins><span class="cx"> 
</span><del>-    return GL_RGBA8_OES;
-}
</del><ins>+    outSubresourceData-&gt;resize(mipLevels);
+    outData-&gt;resize(mipLevels);
</ins><span class="cx"> 
</span><del>-GLenum ConvertTextureInternalFormat(DXGI_FORMAT format)
-{
-    switch (format)
</del><ins>+    for (unsigned int i = 0; i &lt; mipLevels; i++)
</ins><span class="cx">     {
</span><del>-      case DXGI_FORMAT_R8G8B8A8_UNORM:
-        return GL_RGBA8_OES;
-      case DXGI_FORMAT_A8_UNORM:
-        return GL_ALPHA8_EXT;
-      case DXGI_FORMAT_BC1_UNORM:
-        return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
-      case DXGI_FORMAT_BC2_UNORM:
-        return GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE;
-      case DXGI_FORMAT_BC3_UNORM:
-        return GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE;
-      case DXGI_FORMAT_R32G32B32A32_FLOAT:
-        return GL_RGBA32F_EXT;
-      case DXGI_FORMAT_R32G32B32_FLOAT:
-        return GL_RGB32F_EXT;
-      case DXGI_FORMAT_R16G16B16A16_FLOAT:
-        return GL_RGBA16F_EXT;
-      case DXGI_FORMAT_B8G8R8A8_UNORM:
-        return GL_BGRA8_EXT;
-      case DXGI_FORMAT_R8_UNORM:
-        return GL_R8_EXT;
-      case DXGI_FORMAT_R8G8_UNORM:
-        return GL_RG8_EXT;
-      case DXGI_FORMAT_R16_FLOAT:
-        return GL_R16F_EXT;
-      case DXGI_FORMAT_R16G16_FLOAT:
-        return GL_RG16F_EXT;
-      case DXGI_FORMAT_D16_UNORM:
-        return GL_DEPTH_COMPONENT16;
-      case DXGI_FORMAT_D24_UNORM_S8_UINT:
-        return GL_DEPTH24_STENCIL8_OES;
-      case DXGI_FORMAT_UNKNOWN:
-        return GL_NONE;
-      default:
-        UNREACHABLE();
-    }
</del><ins>+        unsigned int mipWidth = std::max(width &gt;&gt; i, 1U);
+        unsigned int mipHeight = std::max(height &gt;&gt; i, 1U);
+        unsigned int mipDepth = std::max(depth &gt;&gt; i, 1U);
</ins><span class="cx"> 
</span><del>-    return GL_RGBA8_OES;
-}
</del><ins>+        unsigned int rowWidth = d3d11::GetFormatPixelBytes(dxgiFormat) * mipWidth;
+        unsigned int imageSize = rowWidth * height;
</ins><span class="cx"> 
</span><del>-}
</del><ins>+        outData-&gt;at(i).resize(rowWidth * mipHeight * mipDepth);
+        initializeFunc(mipWidth, mipHeight, mipDepth, outData-&gt;at(i).data(), rowWidth, imageSize);
</ins><span class="cx"> 
</span><del>-namespace gl_d3d11
-{
-
-DXGI_FORMAT ConvertRenderbufferFormat(GLenum format)
-{
-    switch (format)
-    {
-      case GL_RGBA4:
-      case GL_RGB5_A1:
-      case GL_RGBA8_OES:
-      case GL_RGB565:
-      case GL_RGB8_OES:
-        return DXGI_FORMAT_R8G8B8A8_UNORM;
-      case GL_BGRA8_EXT:
-        return DXGI_FORMAT_B8G8R8A8_UNORM;
-      case GL_DEPTH_COMPONENT16:
-        return DXGI_FORMAT_D16_UNORM;
-      case GL_STENCIL_INDEX8:
-      case GL_DEPTH24_STENCIL8_OES:
-        return DXGI_FORMAT_D24_UNORM_S8_UINT;
-      default:
-        UNREACHABLE();
</del><ins>+        outSubresourceData-&gt;at(i).pSysMem = outData-&gt;at(i).data();
+        outSubresourceData-&gt;at(i).SysMemPitch = rowWidth;
+        outSubresourceData-&gt;at(i).SysMemSlicePitch = imageSize;
</ins><span class="cx">     }
</span><del>-
-    return DXGI_FORMAT_R8G8B8A8_UNORM;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-DXGI_FORMAT ConvertTextureFormat(GLenum internalformat)
-{
-    switch (internalformat)
-    {
-      case GL_RGB565:
-      case GL_RGBA4:
-      case GL_RGB5_A1:
-      case GL_RGB8_OES:
-      case GL_RGBA8_OES:
-      case GL_LUMINANCE8_EXT:
-      case GL_LUMINANCE8_ALPHA8_EXT:
-        return DXGI_FORMAT_R8G8B8A8_UNORM;
-      case GL_ALPHA8_EXT:
-        return DXGI_FORMAT_A8_UNORM;
-      case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-      case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-        return DXGI_FORMAT_BC1_UNORM;
-      case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
-        return DXGI_FORMAT_BC2_UNORM;
-      case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
-        return DXGI_FORMAT_BC3_UNORM;
-      case GL_RGBA32F_EXT:
-      case GL_ALPHA32F_EXT:
-      case GL_LUMINANCE_ALPHA32F_EXT:
-        return DXGI_FORMAT_R32G32B32A32_FLOAT;
-      case GL_RGB32F_EXT:
-      case GL_LUMINANCE32F_EXT:
-        return DXGI_FORMAT_R32G32B32A32_FLOAT;
-      case GL_RGBA16F_EXT:
-      case GL_ALPHA16F_EXT:
-      case GL_LUMINANCE_ALPHA16F_EXT:
-      case GL_RGB16F_EXT:
-      case GL_LUMINANCE16F_EXT:
-        return DXGI_FORMAT_R16G16B16A16_FLOAT;
-      case GL_BGRA8_EXT:
-        return DXGI_FORMAT_B8G8R8A8_UNORM;
-      case GL_R8_EXT:
-        return DXGI_FORMAT_R8_UNORM;
-      case GL_RG8_EXT:
-        return DXGI_FORMAT_R8G8_UNORM;
-      case GL_R16F_EXT:
-        return DXGI_FORMAT_R16_FLOAT;
-      case GL_RG16F_EXT:
-        return DXGI_FORMAT_R16G16_FLOAT;
-      case GL_DEPTH_COMPONENT16:
-        return DXGI_FORMAT_D16_UNORM;
-      case GL_DEPTH_COMPONENT32_OES:
-      case GL_DEPTH24_STENCIL8_OES:
-        return DXGI_FORMAT_D24_UNORM_S8_UINT;
-      case GL_NONE:
-        return DXGI_FORMAT_UNKNOWN;
-      default:
-        UNREACHABLE();
-    }
-
-    return DXGI_FORMAT_R8G8B8A8_UNORM;
-}
-
-}
-
-namespace d3d11
-{
-
</del><span class="cx"> void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y, float u, float v)
</span><span class="cx"> {
</span><span class="cx">     vertex-&gt;x = x;
</span><span class="lines">@@ -400,282 +255,17 @@
</span><span class="cx">     vertex-&gt;v = v;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, float y, float z,
-                                 const gl::Color &amp;color)
</del><ins>+void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, float x, float y,
+                                      unsigned int layer, float u, float v, float s)
</ins><span class="cx"> {
</span><span class="cx">     vertex-&gt;x = x;
</span><span class="cx">     vertex-&gt;y = y;
</span><del>-    vertex-&gt;z = z;
-    vertex-&gt;r = color.red;
-    vertex-&gt;g = color.green;
-    vertex-&gt;b = color.blue;
-    vertex-&gt;a = color.alpha;
</del><ins>+    vertex-&gt;l = layer;
+    vertex-&gt;u = u;
+    vertex-&gt;v = v;
+    vertex-&gt;s = s;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-size_t ComputePixelSizeBits(DXGI_FORMAT format)
-{
-    switch (format)
-    {
-      case DXGI_FORMAT_R1_UNORM:
-        return 1;
-
-      case DXGI_FORMAT_A8_UNORM:
-      case DXGI_FORMAT_R8_SINT:
-      case DXGI_FORMAT_R8_SNORM:
-      case DXGI_FORMAT_R8_TYPELESS:
-      case DXGI_FORMAT_R8_UINT:
-      case DXGI_FORMAT_R8_UNORM:
-        return 8;
-
-      case DXGI_FORMAT_B5G5R5A1_UNORM:
-      case DXGI_FORMAT_B5G6R5_UNORM:
-      case DXGI_FORMAT_D16_UNORM:
-      case DXGI_FORMAT_R16_FLOAT:
-      case DXGI_FORMAT_R16_SINT:
-      case DXGI_FORMAT_R16_SNORM:
-      case DXGI_FORMAT_R16_TYPELESS:
-      case DXGI_FORMAT_R16_UINT:
-      case DXGI_FORMAT_R16_UNORM:
-      case DXGI_FORMAT_R8G8_SINT:
-      case DXGI_FORMAT_R8G8_SNORM:
-      case DXGI_FORMAT_R8G8_TYPELESS:
-      case DXGI_FORMAT_R8G8_UINT:
-      case DXGI_FORMAT_R8G8_UNORM:
-        return 16;
-
-      case DXGI_FORMAT_B8G8R8X8_TYPELESS:
-      case DXGI_FORMAT_B8G8R8X8_UNORM:
-      case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
-      case DXGI_FORMAT_D24_UNORM_S8_UINT:
-      case DXGI_FORMAT_D32_FLOAT:
-      case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
-      case DXGI_FORMAT_G8R8_G8B8_UNORM:
-      case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
-      case DXGI_FORMAT_R10G10B10A2_TYPELESS:
-      case DXGI_FORMAT_R10G10B10A2_UINT:
-      case DXGI_FORMAT_R10G10B10A2_UNORM:
-      case DXGI_FORMAT_R11G11B10_FLOAT:
-      case DXGI_FORMAT_R16G16_FLOAT:
-      case DXGI_FORMAT_R16G16_SINT:
-      case DXGI_FORMAT_R16G16_SNORM:
-      case DXGI_FORMAT_R16G16_TYPELESS:
-      case DXGI_FORMAT_R16G16_UINT:
-      case DXGI_FORMAT_R16G16_UNORM:
-      case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
-      case DXGI_FORMAT_R24G8_TYPELESS:
-      case DXGI_FORMAT_R32_FLOAT:
-      case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
-      case DXGI_FORMAT_R32_SINT:
-      case DXGI_FORMAT_R32_TYPELESS:
-      case DXGI_FORMAT_R32_UINT:
-      case DXGI_FORMAT_R8G8_B8G8_UNORM:
-      case DXGI_FORMAT_R8G8B8A8_SINT:
-      case DXGI_FORMAT_R8G8B8A8_SNORM:
-      case DXGI_FORMAT_R8G8B8A8_TYPELESS:
-      case DXGI_FORMAT_R8G8B8A8_UINT:
-      case DXGI_FORMAT_R8G8B8A8_UNORM:
-      case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
-      case DXGI_FORMAT_B8G8R8A8_TYPELESS:
-      case DXGI_FORMAT_B8G8R8A8_UNORM:
-      case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
-      case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
-      case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
-      case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
-        return 32;
-
-      case DXGI_FORMAT_R16G16B16A16_FLOAT:
-      case DXGI_FORMAT_R16G16B16A16_SINT:
-      case DXGI_FORMAT_R16G16B16A16_SNORM:
-      case DXGI_FORMAT_R16G16B16A16_TYPELESS:
-      case DXGI_FORMAT_R16G16B16A16_UINT:
-      case DXGI_FORMAT_R16G16B16A16_UNORM:
-      case DXGI_FORMAT_R32G32_FLOAT:
-      case DXGI_FORMAT_R32G32_SINT:
-      case DXGI_FORMAT_R32G32_TYPELESS:
-      case DXGI_FORMAT_R32G32_UINT:
-      case DXGI_FORMAT_R32G8X24_TYPELESS:
-        return 64;
-
-      case DXGI_FORMAT_R32G32B32_FLOAT:
-      case DXGI_FORMAT_R32G32B32_SINT:
-      case DXGI_FORMAT_R32G32B32_TYPELESS:
-      case DXGI_FORMAT_R32G32B32_UINT:
-        return 96;
-
-      case DXGI_FORMAT_R32G32B32A32_FLOAT:
-      case DXGI_FORMAT_R32G32B32A32_SINT:
-      case DXGI_FORMAT_R32G32B32A32_TYPELESS:
-      case DXGI_FORMAT_R32G32B32A32_UINT:
-        return 128;
-
-      case DXGI_FORMAT_BC1_TYPELESS:
-      case DXGI_FORMAT_BC1_UNORM:
-      case DXGI_FORMAT_BC1_UNORM_SRGB:
-      case DXGI_FORMAT_BC4_SNORM:
-      case DXGI_FORMAT_BC4_TYPELESS:
-      case DXGI_FORMAT_BC4_UNORM:
-        return 4;
-
-      case DXGI_FORMAT_BC2_TYPELESS:
-      case DXGI_FORMAT_BC2_UNORM:
-      case DXGI_FORMAT_BC2_UNORM_SRGB:
-      case DXGI_FORMAT_BC3_TYPELESS:
-      case DXGI_FORMAT_BC3_UNORM:
-      case DXGI_FORMAT_BC3_UNORM_SRGB:
-      case DXGI_FORMAT_BC5_SNORM:
-      case DXGI_FORMAT_BC5_TYPELESS:
-      case DXGI_FORMAT_BC5_UNORM:
-      case DXGI_FORMAT_BC6H_SF16:
-      case DXGI_FORMAT_BC6H_TYPELESS:
-      case DXGI_FORMAT_BC6H_UF16:
-      case DXGI_FORMAT_BC7_TYPELESS:
-      case DXGI_FORMAT_BC7_UNORM:
-      case DXGI_FORMAT_BC7_UNORM_SRGB:
-        return 8;
-
-      default:
-        return 0;
-    }
-}
-
-size_t ComputeBlockSizeBits(DXGI_FORMAT format)
-{
-    switch (format)
-    {
-      case DXGI_FORMAT_BC1_TYPELESS:
-      case DXGI_FORMAT_BC1_UNORM:
-      case DXGI_FORMAT_BC1_UNORM_SRGB:
-      case DXGI_FORMAT_BC4_SNORM:
-      case DXGI_FORMAT_BC4_TYPELESS:
-      case DXGI_FORMAT_BC4_UNORM:
-      case DXGI_FORMAT_BC2_TYPELESS:
-      case DXGI_FORMAT_BC2_UNORM:
-      case DXGI_FORMAT_BC2_UNORM_SRGB:
-      case DXGI_FORMAT_BC3_TYPELESS:
-      case DXGI_FORMAT_BC3_UNORM:
-      case DXGI_FORMAT_BC3_UNORM_SRGB:
-      case DXGI_FORMAT_BC5_SNORM:
-      case DXGI_FORMAT_BC5_TYPELESS:
-      case DXGI_FORMAT_BC5_UNORM:
-      case DXGI_FORMAT_BC6H_SF16:
-      case DXGI_FORMAT_BC6H_TYPELESS:
-      case DXGI_FORMAT_BC6H_UF16:
-      case DXGI_FORMAT_BC7_TYPELESS:
-      case DXGI_FORMAT_BC7_UNORM:
-      case DXGI_FORMAT_BC7_UNORM_SRGB:
-        return ComputePixelSizeBits(format) * 16;
-      default:
-        UNREACHABLE();
-        return 0;
-    }
-}
-
-bool IsCompressed(DXGI_FORMAT format)
-{
-    switch (format)
-    {
-      case DXGI_FORMAT_BC1_TYPELESS:
-      case DXGI_FORMAT_BC1_UNORM:
-      case DXGI_FORMAT_BC1_UNORM_SRGB:
-      case DXGI_FORMAT_BC4_SNORM:
-      case DXGI_FORMAT_BC4_TYPELESS:
-      case DXGI_FORMAT_BC4_UNORM:
-      case DXGI_FORMAT_BC2_TYPELESS:
-      case DXGI_FORMAT_BC2_UNORM:
-      case DXGI_FORMAT_BC2_UNORM_SRGB:
-      case DXGI_FORMAT_BC3_TYPELESS:
-      case DXGI_FORMAT_BC3_UNORM:
-      case DXGI_FORMAT_BC3_UNORM_SRGB:
-      case DXGI_FORMAT_BC5_SNORM:
-      case DXGI_FORMAT_BC5_TYPELESS:
-      case DXGI_FORMAT_BC5_UNORM:
-      case DXGI_FORMAT_BC6H_SF16:
-      case DXGI_FORMAT_BC6H_TYPELESS:
-      case DXGI_FORMAT_BC6H_UF16:
-      case DXGI_FORMAT_BC7_TYPELESS:
-      case DXGI_FORMAT_BC7_UNORM:
-      case DXGI_FORMAT_BC7_UNORM_SRGB:
-        return true;
-      case DXGI_FORMAT_UNKNOWN:
-        UNREACHABLE();
-        return false;
-      default:
-        return false;
-    }
-}
-
-unsigned int GetTextureFormatDimensionAlignment(DXGI_FORMAT format)
-{
-    switch (format)
-    {
-      case DXGI_FORMAT_BC1_TYPELESS:
-      case DXGI_FORMAT_BC1_UNORM:
-      case DXGI_FORMAT_BC1_UNORM_SRGB:
-      case DXGI_FORMAT_BC4_SNORM:
-      case DXGI_FORMAT_BC4_TYPELESS:
-      case DXGI_FORMAT_BC4_UNORM:
-      case DXGI_FORMAT_BC2_TYPELESS:
-      case DXGI_FORMAT_BC2_UNORM:
-      case DXGI_FORMAT_BC2_UNORM_SRGB:
-      case DXGI_FORMAT_BC3_TYPELESS:
-      case DXGI_FORMAT_BC3_UNORM:
-      case DXGI_FORMAT_BC3_UNORM_SRGB:
-      case DXGI_FORMAT_BC5_SNORM:
-      case DXGI_FORMAT_BC5_TYPELESS:
-      case DXGI_FORMAT_BC5_UNORM:
-      case DXGI_FORMAT_BC6H_SF16:
-      case DXGI_FORMAT_BC6H_TYPELESS:
-      case DXGI_FORMAT_BC6H_UF16:
-      case DXGI_FORMAT_BC7_TYPELESS:
-      case DXGI_FORMAT_BC7_UNORM:
-      case DXGI_FORMAT_BC7_UNORM_SRGB:
-        return 4;
-      case DXGI_FORMAT_UNKNOWN:
-        UNREACHABLE();
-        return 1;
-      default:
-        return 1;
-    }
-}
-
-bool IsDepthStencilFormat(DXGI_FORMAT format)
-{
-    switch (format)
-    {
-      case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
-      case DXGI_FORMAT_D32_FLOAT:
-      case DXGI_FORMAT_D24_UNORM_S8_UINT:
-      case DXGI_FORMAT_D16_UNORM:
-        return true;
-      default:
-        return false;
-    }
-}
-
-DXGI_FORMAT GetDepthTextureFormat(DXGI_FORMAT format)
-{
-    switch (format)
-    {
-      case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: return DXGI_FORMAT_R32G8X24_TYPELESS;
-      case DXGI_FORMAT_D32_FLOAT:            return DXGI_FORMAT_R32_TYPELESS;
-      case DXGI_FORMAT_D24_UNORM_S8_UINT:    return DXGI_FORMAT_R24G8_TYPELESS;
-      case DXGI_FORMAT_D16_UNORM:            return DXGI_FORMAT_R16_TYPELESS;
-      default: UNREACHABLE();                return DXGI_FORMAT_UNKNOWN;
-    }
-}
-
-DXGI_FORMAT GetDepthShaderResourceFormat(DXGI_FORMAT format)
-{
-    switch (format)
-    {
-      case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: return DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS;
-      case DXGI_FORMAT_D32_FLOAT:            return DXGI_FORMAT_R32_UINT;
-      case DXGI_FORMAT_D24_UNORM_S8_UINT:    return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
-      case DXGI_FORMAT_D16_UNORM:            return DXGI_FORMAT_R16_UNORM;
-      default: UNREACHABLE();                return DXGI_FORMAT_UNKNOWN;
-    }
-}
-
</del><span class="cx"> HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name)
</span><span class="cx"> {
</span><span class="cx"> #if defined(_DEBUG)
</span><span class="lines">@@ -686,3 +276,5 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11renderer11_utilsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/renderer11_utils.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/renderer11_utils.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/renderer11_utils.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -12,6 +12,9 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/angletypes.h&quot;
</span><span class="cx"> 
</span><ins>+namespace rx
+{
+
</ins><span class="cx"> namespace gl_d3d11
</span><span class="cx"> {
</span><span class="cx"> 
</span><span class="lines">@@ -26,28 +29,20 @@
</span><span class="cx"> UINT8 ConvertStencilMask(GLuint stencilmask);
</span><span class="cx"> D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp);
</span><span class="cx"> 
</span><del>-D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy);
</del><ins>+D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy, GLenum comparisonMode);
</ins><span class="cx"> D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap);
</span><del>-FLOAT ConvertMinLOD(GLenum minFilter, unsigned int lodOffset);
-FLOAT ConvertMaxLOD(GLenum minFilter, unsigned int lodOffset);
</del><span class="cx"> 
</span><del>-DXGI_FORMAT ConvertRenderbufferFormat(GLenum format);
-DXGI_FORMAT ConvertTextureFormat(GLenum format);
-}
</del><ins>+D3D11_QUERY ConvertQueryType(GLenum queryType);
</ins><span class="cx"> 
</span><del>-namespace d3d11_gl
-{
-
-GLenum ConvertBackBufferFormat(DXGI_FORMAT format);
-GLenum ConvertDepthStencilFormat(DXGI_FORMAT format);
-GLenum ConvertRenderbufferFormat(DXGI_FORMAT format);
-GLenum ConvertTextureInternalFormat(DXGI_FORMAT format);
-
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace d3d11
</span><span class="cx"> {
</span><span class="cx"> 
</span><ins>+void GenerateInitialTextureData(GLint internalFormat, GLuint clientVersion, GLuint width, GLuint height, GLuint depth,
+                                GLuint mipLevels, std::vector&lt;D3D11_SUBRESOURCE_DATA&gt; *outSubresourceData,
+                                std::vector&lt; std::vector&lt;BYTE&gt; &gt; *outData);
+
</ins><span class="cx"> struct PositionTexCoordVertex
</span><span class="cx"> {
</span><span class="cx">     float x, y;
</span><span class="lines">@@ -55,26 +50,53 @@
</span><span class="cx"> };
</span><span class="cx"> void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y, float u, float v);
</span><span class="cx"> 
</span><ins>+struct PositionLayerTexCoord3DVertex
+{
+    float x, y;
+    unsigned int l;
+    float u, v, s;
+};
+void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, float x, float y,
+                                      unsigned int layer, float u, float v, float s);
+
+template &lt;typename T&gt;
</ins><span class="cx"> struct PositionDepthColorVertex
</span><span class="cx"> {
</span><span class="cx">     float x, y, z;
</span><del>-    float r, g, b, a;
</del><ins>+    T r, g, b, a;
</ins><span class="cx"> };
</span><del>-void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, float y, float z,
-                                 const gl::Color &amp;color);
</del><span class="cx"> 
</span><del>-size_t ComputePixelSizeBits(DXGI_FORMAT format);
-size_t ComputeBlockSizeBits(DXGI_FORMAT format);
</del><ins>+template &lt;typename T&gt;
+void SetPositionDepthColorVertex(PositionDepthColorVertex&lt;T&gt;* vertex, float x, float y, float z,
+                                 const gl::Color&lt;T&gt; &amp;color)
+{
+    vertex-&gt;x = x;
+    vertex-&gt;y = y;
+    vertex-&gt;z = z;
+    vertex-&gt;r = color.red;
+    vertex-&gt;g = color.green;
+    vertex-&gt;b = color.blue;
+    vertex-&gt;a = color.alpha;
+}
</ins><span class="cx"> 
</span><del>-bool IsCompressed(DXGI_FORMAT format);
-unsigned int GetTextureFormatDimensionAlignment(DXGI_FORMAT format);
</del><ins>+HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name);
</ins><span class="cx"> 
</span><del>-bool IsDepthStencilFormat(DXGI_FORMAT format);
-DXGI_FORMAT GetDepthTextureFormat(DXGI_FORMAT format);
-DXGI_FORMAT GetDepthShaderResourceFormat(DXGI_FORMAT format);
</del><ins>+template &lt;typename outType&gt;
+outType* DynamicCastComObject(IUnknown* object)
+{
+    outType *outObject = NULL;
+    HRESULT result = object-&gt;QueryInterface(__uuidof(outType), reinterpret_cast&lt;void**&gt;(&amp;outObject));
+    if (SUCCEEDED(result))
+    {
+        return outObject;
+    }
+    else
+    {
+        SafeRelease(outObject);
+        return NULL;
+    }
+}
</ins><span class="cx"> 
</span><del>-HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name);
-
</del><span class="cx"> inline bool isDeviceLostError(HRESULT errorCode)
</span><span class="cx"> {
</span><span class="cx">     switch (errorCode)
</span><span class="lines">@@ -90,6 +112,51 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;unsigned int N&gt;
+inline ID3D11VertexShader *CompileVS(ID3D11Device *device, const BYTE (&amp;byteCode)[N], const char *name)
+{
+    ID3D11VertexShader *vs = NULL;
+    HRESULT result = device-&gt;CreateVertexShader(byteCode, N, NULL, &amp;vs);
+    ASSERT(SUCCEEDED(result));
+    SetDebugName(vs, name);
+    return vs;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;unsigned int N&gt;
+inline ID3D11GeometryShader *CompileGS(ID3D11Device *device, const BYTE (&amp;byteCode)[N], const char *name)
+{
+    ID3D11GeometryShader *gs = NULL;
+    HRESULT result = device-&gt;CreateGeometryShader(byteCode, N, NULL, &amp;gs);
+    ASSERT(SUCCEEDED(result));
+    SetDebugName(gs, name);
+    return gs;
+}
+
+template &lt;unsigned int N&gt;
+inline ID3D11PixelShader *CompilePS(ID3D11Device *device, const BYTE (&amp;byteCode)[N], const char *name)
+{
+    ID3D11PixelShader *ps = NULL;
+    HRESULT result = device-&gt;CreatePixelShader(byteCode, N, NULL, &amp;ps);
+    ASSERT(SUCCEEDED(result));
+    SetDebugName(ps, name);
+    return ps;
+}
+
+// Copy data to small D3D11 buffers, such as for small constant buffers, which use one struct to
+// represent an entire buffer.
+template &lt;class T&gt;
+inline void SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBuffer, const T &amp;value)
+{
+    D3D11_MAPPED_SUBRESOURCE mappedResource;
+    context-&gt;Map(constantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &amp;mappedResource);
+
+    memcpy(mappedResource.pData, &amp;value, sizeof(T));
+
+    context-&gt;Unmap(constantBuffer, 0);
+}
+
+}
+
+}
+
</ins><span class="cx"> #endif // LIBGLESV2_RENDERER_RENDERER11_UTILS_H
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11shadersClear11hlsl"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Clear11.hlsl (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Clear11.hlsl        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Clear11.hlsl        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,38 +1,102 @@
</span><del>-void VS_Clear( in float3  inPosition :    POSITION,  in float4  inColor : COLOR,
-              out float4 outPosition : SV_POSITION, out float4 outColor : COLOR)
</del><ins>+// Assume we are in SM4+, which has 8 color outputs
+
+void VS_ClearFloat( in float3  inPosition :    POSITION,  in float4  inColor : COLOR,
+                   out float4 outPosition : SV_POSITION, out float4 outColor : COLOR)
</ins><span class="cx"> {
</span><span class="cx">     outPosition = float4(inPosition, 1.0f);
</span><span class="cx">     outColor = inColor;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Assume we are in SM4+, which has 8 color outputs
-struct PS_OutputMultiple
</del><ins>+struct PS_OutputFloat
</ins><span class="cx"> {
</span><del>-        float4 color0 : SV_TARGET0;
-        float4 color1 : SV_TARGET1;
-        float4 color2 : SV_TARGET2;
-        float4 color3 : SV_TARGET3;
-        float4 color4 : SV_TARGET4;
-        float4 color5 : SV_TARGET5;
-        float4 color6 : SV_TARGET6;
-        float4 color7 : SV_TARGET7;
</del><ins>+    float4 color0 : SV_TARGET0;
+    float4 color1 : SV_TARGET1;
+    float4 color2 : SV_TARGET2;
+    float4 color3 : SV_TARGET3;
+    float4 color4 : SV_TARGET4;
+    float4 color5 : SV_TARGET5;
+    float4 color6 : SV_TARGET6;
+    float4 color7 : SV_TARGET7;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-PS_OutputMultiple PS_ClearMultiple(in float4 inPosition : SV_POSITION, in float4 inColor : COLOR)
</del><ins>+PS_OutputFloat PS_ClearFloat(in float4 inPosition : SV_POSITION, in float4 inColor : COLOR)
</ins><span class="cx"> {
</span><del>-        PS_OutputMultiple outColor;
-        outColor.color0 = inColor;
-        outColor.color1 = inColor;
-        outColor.color2 = inColor;
-        outColor.color3 = inColor;
-        outColor.color4 = inColor;
-        outColor.color5 = inColor;
-        outColor.color6 = inColor;
-        outColor.color7 = inColor;
-        return outColor;
</del><ins>+    PS_OutputFloat outColor;
+    outColor.color0 = inColor;
+    outColor.color1 = inColor;
+    outColor.color2 = inColor;
+    outColor.color3 = inColor;
+    outColor.color4 = inColor;
+    outColor.color5 = inColor;
+    outColor.color6 = inColor;
+    outColor.color7 = inColor;
+    return outColor;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-float4 PS_ClearSingle(in float4 inPosition : SV_Position, in float4 inColor : COLOR) : SV_Target0
</del><ins>+
+void VS_ClearUint( in float3  inPosition :    POSITION,   in uint4  inColor : COLOR,
+                   out float4 outPosition : SV_POSITION, out uint4 outColor : COLOR)
</ins><span class="cx"> {
</span><del>-        return inColor;
</del><ins>+    outPosition = float4(inPosition, 1.0f);
+    outColor = inColor;
</ins><span class="cx"> }
</span><ins>+
+struct PS_OutputUint
+{
+    uint4 color0 : SV_TARGET0;
+    uint4 color1 : SV_TARGET1;
+    uint4 color2 : SV_TARGET2;
+    uint4 color3 : SV_TARGET3;
+    uint4 color4 : SV_TARGET4;
+    uint4 color5 : SV_TARGET5;
+    uint4 color6 : SV_TARGET6;
+    uint4 color7 : SV_TARGET7;
+};
+
+PS_OutputUint PS_ClearUint(in float4 inPosition : SV_POSITION, in uint4 inColor : COLOR)
+{
+    PS_OutputUint outColor;
+    outColor.color0 = inColor;
+    outColor.color1 = inColor;
+    outColor.color2 = inColor;
+    outColor.color3 = inColor;
+    outColor.color4 = inColor;
+    outColor.color5 = inColor;
+    outColor.color6 = inColor;
+    outColor.color7 = inColor;
+    return outColor;
+}
+
+
+void VS_ClearSint( in float3  inPosition :    POSITION,   in int4  inColor : COLOR,
+                   out float4 outPosition : SV_POSITION, out int4 outColor : COLOR)
+{
+    outPosition = float4(inPosition, 1.0f);
+    outColor = inColor;
+}
+
+struct PS_OutputSint
+{
+    int4 color0 : SV_TARGET0;
+    int4 color1 : SV_TARGET1;
+    int4 color2 : SV_TARGET2;
+    int4 color3 : SV_TARGET3;
+    int4 color4 : SV_TARGET4;
+    int4 color5 : SV_TARGET5;
+    int4 color6 : SV_TARGET6;
+    int4 color7 : SV_TARGET7;
+};
+
+PS_OutputSint PS_ClearSint(in float4 inPosition : SV_POSITION, in int4 inColor : COLOR)
+{
+    PS_OutputSint outColor;
+    outColor.color0 = inColor;
+    outColor.color1 = inColor;
+    outColor.color2 = inColor;
+    outColor.color3 = inColor;
+    outColor.color4 = inColor;
+    outColor.color5 = inColor;
+    outColor.color6 = inColor;
+    outColor.color7 = inColor;
+    return outColor;
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11shadersPassthrough2D11hlsl"></a>
<div class="addfile"><h4>Added: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough2D11.hlsl (0 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough2D11.hlsl                                (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough2D11.hlsl        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -0,0 +1,111 @@
</span><ins>+Texture2D&lt;float4&gt; TextureF  : register(t0);
+Texture2D&lt;uint4&gt;  TextureUI : register(t0);
+Texture2D&lt;int4&gt;   TextureI  : register(t0);
+
+SamplerState Sampler        : register(s0);
+
+void VS_Passthrough2D( 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;
+}
+
+float PS_PassthroughDepth2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_DEPTH
+{
+    return TextureF.Sample(Sampler, inTexCoord).r;
+}
+
+float4 PS_PassthroughRGBA2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    return TextureF.Sample(Sampler, inTexCoord).rgba;
+}
+
+uint4 PS_PassthroughRGBA2DUI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureUI.GetDimensions(size.x, size.y);
+
+    return TextureUI.Load(int3(size * inTexCoord, 0)).rgba;
+}
+
+int4 PS_PassthroughRGBA2DI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureI.GetDimensions(size.x, size.y);
+
+    return TextureI.Load(int3(size * inTexCoord, 0)).rgba;
+}
+
+float4 PS_PassthroughRGB2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    return float4(TextureF.Sample(Sampler, inTexCoord).rgb, 1.0f);
+}
+
+uint4 PS_PassthroughRGB2DUI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureUI.GetDimensions(size.x, size.y);
+
+    return uint4(TextureUI.Load(int3(size * inTexCoord, 0)).rgb, 0);
+}
+
+int4 PS_PassthroughRGB2DI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureI.GetDimensions(size.x, size.y);
+
+    return int4(TextureI.Load(int3(size * inTexCoord, 0)).rgb, 0);
+}
+
+float4 PS_PassthroughRG2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    return float4(TextureF.Sample(Sampler, inTexCoord).rg, 0.0f, 1.0f);
+}
+
+uint4 PS_PassthroughRG2DUI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureUI.GetDimensions(size.x, size.y);
+
+    return uint4(TextureUI.Load(int3(size * inTexCoord, 0)).rg, 0, 0);
+}
+
+int4 PS_PassthroughRG2DI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureI.GetDimensions(size.x, size.y);
+
+    return int4(TextureI.Load(int3(size * inTexCoord, 0)).rg, 0, 0);
+}
+
+float4 PS_PassthroughR2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    return float4(TextureF.Sample(Sampler, inTexCoord).r, 0.0f, 0.0f, 1.0f);
+}
+
+uint4 PS_PassthroughR2DUI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureUI.GetDimensions(size.x, size.y);
+
+    return uint4(TextureUI.Load(int3(size * inTexCoord, 0)).r, 0, 0, 0);
+}
+
+int4 PS_PassthroughR2DI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureI.GetDimensions(size.x, size.y);
+
+    return int4(TextureI.Load(int3(size * inTexCoord, 0)).r, 0, 0, 0);
+}
+
+float4 PS_PassthroughLum2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    return float4(TextureF.Sample(Sampler, inTexCoord).rrr, 1.0f);
+}
+
+float4 PS_PassthroughLumAlpha2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    return TextureF.Sample(Sampler, inTexCoord).rrra;
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d11shadersgenerate_shadersbat"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/generate_shaders.bat (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/generate_shaders.bat        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/generate_shaders.bat        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,18 +1,119 @@
</span><span class="cx"> @ECHO OFF
</span><span class="cx"> REM
</span><del>-REM Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+REM Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> REM Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> REM found in the LICENSE file.
</span><span class="cx"> REM
</span><span class="cx"> 
</span><span class="cx"> PATH %PATH%;%ProgramFiles(x86)%\Windows Kits\8.0\bin\x86;%DXSDK_DIR%\Utilities\bin\x86
</span><span class="cx"> 
</span><del>-fxc /E VS_Passthrough /T vs_4_0 /Fh compiled/passthrough11vs.h Passthrough11.hlsl
-fxc /E PS_PassthroughRGBA /T ps_4_0 /Fh compiled/passthroughrgba11ps.h Passthrough11.hlsl
-fxc /E PS_PassthroughRGB /T ps_4_0 /Fh compiled/passthroughrgb11ps.h Passthrough11.hlsl
-fxc /E PS_PassthroughLum /T ps_4_0 /Fh compiled/passthroughlum11ps.h Passthrough11.hlsl
-fxc /E PS_PassthroughLumAlpha /T ps_4_0 /Fh compiled/passthroughlumalpha11ps.h Passthrough11.hlsl
</del><ins>+setlocal
+set errorCount=0
+set successCount=0
+set debug=0
</ins><span class="cx"> 
</span><del>-fxc /E VS_Clear /T vs_4_0 /Fh compiled/clear11vs.h Clear11.hlsl
-fxc /E PS_ClearSingle /T ps_4_0 /Fh compiled/clearsingle11ps.h Clear11.hlsl
-fxc /E PS_ClearMultiple /T ps_4_0 /Fh compiled/clearmultiple11ps.h Clear11.hlsl
</del><ins>+if &quot;%1&quot; == &quot;debug&quot; (
+    set debug=1
+)
+if &quot;%1&quot; == &quot;release&quot; (
+    set debug=0
+)
+
+::              | Input file          | Entry point           | Type | Output file                        | Debug |
+call:BuildShader Passthrough2D11.hlsl VS_Passthrough2D         vs_4_0 compiled\passthrough2d11vs.h         %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughDepth2D    ps_4_0 compiled\passthroughdepth2d11ps.h    %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughRGBA2D     ps_4_0 compiled\passthroughrgba2d11ps.h     %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughRGBA2DUI   ps_4_0 compiled\passthroughrgba2dui11ps.h   %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughRGBA2DI    ps_4_0 compiled\passthroughrgba2di11ps.h    %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughRGB2D      ps_4_0 compiled\passthroughrgb2d11ps.h      %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughRGB2DUI    ps_4_0 compiled\passthroughrgb2dui11ps.h    %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughRGB2DI     ps_4_0 compiled\passthroughrgb2di11ps.h     %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughRG2D       ps_4_0 compiled\passthroughrg2d11ps.h       %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughRG2DUI     ps_4_0 compiled\passthroughrg2dui11ps.h     %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughRG2DI      ps_4_0 compiled\passthroughrg2di11ps.h      %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughR2D        ps_4_0 compiled\passthroughr2d11ps.h        %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughR2DUI      ps_4_0 compiled\passthroughr2dui11ps.h      %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughR2DI       ps_4_0 compiled\passthroughr2di11ps.h       %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughLum2D      ps_4_0 compiled\passthroughlum2d11ps.h      %debug%
+call:BuildShader Passthrough2D11.hlsl PS_PassthroughLumAlpha2D ps_4_0 compiled\passthroughlumalpha2d11ps.h %debug%
+
+
+call:BuildShader Passthrough3D11.hlsl VS_Passthrough3D         vs_4_0 compiled\passthrough3d11vs.h         %debug%
+call:BuildShader Passthrough3D11.hlsl GS_Passthrough3D         gs_4_0 compiled\passthrough3d11gs.h         %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughRGBA3D     ps_4_0 compiled\passthroughrgba3d11ps.h     %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughRGBA3DUI   ps_4_0 compiled\passthroughrgba3dui11ps.h   %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughRGBA3DI    ps_4_0 compiled\passthroughrgba3di11ps.h    %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughRGB3D      ps_4_0 compiled\passthroughrgb3d11ps.h      %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughRGB3DUI    ps_4_0 compiled\passthroughrgb3dui11ps.h    %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughRGB3DI     ps_4_0 compiled\passthroughrgb3di11ps.h     %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughRG3D       ps_4_0 compiled\passthroughrg3d11ps.h       %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughRG3DUI     ps_4_0 compiled\passthroughrg3dui11ps.h     %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughRG3DI      ps_4_0 compiled\passthroughrg3di11ps.h      %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughR3D        ps_4_0 compiled\passthroughr3d11ps.h        %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughR3DUI      ps_4_0 compiled\passthroughr3dui11ps.h      %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughR3DI       ps_4_0 compiled\passthroughr3di11ps.h       %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughLum3D      ps_4_0 compiled\passthroughlum3d11ps.h      %debug%
+call:BuildShader Passthrough3D11.hlsl PS_PassthroughLumAlpha3D ps_4_0 compiled\passthroughlumalpha3d11ps.h %debug%
+
+call:BuildShader Swizzle11.hlsl       PS_SwizzleF2D            ps_4_0 compiled\swizzlef2dps.h              %debug%
+call:BuildShader Swizzle11.hlsl       PS_SwizzleI2D            ps_4_0 compiled\swizzlei2dps.h              %debug%
+call:BuildShader Swizzle11.hlsl       PS_SwizzleUI2D           ps_4_0 compiled\swizzleui2dps.h             %debug%
+
+call:BuildShader Swizzle11.hlsl       PS_SwizzleF3D            ps_4_0 compiled\swizzlef3dps.h              %debug%
+call:BuildShader Swizzle11.hlsl       PS_SwizzleI3D            ps_4_0 compiled\swizzlei3dps.h              %debug%
+call:BuildShader Swizzle11.hlsl       PS_SwizzleUI3D           ps_4_0 compiled\swizzleui3dps.h             %debug%
+
+call:BuildShader Swizzle11.hlsl       PS_SwizzleF2DArray       ps_4_0 compiled\swizzlef2darrayps.h         %debug%
+call:BuildShader Swizzle11.hlsl       PS_SwizzleI2DArray       ps_4_0 compiled\swizzlei2darrayps.h         %debug%
+call:BuildShader Swizzle11.hlsl       PS_SwizzleUI2DArray      ps_4_0 compiled\swizzleui2darrayps.h        %debug%
+
+call:BuildShader Clear11.hlsl         VS_ClearFloat            vs_4_0 compiled\clearfloat11vs.h            %debug%
+call:BuildShader Clear11.hlsl         PS_ClearFloat            ps_4_0 compiled\clearfloat11ps.h            %debug%
+
+call:BuildShader Clear11.hlsl         VS_ClearUint             vs_4_0 compiled\clearuint11vs.h             %debug%
+call:BuildShader Clear11.hlsl         PS_ClearUint             ps_4_0 compiled\clearuint11ps.h             %debug%
+
+call:BuildShader Clear11.hlsl         VS_ClearSint             vs_4_0 compiled\clearsint11vs.h             %debug%
+call:BuildShader Clear11.hlsl         PS_ClearSint             ps_4_0 compiled\clearsint11ps.h             %debug%
+
+call:BuildShader BufferToTexture11.hlsl  VS_BufferToTexture        vs_4_0 compiled/buffertotexture11_vs.h      %debug%
+call:BuildShader BufferToTexture11.hlsl  GS_BufferToTexture        gs_4_0 compiled/buffertotexture11_gs.h      %debug%
+call:BuildShader BufferToTexture11.hlsl  PS_BufferToTexture_4F     ps_4_0 compiled/buffertotexture11_ps_4f.h   %debug%
+call:BuildShader BufferToTexture11.hlsl  PS_BufferToTexture_4I     ps_4_0 compiled/buffertotexture11_ps_4i.h   %debug%
+call:BuildShader BufferToTexture11.hlsl  PS_BufferToTexture_4UI    ps_4_0 compiled/buffertotexture11_ps_4ui.h  %debug%
+
+echo.
+
+if %successCount% GTR 0 (
+   echo %successCount% shaders compiled successfully.
+)
+if %errorCount% GTR 0 (
+   echo There were %errorCount% shader compilation errors.
+)
+
+endlocal
+exit /b
+
+:BuildShader
+set input=%~1
+set entry=%~2
+set type=%~3
+set output=%~4
+set debug=%~5
+
+if %debug% == 0 (
+    set &quot;buildCMD=fxc /nologo /E %entry% /T %type% /Fh %output% %input%&quot;
+) else (
+    set &quot;buildCMD=fxc /nologo /Zi /Od /E %entry% /T %type% /Fh %output% %input%&quot;
+)
+
+set error=0
+%buildCMD% || set error=1
+
+if %error% == 0 (
+    set /a successCount=%successCount%+1
+) else (
+    set /a errorCount=%errorCount%+1
+)
+
+exit /b
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9BufferStorage9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx"> 
</span><span class="cx"> BufferStorage9::~BufferStorage9()
</span><span class="cx"> {
</span><del>-    delete[] mMemory;
</del><ins>+    SafeDeleteArray(mMemory);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> BufferStorage9 *BufferStorage9::makeBufferStorage9(BufferStorage *bufferStorage)
</span><span class="lines">@@ -60,11 +60,29 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void BufferStorage9::copyData(BufferStorage* sourceStorage, unsigned int size,
+                              unsigned int sourceOffset, unsigned int destOffset)
+{
+    BufferStorage9* source = makeBufferStorage9(sourceStorage);
+    if (source)
+    {
+        void* sourceMemory = reinterpret_cast&lt;char*&gt;(source-&gt;mMemory) + sourceOffset;
+        void* destMemory = reinterpret_cast&lt;char*&gt;(mMemory) + destOffset;
+
+        memcpy(destMemory, sourceMemory, size);
+    }
+}
+
</ins><span class="cx"> void BufferStorage9::clear()
</span><span class="cx"> {
</span><span class="cx">     mSize = 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void BufferStorage9::markTransformFeedbackUsage()
+{
+    UNREACHABLE();
+}
+
</ins><span class="cx"> unsigned int BufferStorage9::getSize() const
</span><span class="cx"> {
</span><span class="cx">     return mSize;
</span><span class="lines">@@ -75,4 +93,22 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// We do not suppot buffer mapping facility in D3D9
+bool BufferStorage9::isMapped() const
+{
+    UNREACHABLE();
+    return false;
</ins><span class="cx"> }
</span><ins>+
+void *BufferStorage9::map(GLbitfield access)
+{
+    UNREACHABLE();
+    return NULL;
+}
+
+void BufferStorage9::unmap()
+{
+    UNREACHABLE();
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9BufferStorage9h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/BufferStorage9.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/BufferStorage9.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/BufferStorage9.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -24,10 +24,17 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void *getData();
</span><span class="cx">     virtual void setData(const void* data, unsigned int size, unsigned int offset);
</span><ins>+    virtual void copyData(BufferStorage* sourceStorage, unsigned int size,
+                          unsigned int sourceOffset, unsigned int destOffset);
</ins><span class="cx">     virtual void clear();
</span><ins>+    virtual void markTransformFeedbackUsage();
</ins><span class="cx">     virtual unsigned int getSize() const;
</span><span class="cx">     virtual bool supportsDirectBinding() const;
</span><span class="cx"> 
</span><ins>+    virtual bool isMapped() const;
+    virtual void *map(GLbitfield access);
+    virtual void unmap();
+
</ins><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(BufferStorage9);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Fence9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Fence9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Fence9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Fence9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -23,21 +23,15 @@
</span><span class="cx"> 
</span><span class="cx"> Fence9::~Fence9()
</span><span class="cx"> {
</span><del>-    if (mQuery)
-    {
-        mRenderer-&gt;freeEventQuery(mQuery);
-        mQuery = NULL;
-    }
</del><ins>+    SafeRelease(mQuery);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLboolean Fence9::isFence()
</del><ins>+bool Fence9::isSet() const
</ins><span class="cx"> {
</span><del>-    // GL_NV_fence spec:
-    // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence.
</del><span class="cx">     return mQuery != NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Fence9::setFence(GLenum condition)
</del><ins>+void Fence9::set()
</ins><span class="cx"> {
</span><span class="cx">     if (!mQuery)
</span><span class="cx">     {
</span><span class="lines">@@ -50,86 +44,29 @@
</span><span class="cx"> 
</span><span class="cx">     HRESULT result = mQuery-&gt;Issue(D3DISSUE_END);
</span><span class="cx">     ASSERT(SUCCEEDED(result));
</span><del>-
-    setCondition(condition);
-    setStatus(GL_FALSE);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLboolean Fence9::testFence()
</del><ins>+bool Fence9::test(bool flushCommandBuffer)
</ins><span class="cx"> {
</span><del>-    if (mQuery == NULL)
-    {
-        return gl::error(GL_INVALID_OPERATION, GL_TRUE);
-    }
</del><ins>+    ASSERT(mQuery);
</ins><span class="cx"> 
</span><del>-    HRESULT result = mQuery-&gt;GetData(NULL, 0, D3DGETDATA_FLUSH);
</del><ins>+    DWORD getDataFlags = (flushCommandBuffer ? D3DGETDATA_FLUSH : 0);
+    HRESULT result = mQuery-&gt;GetData(NULL, 0, getDataFlags);
</ins><span class="cx"> 
</span><span class="cx">     if (d3d9::isDeviceLostError(result))
</span><span class="cx">     {
</span><span class="cx">         mRenderer-&gt;notifyDeviceLost();
</span><del>-        return gl::error(GL_OUT_OF_MEMORY, GL_TRUE);
</del><ins>+        return gl::error(GL_OUT_OF_MEMORY, true);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT(result == S_OK || result == S_FALSE);
</span><del>-    setStatus(result == S_OK);
-    return getStatus();
-}
</del><span class="cx"> 
</span><del>-void Fence9::finishFence()
-{
-    if (mQuery == NULL)
-    {
-        return gl::error(GL_INVALID_OPERATION);
-    }
-
-    while (!testFence())
-    {
-        Sleep(0);
-    }
</del><ins>+    return (result == S_OK);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Fence9::getFenceiv(GLenum pname, GLint *params)
</del><ins>+bool Fence9::hasError() const
</ins><span class="cx"> {
</span><del>-    if (mQuery == NULL)
-    {
-        return gl::error(GL_INVALID_OPERATION);
-    }
-
-    switch (pname)
-    {
-        case GL_FENCE_STATUS_NV:
-        {
-            // GL_NV_fence spec:
-            // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
-            // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
-            if (getStatus())
-            {
-                params[0] = GL_TRUE;
-                return;
-            }
-            
-            HRESULT result = mQuery-&gt;GetData(NULL, 0, 0);
-
-            if (d3d9::isDeviceLostError(result))
-            {
-                params[0] = GL_TRUE;
-                mRenderer-&gt;notifyDeviceLost();
-                return gl::error(GL_OUT_OF_MEMORY);
-            }
-
-            ASSERT(result == S_OK || result == S_FALSE);
-            setStatus(result == S_OK);
-            params[0] = getStatus();
-
-            break;
-        }
-        case GL_FENCE_CONDITION_NV:
-            params[0] = getCondition();
-            break;
-        default:
-            return gl::error(GL_INVALID_ENUM);
-            break;
-    }
</del><ins>+    return mRenderer-&gt;isDeviceLost();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Fence9h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Fence9.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Fence9.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Fence9.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -21,11 +21,10 @@
</span><span class="cx">     explicit Fence9(rx::Renderer9 *renderer);
</span><span class="cx">     virtual ~Fence9();
</span><span class="cx"> 
</span><del>-    GLboolean isFence();
-    void setFence(GLenum condition);
-    GLboolean testFence();
-    void finishFence();
-    void getFenceiv(GLenum pname, GLint *params);
</del><ins>+    bool isSet() const;
+    void set();
+    bool test(bool flushCommandBuffer);
+    bool hasError() const;
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Fence9);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Image9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Image9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Image9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Image9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/TextureStorage9.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/renderer9_utils.h&quot;
</span><del>-#include &quot;libGLESv2/renderer/generatemip.h&quot;
</del><ins>+#include &quot;libGLESv2/renderer/d3d9/formatutils9.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -34,10 +34,7 @@
</span><span class="cx"> 
</span><span class="cx"> Image9::~Image9()
</span><span class="cx"> {
</span><del>-    if (mSurface)
-    {
-        mSurface-&gt;Release();
-    }
</del><ins>+    SafeRelease(mSurface);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface)
</span><span class="lines">@@ -54,6 +51,9 @@
</span><span class="cx">     ASSERT(sourceDesc.Width == 1 || sourceDesc.Width / 2 == destDesc.Width);
</span><span class="cx">     ASSERT(sourceDesc.Height == 1 || sourceDesc.Height / 2 == destDesc.Height);
</span><span class="cx"> 
</span><ins>+    MipGenerationFunction mipFunction = d3d9::GetMipGenerationFunction(sourceDesc.Format);
+    ASSERT(mipFunction != NULL);
+
</ins><span class="cx">     D3DLOCKED_RECT sourceLocked = {0};
</span><span class="cx">     result = sourceSurface-&gt;LockRect(&amp;sourceLocked, NULL, D3DLOCK_READONLY);
</span><span class="cx">     ASSERT(SUCCEEDED(result));
</span><span class="lines">@@ -67,32 +67,12 @@
</span><span class="cx"> 
</span><span class="cx">     if (sourceData &amp;&amp; destData)
</span><span class="cx">     {
</span><del>-        switch (sourceDesc.Format)
-        {
-          case D3DFMT_L8:
-            GenerateMip&lt;L8&gt;(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch);
-            break;
-          case D3DFMT_A8L8:
-            GenerateMip&lt;A8L8&gt;(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch);
-            break;
-          case D3DFMT_A8R8G8B8:
-          case D3DFMT_X8R8G8B8:
-            GenerateMip&lt;A8R8G8B8&gt;(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch);
-            break;
-          case D3DFMT_A16B16G16R16F:
-            GenerateMip&lt;A16B16G16R16F&gt;(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch);
-            break;
-          case D3DFMT_A32B32G32R32F:
-            GenerateMip&lt;A32B32G32R32F&gt;(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch);
-            break;
-          default:
-            UNREACHABLE();
-            break;
-        }
-
-        destSurface-&gt;UnlockRect();
-        sourceSurface-&gt;UnlockRect();
</del><ins>+        mipFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData, sourceLocked.Pitch, 0,
+                    destData, destLocked.Pitch, 0);
</ins><span class="cx">     }
</span><ins>+
+    destSurface-&gt;UnlockRect();
+    sourceSurface-&gt;UnlockRect();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Image9 *Image9::makeImage9(Image *img)
</span><span class="lines">@@ -126,8 +106,10 @@
</span><span class="cx">         D3DSURFACE_DESC desc;
</span><span class="cx">         source-&gt;GetDesc(&amp;desc);
</span><span class="cx"> 
</span><del>-        int rows = d3d9::IsCompressedFormat(desc.Format) ? desc.Height / 4 : desc.Height;
-        int bytes = d3d9::ComputeRowSize(desc.Format, desc.Width);
</del><ins>+        int blockHeight = d3d9::GetBlockHeight(desc.Format);
+        int rows = desc.Height / blockHeight;
+
+        int bytes = d3d9::GetBlockSize(desc.Format, desc.Width, blockHeight);
</ins><span class="cx">         ASSERT(bytes &lt;= sourceLock.Pitch &amp;&amp; bytes &lt;= destLock.Pitch);
</span><span class="cx"> 
</span><span class="cx">         for(int i = 0; i &lt; rows; i++)
</span><span class="lines">@@ -141,10 +123,17 @@
</span><span class="cx">     else UNREACHABLE();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Image9::redefine(rx::Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease)
</del><ins>+bool Image9::redefine(rx::Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease)
</ins><span class="cx"> {
</span><ins>+    // 3D textures are not supported by the D3D9 backend.
+    ASSERT(depth &lt;= 1);
+
+    // Only 2D and cube texture are supported by the D3D9 backend.
+    ASSERT(target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP);
+
</ins><span class="cx">     if (mWidth != width ||
</span><span class="cx">         mHeight != height ||
</span><ins>+        mDepth != depth ||
</ins><span class="cx">         mInternalFormat != internalformat ||
</span><span class="cx">         forceRelease)
</span><span class="cx">     {
</span><span class="lines">@@ -152,16 +141,16 @@
</span><span class="cx"> 
</span><span class="cx">         mWidth = width;
</span><span class="cx">         mHeight = height;
</span><ins>+        mDepth = depth;
</ins><span class="cx">         mInternalFormat = internalformat;
</span><ins>+
</ins><span class="cx">         // compute the d3d format that will be used
</span><del>-        mD3DFormat = mRenderer-&gt;ConvertTextureInternalFormat(internalformat);
-        mActualFormat = d3d9_gl::GetEquivalentFormat(mD3DFormat);
</del><ins>+        mD3DFormat = gl_d3d9::GetTextureFormat(internalformat, mRenderer);
+        mActualFormat = d3d9_gl::GetInternalFormat(mD3DFormat);
+        mRenderable = gl_d3d9::GetRenderFormat(internalformat, mRenderer) != D3DFMT_UNKNOWN;
</ins><span class="cx"> 
</span><del>-        if (mSurface)
-        {
-            mSurface-&gt;Release();
-            mSurface = NULL;
-        }
</del><ins>+        SafeRelease(mSurface);
+        mDirty = gl_d3d9::RequiresTextureDataInitialization(mInternalFormat);
</ins><span class="cx"> 
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -180,14 +169,13 @@
</span><span class="cx">     IDirect3DSurface9 *newSurface = NULL;
</span><span class="cx">     const D3DPOOL poolToUse = D3DPOOL_SYSTEMMEM;
</span><span class="cx">     const D3DFORMAT d3dFormat = getD3DFormat();
</span><del>-    ASSERT(d3dFormat != D3DFMT_INTZ); // We should never get here for depth textures
</del><span class="cx"> 
</span><span class="cx">     if (mWidth != 0 &amp;&amp; mHeight != 0)
</span><span class="cx">     {
</span><span class="cx">         int levelToFetch = 0;
</span><span class="cx">         GLsizei requestWidth = mWidth;
</span><span class="cx">         GLsizei requestHeight = mHeight;
</span><del>-        gl::MakeValidSize(true, gl::IsCompressed(mInternalFormat), &amp;requestWidth, &amp;requestHeight, &amp;levelToFetch);
</del><ins>+        d3d9::MakeValidSize(true, d3dFormat, &amp;requestWidth, &amp;requestHeight, &amp;levelToFetch);
</ins><span class="cx"> 
</span><span class="cx">         IDirect3DDevice9 *device = mRenderer-&gt;getDevice();
</span><span class="cx"> 
</span><span class="lines">@@ -202,7 +190,27 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         newTexture-&gt;GetSurfaceLevel(levelToFetch, &amp;newSurface);
</span><del>-        newTexture-&gt;Release();
</del><ins>+        SafeRelease(newTexture);
+
+        if (gl_d3d9::RequiresTextureDataInitialization(mInternalFormat))
+        {
+            InitializeTextureDataFunction initializeFunc = gl_d3d9::GetTextureDataInitializationFunction(mInternalFormat);
+
+            RECT entireRect;
+            entireRect.left = 0;
+            entireRect.right = mWidth;
+            entireRect.top = 0;
+            entireRect.bottom = mHeight;
+
+            D3DLOCKED_RECT lockedRect;
+            result = newSurface-&gt;LockRect(&amp;lockedRect, &amp;entireRect, 0);
+            ASSERT(SUCCEEDED(result));
+
+            initializeFunc(mWidth, mHeight, 1, lockedRect.pBits, lockedRect.Pitch, 0);
+
+            result = newSurface-&gt;UnlockRect();
+            ASSERT(SUCCEEDED(result));
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     mSurface = newSurface;
</span><span class="lines">@@ -236,11 +244,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Image9::isRenderableFormat() const
-{    
-    return TextureStorage9::IsTextureFormatRenderable(getD3DFormat());
-}
-
</del><span class="cx"> D3DFORMAT Image9::getD3DFormat() const
</span><span class="cx"> {
</span><span class="cx">     // this should only happen if the image hasn't been redefined first
</span><span class="lines">@@ -250,6 +253,13 @@
</span><span class="cx">     return mD3DFormat;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Image9::isDirty() const
+{
+    // Make sure to that this image is marked as dirty even if the staging texture hasn't been created yet
+    // if initialization is required before use.
+    return (mSurface || gl_d3d9::RequiresTextureDataInitialization(mInternalFormat)) &amp;&amp; mDirty;
+}
+
</ins><span class="cx"> IDirect3DSurface9 *Image9::getSurface()
</span><span class="cx"> {
</span><span class="cx">     createSurface();
</span><span class="lines">@@ -280,7 +290,7 @@
</span><span class="cx">         if (mSurface)
</span><span class="cx">         {
</span><span class="cx">             copyLockableSurfaces(surface, mSurface);
</span><del>-            mSurface-&gt;Release();
</del><ins>+            SafeRelease(mSurface);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         mSurface = surface;
</span><span class="lines">@@ -288,22 +298,38 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Image9::updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</del><ins>+bool Image9::copyToStorage(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(getSurface() != NULL);
</span><span class="cx">     TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage-&gt;getStorageInstance());
</span><del>-    return updateSurface(storage9-&gt;getSurfaceLevel(level, true), xoffset, yoffset, width, height);
</del><ins>+    return copyToSurface(storage9-&gt;getSurfaceLevel(level, true), xoffset, yoffset, width, height);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Image9::updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</del><ins>+bool Image9::copyToStorage(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(getSurface() != NULL);
</span><span class="cx">     TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage-&gt;getStorageInstance());
</span><del>-    return updateSurface(storage9-&gt;getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, true), xoffset, yoffset, width, height);
</del><ins>+    return copyToSurface(storage9-&gt;getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, true), xoffset, yoffset, width, height);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Image9::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
</del><ins>+bool Image9::copyToStorage(TextureStorageInterface3D *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth)
</ins><span class="cx"> {
</span><ins>+    // 3D textures are not supported by the D3D9 backend.
+    UNREACHABLE();
+    return false;
+}
+
+bool Image9::copyToStorage(TextureStorageInterface2DArray *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height)
+{
+    // 2D array textures are not supported by the D3D9 backend.
+    UNREACHABLE();
+    return false;
+}
+
+bool Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
+{
+    ASSERT(width &gt; 0 &amp;&amp; height &gt; 0);
+
</ins><span class="cx">     if (!destSurface)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="lines">@@ -334,7 +360,7 @@
</span><span class="cx">                 copyLockableSurfaces(surf, sourceSurface);
</span><span class="cx">                 result = device-&gt;UpdateSurface(surf, &amp;rect, destSurface, &amp;point);
</span><span class="cx">                 ASSERT(SUCCEEDED(result));
</span><del>-                surf-&gt;Release();
</del><ins>+                SafeRelease(surf);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         else
</span><span class="lines">@@ -345,15 +371,24 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    destSurface-&gt;Release();
</del><ins>+    SafeRelease(destSurface);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
</span><span class="cx"> // into the target pixel rectangle.
</span><del>-void Image9::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
-                      GLint unpackAlignment, const void *input)
</del><ins>+void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                      GLint unpackAlignment, GLenum type, const void *input)
</ins><span class="cx"> {
</span><ins>+    // 3D textures are not supported by the D3D9 backend.
+    ASSERT(zoffset == 0 &amp;&amp; depth == 1);
+
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, clientVersion, width, unpackAlignment);
+
+    LoadImageFunction loadFunction = d3d9::GetImageLoadFunction(mInternalFormat, mRenderer);
+    ASSERT(loadFunction != NULL);
+
</ins><span class="cx">     RECT lockRect =
</span><span class="cx">     {
</span><span class="cx">         xoffset, yoffset,
</span><span class="lines">@@ -367,96 +402,32 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    loadFunction(width, height, depth, input, inputRowPitch, 0, locked.pBits, locked.Pitch, 0);
</ins><span class="cx"> 
</span><del>-    GLsizei inputPitch = gl::ComputePitch(width, mInternalFormat, unpackAlignment);
-
-    switch (mInternalFormat)
-    {
-      case GL_ALPHA8_EXT:
-        if (gl::supportsSSE2())
-        {
-            loadAlphaDataToBGRASSE2(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        }
-        else
-        {
-            loadAlphaDataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        }
-        break;
-      case GL_LUMINANCE8_EXT:
-        loadLuminanceDataToNativeOrBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits, getD3DFormat() == D3DFMT_L8);
-        break;
-      case GL_ALPHA32F_EXT:
-        loadAlphaFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_LUMINANCE32F_EXT:
-        loadLuminanceFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_ALPHA16F_EXT:
-        loadAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_LUMINANCE16F_EXT:
-        loadLuminanceHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_LUMINANCE8_ALPHA8_EXT:
-        loadLuminanceAlphaDataToNativeOrBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits, getD3DFormat() == D3DFMT_A8L8);
-        break;
-      case GL_LUMINANCE_ALPHA32F_EXT:
-        loadLuminanceAlphaFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_LUMINANCE_ALPHA16F_EXT:
-        loadLuminanceAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_RGB8_OES:
-        loadRGBUByteDataToBGRX(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_RGB565:
-        loadRGB565DataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_RGBA8_OES:
-        if (gl::supportsSSE2())
-        {
-            loadRGBAUByteDataToBGRASSE2(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        }
-        else
-        {
-            loadRGBAUByteDataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        }
-        break;
-      case GL_RGBA4:
-        loadRGBA4444DataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_RGB5_A1:
-        loadRGBA5551DataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_BGRA8_EXT:
-        loadBGRADataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      // float textures are converted to RGBA, not BGRA, as they're stored that way in D3D
-      case GL_RGB32F_EXT:
-        loadRGBFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_RGB16F_EXT:
-        loadRGBHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_RGBA32F_EXT:
-        loadRGBAFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      case GL_RGBA16F_EXT:
-        loadRGBAHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
-        break;
-      default: UNREACHABLE(); 
-    }
-
</del><span class="cx">     unlock();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
</del><ins>+void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
</ins><span class="cx">                                 const void *input)
</span><span class="cx"> {
</span><del>-    ASSERT(xoffset % 4 == 0);
-    ASSERT(yoffset % 4 == 0);
</del><ins>+    // 3D textures are not supported by the D3D9 backend.
+    ASSERT(zoffset == 0 &amp;&amp; depth == 1);
</ins><span class="cx"> 
</span><del>-    RECT lockRect = {
</del><ins>+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+    GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, 1);
+    GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
+
+    GLuint outputBlockWidth = d3d9::GetBlockWidth(mD3DFormat);
+    GLuint outputBlockHeight = d3d9::GetBlockHeight(mD3DFormat);
+
+    ASSERT(xoffset % outputBlockWidth == 0);
+    ASSERT(yoffset % outputBlockHeight == 0);
+
+    LoadImageFunction loadFunction = d3d9::GetImageLoadFunction(mInternalFormat, mRenderer);
+    ASSERT(loadFunction != NULL);
+
+    RECT lockRect =
+    {
</ins><span class="cx">         xoffset, yoffset,
</span><span class="cx">         xoffset + width, yoffset + height
</span><span class="cx">     };
</span><span class="lines">@@ -468,20 +439,18 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    GLsizei inputSize = gl::ComputeCompressedSize(width, height, mInternalFormat);
-    GLsizei inputPitch = gl::ComputeCompressedPitch(width, mInternalFormat);
-    int rows = inputSize / inputPitch;
-    for (int i = 0; i &lt; rows; ++i)
-    {
-        memcpy((void*)((BYTE*)locked.pBits + i * locked.Pitch), (void*)((BYTE*)input + i * inputPitch), inputPitch);
-    }
</del><ins>+    loadFunction(width, height, depth, input, inputRowPitch, inputDepthPitch,
+                 locked.pBits, locked.Pitch, 0);
</ins><span class="cx"> 
</span><span class="cx">     unlock();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures
</span><del>-void Image9::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source)
</del><ins>+void Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source)
</ins><span class="cx"> {
</span><ins>+    // ES3.0 only behaviour to copy into a 3d texture
+    ASSERT(zoffset == 0);
+
</ins><span class="cx">     RenderTarget9 *renderTarget = NULL;
</span><span class="cx">     IDirect3DSurface9 *surface = NULL;
</span><span class="cx">     gl::Renderbuffer *colorbuffer = source-&gt;getColorbuffer(0);
</span><span class="lines">@@ -513,7 +482,7 @@
</span><span class="cx">     if (FAILED(result))
</span><span class="cx">     {
</span><span class="cx">         ERR(&quot;Could not create matching destination surface.&quot;);
</span><del>-        surface-&gt;Release();
</del><ins>+        SafeRelease(surface);
</ins><span class="cx">         return gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -522,8 +491,8 @@
</span><span class="cx">     if (FAILED(result))
</span><span class="cx">     {
</span><span class="cx">         ERR(&quot;GetRenderTargetData unexpectedly failed.&quot;);
</span><del>-        renderTargetData-&gt;Release();
-        surface-&gt;Release();
</del><ins>+        SafeRelease(renderTargetData);
+        SafeRelease(surface);
</ins><span class="cx">         return gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -536,8 +505,8 @@
</span><span class="cx">     if (FAILED(result))
</span><span class="cx">     {
</span><span class="cx">         ERR(&quot;Failed to lock the source surface (rectangle might be invalid).&quot;);
</span><del>-        renderTargetData-&gt;Release();
-        surface-&gt;Release();
</del><ins>+        SafeRelease(renderTargetData);
+        SafeRelease(surface);
</ins><span class="cx">         return gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -548,8 +517,8 @@
</span><span class="cx">     {
</span><span class="cx">         ERR(&quot;Failed to lock the destination surface (rectangle might be invalid).&quot;);
</span><span class="cx">         renderTargetData-&gt;UnlockRect();
</span><del>-        renderTargetData-&gt;Release();
-        surface-&gt;Release();
</del><ins>+        SafeRelease(renderTargetData);
+        SafeRelease(surface);
</ins><span class="cx">         return gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -723,10 +692,10 @@
</span><span class="cx">     unlock();
</span><span class="cx">     renderTargetData-&gt;UnlockRect();
</span><span class="cx"> 
</span><del>-    renderTargetData-&gt;Release();
-    surface-&gt;Release();
</del><ins>+    SafeRelease(renderTargetData);
+    SafeRelease(surface);
</ins><span class="cx"> 
</span><span class="cx">     mDirty = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Image9h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Image9.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Image9.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Image9.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -37,32 +37,33 @@
</span><span class="cx">     static void generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface);
</span><span class="cx">     static void copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source);
</span><span class="cx"> 
</span><del>-    virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease);
</del><ins>+    virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease);
</ins><span class="cx"> 
</span><del>-    virtual bool isRenderableFormat() const;
</del><span class="cx">     D3DFORMAT getD3DFormat() const;
</span><span class="cx"> 
</span><del>-    virtual bool isDirty() const {return mSurface &amp;&amp; mDirty;}
</del><ins>+    virtual bool isDirty() const;
</ins><span class="cx">     IDirect3DSurface9 *getSurface();
</span><span class="cx"> 
</span><span class="cx">     virtual void setManagedSurface(TextureStorageInterface2D *storage, int level);
</span><span class="cx">     virtual void setManagedSurface(TextureStorageInterfaceCube *storage, int face, int level);
</span><del>-    virtual bool updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
-    virtual bool updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
</del><ins>+    virtual bool copyToStorage(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
+    virtual bool copyToStorage(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
+    virtual bool copyToStorage(TextureStorageInterface3D *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
+    virtual bool copyToStorage(TextureStorageInterface2DArray *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height);
</ins><span class="cx"> 
</span><del>-    virtual void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
-                  GLint unpackAlignment, const void *input);
-    virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
</del><ins>+    virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                          GLint unpackAlignment, GLenum type, const void *input);
+    virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
</ins><span class="cx">                                     const void *input);
</span><span class="cx"> 
</span><del>-    virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
</del><ins>+    virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset,GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Image9);
</span><span class="cx"> 
</span><span class="cx">     void createSurface();
</span><span class="cx">     void setManagedSurface(IDirect3DSurface9 *surface);
</span><del>-    bool updateSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
</del><ins>+    bool copyToSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
</ins><span class="cx"> 
</span><span class="cx">     HRESULT lock(D3DLOCKED_RECT *lockedRect, const RECT *rect);
</span><span class="cx">     void unlock();
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9IndexBuffer9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -23,20 +23,12 @@
</span><span class="cx"> 
</span><span class="cx"> IndexBuffer9::~IndexBuffer9()
</span><span class="cx"> {
</span><del>-    if (mIndexBuffer)
-    {
-        mIndexBuffer-&gt;Release();
-        mIndexBuffer = NULL;
-    }
</del><ins>+    SafeRelease(mIndexBuffer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic)
</span><span class="cx"> {
</span><del>-    if (mIndexBuffer)
-    {
-        mIndexBuffer-&gt;Release();
-        mIndexBuffer = NULL;
-    }
</del><ins>+    SafeRelease(mIndexBuffer);
</ins><span class="cx"> 
</span><span class="cx">     updateSerial();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Query9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Query9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Query9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Query9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -24,11 +24,7 @@
</span><span class="cx"> 
</span><span class="cx"> Query9::~Query9()
</span><span class="cx"> {
</span><del>-    if (mQuery)
-    {
-        mQuery-&gt;Release();
-        mQuery = NULL;
-    }
</del><ins>+    SafeRelease(mQuery);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Query9::begin()
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9RenderTarget9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -12,11 +12,13 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/Renderer9.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/renderer9_utils.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d9/formatutils9.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><ins>+// TODO: AddRef the incoming surface to take ownership instead of expecting that its ref is being given.
</ins><span class="cx"> RenderTarget9::RenderTarget9(Renderer *renderer, IDirect3DSurface9 *surface)
</span><span class="cx"> {
</span><span class="cx">     mRenderer = Renderer9::makeRenderer9(renderer);
</span><span class="lines">@@ -29,20 +31,21 @@
</span><span class="cx"> 
</span><span class="cx">         mWidth = description.Width;
</span><span class="cx">         mHeight = description.Height;
</span><del>-        
-        mInternalFormat = d3d9_gl::GetEquivalentFormat(description.Format);
-        mActualFormat = d3d9_gl::GetEquivalentFormat(description.Format);
-        mSamples = d3d9_gl::GetSamplesFromMultisampleType(description.MultiSampleType);
</del><ins>+        mDepth = 1;
+
+        mInternalFormat = d3d9_gl::GetInternalFormat(description.Format);
+        mActualFormat = d3d9_gl::GetInternalFormat(description.Format);
+        mSamples = d3d9_gl::GetSamplesCount(description.MultiSampleType);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget9::RenderTarget9(Renderer *renderer, GLsizei width, GLsizei height, GLenum format, GLsizei samples)
</del><ins>+RenderTarget9::RenderTarget9(Renderer *renderer, GLsizei width, GLsizei height, GLenum internalFormat, GLsizei samples)
</ins><span class="cx"> {
</span><span class="cx">     mRenderer = Renderer9::makeRenderer9(renderer);
</span><span class="cx">     mRenderTarget = NULL;
</span><span class="cx"> 
</span><del>-    D3DFORMAT requestedFormat = gl_d3d9::ConvertRenderbufferFormat(format);
-    int supportedSamples = mRenderer-&gt;getNearestSupportedSamples(requestedFormat, samples);
</del><ins>+    D3DFORMAT renderFormat = gl_d3d9::GetRenderFormat(internalFormat, mRenderer);
+    int supportedSamples = mRenderer-&gt;getNearestSupportedSamples(renderFormat, samples);
</ins><span class="cx"> 
</span><span class="cx">     if (supportedSamples == -1)
</span><span class="cx">     {
</span><span class="lines">@@ -52,20 +55,29 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     HRESULT result = D3DERR_INVALIDCALL;
</span><del>-    
</del><ins>+
+    GLuint clientVersion = mRenderer-&gt;getCurrentClientVersion();
+
</ins><span class="cx">     if (width &gt; 0 &amp;&amp; height &gt; 0)
</span><span class="cx">     {
</span><del>-        if (requestedFormat == D3DFMT_D24S8)
</del><ins>+        IDirect3DDevice9 *device = mRenderer-&gt;getDevice();
+
+        bool requiresInitialization = false;
+
+        if (gl::GetDepthBits(internalFormat, clientVersion) &gt; 0 ||
+            gl::GetStencilBits(internalFormat, clientVersion) &gt; 0)
</ins><span class="cx">         {
</span><del>-            result = mRenderer-&gt;getDevice()-&gt;CreateDepthStencilSurface(width, height, requestedFormat,
-                                                                       gl_d3d9::GetMultisampleTypeFromSamples(supportedSamples),
-                                                                       0, FALSE, &amp;mRenderTarget, NULL);
</del><ins>+            result = device-&gt;CreateDepthStencilSurface(width, height, renderFormat,
+                                                       gl_d3d9::GetMultisampleType(supportedSamples),
+                                                       0, FALSE, &amp;mRenderTarget, NULL);
</ins><span class="cx">         }
</span><span class="cx">         else
</span><span class="cx">         {
</span><del>-            result = mRenderer-&gt;getDevice()-&gt;CreateRenderTarget(width, height, requestedFormat, 
-                                                                gl_d3d9::GetMultisampleTypeFromSamples(supportedSamples),
-                                                                0, FALSE, &amp;mRenderTarget, NULL);
</del><ins>+            requiresInitialization = gl_d3d9::RequiresTextureDataInitialization(internalFormat);
+
+            result = device-&gt;CreateRenderTarget(width, height, renderFormat,
+                                                gl_d3d9::GetMultisampleType(supportedSamples),
+                                                0, FALSE, &amp;mRenderTarget, NULL);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
</span><span class="lines">@@ -76,21 +88,31 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         ASSERT(SUCCEEDED(result));
</span><ins>+
+        if (requiresInitialization)
+        {
+            // This format requires that the data be initialized before the render target can be used
+            // Unfortunately this requires a Get call on the d3d device but it is far better than having
+            // to mark the render target as lockable and copy data to the gpu.
+            IDirect3DSurface9 *prevRenderTarget = NULL;
+            device-&gt;GetRenderTarget(0, &amp;prevRenderTarget);
+            device-&gt;SetRenderTarget(0, mRenderTarget);
+            device-&gt;Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 255), 0.0f, 0);
+            device-&gt;SetRenderTarget(0, prevRenderTarget);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     mWidth = width;
</span><span class="cx">     mHeight = height;
</span><del>-    mInternalFormat = format;
</del><ins>+    mDepth = 1;
+    mInternalFormat = internalFormat;
</ins><span class="cx">     mSamples = supportedSamples;
</span><del>-    mActualFormat = d3d9_gl::GetEquivalentFormat(requestedFormat);
</del><ins>+    mActualFormat = d3d9_gl::GetInternalFormat(renderFormat);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderTarget9::~RenderTarget9()
</span><span class="cx"> {
</span><del>-    if (mRenderTarget)
-    {
-        mRenderTarget-&gt;Release();
-    }
</del><ins>+    SafeRelease(mRenderTarget);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderTarget9 *RenderTarget9::makeRenderTarget9(RenderTarget *target)
</span><span class="lines">@@ -99,9 +121,15 @@
</span><span class="cx">     return static_cast&lt;rx::RenderTarget9*&gt;(target);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RenderTarget9::invalidate(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+    // Currently a no-op
+}
+
</ins><span class="cx"> IDirect3DSurface9 *RenderTarget9::getSurface()
</span><span class="cx"> {
</span><span class="cx">     // Caller is responsible for releasing the returned surface reference.
</span><ins>+    // TODO: remove the AddRef to match RenderTarget11
</ins><span class="cx">     if (mRenderTarget)
</span><span class="cx">     {
</span><span class="cx">         mRenderTarget-&gt;AddRef();
</span><span class="lines">@@ -110,4 +138,4 @@
</span><span class="cx">     return mRenderTarget;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9RenderTarget9h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/RenderTarget9.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/RenderTarget9.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/RenderTarget9.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -21,10 +21,13 @@
</span><span class="cx"> {
</span><span class="cx">   public:
</span><span class="cx">     RenderTarget9(Renderer *renderer, IDirect3DSurface9 *surface);
</span><del>-    RenderTarget9(Renderer *renderer, GLsizei width, GLsizei height, GLenum format, GLsizei samples);
</del><ins>+    RenderTarget9(Renderer *renderer, GLsizei width, GLsizei height, GLenum internalFormat, GLsizei samples);
</ins><span class="cx">     virtual ~RenderTarget9();
</span><span class="cx"> 
</span><span class="cx">     static RenderTarget9 *makeRenderTarget9(RenderTarget *renderTarget);
</span><ins>+
+    virtual void invalidate(GLint x, GLint y, GLsizei width, GLsizei height);
+
</ins><span class="cx">     IDirect3DSurface9 *getSurface();
</span><span class="cx"> 
</span><span class="cx">   private:
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Renderer9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Renderer9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Renderer9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Renderer9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,12 +1,14 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="cx"> 
</span><span class="cx"> // Renderer9.cpp: Implements a back-end specific class for the D3D9 renderer.
</span><span class="cx"> 
</span><ins>+#include &quot;common/utilities.h&quot;
+
</ins><span class="cx"> #include &quot;libGLESv2/main.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Buffer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/Texture.h&quot;
</span><span class="lines">@@ -16,17 +18,19 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/IndexDataManager.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/Renderer9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/renderer9_utils.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d9/formatutils9.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/ShaderExecutable9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/SwapChain9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/TextureStorage9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/Image9.h&quot;
</span><del>-#include &quot;libGLESv2/renderer/d3d9/Blit.h&quot;
</del><ins>+#include &quot;libGLESv2/renderer/d3d9/Blit9.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/RenderTarget9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/VertexBuffer9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/IndexBuffer9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/BufferStorage9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/Query9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/Fence9.h&quot;
</span><ins>+#include &quot;libGLESv2/angletypes.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;libEGL/Display.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -43,6 +47,13 @@
</span><span class="cx"> #define ANGLE_ENABLE_D3D9EX 1
</span><span class="cx"> #endif // !defined(ANGLE_ENABLE_D3D9EX)
</span><span class="cx"> 
</span><ins>+#if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL)
+#define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL3
+#endif
+
+const D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I','N','T','Z')));
+const D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N','U','L','L')));
+
</ins><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> static const D3DFORMAT RenderTargetFormats[] =
</span><span class="lines">@@ -117,6 +128,9 @@
</span><span class="cx">         mNullColorbufferCache[i].height = 0;
</span><span class="cx">         mNullColorbufferCache[i].buffer = NULL;
</span><span class="cx">     }
</span><ins>+
+    mAppliedVertexShader = NULL;
+    mAppliedPixelShader = NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Renderer9::~Renderer9()
</span><span class="lines">@@ -142,22 +156,15 @@
</span><span class="cx">     SafeRelease(mD3d9);
</span><span class="cx">     SafeRelease(mD3d9Ex);
</span><span class="cx"> 
</span><ins>+    mCompiler.release();
+
</ins><span class="cx">     if (mDeviceWindow)
</span><span class="cx">     {
</span><span class="cx">         DestroyWindow(mDeviceWindow);
</span><span class="cx">         mDeviceWindow = NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (mD3d9Module)
-    {
-        mD3d9Module = NULL;
-    }
-
-    while (!mMultiSampleSupport.empty())
-    {
-        delete [] mMultiSampleSupport.begin()-&gt;second;
-        mMultiSampleSupport.erase(mMultiSampleSupport.begin());
-    }
</del><ins>+    mD3d9Module = NULL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Renderer9 *Renderer9::makeRenderer9(Renderer *renderer)
</span><span class="lines">@@ -168,7 +175,7 @@
</span><span class="cx"> 
</span><span class="cx"> EGLint Renderer9::initialize()
</span><span class="cx"> {
</span><del>-    if (!initializeCompiler())
</del><ins>+    if (!mCompiler.initialize())
</ins><span class="cx">     {
</span><span class="cx">         return EGL_NOT_INITIALIZED;
</span><span class="cx">     }
</span><span class="lines">@@ -200,7 +207,7 @@
</span><span class="cx">     {
</span><span class="cx">         TRACE_EVENT0(&quot;gpu&quot;, &quot;D3d9Ex_QueryInterface&quot;);
</span><span class="cx">         ASSERT(mD3d9Ex);
</span><del>-        mD3d9Ex-&gt;QueryInterface(IID_IDirect3D9, reinterpret_cast&lt;void**&gt;(&amp;mD3d9));
</del><ins>+        mD3d9Ex-&gt;QueryInterface(__uuidof(IDirect3D9), reinterpret_cast&lt;void**&gt;(&amp;mD3d9));
</ins><span class="cx">         ASSERT(mD3d9);
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="lines">@@ -251,7 +258,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // When DirectX9 is running with an older DirectX8 driver, a StretchRect from a regular texture to a render target texture is not supported.
</span><del>-    // This is required by Texture2D::convertToRenderTarget.
</del><ins>+    // This is required by Texture2D::ensureRenderTarget.
</ins><span class="cx">     if ((mDeviceCaps.DevCaps2 &amp; D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES) == 0)
</span><span class="cx">     {
</span><span class="cx">         ERR(&quot;Renderer does not support stretctrect from textures!\n&quot;);
</span><span class="lines">@@ -301,48 +308,17 @@
</span><span class="cx">         mMaxSwapInterval = std::max(mMaxSwapInterval, 4);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    int max = 0;
</del><ins>+    mMaxSupportedSamples = 0;
+
+    const d3d9::D3DFormatSet &amp;d3d9Formats = d3d9::GetAllUsedD3DFormats();
+    for (d3d9::D3DFormatSet::const_iterator i = d3d9Formats.begin(); i != d3d9Formats.end(); ++i)
</ins><span class="cx">     {
</span><span class="cx">         TRACE_EVENT0(&quot;gpu&quot;, &quot;getMultiSampleSupport&quot;);
</span><del>-        for (unsigned int i = 0; i &lt; ArraySize(RenderTargetFormats); ++i)
-        {
-            bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1];
-            getMultiSampleSupport(RenderTargetFormats[i], multisampleArray);
-            mMultiSampleSupport[RenderTargetFormats[i]] = multisampleArray;
-
-            for (int j = D3DMULTISAMPLE_16_SAMPLES; j &gt;= 0; --j)
-            {
-                if (multisampleArray[j] &amp;&amp; j != D3DMULTISAMPLE_NONMASKABLE &amp;&amp; j &gt; max)
-                {
-                    max = j;
-                }
-            }
-        }
</del><ins>+        MultisampleSupportInfo support = getMultiSampleSupport(*i);
+        mMultiSampleSupport[*i] = support;
+        mMaxSupportedSamples = std::max(mMaxSupportedSamples, support.maxSupportedSamples);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    {
-        TRACE_EVENT0(&quot;gpu&quot;, &quot;getMultiSampleSupport2&quot;);
-        for (unsigned int i = 0; i &lt; ArraySize(DepthStencilFormats); ++i)
-        {
-            if (DepthStencilFormats[i] == D3DFMT_UNKNOWN)
-                continue;
-
-            bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1];
-            getMultiSampleSupport(DepthStencilFormats[i], multisampleArray);
-            mMultiSampleSupport[DepthStencilFormats[i]] = multisampleArray;
-
-            for (int j = D3DMULTISAMPLE_16_SAMPLES; j &gt;= 0; --j)
-            {
-                if (multisampleArray[j] &amp;&amp; j != D3DMULTISAMPLE_NONMASKABLE &amp;&amp; j &gt; max)
-                {
-                    max = j;
-                }
-            }
-        }
-    }
-
-    mMaxSupportedSamples = max;
-
</del><span class="cx">     static const TCHAR windowName[] = TEXT(&quot;AngleHiddenWindow&quot;);
</span><span class="cx">     static const TCHAR className[] = TEXT(&quot;STATIC&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -378,7 +354,7 @@
</span><span class="cx">     if (mD3d9Ex)
</span><span class="cx">     {
</span><span class="cx">         TRACE_EVENT0(&quot;gpu&quot;, &quot;mDevice_QueryInterface&quot;);
</span><del>-        result = mDevice-&gt;QueryInterface(IID_IDirect3DDevice9Ex, (void**) &amp;mDeviceEx);
</del><ins>+        result = mDevice-&gt;QueryInterface(__uuidof(IDirect3DDevice9Ex), (void**)&amp;mDeviceEx);
</ins><span class="cx">         ASSERT(SUCCEEDED(result));
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -394,7 +370,7 @@
</span><span class="cx">         TRACE_EVENT0(&quot;gpu&quot;, &quot;device_CreateQuery&quot;);
</span><span class="cx">         if (SUCCEEDED(mDevice-&gt;CreateQuery(D3DQUERYTYPE_OCCLUSION, &amp;occlusionQuery)) &amp;&amp; occlusionQuery)
</span><span class="cx">         {
</span><del>-            occlusionQuery-&gt;Release();
</del><ins>+            SafeRelease(occlusionQuery);
</ins><span class="cx">             mOcclusionQuerySupport = true;
</span><span class="cx">         }
</span><span class="cx">         else
</span><span class="lines">@@ -409,7 +385,7 @@
</span><span class="cx">         TRACE_EVENT0(&quot;gpu&quot;, &quot;device_CreateQuery2&quot;);
</span><span class="cx">         if (SUCCEEDED(mDevice-&gt;CreateQuery(D3DQUERYTYPE_EVENT, &amp;eventQuery)) &amp;&amp; eventQuery)
</span><span class="cx">         {
</span><del>-            eventQuery-&gt;Release();
</del><ins>+            SafeRelease(eventQuery);
</ins><span class="cx">             mEventQuerySupport = true;
</span><span class="cx">         }
</span><span class="cx">         else
</span><span class="lines">@@ -428,6 +404,10 @@
</span><span class="cx">                             SUCCEEDED(mD3d9-&gt;CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format,
</span><span class="cx">                                                                D3DUSAGE_QUERY_VERTEXTEXTURE, D3DRTYPE_TEXTURE, D3DFMT_R16F));
</span><span class="cx"> 
</span><ins>+    // Check RGB565 texture support
+    mRGB565TextureSupport = SUCCEEDED(mD3d9-&gt;CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format,
+                                                               D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, D3DFMT_R5G6B5));
+
</ins><span class="cx">     // Check depth texture support
</span><span class="cx">     // we use INTZ for depth textures in Direct3D9
</span><span class="cx">     // we also want NULL texture support to ensure the we can make depth-only FBOs
</span><span class="lines">@@ -483,6 +463,25 @@
</span><span class="cx">         mFloat16TextureSupport = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    D3DFORMAT rgTextureFormats[] =
+    {
+        D3DFMT_R16F,
+        D3DFMT_G16R16F,
+        D3DFMT_R32F,
+        D3DFMT_G32R32F,
+    };
+
+    mRGTextureSupport = true;
+    for (unsigned int i = 0; i &lt; ArraySize(rgTextureFormats); i++)
+    {
+        D3DFORMAT fmt = rgTextureFormats[i];
+        mRGTextureSupport = SUCCEEDED(mD3d9-&gt;CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, fmt)) &amp;&amp;
+                            SUCCEEDED(mD3d9-&gt;CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, fmt)) &amp;&amp;
+                            SUCCEEDED(mD3d9-&gt;CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, D3DRTYPE_CUBETEXTURE, fmt)) &amp;&amp;
+                            SUCCEEDED(mD3d9-&gt;CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_CUBETEXTURE, fmt));
+    }
+
+
</ins><span class="cx">     // Check DXT texture support
</span><span class="cx">     mDXT1TextureSupport = SUCCEEDED(mD3d9-&gt;CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1));
</span><span class="cx">     mDXT3TextureSupport = SUCCEEDED(mD3d9-&gt;CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT3));
</span><span class="lines">@@ -494,6 +493,8 @@
</span><span class="cx"> 
</span><span class="cx">     initializeDevice();
</span><span class="cx"> 
</span><ins>+    d3d9::InitializeVertexTranslations(this);
+
</ins><span class="cx">     return EGL_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -520,7 +521,7 @@
</span><span class="cx">     mSceneStarted = false;
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!mBlit &amp;&amp; !mVertexDataManager &amp;&amp; !mIndexDataManager);
</span><del>-    mBlit = new Blit(this);
</del><ins>+    mBlit = new Blit9(this);
</ins><span class="cx">     mVertexDataManager = new rx::VertexDataManager(this);
</span><span class="cx">     mIndexDataManager = new rx::IndexDataManager(this);
</span><span class="cx"> }
</span><span class="lines">@@ -585,10 +586,11 @@
</span><span class="cx">                     if (SUCCEEDED(result))
</span><span class="cx">                     {
</span><span class="cx">                         ConfigDesc newConfig;
</span><del>-                        newConfig.renderTargetFormat = d3d9_gl::ConvertBackBufferFormat(renderTargetFormat);
-                        newConfig.depthStencilFormat = d3d9_gl::ConvertDepthStencilFormat(depthStencilFormat);
</del><ins>+                        newConfig.renderTargetFormat = d3d9_gl::GetInternalFormat(renderTargetFormat);
+                        newConfig.depthStencilFormat = d3d9_gl::GetInternalFormat(depthStencilFormat);
</ins><span class="cx">                         newConfig.multiSample = 0; // FIXME: enumerate multi-sampling
</span><span class="cx">                         newConfig.fastConfig = (currentDisplayMode.Format == renderTargetFormat);
</span><ins>+                        newConfig.es3Capable = false;
</ins><span class="cx"> 
</span><span class="cx">                         (*configDescList)[numConfigs++] = newConfig;
</span><span class="cx">                     }
</span><span class="lines">@@ -696,7 +698,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (mEventQueryPool.size() &gt; 1000)
</span><span class="cx">     {
</span><del>-        query-&gt;Release();
</del><ins>+        SafeRelease(query);
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="lines">@@ -751,6 +753,26 @@
</span><span class="cx">     return new Fence9(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer9::supportsFastCopyBufferToTexture(GLenum internalFormat) const
+{
+    // Pixel buffer objects are not supported in D3D9, since D3D9 is ES2-only and PBOs are ES3.
+    return false;
+}
+
+bool Renderer9::fastCopyBufferToTexture(const gl::PixelUnpackState &amp;unpack, unsigned int offset, RenderTarget *destRenderTarget,
+                                        GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &amp;destArea)
+{
+    // Pixel buffer objects are not supported in D3D9, since D3D9 is ES2-only and PBOs are ES3.
+    UNREACHABLE();
+    return false;
+}
+
+void Renderer9::generateSwizzle(gl::Texture *texture)
+{
+    // Swizzled textures are not available in ES2 or D3D9
+    UNREACHABLE();
+}
+
</ins><span class="cx"> void Renderer9::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &amp;samplerState)
</span><span class="cx"> {
</span><span class="cx">     bool *forceSetSamplers = (type == gl::SAMPLER_PIXEL) ? mForceSetPixelSamplerStates : mForceSetVertexSamplerStates;
</span><span class="lines">@@ -769,7 +791,7 @@
</span><span class="cx">         gl_d3d9::ConvertMinFilter(samplerState.minFilter, &amp;d3dMinFilter, &amp;d3dMipFilter, samplerState.maxAnisotropy);
</span><span class="cx">         mDevice-&gt;SetSamplerState(d3dSampler, D3DSAMP_MINFILTER, d3dMinFilter);
</span><span class="cx">         mDevice-&gt;SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter);
</span><del>-        mDevice-&gt;SetSamplerState(d3dSampler, D3DSAMP_MAXMIPLEVEL, samplerState.lodOffset);
</del><ins>+        mDevice-&gt;SetSamplerState(d3dSampler, D3DSAMP_MAXMIPLEVEL, samplerState.baseLevel);
</ins><span class="cx">         if (mSupportsTextureFilterAnisotropy)
</span><span class="cx">         {
</span><span class="cx">             mDevice-&gt;SetSamplerState(d3dSampler, D3DSAMP_MAXANISOTROPY, (DWORD)samplerState.maxAnisotropy);
</span><span class="lines">@@ -814,6 +836,12 @@
</span><span class="cx">     appliedSerials[index] = serial;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer9::setUniformBuffers(const gl::Buffer* /*vertexUniformBuffers*/[], const gl::Buffer* /*fragmentUniformBuffers*/[])
+{
+    // No effect in ES2/D3D9
+    return true;
+}
+
</ins><span class="cx"> void Renderer9::setRasterizerState(const gl::RasterizerState &amp;rasterState)
</span><span class="cx"> {
</span><span class="cx">     bool rasterStateChanged = mForceSetRasterState || memcmp(&amp;rasterState, &amp;mCurRasterState, sizeof(gl::RasterizerState)) != 0;
</span><span class="lines">@@ -852,10 +880,11 @@
</span><span class="cx">     mForceSetRasterState = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::Color &amp;blendColor, unsigned int sampleMask)
</del><ins>+void Renderer9::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::ColorF &amp;blendColor,
+                              unsigned int sampleMask)
</ins><span class="cx"> {
</span><span class="cx">     bool blendStateChanged = mForceSetBlendState || memcmp(&amp;blendState, &amp;mCurBlendState, sizeof(gl::BlendState)) != 0;
</span><del>-    bool blendColorChanged = mForceSetBlendState || memcmp(&amp;blendColor, &amp;mCurBlendColor, sizeof(gl::Color)) != 0;
</del><ins>+    bool blendColorChanged = mForceSetBlendState || memcmp(&amp;blendColor, &amp;mCurBlendColor, sizeof(gl::ColorF)) != 0;
</ins><span class="cx">     bool sampleMaskChanged = mForceSetBlendState || sampleMask != mCurSampleMask;
</span><span class="cx"> 
</span><span class="cx">     if (blendStateChanged || blendColorChanged)
</span><span class="lines">@@ -906,6 +935,10 @@
</span><span class="cx">             FIXME(&quot;Sample alpha to coverage is unimplemented.&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        gl::Renderbuffer *renderBuffer = framebuffer-&gt;getFirstColorbuffer();
+        GLenum internalFormat = renderBuffer ? renderBuffer-&gt;getInternalFormat() : GL_NONE;
+        GLuint clientVersion = getCurrentClientVersion();
+
</ins><span class="cx">         // Set the color mask
</span><span class="cx">         bool zeroColorMaskAllowed = getAdapterVendor() != VENDOR_ID_AMD;
</span><span class="cx">         // Apparently some ATI cards have a bug where a draw with a zero color
</span><span class="lines">@@ -914,8 +947,10 @@
</span><span class="cx">         // drawing is done.
</span><span class="cx">         // http://code.google.com/p/angleproject/issues/detail?id=169
</span><span class="cx"> 
</span><del>-        DWORD colorMask = gl_d3d9::ConvertColorMask(blendState.colorMaskRed, blendState.colorMaskGreen,
-                                                    blendState.colorMaskBlue, blendState.colorMaskAlpha);
</del><ins>+        DWORD colorMask = gl_d3d9::ConvertColorMask(gl::GetRedBits(internalFormat, clientVersion) &gt; 0 &amp;&amp; blendState.colorMaskRed,
+                                                    gl::GetGreenBits(internalFormat, clientVersion) &gt; 0 &amp;&amp; blendState.colorMaskGreen,
+                                                    gl::GetBlueBits(internalFormat, clientVersion) &gt; 0 &amp;&amp; blendState.colorMaskBlue,
+                                                    gl::GetAlphaBits(internalFormat, clientVersion) &gt; 0 &amp;&amp; blendState.colorMaskAlpha);
</ins><span class="cx">         if (colorMask == 0 &amp;&amp; !zeroColorMaskAllowed)
</span><span class="cx">         {
</span><span class="cx">             // Enable green channel, but set blending so nothing will be drawn.
</span><span class="lines">@@ -1278,7 +1313,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         mDevice-&gt;SetRenderTarget(0, renderTargetSurface);
</span><del>-        renderTargetSurface-&gt;Release();
</del><ins>+        SafeRelease(renderTargetSurface);
</ins><span class="cx"> 
</span><span class="cx">         mAppliedRenderTargetSerial = renderTargetSerial;
</span><span class="cx">         renderTargetChanged = true;
</span><span class="lines">@@ -1335,7 +1370,7 @@
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             mDevice-&gt;SetDepthStencilSurface(depthStencilSurface);
</span><del>-            depthStencilSurface-&gt;Release();
</del><ins>+            SafeRelease(depthStencilSurface);
</ins><span class="cx"> 
</span><span class="cx">             depthSize = depthStencil-&gt;getDepthSize();
</span><span class="cx">             stencilSize = depthStencil-&gt;getStencilSize();
</span><span class="lines">@@ -1366,6 +1401,7 @@
</span><span class="cx">     {
</span><span class="cx">         mForceSetScissor = true;
</span><span class="cx">         mForceSetViewport = true;
</span><ins>+        mForceSetBlendState = true;
</ins><span class="cx"> 
</span><span class="cx">         mRenderTargetDesc.width = renderbufferObject-&gt;getWidth();
</span><span class="cx">         mRenderTargetDesc.height = renderbufferObject-&gt;getHeight();
</span><span class="lines">@@ -1376,15 +1412,16 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLenum Renderer9::applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances)
</del><ins>+GLenum Renderer9::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
+                                    GLint first, GLsizei count, GLsizei instances)
</ins><span class="cx"> {
</span><span class="cx">     TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS];
</span><del>-    GLenum err = mVertexDataManager-&gt;prepareVertexData(vertexAttributes, programBinary, first, count, attributes, instances);
</del><ins>+    GLenum err = mVertexDataManager-&gt;prepareVertexData(vertexAttributes, currentValues, programBinary, first, count, attributes, instances);
</ins><span class="cx">     if (err != GL_NO_ERROR)
</span><span class="cx">     {
</span><span class="cx">         return err;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, programBinary, instances, &amp;mRepeatDraw);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1410,10 +1447,17 @@
</span><span class="cx">     return err;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::drawArrays(GLenum mode, GLsizei count, GLsizei instances)
</del><ins>+void Renderer9::applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[])
</ins><span class="cx"> {
</span><ins>+    UNREACHABLE();
+}
+
+void Renderer9::drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive)
+{
+    ASSERT(!transformFeedbackActive);
+
</ins><span class="cx">     startScene();
</span><del>-        
</del><ins>+
</ins><span class="cx">     if (mode == GL_LINE_LOOP)
</span><span class="cx">     {
</span><span class="cx">         drawLineLoop(count, GL_NONE, NULL, 0, NULL);
</span><span class="lines">@@ -1448,7 +1492,8 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei /*instances*/)
</del><ins>+void Renderer9::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
+                             gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei /*instances*/)
</ins><span class="cx"> {
</span><span class="cx">     startScene();
</span><span class="cx"> 
</span><span class="lines">@@ -1498,15 +1543,15 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        // Checked by Renderer9::applyPrimitiveType
+        ASSERT(count &gt;= 0);
+
</ins><span class="cx">         if (static_cast&lt;unsigned int&gt;(count) + 1 &gt; (std::numeric_limits&lt;unsigned int&gt;::max() / sizeof(unsigned int)))
</span><span class="cx">         {
</span><span class="cx">             ERR(&quot;Could not create a 32-bit looping index buffer for GL_LINE_LOOP, too many indices required.&quot;);
</span><span class="cx">             return gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        // Checked by Renderer9::applyPrimitiveType
-        ASSERT(count &gt;= 0);
-
</del><span class="cx">         const unsigned int spaceNeeded = (static_cast&lt;unsigned int&gt;(count) + 1) * sizeof(unsigned int);
</span><span class="cx">         if (!mLineLoopIB-&gt;reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT))
</span><span class="cx">         {
</span><span class="lines">@@ -1688,34 +1733,46 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::applyShaders(gl::ProgramBinary *programBinary)
</del><ins>+void Renderer9::applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[])
</ins><span class="cx"> {
</span><del>-    unsigned int programBinarySerial = programBinary-&gt;getSerial();
-    if (programBinarySerial != mAppliedProgramBinarySerial)
-    {
-        ShaderExecutable *vertexExe = programBinary-&gt;getVertexExecutable();
-        ShaderExecutable *pixelExe = programBinary-&gt;getPixelExecutable();
</del><ins>+    ASSERT(!transformFeedbackActive);
+    ASSERT(!rasterizerDiscard);
</ins><span class="cx"> 
</span><del>-        IDirect3DVertexShader9 *vertexShader = NULL;
-        if (vertexExe) vertexShader = ShaderExecutable9::makeShaderExecutable9(vertexExe)-&gt;getVertexShader();
</del><ins>+    ShaderExecutable *vertexExe = programBinary-&gt;getVertexExecutableForInputLayout(inputLayout);
+    ShaderExecutable *pixelExe = programBinary-&gt;getPixelExecutable();
</ins><span class="cx"> 
</span><del>-        IDirect3DPixelShader9 *pixelShader = NULL;
-        if (pixelExe) pixelShader = ShaderExecutable9::makeShaderExecutable9(pixelExe)-&gt;getPixelShader();
</del><ins>+    IDirect3DVertexShader9 *vertexShader = (vertexExe ? ShaderExecutable9::makeShaderExecutable9(vertexExe)-&gt;getVertexShader() : NULL);
+    IDirect3DPixelShader9 *pixelShader = (pixelExe ? ShaderExecutable9::makeShaderExecutable9(pixelExe)-&gt;getPixelShader() : NULL);
</ins><span class="cx"> 
</span><del>-        mDevice-&gt;SetPixelShader(pixelShader);
</del><ins>+    bool dirtyUniforms = false;
+
+    if (vertexShader != mAppliedVertexShader)
+    {
</ins><span class="cx">         mDevice-&gt;SetVertexShader(vertexShader);
</span><del>-        programBinary-&gt;dirtyAllUniforms();
-        mDxUniformsDirty = true;
</del><ins>+        mAppliedVertexShader = vertexShader;
+        dirtyUniforms = true;
+    }
</ins><span class="cx"> 
</span><del>-        mAppliedProgramBinarySerial = programBinarySerial;
</del><ins>+    if (pixelShader != mAppliedPixelShader)
+    {
+        mDevice-&gt;SetPixelShader(pixelShader);
+        mAppliedPixelShader = pixelShader;
+        dirtyUniforms = true;
</ins><span class="cx">     }
</span><ins>+
+    if (dirtyUniforms)
+    {
+        programBinary-&gt;dirtyAllUniforms();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray *uniformArray)
</del><ins>+void Renderer9::applyUniforms(const gl::ProgramBinary &amp;programBinary)
</ins><span class="cx"> {
</span><del>-    for (std::vector&lt;gl::Uniform*&gt;::const_iterator ub = uniformArray-&gt;begin(), ue = uniformArray-&gt;end(); ub != ue; ++ub)
</del><ins>+    const std::vector&lt;gl::LinkedUniform*&gt; &amp;uniformArray = programBinary.getUniforms();
+
+    for (size_t uniformIndex = 0; uniformIndex &lt; uniformArray.size(); uniformIndex++)
</ins><span class="cx">     {
</span><del>-        gl::Uniform *targetUniform = *ub;
</del><ins>+        gl::LinkedUniform *targetUniform = uniformArray[uniformIndex];
</ins><span class="cx"> 
</span><span class="cx">         if (targetUniform-&gt;dirty)
</span><span class="cx">         {
</span><span class="lines">@@ -1751,8 +1808,6 @@
</span><span class="cx">               default:
</span><span class="cx">                 UNREACHABLE();
</span><span class="cx">             }
</span><del>-
-            targetUniform-&gt;dirty = false;
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1765,20 +1820,20 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v)
</del><ins>+void Renderer9::applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v)
</ins><span class="cx"> {
</span><del>-    if (targetUniform-&gt;psRegisterIndex &gt;= 0)
</del><ins>+    if (targetUniform-&gt;isReferencedByFragmentShader())
</ins><span class="cx">     {
</span><span class="cx">         mDevice-&gt;SetPixelShaderConstantF(targetUniform-&gt;psRegisterIndex, v, targetUniform-&gt;registerCount);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (targetUniform-&gt;vsRegisterIndex &gt;= 0)
</del><ins>+    if (targetUniform-&gt;isReferencedByVertexShader())
</ins><span class="cx">     {
</span><span class="cx">         mDevice-&gt;SetVertexShaderConstantF(targetUniform-&gt;vsRegisterIndex, v, targetUniform-&gt;registerCount);
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::applyUniformniv(gl::Uniform *targetUniform, const GLint *v)
</del><ins>+void Renderer9::applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(targetUniform-&gt;registerCount &lt;= MAX_VERTEX_CONSTANT_VECTORS_D3D9);
</span><span class="cx">     GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4];
</span><span class="lines">@@ -1794,7 +1849,7 @@
</span><span class="cx">     applyUniformnfv(targetUniform, (GLfloat*)vector);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::applyUniformnbv(gl::Uniform *targetUniform, const GLint *v)
</del><ins>+void Renderer9::applyUniformnbv(gl::LinkedUniform *targetUniform, const GLint *v)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(targetUniform-&gt;registerCount &lt;= MAX_VERTEX_CONSTANT_VECTORS_D3D9);
</span><span class="cx">     GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4];
</span><span class="lines">@@ -1812,28 +1867,71 @@
</span><span class="cx"> 
</span><span class="cx"> void Renderer9::clear(const gl::ClearParameters &amp;clearParams, gl::Framebuffer *frameBuffer)
</span><span class="cx"> {
</span><del>-    D3DCOLOR color = D3DCOLOR_ARGB(gl::unorm&lt;8&gt;(clearParams.colorClearValue.alpha),
-                                   gl::unorm&lt;8&gt;(clearParams.colorClearValue.red),
-                                   gl::unorm&lt;8&gt;(clearParams.colorClearValue.green),
-                                   gl::unorm&lt;8&gt;(clearParams.colorClearValue.blue));
</del><ins>+    if (clearParams.colorClearType != GL_FLOAT)
+    {
+        // Clearing buffers with non-float values is not supported by Renderer9 and ES 2.0
+        UNREACHABLE();
+        return;
+    }
+
+    bool clearColor = clearParams.clearColor[0];
+    for (unsigned int i = 0; i &lt; ArraySize(clearParams.clearColor); i++)
+    {
+        if (clearParams.clearColor[i] != clearColor)
+        {
+            // Clearing individual buffers other than buffer zero is not supported by Renderer9 and ES 2.0
+            UNREACHABLE();
+            return;
+        }
+    }
+
</ins><span class="cx">     float depth = gl::clamp01(clearParams.depthClearValue);
</span><del>-    int stencil = clearParams.stencilClearValue &amp; 0x000000FF;
</del><ins>+    DWORD stencil = clearParams.stencilClearValue &amp; 0x000000FF;
</ins><span class="cx"> 
</span><span class="cx">     unsigned int stencilUnmasked = 0x0;
</span><del>-    if ((clearParams.mask &amp; GL_STENCIL_BUFFER_BIT) &amp;&amp; frameBuffer-&gt;hasStencil())
</del><ins>+    if (clearParams.clearStencil &amp;&amp; frameBuffer-&gt;hasStencil())
</ins><span class="cx">     {
</span><del>-        unsigned int stencilSize = gl::GetStencilSize(frameBuffer-&gt;getStencilbuffer()-&gt;getActualFormat());
</del><ins>+        unsigned int stencilSize = gl::GetStencilBits(frameBuffer-&gt;getStencilbuffer()-&gt;getActualFormat(),
+                                                      getCurrentClientVersion());
</ins><span class="cx">         stencilUnmasked = (0x1 &lt;&lt; stencilSize) - 1;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool alphaUnmasked = (gl::GetAlphaSize(mRenderTargetDesc.format) == 0) || clearParams.colorMaskAlpha;
-
-    const bool needMaskedStencilClear = (clearParams.mask &amp; GL_STENCIL_BUFFER_BIT) &amp;&amp;
</del><ins>+    const bool needMaskedStencilClear = clearParams.clearStencil &amp;&amp;
</ins><span class="cx">                                         (clearParams.stencilWriteMask &amp; stencilUnmasked) != stencilUnmasked;
</span><del>-    const bool needMaskedColorClear = (clearParams.mask &amp; GL_COLOR_BUFFER_BIT) &amp;&amp;
-                                      !(clearParams.colorMaskRed &amp;&amp; clearParams.colorMaskGreen &amp;&amp;
-                                        clearParams.colorMaskBlue &amp;&amp; alphaUnmasked);
</del><span class="cx"> 
</span><ins>+    bool needMaskedColorClear = false;
+    D3DCOLOR color = D3DCOLOR_ARGB(255, 0, 0, 0);
+    if (clearColor)
+    {
+        gl::Renderbuffer *renderbuffer = frameBuffer-&gt;getFirstColorbuffer();
+        GLenum internalFormat = renderbuffer-&gt;getInternalFormat();
+        GLenum actualFormat = renderbuffer-&gt;getActualFormat();
+
+        GLuint clientVersion = getCurrentClientVersion();
+        GLuint internalRedBits = gl::GetRedBits(internalFormat, clientVersion);
+        GLuint internalGreenBits = gl::GetGreenBits(internalFormat, clientVersion);
+        GLuint internalBlueBits = gl::GetBlueBits(internalFormat, clientVersion);
+        GLuint internalAlphaBits = gl::GetAlphaBits(internalFormat, clientVersion);
+
+        GLuint actualRedBits = gl::GetRedBits(actualFormat, clientVersion);
+        GLuint actualGreenBits = gl::GetGreenBits(actualFormat, clientVersion);
+        GLuint actualBlueBits = gl::GetBlueBits(actualFormat, clientVersion);
+        GLuint actualAlphaBits = gl::GetAlphaBits(actualFormat, clientVersion);
+
+        color = D3DCOLOR_ARGB(gl::unorm&lt;8&gt;((internalAlphaBits == 0 &amp;&amp; actualAlphaBits &gt; 0) ? 1.0f : clearParams.colorFClearValue.alpha),
+                              gl::unorm&lt;8&gt;((internalRedBits   == 0 &amp;&amp; actualRedBits   &gt; 0) ? 0.0f : clearParams.colorFClearValue.red),
+                              gl::unorm&lt;8&gt;((internalGreenBits == 0 &amp;&amp; actualGreenBits &gt; 0) ? 0.0f : clearParams.colorFClearValue.green),
+                              gl::unorm&lt;8&gt;((internalBlueBits  == 0 &amp;&amp; actualBlueBits  &gt; 0) ? 0.0f : clearParams.colorFClearValue.blue));
+
+        if ((internalRedBits   &gt; 0 &amp;&amp; !clearParams.colorMaskRed) ||
+            (internalGreenBits &gt; 0 &amp;&amp; !clearParams.colorMaskGreen) ||
+            (internalBlueBits  &gt; 0 &amp;&amp; !clearParams.colorMaskBlue) ||
+            (internalAlphaBits &gt; 0 &amp;&amp; !clearParams.colorMaskAlpha))
+        {
+            needMaskedColorClear = true;
+        }
+    }
+
</ins><span class="cx">     if (needMaskedColorClear || needMaskedStencilClear)
</span><span class="cx">     {
</span><span class="cx">         // State which is altered in all paths from this point to the clear call is saved.
</span><span class="lines">@@ -1893,7 +1991,7 @@
</span><span class="cx">         mDevice-&gt;SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
</span><span class="cx">         mDevice-&gt;SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
</span><span class="cx"> 
</span><del>-        if (clearParams.mask &amp; GL_COLOR_BUFFER_BIT)
</del><ins>+        if (clearColor)
</ins><span class="cx">         {
</span><span class="cx">             mDevice-&gt;SetRenderState(D3DRS_COLORWRITEENABLE,
</span><span class="cx">                                     gl_d3d9::ConvertColorMask(clearParams.colorMaskRed,
</span><span class="lines">@@ -1906,7 +2004,7 @@
</span><span class="cx">             mDevice-&gt;SetRenderState(D3DRS_COLORWRITEENABLE, 0);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (stencilUnmasked != 0x0 &amp;&amp; (clearParams.mask &amp; GL_STENCIL_BUFFER_BIT))
</del><ins>+        if (stencilUnmasked != 0x0 &amp;&amp; clearParams.clearStencil)
</ins><span class="cx">         {
</span><span class="cx">             mDevice-&gt;SetRenderState(D3DRS_STENCILENABLE, TRUE);
</span><span class="cx">             mDevice-&gt;SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, FALSE);
</span><span class="lines">@@ -1962,7 +2060,7 @@
</span><span class="cx">         startScene();
</span><span class="cx">         mDevice-&gt;DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float[4]));
</span><span class="cx"> 
</span><del>-        if (clearParams.mask &amp; GL_DEPTH_BUFFER_BIT)
</del><ins>+        if (clearParams.clearDepth)
</ins><span class="cx">         {
</span><span class="cx">             mDevice-&gt;SetRenderState(D3DRS_ZENABLE, TRUE);
</span><span class="cx">             mDevice-&gt;SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
</span><span class="lines">@@ -1974,18 +2072,18 @@
</span><span class="cx">             mMaskedClearSavedState-&gt;Apply();
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else if (clearParams.mask)
</del><ins>+    else if (clearColor || clearParams.clearDepth || clearParams.clearStencil)
</ins><span class="cx">     {
</span><span class="cx">         DWORD dxClearFlags = 0;
</span><del>-        if (clearParams.mask &amp; GL_COLOR_BUFFER_BIT)
</del><ins>+        if (clearColor)
</ins><span class="cx">         {
</span><span class="cx">             dxClearFlags |= D3DCLEAR_TARGET;
</span><span class="cx">         }
</span><del>-        if (clearParams.mask &amp; GL_DEPTH_BUFFER_BIT)
</del><ins>+        if (clearParams.clearDepth)
</ins><span class="cx">         {
</span><span class="cx">             dxClearFlags |= D3DCLEAR_ZBUFFER;
</span><span class="cx">         }
</span><del>-        if (clearParams.mask &amp; GL_STENCIL_BUFFER_BIT)
</del><ins>+        if (clearParams.clearStencil)
</ins><span class="cx">         {
</span><span class="cx">             dxClearFlags |= D3DCLEAR_STENCIL;
</span><span class="cx">         }
</span><span class="lines">@@ -2020,7 +2118,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     mAppliedIBSerial = 0;
</span><del>-    mAppliedProgramBinarySerial = 0;
</del><ins>+    mAppliedVertexShader = NULL;
+    mAppliedPixelShader = NULL;
</ins><span class="cx">     mDxUniformsDirty = true;
</span><span class="cx"> 
</span><span class="cx">     mVertexDeclarationCache.markStateDirty();
</span><span class="lines">@@ -2028,11 +2127,11 @@
</span><span class="cx"> 
</span><span class="cx"> void Renderer9::releaseDeviceResources()
</span><span class="cx"> {
</span><del>-    while (!mEventQueryPool.empty())
</del><ins>+    for (size_t i = 0; i &lt; mEventQueryPool.size(); i++)
</ins><span class="cx">     {
</span><del>-        mEventQueryPool.back()-&gt;Release();
-        mEventQueryPool.pop_back();
</del><ins>+        SafeRelease(mEventQueryPool[i]);
</ins><span class="cx">     }
</span><ins>+    mEventQueryPool.clear();
</ins><span class="cx"> 
</span><span class="cx">     SafeRelease(mMaskedClearSavedState);
</span><span class="cx"> 
</span><span class="lines">@@ -2048,10 +2147,8 @@
</span><span class="cx">     {
</span><span class="cx">         SafeDelete(mNullColorbufferCache[i].buffer);
</span><span class="cx">     }
</span><del>-
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> void Renderer9::notifyDeviceLost()
</span><span class="cx"> {
</span><span class="cx">     mDeviceLost = true;
</span><span class="lines">@@ -2255,15 +2352,30 @@
</span><span class="cx">     return mAdapterIdentifier.DeviceIdentifier;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray)
</del><ins>+Renderer9::MultisampleSupportInfo Renderer9::getMultiSampleSupport(D3DFORMAT format)
</ins><span class="cx"> {
</span><del>-    for (int multiSampleIndex = 0; multiSampleIndex &lt;= D3DMULTISAMPLE_16_SAMPLES; multiSampleIndex++)
</del><ins>+    MultisampleSupportInfo support = { 0 };
+
+    for (unsigned int multiSampleIndex = 0; multiSampleIndex &lt; ArraySize(support.supportedSamples); multiSampleIndex++)
</ins><span class="cx">     {
</span><del>-        HRESULT result = mD3d9-&gt;CheckDeviceMultiSampleType(mAdapter, mDeviceType, format,
-                                                           TRUE, (D3DMULTISAMPLE_TYPE)multiSampleIndex, NULL);
</del><ins>+        HRESULT result = mD3d9-&gt;CheckDeviceMultiSampleType(mAdapter, mDeviceType, format, TRUE,
+                                                           (D3DMULTISAMPLE_TYPE)multiSampleIndex, NULL);
</ins><span class="cx"> 
</span><del>-        multiSampleArray[multiSampleIndex] = SUCCEEDED(result);
</del><ins>+        if (SUCCEEDED(result))
+        {
+             support.supportedSamples[multiSampleIndex] = true;
+             if (multiSampleIndex != D3DMULTISAMPLE_NONMASKABLE)
+             {
+                 support.maxSupportedSamples = std::max(support.maxSupportedSamples, multiSampleIndex);
+             }
+        }
+        else
+        {
+            support.supportedSamples[multiSampleIndex] = false;
+        }
</ins><span class="cx">     }
</span><ins>+
+    return support;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Renderer9::getBGRATextureSupport() const
</span><span class="lines">@@ -2272,17 +2384,17 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer9::getDXT1TextureSupport()
</del><ins>+bool Renderer9::getDXT1TextureSupport() const
</ins><span class="cx"> {
</span><span class="cx">     return mDXT1TextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer9::getDXT3TextureSupport()
</del><ins>+bool Renderer9::getDXT3TextureSupport() const
</ins><span class="cx"> {
</span><span class="cx">     return mDXT3TextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer9::getDXT5TextureSupport()
</del><ins>+bool Renderer9::getDXT5TextureSupport() const
</ins><span class="cx"> {
</span><span class="cx">     return mDXT5TextureSupport;
</span><span class="cx"> }
</span><span class="lines">@@ -2292,35 +2404,67 @@
</span><span class="cx">     return mDepthTextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer9::getFloat32TextureSupport(bool *filtering, bool *renderable)
</del><ins>+bool Renderer9::getFloat32TextureSupport() const
</ins><span class="cx"> {
</span><del>-    *filtering = mFloat32FilterSupport;
-    *renderable = mFloat32RenderSupport;
</del><span class="cx">     return mFloat32TextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer9::getFloat16TextureSupport(bool *filtering, bool *renderable)
</del><ins>+bool Renderer9::getFloat32TextureFilteringSupport() const
</ins><span class="cx"> {
</span><del>-    *filtering = mFloat16FilterSupport;
-    *renderable = mFloat16RenderSupport;
</del><ins>+    return mFloat32FilterSupport;
+}
+
+bool Renderer9::getFloat32TextureRenderingSupport() const
+{
+    return mFloat32RenderSupport;
+}
+
+bool Renderer9::getFloat16TextureSupport() const
+{
</ins><span class="cx">     return mFloat16TextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer9::getLuminanceTextureSupport()
</del><ins>+bool Renderer9::getFloat16TextureFilteringSupport() const
</ins><span class="cx"> {
</span><ins>+    return mFloat16FilterSupport;
+}
+
+bool Renderer9::getFloat16TextureRenderingSupport() const
+{
+    return mFloat16RenderSupport;
+}
+
+bool Renderer9::getRGB565TextureSupport() const
+{
+    return mRGB565TextureSupport;
+}
+
+bool Renderer9::getLuminanceTextureSupport() const
+{
</ins><span class="cx">     return mLuminanceTextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer9::getLuminanceAlphaTextureSupport()
</del><ins>+bool Renderer9::getLuminanceAlphaTextureSupport() const
</ins><span class="cx"> {
</span><span class="cx">     return mLuminanceAlphaTextureSupport;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer9::getRGTextureSupport() const
+{
+    return mRGTextureSupport;
+}
+
</ins><span class="cx"> bool Renderer9::getTextureFilterAnisotropySupport() const
</span><span class="cx"> {
</span><span class="cx">     return mSupportsTextureFilterAnisotropy;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer9::getPBOSupport() const
+{
+    // D3D9 cannot support PBOs
+    return false;
+}
+
</ins><span class="cx"> float Renderer9::getTextureMaxAnisotropy() const
</span><span class="cx"> {
</span><span class="cx">     if (mSupportsTextureFilterAnisotropy)
</span><span class="lines">@@ -2330,7 +2474,7 @@
</span><span class="cx">     return 1.0f;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Renderer9::getEventQuerySupport()
</del><ins>+bool Renderer9::getEventQuerySupport() const
</ins><span class="cx"> {
</span><span class="cx">     return mEventQuerySupport;
</span><span class="cx"> }
</span><span class="lines">@@ -2373,6 +2517,46 @@
</span><span class="cx">     return (getMajorShaderModel() &gt;= 3) ? MAX_VARYING_VECTORS_SM3 : MAX_VARYING_VECTORS_SM2;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+unsigned int Renderer9::getMaxVertexShaderUniformBuffers() const
+{
+    return 0;
+}
+
+unsigned int Renderer9::getMaxFragmentShaderUniformBuffers() const
+{
+    return 0;
+}
+
+unsigned int Renderer9::getReservedVertexUniformBuffers() const
+{
+    return 0;
+}
+
+unsigned int Renderer9::getReservedFragmentUniformBuffers() const
+{
+    return 0;
+}
+
+unsigned int Renderer9::getMaxTransformFeedbackBuffers() const
+{
+    return 0;
+}
+
+unsigned int Renderer9::getMaxTransformFeedbackSeparateComponents() const
+{
+    return 0;
+}
+
+unsigned int Renderer9::getMaxTransformFeedbackInterleavedComponents() const
+{
+    return 0;
+}
+
+unsigned int Renderer9::getMaxUniformBufferSize() const
+{
+    return 0;
+}
+
</ins><span class="cx"> bool Renderer9::getNonPower2TextureSupport() const
</span><span class="cx"> {
</span><span class="cx">     return mSupportsNonPower2Textures;
</span><span class="lines">@@ -2404,6 +2588,20 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int Renderer9::getMaxRecommendedElementsIndices() const
+{
+    // ES3 only
+    UNREACHABLE();
+    return 0;
+}
+
+int Renderer9::getMaxRecommendedElementsVertices() const
+{
+    // ES3 only
+    UNREACHABLE();
+    return 0;
+}
+
</ins><span class="cx"> int Renderer9::getMajorShaderModel() const
</span><span class="cx"> {
</span><span class="cx">     return D3DSHADER_VERSION_MAJOR(mDeviceCaps.PixelShaderVersion);
</span><span class="lines">@@ -2418,7 +2616,7 @@
</span><span class="cx"> int Renderer9::getMaxViewportDimension() const
</span><span class="cx"> {
</span><span class="cx">     int maxTextureDimension = std::min(std::min(getMaxTextureWidth(), getMaxTextureHeight()),
</span><del>-                                       (int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE);
</del><ins>+                                       (int)gl::IMPLEMENTATION_MAX_2D_TEXTURE_SIZE);
</ins><span class="cx">     return maxTextureDimension;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2432,6 +2630,18 @@
</span><span class="cx">     return (int)mDeviceCaps.MaxTextureHeight;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int Renderer9::getMaxTextureDepth() const
+{
+    // 3D textures are not available in the D3D9 backend.
+    return 1;
+}
+
+int Renderer9::getMaxTextureArrayLayers() const
+{
+    // 2D array textures are not available in the D3D9 backend.
+    return 1;
+}
+
</ins><span class="cx"> bool Renderer9::get32BitIndexSupport() const
</span><span class="cx"> {
</span><span class="cx">     return mDeviceCaps.MaxVertexIndex &gt;= (1 &lt;&lt; 16);
</span><span class="lines">@@ -2457,6 +2667,53 @@
</span><span class="cx">     return mMaxSupportedSamples;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLsizei Renderer9::getMaxSupportedFormatSamples(GLenum internalFormat) const
+{
+    D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat, this);
+    MultisampleSupportMap::const_iterator itr = mMultiSampleSupport.find(format);
+    return (itr != mMultiSampleSupport.end()) ? mMaxSupportedSamples : 0;
+}
+
+GLsizei Renderer9::getNumSampleCounts(GLenum internalFormat) const
+{
+    D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat, this);
+    MultisampleSupportMap::const_iterator iter = mMultiSampleSupport.find(format);
+
+    unsigned int numCounts = 0;
+    if (iter != mMultiSampleSupport.end())
+    {
+        const MultisampleSupportInfo&amp; info = iter-&gt;second;
+        for (int i = 0; i &lt; D3DMULTISAMPLE_16_SAMPLES; i++)
+        {
+            if (i != D3DMULTISAMPLE_NONMASKABLE &amp;&amp; info.supportedSamples[i])
+            {
+                numCounts++;
+            }
+        }
+    }
+
+    return numCounts;
+}
+
+void Renderer9::getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const
+{
+    D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat, this);
+    MultisampleSupportMap::const_iterator iter = mMultiSampleSupport.find(format);
+
+    if (iter != mMultiSampleSupport.end())
+    {
+        const MultisampleSupportInfo&amp; info = iter-&gt;second;
+        int bufPos = 0;
+        for (int i = D3DMULTISAMPLE_16_SAMPLES; i &gt;= 0 &amp;&amp; bufPos &lt; bufSize; i--)
+        {
+            if (i != D3DMULTISAMPLE_NONMASKABLE &amp;&amp; info.supportedSamples[i])
+            {
+                params[bufPos++] = i;
+            }
+        }
+    }
+}
+
</ins><span class="cx"> int Renderer9::getNearestSupportedSamples(D3DFORMAT format, int requested) const
</span><span class="cx"> {
</span><span class="cx">     if (requested == 0)
</span><span class="lines">@@ -2464,7 +2721,7 @@
</span><span class="cx">         return requested;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    std::map&lt;D3DFORMAT, bool *&gt;::const_iterator itr = mMultiSampleSupport.find(format);
</del><ins>+    MultisampleSupportMap::const_iterator itr = mMultiSampleSupport.find(format);
</ins><span class="cx">     if (itr == mMultiSampleSupport.end())
</span><span class="cx">     {
</span><span class="cx">         if (format == D3DFMT_UNKNOWN)
</span><span class="lines">@@ -2472,9 +2729,9 @@
</span><span class="cx">         return -1;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (int i = requested; i &lt;= D3DMULTISAMPLE_16_SAMPLES; ++i)
</del><ins>+    for (unsigned int i = requested; i &lt; ArraySize(itr-&gt;second.supportedSamples); ++i)
</ins><span class="cx">     {
</span><del>-        if (itr-&gt;second[i] &amp;&amp; i != D3DMULTISAMPLE_NONMASKABLE)
</del><ins>+        if (itr-&gt;second.supportedSamples[i] &amp;&amp; i != D3DMULTISAMPLE_NONMASKABLE)
</ins><span class="cx">         {
</span><span class="cx">             return i;
</span><span class="cx">         }
</span><span class="lines">@@ -2489,7 +2746,7 @@
</span><span class="cx">     return 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-D3DFORMAT Renderer9::ConvertTextureInternalFormat(GLint internalformat)
</del><ins>+D3DFORMAT Renderer9::ConvertTextureInternalFormat(GLenum internalformat)
</ins><span class="cx"> {
</span><span class="cx">     switch (internalformat)
</span><span class="cx">     {
</span><span class="lines">@@ -2545,19 +2802,21 @@
</span><span class="cx">         TextureStorage9_2D *source9 = TextureStorage9_2D::makeTextureStorage9_2D(source-&gt;getStorageInstance());
</span><span class="cx">         TextureStorage9_2D *dest9 = TextureStorage9_2D::makeTextureStorage9_2D(dest-&gt;getStorageInstance());
</span><span class="cx"> 
</span><del>-        int levels = source9-&gt;levelCount();
</del><ins>+        int levels = source9-&gt;getLevelCount();
</ins><span class="cx">         for (int i = 0; i &lt; levels; ++i)
</span><span class="cx">         {
</span><span class="cx">             IDirect3DSurface9 *srcSurf = source9-&gt;getSurfaceLevel(i, false);
</span><span class="cx">             IDirect3DSurface9 *dstSurf = dest9-&gt;getSurfaceLevel(i, false);
</span><del>-            
</del><ins>+
</ins><span class="cx">             result = copyToRenderTarget(dstSurf, srcSurf, source9-&gt;isManaged());
</span><span class="cx"> 
</span><del>-            if (srcSurf) srcSurf-&gt;Release();
-            if (dstSurf) dstSurf-&gt;Release();
</del><ins>+            SafeRelease(srcSurf);
+            SafeRelease(dstSurf);
</ins><span class="cx"> 
</span><span class="cx">             if (!result)
</span><ins>+            {
</ins><span class="cx">                 return false;
</span><ins>+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2572,7 +2831,7 @@
</span><span class="cx">     {
</span><span class="cx">         TextureStorage9_Cube *source9 = TextureStorage9_Cube::makeTextureStorage9_Cube(source-&gt;getStorageInstance());
</span><span class="cx">         TextureStorage9_Cube *dest9 = TextureStorage9_Cube::makeTextureStorage9_Cube(dest-&gt;getStorageInstance());
</span><del>-        int levels = source9-&gt;levelCount();
</del><ins>+        int levels = source9-&gt;getLevelCount();
</ins><span class="cx">         for (int f = 0; f &lt; 6; f++)
</span><span class="cx">         {
</span><span class="cx">             for (int i = 0; i &lt; levels; i++)
</span><span class="lines">@@ -2582,11 +2841,13 @@
</span><span class="cx"> 
</span><span class="cx">                 result = copyToRenderTarget(dstSurf, srcSurf, source9-&gt;isManaged());
</span><span class="cx"> 
</span><del>-                if (srcSurf) srcSurf-&gt;Release();
-                if (dstSurf) dstSurf-&gt;Release();
</del><ins>+                SafeRelease(srcSurf);
+                SafeRelease(dstSurf);
</ins><span class="cx"> 
</span><span class="cx">                 if (!result)
</span><ins>+                {
</ins><span class="cx">                     return false;
</span><ins>+                }
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2594,6 +2855,20 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer9::copyToRenderTarget(TextureStorageInterface3D *dest, TextureStorageInterface3D *source)
+{
+    // 3D textures are not available in the D3D9 backend.
+    UNREACHABLE();
+    return false;
+}
+
+bool Renderer9::copyToRenderTarget(TextureStorageInterface2DArray *dest, TextureStorageInterface2DArray *source)
+{
+    // 2D array textures are not supported by the D3D9 backend.
+    UNREACHABLE();
+    return false;
+}
+
</ins><span class="cx"> D3DPOOL Renderer9::getBufferPool(DWORD usage) const
</span><span class="cx"> {
</span><span class="cx">     if (mD3d9Ex != NULL)
</span><span class="lines">@@ -2635,9 +2910,27 @@
</span><span class="cx">     return mBlit-&gt;copy(framebuffer, rect, destFormat, xoffset, yoffset, storage, target, level);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Renderer9::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                          GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface3D *storage, GLint level)
+{
+    // 3D textures are not available in the D3D9 backend.
+    UNREACHABLE();
+    return false;
+}
+
+bool Renderer9::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                          GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface2DArray *storage, GLint level)
+{
+    // 2D array textures are not available in the D3D9 backend.
+    UNREACHABLE();
+    return false;
+}
+
</ins><span class="cx"> bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle &amp;readRect, gl::Framebuffer *drawFramebuffer, const gl::Rectangle &amp;drawRect,
</span><del>-                         bool blitRenderTarget, bool blitDepthStencil)
</del><ins>+                         const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter)
</ins><span class="cx"> {
</span><ins>+    ASSERT(filter == GL_NEAREST);
+
</ins><span class="cx">     endScene();
</span><span class="cx"> 
</span><span class="cx">     if (blitRenderTarget)
</span><span class="lines">@@ -2673,6 +2966,9 @@
</span><span class="cx">             return gl::error(GL_OUT_OF_MEMORY, false);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        gl::Extents srcSize(readRenderTarget-&gt;getWidth(), readRenderTarget-&gt;getHeight(), 1);
+        gl::Extents dstSize(drawRenderTarget-&gt;getWidth(), drawRenderTarget-&gt;getHeight(), 1);
+
</ins><span class="cx">         RECT srcRect;
</span><span class="cx">         srcRect.left = readRect.x;
</span><span class="cx">         srcRect.right = readRect.x + readRect.width;
</span><span class="lines">@@ -2685,10 +2981,79 @@
</span><span class="cx">         dstRect.top = drawRect.y;
</span><span class="cx">         dstRect.bottom = drawRect.y + drawRect.height;
</span><span class="cx"> 
</span><ins>+        // Clip the rectangles to the scissor rectangle
+        if (scissor)
+        {
+            if (dstRect.left &lt; scissor-&gt;x)
+            {
+                srcRect.left += (scissor-&gt;x - dstRect.left);
+                dstRect.left = scissor-&gt;x;
+            }
+            if (dstRect.top &lt; scissor-&gt;y)
+            {
+                srcRect.top += (scissor-&gt;y - dstRect.top);
+                dstRect.top = scissor-&gt;y;
+            }
+            if (dstRect.right &gt; scissor-&gt;x + scissor-&gt;width)
+            {
+                srcRect.right -= (dstRect.right - (scissor-&gt;x + scissor-&gt;width));
+                dstRect.right = scissor-&gt;x + scissor-&gt;width;
+            }
+            if (dstRect.bottom &gt; scissor-&gt;y + scissor-&gt;height)
+            {
+                srcRect.bottom -= (dstRect.bottom - (scissor-&gt;y + scissor-&gt;height));
+                dstRect.bottom = scissor-&gt;y + scissor-&gt;height;
+            }
+        }
+
+        // Clip the rectangles to the destination size
+        if (dstRect.left &lt; 0)
+        {
+            srcRect.left += -dstRect.left;
+            dstRect.left = 0;
+        }
+        if (dstRect.right &gt; dstSize.width)
+        {
+            srcRect.right -= (dstRect.right - dstSize.width);
+            dstRect.right = dstSize.width;
+        }
+        if (dstRect.top &lt; 0)
+        {
+            srcRect.top += -dstRect.top;
+            dstRect.top = 0;
+        }
+        if (dstRect.bottom &gt; dstSize.height)
+        {
+            srcRect.bottom -= (dstRect.bottom - dstSize.height);
+            dstRect.bottom = dstSize.height;
+        }
+
+        // Clip the rectangles to the source size
+        if (srcRect.left &lt; 0)
+        {
+            dstRect.left += -srcRect.left;
+            srcRect.left = 0;
+        }
+        if (srcRect.right &gt; srcSize.width)
+        {
+            dstRect.right -= (srcRect.right - srcSize.width);
+            srcRect.right = srcSize.width;
+        }
+        if (srcRect.top &lt; 0)
+        {
+            dstRect.top += -srcRect.top;
+            srcRect.top = 0;
+        }
+        if (srcRect.bottom &gt; srcSize.height)
+        {
+            dstRect.bottom -= (srcRect.bottom - srcSize.height);
+            srcRect.bottom = srcSize.height;
+        }
+
</ins><span class="cx">         HRESULT result = mDevice-&gt;StretchRect(readSurface, &amp;srcRect, drawSurface, &amp;dstRect, D3DTEXF_NONE);
</span><span class="cx"> 
</span><del>-        readSurface-&gt;Release();
-        drawSurface-&gt;Release();
</del><ins>+        SafeRelease(readSurface);
+        SafeRelease(drawSurface);
</ins><span class="cx"> 
</span><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="lines">@@ -2697,7 +3062,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (blitDepthStencil)
</del><ins>+    if (blitDepth || blitStencil)
</ins><span class="cx">     {
</span><span class="cx">         gl::Renderbuffer *readBuffer = readFramebuffer-&gt;getDepthOrStencilbuffer();
</span><span class="cx">         gl::Renderbuffer *drawBuffer = drawFramebuffer-&gt;getDepthOrStencilbuffer();
</span><span class="lines">@@ -2732,8 +3097,8 @@
</span><span class="cx"> 
</span><span class="cx">         HRESULT result = mDevice-&gt;StretchRect(readSurface, NULL, drawSurface, NULL, D3DTEXF_NONE);
</span><span class="cx"> 
</span><del>-        readSurface-&gt;Release();
-        drawSurface-&gt;Release();
</del><ins>+        SafeRelease(readSurface);
+        SafeRelease(drawSurface);
</ins><span class="cx"> 
</span><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="lines">@@ -2745,9 +3110,11 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, 
-                           GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels)
</del><ins>+void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
+                           GLenum type, GLuint outputPitch, const gl::PixelPackState &amp;pack, void* pixels)
</ins><span class="cx"> {
</span><ins>+    ASSERT(pack.pixelBuffer.get() == NULL);
+
</ins><span class="cx">     RenderTarget9 *renderTarget = NULL;
</span><span class="cx">     IDirect3DSurface9 *surface = NULL;
</span><span class="cx">     gl::Renderbuffer *colorbuffer = framebuffer-&gt;getColorbuffer(0);
</span><span class="lines">@@ -2756,7 +3123,7 @@
</span><span class="cx">     {
</span><span class="cx">         renderTarget = RenderTarget9::makeRenderTarget9(colorbuffer-&gt;getRenderTarget());
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (renderTarget)
</span><span class="cx">     {
</span><span class="cx">         surface = renderTarget-&gt;getSurface();
</span><span class="lines">@@ -2774,13 +3141,13 @@
</span><span class="cx">     if (desc.MultiSampleType != D3DMULTISAMPLE_NONE)
</span><span class="cx">     {
</span><span class="cx">         UNIMPLEMENTED();   // FIXME: Requires resolve using StretchRect into non-multisampled render target
</span><del>-        surface-&gt;Release();
</del><ins>+        SafeRelease(surface);
</ins><span class="cx">         return gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     HRESULT result;
</span><span class="cx">     IDirect3DSurface9 *systemSurface = NULL;
</span><del>-    bool directToPixels = !packReverseRowOrder &amp;&amp; packAlignment &lt;= 4 &amp;&amp; getShareHandleSupport() &amp;&amp;
</del><ins>+    bool directToPixels = !pack.reverseRowOrder &amp;&amp; pack.alignment &lt;= 4 &amp;&amp; getShareHandleSupport() &amp;&amp;
</ins><span class="cx">                           x == 0 &amp;&amp; y == 0 &amp;&amp; UINT(width) == desc.Width &amp;&amp; UINT(height) == desc.Height &amp;&amp;
</span><span class="cx">                           desc.Format == D3DFMT_A8R8G8B8 &amp;&amp; format == GL_BGRA_EXT &amp;&amp; type == GL_UNSIGNED_BYTE;
</span><span class="cx">     if (directToPixels)
</span><span class="lines">@@ -2802,18 +3169,17 @@
</span><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="cx">             ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
</span><del>-            surface-&gt;Release();
</del><ins>+            SafeRelease(surface);
</ins><span class="cx">             return gl::error(GL_OUT_OF_MEMORY);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     result = mDevice-&gt;GetRenderTargetData(surface, systemSurface);
</span><del>-    surface-&gt;Release();
-    surface = NULL;
</del><ins>+    SafeRelease(surface);
</ins><span class="cx"> 
</span><span class="cx">     if (FAILED(result))
</span><span class="cx">     {
</span><del>-        systemSurface-&gt;Release();
</del><ins>+        SafeRelease(systemSurface);
</ins><span class="cx"> 
</span><span class="cx">         // It turns out that D3D will sometimes produce more error
</span><span class="cx">         // codes than those documented.
</span><span class="lines">@@ -2832,7 +3198,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (directToPixels)
</span><span class="cx">     {
</span><del>-        systemSurface-&gt;Release();
</del><ins>+        SafeRelease(systemSurface);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2848,17 +3214,14 @@
</span><span class="cx">     if (FAILED(result))
</span><span class="cx">     {
</span><span class="cx">         UNREACHABLE();
</span><del>-        systemSurface-&gt;Release();
</del><ins>+        SafeRelease(systemSurface);
</ins><span class="cx"> 
</span><span class="cx">         return;   // No sensible error to generate
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned char *dest = (unsigned char*)pixels;
-    unsigned short *dest16 = (unsigned short*)pixels;
-
</del><span class="cx">     unsigned char *source;
</span><span class="cx">     int inputPitch;
</span><del>-    if (packReverseRowOrder)
</del><ins>+    if (pack.reverseRowOrder)
</ins><span class="cx">     {
</span><span class="cx">         source = ((unsigned char*)lock.pBits) + lock.Pitch * (rect.bottom - rect.top - 1);
</span><span class="cx">         inputPitch = -lock.Pitch;
</span><span class="lines">@@ -2869,231 +3232,69 @@
</span><span class="cx">         inputPitch = lock.Pitch;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned int fastPixelSize = 0;
</del><ins>+    GLuint clientVersion = getCurrentClientVersion();
</ins><span class="cx"> 
</span><del>-    if (desc.Format == D3DFMT_A8R8G8B8 &amp;&amp;
-        format == GL_BGRA_EXT &amp;&amp;
-        type == GL_UNSIGNED_BYTE)
-    {
-        fastPixelSize = 4;
-    }
-    else if ((desc.Format == D3DFMT_A4R4G4B4 &amp;&amp;
-             format == GL_BGRA_EXT &amp;&amp;
-             type == GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT) ||
-             (desc.Format == D3DFMT_A1R5G5B5 &amp;&amp;
-             format == GL_BGRA_EXT &amp;&amp;
-             type == GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT))
-    {
-        fastPixelSize = 2;
-    }
-    else if (desc.Format == D3DFMT_A16B16G16R16F &amp;&amp;
-             format == GL_RGBA &amp;&amp;
-             type == GL_HALF_FLOAT_OES)
-    {
-        fastPixelSize = 8;
-    }
-    else if (desc.Format == D3DFMT_A32B32G32R32F &amp;&amp;
-             format == GL_RGBA &amp;&amp;
-             type == GL_FLOAT)
-    {
-        fastPixelSize = 16;
-    }
</del><ins>+    GLenum sourceInternalFormat = d3d9_gl::GetInternalFormat(desc.Format);
+    GLenum sourceFormat = gl::GetFormat(sourceInternalFormat, clientVersion);
+    GLenum sourceType = gl::GetType(sourceInternalFormat, clientVersion);
</ins><span class="cx"> 
</span><del>-    for (int j = 0; j &lt; rect.bottom - rect.top; j++)
</del><ins>+    GLuint sourcePixelSize = gl::GetPixelBytes(sourceInternalFormat, clientVersion);
+
+    if (sourceFormat == format &amp;&amp; sourceType == type)
</ins><span class="cx">     {
</span><del>-        if (fastPixelSize != 0)
</del><ins>+        // Direct copy possible
+        unsigned char *dest = static_cast&lt;unsigned char*&gt;(pixels);
+        for (int y = 0; y &lt; rect.bottom - rect.top; y++)
</ins><span class="cx">         {
</span><del>-            // Fast path for formats which require no translation:
-            // D3DFMT_A8R8G8B8 to BGRA/UNSIGNED_BYTE
-            // D3DFMT_A4R4G4B4 to BGRA/UNSIGNED_SHORT_4_4_4_4_REV_EXT
-            // D3DFMT_A1R5G5B5 to BGRA/UNSIGNED_SHORT_1_5_5_5_REV_EXT
-            // D3DFMT_A16B16G16R16F to RGBA/HALF_FLOAT_OES
-            // D3DFMT_A32B32G32R32F to RGBA/FLOAT
-            // 
-            // Note that buffers with no alpha go through the slow path below.
-            memcpy(dest + j * outputPitch,
-                   source + j * inputPitch,
-                   (rect.right - rect.left) * fastPixelSize);
-            continue;
</del><ins>+            memcpy(dest + y * outputPitch, source + y * inputPitch, (rect.right - rect.left) * sourcePixelSize);
</ins><span class="cx">         }
</span><del>-        else if (desc.Format == D3DFMT_A8R8G8B8 &amp;&amp;
-                 format == GL_RGBA &amp;&amp;
-                 type == GL_UNSIGNED_BYTE)
-        {
-            // Fast path for swapping red with blue
-            for (int i = 0; i &lt; rect.right - rect.left; i++)
-            {
-                unsigned int argb = *(unsigned int*)(source + 4 * i + j * inputPitch);
-                *(unsigned int*)(dest + 4 * i + j * outputPitch) =
-                    (argb &amp; 0xFF00FF00) |       // Keep alpha and green
-                    (argb &amp; 0x00FF0000) &gt;&gt; 16 | // Move red to blue
-                    (argb &amp; 0x000000FF) &lt;&lt; 16;  // Move blue to red
-            }
-            continue;
-        }
</del><ins>+    }
+    else
+    {
+        GLenum destInternalFormat = gl::GetSizedInternalFormat(format, type, clientVersion);
+        GLuint destPixelSize = gl::GetPixelBytes(destInternalFormat, clientVersion);
+        GLuint sourcePixelSize = gl::GetPixelBytes(sourceInternalFormat, clientVersion);
</ins><span class="cx"> 
</span><del>-        for (int i = 0; i &lt; rect.right - rect.left; i++)
</del><ins>+        ColorCopyFunction fastCopyFunc = d3d9::GetFastCopyFunction(desc.Format, format, type, getCurrentClientVersion());
+        if (fastCopyFunc)
</ins><span class="cx">         {
</span><del>-            float r;
-            float g;
-            float b;
-            float a;
-
-            switch (desc.Format)
</del><ins>+            // Fast copy is possible through some special function
+            for (int y = 0; y &lt; rect.bottom - rect.top; y++)
</ins><span class="cx">             {
</span><del>-              case D3DFMT_R5G6B5:
</del><ins>+                for (int x = 0; x &lt; rect.right - rect.left; x++)
</ins><span class="cx">                 {
</span><del>-                    unsigned short rgb = *(unsigned short*)(source + 2 * i + j * inputPitch);
</del><ins>+                    void *dest = static_cast&lt;unsigned char*&gt;(pixels) + y * outputPitch + x * destPixelSize;
+                    void *src = static_cast&lt;unsigned char*&gt;(source) + y * inputPitch + x * sourcePixelSize;
</ins><span class="cx"> 
</span><del>-                    a = 1.0f;
-                    b = (rgb &amp; 0x001F) * (1.0f / 0x001F);
-                    g = (rgb &amp; 0x07E0) * (1.0f / 0x07E0);
-                    r = (rgb &amp; 0xF800) * (1.0f / 0xF800);
</del><ins>+                    fastCopyFunc(src, dest);
</ins><span class="cx">                 }
</span><del>-                break;
-              case D3DFMT_A1R5G5B5:
-                {
-                    unsigned short argb = *(unsigned short*)(source + 2 * i + j * inputPitch);
</del><ins>+            }
+        }
+        else
+        {
+            ColorReadFunction readFunc = d3d9::GetColorReadFunction(desc.Format);
+            ColorWriteFunction writeFunc = gl::GetColorWriteFunction(format, type, clientVersion);
</ins><span class="cx"> 
</span><del>-                    a = (argb &amp; 0x8000) ? 1.0f : 0.0f;
-                    b = (argb &amp; 0x001F) * (1.0f / 0x001F);
-                    g = (argb &amp; 0x03E0) * (1.0f / 0x03E0);
-                    r = (argb &amp; 0x7C00) * (1.0f / 0x7C00);
-                }
-                break;
-              case D3DFMT_A8R8G8B8:
-                {
-                    unsigned int argb = *(unsigned int*)(source + 4 * i + j * inputPitch);
</del><ins>+            gl::ColorF temp;
</ins><span class="cx"> 
</span><del>-                    a = (argb &amp; 0xFF000000) * (1.0f / 0xFF000000);
-                    b = (argb &amp; 0x000000FF) * (1.0f / 0x000000FF);
-                    g = (argb &amp; 0x0000FF00) * (1.0f / 0x0000FF00);
-                    r = (argb &amp; 0x00FF0000) * (1.0f / 0x00FF0000);
-                }
-                break;
-              case D3DFMT_X8R8G8B8:
</del><ins>+            for (int y = 0; y &lt; rect.bottom - rect.top; y++)
+            {
+                for (int x = 0; x &lt; rect.right - rect.left; x++)
</ins><span class="cx">                 {
</span><del>-                    unsigned int xrgb = *(unsigned int*)(source + 4 * i + j * inputPitch);
</del><ins>+                    void *dest = reinterpret_cast&lt;unsigned char*&gt;(pixels) + y * outputPitch + x * destPixelSize;
+                    void *src = source + y * inputPitch + x * sourcePixelSize;
</ins><span class="cx"> 
</span><del>-                    a = 1.0f;
-                    b = (xrgb &amp; 0x000000FF) * (1.0f / 0x000000FF);
-                    g = (xrgb &amp; 0x0000FF00) * (1.0f / 0x0000FF00);
-                    r = (xrgb &amp; 0x00FF0000) * (1.0f / 0x00FF0000);
</del><ins>+                    // readFunc and writeFunc will be using the same type of color, CopyTexImage
+                    // will not allow the copy otherwise.
+                    readFunc(src, &amp;temp);
+                    writeFunc(&amp;temp, dest);
</ins><span class="cx">                 }
</span><del>-                break;
-              case D3DFMT_A2R10G10B10:
-                {
-                    unsigned int argb = *(unsigned int*)(source + 4 * i + j * inputPitch);
-
-                    a = (argb &amp; 0xC0000000) * (1.0f / 0xC0000000);
-                    b = (argb &amp; 0x000003FF) * (1.0f / 0x000003FF);
-                    g = (argb &amp; 0x000FFC00) * (1.0f / 0x000FFC00);
-                    r = (argb &amp; 0x3FF00000) * (1.0f / 0x3FF00000);
-                }
-                break;
-              case D3DFMT_A32B32G32R32F:
-                {
-                    // float formats in D3D are stored rgba, rather than the other way round
-                    r = *((float*)(source + 16 * i + j * inputPitch) + 0);
-                    g = *((float*)(source + 16 * i + j * inputPitch) + 1);
-                    b = *((float*)(source + 16 * i + j * inputPitch) + 2);
-                    a = *((float*)(source + 16 * i + j * inputPitch) + 3);
-                }
-                break;
-              case D3DFMT_A16B16G16R16F:
-                {
-                    // float formats in D3D are stored rgba, rather than the other way round
-                    r = gl::float16ToFloat32(*((unsigned short*)(source + 8 * i + j * inputPitch) + 0));
-                    g = gl::float16ToFloat32(*((unsigned short*)(source + 8 * i + j * inputPitch) + 1));
-                    b = gl::float16ToFloat32(*((unsigned short*)(source + 8 * i + j * inputPitch) + 2));
-                    a = gl::float16ToFloat32(*((unsigned short*)(source + 8 * i + j * inputPitch) + 3));
-                }
-                break;
-              default:
-                UNIMPLEMENTED();   // FIXME
-                UNREACHABLE();
-                return;
</del><span class="cx">             }
</span><del>-
-            switch (format)
-            {
-              case GL_RGBA:
-                switch (type)
-                {
-                  case GL_UNSIGNED_BYTE:
-                    dest[4 * i + j * outputPitch + 0] = (unsigned char)(255 * r + 0.5f);
-                    dest[4 * i + j * outputPitch + 1] = (unsigned char)(255 * g + 0.5f);
-                    dest[4 * i + j * outputPitch + 2] = (unsigned char)(255 * b + 0.5f);
-                    dest[4 * i + j * outputPitch + 3] = (unsigned char)(255 * a + 0.5f);
-                    break;
-                  default: UNREACHABLE();
-                }
-                break;
-              case GL_BGRA_EXT:
-                switch (type)
-                {
-                  case GL_UNSIGNED_BYTE:
-                    dest[4 * i + j * outputPitch + 0] = (unsigned char)(255 * b + 0.5f);
-                    dest[4 * i + j * outputPitch + 1] = (unsigned char)(255 * g + 0.5f);
-                    dest[4 * i + j * outputPitch + 2] = (unsigned char)(255 * r + 0.5f);
-                    dest[4 * i + j * outputPitch + 3] = (unsigned char)(255 * a + 0.5f);
-                    break;
-                  case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
-                    // According to the desktop GL spec in the &quot;Transfer of Pixel Rectangles&quot; section
-                    // this type is packed as follows:
-                    //   15   14   13   12   11   10    9    8    7    6    5    4    3    2    1    0
-                    //  --------------------------------------------------------------------------------
-                    // |       4th         |        3rd         |        2nd        |   1st component   |
-                    //  --------------------------------------------------------------------------------
-                    // in the case of BGRA_EXT, B is the first component, G the second, and so forth.
-                    dest16[i + j * outputPitch / sizeof(unsigned short)] =
-                        ((unsigned short)(15 * a + 0.5f) &lt;&lt; 12)|
-                        ((unsigned short)(15 * r + 0.5f) &lt;&lt; 8) |
-                        ((unsigned short)(15 * g + 0.5f) &lt;&lt; 4) |
-                        ((unsigned short)(15 * b + 0.5f) &lt;&lt; 0);
-                    break;
-                  case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
-                    // According to the desktop GL spec in the &quot;Transfer of Pixel Rectangles&quot; section
-                    // this type is packed as follows:
-                    //   15   14   13   12   11   10    9    8    7    6    5    4    3    2    1    0
-                    //  --------------------------------------------------------------------------------
-                    // | 4th |          3rd           |           2nd          |      1st component     |
-                    //  --------------------------------------------------------------------------------
-                    // in the case of BGRA_EXT, B is the first component, G the second, and so forth.
-                    dest16[i + j * outputPitch / sizeof(unsigned short)] =
-                        ((unsigned short)(     a + 0.5f) &lt;&lt; 15) |
-                        ((unsigned short)(31 * r + 0.5f) &lt;&lt; 10) |
-                        ((unsigned short)(31 * g + 0.5f) &lt;&lt; 5) |
-                        ((unsigned short)(31 * b + 0.5f) &lt;&lt; 0);
-                    break;
-                  default: UNREACHABLE();
-                }
-                break;
-              case GL_RGB:
-                switch (type)
-                {
-                  case GL_UNSIGNED_SHORT_5_6_5:
-                    dest16[i + j * outputPitch / sizeof(unsigned short)] = 
-                        ((unsigned short)(31 * b + 0.5f) &lt;&lt; 0) |
-                        ((unsigned short)(63 * g + 0.5f) &lt;&lt; 5) |
-                        ((unsigned short)(31 * r + 0.5f) &lt;&lt; 11);
-                    break;
-                  case GL_UNSIGNED_BYTE:
-                    dest[3 * i + j * outputPitch + 0] = (unsigned char)(255 * r + 0.5f);
-                    dest[3 * i + j * outputPitch + 1] = (unsigned char)(255 * g + 0.5f);
-                    dest[3 * i + j * outputPitch + 2] = (unsigned char)(255 * b + 0.5f);
-                    break;
-                  default: UNREACHABLE();
-                }
-                break;
-              default: UNREACHABLE();
-            }
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     systemSurface-&gt;UnlockRect();
</span><del>-
-    systemSurface-&gt;Release();
</del><ins>+    SafeRelease(systemSurface);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderTarget *Renderer9::createRenderTarget(SwapChain *swapChain, bool depth)
</span><span class="lines">@@ -3114,14 +3315,19 @@
</span><span class="cx">     return renderTarget;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget *Renderer9::createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth)
</del><ins>+RenderTarget *Renderer9::createRenderTarget(int width, int height, GLenum format, GLsizei samples)
</ins><span class="cx"> {
</span><span class="cx">     RenderTarget9 *renderTarget = new RenderTarget9(this, width, height, format, samples);
</span><span class="cx">     return renderTarget;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ShaderExecutable *Renderer9::loadExecutable(const void *function, size_t length, rx::ShaderType type)
</del><ins>+ShaderExecutable *Renderer9::loadExecutable(const void *function, size_t length, rx::ShaderType type,
+                                            const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                            bool separatedOutputBuffers)
</ins><span class="cx"> {
</span><ins>+    // Transform feedback is not supported in ES2 or D3D9
+    ASSERT(transformFeedbackVaryings.size() == 0);
+
</ins><span class="cx">     ShaderExecutable9 *executable = NULL;
</span><span class="cx"> 
</span><span class="cx">     switch (type)
</span><span class="lines">@@ -3152,8 +3358,13 @@
</span><span class="cx">     return executable;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround)
</del><ins>+ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type,
+                                                 const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                                 bool separatedOutputBuffers, D3DWorkaroundType workaround)
</ins><span class="cx"> {
</span><ins>+    // Transform feedback is not supported in ES2 or D3D9
+    ASSERT(transformFeedbackVaryings.size() == 0);
+
</ins><span class="cx">     const char *profile = NULL;
</span><span class="cx"> 
</span><span class="cx">     switch (type)
</span><span class="lines">@@ -3169,20 +3380,36 @@
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // ANGLE issue 486:
-    // Work-around a D3D9 compiler bug that presents itself when using conditional discard, by disabling optimization
-    UINT optimizationFlags = (workaround == ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER ? D3DCOMPILE_SKIP_OPTIMIZATION : ANGLE_COMPILE_OPTIMIZATION_LEVEL);
</del><ins>+    UINT optimizationFlags = ANGLE_COMPILE_OPTIMIZATION_LEVEL;
</ins><span class="cx"> 
</span><del>-    ID3DBlob *binary = (ID3DBlob*)compileToBinary(infoLog, shaderHLSL, profile, optimizationFlags, true);
</del><ins>+    if (workaround == ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION)
+    {
+        optimizationFlags = D3DCOMPILE_SKIP_OPTIMIZATION;
+    }
+    else if (workaround == ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION)
+    {
+        optimizationFlags = D3DCOMPILE_OPTIMIZATION_LEVEL3;
+    }
+    else ASSERT(workaround == ANGLE_D3D_WORKAROUND_NONE);
+
+    ID3DBlob *binary = (ID3DBlob*)mCompiler.compileToBinary(infoLog, shaderHLSL, profile, optimizationFlags, true);
</ins><span class="cx">     if (!binary)
</span><ins>+    {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    ShaderExecutable *executable = loadExecutable(binary-&gt;GetBufferPointer(), binary-&gt;GetBufferSize(), type);
-    binary-&gt;Release();
</del><ins>+    ShaderExecutable *executable = loadExecutable(binary-&gt;GetBufferPointer(), binary-&gt;GetBufferSize(), type,
+                                                  transformFeedbackVaryings, separatedOutputBuffers);
+    SafeRelease(binary);
</ins><span class="cx"> 
</span><span class="cx">     return executable;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+rx::UniformStorage *Renderer9::createUniformStorage(size_t storageSize)
+{
+    return new UniformStorage(storageSize);
+}
+
</ins><span class="cx"> bool Renderer9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
</span><span class="cx"> {
</span><span class="cx">     return mBlit-&gt;boxFilter(source, dest);
</span><span class="lines">@@ -3223,7 +3450,7 @@
</span><span class="cx">             {
</span><span class="cx">                 Image9::copyLockableSurfaces(surf, source);
</span><span class="cx">                 result = mDevice-&gt;UpdateSurface(surf, NULL, dest, NULL);
</span><del>-                surf-&gt;Release();
</del><ins>+                SafeRelease(surf);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         else
</span><span class="lines">@@ -3260,16 +3487,32 @@
</span><span class="cx">     return new TextureStorage9_2D(this, swapChain9);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorage *Renderer9::createTextureStorage2D(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height)
</del><ins>+TextureStorage *Renderer9::createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
</ins><span class="cx"> {
</span><del>-    return new TextureStorage9_2D(this, levels, internalformat, usage, forceRenderable, width, height);
</del><ins>+    return new TextureStorage9_2D(this, internalformat, renderTarget, width, height, levels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorage *Renderer9::createTextureStorageCube(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size)
</del><ins>+TextureStorage *Renderer9::createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels)
</ins><span class="cx"> {
</span><del>-    return new TextureStorage9_Cube(this, levels, internalformat, usage, forceRenderable, size);
</del><ins>+    return new TextureStorage9_Cube(this, internalformat, renderTarget, size, levels);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TextureStorage *Renderer9::createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels)
+{
+    // 3D textures are not supported by the D3D9 backend.
+    UNREACHABLE();
+
+    return NULL;
+}
+
+TextureStorage *Renderer9::createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels)
+{
+    // 2D array textures are not supported by the D3D9 backend.
+    UNREACHABLE();
+
+    return NULL;
+}
+
</ins><span class="cx"> bool Renderer9::getLUID(LUID *adapterLuid) const
</span><span class="cx"> {
</span><span class="cx">     adapterLuid-&gt;HighPart = 0;
</span><span class="lines">@@ -3284,4 +3527,20 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLenum Renderer9::getNativeTextureFormat(GLenum internalFormat) const
+{
+    return d3d9_gl::GetInternalFormat(gl_d3d9::GetTextureFormat(internalFormat, this));
</ins><span class="cx"> }
</span><ins>+
+rx::VertexConversionType Renderer9::getVertexConversionType(const gl::VertexFormat &amp;vertexFormat) const
+{
+    return d3d9::GetVertexConversionType(vertexFormat);
+}
+
+GLenum Renderer9::getVertexComponentType(const gl::VertexFormat &amp;vertexFormat) const
+{
+    D3DDECLTYPE declType = d3d9::GetNativeVertexFormat(vertexFormat);
+    return d3d9::GetDeclTypeComponentType(declType);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9Renderer9h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Renderer9.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Renderer9.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Renderer9.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -10,8 +10,9 @@
</span><span class="cx"> #define LIBGLESV2_RENDERER_RENDERER9_H_
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/angleutils.h&quot;
</span><del>-#include &quot;libGLESv2/mathutil.h&quot;
-#include &quot;libGLESv2/renderer/ShaderCache.h&quot;
</del><ins>+#include &quot;common/mathutil.h&quot;
+#include &quot;libGLESv2/renderer/d3d/HLSLCompiler.h&quot;
+#include &quot;libGLESv2/renderer/d3d9/ShaderCache.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/VertexDeclarationCache.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/Renderer.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/RenderTarget.h&quot;
</span><span class="lines">@@ -27,6 +28,7 @@
</span><span class="cx"> class IndexDataManager;
</span><span class="cx"> class StreamingIndexBufferInterface;
</span><span class="cx"> struct TranslatedAttribute;
</span><ins>+class Blit9;
</ins><span class="cx"> 
</span><span class="cx"> class Renderer9 : public Renderer
</span><span class="cx"> {
</span><span class="lines">@@ -57,22 +59,14 @@
</span><span class="cx">     IDirect3DPixelShader9 *createPixelShader(const DWORD *function, size_t length);
</span><span class="cx">     HRESULT createVertexBuffer(UINT Length, DWORD Usage, IDirect3DVertexBuffer9 **ppVertexBuffer);
</span><span class="cx">     HRESULT createIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, IDirect3DIndexBuffer9 **ppIndexBuffer);
</span><del>-#if 0
-    void *createTexture2D();
-    void *createTextureCube();
-    void *createQuery();
-    void *createIndexBuffer();
-    void *createVertexbuffer();
-
-    // state setup
-    void applyShaders();
-    void applyConstants();
-#endif
</del><ins>+    virtual void generateSwizzle(gl::Texture *texture);
</ins><span class="cx">     virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &amp;sampler);
</span><span class="cx">     virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
</span><span class="cx"> 
</span><ins>+    virtual bool setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]);
+
</ins><span class="cx">     virtual void setRasterizerState(const gl::RasterizerState &amp;rasterState);
</span><del>-    virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::Color &amp;blendColor,
</del><ins>+    virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &amp;blendState, const gl::ColorF &amp;blendColor,
</ins><span class="cx">                                unsigned int sampleMask);
</span><span class="cx">     virtual void setDepthStencilState(const gl::DepthStencilState &amp;depthStencilState, int stencilRef,
</span><span class="cx">                                       int stencilBackRef, bool frontFaceCCW);
</span><span class="lines">@@ -82,15 +76,19 @@
</span><span class="cx">                              bool ignoreViewport);
</span><span class="cx"> 
</span><span class="cx">     virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer);
</span><del>-    virtual void applyShaders(gl::ProgramBinary *programBinary);
-    virtual void applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray *uniformArray);
</del><ins>+    virtual void applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[]);
+    virtual void applyUniforms(const gl::ProgramBinary &amp;programBinary);
</ins><span class="cx">     virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount);
</span><del>-    virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances);
</del><ins>+    virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
+                                     GLint first, GLsizei count, GLsizei instances);
</ins><span class="cx">     virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
</span><span class="cx"> 
</span><del>-    virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances);
-    virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei instances);
</del><ins>+    virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]);
</ins><span class="cx"> 
</span><ins>+    virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive);
+    virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
+                              gl::Buffer *elementArrayBuffer, const TranslatedIndexData &amp;indexInfo, GLsizei instances);
+
</ins><span class="cx">     virtual void clear(const gl::ClearParameters &amp;clearParams, gl::Framebuffer *frameBuffer);
</span><span class="cx"> 
</span><span class="cx">     virtual void markAllStateDirty();
</span><span class="lines">@@ -108,14 +106,20 @@
</span><span class="cx">     virtual GUID getAdapterIdentifier() const;
</span><span class="cx"> 
</span><span class="cx">     virtual bool getBGRATextureSupport() const;
</span><del>-    virtual bool getDXT1TextureSupport();
-    virtual bool getDXT3TextureSupport();
-    virtual bool getDXT5TextureSupport();
-    virtual bool getEventQuerySupport();
-    virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable);
-    virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable);
-    virtual bool getLuminanceTextureSupport();
-    virtual bool getLuminanceAlphaTextureSupport();
</del><ins>+    virtual bool getDXT1TextureSupport() const;
+    virtual bool getDXT3TextureSupport() const;
+    virtual bool getDXT5TextureSupport() const;
+    virtual bool getEventQuerySupport() const;
+    virtual bool getFloat32TextureSupport() const;
+    virtual bool getFloat32TextureFilteringSupport() const;
+    virtual bool getFloat32TextureRenderingSupport() const;
+    virtual bool getFloat16TextureSupport() const;
+    virtual bool getFloat16TextureFilteringSupport() const;
+    virtual bool getFloat16TextureRenderingSupport() const;
+    virtual bool getRGB565TextureSupport() const;
+    virtual bool getLuminanceTextureSupport() const;
+    virtual bool getLuminanceAlphaTextureSupport() const;
+    virtual bool getRGTextureSupport() const;
</ins><span class="cx">     virtual unsigned int getMaxVertexTextureImageUnits() const;
</span><span class="cx">     virtual unsigned int getMaxCombinedTextureImageUnits() const;
</span><span class="cx">     virtual unsigned int getReservedVertexUniformVectors() const;
</span><span class="lines">@@ -123,61 +127,90 @@
</span><span class="cx">     virtual unsigned int getMaxVertexUniformVectors() const;
</span><span class="cx">     virtual unsigned int getMaxFragmentUniformVectors() const;
</span><span class="cx">     virtual unsigned int getMaxVaryingVectors() const;
</span><ins>+    virtual unsigned int getMaxVertexShaderUniformBuffers() const;
+    virtual unsigned int getMaxFragmentShaderUniformBuffers() const;
+    virtual unsigned int getReservedVertexUniformBuffers() const;
+    virtual unsigned int getReservedFragmentUniformBuffers() const;
+    virtual unsigned int getMaxTransformFeedbackBuffers() const;
+    virtual unsigned int getMaxTransformFeedbackSeparateComponents() const;
+    virtual unsigned int getMaxTransformFeedbackInterleavedComponents() const;
+    virtual unsigned int getMaxUniformBufferSize() const;
</ins><span class="cx">     virtual bool getNonPower2TextureSupport() const;
</span><span class="cx">     virtual bool getDepthTextureSupport() const;
</span><span class="cx">     virtual bool getOcclusionQuerySupport() const;
</span><span class="cx">     virtual bool getInstancingSupport() const;
</span><span class="cx">     virtual bool getTextureFilterAnisotropySupport() const;
</span><ins>+    virtual bool getPBOSupport() const;
</ins><span class="cx">     virtual float getTextureMaxAnisotropy() const;
</span><span class="cx">     virtual bool getShareHandleSupport() const;
</span><span class="cx">     virtual bool getDerivativeInstructionSupport() const;
</span><span class="cx">     virtual bool getPostSubBufferSupport() const;
</span><ins>+    virtual int getMaxRecommendedElementsIndices() const;
+    virtual int getMaxRecommendedElementsVertices() const;
</ins><span class="cx"> 
</span><span class="cx">     virtual int getMajorShaderModel() const;
</span><span class="cx">     virtual float getMaxPointSize() const;
</span><span class="cx">     virtual int getMaxViewportDimension() const;
</span><span class="cx">     virtual int getMaxTextureWidth() const;
</span><span class="cx">     virtual int getMaxTextureHeight() const;
</span><ins>+    virtual int getMaxTextureDepth() const;
+    virtual int getMaxTextureArrayLayers() const;
</ins><span class="cx">     virtual bool get32BitIndexSupport() const;
</span><span class="cx">     DWORD getCapsDeclTypes() const;
</span><span class="cx">     virtual int getMinSwapInterval() const;
</span><span class="cx">     virtual int getMaxSwapInterval() const;
</span><span class="cx"> 
</span><span class="cx">     virtual GLsizei getMaxSupportedSamples() const;
</span><ins>+    virtual GLsizei getMaxSupportedFormatSamples(GLenum internalFormat) const;
+    virtual GLsizei getNumSampleCounts(GLenum internalFormat) const;
+    virtual void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const;
</ins><span class="cx">     int getNearestSupportedSamples(D3DFORMAT format, int requested) const;
</span><span class="cx">     
</span><span class="cx">     virtual unsigned int getMaxRenderTargets() const;
</span><span class="cx"> 
</span><del>-    D3DFORMAT ConvertTextureInternalFormat(GLint internalformat);
</del><ins>+    D3DFORMAT ConvertTextureInternalFormat(GLenum internalformat);
</ins><span class="cx"> 
</span><span class="cx">     // Pixel operations
</span><span class="cx">     virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source);
</span><span class="cx">     virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source);
</span><ins>+    virtual bool copyToRenderTarget(TextureStorageInterface3D *dest, TextureStorageInterface3D *source);
+    virtual bool copyToRenderTarget(TextureStorageInterface2DArray *dest, TextureStorageInterface2DArray *source);
</ins><span class="cx"> 
</span><span class="cx">     virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
</span><span class="cx">                            GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level);
</span><span class="cx">     virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
</span><span class="cx">                            GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level);
</span><ins>+    virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                           GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface3D *storage, GLint level);
+    virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &amp;sourceRect, GLenum destFormat,
+                           GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface2DArray *storage, GLint level);
</ins><span class="cx"> 
</span><span class="cx">     virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &amp;readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &amp;drawRect,
</span><del>-                          bool blitRenderTarget, bool blitDepthStencil);
-    virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
-                            GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels);
</del><ins>+                          const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
+    virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
+                            GLenum type, GLuint outputPitch, const gl::PixelPackState &amp;pack, void* pixels);
</ins><span class="cx"> 
</span><span class="cx">     // RenderTarget creation
</span><span class="cx">     virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
</span><del>-    virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth);
</del><ins>+    virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples);
</ins><span class="cx"> 
</span><span class="cx">     // Shader operations
</span><del>-    virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type);
-    virtual ShaderExecutable *compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround);
</del><ins>+    virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type,
+                                             const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                             bool separatedOutputBuffers);
+    virtual ShaderExecutable *compileToExecutable(gl::InfoLog &amp;infoLog, const char *shaderHLSL, rx::ShaderType type,
+                                                  const std::vector&lt;gl::LinkedVarying&gt; &amp;transformFeedbackVaryings,
+                                                  bool separatedOutputBuffers, D3DWorkaroundType workaround);
+    virtual UniformStorage *createUniformStorage(size_t storageSize);
</ins><span class="cx"> 
</span><span class="cx">     // Image operations
</span><span class="cx">     virtual Image *createImage();
</span><span class="cx">     virtual void generateMipmap(Image *dest, Image *source);
</span><span class="cx">     virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain);
</span><del>-    virtual TextureStorage *createTextureStorage2D(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height);
-    virtual TextureStorage *createTextureStorageCube(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size);
</del><ins>+    virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
+    virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels);
+    virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
+    virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
</ins><span class="cx"> 
</span><span class="cx">     // Buffer creation
</span><span class="cx">     virtual VertexBuffer *createVertexBuffer();
</span><span class="lines">@@ -188,26 +221,33 @@
</span><span class="cx">     virtual QueryImpl *createQuery(GLenum type);
</span><span class="cx">     virtual FenceImpl *createFence();
</span><span class="cx"> 
</span><ins>+    // Buffer-to-texture and Texture-to-buffer copies
+    virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const;
+    virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &amp;unpack, unsigned int offset, RenderTarget *destRenderTarget,
+                                         GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &amp;destArea);
+
</ins><span class="cx">     // D3D9-renderer specific methods
</span><span class="cx">     bool boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest);
</span><span class="cx"> 
</span><span class="cx">     D3DPOOL getTexturePool(DWORD usage) const;
</span><span class="cx"> 
</span><span class="cx">     virtual bool getLUID(LUID *adapterLuid) const;
</span><ins>+    virtual GLenum getNativeTextureFormat(GLenum internalFormat) const;
+    virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &amp;vertexFormat) const;
+    virtual GLenum getVertexComponentType(const gl::VertexFormat &amp;vertexFormat) const;
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(Renderer9);
</span><span class="cx"> 
</span><span class="cx">     void deinitialize();
</span><span class="cx"> 
</span><del>-    void applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v);
-    void applyUniformniv(gl::Uniform *targetUniform, const GLint *v);
-    void applyUniformnbv(gl::Uniform *targetUniform, const GLint *v);
</del><ins>+    void applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v);
+    void applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v);
+    void applyUniformnbv(gl::LinkedUniform *targetUniform, const GLint *v);
</ins><span class="cx"> 
</span><span class="cx">     void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
</span><span class="cx">     void drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
</span><span class="cx"> 
</span><del>-    void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray);
</del><span class="cx">     bool copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged);
</span><span class="cx">     gl::Renderbuffer *getNullColorbuffer(gl::Renderbuffer *depthbuffer);
</span><span class="cx"> 
</span><span class="lines">@@ -232,8 +272,10 @@
</span><span class="cx">     IDirect3DDevice9 *mDevice;
</span><span class="cx">     IDirect3DDevice9Ex *mDeviceEx;  // Might be null if D3D9Ex is not supported.
</span><span class="cx"> 
</span><del>-    Blit *mBlit;
</del><ins>+    HLSLCompiler mCompiler;
</ins><span class="cx"> 
</span><ins>+    Blit9 *mBlit;
+
</ins><span class="cx">     HWND mDeviceWindow;
</span><span class="cx"> 
</span><span class="cx">     bool mDeviceLost;
</span><span class="lines">@@ -256,6 +298,8 @@
</span><span class="cx"> 
</span><span class="cx">     bool mDepthTextureSupport;
</span><span class="cx"> 
</span><ins>+    bool mRGB565TextureSupport;
+
</ins><span class="cx">     bool mFloat32TextureSupport;
</span><span class="cx">     bool mFloat32FilterSupport;
</span><span class="cx">     bool mFloat32RenderSupport;
</span><span class="lines">@@ -271,9 +315,19 @@
</span><span class="cx">     bool mLuminanceTextureSupport;
</span><span class="cx">     bool mLuminanceAlphaTextureSupport;
</span><span class="cx"> 
</span><del>-    std::map&lt;D3DFORMAT, bool *&gt; mMultiSampleSupport;
-    GLsizei mMaxSupportedSamples;
</del><ins>+    bool mRGTextureSupport;
</ins><span class="cx"> 
</span><ins>+    struct MultisampleSupportInfo
+    {
+        bool supportedSamples[D3DMULTISAMPLE_16_SAMPLES + 1];
+        unsigned int maxSupportedSamples;
+    };
+    typedef std::map&lt;D3DFORMAT, MultisampleSupportInfo&gt; MultisampleSupportMap;
+    MultisampleSupportMap mMultiSampleSupport;
+    unsigned int mMaxSupportedSamples;
+
+    MultisampleSupportInfo getMultiSampleSupport(D3DFORMAT format);
+
</ins><span class="cx">     // current render target states
</span><span class="cx">     unsigned int mAppliedRenderTargetSerial;
</span><span class="cx">     unsigned int mAppliedDepthbufferSerial;
</span><span class="lines">@@ -308,7 +362,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool mForceSetBlendState;
</span><span class="cx">     gl::BlendState mCurBlendState;
</span><del>-    gl::Color mCurBlendColor;
</del><ins>+    gl::ColorF mCurBlendColor;
</ins><span class="cx">     GLuint mCurSampleMask;
</span><span class="cx"> 
</span><span class="cx">     // Currently applied sampler states
</span><span class="lines">@@ -323,7 +377,8 @@
</span><span class="cx">     unsigned int mCurPixelTextureSerials[gl::MAX_TEXTURE_IMAGE_UNITS];
</span><span class="cx"> 
</span><span class="cx">     unsigned int mAppliedIBSerial;
</span><del>-    unsigned int mAppliedProgramBinarySerial;
</del><ins>+    IDirect3DVertexShader9 *mAppliedVertexShader;
+    IDirect3DPixelShader9 *mAppliedPixelShader;
</ins><span class="cx">     
</span><span class="cx">     rx::dx_VertexConstants mVertexConstants;
</span><span class="cx">     rx::dx_PixelConstants mPixelConstants;
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9ShaderExecutable9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -31,14 +31,8 @@
</span><span class="cx"> 
</span><span class="cx"> ShaderExecutable9::~ShaderExecutable9()
</span><span class="cx"> {
</span><del>-    if (mVertexExecutable)
-    {
-        mVertexExecutable-&gt;Release();
-    }
-    if (mPixelExecutable)
-    {
-        mPixelExecutable-&gt;Release();
-    }
</del><ins>+    SafeRelease(mVertexExecutable);
+    SafeRelease(mPixelExecutable);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ShaderExecutable9 *ShaderExecutable9::makeShaderExecutable9(ShaderExecutable *executable)
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9SwapChain9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/SwapChain9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/SwapChain9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/SwapChain9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -9,6 +9,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/SwapChain9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/renderer9_utils.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d9/formatutils9.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/Renderer9.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="lines">@@ -35,38 +36,16 @@
</span><span class="cx"> 
</span><span class="cx"> void SwapChain9::release()
</span><span class="cx"> {
</span><del>-    if (mSwapChain)
-    {
-        mSwapChain-&gt;Release();
-        mSwapChain = NULL;
-    }
</del><ins>+    SafeRelease(mSwapChain);
+    SafeRelease(mBackBuffer);
+    SafeRelease(mDepthStencil);
+    SafeRelease(mRenderTarget);
+    SafeRelease(mOffscreenTexture);
</ins><span class="cx"> 
</span><del>-    if (mBackBuffer)
-    {
-        mBackBuffer-&gt;Release();
-        mBackBuffer = NULL;
-    }
-
-    if (mDepthStencil)
-    {
-        mDepthStencil-&gt;Release();
-        mDepthStencil = NULL;
-    }
-
-    if (mRenderTarget)
-    {
-        mRenderTarget-&gt;Release();
-        mRenderTarget = NULL;
-    }
-
-    if (mOffscreenTexture)
-    {
-        mOffscreenTexture-&gt;Release();
-        mOffscreenTexture = NULL;
-    }
-
</del><span class="cx">     if (mWindow)
</span><ins>+    {
</ins><span class="cx">         mShareHandle = NULL;
</span><ins>+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static DWORD convertInterval(EGLint interval)
</span><span class="lines">@@ -111,30 +90,11 @@
</span><span class="cx"> 
</span><span class="cx">     // Release specific resources to free up memory for the new render target, while the
</span><span class="cx">     // old render target still exists for the purpose of preserving its contents.
</span><del>-    if (mSwapChain)
-    {
-        mSwapChain-&gt;Release();
-        mSwapChain = NULL;
-    }
</del><ins>+    SafeRelease(mSwapChain);
+    SafeRelease(mBackBuffer);
+    SafeRelease(mOffscreenTexture);
+    SafeRelease(mDepthStencil);
</ins><span class="cx"> 
</span><del>-    if (mBackBuffer)
-    {
-        mBackBuffer-&gt;Release();
-        mBackBuffer = NULL;
-    }
-
-    if (mOffscreenTexture)
-    {
-        mOffscreenTexture-&gt;Release();
-        mOffscreenTexture = NULL;
-    }
-
-    if (mDepthStencil)
-    {
-        mDepthStencil-&gt;Release();
-        mDepthStencil = NULL;
-    }
-
</del><span class="cx">     HANDLE *pShareHandle = NULL;
</span><span class="cx">     if (!mWindow &amp;&amp; mRenderer-&gt;getShareHandleSupport())
</span><span class="cx">     {
</span><span class="lines">@@ -142,8 +102,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     result = device-&gt;CreateTexture(backbufferWidth, backbufferHeight, 1, D3DUSAGE_RENDERTARGET,
</span><del>-                                   gl_d3d9::ConvertRenderbufferFormat(mBackBufferFormat), D3DPOOL_DEFAULT,
-                                   &amp;mOffscreenTexture, pShareHandle);
</del><ins>+                                   gl_d3d9::GetTextureFormat(mBackBufferFormat, mRenderer),
+                                   D3DPOOL_DEFAULT, &amp;mOffscreenTexture, pShareHandle);
</ins><span class="cx">     if (FAILED(result))
</span><span class="cx">     {
</span><span class="cx">         ERR(&quot;Could not create offscreen texture: %08lX&quot;, result);
</span><span class="lines">@@ -187,15 +147,15 @@
</span><span class="cx">         result = device-&gt;StretchRect(oldRenderTarget, &amp;rect, mRenderTarget, &amp;rect, D3DTEXF_NONE);
</span><span class="cx">         ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><del>-        oldRenderTarget-&gt;Release();
</del><ins>+        SafeRelease(oldRenderTarget);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (mWindow)
</span><span class="cx">     {
</span><span class="cx">         D3DPRESENT_PARAMETERS presentParameters = {0};
</span><del>-        presentParameters.AutoDepthStencilFormat = gl_d3d9::ConvertRenderbufferFormat(mDepthBufferFormat);
</del><ins>+        presentParameters.AutoDepthStencilFormat = gl_d3d9::GetRenderFormat(mDepthBufferFormat, mRenderer);
</ins><span class="cx">         presentParameters.BackBufferCount = 1;
</span><del>-        presentParameters.BackBufferFormat = gl_d3d9::ConvertRenderbufferFormat(mBackBufferFormat);
</del><ins>+        presentParameters.BackBufferFormat = gl_d3d9::GetRenderFormat(mBackBufferFormat, mRenderer);
</ins><span class="cx">         presentParameters.EnableAutoDepthStencil = FALSE;
</span><span class="cx">         presentParameters.Flags = 0;
</span><span class="cx">         presentParameters.hDeviceWindow = mWindow;
</span><span class="lines">@@ -247,7 +207,7 @@
</span><span class="cx">     if (mDepthBufferFormat != GL_NONE)
</span><span class="cx">     {
</span><span class="cx">         result = device-&gt;CreateDepthStencilSurface(backbufferWidth, backbufferHeight,
</span><del>-                                                   gl_d3d9::ConvertRenderbufferFormat(mDepthBufferFormat),
</del><ins>+                                                   gl_d3d9::GetRenderFormat(mDepthBufferFormat, mRenderer),
</ins><span class="cx">                                                    D3DMULTISAMPLE_NONE, 0, FALSE, &amp;mDepthStencil, NULL);
</span><span class="cx"> 
</span><span class="cx">         if (FAILED(result))
</span><span class="lines">@@ -356,6 +316,14 @@
</span><span class="cx">         return EGL_BAD_ALLOC;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // On Windows 8 systems, IDirect3DSwapChain9::Present sometimes returns 0x88760873 when the windows is
+    // in the process of entering/exiting fullscreen. This code doesn't seem to have any documentation.  The
+    // device appears to be ok after emitting this error so simply return a failure to swap.
+    if (result == 0x88760873)
+    {
+        return EGL_BAD_MATCH;
+    }
+
</ins><span class="cx">     // http://crbug.com/313210
</span><span class="cx">     // If our swap failed, trigger a device lost event. Resetting will work around an AMD-specific
</span><span class="cx">     // device removed bug with lost contexts when reinstalling drivers.
</span><span class="lines">@@ -370,6 +338,7 @@
</span><span class="cx"> 
</span><span class="cx"> // Increments refcount on surface.
</span><span class="cx"> // caller must Release() the returned surface
</span><ins>+// TODO: remove the AddRef to match SwapChain11
</ins><span class="cx"> IDirect3DSurface9 *SwapChain9::getRenderTarget()
</span><span class="cx"> {
</span><span class="cx">     if (mRenderTarget)
</span><span class="lines">@@ -382,6 +351,7 @@
</span><span class="cx"> 
</span><span class="cx"> // Increments refcount on surface.
</span><span class="cx"> // caller must Release() the returned surface
</span><ins>+// TODO: remove the AddRef to match SwapChain11
</ins><span class="cx"> IDirect3DSurface9 *SwapChain9::getDepthStencil()
</span><span class="cx"> {
</span><span class="cx">     if (mDepthStencil)
</span><span class="lines">@@ -394,6 +364,7 @@
</span><span class="cx"> 
</span><span class="cx"> // Increments refcount on texture.
</span><span class="cx"> // caller must Release() the returned texture
</span><ins>+// TODO: remove the AddRef to match SwapChain11
</ins><span class="cx"> IDirect3DTexture9 *SwapChain9::getOffscreenTexture()
</span><span class="cx"> {
</span><span class="cx">     if (mOffscreenTexture)
</span><span class="lines">@@ -434,10 +405,10 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    mSwapChain-&gt;Release();
</del><ins>+    SafeRelease(mSwapChain);
</ins><span class="cx">     mSwapChain = newSwapChain;
</span><span class="cx"> 
</span><del>-    mBackBuffer-&gt;Release();
</del><ins>+    SafeRelease(mBackBuffer);
</ins><span class="cx">     result = mSwapChain-&gt;GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &amp;mBackBuffer);
</span><span class="cx">     ASSERT(SUCCEEDED(result));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9TextureStorage9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #include &quot;precompiled.h&quot;
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -15,12 +15,13 @@
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/SwapChain9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/RenderTarget9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/renderer9_utils.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d9/formatutils9.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/Texture.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> TextureStorage9::TextureStorage9(Renderer *renderer, DWORD usage)
</span><del>-    : mLodOffset(0),
</del><ins>+    : mTopLevel(0),
</ins><span class="cx">       mRenderer(Renderer9::makeRenderer9(renderer)),
</span><span class="cx">       mD3DUsage(usage),
</span><span class="cx">       mD3DPool(mRenderer-&gt;getTexturePool(usage))
</span><span class="lines">@@ -37,47 +38,26 @@
</span><span class="cx">     return static_cast&lt;TextureStorage9*&gt;(storage);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DWORD TextureStorage9::GetTextureUsage(D3DFORMAT d3dfmt, GLenum glusage, bool forceRenderable)
</del><ins>+DWORD TextureStorage9::GetTextureUsage(GLenum internalformat, Renderer9 *renderer, bool renderTarget)
</ins><span class="cx"> {
</span><ins>+    GLuint clientVersion = renderer-&gt;getCurrentClientVersion();
+
</ins><span class="cx">     DWORD d3dusage = 0;
</span><span class="cx"> 
</span><del>-    if (d3dfmt == D3DFMT_INTZ)
</del><ins>+    if (gl::GetDepthBits(internalformat, clientVersion) &gt; 0 ||
+        gl::GetStencilBits(internalformat, clientVersion) &gt; 0)
</ins><span class="cx">     {
</span><span class="cx">         d3dusage |= D3DUSAGE_DEPTHSTENCIL;
</span><span class="cx">     }
</span><del>-    else if(forceRenderable || (TextureStorage9::IsTextureFormatRenderable(d3dfmt) &amp;&amp; (glusage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE)))
</del><ins>+    else if (renderTarget &amp;&amp; (gl_d3d9::GetRenderFormat(internalformat, renderer) != D3DFMT_UNKNOWN))
</ins><span class="cx">     {
</span><span class="cx">         d3dusage |= D3DUSAGE_RENDERTARGET;
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     return d3dusage;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool TextureStorage9::IsTextureFormatRenderable(D3DFORMAT format)
-{
-    if (format == D3DFMT_INTZ)
-    {
-        return true;
-    }
-    switch(format)
-    {
-      case D3DFMT_L8:
-      case D3DFMT_A8L8:
-      case D3DFMT_DXT1:
-      case D3DFMT_DXT3:
-      case D3DFMT_DXT5:
-        return false;
-      case D3DFMT_A8R8G8B8:
-      case D3DFMT_X8R8G8B8:
-      case D3DFMT_A16B16G16R16F:
-      case D3DFMT_A32B32G32R32F:
-        return true;
-      default:
-        UNREACHABLE();
-    }
</del><span class="cx"> 
</span><del>-    return false;
-}
-
</del><span class="cx"> bool TextureStorage9::isRenderTarget() const
</span><span class="cx"> {
</span><span class="cx">     return (mD3DUsage &amp; (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0;
</span><span class="lines">@@ -98,17 +78,18 @@
</span><span class="cx">     return mD3DUsage;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int TextureStorage9::getLodOffset() const
</del><ins>+int TextureStorage9::getTopLevel() const
</ins><span class="cx"> {
</span><del>-    return mLodOffset;
</del><ins>+    return mTopLevel;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int TextureStorage9::levelCount()
</del><ins>+int TextureStorage9::getLevelCount() const
</ins><span class="cx"> {
</span><del>-    return getBaseTexture() ? getBaseTexture()-&gt;GetLevelCount() - getLodOffset() : 0;
</del><ins>+    return getBaseTexture() ? (getBaseTexture()-&gt;GetLevelCount() - getTopLevel()) : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorage9_2D::TextureStorage9_2D(Renderer *renderer, SwapChain9 *swapchain) : TextureStorage9(renderer, D3DUSAGE_RENDERTARGET)
</del><ins>+TextureStorage9_2D::TextureStorage9_2D(Renderer *renderer, SwapChain9 *swapchain)
+    : TextureStorage9(renderer, D3DUSAGE_RENDERTARGET)
</ins><span class="cx"> {
</span><span class="cx">     IDirect3DTexture9 *surfaceTexture = swapchain-&gt;getOffscreenTexture();
</span><span class="cx">     mTexture = surfaceTexture;
</span><span class="lines">@@ -117,8 +98,8 @@
</span><span class="cx">     initializeRenderTarget();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorage9_2D::TextureStorage9_2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height)
-    : TextureStorage9(renderer, GetTextureUsage(Renderer9::makeRenderer9(renderer)-&gt;ConvertTextureInternalFormat(internalformat), usage, forceRenderable))
</del><ins>+TextureStorage9_2D::TextureStorage9_2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
+    : TextureStorage9(renderer, GetTextureUsage(internalformat, Renderer9::makeRenderer9(renderer), renderTarget))
</ins><span class="cx"> {
</span><span class="cx">     mTexture = NULL;
</span><span class="cx">     mRenderTarget = NULL;
</span><span class="lines">@@ -127,10 +108,12 @@
</span><span class="cx">     if (width &gt; 0 &amp;&amp; height &gt; 0)
</span><span class="cx">     {
</span><span class="cx">         IDirect3DDevice9 *device = mRenderer-&gt;getDevice();
</span><del>-        gl::MakeValidSize(false, gl::IsCompressed(internalformat), &amp;width, &amp;height, &amp;mLodOffset);
-        HRESULT result = device-&gt;CreateTexture(width, height, levels ? levels + mLodOffset : 0, getUsage(),
-                                               mRenderer-&gt;ConvertTextureInternalFormat(internalformat), getPool(), &amp;mTexture, NULL);
</del><ins>+        D3DFORMAT format = gl_d3d9::GetTextureFormat(internalformat, mRenderer);
+        d3d9::MakeValidSize(false, format, &amp;width, &amp;height, &amp;mTopLevel);
+        UINT creationLevels = (levels == 0) ? 0 : mTopLevel + levels;
</ins><span class="cx"> 
</span><ins>+        HRESULT result = device-&gt;CreateTexture(width, height, creationLevels, getUsage(), format, getPool(), &amp;mTexture, NULL);
+
</ins><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="cx">             ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
</span><span class="lines">@@ -143,12 +126,8 @@
</span><span class="cx"> 
</span><span class="cx"> TextureStorage9_2D::~TextureStorage9_2D()
</span><span class="cx"> {
</span><del>-    if (mTexture)
-    {
-        mTexture-&gt;Release();
-    }
-
-    delete mRenderTarget;
</del><ins>+    SafeRelease(mTexture);
+    SafeDelete(mRenderTarget);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureStorage9_2D *TextureStorage9_2D::makeTextureStorage9_2D(TextureStorage *storage)
</span><span class="lines">@@ -165,11 +144,11 @@
</span><span class="cx"> 
</span><span class="cx">     if (mTexture)
</span><span class="cx">     {
</span><del>-        HRESULT result = mTexture-&gt;GetSurfaceLevel(level + mLodOffset, &amp;surface);
</del><ins>+        HRESULT result = mTexture-&gt;GetSurfaceLevel(level + mTopLevel, &amp;surface);
</ins><span class="cx">         ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><span class="cx">         // With managed textures the driver needs to be informed of updates to the lower mipmap levels
</span><del>-        if (level + mLodOffset != 0 &amp;&amp; isManaged() &amp;&amp; dirty)
</del><ins>+        if (level + mTopLevel != 0 &amp;&amp; isManaged() &amp;&amp; dirty)
</ins><span class="cx">         {
</span><span class="cx">             mTexture-&gt;AddDirtyRect(NULL);
</span><span class="cx">         }
</span><span class="lines">@@ -178,7 +157,7 @@
</span><span class="cx">     return surface;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget *TextureStorage9_2D::getRenderTarget()
</del><ins>+RenderTarget *TextureStorage9_2D::getRenderTarget(int level)
</ins><span class="cx"> {
</span><span class="cx">     return mRenderTarget;
</span><span class="cx"> }
</span><span class="lines">@@ -193,8 +172,8 @@
</span><span class="cx">         mRenderer-&gt;boxFilter(upper, lower);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (upper != NULL) upper-&gt;Release();
-    if (lower != NULL) lower-&gt;Release();
</del><ins>+    SafeRelease(upper);
+    SafeRelease(lower);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IDirect3DBaseTexture9 *TextureStorage9_2D::getBaseTexture() const
</span><span class="lines">@@ -214,8 +193,8 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureStorage9_Cube::TextureStorage9_Cube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size)
-    : TextureStorage9(renderer, GetTextureUsage(Renderer9::makeRenderer9(renderer)-&gt;ConvertTextureInternalFormat(internalformat), usage, forceRenderable))
</del><ins>+TextureStorage9_Cube::TextureStorage9_Cube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels)
+    : TextureStorage9(renderer, GetTextureUsage(internalformat, Renderer9::makeRenderer9(renderer), renderTarget))
</ins><span class="cx"> {
</span><span class="cx">     mTexture = NULL;
</span><span class="cx">     for (int i = 0; i &lt; 6; ++i)
</span><span class="lines">@@ -229,10 +208,12 @@
</span><span class="cx">     {
</span><span class="cx">         IDirect3DDevice9 *device = mRenderer-&gt;getDevice();
</span><span class="cx">         int height = size;
</span><del>-        gl::MakeValidSize(false, gl::IsCompressed(internalformat), &amp;size, &amp;height, &amp;mLodOffset);
-        HRESULT result = device-&gt;CreateCubeTexture(size, levels ? levels + mLodOffset : 0, getUsage(),
-                                                   mRenderer-&gt;ConvertTextureInternalFormat(internalformat), getPool(), &amp;mTexture, NULL);
</del><ins>+        D3DFORMAT format = gl_d3d9::GetTextureFormat(internalformat, mRenderer);
+        d3d9::MakeValidSize(false, format, &amp;size, &amp;height, &amp;mTopLevel);
+        UINT creationLevels = (levels == 0) ? 0 : mTopLevel + levels;
</ins><span class="cx"> 
</span><ins>+        HRESULT result = device-&gt;CreateCubeTexture(size, creationLevels, getUsage(), format, getPool(), &amp;mTexture, NULL);
+
</ins><span class="cx">         if (FAILED(result))
</span><span class="cx">         {
</span><span class="cx">             ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
</span><span class="lines">@@ -245,14 +226,11 @@
</span><span class="cx"> 
</span><span class="cx"> TextureStorage9_Cube::~TextureStorage9_Cube()
</span><span class="cx"> {
</span><del>-    if (mTexture)
-    {
-        mTexture-&gt;Release();
-    }
</del><ins>+    SafeRelease(mTexture);
</ins><span class="cx"> 
</span><span class="cx">     for (int i = 0; i &lt; 6; ++i)
</span><span class="cx">     {
</span><del>-        delete mRenderTarget[i];
</del><ins>+        SafeDelete(mRenderTarget[i]);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -271,7 +249,7 @@
</span><span class="cx">     if (mTexture)
</span><span class="cx">     {
</span><span class="cx">         D3DCUBEMAP_FACES face = gl_d3d9::ConvertCubeFace(faceTarget);
</span><del>-        HRESULT result = mTexture-&gt;GetCubeMapSurface(face, level + mLodOffset, &amp;surface);
</del><ins>+        HRESULT result = mTexture-&gt;GetCubeMapSurface(face, level + mTopLevel, &amp;surface);
</ins><span class="cx">         ASSERT(SUCCEEDED(result));
</span><span class="cx"> 
</span><span class="cx">         // With managed textures the driver needs to be informed of updates to the lower mipmap levels
</span><span class="lines">@@ -284,23 +262,23 @@
</span><span class="cx">     return surface;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderTarget *TextureStorage9_Cube::getRenderTarget(GLenum faceTarget)
</del><ins>+RenderTarget *TextureStorage9_Cube::getRenderTargetFace(GLenum faceTarget, int level)
</ins><span class="cx"> {
</span><del>-    return mRenderTarget[gl::TextureCubeMap::faceIndex(faceTarget)];
</del><ins>+    return mRenderTarget[gl::TextureCubeMap::targetToIndex(faceTarget)];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureStorage9_Cube::generateMipmap(int face, int level)
</del><ins>+void TextureStorage9_Cube::generateMipmap(int faceIndex, int level)
</ins><span class="cx"> {
</span><del>-    IDirect3DSurface9 *upper = getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level - 1, false);
-    IDirect3DSurface9 *lower = getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, true);
</del><ins>+    IDirect3DSurface9 *upper = getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level - 1, false);
+    IDirect3DSurface9 *lower = getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, true);
</ins><span class="cx"> 
</span><span class="cx">     if (upper != NULL &amp;&amp; lower != NULL)
</span><span class="cx">     {
</span><span class="cx">         mRenderer-&gt;boxFilter(upper, lower);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (upper != NULL) upper-&gt;Release();
-    if (lower != NULL) lower-&gt;Release();
</del><ins>+    SafeRelease(upper);
+    SafeRelease(lower);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IDirect3DBaseTexture9 *TextureStorage9_Cube::getBaseTexture() const
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9TextureStorage9h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/TextureStorage9.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/TextureStorage9.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/TextureStorage9.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> //
</span><del>-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> // Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> // found in the LICENSE file.
</span><span class="cx"> //
</span><span class="lines">@@ -20,37 +20,37 @@
</span><span class="cx"> class SwapChain9;
</span><span class="cx"> class RenderTarget;
</span><span class="cx"> class RenderTarget9;
</span><del>-class Blit;
</del><span class="cx"> 
</span><span class="cx"> class TextureStorage9 : public TextureStorage
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    TextureStorage9(Renderer *renderer, DWORD usage);
</del><span class="cx">     virtual ~TextureStorage9();
</span><span class="cx"> 
</span><span class="cx">     static TextureStorage9 *makeTextureStorage9(TextureStorage *storage);
</span><span class="cx"> 
</span><del>-    static DWORD GetTextureUsage(D3DFORMAT d3dfmt, GLenum glusage, bool forceRenderable);
-    static bool IsTextureFormatRenderable(D3DFORMAT format);
</del><ins>+    static DWORD GetTextureUsage(GLenum internalformat, Renderer9 *renderer, bool renderTarget);
</ins><span class="cx"> 
</span><span class="cx">     D3DPOOL getPool() const;
</span><span class="cx">     DWORD getUsage() const;
</span><span class="cx"> 
</span><span class="cx">     virtual IDirect3DBaseTexture9 *getBaseTexture() const = 0;
</span><del>-    virtual RenderTarget *getRenderTarget() { return NULL; }
-    virtual RenderTarget *getRenderTarget(GLenum faceTarget) { return NULL; }
</del><ins>+    virtual RenderTarget *getRenderTarget(int level) { return NULL; }
+    virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level) { return NULL; }
+    virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer) { return NULL; }
</ins><span class="cx">     virtual void generateMipmap(int level) {};
</span><span class="cx">     virtual void generateMipmap(int face, int level) {};
</span><span class="cx"> 
</span><del>-    virtual int getLodOffset() const;
</del><ins>+    virtual int getTopLevel() const;
</ins><span class="cx">     virtual bool isRenderTarget() const;
</span><span class="cx">     virtual bool isManaged() const;
</span><del>-    virtual int levelCount();
</del><ins>+    virtual int getLevelCount() const;
</ins><span class="cx"> 
</span><span class="cx">   protected:
</span><del>-    int mLodOffset;
</del><ins>+    int mTopLevel;
</ins><span class="cx">     Renderer9 *mRenderer;
</span><span class="cx"> 
</span><ins>+    TextureStorage9(Renderer *renderer, DWORD usage);
+
</ins><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TextureStorage9);
</span><span class="cx"> 
</span><span class="lines">@@ -62,13 +62,13 @@
</span><span class="cx"> {
</span><span class="cx">   public:
</span><span class="cx">     TextureStorage9_2D(Renderer *renderer, SwapChain9 *swapchain);
</span><del>-    TextureStorage9_2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height);
</del><ins>+    TextureStorage9_2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
</ins><span class="cx">     virtual ~TextureStorage9_2D();
</span><span class="cx"> 
</span><span class="cx">     static TextureStorage9_2D *makeTextureStorage9_2D(TextureStorage *storage);
</span><span class="cx"> 
</span><span class="cx">     IDirect3DSurface9 *getSurfaceLevel(int level, bool dirty);
</span><del>-    virtual RenderTarget *getRenderTarget();
</del><ins>+    virtual RenderTarget *getRenderTarget(int level);
</ins><span class="cx">     virtual IDirect3DBaseTexture9 *getBaseTexture() const;
</span><span class="cx">     virtual void generateMipmap(int level);
</span><span class="cx"> 
</span><span class="lines">@@ -84,15 +84,15 @@
</span><span class="cx"> class TextureStorage9_Cube : public TextureStorage9
</span><span class="cx"> {
</span><span class="cx">   public:
</span><del>-    TextureStorage9_Cube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size);
</del><ins>+    TextureStorage9_Cube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels);
</ins><span class="cx">     virtual ~TextureStorage9_Cube();
</span><span class="cx"> 
</span><span class="cx">     static TextureStorage9_Cube *makeTextureStorage9_Cube(TextureStorage *storage);
</span><span class="cx"> 
</span><span class="cx">     IDirect3DSurface9 *getCubeMapSurface(GLenum faceTarget, int level, bool dirty);
</span><del>-    virtual RenderTarget *getRenderTarget(GLenum faceTarget);
</del><ins>+    virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level);
</ins><span class="cx">     virtual IDirect3DBaseTexture9 *getBaseTexture() const;
</span><del>-    virtual void generateMipmap(int face, int level);
</del><ins>+    virtual void generateMipmap(int faceIndex, int level);
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     DISALLOW_COPY_AND_ASSIGN(TextureStorage9_Cube);
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9VertexBuffer9cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -8,48 +8,32 @@
</span><span class="cx"> // VertexBuffer9.cpp: Defines the D3D9 VertexBuffer implementation.
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/VertexBuffer9.h&quot;
</span><del>-#include &quot;libGLESv2/renderer/d3d9/vertexconversion.h&quot;
</del><ins>+#include &quot;libGLESv2/renderer/vertexconversion.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/BufferStorage.h&quot;
</span><del>-#include &quot;libGLESv2/Context.h&quot;
</del><ins>+#include &quot;libGLESv2/VertexAttribute.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/Renderer9.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d9/formatutils9.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/Buffer.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-bool VertexBuffer9::mTranslationsInitialized = false;
-VertexBuffer9::FormatConverter VertexBuffer9::mFormatConverters[NUM_GL_VERTEX_ATTRIB_TYPES][2][4];
-
</del><span class="cx"> VertexBuffer9::VertexBuffer9(rx::Renderer9 *const renderer) : mRenderer(renderer)
</span><span class="cx"> {
</span><span class="cx">     mVertexBuffer = NULL;
</span><span class="cx">     mBufferSize = 0;
</span><span class="cx">     mDynamicUsage = false;
</span><del>-
-    if (!mTranslationsInitialized)
-    {
-        initializeTranslations(renderer-&gt;getCapsDeclTypes());
-        mTranslationsInitialized = true;
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> VertexBuffer9::~VertexBuffer9()
</span><span class="cx"> {
</span><del>-    if (mVertexBuffer)
-    {
-        mVertexBuffer-&gt;Release();
-        mVertexBuffer = NULL;
-    }
</del><ins>+    SafeRelease(mVertexBuffer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool VertexBuffer9::initialize(unsigned int size, bool dynamicUsage)
</span><span class="cx"> {
</span><del>-    if (mVertexBuffer)
-    {
-        mVertexBuffer-&gt;Release();
-        mVertexBuffer = NULL;
-    }
</del><ins>+    SafeRelease(mVertexBuffer);
</ins><span class="cx"> 
</span><span class="cx">     updateSerial();
</span><span class="cx"> 
</span><span class="lines">@@ -81,8 +65,8 @@
</span><span class="cx">     return static_cast&lt;VertexBuffer9*&gt;(vertexBuffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &amp;attrib, GLint start, GLsizei count,
-                                             GLsizei instances, unsigned int offset)
</del><ins>+bool VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &amp;attrib, const gl::VertexAttribCurrentValueData &amp;currentValue,
+                                          GLint start, GLsizei count, GLsizei instances, unsigned int offset)
</ins><span class="cx"> {
</span><span class="cx">     if (mVertexBuffer)
</span><span class="cx">     {
</span><span class="lines">@@ -90,7 +74,6 @@
</span><span class="cx"> 
</span><span class="cx">         int inputStride = attrib.stride();
</span><span class="cx">         int elementSize = attrib.typeSize();
</span><del>-        const FormatConverter &amp;converter = formatConverter(attrib);
</del><span class="cx"> 
</span><span class="cx">         DWORD lockFlags = mDynamicUsage ? D3DLOCK_NOOVERWRITE : 0;
</span><span class="cx"> 
</span><span class="lines">@@ -111,14 +94,21 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         const char *input = NULL;
</span><del>-        if (buffer)
</del><ins>+        if (attrib.mArrayEnabled)
</ins><span class="cx">         {
</span><del>-            BufferStorage *storage = buffer-&gt;getStorage();
-            input = static_cast&lt;const char*&gt;(storage-&gt;getData()) + static_cast&lt;int&gt;(attrib.mOffset);
</del><ins>+            if (buffer)
+            {
+                BufferStorage *storage = buffer-&gt;getStorage();
+                input = static_cast&lt;const char*&gt;(storage-&gt;getData()) + static_cast&lt;int&gt;(attrib.mOffset);
+            }
+            else
+            {
+                input = static_cast&lt;const char*&gt;(attrib.mPointer);
+            }
</ins><span class="cx">         }
</span><span class="cx">         else
</span><span class="cx">         {
</span><del>-            input = static_cast&lt;const char*&gt;(attrib.mPointer);
</del><ins>+            input = reinterpret_cast&lt;const char*&gt;(currentValue.FloatValues);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (instances == 0 || attrib.mDivisor == 0)
</span><span class="lines">@@ -126,13 +116,17 @@
</span><span class="cx">             input += inputStride * start;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (converter.identity &amp;&amp; inputStride == elementSize)
</del><ins>+        gl::VertexFormat vertexFormat(attrib, currentValue.Type);
+        bool needsConversion = (d3d9::GetVertexConversionType(vertexFormat) &amp; VERTEX_CONVERT_CPU) &gt; 0;
+
+        if (!needsConversion &amp;&amp; inputStride == elementSize)
</ins><span class="cx">         {
</span><span class="cx">             memcpy(mapPtr, input, count * inputStride);
</span><span class="cx">         }
</span><span class="cx">         else
</span><span class="cx">         {
</span><del>-            converter.convertArray(input, inputStride, count, mapPtr);
</del><ins>+            VertexCopyFunction copyFunction = d3d9::GetVertexCopyFunction(vertexFormat);
+            copyFunction(input, inputStride, count, mapPtr);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         mVertexBuffer-&gt;Unlock();
</span><span class="lines">@@ -146,56 +140,12 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool VertexBuffer9::storeRawData(const void* data, unsigned int size, unsigned int offset)
-{
-    if (mVertexBuffer)
-    {
-        DWORD lockFlags = mDynamicUsage ? D3DLOCK_NOOVERWRITE : 0;
-
-        void *mapPtr = NULL;
-        HRESULT result = mVertexBuffer-&gt;Lock(offset, size, &amp;mapPtr, lockFlags);
-
-        if (FAILED(result))
-        {
-            ERR(&quot;Lock failed with error 0x%08x&quot;, result);
-            return false;
-        }
-
-        memcpy(mapPtr, data, size);
-
-        mVertexBuffer-&gt;Unlock();
-
-        return true;
-    }
-    else
-    {
-        ERR(&quot;Vertex buffer not initialized.&quot;);
-        return false;
-    }
-}
-
</del><span class="cx"> bool VertexBuffer9::getSpaceRequired(const gl::VertexAttribute &amp;attrib, GLsizei count, GLsizei instances,
</span><span class="cx">                                      unsigned int *outSpaceRequired) const
</span><span class="cx"> {
</span><span class="cx">     return spaceRequired(attrib, count, instances, outSpaceRequired);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool VertexBuffer9::requiresConversion(const gl::VertexAttribute &amp;attrib) const
-{
-    return !formatConverter(attrib).identity;
-}
-
-unsigned int VertexBuffer9::getVertexSize(const gl::VertexAttribute &amp;attrib) const
-{
-    unsigned int spaceRequired;
-    return getSpaceRequired(attrib, 1, 0, &amp;spaceRequired) ? spaceRequired : 0;
-}
-
-D3DDECLTYPE VertexBuffer9::getDeclType(const gl::VertexAttribute &amp;attrib) const
-{
-    return formatConverter(attrib).d3dDeclType;
-}
-
</del><span class="cx"> unsigned int VertexBuffer9::getBufferSize() const
</span><span class="cx"> {
</span><span class="cx">     return mBufferSize;
</span><span class="lines">@@ -248,240 +198,11 @@
</span><span class="cx">     return mVertexBuffer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Mapping from OpenGL-ES vertex attrib type to D3D decl type:
-//
-// BYTE                 SHORT (Cast)
-// BYTE-norm            FLOAT (Normalize) (can't be exactly represented as SHORT-norm)
-// UNSIGNED_BYTE        UBYTE4 (Identity) or SHORT (Cast)
-// UNSIGNED_BYTE-norm   UBYTE4N (Identity) or FLOAT (Normalize)
-// SHORT                SHORT (Identity)
-// SHORT-norm           SHORT-norm (Identity) or FLOAT (Normalize)
-// UNSIGNED_SHORT       FLOAT (Cast)
-// UNSIGNED_SHORT-norm  USHORT-norm (Identity) or FLOAT (Normalize)
-// FIXED (not in WebGL) FLOAT (FixedToFloat)
-// FLOAT                FLOAT (Identity)
-
-// GLToCType maps from GL type (as GLenum) to the C typedef.
-template &lt;GLenum GLType&gt; struct GLToCType { };
-
-template &lt;&gt; struct GLToCType&lt;GL_BYTE&gt;           { typedef GLbyte type;      };
-template &lt;&gt; struct GLToCType&lt;GL_UNSIGNED_BYTE&gt;  { typedef GLubyte type;     };
-template &lt;&gt; struct GLToCType&lt;GL_SHORT&gt;          { typedef GLshort type;     };
-template &lt;&gt; struct GLToCType&lt;GL_UNSIGNED_SHORT&gt; { typedef GLushort type;    };
-template &lt;&gt; struct GLToCType&lt;GL_FIXED&gt;          { typedef GLuint type;      };
-template &lt;&gt; struct GLToCType&lt;GL_FLOAT&gt;          { typedef GLfloat type;     };
-
-// This differs from D3DDECLTYPE in that it is unsized. (Size expansion is applied last.)
-enum D3DVertexType
-{
-    D3DVT_FLOAT,
-    D3DVT_SHORT,
-    D3DVT_SHORT_NORM,
-    D3DVT_UBYTE,
-    D3DVT_UBYTE_NORM,
-    D3DVT_USHORT_NORM
-};
-
-// D3DToCType maps from D3D vertex type (as enum D3DVertexType) to the corresponding C type.
-template &lt;unsigned int D3DType&gt; struct D3DToCType { };
-
-template &lt;&gt; struct D3DToCType&lt;D3DVT_FLOAT&gt; { typedef float type; };
-template &lt;&gt; struct D3DToCType&lt;D3DVT_SHORT&gt; { typedef short type; };
-template &lt;&gt; struct D3DToCType&lt;D3DVT_SHORT_NORM&gt; { typedef short type; };
-template &lt;&gt; struct D3DToCType&lt;D3DVT_UBYTE&gt; { typedef unsigned char type; };
-template &lt;&gt; struct D3DToCType&lt;D3DVT_UBYTE_NORM&gt; { typedef unsigned char type; };
-template &lt;&gt; struct D3DToCType&lt;D3DVT_USHORT_NORM&gt; { typedef unsigned short type; };
-
-// Encode the type/size combinations that D3D permits. For each type/size it expands to a widener that will provide the appropriate final size.
-template &lt;unsigned int type, int size&gt; struct WidenRule { };
-
-template &lt;int size&gt; struct WidenRule&lt;D3DVT_FLOAT, size&gt;          : NoWiden&lt;size&gt; { };
-template &lt;int size&gt; struct WidenRule&lt;D3DVT_SHORT, size&gt;          : WidenToEven&lt;size&gt; { };
-template &lt;int size&gt; struct WidenRule&lt;D3DVT_SHORT_NORM, size&gt;     : WidenToEven&lt;size&gt; { };
-template &lt;int size&gt; struct WidenRule&lt;D3DVT_UBYTE, size&gt;          : WidenToFour&lt;size&gt; { };
-template &lt;int size&gt; struct WidenRule&lt;D3DVT_UBYTE_NORM, size&gt;     : WidenToFour&lt;size&gt; { };
-template &lt;int size&gt; struct WidenRule&lt;D3DVT_USHORT_NORM, size&gt;    : WidenToEven&lt;size&gt; { };
-
-// VertexTypeFlags encodes the D3DCAPS9::DeclType flag and vertex declaration flag for each D3D vertex type &amp; size combination.
-template &lt;unsigned int d3dtype, int size&gt; struct VertexTypeFlags { };
-
-template &lt;unsigned int _capflag, unsigned int _declflag&gt;
-struct VertexTypeFlagsHelper
-{
-    enum { capflag = _capflag };
-    enum { declflag = _declflag };
-};
-
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_FLOAT, 1&gt; : VertexTypeFlagsHelper&lt;0, D3DDECLTYPE_FLOAT1&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_FLOAT, 2&gt; : VertexTypeFlagsHelper&lt;0, D3DDECLTYPE_FLOAT2&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_FLOAT, 3&gt; : VertexTypeFlagsHelper&lt;0, D3DDECLTYPE_FLOAT3&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_FLOAT, 4&gt; : VertexTypeFlagsHelper&lt;0, D3DDECLTYPE_FLOAT4&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_SHORT, 2&gt; : VertexTypeFlagsHelper&lt;0, D3DDECLTYPE_SHORT2&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_SHORT, 4&gt; : VertexTypeFlagsHelper&lt;0, D3DDECLTYPE_SHORT4&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_SHORT_NORM, 2&gt; : VertexTypeFlagsHelper&lt;D3DDTCAPS_SHORT2N, D3DDECLTYPE_SHORT2N&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_SHORT_NORM, 4&gt; : VertexTypeFlagsHelper&lt;D3DDTCAPS_SHORT4N, D3DDECLTYPE_SHORT4N&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_UBYTE, 4&gt; : VertexTypeFlagsHelper&lt;D3DDTCAPS_UBYTE4, D3DDECLTYPE_UBYTE4&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_UBYTE_NORM, 4&gt; : VertexTypeFlagsHelper&lt;D3DDTCAPS_UBYTE4N, D3DDECLTYPE_UBYTE4N&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_USHORT_NORM, 2&gt; : VertexTypeFlagsHelper&lt;D3DDTCAPS_USHORT2N, D3DDECLTYPE_USHORT2N&gt; { };
-template &lt;&gt; struct VertexTypeFlags&lt;D3DVT_USHORT_NORM, 4&gt; : VertexTypeFlagsHelper&lt;D3DDTCAPS_USHORT4N, D3DDECLTYPE_USHORT4N&gt; { };
-
-
-// VertexTypeMapping maps GL type &amp; normalized flag to preferred and fallback D3D vertex types (as D3DVertexType enums).
-template &lt;GLenum GLtype, bool normalized&gt; struct VertexTypeMapping { };
-
-template &lt;D3DVertexType Preferred, D3DVertexType Fallback = Preferred&gt;
-struct VertexTypeMappingBase
-{
-    enum { preferred = Preferred };
-    enum { fallback = Fallback };
-};
-
-template &lt;&gt; struct VertexTypeMapping&lt;GL_BYTE, false&gt;                        : VertexTypeMappingBase&lt;D3DVT_SHORT&gt; { };                       // Cast
-template &lt;&gt; struct VertexTypeMapping&lt;GL_BYTE, true&gt;                         : VertexTypeMappingBase&lt;D3DVT_FLOAT&gt; { };                       // Normalize
-template &lt;&gt; struct VertexTypeMapping&lt;GL_UNSIGNED_BYTE, false&gt;               : VertexTypeMappingBase&lt;D3DVT_UBYTE, D3DVT_FLOAT&gt; { };          // Identity, Cast
-template &lt;&gt; struct VertexTypeMapping&lt;GL_UNSIGNED_BYTE, true&gt;                : VertexTypeMappingBase&lt;D3DVT_UBYTE_NORM, D3DVT_FLOAT&gt; { };     // Identity, Normalize
-template &lt;&gt; struct VertexTypeMapping&lt;GL_SHORT, false&gt;                       : VertexTypeMappingBase&lt;D3DVT_SHORT&gt; { };                       // Identity
-template &lt;&gt; struct VertexTypeMapping&lt;GL_SHORT, true&gt;                        : VertexTypeMappingBase&lt;D3DVT_SHORT_NORM, D3DVT_FLOAT&gt; { };     // Cast, Normalize
-template &lt;&gt; struct VertexTypeMapping&lt;GL_UNSIGNED_SHORT, false&gt;              : VertexTypeMappingBase&lt;D3DVT_FLOAT&gt; { };                       // Cast
-template &lt;&gt; struct VertexTypeMapping&lt;GL_UNSIGNED_SHORT, true&gt;               : VertexTypeMappingBase&lt;D3DVT_USHORT_NORM, D3DVT_FLOAT&gt; { };    // Cast, Normalize
-template &lt;bool normalized&gt; struct VertexTypeMapping&lt;GL_FIXED, normalized&gt;   : VertexTypeMappingBase&lt;D3DVT_FLOAT&gt; { };                       // FixedToFloat
-template &lt;bool normalized&gt; struct VertexTypeMapping&lt;GL_FLOAT, normalized&gt;   : VertexTypeMappingBase&lt;D3DVT_FLOAT&gt; { };                       // Identity
-
-
-// Given a GL type &amp; norm flag and a D3D type, ConversionRule provides the type conversion rule (Cast, Normalize, Identity, FixedToFloat).
-// The conversion rules themselves are defined in vertexconversion.h.
-
-// Almost all cases are covered by Cast (including those that are actually Identity since Cast&lt;T,T&gt; knows it's an identity mapping).
-template &lt;GLenum fromType, bool normalized, unsigned int toType&gt;
-struct ConversionRule : Cast&lt;typename GLToCType&lt;fromType&gt;::type, typename D3DToCType&lt;toType&gt;::type&gt; { };
-
-// All conversions from normalized types to float use the Normalize operator.
-template &lt;GLenum fromType&gt; struct ConversionRule&lt;fromType, true, D3DVT_FLOAT&gt; : Normalize&lt;typename GLToCType&lt;fromType&gt;::type&gt; { };
-
-// Use a full specialization for this so that it preferentially matches ahead of the generic normalize-to-float rules.
-template &lt;&gt; struct ConversionRule&lt;GL_FIXED, true, D3DVT_FLOAT&gt;  : FixedToFloat&lt;GLint, 16&gt; { };
-template &lt;&gt; struct ConversionRule&lt;GL_FIXED, false, D3DVT_FLOAT&gt; : FixedToFloat&lt;GLint, 16&gt; { };
-
-// A 2-stage construction is used for DefaultVertexValues because float must use SimpleDefaultValues (i.e. 0/1)
-// whether it is normalized or not.
-template &lt;class T, bool normalized&gt; struct DefaultVertexValuesStage2 { };
-
-template &lt;class T&gt; struct DefaultVertexValuesStage2&lt;T, true&gt;  : NormalizedDefaultValues&lt;T&gt; { };
-template &lt;class T&gt; struct DefaultVertexValuesStage2&lt;T, false&gt; : SimpleDefaultValues&lt;T&gt; { };
-
-// Work out the default value rule for a D3D type (expressed as the C type) and
-template &lt;class T, bool normalized&gt; struct DefaultVertexValues : DefaultVertexValuesStage2&lt;T, normalized&gt; { };
-template &lt;bool normalized&gt; struct DefaultVertexValues&lt;float, normalized&gt; : SimpleDefaultValues&lt;float&gt; { };
-
-// Policy rules for use with Converter, to choose whether to use the preferred or fallback conversion.
-// The fallback conversion produces an output that all D3D9 devices must support.
-template &lt;class T&gt; struct UsePreferred { enum { type = T::preferred }; };
-template &lt;class T&gt; struct UseFallback { enum { type = T::fallback }; };
-
-// Converter ties it all together. Given an OpenGL type/norm/size and choice of preferred/fallback conversion,
-// it provides all the members of the appropriate VertexDataConverter, the D3DCAPS9::DeclTypes flag in cap flag
-// and the D3DDECLTYPE member needed for the vertex declaration in declflag.
-template &lt;GLenum fromType, bool normalized, int size, template &lt;class T&gt; class PreferenceRule&gt;
-struct Converter
-    : VertexDataConverter&lt;typename GLToCType&lt;fromType&gt;::type,
-                          WidenRule&lt;PreferenceRule&lt; VertexTypeMapping&lt;fromType, normalized&gt; &gt;::type, size&gt;,
-                          ConversionRule&lt;fromType,
-                                         normalized,
-                                         PreferenceRule&lt; VertexTypeMapping&lt;fromType, normalized&gt; &gt;::type&gt;,
-                          DefaultVertexValues&lt;typename D3DToCType&lt;PreferenceRule&lt; VertexTypeMapping&lt;fromType, normalized&gt; &gt;::type&gt;::type, normalized &gt; &gt;
-{
-private:
-    enum { d3dtype = PreferenceRule&lt; VertexTypeMapping&lt;fromType, normalized&gt; &gt;::type };
-    enum { d3dsize = WidenRule&lt;d3dtype, size&gt;::finalWidth };
-
-public:
-    enum { capflag = VertexTypeFlags&lt;d3dtype, d3dsize&gt;::capflag };
-    enum { declflag = VertexTypeFlags&lt;d3dtype, d3dsize&gt;::declflag };
-};
-
-// Initialize a TranslationInfo
-#define TRANSLATION(type, norm, size, preferred)                                    \
-    {                                                                               \
-        Converter&lt;type, norm, size, preferred&gt;::identity,                           \
-        Converter&lt;type, norm, size, preferred&gt;::finalSize,                          \
-        Converter&lt;type, norm, size, preferred&gt;::convertArray,                       \
-        static_cast&lt;D3DDECLTYPE&gt;(Converter&lt;type, norm, size, preferred&gt;::declflag)  \
-    }
-
-#define TRANSLATION_FOR_TYPE_NORM_SIZE(type, norm, size)    \
-    {                                                       \
-        Converter&lt;type, norm, size, UsePreferred&gt;::capflag, \
-        TRANSLATION(type, norm, size, UsePreferred),        \
-        TRANSLATION(type, norm, size, UseFallback)          \
-    }
-
-#define TRANSLATIONS_FOR_TYPE(type)                                                                                                                                                                         \
-    {                                                                                                                                                                                                       \
-        { TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 4) }, \
-        { TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 4) },     \
-    }
-
-#define TRANSLATIONS_FOR_TYPE_NO_NORM(type)                                                                                                                                                                 \
-    {                                                                                                                                                                                                       \
-        { TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 4) }, \
-        { TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 4) }, \
-    }
-
-const VertexBuffer9::TranslationDescription VertexBuffer9::mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4] = // [GL types as enumerated by typeIndex()][normalized][size-1]
-{
-    TRANSLATIONS_FOR_TYPE(GL_BYTE),
-    TRANSLATIONS_FOR_TYPE(GL_UNSIGNED_BYTE),
-    TRANSLATIONS_FOR_TYPE(GL_SHORT),
-    TRANSLATIONS_FOR_TYPE(GL_UNSIGNED_SHORT),
-    TRANSLATIONS_FOR_TYPE_NO_NORM(GL_FIXED),
-    TRANSLATIONS_FOR_TYPE_NO_NORM(GL_FLOAT)
-};
-
-void VertexBuffer9::initializeTranslations(DWORD declTypes)
-{
-    for (unsigned int i = 0; i &lt; NUM_GL_VERTEX_ATTRIB_TYPES; i++)
-    {
-        for (unsigned int j = 0; j &lt; 2; j++)
-        {
-            for (unsigned int k = 0; k &lt; 4; k++)
-            {
-                if (mPossibleTranslations[i][j][k].capsFlag == 0 || (declTypes &amp; mPossibleTranslations[i][j][k].capsFlag) != 0)
-                {
-                    mFormatConverters[i][j][k] = mPossibleTranslations[i][j][k].preferredConversion;
-                }
-                else
-                {
-                    mFormatConverters[i][j][k] = mPossibleTranslations[i][j][k].fallbackConversion;
-                }
-            }
-        }
-    }
-}
-
-unsigned int VertexBuffer9::typeIndex(GLenum type)
-{
-    switch (type)
-    {
-      case GL_BYTE: return 0;
-      case GL_UNSIGNED_BYTE: return 1;
-      case GL_SHORT: return 2;
-      case GL_UNSIGNED_SHORT: return 3;
-      case GL_FIXED: return 4;
-      case GL_FLOAT: return 5;
-
-      default: UNREACHABLE(); return 5;
-    }
-}
-
-const VertexBuffer9::FormatConverter &amp;VertexBuffer9::formatConverter(const gl::VertexAttribute &amp;attribute)
-{
-    return mFormatConverters[typeIndex(attribute.mType)][attribute.mNormalized][attribute.mSize - 1];
-}
-
</del><span class="cx"> bool VertexBuffer9::spaceRequired(const gl::VertexAttribute &amp;attrib, std::size_t count, GLsizei instances,
</span><span class="cx">                                   unsigned int *outSpaceRequired)
</span><span class="cx"> {
</span><del>-    unsigned int elementSize = formatConverter(attrib).outputElementSize;
</del><ins>+    gl::VertexFormat vertexFormat(attrib, GL_FLOAT);
+    unsigned int elementSize = d3d9::GetVertexElementSize(vertexFormat);
</ins><span class="cx"> 
</span><span class="cx">     if (attrib.mArrayEnabled)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9VertexBuffer9h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexBuffer9.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexBuffer9.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexBuffer9.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -25,17 +25,11 @@
</span><span class="cx"> 
</span><span class="cx">     static VertexBuffer9 *makeVertexBuffer9(VertexBuffer *vertexBuffer);
</span><span class="cx"> 
</span><del>-    virtual bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, GLint start, GLsizei count, GLsizei instances,
-                                       unsigned int offset);
-    virtual bool storeRawData(const void* data, unsigned int size, unsigned int offset);
</del><ins>+    virtual bool storeVertexAttributes(const gl::VertexAttribute &amp;attrib, const gl::VertexAttribCurrentValueData &amp;currentValue,
+                                       GLint start, GLsizei count, GLsizei instances, unsigned int offset);
</ins><span class="cx"> 
</span><span class="cx">     virtual bool getSpaceRequired(const gl::VertexAttribute &amp;attrib, GLsizei count, GLsizei instances, unsigned int *outSpaceRequired) const;
</span><span class="cx"> 
</span><del>-    virtual bool requiresConversion(const gl::VertexAttribute &amp;attrib) const;
-
-    unsigned int getVertexSize(const gl::VertexAttribute &amp;attrib) const;
-    D3DDECLTYPE getDeclType(const gl::VertexAttribute &amp;attrib) const;
-
</del><span class="cx">     virtual unsigned int getBufferSize() const;
</span><span class="cx">     virtual bool setBufferSize(unsigned int size);
</span><span class="cx">     virtual bool discard();
</span><span class="lines">@@ -51,37 +45,6 @@
</span><span class="cx">     unsigned int mBufferSize;
</span><span class="cx">     bool mDynamicUsage;
</span><span class="cx"> 
</span><del>-    // Attribute format conversion
-    enum { NUM_GL_VERTEX_ATTRIB_TYPES = 6 };
-
-    struct FormatConverter
-    {
-        bool identity;
-        std::size_t outputElementSize;
-        void (*convertArray)(const void *in, std::size_t stride, std::size_t n, void *out);
-        D3DDECLTYPE d3dDeclType;
-    };
-
-    static bool mTranslationsInitialized;
-    static void initializeTranslations(DWORD declTypes);
-
-    // [GL types as enumerated by typeIndex()][normalized][size - 1]
-    static FormatConverter mFormatConverters[NUM_GL_VERTEX_ATTRIB_TYPES][2][4];
-
-    struct TranslationDescription
-    {
-        DWORD capsFlag;
-        FormatConverter preferredConversion;
-        FormatConverter fallbackConversion;
-    };
-
-    // This table is used to generate mFormatConverters.
-    // [GL types as enumerated by typeIndex()][normalized][size - 1]
-    static const TranslationDescription mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4];
-
-    static unsigned int typeIndex(GLenum type);
-    static const FormatConverter &amp;formatConverter(const gl::VertexAttribute &amp;attribute);
-
</del><span class="cx">     static bool spaceRequired(const gl::VertexAttribute &amp;attrib, std::size_t count, GLsizei instances,
</span><span class="cx">                               unsigned int *outSpaceRequired);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9VertexDeclarationCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -8,9 +8,10 @@
</span><span class="cx"> // VertexDeclarationCache.cpp: Implements a helper class to construct and cache vertex declarations.
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/ProgramBinary.h&quot;
</span><del>-#include &quot;libGLESv2/Context.h&quot;
</del><ins>+#include &quot;libGLESv2/VertexAttribute.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/VertexBuffer9.h&quot;
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/VertexDeclarationCache.h&quot;
</span><ins>+#include &quot;libGLESv2/renderer/d3d9/formatutils9.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><span class="lines">@@ -36,10 +37,7 @@
</span><span class="cx"> {
</span><span class="cx">     for (int i = 0; i &lt; NUM_VERTEX_DECL_CACHE_ENTRIES; i++)
</span><span class="cx">     {
</span><del>-        if (mVertexDeclCache[i].vertexDeclaration)
-        {
-            mVertexDeclCache[i].vertexDeclaration-&gt;Release();
-        }
</del><ins>+        SafeRelease(mVertexDeclCache[i].vertexDeclaration);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -134,9 +132,11 @@
</span><span class="cx">                 mAppliedVBs[stream].offset = attributes[i].offset;
</span><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            gl::VertexFormat vertexFormat(*attributes[i].attribute, GL_FLOAT);
+
</ins><span class="cx">             element-&gt;Stream = stream;
</span><span class="cx">             element-&gt;Offset = 0;
</span><del>-            element-&gt;Type = attributes[i].attribute-&gt;mArrayEnabled ? vertexBuffer-&gt;getDeclType(*attributes[i].attribute) : D3DDECLTYPE_FLOAT4;
</del><ins>+            element-&gt;Type = d3d9::GetNativeVertexFormat(vertexFormat);
</ins><span class="cx">             element-&gt;Method = D3DDECLMETHOD_DEFAULT;
</span><span class="cx">             element-&gt;Usage = D3DDECLUSAGE_TEXCOORD;
</span><span class="cx">             element-&gt;UsageIndex = programBinary-&gt;getSemanticIndex(i);
</span><span class="lines">@@ -188,8 +188,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (lastCache-&gt;vertexDeclaration != NULL)
</span><span class="cx">     {
</span><del>-        lastCache-&gt;vertexDeclaration-&gt;Release();
-        lastCache-&gt;vertexDeclaration = NULL;
</del><ins>+        SafeRelease(lastCache-&gt;vertexDeclaration);
</ins><span class="cx">         // mLastSetVDecl is set to the replacement, so we don't have to worry
</span><span class="cx">         // about it.
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9renderer9_utilscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -9,11 +9,14 @@
</span><span class="cx"> // specific to the D3D9 renderer.
</span><span class="cx"> 
</span><span class="cx"> #include &quot;libGLESv2/renderer/d3d9/renderer9_utils.h&quot;
</span><del>-#include &quot;libGLESv2/mathutil.h&quot;
</del><ins>+#include &quot;common/mathutil.h&quot;
</ins><span class="cx"> #include &quot;libGLESv2/Context.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;common/debug.h&quot;
</span><span class="cx"> 
</span><ins>+namespace rx
+{
+
</ins><span class="cx"> namespace gl_d3d9
</span><span class="cx"> {
</span><span class="cx"> 
</span><span class="lines">@@ -36,7 +39,7 @@
</span><span class="cx">     return d3dComp;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-D3DCOLOR ConvertColor(gl::Color color)
</del><ins>+D3DCOLOR ConvertColor(gl::ColorF color)
</ins><span class="cx"> {
</span><span class="cx">     return D3DCOLOR_RGBA(gl::unorm&lt;8&gt;(color.red),
</span><span class="cx">                          gl::unorm&lt;8&gt;(color.green),
</span><span class="lines">@@ -80,6 +83,8 @@
</span><span class="cx">       case GL_FUNC_ADD:              d3dBlendOp = D3DBLENDOP_ADD;         break;
</span><span class="cx">       case GL_FUNC_SUBTRACT:         d3dBlendOp = D3DBLENDOP_SUBTRACT;    break;
</span><span class="cx">       case GL_FUNC_REVERSE_SUBTRACT: d3dBlendOp = D3DBLENDOP_REVSUBTRACT; break;
</span><ins>+      case GL_MIN_EXT:               d3dBlendOp = D3DBLENDOP_MIN;         break;
+      case GL_MAX_EXT:               d3dBlendOp = D3DBLENDOP_MAX;         break;
</ins><span class="cx">       default: UNREACHABLE();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -237,264 +242,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-D3DFORMAT ConvertRenderbufferFormat(GLenum format)
-{
-    switch (format)
-    {
-      case GL_NONE:                 return D3DFMT_NULL;
-      case GL_RGBA4:
-      case GL_RGB5_A1:
-      case GL_RGBA8_OES:            return D3DFMT_A8R8G8B8;
-      case GL_RGB565:               return D3DFMT_R5G6B5;
-      case GL_RGB8_OES:             return D3DFMT_X8R8G8B8;
-      case GL_DEPTH_COMPONENT16:
-      case GL_STENCIL_INDEX8:       
-      case GL_DEPTH24_STENCIL8_OES: return D3DFMT_D24S8;
-      default: UNREACHABLE();       return D3DFMT_A8R8G8B8;
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples)
-{
-    if (samples &lt;= 1)
-        return D3DMULTISAMPLE_NONE;
-    else
-        return (D3DMULTISAMPLE_TYPE)samples;
</del><span class="cx"> }
</span><del>-
-}
-
-namespace d3d9_gl
-{
-
-unsigned int GetStencilSize(D3DFORMAT stencilFormat)
-{
-    if (stencilFormat == D3DFMT_INTZ)
-    {
-        return 8;
-    }
-    switch(stencilFormat)
-    {
-      case D3DFMT_D24FS8:
-      case D3DFMT_D24S8:
-        return 8;
-      case D3DFMT_D24X4S4:
-        return 4;
-      case D3DFMT_D15S1:
-        return 1;
-      case D3DFMT_D16_LOCKABLE:
-      case D3DFMT_D32:
-      case D3DFMT_D24X8:
-      case D3DFMT_D32F_LOCKABLE:
-      case D3DFMT_D16:
-        return 0;
-    //case D3DFMT_D32_LOCKABLE:  return 0;   // DirectX 9Ex only
-    //case D3DFMT_S8_LOCKABLE:   return 8;   // DirectX 9Ex only
-      default:
-        return 0;
-    }
-}
-
-unsigned int GetAlphaSize(D3DFORMAT colorFormat)
-{
-    switch (colorFormat)
-    {
-      case D3DFMT_A16B16G16R16F:
-        return 16;
-      case D3DFMT_A32B32G32R32F:
-        return 32;
-      case D3DFMT_A2R10G10B10:
-        return 2;
-      case D3DFMT_A8R8G8B8:
-        return 8;
-      case D3DFMT_A1R5G5B5:
-        return 1;
-      case D3DFMT_X8R8G8B8:
-      case D3DFMT_R5G6B5:
-        return 0;
-      default:
-        return 0;
-    }
-}
-
-GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type)
-{
-    if (type == D3DMULTISAMPLE_NONMASKABLE)
-        return 0;
-    else
-        return type;
-}
-
-bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format)
-{
-    switch (d3dformat)
-    {
-      case D3DFMT_L8:
-        return (format == GL_LUMINANCE);
-      case D3DFMT_A8L8:
-        return (format == GL_LUMINANCE_ALPHA);
-      case D3DFMT_DXT1:
-        return (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT || format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
-      case D3DFMT_DXT3:
-        return (format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
-      case D3DFMT_DXT5:
-        return (format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
-      case D3DFMT_A8R8G8B8:
-      case D3DFMT_A16B16G16R16F:
-      case D3DFMT_A32B32G32R32F:
-        return (format == GL_RGBA || format == GL_BGRA_EXT);
-      case D3DFMT_X8R8G8B8:
-        return (format == GL_RGB);
-      default:
-        if (d3dformat == D3DFMT_INTZ &amp;&amp; gl::IsDepthTexture(format))
-            return true;
-        return false;
-    }
-}
-
-GLenum ConvertBackBufferFormat(D3DFORMAT format)
-{
-    switch (format)
-    {
-      case D3DFMT_A4R4G4B4: return GL_RGBA4;
-      case D3DFMT_A8R8G8B8: return GL_RGBA8_OES;
-      case D3DFMT_A1R5G5B5: return GL_RGB5_A1;
-      case D3DFMT_R5G6B5:   return GL_RGB565;
-      case D3DFMT_X8R8G8B8: return GL_RGB8_OES;
-      default:
-        UNREACHABLE();
-    }
-
-    return GL_RGBA4;
-}
-
-GLenum ConvertDepthStencilFormat(D3DFORMAT format)
-{
-    if (format == D3DFMT_INTZ)
-    {
-        return GL_DEPTH24_STENCIL8_OES;
-    }
-    switch (format)
-    {
-      case D3DFMT_D16:
-      case D3DFMT_D24X8:
-        return GL_DEPTH_COMPONENT16;
-      case D3DFMT_D24S8:
-        return GL_DEPTH24_STENCIL8_OES;
-      case D3DFMT_UNKNOWN:
-        return GL_NONE;
-      default:
-        UNREACHABLE();
-    }
-
-    return GL_DEPTH24_STENCIL8_OES;
-}
-
-GLenum ConvertRenderTargetFormat(D3DFORMAT format)
-{
-    if (format == D3DFMT_INTZ)
-    {
-        return GL_DEPTH24_STENCIL8_OES;
-    }
-    
-    switch (format)
-    {
-      case D3DFMT_A4R4G4B4: return GL_RGBA4;
-      case D3DFMT_A8R8G8B8: return GL_RGBA8_OES;
-      case D3DFMT_A1R5G5B5: return GL_RGB5_A1;
-      case D3DFMT_R5G6B5:   return GL_RGB565;
-      case D3DFMT_X8R8G8B8: return GL_RGB8_OES;
-      case D3DFMT_D16:
-      case D3DFMT_D24X8:
-        return GL_DEPTH_COMPONENT16;
-      case D3DFMT_D24S8:
-        return GL_DEPTH24_STENCIL8_OES;
-      case D3DFMT_UNKNOWN:
-        return GL_NONE;
-      default:
-        UNREACHABLE();
-    }
-
-    return GL_RGBA4;
-}
-
-GLenum GetEquivalentFormat(D3DFORMAT format)
-{
-    if (format == D3DFMT_INTZ)
-        return GL_DEPTH24_STENCIL8_OES;
-    if (format == D3DFMT_NULL)
-        return GL_NONE;
-
-    switch (format)
-    {
-      case D3DFMT_A4R4G4B4:             return GL_RGBA4;
-      case D3DFMT_A8R8G8B8:             return GL_RGBA8_OES;
-      case D3DFMT_A1R5G5B5:             return GL_RGB5_A1;
-      case D3DFMT_R5G6B5:               return GL_RGB565;
-      case D3DFMT_X8R8G8B8:             return GL_RGB8_OES;
-      case D3DFMT_D16:                  return GL_DEPTH_COMPONENT16;
-      case D3DFMT_D24S8:                return GL_DEPTH24_STENCIL8_OES;
-      case D3DFMT_UNKNOWN:              return GL_NONE;
-      case D3DFMT_DXT1:                 return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
-      case D3DFMT_DXT3:                 return GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE;
-      case D3DFMT_DXT5:                 return GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE;
-      case D3DFMT_A32B32G32R32F:        return GL_RGBA32F_EXT;
-      case D3DFMT_A16B16G16R16F:        return GL_RGBA16F_EXT;
-      case D3DFMT_L8:                   return GL_LUMINANCE8_EXT;
-      case D3DFMT_A8L8:                 return GL_LUMINANCE8_ALPHA8_EXT;
-      default:              UNREACHABLE();
-        return GL_NONE;
-    }
-}
-
-}
-
-namespace d3d9
-{
-
-bool IsCompressedFormat(D3DFORMAT surfaceFormat)
-{
-    switch(surfaceFormat)
-    {
-      case D3DFMT_DXT1:
-      case D3DFMT_DXT2:
-      case D3DFMT_DXT3:
-      case D3DFMT_DXT4:
-      case D3DFMT_DXT5:
-        return true;
-      default:
-        return false;
-    }
-}
-
-size_t ComputeRowSize(D3DFORMAT format, unsigned int width)
-{
-    if (format == D3DFMT_INTZ)
-    {
-        return 4 * width;
-    }
-    switch (format)
-    {
-      case D3DFMT_L8:
-          return 1 * width;
-      case D3DFMT_A8L8:
-          return 2 * width;
-      case D3DFMT_X8R8G8B8:
-      case D3DFMT_A8R8G8B8:
-        return 4 * width;
-      case D3DFMT_A16B16G16R16F:
-        return 8 * width;
-      case D3DFMT_A32B32G32R32F:
-        return 16 * width;
-      case D3DFMT_DXT1:
-        return 8 * ((width + 3) / 4);
-      case D3DFMT_DXT3:
-      case D3DFMT_DXT5:
-        return 16 * ((width + 3) / 4);
-      default:
-        UNREACHABLE();
-        return 0;
-    }
-}
-
-}
</del></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9renderer9_utilsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/renderer9_utils.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/renderer9_utils.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/renderer9_utils.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -10,16 +10,16 @@
</span><span class="cx"> #ifndef LIBGLESV2_RENDERER_RENDERER9_UTILS_H
</span><span class="cx"> #define LIBGLESV2_RENDERER_RENDERER9_UTILS_H
</span><span class="cx"> 
</span><del>-#include &quot;libGLESv2/utilities.h&quot;
</del><ins>+#include &quot;libGLESv2/angletypes.h&quot;
</ins><span class="cx"> 
</span><del>-const D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I','N','T','Z')));
-const D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N','U','L','L')));
</del><ins>+namespace rx
+{
</ins><span class="cx"> 
</span><span class="cx"> namespace gl_d3d9
</span><span class="cx"> {
</span><span class="cx"> 
</span><span class="cx"> D3DCMPFUNC ConvertComparison(GLenum comparison);
</span><del>-D3DCOLOR ConvertColor(gl::Color color);
</del><ins>+D3DCOLOR ConvertColor(gl::ColorF color);
</ins><span class="cx"> D3DBLEND ConvertBlendFunc(GLenum blend);
</span><span class="cx"> D3DBLENDOP ConvertBlendOp(GLenum blendOp);
</span><span class="cx"> D3DSTENCILOP ConvertStencilOp(GLenum stencilOp);
</span><span class="lines">@@ -29,31 +29,11 @@
</span><span class="cx"> DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha);
</span><span class="cx"> D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy);
</span><span class="cx"> void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter, float maxAnisotropy);
</span><del>-D3DFORMAT ConvertRenderbufferFormat(GLenum format);
-D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples);
</del><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-namespace d3d9_gl
-{
-
-GLuint GetAlphaSize(D3DFORMAT colorFormat);
-GLuint GetStencilSize(D3DFORMAT stencilFormat);
-
-GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type);
-
-bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format);
-GLenum ConvertBackBufferFormat(D3DFORMAT format);
-GLenum ConvertDepthStencilFormat(D3DFORMAT format);
-GLenum ConvertRenderTargetFormat(D3DFORMAT format);
-GLenum GetEquivalentFormat(D3DFORMAT format);
-
-}
-
</del><span class="cx"> namespace d3d9
</span><span class="cx"> {
</span><del>-bool IsCompressedFormat(D3DFORMAT format);
-size_t ComputeRowSize(D3DFORMAT format, unsigned int width);
</del><span class="cx"> 
</span><span class="cx"> inline bool isDeviceLostError(HRESULT errorCode)
</span><span class="cx"> {
</span><span class="lines">@@ -71,4 +51,6 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif // LIBGLESV2_RENDERER_RENDERER9_UTILS_H
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shadersBlitps"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/Blit.ps (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/Blit.ps        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/Blit.ps        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -6,34 +6,28 @@
</span><span class="cx"> 
</span><span class="cx"> sampler2D tex : s0;
</span><span class="cx"> 
</span><del>-uniform float4 mode : c0;
</del><ins>+uniform float4 mult : c0;
+uniform float4 add  : c1;
</ins><span class="cx"> 
</span><span class="cx"> // Passthrough Pixel Shader
</span><span class="cx"> // Outputs texture 0 sampled at texcoord 0.
</span><span class="cx"> float4 passthroughps(float4 texcoord : TEXCOORD0) : COLOR
</span><span class="cx"> {
</span><del>-        return tex2D(tex, texcoord.xy);
</del><ins>+    return tex2D(tex, texcoord.xy);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> // Luminance Conversion Pixel Shader
</span><del>-// Outputs sample(tex0, tc0).rrra.
-// For LA output (pass A) set C0.X = 1, C0.Y = 0.
-// For L output (A = 1) set C0.X = 0, C0.Y = 1.
</del><ins>+// Performs a mad operation using the LA data from the texture with mult.xw and add.xw.
+// Returns data in the form of llla
</ins><span class="cx"> float4 luminanceps(float4 texcoord : TEXCOORD0) : COLOR
</span><span class="cx"> {
</span><del>-        float4 tmp = tex2D(tex, texcoord.xy);
-        tmp.w = tmp.w * mode.x + mode.y;
-        return tmp.xxxw;
</del><ins>+    return (tex2D(tex, texcoord.xy).xw * mult.xw + add.xw).xxxy;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> // RGB/A Component Mask Pixel Shader
</span><del>-// Outputs sample(tex0, tc0) with options to force RGB = 0 and/or A = 1.
-// To force RGB = 0, set C0.X = 0, otherwise C0.X = 1.
-// To force A = 1, set C0.Z = 0, C0.W = 1, otherwise C0.Z = 1, C0.W = 0.
</del><ins>+// Performs a mad operation using the texture's RGBA data with mult.xyzw and add.xyzw.
+// Returns data in the form of rgba
</ins><span class="cx"> float4 componentmaskps(float4 texcoord : TEXCOORD0) : COLOR
</span><span class="cx"> {
</span><del>-        float4 tmp = tex2D(tex, texcoord.xy);
-        tmp.xyz = tmp.xyz * mode.x;
-        tmp.w = tmp.w * mode.z + mode.w;
-        return tmp;
</del><ins>+    return tex2D(tex, texcoord.xy) * mult + add;
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledcomponentmaskpsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,79 +1,85 @@
</span><del>-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
-//
-///
-// Parameters:
-//
-//   float4 mode;
-//   sampler2D tex;
-//
-//
-// Registers:
-//
-//   Name         Reg   Size
-//   ------------ ----- ----
-//   mode         c0       1
-//   tex          s0       1
-//
-
-    ps_2_0
-    dcl t0.xy
-    dcl_2d s0
-    texld r0, t0, s0
-    mul r1.xyz, r0, c0.x
-    mad r1.w, r0.w, c0.z, c0.w
-    mov oC0, r1
-
-// approximately 4 instruction slots used (1 texture, 3 arithmetic)
-#endif
-
-const BYTE g_ps20_componentmaskps[] =
-{
-      0,   2, 255, 255, 254, 255, 
-     44,   0,  67,  84,  65,  66, 
-     28,   0,   0,   0, 119,   0, 
-      0,   0,   0,   2, 255, 255, 
-      2,   0,   0,   0,  28,   0, 
-      0,   0,   0,   1,   0,   0, 
-    112,   0,   0,   0,  68,   0, 
-      0,   0,   2,   0,   0,   0, 
-      1,   0,   0,   0,  76,   0, 
-      0,   0,   0,   0,   0,   0, 
-     92,   0,   0,   0,   3,   0, 
-      0,   0,   1,   0,   0,   0, 
-     96,   0,   0,   0,   0,   0, 
-      0,   0, 109, 111, 100, 101, 
-      0, 171, 171, 171,   1,   0, 
-      3,   0,   1,   0,   4,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0, 116, 101, 120,   0, 
-      4,   0,  12,   0,   1,   0, 
-      1,   0,   1,   0,   0,   0, 
-      0,   0,   0,   0, 112, 115, 
-     95,  50,  95,  48,   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,  31,   0, 
-      0,   2,   0,   0,   0, 128, 
-      0,   0,   3, 176,  31,   0, 
-      0,   2,   0,   0,   0, 144, 
-      0,   8,  15, 160,  66,   0, 
-      0,   3,   0,   0,  15, 128, 
-      0,   0, 228, 176,   0,   8, 
-    228, 160,   5,   0,   0,   3, 
-      1,   0,   7, 128,   0,   0, 
-    228, 128,   0,   0,   0, 160, 
-      4,   0,   0,   4,   1,   0, 
-      8, 128,   0,   0, 255, 128, 
-      0,   0, 170, 160,   0,   0, 
-    255, 160,   1,   0,   0,   2, 
-      0,   8,  15, 128,   1,   0, 
-    228, 128, 255, 255,   0,   0
-};
</del><ins>+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+///
+// Parameters:
+//
+//   float4 add;
+//   float4 mult;
+//   sampler2D tex;
+//
+//
+// Registers:
+//
+//   Name         Reg   Size
+//   ------------ ----- ----
+//   mult         c0       1
+//   add          c1       1
+//   tex          s0       1
+//
+
+    ps_2_0
+    dcl t0.xy
+    dcl_2d s0
+    texld r0, t0, s0
+    mov r1, c0
+    mad r0, r0, r1, c1
+    mov oC0, r0
+
+// approximately 4 instruction slots used (1 texture, 3 arithmetic)
+#endif
+
+const BYTE g_ps20_componentmaskps[] =
+{
+      0,   2, 255, 255, 254, 255, 
+     50,   0,  67,  84,  65,  66, 
+     28,   0,   0,   0, 143,   0, 
+      0,   0,   0,   2, 255, 255, 
+      3,   0,   0,   0,  28,   0, 
+      0,   0,   0,   1,   0,   0, 
+    136,   0,   0,   0,  88,   0, 
+      0,   0,   2,   0,   1,   0, 
+      1,   0,   0,   0,  92,   0, 
+      0,   0,   0,   0,   0,   0, 
+    108,   0,   0,   0,   2,   0, 
+      0,   0,   1,   0,   0,   0, 
+     92,   0,   0,   0,   0,   0, 
+      0,   0, 113,   0,   0,   0, 
+      3,   0,   0,   0,   1,   0, 
+      0,   0, 120,   0,   0,   0, 
+      0,   0,   0,   0,  97, 100, 
+    100,   0,   1,   0,   3,   0, 
+      1,   0,   4,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+    109, 117, 108, 116,   0, 116, 
+    101, 120,   0, 171, 171, 171, 
+      4,   0,  12,   0,   1,   0, 
+      1,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0, 112, 115, 
+     95,  50,  95,  48,   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,  31,   0, 
+      0,   2,   0,   0,   0, 128, 
+      0,   0,   3, 176,  31,   0, 
+      0,   2,   0,   0,   0, 144, 
+      0,   8,  15, 160,  66,   0, 
+      0,   3,   0,   0,  15, 128, 
+      0,   0, 228, 176,   0,   8, 
+    228, 160,   1,   0,   0,   2, 
+      1,   0,  15, 128,   0,   0, 
+    228, 160,   4,   0,   0,   4, 
+      0,   0,  15, 128,   0,   0, 
+    228, 128,   1,   0, 228, 128, 
+      1,   0, 228, 160,   1,   0, 
+      0,   2,   0,   8,  15, 128, 
+      0,   0, 228, 128, 255, 255, 
+      0,   0
+};
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledflipyvsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,67 +1,67 @@
</span><del>-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
-//
-///
-// Parameters:
-//
-//   float4 halfPixelSize;
-//
-//
-// Registers:
-//
-//   Name          Reg   Size
-//   ------------- ----- ----
-//   halfPixelSize c0       1
-//
-
-    vs_2_0
-    def c1, 0.5, 1, 0, 0
-    dcl_position v0
-    add oPos, v0, c0
-    mad oT0, v0, c1.xxyy, c1.xxzz
-
-// approximately 2 instruction slots used
-#endif
-
-const BYTE g_vs20_flipyvs[] =
-{
-      0,   2, 254, 255, 254, 255, 
-     36,   0,  67,  84,  65,  66, 
-     28,   0,   0,   0,  87,   0, 
-      0,   0,   0,   2, 254, 255, 
-      1,   0,   0,   0,  28,   0, 
-      0,   0,   0,   1,   0,   0, 
-     80,   0,   0,   0,  48,   0, 
-      0,   0,   2,   0,   0,   0, 
-      1,   0,   0,   0,  64,   0, 
-      0,   0,   0,   0,   0,   0, 
-    104,  97, 108, 102,  80, 105, 
-    120, 101, 108,  83, 105, 122, 
-    101,   0, 171, 171,   1,   0, 
-      3,   0,   1,   0,   4,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0, 118, 115,  95,  50, 
-     95,  48,   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,  81,   0,   0,   5, 
-      1,   0,  15, 160,   0,   0, 
-      0,  63,   0,   0, 128,  63, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  31,   0,   0,   2, 
-      0,   0,   0, 128,   0,   0, 
-     15, 144,   2,   0,   0,   3, 
-      0,   0,  15, 192,   0,   0, 
-    228, 144,   0,   0, 228, 160, 
-      4,   0,   0,   4,   0,   0, 
-     15, 224,   0,   0, 228, 144, 
-      1,   0,  80, 160,   1,   0, 
-    160, 160, 255, 255,   0,   0
-};
</del><ins>+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+///
+// Parameters:
+//
+//   float4 halfPixelSize;
+//
+//
+// Registers:
+//
+//   Name          Reg   Size
+//   ------------- ----- ----
+//   halfPixelSize c0       1
+//
+
+    vs_2_0
+    def c1, 0.5, 1, 0, 0
+    dcl_position v0
+    add oPos, v0, c0
+    mad oT0, v0, c1.xxyy, c1.xxzz
+
+// approximately 2 instruction slots used
+#endif
+
+const BYTE g_vs20_flipyvs[] =
+{
+      0,   2, 254, 255, 254, 255, 
+     36,   0,  67,  84,  65,  66, 
+     28,   0,   0,   0,  87,   0, 
+      0,   0,   0,   2, 254, 255, 
+      1,   0,   0,   0,  28,   0, 
+      0,   0,   0,   1,   0,   0, 
+     80,   0,   0,   0,  48,   0, 
+      0,   0,   2,   0,   0,   0, 
+      1,   0,   0,   0,  64,   0, 
+      0,   0,   0,   0,   0,   0, 
+    104,  97, 108, 102,  80, 105, 
+    120, 101, 108,  83, 105, 122, 
+    101,   0, 171, 171,   1,   0, 
+      3,   0,   1,   0,   4,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0, 118, 115,  95,  50, 
+     95,  48,   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,  81,   0,   0,   5, 
+      1,   0,  15, 160,   0,   0, 
+      0,  63,   0,   0, 128,  63, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  31,   0,   0,   2, 
+      0,   0,   0, 128,   0,   0, 
+     15, 144,   2,   0,   0,   3, 
+      0,   0,  15, 192,   0,   0, 
+    228, 144,   0,   0, 228, 160, 
+      4,   0,   0,   4,   0,   0, 
+     15, 224,   0,   0, 228, 144, 
+      1,   0,  80, 160,   1,   0, 
+    160, 160, 255, 255,   0,   0
+};
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledluminancepsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,79 +1,95 @@
</span><del>-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
-//
-///
-// Parameters:
-//
-//   float4 mode;
-//   sampler2D tex;
-//
-//
-// Registers:
-//
-//   Name         Reg   Size
-//   ------------ ----- ----
-//   mode         c0       1
-//   tex          s0       1
-//
-
-    ps_2_0
-    dcl t0.xy
-    dcl_2d s0
-    texld r0, t0, s0
-    mad r1.w, r0.w, c0.x, c0.y
-    mov r1.xyz, r0.x
-    mov oC0, r1
-
-// approximately 4 instruction slots used (1 texture, 3 arithmetic)
-#endif
-
-const BYTE g_ps20_luminanceps[] =
-{
-      0,   2, 255, 255, 254, 255, 
-     44,   0,  67,  84,  65,  66, 
-     28,   0,   0,   0, 119,   0, 
-      0,   0,   0,   2, 255, 255, 
-      2,   0,   0,   0,  28,   0, 
-      0,   0,   0,   1,   0,   0, 
-    112,   0,   0,   0,  68,   0, 
-      0,   0,   2,   0,   0,   0, 
-      1,   0,   0,   0,  76,   0, 
-      0,   0,   0,   0,   0,   0, 
-     92,   0,   0,   0,   3,   0, 
-      0,   0,   1,   0,   0,   0, 
-     96,   0,   0,   0,   0,   0, 
-      0,   0, 109, 111, 100, 101, 
-      0, 171, 171, 171,   1,   0, 
-      3,   0,   1,   0,   4,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0, 116, 101, 120,   0, 
-      4,   0,  12,   0,   1,   0, 
-      1,   0,   1,   0,   0,   0, 
-      0,   0,   0,   0, 112, 115, 
-     95,  50,  95,  48,   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,  31,   0, 
-      0,   2,   0,   0,   0, 128, 
-      0,   0,   3, 176,  31,   0, 
-      0,   2,   0,   0,   0, 144, 
-      0,   8,  15, 160,  66,   0, 
-      0,   3,   0,   0,  15, 128, 
-      0,   0, 228, 176,   0,   8, 
-    228, 160,   4,   0,   0,   4, 
-      1,   0,   8, 128,   0,   0, 
-    255, 128,   0,   0,   0, 160, 
-      0,   0,  85, 160,   1,   0, 
-      0,   2,   1,   0,   7, 128, 
-      0,   0,   0, 128,   1,   0, 
-      0,   2,   0,   8,  15, 128, 
-      1,   0, 228, 128, 255, 255, 
-      0,   0
-};
</del><ins>+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+///
+// Parameters:
+//
+//   float4 add;
+//   float4 mult;
+//   sampler2D tex;
+//
+//
+// Registers:
+//
+//   Name         Reg   Size
+//   ------------ ----- ----
+//   mult         c0       1
+//   add          c1       1
+//   tex          s0       1
+//
+
+    ps_2_0
+    dcl t0.xy
+    dcl_2d s0
+    texld r0, t0, s0
+    mov r1.xw, c0
+    mad r0.x, r0.x, r1.x, c1.x
+    mad r0.y, r0.w, r1.w, c1.w
+    mov r1.xyz, r0.x
+    mov r1.w, r0.y
+    mov oC0, r1
+
+// approximately 7 instruction slots used (1 texture, 6 arithmetic)
+#endif
+
+const BYTE g_ps20_luminanceps[] =
+{
+      0,   2, 255, 255, 254, 255, 
+     50,   0,  67,  84,  65,  66, 
+     28,   0,   0,   0, 143,   0, 
+      0,   0,   0,   2, 255, 255, 
+      3,   0,   0,   0,  28,   0, 
+      0,   0,   0,   1,   0,   0, 
+    136,   0,   0,   0,  88,   0, 
+      0,   0,   2,   0,   1,   0, 
+      1,   0,   0,   0,  92,   0, 
+      0,   0,   0,   0,   0,   0, 
+    108,   0,   0,   0,   2,   0, 
+      0,   0,   1,   0,   0,   0, 
+     92,   0,   0,   0,   0,   0, 
+      0,   0, 113,   0,   0,   0, 
+      3,   0,   0,   0,   1,   0, 
+      0,   0, 120,   0,   0,   0, 
+      0,   0,   0,   0,  97, 100, 
+    100,   0,   1,   0,   3,   0, 
+      1,   0,   4,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+    109, 117, 108, 116,   0, 116, 
+    101, 120,   0, 171, 171, 171, 
+      4,   0,  12,   0,   1,   0, 
+      1,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0, 112, 115, 
+     95,  50,  95,  48,   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,  31,   0, 
+      0,   2,   0,   0,   0, 128, 
+      0,   0,   3, 176,  31,   0, 
+      0,   2,   0,   0,   0, 144, 
+      0,   8,  15, 160,  66,   0, 
+      0,   3,   0,   0,  15, 128, 
+      0,   0, 228, 176,   0,   8, 
+    228, 160,   1,   0,   0,   2, 
+      1,   0,   9, 128,   0,   0, 
+    228, 160,   4,   0,   0,   4, 
+      0,   0,   1, 128,   0,   0, 
+      0, 128,   1,   0,   0, 128, 
+      1,   0,   0, 160,   4,   0, 
+      0,   4,   0,   0,   2, 128, 
+      0,   0, 255, 128,   1,   0, 
+    255, 128,   1,   0, 255, 160, 
+      1,   0,   0,   2,   1,   0, 
+      7, 128,   0,   0,   0, 128, 
+      1,   0,   0,   2,   1,   0, 
+      8, 128,   0,   0,  85, 128, 
+      1,   0,   0,   2,   0,   8, 
+     15, 128,   1,   0, 228, 128, 
+    255, 255,   0,   0
+};
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledpassthroughpsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,62 +1,62 @@
</span><del>-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
-//
-///
-// Parameters:
-//
-//   sampler2D tex;
-//
-//
-// Registers:
-//
-//   Name         Reg   Size
-//   ------------ ----- ----
-//   tex          s0       1
-//
-
-    ps_2_0
-    dcl t0.xy
-    dcl_2d s0
-    texld r0, t0, s0
-    mov oC0, r0
-
-// approximately 2 instruction slots used (1 texture, 1 arithmetic)
-#endif
-
-const BYTE g_ps20_passthroughps[] =
-{
-      0,   2, 255, 255, 254, 255, 
-     33,   0,  67,  84,  65,  66, 
-     28,   0,   0,   0,  75,   0, 
-      0,   0,   0,   2, 255, 255, 
-      1,   0,   0,   0,  28,   0, 
-      0,   0,   0,   1,   0,   0, 
-     68,   0,   0,   0,  48,   0, 
-      0,   0,   3,   0,   0,   0, 
-      1,   0,   0,   0,  52,   0, 
-      0,   0,   0,   0,   0,   0, 
-    116, 101, 120,   0,   4,   0, 
-     12,   0,   1,   0,   1,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0, 112, 115,  95,  50, 
-     95,  48,   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,  31,   0,   0,   2, 
-      0,   0,   0, 128,   0,   0, 
-      3, 176,  31,   0,   0,   2, 
-      0,   0,   0, 144,   0,   8, 
-     15, 160,  66,   0,   0,   3, 
-      0,   0,  15, 128,   0,   0, 
-    228, 176,   0,   8, 228, 160, 
-      1,   0,   0,   2,   0,   8, 
-     15, 128,   0,   0, 228, 128, 
-    255, 255,   0,   0
-};
</del><ins>+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+///
+// Parameters:
+//
+//   sampler2D tex;
+//
+//
+// Registers:
+//
+//   Name         Reg   Size
+//   ------------ ----- ----
+//   tex          s0       1
+//
+
+    ps_2_0
+    dcl t0.xy
+    dcl_2d s0
+    texld r0, t0, s0
+    mov oC0, r0
+
+// approximately 2 instruction slots used (1 texture, 1 arithmetic)
+#endif
+
+const BYTE g_ps20_passthroughps[] =
+{
+      0,   2, 255, 255, 254, 255, 
+     33,   0,  67,  84,  65,  66, 
+     28,   0,   0,   0,  75,   0, 
+      0,   0,   0,   2, 255, 255, 
+      1,   0,   0,   0,  28,   0, 
+      0,   0,   0,   1,   0,   0, 
+     68,   0,   0,   0,  48,   0, 
+      0,   0,   3,   0,   0,   0, 
+      1,   0,   0,   0,  52,   0, 
+      0,   0,   0,   0,   0,   0, 
+    116, 101, 120,   0,   4,   0, 
+     12,   0,   1,   0,   1,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0, 112, 115,  95,  50, 
+     95,  48,   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,  31,   0,   0,   2, 
+      0,   0,   0, 128,   0,   0, 
+      3, 176,  31,   0,   0,   2, 
+      0,   0,   0, 144,   0,   8, 
+     15, 160,  66,   0,   0,   3, 
+      0,   0,  15, 128,   0,   0, 
+    228, 176,   0,   8, 228, 160, 
+      1,   0,   0,   2,   0,   8, 
+     15, 128,   0,   0, 228, 128, 
+    255, 255,   0,   0
+};
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shaderscompiledstandardvsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,67 +1,67 @@
</span><del>-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
-//
-///
-// Parameters:
-//
-//   float4 halfPixelSize;
-//
-//
-// Registers:
-//
-//   Name          Reg   Size
-//   ------------- ----- ----
-//   halfPixelSize c0       1
-//
-
-    vs_2_0
-    def c1, 0.5, -0.5, 1, 0
-    dcl_position v0
-    add oPos, v0, c0
-    mad oT0, v0, c1.xyzz, c1.xxww
-
-// approximately 2 instruction slots used
-#endif
-
-const BYTE g_vs20_standardvs[] =
-{
-      0,   2, 254, 255, 254, 255, 
-     36,   0,  67,  84,  65,  66, 
-     28,   0,   0,   0,  87,   0, 
-      0,   0,   0,   2, 254, 255, 
-      1,   0,   0,   0,  28,   0, 
-      0,   0,   0,   1,   0,   0, 
-     80,   0,   0,   0,  48,   0, 
-      0,   0,   2,   0,   0,   0, 
-      1,   0,   0,   0,  64,   0, 
-      0,   0,   0,   0,   0,   0, 
-    104,  97, 108, 102,  80, 105, 
-    120, 101, 108,  83, 105, 122, 
-    101,   0, 171, 171,   1,   0, 
-      3,   0,   1,   0,   4,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0, 118, 115,  95,  50, 
-     95,  48,   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,  81,   0,   0,   5, 
-      1,   0,  15, 160,   0,   0, 
-      0,  63,   0,   0,   0, 191, 
-      0,   0, 128,  63,   0,   0, 
-      0,   0,  31,   0,   0,   2, 
-      0,   0,   0, 128,   0,   0, 
-     15, 144,   2,   0,   0,   3, 
-      0,   0,  15, 192,   0,   0, 
-    228, 144,   0,   0, 228, 160, 
-      4,   0,   0,   4,   0,   0, 
-     15, 224,   0,   0, 228, 144, 
-      1,   0, 164, 160,   1,   0, 
-    240, 160, 255, 255,   0,   0
-};
</del><ins>+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+///
+// Parameters:
+//
+//   float4 halfPixelSize;
+//
+//
+// Registers:
+//
+//   Name          Reg   Size
+//   ------------- ----- ----
+//   halfPixelSize c0       1
+//
+
+    vs_2_0
+    def c1, 0.5, -0.5, 1, 0
+    dcl_position v0
+    add oPos, v0, c0
+    mad oT0, v0, c1.xyzz, c1.xxww
+
+// approximately 2 instruction slots used
+#endif
+
+const BYTE g_vs20_standardvs[] =
+{
+      0,   2, 254, 255, 254, 255, 
+     36,   0,  67,  84,  65,  66, 
+     28,   0,   0,   0,  87,   0, 
+      0,   0,   0,   2, 254, 255, 
+      1,   0,   0,   0,  28,   0, 
+      0,   0,   0,   1,   0,   0, 
+     80,   0,   0,   0,  48,   0, 
+      0,   0,   2,   0,   0,   0, 
+      1,   0,   0,   0,  64,   0, 
+      0,   0,   0,   0,   0,   0, 
+    104,  97, 108, 102,  80, 105, 
+    120, 101, 108,  83, 105, 122, 
+    101,   0, 171, 171,   1,   0, 
+      3,   0,   1,   0,   4,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0, 118, 115,  95,  50, 
+     95,  48,   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,  81,   0,   0,   5, 
+      1,   0,  15, 160,   0,   0, 
+      0,  63,   0,   0,   0, 191, 
+      0,   0, 128,  63,   0,   0, 
+      0,   0,  31,   0,   0,   2, 
+      0,   0,   0, 128,   0,   0, 
+     15, 144,   2,   0,   0,   3, 
+      0,   0,  15, 192,   0,   0, 
+    228, 144,   0,   0, 228, 160, 
+      4,   0,   0,   4,   0,   0, 
+     15, 224,   0,   0, 228, 144, 
+      1,   0, 164, 160,   1,   0, 
+    240, 160, 255, 255,   0,   0
+};
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2rendererd3d9shadersgenerate_shadersbat"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/generate_shaders.bat (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/generate_shaders.bat        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/shaders/generate_shaders.bat        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,14 +1,63 @@
</span><span class="cx"> @ECHO OFF
</span><span class="cx"> REM
</span><del>-REM Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
</del><ins>+REM Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
</ins><span class="cx"> REM Use of this source code is governed by a BSD-style license that can be
</span><span class="cx"> REM found in the LICENSE file.
</span><span class="cx"> REM
</span><span class="cx"> 
</span><span class="cx"> PATH %PATH%;%ProgramFiles(x86)%\Windows Kits\8.0\bin\x86;%DXSDK_DIR%\Utilities\bin\x86
</span><span class="cx"> 
</span><del>-fxc /E standardvs /T vs_2_0 /Fh compiled/standardvs.h Blit.vs
-fxc /E flipyvs /T vs_2_0 /Fh compiled/flipyvs.h Blit.vs
-fxc /E passthroughps /T ps_2_0 /Fh compiled/passthroughps.h Blit.ps
-fxc /E luminanceps /T ps_2_0 /Fh compiled/luminanceps.h Blit.ps
-fxc /E componentmaskps /T ps_2_0 /Fh compiled/componentmaskps.h Blit.ps
</del><ins>+setlocal
+set errorCount=0
+set successCount=0
+set debug=0
+
+if &quot;%1&quot; == &quot;debug&quot; (
+    set debug=1
+)
+if &quot;%1&quot; == &quot;release&quot; (
+    set debug=0
+)
+
+::              | Input file          | Entry point           | Type | Output file                        | Debug |
+call:BuildShader Blit.vs               standardvs              vs_2_0 compiled\standardvs.h                %debug%
+call:BuildShader Blit.vs               flipyvs                 vs_2_0 compiled\flipyvs.h                   %debug%
+call:BuildShader Blit.ps               passthroughps           ps_2_0 compiled\passthroughps.h             %debug%
+call:BuildShader Blit.ps               luminanceps             ps_2_0 compiled\luminanceps.h               %debug%
+call:BuildShader Blit.ps               componentmaskps         ps_2_0 compiled\componentmaskps.h           %debug%
+
+echo.
+
+if %successCount% GTR 0 (
+   echo %successCount% shaders compiled successfully.
+)
+if %errorCount% GTR 0 (
+   echo There were %errorCount% shader compilation errors.
+)
+
+endlocal
+exit /b
+
+:BuildShader
+set input=%~1
+set entry=%~2
+set type=%~3
+set output=%~4
+set debug=%~5
+
+if %debug% == 0 (
+    set &quot;buildCMD=fxc /nologo /E %entry% /T %type% /Fh %output% %input%&quot;
+) else (
+    set &quot;buildCMD=fxc /nologo /Zi /Od /E %entry% /T %type% /Fh %output% %input%&quot;
+)
+
+set error=0
+%buildCMD% || set error=1
+
+if %error% == 0 (
+    set /a successCount=%successCount%+1
+) else (
+    set /a errorCount=%errorCount%+1
+)
+
+exit /b
</ins></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibGLESv2renderergeneratemiph"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/generatemip.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/generatemip.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/generatemip.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -10,194 +10,260 @@
</span><span class="cx"> #ifndef LIBGLESV2_RENDERER_GENERATEMIP_H_
</span><span class="cx"> #define LIBGLESV2_RENDERER_GENERATEMIP_H_
</span><span class="cx"> 
</span><del>-#include &quot;libGLESv2/mathutil.h&quot;
</del><ins>+#include &quot;common/mathutil.h&quot;
+#include &quot;imageformats.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace rx
</span><span class="cx"> {
</span><del>-struct L8
</del><ins>+
+namespace priv
</ins><span class="cx"> {
</span><del>-    unsigned char L;
</del><span class="cx"> 
</span><del>-    static void average(L8 *dst, const L8 *src1, const L8 *src2)
-    {
-        dst-&gt;L = ((src1-&gt;L ^ src2-&gt;L) &gt;&gt; 1) + (src1-&gt;L &amp; src2-&gt;L);
-    }
-};
</del><ins>+template &lt;typename T&gt;
+static inline T *GetPixel(void *data, unsigned int x, unsigned int y, unsigned int z, unsigned int rowPitch, unsigned int depthPitch)
+{
+    return reinterpret_cast&lt;T*&gt;(reinterpret_cast&lt;unsigned char*&gt;(data) + (x * sizeof(T)) + (y * rowPitch) + (z * depthPitch));
+}
</ins><span class="cx"> 
</span><del>-typedef L8 R8; // R8 type is functionally equivalent for mip purposes
-typedef L8 A8; // A8 type is functionally equivalent for mip purposes
</del><ins>+template &lt;typename T&gt;
+static inline const T *GetPixel(const void *data, unsigned int x, unsigned int y, unsigned int z, unsigned int rowPitch, unsigned int depthPitch)
+{
+    return reinterpret_cast&lt;const T*&gt;(reinterpret_cast&lt;const unsigned char*&gt;(data) + (x * sizeof(T)) + (y * rowPitch) + (z * depthPitch));
+}
</ins><span class="cx"> 
</span><del>-struct A8L8
</del><ins>+template &lt;typename T&gt;
+static void GenerateMip_Y(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                          const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                          unsigned int destWidth, unsigned int destHeight, unsigned int destDepth,
+                          unsigned char *destData, int destRowPitch, int destDepthPitch)
</ins><span class="cx"> {
</span><del>-    unsigned char L;
-    unsigned char A;
</del><ins>+    ASSERT(sourceWidth == 1);
+    ASSERT(sourceHeight &gt; 1);
+    ASSERT(sourceDepth == 1);
</ins><span class="cx"> 
</span><del>-    static void average(A8L8 *dst, const A8L8 *src1, const A8L8 *src2)
</del><ins>+    for (unsigned int y = 0; y &lt; destHeight; y++)
</ins><span class="cx">     {
</span><del>-        *(unsigned short*)dst = (((*(unsigned short*)src1 ^ *(unsigned short*)src2) &amp; 0xFEFE) &gt;&gt; 1) + (*(unsigned short*)src1 &amp; *(unsigned short*)src2);
</del><ins>+        const T *src0 = GetPixel&lt;T&gt;(sourceData, 0, y * 2, 0, sourceRowPitch, sourceDepthPitch);
+        const T *src1 = GetPixel&lt;T&gt;(sourceData, 0, y * 2 + 1, 0, sourceRowPitch, sourceDepthPitch);
+        T *dst = GetPixel&lt;T&gt;(destData, 0, y, 0, destRowPitch, destDepthPitch);
+
+        T::average(dst, src0, src1);
</ins><span class="cx">     }
</span><del>-};
</del><ins>+}
</ins><span class="cx"> 
</span><del>-typedef A8L8 R8G8; // R8G8 type is functionally equivalent for mip purposes
-
-struct A8R8G8B8
</del><ins>+template &lt;typename T&gt;
+static void GenerateMip_X(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                          const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                          unsigned int destWidth, unsigned int destHeight, unsigned int destDepth,
+                          unsigned char *destData, int destRowPitch, int destDepthPitch)
</ins><span class="cx"> {
</span><del>-    unsigned char B;
-    unsigned char G;
-    unsigned char R;
-    unsigned char A;
</del><ins>+    ASSERT(sourceWidth &gt; 1);
+    ASSERT(sourceHeight == 1);
+    ASSERT(sourceDepth == 1);
</ins><span class="cx"> 
</span><del>-    static void average(A8R8G8B8 *dst, const A8R8G8B8 *src1, const A8R8G8B8 *src2)
</del><ins>+    for (unsigned int x = 0; x &lt; destWidth; x++)
</ins><span class="cx">     {
</span><del>-        *(unsigned int*)dst = (((*(unsigned int*)src1 ^ *(unsigned int*)src2) &amp; 0xFEFEFEFE) &gt;&gt; 1) + (*(unsigned int*)src1 &amp; *(unsigned int*)src2);
</del><ins>+        const T *src0 = GetPixel&lt;T&gt;(sourceData, x * 2, 0, 0, sourceRowPitch, sourceDepthPitch);
+        const T *src1 = GetPixel&lt;T&gt;(sourceData, x * 2 + 1, 0, 0, sourceRowPitch, sourceDepthPitch);
+        T *dst = GetPixel&lt;T&gt;(destData, x, 0, 0, destRowPitch, destDepthPitch);
+
+        T::average(dst, src0, src1);
</ins><span class="cx">     }
</span><del>-};
</del><ins>+}
</ins><span class="cx"> 
</span><del>-typedef A8R8G8B8 R8G8B8A8; // R8G8B8A8 type is functionally equivalent for mip purposes
-
-struct A16B16G16R16F
</del><ins>+template &lt;typename T&gt;
+static void GenerateMip_Z(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                          const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                          unsigned int destWidth, unsigned int destHeight, unsigned int destDepth,
+                          unsigned char *destData, int destRowPitch, int destDepthPitch)
</ins><span class="cx"> {
</span><del>-    unsigned short R;
-    unsigned short G;
-    unsigned short B;
-    unsigned short A;
</del><ins>+    ASSERT(sourceWidth == 1);
+    ASSERT(sourceHeight == 1);
+    ASSERT(sourceDepth &gt; 1);
</ins><span class="cx"> 
</span><del>-    static void average(A16B16G16R16F *dst, const A16B16G16R16F *src1, const A16B16G16R16F *src2)
</del><ins>+    for (unsigned int z = 0; z &lt; destDepth; z++)
</ins><span class="cx">     {
</span><del>-        dst-&gt;R = gl::float32ToFloat16((gl::float16ToFloat32(src1-&gt;R) + gl::float16ToFloat32(src2-&gt;R)) * 0.5f);
-        dst-&gt;G = gl::float32ToFloat16((gl::float16ToFloat32(src1-&gt;G) + gl::float16ToFloat32(src2-&gt;G)) * 0.5f);
-        dst-&gt;B = gl::float32ToFloat16((gl::float16ToFloat32(src1-&gt;B) + gl::float16ToFloat32(src2-&gt;B)) * 0.5f);
-        dst-&gt;A = gl::float32ToFloat16((gl::float16ToFloat32(src1-&gt;A) + gl::float16ToFloat32(src2-&gt;A)) * 0.5f);
</del><ins>+        const T *src0 = GetPixel&lt;T&gt;(sourceData, 0, 0, z * 2, sourceRowPitch, sourceDepthPitch);
+        const T *src1 = GetPixel&lt;T&gt;(sourceData, 0, 0, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
+        T *dst = GetPixel&lt;T&gt;(destData, 0, 0, z, destRowPitch, destDepthPitch);
+
+        T::average(dst, src0, src1);
</ins><span class="cx">     }
</span><del>-};
</del><ins>+}
</ins><span class="cx"> 
</span><del>-struct R16F
</del><ins>+template &lt;typename T&gt;
+static void GenerateMip_XY(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                           const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                           unsigned int destWidth, unsigned int destHeight, unsigned int destDepth,
+                           unsigned char *destData, int destRowPitch, int destDepthPitch)
</ins><span class="cx"> {
</span><del>-    unsigned short R;
</del><ins>+    ASSERT(sourceWidth &gt; 1);
+    ASSERT(sourceHeight &gt; 1);
+    ASSERT(sourceDepth == 1);
</ins><span class="cx"> 
</span><del>-    static void average(R16F *dst, const R16F *src1, const R16F *src2)
</del><ins>+    for (unsigned int y = 0; y &lt; destHeight; y++)
</ins><span class="cx">     {
</span><del>-        dst-&gt;R = gl::float32ToFloat16((gl::float16ToFloat32(src1-&gt;R) + gl::float16ToFloat32(src2-&gt;R)) * 0.5f);
-    }
-};
</del><ins>+        for (unsigned int x = 0; x &lt; destWidth; x++)
+        {
+            const T *src0 = GetPixel&lt;T&gt;(sourceData, x * 2, y * 2, 0, sourceRowPitch, sourceDepthPitch);
+            const T *src1 = GetPixel&lt;T&gt;(sourceData, x * 2, y * 2 + 1, 0, sourceRowPitch, sourceDepthPitch);
+            const T *src2 = GetPixel&lt;T&gt;(sourceData, x * 2 + 1, y * 2, 0, sourceRowPitch, sourceDepthPitch);
+            const T *src3 = GetPixel&lt;T&gt;(sourceData, x * 2 + 1, y * 2 + 1, 0, sourceRowPitch, sourceDepthPitch);
+            T *dst = GetPixel&lt;T&gt;(destData, x, y, 0, destRowPitch, destDepthPitch);
</ins><span class="cx"> 
</span><del>-struct R16G16F
-{
-    unsigned short R;
-    unsigned short G;
</del><ins>+            T tmp0, tmp1;
</ins><span class="cx"> 
</span><del>-    static void average(R16G16F *dst, const R16G16F *src1, const R16G16F *src2)
-    {
-        dst-&gt;R = gl::float32ToFloat16((gl::float16ToFloat32(src1-&gt;R) + gl::float16ToFloat32(src2-&gt;R)) * 0.5f);
-        dst-&gt;G = gl::float32ToFloat16((gl::float16ToFloat32(src1-&gt;G) + gl::float16ToFloat32(src2-&gt;G)) * 0.5f);
</del><ins>+            T::average(&amp;tmp0, src0, src1);
+            T::average(&amp;tmp1, src2, src3);
+            T::average(dst, &amp;tmp0, &amp;tmp1);
+        }
</ins><span class="cx">     }
</span><del>-};
</del><ins>+}
</ins><span class="cx"> 
</span><del>-struct A32B32G32R32F
</del><ins>+template &lt;typename T&gt;
+static void GenerateMip_YZ(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                           const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                           unsigned int destWidth, unsigned int destHeight, unsigned int destDepth,
+                           unsigned char *destData, int destRowPitch, int destDepthPitch)
</ins><span class="cx"> {
</span><del>-    float R;
-    float G;
-    float B;
-    float A;
</del><ins>+    ASSERT(sourceWidth == 1);
+    ASSERT(sourceHeight &gt; 1);
+    ASSERT(sourceDepth &gt; 1);
</ins><span class="cx"> 
</span><del>-    static void average(A32B32G32R32F *dst, const A32B32G32R32F *src1, const A32B32G32R32F *src2)
</del><ins>+    for (unsigned int z = 0; z &lt; destDepth; z++)
</ins><span class="cx">     {
</span><del>-        dst-&gt;R = (src1-&gt;R + src2-&gt;R) * 0.5f;
-        dst-&gt;G = (src1-&gt;G + src2-&gt;G) * 0.5f;
-        dst-&gt;B = (src1-&gt;B + src2-&gt;B) * 0.5f;
-        dst-&gt;A = (src1-&gt;A + src2-&gt;A) * 0.5f;
-    }
-};
</del><ins>+        for (unsigned int y = 0; y &lt; destHeight; y++)
+        {
+            const T *src0 = GetPixel&lt;T&gt;(sourceData, 0, y * 2, z * 2, sourceRowPitch, sourceDepthPitch);
+            const T *src1 = GetPixel&lt;T&gt;(sourceData, 0, y * 2, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
+            const T *src2 = GetPixel&lt;T&gt;(sourceData, 0, y * 2 + 1, z * 2, sourceRowPitch, sourceDepthPitch);
+            const T *src3 = GetPixel&lt;T&gt;(sourceData, 0, y * 2 + 1, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
+            T *dst = GetPixel&lt;T&gt;(destData, 0, y, z, destRowPitch, destDepthPitch);
</ins><span class="cx"> 
</span><del>-struct R32F
-{
-    float R;
</del><ins>+            T tmp0, tmp1;
</ins><span class="cx"> 
</span><del>-    static void average(R32F *dst, const R32F *src1, const R32F *src2)
-    {
-        dst-&gt;R = (src1-&gt;R + src2-&gt;R) * 0.5f;
</del><ins>+            T::average(&amp;tmp0, src0, src1);
+            T::average(&amp;tmp1, src2, src3);
+            T::average(dst, &amp;tmp0, &amp;tmp1);
+        }
</ins><span class="cx">     }
</span><del>-};
</del><ins>+}
</ins><span class="cx"> 
</span><del>-struct R32G32F
</del><ins>+template &lt;typename T&gt;
+static void GenerateMip_XZ(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                           const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                           unsigned int destWidth, unsigned int destHeight, unsigned int destDepth,
+                           unsigned char *destData, int destRowPitch, int destDepthPitch)
</ins><span class="cx"> {
</span><del>-    float R;
-    float G;
</del><ins>+    ASSERT(sourceWidth &gt; 1);
+    ASSERT(sourceHeight == 1);
+    ASSERT(sourceDepth &gt; 1);
</ins><span class="cx"> 
</span><del>-    static void average(R32G32F *dst, const R32G32F *src1, const R32G32F *src2)
</del><ins>+    for (unsigned int z = 0; z &lt; destDepth; z++)
</ins><span class="cx">     {
</span><del>-        dst-&gt;R = (src1-&gt;R + src2-&gt;R) * 0.5f;
-        dst-&gt;G = (src1-&gt;G + src2-&gt;G) * 0.5f;
-    }
-};
</del><ins>+        for (unsigned int x = 0; x &lt; destWidth; x++)
+        {
+            const T *src0 = GetPixel&lt;T&gt;(sourceData, x * 2, 0, z * 2, sourceRowPitch, sourceDepthPitch);
+            const T *src1 = GetPixel&lt;T&gt;(sourceData, x * 2, 0, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
+            const T *src2 = GetPixel&lt;T&gt;(sourceData, x * 2 + 1, 0, z * 2, sourceRowPitch, sourceDepthPitch);
+            const T *src3 = GetPixel&lt;T&gt;(sourceData, x * 2 + 1, 0, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
+            T *dst = GetPixel&lt;T&gt;(destData, x, 0, z, destRowPitch, destDepthPitch);
</ins><span class="cx"> 
</span><del>-struct R32G32B32F
-{
-    float R;
-    float G;
-    float B;
</del><ins>+            T tmp0, tmp1;
</ins><span class="cx"> 
</span><del>-    static void average(R32G32B32F *dst, const R32G32B32F *src1, const R32G32B32F *src2)
-    {
-        dst-&gt;R = (src1-&gt;R + src2-&gt;R) * 0.5f;
-        dst-&gt;G = (src1-&gt;G + src2-&gt;G) * 0.5f;
-        dst-&gt;B = (src1-&gt;B + src2-&gt;B) * 0.5f;
</del><ins>+            T::average(&amp;tmp0, src0, src1);
+            T::average(&amp;tmp1, src2, src3);
+            T::average(dst, &amp;tmp0, &amp;tmp1);
+        }
</ins><span class="cx">     }
</span><del>-};
</del><ins>+}
</ins><span class="cx"> 
</span><span class="cx"> template &lt;typename T&gt;
</span><del>-static void GenerateMip(unsigned int sourceWidth, unsigned int sourceHeight,
-                        const unsigned char *sourceData, int sourcePitch,
-                        unsigned char *destData, int destPitch)
</del><ins>+static void GenerateMip_XYZ(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                            const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                            unsigned int destWidth, unsigned int destHeight, unsigned int destDepth,
+                            unsigned char *destData, int destRowPitch, int destDepthPitch)
</ins><span class="cx"> {
</span><del>-    unsigned int mipWidth = std::max(1U, sourceWidth &gt;&gt; 1);
-    unsigned int mipHeight = std::max(1U, sourceHeight &gt;&gt; 1);
</del><ins>+    ASSERT(sourceWidth &gt; 1);
+    ASSERT(sourceHeight &gt; 1);
+    ASSERT(sourceDepth &gt; 1);
</ins><span class="cx"> 
</span><del>-    if (sourceHeight == 1)
</del><ins>+    for (unsigned int z = 0; z &lt; destDepth; z++)
</ins><span class="cx">     {
</span><del>-        ASSERT(sourceWidth != 1);
</del><ins>+        for (unsigned int y = 0; y &lt; destHeight; y++)
+        {
+            for (unsigned int x = 0; x &lt; destWidth; x++)
+            {
+                const T *src0 = GetPixel&lt;T&gt;(sourceData, x * 2, y * 2, z * 2, sourceRowPitch, sourceDepthPitch);
+                const T *src1 = GetPixel&lt;T&gt;(sourceData, x * 2, y * 2, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
+                const T *src2 = GetPixel&lt;T&gt;(sourceData, x * 2, y * 2 + 1, z * 2, sourceRowPitch, sourceDepthPitch);
+                const T *src3 = GetPixel&lt;T&gt;(sourceData, x * 2, y * 2 + 1, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
+                const T *src4 = GetPixel&lt;T&gt;(sourceData, x * 2 + 1, y * 2, z * 2, sourceRowPitch, sourceDepthPitch);
+                const T *src5 = GetPixel&lt;T&gt;(sourceData, x * 2 + 1, y * 2, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
+                const T *src6 = GetPixel&lt;T&gt;(sourceData, x * 2 + 1, y * 2 + 1, z * 2, sourceRowPitch, sourceDepthPitch);
+                const T *src7 = GetPixel&lt;T&gt;(sourceData, x * 2 + 1, y * 2 + 1, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
+                T *dst = GetPixel&lt;T&gt;(destData, x, y, z, destRowPitch, destDepthPitch);
</ins><span class="cx"> 
</span><del>-        const T *src = (const T*)sourceData;
-        T *dst = (T*)destData;
</del><ins>+                T tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
</ins><span class="cx"> 
</span><del>-        for (unsigned int x = 0; x &lt; mipWidth; x++)
-        {
-            T::average(&amp;dst[x], &amp;src[x * 2], &amp;src[x * 2 + 1]);
-        }
-    }
-    else if (sourceWidth == 1)
-    {
-        ASSERT(sourceHeight != 1);
</del><ins>+                T::average(&amp;tmp0, src0, src1);
+                T::average(&amp;tmp1, src2, src3);
+                T::average(&amp;tmp2, src4, src5);
+                T::average(&amp;tmp3, src6, src7);
</ins><span class="cx"> 
</span><del>-        for (unsigned int y = 0; y &lt; mipHeight; y++)
-        {
-            const T *src0 = (const T*)(sourceData + y * 2 * sourcePitch);
-            const T *src1 = (const T*)(sourceData + y * 2 * sourcePitch + sourcePitch);
-            T *dst = (T*)(destData + y * destPitch);
</del><ins>+                T::average(&amp;tmp4, &amp;tmp0, &amp;tmp1);
+                T::average(&amp;tmp5, &amp;tmp2, &amp;tmp3);
</ins><span class="cx"> 
</span><del>-            T::average(dst, src0, src1);
</del><ins>+                T::average(dst, &amp;tmp4, &amp;tmp5);
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><del>-    else
-    {
-        for (unsigned int y = 0; y &lt; mipHeight; y++)
-        {
-            const T *src0 = (const T*)(sourceData + y * 2 * sourcePitch);
-            const T *src1 = (const T*)(sourceData + y * 2 * sourcePitch + sourcePitch);
-            T *dst = (T*)(destData + y * destPitch);
</del><ins>+}
</ins><span class="cx"> 
</span><del>-            for (unsigned int x = 0; x &lt; mipWidth; x++)
-            {
-                T tmp0;
-                T tmp1;
</del><span class="cx"> 
</span><del>-                T::average(&amp;tmp0, &amp;src0[x * 2], &amp;src0[x * 2 + 1]);
-                T::average(&amp;tmp1, &amp;src1[x * 2], &amp;src1[x * 2 + 1]);
-                T::average(&amp;dst[x], &amp;tmp0, &amp;tmp1);
-            }
-        }
</del><ins>+typedef void (*MipGenerationFunction)(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                                      const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                                      unsigned int destWidth, unsigned int destHeight, unsigned int destDepth,
+                                      unsigned char *destData, int destRowPitch, int destDepthPitch);
+
+template &lt;typename T&gt;
+static MipGenerationFunction GetMipGenerationFunction(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth)
+{
+    unsigned char index = ((sourceWidth &gt; 1)  ? 1 : 0) |
+                          ((sourceHeight &gt; 1) ? 2 : 0) |
+                          ((sourceDepth &gt; 1)  ? 4 : 0);
+
+    switch (index)
+    {
+      case 1:  return GenerateMip_X&lt;T&gt;;   // W x 1 x 1
+      case 2:  return GenerateMip_Y&lt;T&gt;;   // 1 x H x 1
+      case 3:  return GenerateMip_XY&lt;T&gt;;  // W x H x 1
+      case 4:  return GenerateMip_Z&lt;T&gt;;   // 1 x 1 x D
+      case 5:  return GenerateMip_XZ&lt;T&gt;;  // W x 1 x D
+      case 6:  return GenerateMip_YZ&lt;T&gt;;  // 1 x H x D
+      case 7:  return GenerateMip_XYZ&lt;T&gt;; // W x H x D
+      default: return NULL;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;typename T&gt;
+static void GenerateMip(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
+                        const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
+                        unsigned char *destData, int destRowPitch, int destDepthPitch)
+{
+    unsigned int mipWidth = std::max(1U, sourceWidth &gt;&gt; 1);
+    unsigned int mipHeight = std::max(1U, sourceHeight &gt;&gt; 1);
+    unsigned int mipDepth = std::max(1U, sourceDepth &gt;&gt; 1);
+
+    priv::MipGenerationFunction generationFunction = priv::GetMipGenerationFunction&lt;T&gt;(sourceWidth, sourceHeight, sourceDepth);
+    ASSERT(generationFunction != NULL);
+
+    generationFunction(sourceWidth, sourceHeight, sourceDepth, sourceData, sourceRowPitch, sourceDepthPitch,
+                       mipWidth, mipHeight, mipDepth, destData, destRowPitch, destDepthPitch);
+}
+
+}
+
</ins><span class="cx"> #endif // LIBGLESV2_RENDERER_GENERATEMIP_H_
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrcthird_partycompilerArrayBoundsClamperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/third_party/compiler/ArrayBoundsClamper.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/third_party/compiler/ArrayBoundsClamper.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/third_party/compiler/ArrayBoundsClamper.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -26,8 +26,6 @@
</span><span class="cx"> #ifndef THIRD_PARTY_COMPILER_ARRAY_BOUNDS_CLAMPER_H_
</span><span class="cx"> #define THIRD_PARTY_COMPILER_ARRAY_BOUNDS_CLAMPER_H_
</span><span class="cx"> 
</span><del>-#include &quot;GLSLANG/ShaderLang.h&quot;
-
</del><span class="cx"> #include &quot;compiler/translator/InfoSink.h&quot;
</span><span class="cx"> #include &quot;compiler/translator/intermediate.h&quot;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrcthird_partymurmurhashMurmurHash3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -16,20 +16,20 @@
</span><span class="cx"> 
</span><span class="cx"> #if defined(_MSC_VER)
</span><span class="cx"> 
</span><del>-#define FORCE_INLINE    __forceinline
</del><ins>+#define FORCE_INLINE        __forceinline
</ins><span class="cx"> 
</span><span class="cx"> #include &lt;stdlib.h&gt;
</span><span class="cx"> 
</span><del>-#define ROTL32(x,y) _rotl(x,y)
-#define ROTL64(x,y) _rotl64(x,y)
</del><ins>+#define ROTL32(x,y)        _rotl(x,y)
+#define ROTL64(x,y)        _rotl64(x,y)
</ins><span class="cx"> 
</span><span class="cx"> #define BIG_CONSTANT(x) (x)
</span><span class="cx"> 
</span><span class="cx"> // Other compilers
</span><span class="cx"> 
</span><del>-#else   // defined(_MSC_VER)
</del><ins>+#else        // defined(_MSC_VER)
</ins><span class="cx"> 
</span><del>-#define FORCE_INLINE __attribute__((always_inline))
</del><ins>+#define        FORCE_INLINE __attribute__((always_inline))
</ins><span class="cx"> 
</span><span class="cx"> inline uint32_t rotl32 ( uint32_t x, int8_t r )
</span><span class="cx"> {
</span><span class="lines">@@ -41,8 +41,8 @@
</span><span class="cx">   return (x &lt;&lt; r) | (x &gt;&gt; (64 - r));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#define ROTL32(x,y) rotl32(x,y)
-#define ROTL64(x,y) rotl64(x,y)
</del><ins>+#define        ROTL32(x,y)        rotl32(x,y)
+#define ROTL64(x,y)        rotl64(x,y)
</ins><span class="cx"> 
</span><span class="cx"> #define BIG_CONSTANT(x) (x##LLU)
</span><span class="cx"> 
</span><span class="cx">Property changes on: trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="allowtabs"></a>
<div class="addfile"><h4>Added: allow-tabs</h4></div>
<a id="trunkSourceThirdPartyANGLEsrcthird_partymurmurhashMurmurHash3h"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/ThirdParty/ANGLE/src/third_party/murmurhash/MurmurHash3.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -8,22 +8,8 @@
</span><span class="cx"> //-----------------------------------------------------------------------------
</span><span class="cx"> // Platform-specific functions and macros
</span><span class="cx"> 
</span><del>-// Microsoft Visual Studio
-
-#if defined(_MSC_VER)
-
-typedef unsigned char uint8_t;
-typedef unsigned long uint32_t;
-typedef unsigned __int64 uint64_t;
-
-// Other compilers
-
-#else // defined(_MSC_VER)
-
</del><span class="cx"> #include &lt;stdint.h&gt;
</span><span class="cx"> 
</span><del>-#endif // !defined(_MSC_VER)
-
</del><span class="cx"> //-----------------------------------------------------------------------------
</span><span class="cx"> 
</span><span class="cx"> void MurmurHash3_x86_32  ( const void * key, int len, uint32_t seed, void * out );
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/WebCore/CMakeLists.txt        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -3019,6 +3019,14 @@
</span><span class="cx">     endif ()
</span><span class="cx"> 
</span><span class="cx">     list(APPEND ANGLESupport_SOURCES
</span><ins>+        ${THIRDPARTY_DIR}/ANGLE/src/common/blocklayout.cpp
+        ${THIRDPARTY_DIR}/ANGLE/src/common/debug.cpp
+        ${THIRDPARTY_DIR}/ANGLE/src/common/event_tracer.cpp
+        ${THIRDPARTY_DIR}/ANGLE/src/common/mathutil.cpp
+        ${THIRDPARTY_DIR}/ANGLE/src/common/RefCountObject.cpp
+        ${THIRDPARTY_DIR}/ANGLE/src/common/shadervars.cpp
+        ${THIRDPARTY_DIR}/ANGLE/src/common/utilities.cpp
+    
</ins><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/BuiltInFunctionEmulator.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/CodeGen.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/Compiler.cpp
</span><span class="lines">@@ -3027,6 +3035,7 @@
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/Diagnostics.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/DirectiveHandler.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/ForLoopUnroll.cpp
</span><ins>+        ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/FlagStd140Structs.cpp
</ins><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/InfoSink.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/Initialize.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/InitializeDll.cpp
</span><span class="lines">@@ -3035,7 +3044,7 @@
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/Intermediate.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/IntermTraverse.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/Intermediate.cpp
</span><del>-        ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/MapLongVariableNames.cpp
</del><ins>+        ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/LoopInfo.cpp        
</ins><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/OutputESSL.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/OutputGLSL.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/OutputGLSLBase.cpp
</span><span class="lines">@@ -3054,6 +3063,7 @@
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/UnfoldShortCircuit.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/UnfoldShortCircuitAST.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/Uniform.cpp
</span><ins>+        ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/ValidateOutputs.cpp
</ins><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/ValidateLimitations.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/VariableInfo.cpp
</span><span class="cx">         ${THIRDPARTY_DIR}/ANGLE/src/compiler/translator/VariablePacker.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/WebCore/ChangeLog        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2014-04-30  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        Updated ANGLE.
+        https://bugs.webkit.org/show_bug.cgi?id=132367
+        &lt;rdar://problem/16211451&gt;
+
+        Reviewed by Dean Jackson.
+
+        * CMakeLists.txt
+        Fixed ANGLE compiling with the update.
+        * platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:
+        (WebCore::Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE):
+        Removed SH_MAP_LONG_VARIABLE_NAMES which is no longer defined in ANGLE.
+        See https://chromium.googlesource.com/angle/angle/+/3cdfcce86b38ef31a0afd71855887193a7924468
+        * platform/graphics/opengl/Extensions3DOpenGLES.h:
+        * platform/graphics/opengl/Extensions3DOpenGLES.cpp:
+        Updated type names from ANGLE.
+
</ins><span class="cx"> 2014-04-30  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move Blob.slice() implementation into BlobRegistryImpl
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopenglExtensions3DOpenGLCommoncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx"> 
</span><span class="cx">     String translatedShaderSource;
</span><span class="cx">     String shaderInfoLog;
</span><del>-    int extraCompileOptions = SH_MAP_LONG_VARIABLE_NAMES | SH_CLAMP_INDIRECT_ARRAY_BOUNDS | SH_UNFOLD_SHORT_CIRCUIT | SH_ENFORCE_PACKING_RESTRICTIONS | SH_INIT_VARYINGS_WITHOUT_STATIC_USE;
</del><ins>+    int extraCompileOptions = SH_CLAMP_INDIRECT_ARRAY_BOUNDS | SH_UNFOLD_SHORT_CIRCUIT | SH_ENFORCE_PACKING_RESTRICTIONS | SH_INIT_VARYINGS_WITHOUT_STATIC_USE;
</ins><span class="cx"> 
</span><span class="cx">     if (m_requiresBuiltInFunctionEmulation)
</span><span class="cx">         extraCompileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopenglExtensions3DOpenGLEScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -272,8 +272,8 @@
</span><span class="cx">             m_glIsVertexArrayOES = reinterpret_cast&lt;PFNGLISVERTEXARRAYOESPROC&gt;(eglGetProcAddress(&quot;glIsVertexArrayOES&quot;));
</span><span class="cx">             m_supportsOESvertexArrayObject = true;
</span><span class="cx">         } else if (!m_supportsIMGMultisampledRenderToTexture &amp;&amp; name == &quot;GL_IMG_multisampled_render_to_texture&quot;) {
</span><del>-            m_glFramebufferTexture2DMultisampleIMG = reinterpret_cast&lt;PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG&gt;(eglGetProcAddress(&quot;glFramebufferTexture2DMultisampleIMG&quot;));
-            m_glRenderbufferStorageMultisampleIMG = reinterpret_cast&lt;PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG&gt;(eglGetProcAddress(&quot;glRenderbufferStorageMultisampleIMG&quot;));
</del><ins>+            m_glFramebufferTexture2DMultisampleIMG = reinterpret_cast&lt;PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC&gt;(eglGetProcAddress(&quot;glFramebufferTexture2DMultisampleIMG&quot;));
+            m_glRenderbufferStorageMultisampleIMG = reinterpret_cast&lt;PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC&gt;(eglGetProcAddress(&quot;glRenderbufferStorageMultisampleIMG&quot;));
</ins><span class="cx">             m_supportsIMGMultisampledRenderToTexture = true;
</span><span class="cx">         } else if (!m_glGetGraphicsResetStatusEXT &amp;&amp; name == &quot;GL_EXT_robustness&quot;) {
</span><span class="cx">             m_glGetGraphicsResetStatusEXT = reinterpret_cast&lt;PFNGLGETGRAPHICSRESETSTATUSEXTPROC&gt;(eglGetProcAddress(&quot;glGetGraphicsResetStatusEXT&quot;));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopenglExtensions3DOpenGLESh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h (168054 => 168055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h        2014-04-30 22:52:30 UTC (rev 168054)
+++ trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h        2014-04-30 22:57:08 UTC (rev 168055)
</span><span class="lines">@@ -106,8 +106,8 @@
</span><span class="cx">     bool m_supportsIMGMultisampledRenderToTexture;
</span><span class="cx">     bool m_supportsANGLEinstancedArrays;
</span><span class="cx"> 
</span><del>-    PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG m_glFramebufferTexture2DMultisampleIMG;
-    PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG m_glRenderbufferStorageMultisampleIMG;
</del><ins>+    PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC m_glFramebufferTexture2DMultisampleIMG;
+    PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC m_glRenderbufferStorageMultisampleIMG;
</ins><span class="cx">     PFNGLBINDVERTEXARRAYOESPROC m_glBindVertexArrayOES;
</span><span class="cx">     PFNGLDELETEVERTEXARRAYSOESPROC m_glDeleteVertexArraysOES;
</span><span class="cx">     PFNGLGENVERTEXARRAYSOESPROC m_glGenVertexArraysOES;
</span></span></pre>
</div>
</div>

</body>
</html>