diff --git a/gfx/angle/.gitignore b/gfx/angle/.gitignore new file mode 100644 index 000000000000..b42d00434bed --- /dev/null +++ b/gfx/angle/.gitignore @@ -0,0 +1,9 @@ +Debug +Release +*.sdf +*.ncb +*.suo +*.vcproj.* +*.vcxproj.user +patches-* +*.target.mk diff --git a/gfx/angle/AUTHORS b/gfx/angle/AUTHORS index 6b93e4cc4d36..a2ce91575aee 100644 --- a/gfx/angle/AUTHORS +++ b/gfx/angle/AUTHORS @@ -4,15 +4,29 @@ # See the latter for an explanation. # Names should be added to this file as -# Name or Organization -# The email address is not required for organizations. - -TransGaming Inc. +# Name or Organization +# Email addresses for individuals are tracked elsewhere to avoid spam. Google Inc. - +TransGaming Inc. 3DLabs Inc. Ltd. +Adobe Systems Inc. +Autodesk, Inc. Cloud Party, Inc. +Intel Corporation +Mozilla Corporation +Turbulenz +Klarälvdalens Datakonsult AB -Jacek Caban +Jacek Caban +Mark Callow +Ginn Chen +James Hauxwell +Sam Hocevar +Pierre Leveille +Jonathan Liu +Boying Lu +Aitor Moreno +Yuri O'Donnell +Josh Soref diff --git a/gfx/angle/CONTRIBUTORS b/gfx/angle/CONTRIBUTORS index 212784d4640d..1859e40c0bf3 100644 --- a/gfx/angle/CONTRIBUTORS +++ b/gfx/angle/CONTRIBUTORS @@ -17,9 +17,13 @@ Google Inc. Brent Austin Michael Bai John Bauman + Peter Beverloo Steve Block + Rachel Blum + Eric Boren Henry Bridge Nat Duca + Peter Kasting Vangelis Kokkevis Zhenyao Mo Daniel Nicoara @@ -27,34 +31,43 @@ Google Inc. Alok Priyadarshi Kenneth Russell Brian Salomon + Gregg Tavares + Jeff Timanus Ben Vanik Adrienne Walker + thestig@chromium.org + +Adobe Systems Inc. + Alexandru Chiculita + Steve Minns + Max Vujovic + +Autodesk, Inc. + Ranger Harke + +Cloud Party, Inc. + Conor Dickinson + +Intel Corporation + Jin Yang + Andy Chen + Josh Triplett + +Klarälvdalens Datakonsult AB + Milian Wolff Mozilla Corp. Ehsan Akhgari + Jeff Gilbert Mike Hommey Benoit Jacob Makoto Kato Vladimir Vukicevic -Apple Inc. - David Kilzer +Turbulenz + Michael Braithwaite -Adobe Systems Inc. - Alexandru Chiculita - Max Vujovic - -Cloud Party, Inc. - Conor Dickinson - -Aitor Moreno -Jim Hauxwell -ddefrostt -timeless -Yore Apex -Mark Callow -Yuriy O'Donnell -Sam Hocevar -Pierre Leveille -Jin Yang +Ulrik Persson (ddefrostt) +Mark Banner (standard8mbp) +David Kilzer diff --git a/gfx/angle/LICENSE.preprocessor b/gfx/angle/LICENSE.preprocessor deleted file mode 100644 index 0ec2123b61f6..000000000000 --- a/gfx/angle/LICENSE.preprocessor +++ /dev/null @@ -1,45 +0,0 @@ -Files in src/compiler/preprocessor are provided under the following license: - -**************************************************************************** -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**************************************************************************** diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in index 6971b9fc2801..235097bcfe67 100644 --- a/gfx/angle/Makefile.in +++ b/gfx/angle/Makefile.in @@ -1,18 +1,17 @@ -# # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -MODULE = angle -LIBRARY_NAME = angle -LIBXUL_LIBRARY = 1 +MODULE = angle +LIBRARY_NAME = angle +LIBXUL_LIBRARY = 1 ifeq (WINNT,$(OS_TARGET)) VISIBILITY_FLAGS = endif @@ -20,104 +19,113 @@ endif EXPORTS_NAMESPACES = angle EXPORTS_angle = \ - include/GLSLANG/ShaderLang.h \ - $(NULL) + include/GLSLANG/ShaderLang.h \ + include/KHR/khrplatform.h \ + $(NULL) -LOCAL_INCLUDES += -I$(srcdir)/include -I$(srcdir)/src - -VPATH += $(srcdir)/src -VPATH += $(srcdir)/src/compiler -VPATH += $(srcdir)/src/compiler/preprocessor -VPATH += $(srcdir)/src/compiler/preprocessor/new -VPATH += $(srcdir)/src/compiler/timing -VPATH += $(srcdir)/src/compiler/depgraph - -CPPSRCS = \ - Diagnostics.cpp \ - PreprocessorDiagnostics.cpp \ - DirectiveHandler.cpp \ - PreprocessorDirectiveHandler.cpp \ - DirectiveParser.cpp \ - ExpressionParser.cpp \ - Macro.cpp \ - MacroExpander.cpp \ - Tokenizer.cpp \ - InitializeParseContext.cpp \ - DependencyGraph.cpp \ - DependencyGraphBuilder.cpp \ - DependencyGraphOutput.cpp \ - DependencyGraphTraverse.cpp \ - RestrictFragmentShaderTiming.cpp \ - RestrictVertexShaderTiming.cpp \ - Compiler.cpp \ - DetectRecursion.cpp \ - InfoSink.cpp \ - Initialize.cpp \ - InitializeDll.cpp \ - Intermediate.cpp \ - intermOut.cpp \ - IntermTraverse.cpp \ - parseConst.cpp \ - ParseHelper.cpp \ - PoolAlloc.cpp \ - QualifierAlive.cpp \ - RemoveTree.cpp \ - ShaderLang.cpp \ - SymbolTable.cpp \ - VariableInfo.cpp \ - compilerdebug.cpp \ - util.cpp \ - ValidateLimitations.cpp \ - ForLoopUnroll.cpp \ - MapLongVariableNames.cpp \ - spooky.cpp \ - BuiltInFunctionEmulator.cpp \ - Input.cpp \ - Lexer.cpp \ - Preprocessor.cpp \ - Token.cpp \ - VariablePacker.cpp \ - $(NULL) - -# flex/yacc generated files -CPPSRCS += \ - glslang_lex.cpp \ - glslang_tab.cpp \ - $(NULL) - -# GLSL translator backend -CPPSRCS += \ - CodeGenGLSL.cpp \ - OutputGLSL.cpp \ - TranslatorGLSL.cpp \ - VersionGLSL.cpp \ - OutputESSL.cpp \ - OutputGLSLBase.cpp \ - TranslatorESSL.cpp \ - $(NULL) - -ifeq ($(MOZ_WIDGET_TOOLKIT),windows) -CPPSRCS += ossource_win.cpp $(NULL) -else -CPPSRCS += ossource_posix.cpp $(NULL) -endif - -CSRCS = \ - atom.c \ - cpp.c \ - cppstruct.c \ - memory.c \ - scanner.c \ - symbols.c \ - tokens.c \ - $(NULL) - -DEFINES += -DANGLE_BUILD -DCOMPILER_IMPLEMENTATION - -#these defines are from ANGLE's build_angle.gyp +# The below is a rough translation of build_angle.gypi: DEFINES += -DANGLE_DISABLE_TRACE DEFINES += -DANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL0 -DEFINES += -DANGLE_USE_NEW_PREPROCESSOR=1 + +# Target: 'preprocessor' +# src/compiler/preprocessor: +VPATH += $(srcdir)/src/compiler/preprocessor +CPPSRCS += \ + PreprocessorDiagnostics.cpp \ + PreprocessorDirectiveHandler.cpp \ + DirectiveParser.cpp \ + ExpressionParser.cpp \ + Input.cpp \ + Lexer.cpp \ + Macro.cpp \ + MacroExpander.cpp \ + Preprocessor.cpp \ + Token.cpp \ + Tokenizer.cpp \ + $(NULL) + +# Target: 'translator_common' +# Requires: 'preprocessor' +LOCAL_INCLUDES += \ + -I$(srcdir)/include \ + -I$(srcdir)/include/KHR \ + -I$(srcdir)/src + +DEFINES += -DCOMPILER_IMPLEMENTATION + +VPATH += $(srcdir)/src/compiler +# src/compiler: +CPPSRCS += \ + BuiltInFunctionEmulator.cpp \ + Compiler.cpp \ + compiler_debug.cpp \ + DetectRecursion.cpp \ + Diagnostics.cpp \ + DirectiveHandler.cpp \ + ForLoopUnroll.cpp \ + glslang_lex.cpp \ + glslang_tab.cpp \ + InfoSink.cpp \ + Initialize.cpp \ + InitializeDll.cpp \ + InitializeParseContext.cpp \ + Intermediate.cpp \ + intermOut.cpp \ + IntermTraverse.cpp \ + MapLongVariableNames.cpp \ + parseConst.cpp \ + ParseHelper.cpp \ + PoolAlloc.cpp \ + QualifierAlive.cpp \ + RemoveTree.cpp \ + spooky.cpp \ + SymbolTable.cpp \ + util.cpp \ + ValidateLimitations.cpp \ + VariableInfo.cpp \ + VariablePacker.cpp \ + $(NULL) + +VPATH += $(srcdir)/src/compiler/depgraph +# src/compiler/depgraph: +CPPSRCS += \ + DependencyGraph.cpp \ + DependencyGraphBuilder.cpp \ + DependencyGraphOutput.cpp \ + DependencyGraphTraverse.cpp \ + $(NULL) + +VPATH += $(srcdir)/src/compiler/timing +# src/compiler/timing: +CPPSRCS += \ + RestrictFragmentShaderTiming.cpp \ + RestrictVertexShaderTiming.cpp \ + $(NULL) + +ifeq ($(MOZ_WIDGET_TOOLKIT),windows) +CPPSRCS += ossource_win.cpp +else +CPPSRCS += ossource_posix.cpp +endif + + +# Target: 'translator_glsl' +# Requires: 'translator_common' +# src/compiler: +CPPSRCS += \ + CodeGenGLSL.cpp \ + OutputESSL.cpp \ + OutputGLSLBase.cpp \ + OutputGLSL.cpp \ + ShaderLang.cpp \ + TranslatorESSL.cpp \ + TranslatorGLSL.cpp \ + VersionGLSL.cpp \ + $(NULL) + + +# End gpy translation. Remainder of targets are in src/libEGL/Makefile.in and +# src/libGLESv2/Makefile.in ifdef MOZ_ANGLE_RENDERER @@ -136,3 +144,8 @@ endif include $(topsrcdir)/config/rules.mk +# We have to filter out -pedantic, because of +# comma-at-end-of-enumerator list failures. We can try to get this fixed +# upstream at some point. +CXXFLAGS := $(filter-out -pedantic,$(CXXFLAGS)) +CFLAGS := $(filter-out -pedantic,$(CFLAGS)) diff --git a/gfx/angle/README.mozilla b/gfx/angle/README.mozilla index f9a4cd91550b..10904ed10b64 100644 --- a/gfx/angle/README.mozilla +++ b/gfx/angle/README.mozilla @@ -1,45 +1,81 @@ This is the ANGLE project, from http://code.google.com/p/angleproject/ -Current revision: r1267 +Current revision: r1561 + == Applied local patches == - In this order: - - angle-renaming-debug.patch - rename debug.h to compilerdebug.h to avoid conflict in our makefiles - - angle-renaming-preprocessor-diagonostics.patch - rename one of the two Diagnostics.cpp to avoid conflict in our makefiles - - angle-renaming-preprocessor-directivehandler.patch - rename one of the two DirectiveHandler.cpp to avoid conflict in our makefiles - - angle-enforce-readpixels-spec.patch - see bug 724476 - - angle-impl-read-bgra.patch - see bug 724476 - - gfx/angle/angle-long-identifier-hash-spooky.patch - see bug 676071 - - angle-abort-on-oom-in-preprocessor.patch - see bug 680840. Probably not useful anymore now that we're on the new - preprocessor, but it doesn't hurt to keep it around a bit longer. - - angle-faceforward-emu.patch - See bug 771406. Adds emulation for faceforward(float,float,float), - which is needed to prevent crashing on Mac+Intel. - - angle-r1278.patch - Imports ANGLE r1278, which fixes ANGLE bug 350, a crasher. + angle-build-stdcall-alias.patch: + Fix an issue GCC has with linking to undecorated stdcalls. + + angle-build-dedupe-debug-cpp-h.patch: + Rename: "src/compiler/debug.{cpp,h}" + To: "src/compiler/compiler_debug.{cpp,h}" + Repair includes accordingly. + + angle-build-dedupe-preproc-files.patch: + Rename: "src/compiler/preprocessor/Diagnostics.cpp" + To: "src/compiler/preprocessor/PreprocessorDiagnostics.cpp" + Rename: "src/compiler/preprocessor/DirectiveHandler.cpp" + To: "src/compiler/preprocessor/PreprocessorDirectiveHandler.cpp" + + angle-long-ident-spooky-hash.patch: + Use Spooky Hash for long identifier hashing. See bug 676071. + + angle-faceforward-emu.patch: + Adds emulation for faceforward(float,float,float), which is needed to + prevent crashing on Mac+Intel. See bug 771406. In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE. Therefore, changes made to the Makefile.in files should not be stored in the local .patch files. -== How to update this ANGLE copy == + +== How to do a clean-slate upgrade == +1. Backup our moz-specific files: + README.mozilla + Makefile.in + *.patch + src/libEGL/Makefile.in + src/libGLESv2/Makefile.in + +2. $ rm -rf gfx/angle + +3. Copy the folder containing the angle rev you want onto gfx/angle. + $ svn export -r /gfx/angle + +4. Fold our moz-specific files into this new angle folder. (Makefiles, README) +4a. Remove the unused directories. (test/, samples/, etc) + +5. Clear out the "Applied Local Patches" section above, since we're going to + repopulate it. + +6. Re-apply the angle-build-*.patch files and record them above. + +7. Update the Makefile.in files with the current deps from the .gyp(i) files. + +8. Build. Fix things until it builds. + +9. Reapply the rest of the .patch files and record them above. + +10. Try runs and reviews! + + +== Applying Diffs == +In general: +$ patch -p1 -R < gfx/angle/angle-some-bug-fix.patch + +SVN diffs however can be iffy. They don't seem to be completely compatible +with `patch`. Be aware that you'll likely get rejects whenever a file is +removed. + + + +== How to do an incremental update == +Same general idea here, but instead of nuking the ANGLE dir, we're going to +have to get a diff between revs from SVN, and deal with applying that. We +also naturally have to peel off our local patches before we can apply a diff +from upstream. 1. Unapply patches @@ -130,10 +166,10 @@ new patches that you need to add to get this update to work. You do not need a review for the ANGLE diff itself and for trivial updates of existing patches. -== Visual Studio Solution Files == +== Visual Studio Solution Files == Ignore these. We don't use them anymore. We use custom Makefiles. -== Generated parser code== +== Generated parser code== Don't bother about that anymore. The parser is now generated and included in the ANGLE svn repo. diff --git a/gfx/angle/angle-1317.patch b/gfx/angle/angle-1317.patch deleted file mode 100644 index ae01eb734e9f..000000000000 --- a/gfx/angle/angle-1317.patch +++ /dev/null @@ -1,732 +0,0 @@ -# HG changeset patch -# Parent ef5d80327785b28df0bd778acc86f4987ba5a678 - -diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in ---- a/gfx/angle/Makefile.in -+++ b/gfx/angle/Makefile.in -@@ -71,16 +71,17 @@ CPPSRCS = \ - ForLoopUnroll.cpp \ - MapLongVariableNames.cpp \ - spooky.cpp \ - BuiltInFunctionEmulator.cpp \ - Input.cpp \ - Lexer.cpp \ - Preprocessor.cpp \ - Token.cpp \ -+ VariablePacker.cpp \ - $(NULL) - - # flex/yacc generated files - CPPSRCS += \ - glslang_lex.cpp \ - glslang_tab.cpp \ - $(NULL) - -diff --git a/gfx/angle/include/GLSLANG/ShaderLang.h b/gfx/angle/include/GLSLANG/ShaderLang.h ---- a/gfx/angle/include/GLSLANG/ShaderLang.h -+++ b/gfx/angle/include/GLSLANG/ShaderLang.h -@@ -137,17 +137,20 @@ typedef enum { - SH_TIMING_RESTRICTIONS = 0x0200, - - // This flag prints the dependency graph that is used to enforce timing - // restrictions on fragment shaders. - // This flag only has an effect if all of the following are true: - // - The shader spec is SH_WEBGL_SPEC. - // - The compile options contain the SH_TIMING_RESTRICTIONS flag. - // - The shader type is SH_FRAGMENT_SHADER. -- SH_DEPENDENCY_GRAPH = 0x0400 -+ SH_DEPENDENCY_GRAPH = 0x0400, -+ -+ // Enforce the GLSL 1.017 Appendix A section 7 packing restrictions. -+ SH_ENFORCE_PACKING_RESTRICTIONS = 0x0800, - } ShCompileOptions; - - // - // Driver must call this first, once, before doing any other - // compiler operations. - // If the function succeeds, the return value is nonzero, else zero. - // - COMPILER_EXPORT int ShInitialize(); -diff --git a/gfx/angle/src/compiler/Compiler.cpp b/gfx/angle/src/compiler/Compiler.cpp ---- a/gfx/angle/src/compiler/Compiler.cpp -+++ b/gfx/angle/src/compiler/Compiler.cpp -@@ -9,16 +9,17 @@ - #include "compiler/ForLoopUnroll.h" - #include "compiler/Initialize.h" - #include "compiler/InitializeParseContext.h" - #include "compiler/MapLongVariableNames.h" - #include "compiler/ParseHelper.h" - #include "compiler/RenameFunction.h" - #include "compiler/ShHandle.h" - #include "compiler/ValidateLimitations.h" -+#include "compiler/VariablePacker.h" - #include "compiler/depgraph/DependencyGraph.h" - #include "compiler/depgraph/DependencyGraphOutput.h" - #include "compiler/timing/RestrictFragmentShaderTiming.h" - #include "compiler/timing/RestrictVertexShaderTiming.h" - - bool isWebGLBasedSpec(ShShaderSpec spec) - { - return spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC; -@@ -108,16 +109,19 @@ TCompiler::TCompiler(ShShaderType type, - TCompiler::~TCompiler() - { - ASSERT(longNameMap); - longNameMap->Release(); - } - - bool TCompiler::Init(const ShBuiltInResources& resources) - { -+ maxUniformVectors = (shaderType == SH_VERTEX_SHADER) ? -+ resources.MaxVertexUniformVectors : -+ resources.MaxFragmentUniformVectors; - TScopedPoolAllocator scopedAlloc(&allocator, false); - - // Generate built-in symbol table. - if (!InitBuiltInSymbolTable(resources)) - return false; - InitExtensionBehavior(resources, extensionBehavior); - - return true; -@@ -187,18 +191,25 @@ bool TCompiler::compile(const char* cons - builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root); - - // Call mapLongVariableNames() before collectAttribsUniforms() so in - // collectAttribsUniforms() we already have the mapped symbol names and - // we could composite mapped and original variable names. - if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES)) - mapLongVariableNames(root); - -- if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) -+ if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) { - collectAttribsUniforms(root); -+ if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS) { -+ success = enforcePackingRestrictions(); -+ if (!success) { -+ infoSink.info.message(EPrefixError, "too many uniforms"); -+ } -+ } -+ } - - if (success && (compileOptions & SH_INTERMEDIATE_TREE)) - intermediate.outputTree(root); - - if (success && (compileOptions & SH_OBJECT_CODE)) - translate(root); - } - -@@ -305,16 +316,22 @@ bool TCompiler::enforceVertexShaderTimin - } - - void TCompiler::collectAttribsUniforms(TIntermNode* root) - { - CollectAttribsUniforms collect(attribs, uniforms); - root->traverse(&collect); - } - -+bool TCompiler::enforcePackingRestrictions() -+{ -+ VariablePacker packer; -+ return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms); -+} -+ - void TCompiler::mapLongVariableNames(TIntermNode* root) - { - ASSERT(longNameMap); - MapLongVariableNames map(longNameMap); - root->traverse(&map); - } - - int TCompiler::getMappedNameMaxLength() const -diff --git a/gfx/angle/src/compiler/ShHandle.h b/gfx/angle/src/compiler/ShHandle.h ---- a/gfx/angle/src/compiler/ShHandle.h -+++ b/gfx/angle/src/compiler/ShHandle.h -@@ -83,32 +83,37 @@ protected: - // functionality mandated in GLSL 1.0 spec Appendix A. - bool validateLimitations(TIntermNode* root); - // Collect info for all attribs and uniforms. - void collectAttribsUniforms(TIntermNode* root); - // Map long variable names into shorter ones. - void mapLongVariableNames(TIntermNode* root); - // Translate to object code. - virtual void translate(TIntermNode* root) = 0; -+ // Returns true if, after applying the packing rules in the GLSL 1.017 spec -+ // Appendix A, section 7, the shader does not use too many uniforms. -+ bool enforcePackingRestrictions(); - // Returns true if the shader passes the restrictions that aim to prevent timing attacks. - bool enforceTimingRestrictions(TIntermNode* root, bool outputGraph); - // Returns true if the shader does not use samplers. - bool enforceVertexShaderTimingRestrictions(TIntermNode* root); - // Returns true if the shader does not use sampler dependent values to affect control - // flow or in operations whose time can depend on the input values. - bool enforceFragmentShaderTimingRestrictions(const TDependencyGraph& graph); - // Get built-in extensions with default behavior. - const TExtensionBehavior& getExtensionBehavior() const; - - const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const; - - private: - ShShaderType shaderType; - ShShaderSpec shaderSpec; - -+ int maxUniformVectors; -+ - // Built-in symbol table for the given language, spec, and resources. - // It is preserved from compile-to-compile. - TSymbolTable symbolTable; - // Built-in extensions with default behavior. - TExtensionBehavior extensionBehavior; - - BuiltInFunctionEmulator builtInFunctionEmulator; - -diff --git a/gfx/angle/src/compiler/VariableInfo.cpp b/gfx/angle/src/compiler/VariableInfo.cpp ---- a/gfx/angle/src/compiler/VariableInfo.cpp -+++ b/gfx/angle/src/compiler/VariableInfo.cpp -@@ -133,16 +133,26 @@ void getUserDefinedVariableInfo(const TT - const TType* fieldType = (*structure)[i].type; - getVariableInfo(*fieldType, - name + "." + fieldType->getFieldName(), - mappedName + "." + fieldType->getFieldName(), - infoList); - } - } - -+TVariableInfo::TVariableInfo() -+{ -+} -+ -+TVariableInfo::TVariableInfo(ShDataType type, int size) -+ : type(type), -+ size(size) -+{ -+} -+ - CollectAttribsUniforms::CollectAttribsUniforms(TVariableInfoList& attribs, - TVariableInfoList& uniforms) - : mAttribs(attribs), - mUniforms(uniforms) - { - } - - // We are only interested in attribute and uniform variable declaration. -diff --git a/gfx/angle/src/compiler/VariableInfo.h b/gfx/angle/src/compiler/VariableInfo.h ---- a/gfx/angle/src/compiler/VariableInfo.h -+++ b/gfx/angle/src/compiler/VariableInfo.h -@@ -8,16 +8,19 @@ - #define COMPILER_VARIABLE_INFO_H_ - - #include "GLSLANG/ShaderLang.h" - #include "compiler/intermediate.h" - - // Provides information about a variable. - // It is currently being used to store info about active attribs and uniforms. - struct TVariableInfo { -+ TVariableInfo(ShDataType type, int size); -+ TVariableInfo(); -+ - TPersistString name; - TPersistString mappedName; - ShDataType type; - int size; - }; - typedef std::vector TVariableInfoList; - - // Traverses intermediate tree to collect all attributes and uniforms. -diff --git a/gfx/angle/src/compiler/VariablePacker.cpp b/gfx/angle/src/compiler/VariablePacker.cpp -new file mode 100644 ---- /dev/null -+++ b/gfx/angle/src/compiler/VariablePacker.cpp -@@ -0,0 +1,297 @@ -+// -+// 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 "compiler/VariablePacker.h" -+ -+#include -+#include "compiler/ShHandle.h" -+ -+namespace { -+int GetSortOrder(ShDataType type) -+{ -+ switch (type) { -+ case SH_FLOAT_MAT4: -+ return 0; -+ case SH_FLOAT_MAT2: -+ return 1; -+ case SH_FLOAT_VEC4: -+ case SH_INT_VEC4: -+ case SH_BOOL_VEC4: -+ return 2; -+ case SH_FLOAT_MAT3: -+ return 3; -+ case SH_FLOAT_VEC3: -+ case SH_INT_VEC3: -+ case SH_BOOL_VEC3: -+ return 4; -+ case SH_FLOAT_VEC2: -+ case SH_INT_VEC2: -+ case SH_BOOL_VEC2: -+ return 5; -+ case SH_FLOAT: -+ case SH_INT: -+ case SH_BOOL: -+ case SH_SAMPLER_2D: -+ case SH_SAMPLER_CUBE: -+ case SH_SAMPLER_EXTERNAL_OES: -+ case SH_SAMPLER_2D_RECT_ARB: -+ return 6; -+ default: -+ ASSERT(false); -+ return 7; -+ } -+} -+} // namespace -+ -+int VariablePacker::GetNumComponentsPerRow(ShDataType type) -+{ -+ switch (type) { -+ case SH_FLOAT_MAT4: -+ case SH_FLOAT_MAT2: -+ case SH_FLOAT_VEC4: -+ case SH_INT_VEC4: -+ case SH_BOOL_VEC4: -+ return 4; -+ case SH_FLOAT_MAT3: -+ case SH_FLOAT_VEC3: -+ case SH_INT_VEC3: -+ case SH_BOOL_VEC3: -+ return 3; -+ case SH_FLOAT_VEC2: -+ case SH_INT_VEC2: -+ case SH_BOOL_VEC2: -+ return 2; -+ case SH_FLOAT: -+ case SH_INT: -+ case SH_BOOL: -+ case SH_SAMPLER_2D: -+ case SH_SAMPLER_CUBE: -+ case SH_SAMPLER_EXTERNAL_OES: -+ case SH_SAMPLER_2D_RECT_ARB: -+ return 1; -+ default: -+ ASSERT(false); -+ return 5; -+ } -+} -+ -+int VariablePacker::GetNumRows(ShDataType type) -+{ -+ switch (type) { -+ case SH_FLOAT_MAT4: -+ return 4; -+ case SH_FLOAT_MAT3: -+ return 3; -+ case SH_FLOAT_MAT2: -+ return 1; -+ case SH_FLOAT_VEC4: -+ case SH_INT_VEC4: -+ case SH_BOOL_VEC4: -+ case SH_FLOAT_VEC3: -+ case SH_INT_VEC3: -+ case SH_BOOL_VEC3: -+ case SH_FLOAT_VEC2: -+ case SH_INT_VEC2: -+ case SH_BOOL_VEC2: -+ case SH_FLOAT: -+ case SH_INT: -+ case SH_BOOL: -+ case SH_SAMPLER_2D: -+ case SH_SAMPLER_CUBE: -+ case SH_SAMPLER_EXTERNAL_OES: -+ case SH_SAMPLER_2D_RECT_ARB: -+ return 1; -+ default: -+ ASSERT(false); -+ return 100000; -+ } -+} -+ -+struct TVariableInfoComparer { -+ bool operator()(const TVariableInfo& lhs, const TVariableInfo& rhs) const -+ { -+ int lhsSortOrder = GetSortOrder(lhs.type); -+ int rhsSortOrder = GetSortOrder(rhs.type); -+ if (lhsSortOrder != rhsSortOrder) { -+ return lhsSortOrder < rhsSortOrder; -+ } -+ // Sort by largest first. -+ return lhs.size > rhs.size; -+ } -+}; -+ -+unsigned VariablePacker::makeColumnFlags(int column, int numComponentsPerRow) -+{ -+ return ((kColumnMask << (kNumColumns - numComponentsPerRow)) & -+ kColumnMask) >> column; -+} -+ -+void VariablePacker::fillColumns(int topRow, int numRows, int column, int numComponentsPerRow) -+{ -+ unsigned columnFlags = makeColumnFlags(column, numComponentsPerRow); -+ for (int r = 0; r < numRows; ++r) { -+ int row = topRow + r; -+ ASSERT((rows_[row] & columnFlags) == 0); -+ rows_[row] |= columnFlags; -+ } -+} -+ -+bool VariablePacker::searchColumn(int column, int numRows, int* destRow, int* destSize) -+{ -+ ASSERT(destRow); -+ -+ for (; topNonFullRow_ < maxRows_ && rows_[topNonFullRow_] == kColumnMask; -+ ++topNonFullRow_) { -+ } -+ -+ for (; bottomNonFullRow_ >= 0 && rows_[bottomNonFullRow_] == kColumnMask; -+ --bottomNonFullRow_) { -+ } -+ -+ if (bottomNonFullRow_ - topNonFullRow_ + 1 < numRows) { -+ return false; -+ } -+ -+ unsigned columnFlags = makeColumnFlags(column, 1); -+ int topGoodRow = 0; -+ int smallestGoodTop = -1; -+ int smallestGoodSize = maxRows_ + 1; -+ int bottomRow = bottomNonFullRow_ + 1; -+ bool found = false; -+ for (int row = topNonFullRow_; row <= bottomRow; ++row) { -+ bool rowEmpty = row < bottomRow ? ((rows_[row] & columnFlags) == 0) : false; -+ if (rowEmpty) { -+ if (!found) { -+ topGoodRow = row; -+ found = true; -+ } -+ } else { -+ if (found) { -+ int size = row - topGoodRow; -+ if (size >= numRows && size < smallestGoodSize) { -+ smallestGoodSize = size; -+ smallestGoodTop = topGoodRow; -+ } -+ } -+ found = false; -+ } -+ } -+ if (smallestGoodTop < 0) { -+ return false; -+ } -+ -+ *destRow = smallestGoodTop; -+ if (destSize) { -+ *destSize = smallestGoodSize; -+ } -+ return true; -+} -+ -+bool VariablePacker::CheckVariablesWithinPackingLimits(int maxVectors, const TVariableInfoList& in_variables) -+{ -+ ASSERT(maxVectors > 0); -+ maxRows_ = maxVectors; -+ topNonFullRow_ = 0; -+ bottomNonFullRow_ = maxRows_ - 1; -+ TVariableInfoList variables(in_variables); -+ -+ // As per GLSL 1.017 Appendix A, Section 7 variables are packed in specific -+ // order by type, then by size of array, largest first. -+ std::sort(variables.begin(), variables.end(), TVariableInfoComparer()); -+ rows_.clear(); -+ rows_.resize(maxVectors, 0); -+ -+ // Packs the 4 column variables. -+ size_t ii = 0; -+ for (; ii < variables.size(); ++ii) { -+ const TVariableInfo& variable = variables[ii]; -+ if (GetNumComponentsPerRow(variable.type) != 4) { -+ break; -+ } -+ topNonFullRow_ += GetNumRows(variable.type) * variable.size; -+ } -+ -+ if (topNonFullRow_ > maxRows_) { -+ return false; -+ } -+ -+ // Packs the 3 column variables. -+ int num3ColumnRows = 0; -+ for (; ii < variables.size(); ++ii) { -+ const TVariableInfo& variable = variables[ii]; -+ if (GetNumComponentsPerRow(variable.type) != 3) { -+ break; -+ } -+ num3ColumnRows += GetNumRows(variable.type) * variable.size; -+ } -+ -+ if (topNonFullRow_ + num3ColumnRows > maxRows_) { -+ return false; -+ } -+ -+ fillColumns(topNonFullRow_, num3ColumnRows, 0, 3); -+ -+ // Packs the 2 column variables. -+ int top2ColumnRow = topNonFullRow_ + num3ColumnRows; -+ int twoColumnRowsAvailable = maxRows_ - top2ColumnRow; -+ int rowsAvailableInColumns01 = twoColumnRowsAvailable; -+ int rowsAvailableInColumns23 = twoColumnRowsAvailable; -+ for (; ii < variables.size(); ++ii) { -+ const TVariableInfo& variable = variables[ii]; -+ if (GetNumComponentsPerRow(variable.type) != 2) { -+ break; -+ } -+ int numRows = GetNumRows(variable.type) * variable.size; -+ if (numRows <= rowsAvailableInColumns01) { -+ rowsAvailableInColumns01 -= numRows; -+ } else if (numRows <= rowsAvailableInColumns23) { -+ rowsAvailableInColumns23 -= numRows; -+ } else { -+ return false; -+ } -+ } -+ -+ int numRowsUsedInColumns01 = -+ twoColumnRowsAvailable - rowsAvailableInColumns01; -+ int numRowsUsedInColumns23 = -+ twoColumnRowsAvailable - rowsAvailableInColumns23; -+ fillColumns(top2ColumnRow, numRowsUsedInColumns01, 0, 2); -+ fillColumns(maxRows_ - numRowsUsedInColumns23, numRowsUsedInColumns23, -+ 2, 2); -+ -+ // Packs the 1 column variables. -+ for (; ii < variables.size(); ++ii) { -+ const TVariableInfo& variable = variables[ii]; -+ ASSERT(1 == GetNumComponentsPerRow(variable.type)); -+ int numRows = GetNumRows(variable.type) * variable.size; -+ int smallestColumn = -1; -+ int smallestSize = maxRows_ + 1; -+ int topRow = -1; -+ for (int column = 0; column < kNumColumns; ++column) { -+ int row = 0; -+ int size = 0; -+ if (searchColumn(column, numRows, &row, &size)) { -+ if (size < smallestSize) { -+ smallestSize = size; -+ smallestColumn = column; -+ topRow = row; -+ } -+ } -+ } -+ -+ if (smallestColumn < 0) { -+ return false; -+ } -+ -+ fillColumns(topRow, numRows, smallestColumn, 1); -+ } -+ -+ ASSERT(variables.size() == ii); -+ -+ return true; -+} -+ -+ -+ -diff --git a/gfx/angle/src/compiler/VariablePacker.h b/gfx/angle/src/compiler/VariablePacker.h -new file mode 100644 ---- /dev/null -+++ b/gfx/angle/src/compiler/VariablePacker.h -@@ -0,0 +1,41 @@ -+// -+// 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 _VARIABLEPACKER_INCLUDED_ -+#define _VARIABLEPACKER_INCLUDED_ -+ -+#include -+#include "compiler/ShHandle.h" -+ -+class VariablePacker { -+ public: -+ // Returns true if the passed in variables pack in maxVectors following -+ // the packing rules from the GLSL 1.017 spec, Appendix A, section 7. -+ bool CheckVariablesWithinPackingLimits( -+ int maxVectors, -+ const TVariableInfoList& in_variables); -+ -+ // Gets how many components in a row a data type takes. -+ static int GetNumComponentsPerRow(ShDataType type); -+ -+ // Gets how many rows a data type takes. -+ static int GetNumRows(ShDataType type); -+ -+ private: -+ static const int kNumColumns = 4; -+ static const unsigned kColumnMask = (1 << kNumColumns) - 1; -+ -+ unsigned makeColumnFlags(int column, int numComponentsPerRow); -+ void fillColumns(int topRow, int numRows, int column, int numComponentsPerRow); -+ bool searchColumn(int column, int numRows, int* destRow, int* destSize); -+ -+ int topNonFullRow_; -+ int bottomNonFullRow_; -+ int maxRows_; -+ std::vector rows_; -+}; -+ -+#endif // _VARIABLEPACKER_INCLUDED_ -diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in ---- a/gfx/angle/src/libGLESv2/Makefile.in -+++ b/gfx/angle/src/libGLESv2/Makefile.in -@@ -84,16 +84,17 @@ CPPSRCS = \ - ForLoopUnroll.cpp \ - MapLongVariableNames.cpp \ - spooky.cpp \ - BuiltInFunctionEmulator.cpp \ - Input.cpp \ - Lexer.cpp \ - Preprocessor.cpp \ - Token.cpp \ -+ VariablePacker.cpp \ - $(NULL) - - # flex/yacc generated files - CPPSRCS += \ - glslang_lex.cpp \ - glslang_tab.cpp \ - $(NULL) - -diff --git a/gfx/angle/tests/build_tests.gyp b/gfx/angle/tests/build_tests.gyp ---- a/gfx/angle/tests/build_tests.gyp -+++ b/gfx/angle/tests/build_tests.gyp -@@ -58,16 +58,35 @@ - 'preprocessor_tests/pragma_test.cpp', - 'preprocessor_tests/PreprocessorTest.cpp', - 'preprocessor_tests/PreprocessorTest.h', - 'preprocessor_tests/space_test.cpp', - 'preprocessor_tests/token_test.cpp', - 'preprocessor_tests/version_test.cpp', - ], - }, -+ { -+ 'target_name': 'compiler_tests', -+ 'type': 'executable', -+ 'dependencies': [ -+ '../src/build_angle.gyp:translator_common', -+ 'gtest', -+ 'gmock', -+ ], -+ 'include_dirs': [ -+ '../include', -+ '../src', -+ '../third_party/googletest/include', -+ '../third_party/googlemock/include', -+ ], -+ 'sources': [ -+ '../third_party/googlemock/src/gmock_main.cc', -+ 'compiler_tests/VariablePacker_test.cpp', -+ ], -+ }, - ], - } - - # Local Variables: - # tab-width:2 - # indent-tabs-mode:nil - # End: - # vim: set expandtab tabstop=2 shiftwidth=2: -diff --git a/gfx/angle/tests/compiler_tests/VariablePacker_test.cpp b/gfx/angle/tests/compiler_tests/VariablePacker_test.cpp -new file mode 100644 ---- /dev/null -+++ b/gfx/angle/tests/compiler_tests/VariablePacker_test.cpp -@@ -0,0 +1,85 @@ -+// -+// 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 "compiler/VariablePacker.h" -+#include "gtest/gtest.h" -+ -+TEST(VariablePacking, Pack) { -+ VariablePacker packer; -+ TVariableInfoList vars; -+ const int kMaxRows = 16; -+ // test no vars. -+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); -+ -+ ShDataType types[] = { -+ SH_FLOAT_MAT4, // 0 -+ SH_FLOAT_MAT2, // 1 -+ SH_FLOAT_VEC4, // 2 -+ SH_INT_VEC4, // 3 -+ SH_BOOL_VEC4, // 4 -+ SH_FLOAT_MAT3, // 5 -+ SH_FLOAT_VEC3, // 6 -+ SH_INT_VEC3, // 7 -+ SH_BOOL_VEC3, // 8 -+ SH_FLOAT_VEC2, // 9 -+ SH_INT_VEC2, // 10 -+ SH_BOOL_VEC2, // 11 -+ SH_FLOAT, // 12 -+ SH_INT, // 13 -+ SH_BOOL, // 14 -+ SH_SAMPLER_2D, // 15 -+ SH_SAMPLER_CUBE, // 16 -+ SH_SAMPLER_EXTERNAL_OES, // 17 -+ SH_SAMPLER_2D_RECT_ARB, // 18 -+ }; -+ -+ for (size_t tt = 0; tt < sizeof(types) / sizeof(types[0]); ++tt) { -+ ShDataType type = types[tt]; -+ int num_rows = VariablePacker::GetNumRows(type); -+ int num_components_per_row = VariablePacker::GetNumComponentsPerRow(type); -+ // Check 1 of the type. -+ vars.clear(); -+ vars.push_back(TVariableInfo(type, 1)); -+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); -+ -+ // Check exactly the right amount of 1 type as an array. -+ int num_vars = kMaxRows / num_rows; -+ vars.clear(); -+ vars.push_back(TVariableInfo(type, num_vars)); -+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); -+ -+ // test too many -+ vars.clear(); -+ vars.push_back(TVariableInfo(type, num_vars + 1)); -+ EXPECT_FALSE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); -+ -+ // Check exactly the right amount of 1 type as individual vars. -+ num_vars = kMaxRows / num_rows * -+ ((num_components_per_row > 2) ? 1 : (4 / num_components_per_row)); -+ vars.clear(); -+ for (int ii = 0; ii < num_vars; ++ii) { -+ vars.push_back(TVariableInfo(type, 1)); -+ } -+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); -+ -+ // Check 1 too many. -+ vars.push_back(TVariableInfo( type, 1)); -+ EXPECT_FALSE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); -+ } -+ -+ // Test example from GLSL ES 3.0 spec chapter 11. -+ vars.clear(); -+ vars.push_back(TVariableInfo(SH_FLOAT_VEC4, 1)); -+ vars.push_back(TVariableInfo(SH_FLOAT_MAT3, 1)); -+ vars.push_back(TVariableInfo(SH_FLOAT_MAT3, 1)); -+ vars.push_back(TVariableInfo(SH_FLOAT_VEC2, 6)); -+ vars.push_back(TVariableInfo(SH_FLOAT_VEC2, 4)); -+ vars.push_back(TVariableInfo(SH_FLOAT_VEC2, 1)); -+ vars.push_back(TVariableInfo(SH_FLOAT, 3)); -+ vars.push_back(TVariableInfo(SH_FLOAT, 2)); -+ vars.push_back(TVariableInfo(SH_FLOAT, 1)); -+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); -+} -+ diff --git a/gfx/angle/angle-abort-on-oom-in-preprocessor.patch b/gfx/angle/angle-abort-on-oom-in-preprocessor.patch deleted file mode 100644 index df1c3fb12100..000000000000 --- a/gfx/angle/angle-abort-on-oom-in-preprocessor.patch +++ /dev/null @@ -1,29 +0,0 @@ -# HG changeset patch -# Parent 11023ab3d23865b71678e9a4b22a45646ec0c0f0 -diff --git a/gfx/angle/src/compiler/preprocessor/atom.c b/gfx/angle/src/compiler/preprocessor/atom.c ---- a/gfx/angle/src/compiler/preprocessor/atom.c -+++ b/gfx/angle/src/compiler/preprocessor/atom.c -@@ -327,22 +327,17 @@ static int GrowAtomTable(AtomTable *atab - newmap = realloc(atable->amap, sizeof(int)*size); - newrev = realloc(atable->arev, sizeof(int)*size); - } else { - newmap = malloc(sizeof(int)*size); - newrev = malloc(sizeof(int)*size); - atable->size = 0; - } - if (!newmap || !newrev) { -- /* failed to grow -- error */ -- if (newmap) -- atable->amap = newmap; -- if (newrev) -- atable->arev = newrev; -- return -1; -+ abort(); - } - memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int)); - memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int)); - atable->amap = newmap; - atable->arev = newrev; - atable->size = size; - } - return 0; diff --git a/gfx/angle/angle-renaming-debug.patch b/gfx/angle/angle-build-dedupe-debug-cpp-h.patch similarity index 60% rename from gfx/angle/angle-renaming-debug.patch rename to gfx/angle/angle-build-dedupe-debug-cpp-h.patch index 9d2a691535c5..189b939516d5 100644 --- a/gfx/angle/angle-renaming-debug.patch +++ b/gfx/angle/angle-build-dedupe-debug-cpp-h.patch @@ -1,5 +1,4 @@ -# HG changeset patch -# Parent 8e2ee5b1a34208fd10f501fdee330878e20df599 +From: Jeff Gilbert diff --git a/gfx/angle/src/compiler/Diagnostics.cpp b/gfx/angle/src/compiler/Diagnostics.cpp --- a/gfx/angle/src/compiler/Diagnostics.cpp @@ -14,9 +13,9 @@ diff --git a/gfx/angle/src/compiler/Diagnostics.cpp b/gfx/angle/src/compiler/Dia #include "compiler/Diagnostics.h" -#include "compiler/debug.h" -+#include "compiler/compilerdebug.h" ++#include "compiler/compiler_debug.h" #include "compiler/InfoSink.h" - #include "compiler/preprocessor/new/SourceLocation.h" + #include "compiler/preprocessor/SourceLocation.h" TDiagnostics::TDiagnostics(TInfoSink& infoSink) : mInfoSink(infoSink), @@ -36,7 +35,7 @@ diff --git a/gfx/angle/src/compiler/DirectiveHandler.cpp b/gfx/angle/src/compile #include -#include "compiler/debug.h" -+#include "compiler/compilerdebug.h" ++#include "compiler/compiler_debug.h" #include "compiler/Diagnostics.h" static TBehavior getBehavior(const std::string& str) @@ -57,15 +56,15 @@ diff --git a/gfx/angle/src/compiler/OutputGLSLBase.cpp b/gfx/angle/src/compiler/ #include "compiler/OutputGLSLBase.h" -#include "compiler/debug.h" -+#include "compiler/compilerdebug.h" ++#include "compiler/compiler_debug.h" namespace { - TString getTypeName(const TType& type) + TString arrayBrackets(const TType& type) { + ASSERT(type.isArray()); TInfoSinkBase out; - if (type.isMatrix()) - { + out << "[" << type.getArraySize() << "]"; diff --git a/gfx/angle/src/compiler/OutputHLSL.cpp b/gfx/angle/src/compiler/OutputHLSL.cpp --- a/gfx/angle/src/compiler/OutputHLSL.cpp +++ b/gfx/angle/src/compiler/OutputHLSL.cpp @@ -79,7 +78,7 @@ diff --git a/gfx/angle/src/compiler/OutputHLSL.cpp b/gfx/angle/src/compiler/Outp #include "common/angleutils.h" -#include "compiler/debug.h" -+#include "compiler/compilerdebug.h" ++#include "compiler/compiler_debug.h" #include "compiler/InfoSink.h" #include "compiler/UnfoldShortCircuit.h" #include "compiler/SearchSymbol.h" @@ -101,20 +100,20 @@ diff --git a/gfx/angle/src/compiler/Types.h b/gfx/angle/src/compiler/Types.h #include "compiler/BaseTypes.h" #include "compiler/Common.h" -#include "compiler/debug.h" -+#include "compiler/compilerdebug.h" ++#include "compiler/compiler_debug.h" + + class TType; + struct TPublicType; // // Need to have association of line numbers to types in a list for building structs. // - class TType; struct TTypeLine { - TType* type; - int line; -diff --git a/gfx/angle/src/compiler/debug.cpp b/gfx/angle/src/compiler/compilerdebug.cpp +diff --git a/gfx/angle/src/compiler/debug.cpp b/gfx/angle/src/compiler/compiler_debug.cpp rename from gfx/angle/src/compiler/debug.cpp -rename to gfx/angle/src/compiler/compilerdebug.cpp +rename to gfx/angle/src/compiler/compiler_debug.cpp --- a/gfx/angle/src/compiler/debug.cpp -+++ b/gfx/angle/src/compiler/compilerdebug.cpp ++++ b/gfx/angle/src/compiler/compiler_debug.cpp @@ -1,17 +1,17 @@ // // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. @@ -122,10 +121,11 @@ rename to gfx/angle/src/compiler/compilerdebug.cpp // found in the LICENSE file. // - // debug.cpp: Debugging utilities. +-// debug.cpp: Debugging utilities. ++// compiler_debug.cpp: Debugging utilities. -#include "compiler/debug.h" -+#include "compiler/compilerdebug.h" ++#include "compiler/compiler_debug.h" #include #include @@ -134,11 +134,11 @@ rename to gfx/angle/src/compiler/compilerdebug.cpp #include "compiler/ParseHelper.h" static const int kTraceBufferLen = 1024; -diff --git a/gfx/angle/src/compiler/debug.h b/gfx/angle/src/compiler/compilerdebug.h +diff --git a/gfx/angle/src/compiler/debug.h b/gfx/angle/src/compiler/compiler_debug.h rename from gfx/angle/src/compiler/debug.h -rename to gfx/angle/src/compiler/compilerdebug.h +rename to gfx/angle/src/compiler/compiler_debug.h --- a/gfx/angle/src/compiler/debug.h -+++ b/gfx/angle/src/compiler/compilerdebug.h ++++ b/gfx/angle/src/compiler/compiler_debug.h @@ -1,15 +1,15 @@ // // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. @@ -147,7 +147,7 @@ rename to gfx/angle/src/compiler/compilerdebug.h // -// debug.h: Debugging utilities. -+// compilerdebug.h: Debugging utilities. ++// compiler_debug.h: Debugging utilities. #ifndef COMPILER_DEBUG_H_ #define COMPILER_DEBUG_H_ @@ -159,88 +159,22 @@ rename to gfx/angle/src/compiler/compilerdebug.h diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h --- a/gfx/angle/src/compiler/osinclude.h +++ b/gfx/angle/src/compiler/osinclude.h -@@ -32,17 +32,17 @@ +@@ -30,17 +30,17 @@ #include #elif defined(ANGLE_OS_POSIX) #include #include #include - #endif // ANGLE_USE_NSPR + #endif // ANGLE_OS_WIN -#include "compiler/debug.h" -+#include "compiler/compilerdebug.h" ++#include "compiler/compiler_debug.h" // // Thread Local Storage Operations // - #if defined(ANGLE_USE_NSPR) - typedef PRUintn OS_TLSIndex; - #define OS_INVALID_TLS_INDEX 0xFFFFFFFF - #elif defined(ANGLE_OS_WIN) -diff --git a/gfx/angle/src/compiler/preprocessor/atom.c b/gfx/angle/src/compiler/preprocessor/atom.c ---- a/gfx/angle/src/compiler/preprocessor/atom.c -+++ b/gfx/angle/src/compiler/preprocessor/atom.c -@@ -46,17 +46,17 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILI - // atom.c - // - - #include - #include - #include - - #include "common/angleutils.h" --#include "compiler/debug.h" -+#include "compiler/compilerdebug.h" - #include "compiler/preprocessor/slglobals.h" - - #undef malloc - #undef realloc - #undef free - - /////////////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////// String table: ////////////////////////////////////// -diff --git a/gfx/angle/src/compiler/preprocessor/tokens.c b/gfx/angle/src/compiler/preprocessor/tokens.c ---- a/gfx/angle/src/compiler/preprocessor/tokens.c -+++ b/gfx/angle/src/compiler/preprocessor/tokens.c -@@ -46,17 +46,17 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILI - // - - #include - #include - #include - #include - - #include "common/angleutils.h" --#include "compiler/debug.h" -+#include "compiler/compilerdebug.h" - #include "compiler/preprocessor/slglobals.h" - #include "compiler/util.h" - - #if defined(_MSC_VER) - #pragma warning(disable: 4054) - #pragma warning(disable: 4152) - #endif - -diff --git a/gfx/angle/src/compiler/translator_common.vcproj b/gfx/angle/src/compiler/translator_common.vcproj ---- a/gfx/angle/src/compiler/translator_common.vcproj -+++ b/gfx/angle/src/compiler/translator_common.vcproj -@@ -580,17 +580,17 @@ - RelativePath=".\Common.h" - > - - - - - - - - + +diff --git a/gfx/angle/src/compiler/preprocessor/Diagnostics.cpp b/gfx/angle/src/compiler/preprocessor/PreprocessorDiagnostics.cpp +rename from gfx/angle/src/compiler/preprocessor/Diagnostics.cpp +rename to gfx/angle/src/compiler/preprocessor/PreprocessorDiagnostics.cpp +diff --git a/gfx/angle/src/compiler/preprocessor/DirectiveHandler.cpp b/gfx/angle/src/compiler/preprocessor/PreprocessorDirectiveHandler.cpp +rename from gfx/angle/src/compiler/preprocessor/DirectiveHandler.cpp +rename to gfx/angle/src/compiler/preprocessor/PreprocessorDirectiveHandler.cpp diff --git a/gfx/angle/angle-stdcall-alias.patch b/gfx/angle/angle-build-stdcall-alias.patch similarity index 52% rename from gfx/angle/angle-stdcall-alias.patch rename to gfx/angle/angle-build-stdcall-alias.patch index eca117a00385..f78489bd6897 100644 --- a/gfx/angle/angle-stdcall-alias.patch +++ b/gfx/angle/angle-build-stdcall-alias.patch @@ -1,13 +1,19 @@ +From: Jeff Gilbert + diff --git a/gfx/angle/src/libGLESv2/libGLESv2.def b/gfx/angle/src/libGLESv2/libGLESv2.def -index 5f935c3..2324dcb 100644 --- a/gfx/angle/src/libGLESv2/libGLESv2.def +++ b/gfx/angle/src/libGLESv2/libGLESv2.def -@@ -180,3 +180,8 @@ EXPORTS +@@ -175,8 +175,13 @@ EXPORTS + + ; EGL dependencies + glCreateContext @144 NONAME + glDestroyContext @145 NONAME + glMakeCurrent @146 NONAME glGetCurrentContext @147 NONAME glGetProcAddress @148 NONAME glBindTexImage @158 NONAME + -+ ; GCC has problems with linking to undecored stdcall functions, -+ ; so we explicitly add aliases for APIs used by EGL ++ ; GCC has problems with linking to undecorated stdcall functions, ++ ; so we explicitly add aliases for APIs used by EGL. + glGetProcAddress@4=glGetProcAddress + glBindTexImage@4=glBindTexImage diff --git a/gfx/angle/angle-enforce-readpixels-spec.patch b/gfx/angle/angle-enforce-readpixels-spec.patch deleted file mode 100644 index ff7be4c1c543..000000000000 --- a/gfx/angle/angle-enforce-readpixels-spec.patch +++ /dev/null @@ -1,33 +0,0 @@ -# HG changeset patch -# Parent a1fed68f51737972901e0d6fc829d3e044a453bd -diff --git a/gfx/angle/src/libGLESv2/libGLESv2.cpp b/gfx/angle/src/libGLESv2/libGLESv2.cpp ---- a/gfx/angle/src/libGLESv2/libGLESv2.cpp -+++ b/gfx/angle/src/libGLESv2/libGLESv2.cpp -@@ -231,27 +231,16 @@ bool validReadFormatType(GLenum format, - 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; - case gl::IMPLEMENTATION_COLOR_READ_FORMAT: - switch (type) - { - case gl::IMPLEMENTATION_COLOR_READ_TYPE: - break; - default: - return false; - } diff --git a/gfx/angle/angle-impl-read-bgra.patch b/gfx/angle/angle-impl-read-bgra.patch deleted file mode 100644 index e27686c7911c..000000000000 --- a/gfx/angle/angle-impl-read-bgra.patch +++ /dev/null @@ -1,70 +0,0 @@ -# HG changeset patch -# Parent 97ded57f965865c06306a8ef82d082064542caff -diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Context.cpp ---- a/gfx/angle/src/libGLESv2/Context.cpp -+++ b/gfx/angle/src/libGLESv2/Context.cpp -@@ -2585,16 +2585,17 @@ void Context::readPixels(GLint x, GLint - { - if (desc.Format == D3DFMT_A8R8G8B8 && - format == GL_BGRA_EXT && - type == GL_UNSIGNED_BYTE) - { - // Fast path for EXT_read_format_bgra, given - // an RGBA source buffer. Note that buffers with no - // alpha go through the slow path below. -+ // Note that this is also the combo exposed by IMPLEMENTATION_COLOR_READ_TYPE/FORMAT - memcpy(dest + j * outputPitch, - source + j * inputPitch, - (rect.right - rect.left) * 4); - continue; - } - - for (int i = 0; i < rect.right - rect.left; i++) - { -@@ -2732,20 +2733,20 @@ void Context::readPixels(GLint x, GLint - ((unsigned short)( a + 0.5f) << 15) | - ((unsigned short)(31 * r + 0.5f) << 10) | - ((unsigned short)(31 * g + 0.5f) << 5) | - ((unsigned short)(31 * b + 0.5f) << 0); - break; - default: UNREACHABLE(); - } - break; -- case GL_RGB: // IMPLEMENTATION_COLOR_READ_FORMAT -+ case GL_RGB: - switch (type) - { -- case GL_UNSIGNED_SHORT_5_6_5: // IMPLEMENTATION_COLOR_READ_TYPE -+ case GL_UNSIGNED_SHORT_5_6_5: - dest16[i + j * outputPitch / sizeof(unsigned short)] = - ((unsigned short)(31 * b + 0.5f) << 0) | - ((unsigned short)(63 * g + 0.5f) << 5) | - ((unsigned short)(31 * r + 0.5f) << 11); - break; - default: UNREACHABLE(); - } - break; -diff --git a/gfx/angle/src/libGLESv2/Context.h b/gfx/angle/src/libGLESv2/Context.h ---- a/gfx/angle/src/libGLESv2/Context.h -+++ b/gfx/angle/src/libGLESv2/Context.h -@@ -69,18 +69,18 @@ enum - MAX_VARYING_VECTORS_SM3 = 10, - MAX_TEXTURE_IMAGE_UNITS = 16, - MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF = 4, // For devices supporting vertex texture fetch - MAX_COMBINED_TEXTURE_IMAGE_UNITS_VTF = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF, - MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Coord, dx_Depth, and dx_DepthRange. dx_PointOrLines and dx_FrontCCW use separate bool registers. - MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3, - MAX_DRAW_BUFFERS = 1, - -- IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB, -- IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_SHORT_5_6_5 -+ IMPLEMENTATION_COLOR_READ_FORMAT = GL_BGRA_EXT, -+ IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_BYTE - }; - - enum QueryType - { - QUERY_ANY_SAMPLES_PASSED, - QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE, - - QUERY_TYPE_COUNT diff --git a/gfx/angle/angle-long-identifier-hash-spooky.patch b/gfx/angle/angle-long-ident-spooky-hash.patch similarity index 95% rename from gfx/angle/angle-long-identifier-hash-spooky.patch rename to gfx/angle/angle-long-ident-spooky-hash.patch index 125e04db666a..c7dff7443b0b 100644 --- a/gfx/angle/angle-long-identifier-hash-spooky.patch +++ b/gfx/angle/angle-long-ident-spooky-hash.patch @@ -1,6 +1,27 @@ # HG changeset patch -# Parent c5e7517cbb1c38ce9821ba3deca88768b4dff066 +# Parent 6a165b9e45205190517515abec94429715303081 +diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in +--- a/gfx/angle/Makefile.in ++++ b/gfx/angle/Makefile.in +@@ -73,16 +73,17 @@ CPPSRCS += \ + intermOut.cpp \ + IntermTraverse.cpp \ + MapLongVariableNames.cpp \ + parseConst.cpp \ + ParseHelper.cpp \ + PoolAlloc.cpp \ + QualifierAlive.cpp \ + RemoveTree.cpp \ ++ spooky.cpp \ + SymbolTable.cpp \ + util.cpp \ + ValidateLimitations.cpp \ + VariableInfo.cpp \ + VariablePacker.cpp \ + $(NULL) + + VPATH += $(srcdir)/src/compiler/depgraph diff --git a/gfx/angle/src/compiler/MapLongVariableNames.cpp b/gfx/angle/src/compiler/MapLongVariableNames.cpp --- a/gfx/angle/src/compiler/MapLongVariableNames.cpp +++ b/gfx/angle/src/compiler/MapLongVariableNames.cpp @@ -699,3 +720,24 @@ new file mode 100644 + + + +diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in +--- a/gfx/angle/src/libGLESv2/Makefile.in ++++ b/gfx/angle/src/libGLESv2/Makefile.in +@@ -86,16 +86,17 @@ CPPSRCS += \ + intermOut.cpp \ + IntermTraverse.cpp \ + MapLongVariableNames.cpp \ + parseConst.cpp \ + ParseHelper.cpp \ + PoolAlloc.cpp \ + QualifierAlive.cpp \ + RemoveTree.cpp \ ++ spooky.cpp \ + SymbolTable.cpp \ + util.cpp \ + ValidateLimitations.cpp \ + VariableInfo.cpp \ + VariablePacker.cpp \ + $(NULL) + + VPATH += $(srcdir)/../compiler/depgraph diff --git a/gfx/angle/angle-renaming-preprocessor-diagonostics.patch b/gfx/angle/angle-renaming-preprocessor-diagonostics.patch deleted file mode 100644 index cd7e7250c806..000000000000 --- a/gfx/angle/angle-renaming-preprocessor-diagonostics.patch +++ /dev/null @@ -1,6 +0,0 @@ -# HG changeset patch -# Parent 2cd2556d673d90f79dc29a78a927d2a38b92e14b - -diff --git a/gfx/angle/src/compiler/preprocessor/new/Diagnostics.cpp b/gfx/angle/src/compiler/preprocessor/new/PreprocessorDiagnostics.cpp -rename from gfx/angle/src/compiler/preprocessor/new/Diagnostics.cpp -rename to gfx/angle/src/compiler/preprocessor/new/PreprocessorDiagnostics.cpp diff --git a/gfx/angle/angle-renaming-preprocessor-directivehandler.patch b/gfx/angle/angle-renaming-preprocessor-directivehandler.patch deleted file mode 100644 index 937085ecd5c7..000000000000 --- a/gfx/angle/angle-renaming-preprocessor-directivehandler.patch +++ /dev/null @@ -1,6 +0,0 @@ -# HG changeset patch -# Parent a98ccd93f2ab811670cb50edca50f6381274a345 - -diff --git a/gfx/angle/src/compiler/preprocessor/new/DirectiveHandler.cpp b/gfx/angle/src/compiler/preprocessor/new/PreprocessorDirectiveHandler.cpp -rename from gfx/angle/src/compiler/preprocessor/new/DirectiveHandler.cpp -rename to gfx/angle/src/compiler/preprocessor/new/PreprocessorDirectiveHandler.cpp diff --git a/gfx/angle/extensions/ANGLE_multiple_render_targets.txt b/gfx/angle/extensions/ANGLE_multiple_render_targets.txt new file mode 100644 index 000000000000..7bac65a7476a --- /dev/null +++ b/gfx/angle/extensions/ANGLE_multiple_render_targets.txt @@ -0,0 +1,383 @@ +Name + + ANGLE_multiple_render_targets + +Name Strings + + GL_ANGLE_multiple_render_targets + +Contributors + + Contributors to GL_NV_draw_buffers + Contributors to GL_NV_fbo_color_attachments + Contributors to the OpenGL ES 2.0 specification + Contributors to the OpenGLSL ES 1.0.17 specification + Contributors to the OpenGL ES 3.0 specification + Nicolas Capens, TransGaming Inc. + Daniel Koch, TransGaming Inc. + Alastair Patrick, Google Inc. + Members of the WebGL working group + +Contact + + Daniel Koch + +Status + + Incomplete -- do not implement! + +Version + + Last Modified Data: November 13, 2012 + Revision: #5 + +Number + + TBD + +Dependencies + + OpenGL ES 2.0 is required. + + The extension is written against the OpenGL ES 2.0 specification. + + ANGLE_framebuffer_blit affects the definition of this extension. + APPLE_framebuffer_multisample affects the definitin of this extension. + +Overview + + This extension increases the number of available framebuffer object + color attachment points, extends OpenGL ES 2.0 to allow multiple output + colors, and provides a mechanism for directing those outputs to + multiple color buffers. + + This extension is similar to the combination of the GL_NV_draw_buffers + and GL_NV_fbo_color_attachments extensions, but imposes certain + restrictions informed by the OpenGL ES 3.0 API. + +New Procedures and Functions + + void DrawBuffersANGLE(sizei n, const enum *bufs); + +New Tokens + + Accepted by the parameter of GetIntegerv: + + MAX_COLOR_ATTACHMENTS_ANGLE 0x8CDF + + Accepted by the parameters of GetIntegerv and GetFloatv: + + MAX_DRAW_BUFFERS_ANGLE 0x8824 + DRAW_BUFFER0_ANGLE 0x8825 + DRAW_BUFFER1_ANGLE 0x8826 + DRAW_BUFFER2_ANGLE 0x8827 + DRAW_BUFFER3_ANGLE 0x8828 + DRAW_BUFFER4_ANGLE 0x8829 + DRAW_BUFFER5_ANGLE 0x882A + DRAW_BUFFER6_ANGLE 0x882B + DRAW_BUFFER7_ANGLE 0x882C + DRAW_BUFFER8_ANGLE 0x882D + DRAW_BUFFER9_ANGLE 0x882E + DRAW_BUFFER10_ANGLE 0x882F + DRAW_BUFFER11_ANGLE 0x8830 + DRAW_BUFFER12_ANGLE 0x8831 + DRAW_BUFFER13_ANGLE 0x8832 + DRAW_BUFFER14_ANGLE 0x8833 + DRAW_BUFFER15_ANGLE 0x8834 + + Accepted by the parameter of FramebufferRenderbuffer, + FramebufferTexture2D and GetFramebufferAttachmentParameteriv, and by + the parameter of DrawBuffersANGLE: + + COLOR_ATTACHMENT0_ANGLE 0x8CE0 + COLOR_ATTACHMENT1_ANGLE 0x8CE1 + COLOR_ATTACHMENT2_ANGLE 0x8CE2 + COLOR_ATTACHMENT3_ANGLE 0x8CE3 + COLOR_ATTACHMENT4_ANGLE 0x8CE4 + COLOR_ATTACHMENT5_ANGLE 0x8CE5 + COLOR_ATTACHMENT6_ANGLE 0x8CE6 + COLOR_ATTACHMENT7_ANGLE 0x8CE7 + COLOR_ATTACHMENT8_ANGLE 0x8CE8 + COLOR_ATTACHMENT9_ANGLE 0x8CE9 + COLOR_ATTACHMENT10_ANGLE 0x8CEA + COLOR_ATTACHMENT11_ANGLE 0x8CEB + COLOR_ATTACHMENT12_ANGLE 0x8CEC + COLOR_ATTACHMENT13_ANGLE 0x8CED + COLOR_ATTACHMENT14_ANGLE 0x8CEE + COLOR_ATTACHMENT15_ANGLE 0x8CEF + + The COLOR_ATTACHMENT0_ANGLE constant is equal to the + COLOR_ATTACHMENT0 constant. + + Each COLOR_ATTACHMENT_ANGLE adheres to COLOR_ATTACHMENT_ANGLE + = COLOR_ATTACHMENT0_ANGLE + . + +Changes to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization) + + Section 3.2, (Multisampling). Replace the second paragraph: + + An additional buffer, called the multisample buffer, is added to the + window system-provided framebuffer. Pixel sample values, including + color, depth, and stencil values, are stored in this buffer. Samples + contain separate color values for each fragment color. When the + window system-provided framebuffer includes a multisample buffer, it + does not include depth or stencil buffers, even if the multisample + buffer does not store depth or stencil values. Color buffers do + coexist with the multisample buffer, however. + + Section 3.8.2, (Shader Execution) Replace subsection "Shader + Outputs": + + The OpenGL ES Shading Language specification describes the values + that may be output by a fragment shader. These are gl_FragColor and + gl_FragData[n]. The final fragment color values or the final + fragment data values written by a fragment shader are clamped to the + range [0, 1] and then converted to fixed-point as described in + section 2.1.2 for framebuffer color components. + + Writing to gl_FragColor specifies the fragment color (color number + zero) that will be used by subsequent stages of the pipeline. + Writing to gl_FragData[n] specifies the value of fragment color + number n. Any colors, or color components, associated with a + fragment that are not written by the fragment shader are undefined. + A fragment shader may not statically assign values to both + gl_FragColor and gl_FragData. In this case, a compile or link error + will result. A shader statically assigns a value to a variable if, + after preprocessing, it contains a statement that would write to the + variable, whether or not run-time flow of control will cause that + statement to be executed. + +Changes to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment +Operations and the Frame Buffer) + + Insert Table 4.3 (and renumber subsequent tables): Arguments to + DrawBuffersANGLE when the context is bound to a framebuffer + object, and the buffers they indicate. in + COLOR_ATTACHMENT_ANGLE may range from zero to the value of + MAX_COLOR_ATTACHMENTS_ANGLE minus one. + + Symbolic Constant Meaning + ----------------- --------------------- + NONE No buffer + + COLOR_ATTACHMENT_ANGLE (see caption) Output fragment color to image + attached at color attachment + point i + + + Replace Section 4.2.1, "Selecting a Buffer for Writing" with the following: + + "By default, color values are written into the front buffer for + single buffered surfaces or into the back buffer for back buffered + surfaces as determined when making the context current. To control + the color buffer into which each of the fragment color values is + written, DrawBuffersANGLE is used. + + The command + + void DrawBuffersANGLE(sizei n, const enum *bufs); + + defines the draw buffers to which all fragment colors are written. + specifies the number of buffers in . is a pointer + to an array of symbolic constants specifying the buffer to which + each fragment color is written. + + Each buffer listed in must be BACK, NONE, or one of the + values from table 4.3. Further, acceptable values for the constants + in depend on whether the GL is using the default framebuffer + (i.e., DRAW_FRAMEBUFFER_BINDING is zero), or a framebuffer object + (i.e., DRAW_FRAMEBUFFER_BINDING is non-zero). For more information + about framebuffer objects, see section 4.4. + + If the GL is bound to the default framebuffer, then must be 1 + and the constant must be BACK or NONE. When draw buffer zero is + BACK, color values are written into the sole buffer for single- + buffered contexts, or into the back buffer for double-buffered + contexts. If DrawBuffersANGLE is supplied with a constant other than + BACK and NONE, the error INVALID_OPERATION is generated. + + If the GL is bound to a draw framebuffer object, then each of the + constants must be one of the values listed in table 4.3. + + In both cases, the draw buffers being defined correspond in order to + the respective fragment colors. The draw buffer for fragment + colors beyond is set to NONE. + + The maximum number of draw buffers is implementation-dependent. The + number of draw buffers supported can be queried by calling + GetIntegerv with the symbolic constant MAX_DRAW_BUFFERS_ANGLE. An + INVALID_VALUE error is generated if is greater than + MAX_DRAW_BUFFERS_ANGLE. + + If the GL is bound to a draw framebuffer object, the th buffer listed + in must be COLOR_ATTACHMENT_ANGLE or NONE. Specifying a + buffer out of order, BACK, or COLOR_ATTACHMENT_ANGLE where is + greater than or equal to the value of MAX_COLOR_ATTACHMENTS_ANGLE, + will generate the error INVALID_OPERATION. + + If a fragment shader writes to "gl_FragColor", DrawBuffersANGLE + specifies a set of draw buffers into which the color written to + "gl_FragColor" is written. If a fragment shader writes to + "gl_FragData", DrawBuffersANGLE specifies a set of draw buffers + into which each of the multiple output colors defined by these + variables are separately written. If a fragment shader writes to + neither "gl_FragColor" nor "gl_FragData" the values of the + fragment colors following shader execution are undefined, and may + differ for each fragment color. + + Indicating a buffer or buffers using DrawBuffersANGLE causes + subsequent pixel color value writes to affect the indicated + buffers. If the GL is bound to a draw framebuffer object and a draw + buffer selects an attachment that has no image attached, then that + fragment color is not written. + + Specifying NONE as the draw buffer for a fragment color will inhibit + that fragment color from being written. + + The state required to handle color buffer selection for each + framebuffer is an integer for each supported fragment color. For the + default framebuffer, in the initial state the draw buffer for + fragment color zero is BACK if there is a default framebuffer + associated with the context, otherwise NONE. For framebuffer + objects, in the initial state the draw buffer for fragment color + zero is COLOR_ATTACHMENT0_ANGLE. + + For both the default framebuffer and framebuffer objects, the + initial state of draw buffers for fragment colors other than zero is + NONE. + + The value of the draw buffer selected for fragment color can be + queried by calling GetIntegerv with the symbolic constant + DRAW_BUFFER_ANGLE." + + Replace the second paragraph of Section 4.4.1 (Binding and Managing + Framebuffer Objects) with the following: + + "The namespace for framebuffer objects is the unsigned integers, with + zero reserved by OpenGL ES to refer to the default framebuffer. A + framebuffer object is created by binding an unused name to the + target FRAMEBUFFER, DRAW_FRAMEBUFFER, or READ_FRAMEBUFFER. The binding + is effected by calling + + void BindFramebuffer(enum target, uint framebuffer); + + with set the desired framebuffer target and set + to the unused name. The resulting framebuffer object is a new state + vector. There is a number of color attachment points, plus one each + for the depth and stencil attachment points. The number of color attachment + points is equal to the value of MAX_COLOR_ATTACHMENTS_ANGLE." + +Changes to Chapter 3 of the OpenGL ES Shading Language 1.0.17 Specification (Basics) + + Add a new section: + + 3.4.1 GL_ANGLE_multiple_render_targets Extension + + To use the GL_ANGLE_multiple_render_targets extension in a shader it + must be enabled using the #extension directive. + + The shading language preprocessor #define + GL_ANGLE_multiple_render_targets will be defined to 1, if the + GL_ANGLE_multiple_render_targets extension is supported. + +Dependencies on ANGLE_framebuffer_blit and APPLE_framebuffer_multisample: + + If neither ANGLE_framebuffer_blit nor APPLE_framebuffer_multisample are + supported, then all references to "draw framebuffers" should be replaced + with references to "framebuffers". References to DRAW_FRAMEBUFFER_BINDING + should be replaced with references to FRAMEBUFFER_BINDING. References to + DRAW_FRAMEBUFFER and READ_FRAMEBUFFER should be removed. + + If ANGLE_framebuffer_blit is supported, DRAW_FRAMEBUFFER_BINDING, DRAW_FRAMEBUFFER + and READ_FRAMEBUFFER all refer to corresponding _ANGLE suffixed names + (they have the same token values). + + If APPLE_framebuffer_multisample is supported, DRAW_FRAMEBUFFER_BINDING, + DRAW_FRAMEBUFFER and READ_FRAMEBUFFER all refer to the corresponding _APPLE + suffixed names (they have the same token values). + +Errors + + + +New State + + Add Table 6.X Framebuffer (State per framebuffer object): + + State Type Get Command Initial Value Description + --------------- ---- ------------ ------------- ----------- + DRAW_BUFFER_ANGLE Z10* GetIntegerv see 4.2.1 Draw buffer selected + for fragment color i + + Add to Table 6.18 (Implementation Dependent Values) + + Get value Type Get Cmnd Minimum Value Description Sec. + ------------------------ ---- ----------- ------------- ----------- ----- + MAX_DRAW_BUFFERS_ANGLE Z+ GetIntegerv 1 Maximum number of 4.2.1 + active draw buffers + MAX_COLOR_ATTACHMENTS_ANGLE Z+ GetIntegerv 1 Number of framebuffer 4.4.1 + color attachment points +Issues + + See ARB_draw_buffers for relevant issues. + + 1) Differences from NV_draw_buffers + NV_fbo_color_attachments? + + - interactions with blit_framebuffer + - MAX limits are global instead of per-fbo (TBD - Issue 2) + - no broadcast from gl_FragColor (TBD - Issue 3) + - can be used to with default framebuffer to set NONE/BACK (TBD - Issue 4) + + 2) Should the MAX_DRAW_BUFFERS_ANGLE and MAX_COLOR_ATTACHMENTS_ANGLE limits + be per-framebuffer values or implementation dependent constants? + + DISCUSSION: In ARB_draw_buffers this was per-context (see Issue 2). + EXT_framebuffer_object (and subsequently ARB_framebuffer_object, and GL 3.0 + through GL 4.2) made these queries framebuffer-dependent. + However GL in 4.3 and GLES 3.0, these limits were moved from + framebuffer-dependent state to implementation-dependent state after + much discussion (Bug 7990). + + NV_draw_buffers has MAX_DRAW_BUFFERS listed as per-framebuffer state, + but NV_fbo_color_attachments has MAX_COLOR_ATTACHMENTS as an + implementation-dependent constant. + + This is relevant because some implementations are not able to support + multisampling in conjuction with multiple color attachments. If the + query is per-framebuffer, they can report a maximum of one attachment + when there are multisampled attachments, but a higher limit when only + single-sampled attachments are present. + + 3) Should we support broadcast from gl_FragColor to all gl_FragData[x] + or should it be synonymous with gl_FragData[0]? + + DISCUSSION: With NV_draw_buffers, writing to gl_FragColor writes to all + the enabled draw buffers (ie broadcast). In OpenGL ES 3.0 when using + ESSL 1.0, gl_FragColor is equivalent to writing a single output to + gl_FragData[0] and multiple outputs are not possible. When using ESSL 3.0, + only user-defined out variables may be used. + + If broadcast is supported, some implementations may have to replace + writes to gl_FragColor with replicated writes to all possible gl_FragData + locations when this extension is enabled. + + 4) Should we allow DrawBuffersANGLE to be called when the default FBO is bound? + + DISCUSSION: NV_draw_buffers specifies that DrawBuffersNV errors with + INVALID_OPERATION when the default FBO is bound. OpenGL ES 3.0 allows + DrawBuffers to toggle between BACK and NONE on the default FBO. + + An implementation that does not natively support disabling the drawbuffer + on the default FBO could emulate this by disabling color writes. + + +Revision History + + 11/13/2012 dgkoch add revision history + add text from updated ES 3.0 spec + add issues for discussion + 10/16/2012 kbr update name string + 10/16/2012 kbr remove restrition requiring draw buffer 0 to be non-NULL + 10/12/2012 kbr remove references to GetDoublev and ReadBuffer + 10/11/2012 kbr initial draft extension + diff --git a/gfx/angle/include/GLSLANG/ShaderLang.h b/gfx/angle/include/GLSLANG/ShaderLang.h index d925029a2c6a..f51bd8726ea1 100644 --- a/gfx/angle/include/GLSLANG/ShaderLang.h +++ b/gfx/angle/include/GLSLANG/ShaderLang.h @@ -23,6 +23,8 @@ #define COMPILER_EXPORT #endif +#include "khrplatform.h" + // // This is the platform independent interface between an OGL driver // and the shading language compiler. @@ -110,7 +112,10 @@ typedef enum { SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87, SH_ACTIVE_ATTRIBUTES = 0x8B89, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A, - SH_MAPPED_NAME_MAX_LENGTH = 0x8B8B + SH_MAPPED_NAME_MAX_LENGTH = 0x6000, + SH_NAME_MAX_LENGTH = 0x6001, + SH_HASHED_NAME_MAX_LENGTH = 0x6002, + SH_HASHED_NAMES_COUNT = 0x6003 } ShShaderInfo; // Compile options. @@ -145,7 +150,7 @@ typedef enum { SH_DEPENDENCY_GRAPH = 0x0400, // Enforce the GLSL 1.017 Appendix A section 7 packing restrictions. - SH_ENFORCE_PACKING_RESTRICTIONS = 0x0800, + SH_ENFORCE_PACKING_RESTRICTIONS = 0x0800 } ShCompileOptions; // @@ -160,6 +165,10 @@ COMPILER_EXPORT int ShInitialize(); // COMPILER_EXPORT int ShFinalize(); +// The 64 bits hash function. The first parameter is the input string; the +// second parameter is the string length. +typedef khronos_uint64_t (*ShHashFunction64)(const char*, unsigned int); + // // Implementation dependent built-in resources (constants and extensions). // The names for these resources has been obtained by stripping gl_/GL_. @@ -181,6 +190,11 @@ typedef struct int OES_standard_derivatives; int OES_EGL_image_external; int ARB_texture_rectangle; + + // Name Hashing. + // Set a 64 bit hash function to enable user-defined name hashing. + // Default is NULL. + ShHashFunction64 HashFunction; } ShBuiltInResources; // @@ -267,6 +281,11 @@ COMPILER_EXPORT int ShCompile( // termination character. // SH_MAPPED_NAME_MAX_LENGTH: the length of the mapped variable name including // the null termination character. +// SH_NAME_MAX_LENGTH: the max length of a user-defined name including the +// null termination character. +// SH_HASHED_NAME_MAX_LENGTH: the max length of a hashed name including the +// null termination character. +// SH_HASHED_NAMES_COUNT: the number of hashed names from the latest compile. // // params: Requested parameter COMPILER_EXPORT void ShGetInfo(const ShHandle handle, @@ -347,6 +366,24 @@ COMPILER_EXPORT void ShGetActiveUniform(const ShHandle handle, char* name, char* mappedName); +// Returns information about a name hashing entry from the latest compile. +// Parameters: +// handle: Specifies the compiler +// index: Specifies the index of the name hashing entry to be queried. +// name: Returns a null terminated string containing the user defined name. +// It is assumed that name has enough memory to accomodate the name. +// The size of the buffer required to store the user defined name can +// be obtained by calling ShGetInfo with SH_NAME_MAX_LENGTH. +// hashedName: Returns a null terminated string containing the hashed name of +// the uniform variable, It is assumed that hashedName has enough +// memory to accomodate the name. The size of the buffer required +// to store the name can be obtained by calling ShGetInfo with +// SH_HASHED_NAME_MAX_LENGTH. +COMPILER_EXPORT void ShGetNameHashingEntry(const ShHandle handle, + int index, + char* name, + char* hashedName); + #ifdef __cplusplus } #endif diff --git a/gfx/angle/samples/build_samples.gyp b/gfx/angle/samples/build_samples.gyp deleted file mode 100644 index ccf8ddc78005..000000000000 --- a/gfx/angle/samples/build_samples.gyp +++ /dev/null @@ -1,179 +0,0 @@ -# Copyright (c) 2010 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. - -{ - 'targets': [ - { - 'target_name': 'essl_to_glsl', - 'type': 'executable', - 'dependencies': [ - '../src/build_angle.gyp:translator_glsl', - ], - 'include_dirs': [ - '../include', - ], - 'sources': [ - 'translator/translator.cpp', - ], - }, - ], - 'conditions': [ - ['OS=="win"', { - 'targets': [ - { - 'target_name': 'essl_to_hlsl', - 'type': 'executable', - 'dependencies': [ - '../src/build_angle.gyp:translator_hlsl', - ], - 'include_dirs': [ - '../include', - '../src', - ], - 'sources': [ - 'translator/translator.cpp', - '../src/common/debug.cpp', - ], - 'msvs_settings': { - 'VCLinkerTool': { - 'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'], - 'AdditionalDependencies': ['d3d9.lib'], - } - } - }, - { - 'target_name': 'es_util', - 'type': 'static_library', - 'dependencies': [ - '../src/build_angle.gyp:libEGL', - '../src/build_angle.gyp:libGLESv2', - ], - 'include_dirs': [ - 'gles2_book/Common', - '../include', - ], - 'sources': [ - 'gles2_book/Common/esShader.c', - 'gles2_book/Common/esShapes.c', - 'gles2_book/Common/esTransform.c', - 'gles2_book/Common/esUtil.c', - 'gles2_book/Common/esUtil.h', - 'gles2_book/Common/esUtil_win.h', - 'gles2_book/Common/Win32/esUtil_TGA.c', - 'gles2_book/Common/Win32/esUtil_win32.c', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'gles2_book/Common', - '../include', - ], - }, - }, - { - 'target_name': 'hello_triangle', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/Hello_Triangle/Hello_Triangle.c', - ], - }, - { - 'target_name': 'mip_map_2d', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/MipMap2D/MipMap2D.c', - ], - }, - { - 'target_name': 'multi_texture', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/MultiTexture/MultiTexture.c', - ], - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)', - 'files': [ - 'gles2_book/MultiTexture/basemap.tga', - 'gles2_book/MultiTexture/lightmap.tga', - ], - }, - ], - }, - { - 'target_name': 'particle_system', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/ParticleSystem/ParticleSystem.c', - ], - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)', - 'files': [ - 'gles2_book/ParticleSystem/smoke.tga', - ], - }, - ], - }, - { - 'target_name': 'simple_texture_2d', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/Simple_Texture2D/Simple_Texture2D.c', - ], - }, - { - 'target_name': 'simple_texture_cubemap', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/Simple_TextureCubemap/Simple_TextureCubemap.c', - ], - }, - { - 'target_name': 'simple_vertex_shader', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/Simple_VertexShader/Simple_VertexShader.c', - ], - }, - { - 'target_name': 'stencil_test', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/Stencil_Test/Stencil_Test.c', - ], - }, - { - 'target_name': 'texture_wrap', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/TextureWrap/TextureWrap.c', - ], - }, - { - 'target_name': 'post_sub_buffer', - 'type': 'executable', - 'dependencies': ['es_util'], - 'sources': [ - 'gles2_book/PostSubBuffer/PostSubBuffer.c', - ], - }, - ], - }], - ], -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2: diff --git a/gfx/angle/samples/gles2_book/Common/Win32/esUtil_TGA.c b/gfx/angle/samples/gles2_book/Common/Win32/esUtil_TGA.c deleted file mode 100644 index 61d1cb149d82..000000000000 --- a/gfx/angle/samples/gles2_book/Common/Win32/esUtil_TGA.c +++ /dev/null @@ -1,122 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// esUtil_TGA.c -// -// This file contains the Win32 implementation of a TGA image loader - -#include -#include -#include - -/// -// Macros -// -#define INVERTED_BIT (1 << 5) - -/// -// Types -// -#pragma pack(push,x1) // Byte alignment (8-bit) -#pragma pack(1) - -typedef struct -{ - unsigned char IdSize, - MapType, - ImageType; - unsigned short PaletteStart, - PaletteSize; - unsigned char PaletteEntryDepth; - unsigned short X, - Y, - Width, - Height; - unsigned char ColorDepth, - Descriptor; - -} TGA_HEADER; - -#pragma pack(pop,x1) - -//////////////////////////////////////////////////////////////////////////////////// -// -// Private Functions -// - -//////////////////////////////////////////////////////////////////////////////////// -// -// Public Functions -// -// - - -/// -// WinTGALoad() -// -int WinTGALoad( const char *fileName, char **buffer, int *width, int *height ) -{ - FILE *fp; - TGA_HEADER Header; - - if ( fopen_s ( &fp, fileName, "rb" ) != 0 ) - { - return FALSE; - } - - if ( fp == NULL ) - { - return FALSE; - } - - fread ( &Header, sizeof(TGA_HEADER), 1, fp ); - - *width = Header.Width; - *height = Header.Height; - - if ( Header.ColorDepth == 24 ) - { - RGBTRIPLE *Buffer24; - - Buffer24= (RGBTRIPLE*)malloc(sizeof(RGBTRIPLE) * (*width) * (*height)); - - if(Buffer24) - { - int i=0; - int x, - y; - - fread(Buffer24, sizeof(RGBTRIPLE), (*width) * (*height), fp); - - *buffer= (LPSTR) malloc(3 * (*width) * (*height)); - - for ( y = 0; y < *height; y++ ) - for( x = 0; x < *width; x++ ) - { - int Index= y * (*width) + x; - - if(!(Header.Descriptor & INVERTED_BIT)) - Index= ((*height) - 1 - y) * (*width) + x; - - (*buffer)[(i * 3)]= Buffer24[Index].rgbtRed; - (*buffer)[(i * 3) + 1]= Buffer24[Index].rgbtGreen; - (*buffer)[(i * 3) + 2]= Buffer24[Index].rgbtBlue; - - i++; - } - - fclose(fp); - free(Buffer24); - return(TRUE); - } - } - - return(FALSE); -} diff --git a/gfx/angle/samples/gles2_book/Common/Win32/esUtil_win32.c b/gfx/angle/samples/gles2_book/Common/Win32/esUtil_win32.c deleted file mode 100644 index c27131ed476b..000000000000 --- a/gfx/angle/samples/gles2_book/Common/Win32/esUtil_win32.c +++ /dev/null @@ -1,190 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// esUtil_win32.c -// -// This file contains the Win32 implementation of the windowing functions. - - -/// -// Includes -// - -#include -#include "esUtil.h" - -////////////////////////////////////////////////////////////////// -// -// Private Functions -// -// - -/// -// ESWindowProc() -// -// Main window procedure -// -LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ - LRESULT lRet = 1; - - switch (uMsg) - { - case WM_CREATE: - break; - - case WM_SIZE: - { - ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA ); - if ( esContext ) { - esContext->width = LOWORD( lParam ); - esContext->height = HIWORD( lParam ); - InvalidateRect( esContext->hWnd, NULL, FALSE ); - } - } - - case WM_PAINT: - { - ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA ); - - if ( esContext && esContext->drawFunc ) - esContext->drawFunc ( esContext ); - - if ( esContext ) - ValidateRect( esContext->hWnd, NULL ); - } - break; - - case WM_DESTROY: - PostQuitMessage(0); - break; - - case WM_CHAR: - { - POINT point; - ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA ); - - GetCursorPos( &point ); - - if ( esContext && esContext->keyFunc ) - esContext->keyFunc ( esContext, (unsigned char) wParam, - (int) point.x, (int) point.y ); -} - break; - - default: - lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); - break; - } - - return lRet; -} - -////////////////////////////////////////////////////////////////// -// -// Public Functions -// -// - -/// -// WinCreate() -// -// Create Win32 instance and window -// -GLboolean WinCreate ( ESContext *esContext, LPCTSTR title ) -{ - WNDCLASS wndclass = {0}; - DWORD wStyle = 0; - RECT windowRect; - HINSTANCE hInstance = GetModuleHandle(NULL); - - wndclass.style = CS_OWNDC; - wndclass.lpfnWndProc = (WNDPROC)ESWindowProc; - wndclass.hInstance = hInstance; - wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wndclass.lpszClassName = TEXT("opengles2.0"); - - if (!RegisterClass (&wndclass) ) - return FALSE; - - wStyle = WS_VISIBLE | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION | WS_SIZEBOX; - - // Adjust the window rectangle so that the client area has - // the correct number of pixels - windowRect.left = 0; - windowRect.top = 0; - windowRect.right = esContext->width; - windowRect.bottom = esContext->height; - - AdjustWindowRect ( &windowRect, wStyle, FALSE ); - - esContext->hWnd = CreateWindow( - TEXT("opengles2.0"), - title, - wStyle, - 0, - 0, - windowRect.right - windowRect.left, - windowRect.bottom - windowRect.top, - NULL, - NULL, - hInstance, - NULL); - - // Set the ESContext* to the GWL_USERDATA so that it is available to the - // ESWindowProc - SetWindowLongPtr ( esContext->hWnd, GWL_USERDATA, (LONG) (LONG_PTR) esContext ); - - if ( esContext->hWnd == NULL ) - return GL_FALSE; - - ShowWindow ( esContext->hWnd, TRUE ); - - return GL_TRUE; -} - -/// -// winLoop() -// -// Start main windows loop -// -void WinLoop ( ESContext *esContext ) -{ - MSG msg = { 0 }; - int done = 0; - DWORD lastTime = GetTickCount(); - - while (!done) - { - int gotMsg = (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0); - DWORD curTime = GetTickCount(); - float deltaTime = (float)( curTime - lastTime ) / 1000.0f; - lastTime = curTime; - - if ( gotMsg ) - { - if (msg.message==WM_QUIT) - { - done=1; - } - else - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else - SendMessage( esContext->hWnd, WM_PAINT, 0, 0 ); - - // Call update function if registered - if ( esContext->updateFunc != NULL ) - esContext->updateFunc ( esContext, deltaTime ); - } -} diff --git a/gfx/angle/samples/gles2_book/Common/esShader.c b/gfx/angle/samples/gles2_book/Common/esShader.c deleted file mode 100644 index a2bb6e5206e7..000000000000 --- a/gfx/angle/samples/gles2_book/Common/esShader.c +++ /dev/null @@ -1,155 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// ESShader.c -// -// Utility functions for loading shaders and creating program objects. -// - -/// -// Includes -// -#include "esUtil.h" -#include - -////////////////////////////////////////////////////////////////// -// -// Private Functions -// -// - - - -////////////////////////////////////////////////////////////////// -// -// Public Functions -// -// - -// -/// -/// \brief Load a shader, check for compile errors, print error messages to output log -/// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER) -/// \param shaderSrc Shader source string -/// \return A new shader object on success, 0 on failure -// -GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc ) -{ - GLuint shader; - GLint compiled; - - // Create the shader object - shader = glCreateShader ( type ); - - if ( shader == 0 ) - return 0; - - // Load the shader source - glShaderSource ( shader, 1, &shaderSrc, NULL ); - - // Compile the shader - glCompileShader ( shader ); - - // Check the compile status - glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled ); - - if ( !compiled ) - { - GLint infoLen = 0; - - glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen ); - - if ( infoLen > 1 ) - { - char* infoLog = malloc (sizeof(char) * infoLen ); - - glGetShaderInfoLog ( shader, infoLen, NULL, infoLog ); - esLogMessage ( "Error compiling shader:\n%s\n", infoLog ); - - free ( infoLog ); - } - - glDeleteShader ( shader ); - return 0; - } - - return shader; - -} - - -// -/// -/// \brief Load a vertex and fragment shader, create a program object, link program. -// Errors output to log. -/// \param vertShaderSrc Vertex shader source code -/// \param fragShaderSrc Fragment shader source code -/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure -// -GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc ) -{ - GLuint vertexShader; - GLuint fragmentShader; - GLuint programObject; - GLint linked; - - // Load the vertex/fragment shaders - vertexShader = esLoadShader ( GL_VERTEX_SHADER, vertShaderSrc ); - if ( vertexShader == 0 ) - return 0; - - fragmentShader = esLoadShader ( GL_FRAGMENT_SHADER, fragShaderSrc ); - if ( fragmentShader == 0 ) - { - glDeleteShader( vertexShader ); - return 0; - } - - // Create the program object - programObject = glCreateProgram ( ); - - if ( programObject == 0 ) - return 0; - - glAttachShader ( programObject, vertexShader ); - glAttachShader ( programObject, fragmentShader ); - - // Link the program - glLinkProgram ( programObject ); - - // Check the link status - glGetProgramiv ( programObject, GL_LINK_STATUS, &linked ); - - if ( !linked ) - { - GLint infoLen = 0; - - glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen ); - - if ( infoLen > 1 ) - { - char* infoLog = malloc (sizeof(char) * infoLen ); - - glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog ); - esLogMessage ( "Error linking program:\n%s\n", infoLog ); - - free ( infoLog ); - } - - glDeleteProgram ( programObject ); - return 0; - } - - // Free up no longer needed shader resources - glDeleteShader ( vertexShader ); - glDeleteShader ( fragmentShader ); - - return programObject; -} diff --git a/gfx/angle/samples/gles2_book/Common/esShapes.c b/gfx/angle/samples/gles2_book/Common/esShapes.c deleted file mode 100644 index 6813534e8829..000000000000 --- a/gfx/angle/samples/gles2_book/Common/esShapes.c +++ /dev/null @@ -1,279 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// ESShapes.c -// -// Utility functions for generating shapes -// - -/// -// Includes -// -#include "esUtil.h" -#include -#include - -/// -// Defines -// -#define ES_PI (3.14159265f) - -////////////////////////////////////////////////////////////////// -// -// Private Functions -// -// - - - -////////////////////////////////////////////////////////////////// -// -// Public Functions -// -// - -// -/// \brief Generates geometry for a sphere. Allocates memory for the vertex data and stores -/// the results in the arrays. Generate index list for a TRIANGLE_STRIP -/// \param numSlices The number of slices in the sphere -/// \param vertices If not NULL, will contain array of float3 positions -/// \param normals If not NULL, will contain array of float3 normals -/// \param texCoords If not NULL, will contain array of float2 texCoords -/// \param indices If not NULL, will contain the array of indices for the triangle strip -/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array -/// if it is not NULL ) as a GL_TRIANGLE_STRIP -// -int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals, - GLfloat **texCoords, GLushort **indices ) -{ - int i; - int j; - int numParallels = numSlices / 2; - int numVertices = ( numParallels + 1 ) * ( numSlices + 1 ); - int numIndices = numParallels * numSlices * 6; - float angleStep = (2.0f * ES_PI) / ((float) numSlices); - - // Allocate memory for buffers - if ( vertices != NULL ) - *vertices = malloc ( sizeof(GLfloat) * 3 * numVertices ); - - if ( normals != NULL ) - *normals = malloc ( sizeof(GLfloat) * 3 * numVertices ); - - if ( texCoords != NULL ) - *texCoords = malloc ( sizeof(GLfloat) * 2 * numVertices ); - - if ( indices != NULL ) - *indices = malloc ( sizeof(GLushort) * numIndices ); - - for ( i = 0; i < numParallels + 1; i++ ) - { - for ( j = 0; j < numSlices + 1; j++ ) - { - int vertex = ( i * (numSlices + 1) + j ) * 3; - - if ( vertices ) - { - (*vertices)[vertex + 0] = radius * sinf ( angleStep * (float)i ) * - sinf ( angleStep * (float)j ); - (*vertices)[vertex + 1] = radius * cosf ( angleStep * (float)i ); - (*vertices)[vertex + 2] = radius * sinf ( angleStep * (float)i ) * - cosf ( angleStep * (float)j ); - } - - if ( normals ) - { - (*normals)[vertex + 0] = (*vertices)[vertex + 0] / radius; - (*normals)[vertex + 1] = (*vertices)[vertex + 1] / radius; - (*normals)[vertex + 2] = (*vertices)[vertex + 2] / radius; - } - - if ( texCoords ) - { - int texIndex = ( i * (numSlices + 1) + j ) * 2; - (*texCoords)[texIndex + 0] = (float) j / (float) numSlices; - (*texCoords)[texIndex + 1] = ( 1.0f - (float) i ) / (float) (numParallels - 1 ); - } - } - } - - // Generate the indices - if ( indices != NULL ) - { - GLushort *indexBuf = (*indices); - for ( i = 0; i < numParallels ; i++ ) - { - for ( j = 0; j < numSlices; j++ ) - { - *indexBuf++ = i * ( numSlices + 1 ) + j; - *indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + j; - *indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + ( j + 1 ); - - *indexBuf++ = i * ( numSlices + 1 ) + j; - *indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + ( j + 1 ); - *indexBuf++ = i * ( numSlices + 1 ) + ( j + 1 ); - } - } - } - - return numIndices; -} - -// -/// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores -/// the results in the arrays. Generate index list for a TRIANGLES -/// \param scale The size of the cube, use 1.0 for a unit cube. -/// \param vertices If not NULL, will contain array of float3 positions -/// \param normals If not NULL, will contain array of float3 normals -/// \param texCoords If not NULL, will contain array of float2 texCoords -/// \param indices If not NULL, will contain the array of indices for the triangle strip -/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array -/// if it is not NULL ) as a GL_TRIANGLE_STRIP -// -int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals, - GLfloat **texCoords, GLushort **indices ) -{ - int i; - int numVertices = 24; - int numIndices = 36; - - GLfloat cubeVerts[] = - { - -0.5f, -0.5f, -0.5f, - -0.5f, -0.5f, 0.5f, - 0.5f, -0.5f, 0.5f, - 0.5f, -0.5f, -0.5f, - -0.5f, 0.5f, -0.5f, - -0.5f, 0.5f, 0.5f, - 0.5f, 0.5f, 0.5f, - 0.5f, 0.5f, -0.5f, - -0.5f, -0.5f, -0.5f, - -0.5f, 0.5f, -0.5f, - 0.5f, 0.5f, -0.5f, - 0.5f, -0.5f, -0.5f, - -0.5f, -0.5f, 0.5f, - -0.5f, 0.5f, 0.5f, - 0.5f, 0.5f, 0.5f, - 0.5f, -0.5f, 0.5f, - -0.5f, -0.5f, -0.5f, - -0.5f, -0.5f, 0.5f, - -0.5f, 0.5f, 0.5f, - -0.5f, 0.5f, -0.5f, - 0.5f, -0.5f, -0.5f, - 0.5f, -0.5f, 0.5f, - 0.5f, 0.5f, 0.5f, - 0.5f, 0.5f, -0.5f, - }; - - GLfloat cubeNormals[] = - { - 0.0f, -1.0f, 0.0f, - 0.0f, -1.0f, 0.0f, - 0.0f, -1.0f, 0.0f, - 0.0f, -1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, -1.0f, - 0.0f, 0.0f, -1.0f, - 0.0f, 0.0f, -1.0f, - 0.0f, 0.0f, -1.0f, - 0.0f, 0.0f, 1.0f, - 0.0f, 0.0f, 1.0f, - 0.0f, 0.0f, 1.0f, - 0.0f, 0.0f, 1.0f, - -1.0f, 0.0f, 0.0f, - -1.0f, 0.0f, 0.0f, - -1.0f, 0.0f, 0.0f, - -1.0f, 0.0f, 0.0f, - 1.0f, 0.0f, 0.0f, - 1.0f, 0.0f, 0.0f, - 1.0f, 0.0f, 0.0f, - 1.0f, 0.0f, 0.0f, - }; - - GLfloat cubeTex[] = - { - 0.0f, 0.0f, - 0.0f, 1.0f, - 1.0f, 1.0f, - 1.0f, 0.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f, - 0.0f, 0.0f, - 0.0f, 0.0f, - 0.0f, 1.0f, - 1.0f, 1.0f, - 1.0f, 0.0f, - 0.0f, 0.0f, - 0.0f, 1.0f, - 1.0f, 1.0f, - 1.0f, 0.0f, - 0.0f, 0.0f, - 0.0f, 1.0f, - 1.0f, 1.0f, - 1.0f, 0.0f, - 0.0f, 0.0f, - 0.0f, 1.0f, - 1.0f, 1.0f, - 1.0f, 0.0f, - }; - - // Allocate memory for buffers - if ( vertices != NULL ) - { - *vertices = malloc ( sizeof(GLfloat) * 3 * numVertices ); - memcpy( *vertices, cubeVerts, sizeof( cubeVerts ) ); - for ( i = 0; i < numVertices; i++ ) - { - (*vertices)[i] *= scale; - } - } - - if ( normals != NULL ) - { - *normals = malloc ( sizeof(GLfloat) * 3 * numVertices ); - memcpy( *normals, cubeNormals, sizeof( cubeNormals ) ); - } - - if ( texCoords != NULL ) - { - *texCoords = malloc ( sizeof(GLfloat) * 2 * numVertices ); - memcpy( *texCoords, cubeTex, sizeof( cubeTex ) ) ; - } - - - // Generate the indices - if ( indices != NULL ) - { - GLushort cubeIndices[] = - { - 0, 2, 1, - 0, 3, 2, - 4, 5, 6, - 4, 6, 7, - 8, 9, 10, - 8, 10, 11, - 12, 15, 14, - 12, 14, 13, - 16, 17, 18, - 16, 18, 19, - 20, 23, 22, - 20, 22, 21 - }; - - *indices = malloc ( sizeof(GLushort) * numIndices ); - memcpy( *indices, cubeIndices, sizeof( cubeIndices ) ); - } - - return numIndices; -} diff --git a/gfx/angle/samples/gles2_book/Common/esTransform.c b/gfx/angle/samples/gles2_book/Common/esTransform.c deleted file mode 100644 index 7da8f7652c0c..000000000000 --- a/gfx/angle/samples/gles2_book/Common/esTransform.c +++ /dev/null @@ -1,212 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// ESUtil.c -// -// A utility library for OpenGL ES. This library provides a -// basic common framework for the example applications in the -// OpenGL ES 2.0 Programming Guide. -// - -/// -// Includes -// -#include "esUtil.h" -#include - -#define PI 3.1415926535897932384626433832795f - -void ESUTIL_API -esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz) -{ - result->m[0][0] *= sx; - result->m[0][1] *= sx; - result->m[0][2] *= sx; - result->m[0][3] *= sx; - - result->m[1][0] *= sy; - result->m[1][1] *= sy; - result->m[1][2] *= sy; - result->m[1][3] *= sy; - - result->m[2][0] *= sz; - result->m[2][1] *= sz; - result->m[2][2] *= sz; - result->m[2][3] *= sz; -} - -void ESUTIL_API -esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz) -{ - result->m[3][0] += (result->m[0][0] * tx + result->m[1][0] * ty + result->m[2][0] * tz); - result->m[3][1] += (result->m[0][1] * tx + result->m[1][1] * ty + result->m[2][1] * tz); - result->m[3][2] += (result->m[0][2] * tx + result->m[1][2] * ty + result->m[2][2] * tz); - result->m[3][3] += (result->m[0][3] * tx + result->m[1][3] * ty + result->m[2][3] * tz); -} - -void ESUTIL_API -esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z) -{ - GLfloat sinAngle, cosAngle; - GLfloat mag = sqrtf(x * x + y * y + z * z); - - sinAngle = sinf ( angle * PI / 180.0f ); - cosAngle = cosf ( angle * PI / 180.0f ); - if ( mag > 0.0f ) - { - GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs; - GLfloat oneMinusCos; - ESMatrix rotMat; - - x /= mag; - y /= mag; - z /= mag; - - xx = x * x; - yy = y * y; - zz = z * z; - xy = x * y; - yz = y * z; - zx = z * x; - xs = x * sinAngle; - ys = y * sinAngle; - zs = z * sinAngle; - oneMinusCos = 1.0f - cosAngle; - - rotMat.m[0][0] = (oneMinusCos * xx) + cosAngle; - rotMat.m[0][1] = (oneMinusCos * xy) - zs; - rotMat.m[0][2] = (oneMinusCos * zx) + ys; - rotMat.m[0][3] = 0.0F; - - rotMat.m[1][0] = (oneMinusCos * xy) + zs; - rotMat.m[1][1] = (oneMinusCos * yy) + cosAngle; - rotMat.m[1][2] = (oneMinusCos * yz) - xs; - rotMat.m[1][3] = 0.0F; - - rotMat.m[2][0] = (oneMinusCos * zx) - ys; - rotMat.m[2][1] = (oneMinusCos * yz) + xs; - rotMat.m[2][2] = (oneMinusCos * zz) + cosAngle; - rotMat.m[2][3] = 0.0F; - - rotMat.m[3][0] = 0.0F; - rotMat.m[3][1] = 0.0F; - rotMat.m[3][2] = 0.0F; - rotMat.m[3][3] = 1.0F; - - esMatrixMultiply( result, &rotMat, result ); - } -} - -void ESUTIL_API -esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ) -{ - float deltaX = right - left; - float deltaY = top - bottom; - float deltaZ = farZ - nearZ; - ESMatrix frust; - - if ( (nearZ <= 0.0f) || (farZ <= 0.0f) || - (deltaX <= 0.0f) || (deltaY <= 0.0f) || (deltaZ <= 0.0f) ) - return; - - frust.m[0][0] = 2.0f * nearZ / deltaX; - frust.m[0][1] = frust.m[0][2] = frust.m[0][3] = 0.0f; - - frust.m[1][1] = 2.0f * nearZ / deltaY; - frust.m[1][0] = frust.m[1][2] = frust.m[1][3] = 0.0f; - - frust.m[2][0] = (right + left) / deltaX; - frust.m[2][1] = (top + bottom) / deltaY; - frust.m[2][2] = -(nearZ + farZ) / deltaZ; - frust.m[2][3] = -1.0f; - - frust.m[3][2] = -2.0f * nearZ * farZ / deltaZ; - frust.m[3][0] = frust.m[3][1] = frust.m[3][3] = 0.0f; - - esMatrixMultiply(result, &frust, result); -} - - -void ESUTIL_API -esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ) -{ - GLfloat frustumW, frustumH; - - frustumH = tanf( fovy / 360.0f * PI ) * nearZ; - frustumW = frustumH * aspect; - - esFrustum( result, -frustumW, frustumW, -frustumH, frustumH, nearZ, farZ ); -} - -void ESUTIL_API -esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ) -{ - float deltaX = right - left; - float deltaY = top - bottom; - float deltaZ = farZ - nearZ; - ESMatrix ortho; - - if ( (deltaX == 0.0f) || (deltaY == 0.0f) || (deltaZ == 0.0f) ) - return; - - esMatrixLoadIdentity(&ortho); - ortho.m[0][0] = 2.0f / deltaX; - ortho.m[3][0] = -(right + left) / deltaX; - ortho.m[1][1] = 2.0f / deltaY; - ortho.m[3][1] = -(top + bottom) / deltaY; - ortho.m[2][2] = -2.0f / deltaZ; - ortho.m[3][2] = -(nearZ + farZ) / deltaZ; - - esMatrixMultiply(result, &ortho, result); -} - - -void ESUTIL_API -esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB) -{ - ESMatrix tmp = { 0.0f }; - int i; - - for (i=0; i<4; i++) - { - tmp.m[i][0] = (srcA->m[i][0] * srcB->m[0][0]) + - (srcA->m[i][1] * srcB->m[1][0]) + - (srcA->m[i][2] * srcB->m[2][0]) + - (srcA->m[i][3] * srcB->m[3][0]) ; - - tmp.m[i][1] = (srcA->m[i][0] * srcB->m[0][1]) + - (srcA->m[i][1] * srcB->m[1][1]) + - (srcA->m[i][2] * srcB->m[2][1]) + - (srcA->m[i][3] * srcB->m[3][1]) ; - - tmp.m[i][2] = (srcA->m[i][0] * srcB->m[0][2]) + - (srcA->m[i][1] * srcB->m[1][2]) + - (srcA->m[i][2] * srcB->m[2][2]) + - (srcA->m[i][3] * srcB->m[3][2]) ; - - tmp.m[i][3] = (srcA->m[i][0] * srcB->m[0][3]) + - (srcA->m[i][1] * srcB->m[1][3]) + - (srcA->m[i][2] * srcB->m[2][3]) + - (srcA->m[i][3] * srcB->m[3][3]) ; - } - memcpy(result, &tmp, sizeof(ESMatrix)); -} - - -void ESUTIL_API -esMatrixLoadIdentity(ESMatrix *result) -{ - memset(result, 0x0, sizeof(ESMatrix)); - result->m[0][0] = 1.0f; - result->m[1][1] = 1.0f; - result->m[2][2] = 1.0f; - result->m[3][3] = 1.0f; -} - diff --git a/gfx/angle/samples/gles2_book/Common/esUtil.c b/gfx/angle/samples/gles2_book/Common/esUtil.c deleted file mode 100644 index aeeee7ff8fa9..000000000000 --- a/gfx/angle/samples/gles2_book/Common/esUtil.c +++ /dev/null @@ -1,290 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// ESUtil.c -// -// A utility library for OpenGL ES. This library provides a -// basic common framework for the example applications in the -// OpenGL ES 2.0 Programming Guide. -// - -/// -// Includes -// -#include -#include -#include -#include -#include -#include "esUtil.h" -#include "esUtil_win.h" - -#if defined(_MSC_VER) -#pragma warning(disable: 4204) // nonstandard extension used : non-constant aggregate initializer -#endif - -/// -// Extensions -// - -PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; -PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; - -PFNEGLPOSTSUBBUFFERNVPROC eglPostSubBufferNV; - -PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; - -PFNGLDELETEFENCESNVPROC glDeleteFencesNV; -PFNGLGENFENCESNVPROC glGenFencesNV; -PFNGLGETFENCEIVNVPROC glGetFenceivNV; -PFNGLISFENCENVPROC glIsFenceNV; -PFNGLFINISHFENCENVPROC glFinishFenceNV; -PFNGLSETFENCENVPROC glSetFenceNV; -PFNGLTESTFENCENVPROC glTestFenceNV; - -/// -// CreateEGLContext() -// -// Creates an EGL rendering context and all associated elements -// -EGLBoolean CreateEGLContext ( EGLNativeWindowType hWnd, EGLDisplay* eglDisplay, - EGLContext* eglContext, EGLSurface* eglSurface, - EGLint* configAttribList, EGLint* surfaceAttribList) -{ - EGLint numConfigs; - EGLint majorVersion; - EGLint minorVersion; - EGLDisplay display; - EGLContext context; - EGLSurface surface; - EGLConfig config; - EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE }; - - // Get Display - display = eglGetDisplay(GetDC(hWnd)); - if ( display == EGL_NO_DISPLAY ) - { - return EGL_FALSE; - } - - // Initialize EGL - if ( !eglInitialize(display, &majorVersion, &minorVersion) ) - { - return EGL_FALSE; - } - - // Bind to extensions - eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR"); - eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR"); - - eglPostSubBufferNV = (PFNEGLPOSTSUBBUFFERNVPROC) eglGetProcAddress("eglPostSubBufferNV"); - - glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress("glEGLImageTargetTexture2DOES"); - - glDeleteFencesNV = (PFNGLDELETEFENCESNVPROC) eglGetProcAddress("glDeleteFencesNV"); - glGenFencesNV = (PFNGLGENFENCESNVPROC) eglGetProcAddress("glGenFencesNV"); - glGetFenceivNV = (PFNGLGETFENCEIVNVPROC) eglGetProcAddress("glGetFenceivNV"); - glIsFenceNV = (PFNGLISFENCENVPROC) eglGetProcAddress("glIsFenceNV"); - glFinishFenceNV = (PFNGLFINISHFENCENVPROC) eglGetProcAddress("glFinishFenceNV"); - glSetFenceNV = (PFNGLSETFENCENVPROC) eglGetProcAddress("glSetFenceNV"); - glTestFenceNV = (PFNGLTESTFENCENVPROC) eglGetProcAddress("glTestFenceNV"); - - // Get configs - if ( !eglGetConfigs(display, NULL, 0, &numConfigs) ) - { - return EGL_FALSE; - } - - // Choose config - if ( !eglChooseConfig(display, configAttribList, &config, 1, &numConfigs) ) - { - return EGL_FALSE; - } - - // Create a surface - surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, surfaceAttribList); - if ( surface == EGL_NO_SURFACE ) - { - return EGL_FALSE; - } - - // Create a GL context - context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs ); - if ( context == EGL_NO_CONTEXT ) - { - return EGL_FALSE; - } - - // Make the context current - if ( !eglMakeCurrent(display, surface, surface, context) ) - { - return EGL_FALSE; - } - - *eglDisplay = display; - *eglSurface = surface; - *eglContext = context; - return EGL_TRUE; -} - -////////////////////////////////////////////////////////////////// -// -// Public Functions -// -// - -/// -// esInitContext() -// -// Initialize ES utility context. This must be called before calling any other -// functions. -// -void ESUTIL_API esInitContext ( ESContext *esContext ) -{ - if ( esContext != NULL ) - { - memset( esContext, 0, sizeof( ESContext) ); - } -} - -/// -// esCreateWindow() -// -// title - name for title bar of window -// width - width of window to create -// height - height of window to create -// flags - bitwise or of window creation flags -// ES_WINDOW_ALPHA - specifies that the framebuffer should have alpha -// ES_WINDOW_DEPTH - specifies that a depth buffer should be created -// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created -// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created -// ES_WINDOW_POST_SUB_BUFFER_SUPPORTED - specifies that EGL_POST_SUB_BUFFER_NV is supported. -// -GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, LPCTSTR title, GLint width, GLint height, GLuint flags ) -{ - EGLint configAttribList[] = - { - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_ALPHA_SIZE, (flags & ES_WINDOW_ALPHA) ? 8 : EGL_DONT_CARE, - EGL_DEPTH_SIZE, (flags & ES_WINDOW_DEPTH) ? 8 : EGL_DONT_CARE, - EGL_STENCIL_SIZE, (flags & ES_WINDOW_STENCIL) ? 8 : EGL_DONT_CARE, - EGL_SAMPLE_BUFFERS, (flags & ES_WINDOW_MULTISAMPLE) ? 1 : 0, - EGL_NONE - }; - EGLint surfaceAttribList[] = - { - EGL_POST_SUB_BUFFER_SUPPORTED_NV, flags & (ES_WINDOW_POST_SUB_BUFFER_SUPPORTED) ? EGL_TRUE : EGL_FALSE, - EGL_NONE, EGL_NONE - }; - - if ( esContext == NULL ) - { - return GL_FALSE; - } - - esContext->width = width; - esContext->height = height; - - if ( !WinCreate ( esContext, title) ) - { - return GL_FALSE; - } - - - if ( !CreateEGLContext ( esContext->hWnd, - &esContext->eglDisplay, - &esContext->eglContext, - &esContext->eglSurface, - configAttribList, - surfaceAttribList ) ) - { - return GL_FALSE; - } - - - return GL_TRUE; -} - -/// -// esMainLoop() -// -// Start the main loop for the OpenGL ES application -// -void ESUTIL_API esMainLoop ( ESContext *esContext ) -{ - WinLoop ( esContext ); -} - - -/// -// esRegisterDrawFunc() -// -void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) (ESContext* ) ) -{ - esContext->drawFunc = drawFunc; -} - - -/// -// esRegisterUpdateFunc() -// -void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) ) -{ - esContext->updateFunc = updateFunc; -} - - -/// -// esRegisterKeyFunc() -// -void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext, - void (ESCALLBACK *keyFunc) (ESContext*, unsigned char, int, int ) ) -{ - esContext->keyFunc = keyFunc; -} - - -/// -// esLogMessage() -// -// Log an error message to the debug output for the platform -// -void ESUTIL_API esLogMessage ( const char *formatStr, ... ) -{ - va_list params; - char buf[BUFSIZ]; - - va_start ( params, formatStr ); - vsprintf_s ( buf, sizeof(buf), formatStr, params ); - - printf ( "%s", buf ); - - va_end ( params ); -} - - -/// -// esLoadTGA() -// -// Loads a 24-bit TGA image from a file -// -char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height ) -{ - char *buffer; - - if ( WinTGALoad ( fileName, &buffer, width, height ) ) - { - return buffer; - } - - return NULL; -} diff --git a/gfx/angle/samples/gles2_book/Common/esUtil.h b/gfx/angle/samples/gles2_book/Common/esUtil.h deleted file mode 100644 index 7b7595c0d5b5..000000000000 --- a/gfx/angle/samples/gles2_book/Common/esUtil.h +++ /dev/null @@ -1,297 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// -/// \file ESUtil.h -/// \brief A utility library for OpenGL ES. This library provides a -/// basic common framework for the example applications in the -/// OpenGL ES 2.0 Programming Guide. -// -#ifndef ESUTIL_H -#define ESUTIL_H - -/// -// Includes -// -#include -#include -#include -#include - -#ifdef __cplusplus - -extern "C" { -#endif - - -/// -// Macros -// -#define ESUTIL_API __cdecl -#define ESCALLBACK __cdecl - - -/// esCreateWindow flag - RGB color buffer -#define ES_WINDOW_RGB 0 -/// esCreateWindow flag - ALPHA color buffer -#define ES_WINDOW_ALPHA 1 -/// esCreateWindow flag - depth buffer -#define ES_WINDOW_DEPTH 2 -/// esCreateWindow flag - stencil buffer -#define ES_WINDOW_STENCIL 4 -/// esCreateWindow flag - multi-sample buffer -#define ES_WINDOW_MULTISAMPLE 8 -/// esCreateWindow flag - EGL_POST_SUB_BUFFER_NV supported. -#define ES_WINDOW_POST_SUB_BUFFER_SUPPORTED 16 - -/// -// Types -// - -typedef struct -{ - GLfloat m[4][4]; -} ESMatrix; - -typedef struct -{ - /// Put your user data here... - void* userData; - - /// Window width - GLint width; - - /// Window height - GLint height; - - /// Window handle - EGLNativeWindowType hWnd; - - /// EGL display - EGLDisplay eglDisplay; - - /// EGL context - EGLContext eglContext; - - /// EGL surface - EGLSurface eglSurface; - - /// Callbacks - void (ESCALLBACK *drawFunc) ( void* ); - void (ESCALLBACK *keyFunc) ( void*, unsigned char, int, int ); - void (ESCALLBACK *updateFunc) ( void*, float deltaTime ); -} ESContext; - - -/// -// Extensions -// - -extern PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; -extern PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; - -extern PFNEGLPOSTSUBBUFFERNVPROC eglPostSubBufferNV; - -extern PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; - -extern PFNGLDELETEFENCESNVPROC glDeleteFencesNV; -extern PFNGLGENFENCESNVPROC glGenFencesNV; -extern PFNGLGETFENCEIVNVPROC glGetFenceivNV; -extern PFNGLISFENCENVPROC glIsFenceNV; -extern PFNGLFINISHFENCENVPROC glFinishFenceNV; -extern PFNGLSETFENCENVPROC glSetFenceNV; -extern PFNGLTESTFENCENVPROC glTestFenceNV; - -/// -// Public Functions -// - -// -/// -/// \brief Initialize ES framework context. This must be called before calling any other functions. -/// \param esContext Application context -// -void ESUTIL_API esInitContext ( ESContext *esContext ); - -// -/// \brief Create a window with the specified parameters -/// \param esContext Application context -/// \param title Name for title bar of window -/// \param width Width in pixels of window to create -/// \param height Height in pixels of window to create -/// \param flags Bitfield for the window creation flags -/// ES_WINDOW_RGB - specifies that the color buffer should have R,G,B channels -/// ES_WINDOW_ALPHA - specifies that the color buffer should have alpha -/// ES_WINDOW_DEPTH - specifies that a depth buffer should be created -/// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created -/// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created -/// ES_WINDOW_POST_SUB_BUFFER_SUPPORTED - specifies that EGL_POST_SUB_BUFFER_NV is supported. -/// \return GL_TRUE if window creation is succesful, GL_FALSE otherwise -GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, LPCTSTR title, GLint width, GLint height, GLuint flags ); - -// -/// \brief Start the main loop for the OpenGL ES application -/// \param esContext Application context -// -void ESUTIL_API esMainLoop ( ESContext *esContext ); - -// -/// \brief Register a draw callback function to be used to render each frame -/// \param esContext Application context -/// \param drawFunc Draw callback function that will be used to render the scene -// -void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) ( ESContext* ) ); - -// -/// \brief Register an update callback function to be used to update on each time step -/// \param esContext Application context -/// \param updateFunc Update callback function that will be used to render the scene -// -void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) ); - -// -/// \brief Register an keyboard input processing callback function -/// \param esContext Application context -/// \param keyFunc Key callback function for application processing of keyboard input -// -void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext, - void (ESCALLBACK *drawFunc) ( ESContext*, unsigned char, int, int ) ); -// -/// \brief Log a message to the debug output for the platform -/// \param formatStr Format string for error log. -// -void ESUTIL_API esLogMessage ( const char *formatStr, ... ); - -// -/// -/// \brief Load a shader, check for compile errors, print error messages to output log -/// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER) -/// \param shaderSrc Shader source string -/// \return A new shader object on success, 0 on failure -// -GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc ); - -// -/// -/// \brief Load a vertex and fragment shader, create a program object, link program. -/// Errors output to log. -/// \param vertShaderSrc Vertex shader source code -/// \param fragShaderSrc Fragment shader source code -/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure -// -GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc ); - - -// -/// \brief Generates geometry for a sphere. Allocates memory for the vertex data and stores -/// the results in the arrays. Generate index list for a TRIANGLE_STRIP -/// \param numSlices The number of slices in the sphere -/// \param vertices If not NULL, will contain array of float3 positions -/// \param normals If not NULL, will contain array of float3 normals -/// \param texCoords If not NULL, will contain array of float2 texCoords -/// \param indices If not NULL, will contain the array of indices for the triangle strip -/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array -/// if it is not NULL ) as a GL_TRIANGLE_STRIP -// -int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals, - GLfloat **texCoords, GLushort **indices ); - -// -/// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores -/// the results in the arrays. Generate index list for a TRIANGLES -/// \param scale The size of the cube, use 1.0 for a unit cube. -/// \param vertices If not NULL, will contain array of float3 positions -/// \param normals If not NULL, will contain array of float3 normals -/// \param texCoords If not NULL, will contain array of float2 texCoords -/// \param indices If not NULL, will contain the array of indices for the triangle strip -/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array -/// if it is not NULL ) as a GL_TRIANGLES -// -int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals, - GLfloat **texCoords, GLushort **indices ); - -// -/// \brief Loads a 24-bit TGA image from a file -/// \param fileName Name of the file on disk -/// \param width Width of loaded image in pixels -/// \param height Height of loaded image in pixels -/// \return Pointer to loaded image. NULL on failure. -// -char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height ); - - -// -/// \brief multiply matrix specified by result with a scaling matrix and return new matrix in result -/// \param result Specifies the input matrix. Scaled matrix is returned in result. -/// \param sx, sy, sz Scale factors along the x, y and z axes respectively -// -void ESUTIL_API esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz); - -// -/// \brief multiply matrix specified by result with a translation matrix and return new matrix in result -/// \param result Specifies the input matrix. Translated matrix is returned in result. -/// \param tx, ty, tz Scale factors along the x, y and z axes respectively -// -void ESUTIL_API esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz); - -// -/// \brief multiply matrix specified by result with a rotation matrix and return new matrix in result -/// \param result Specifies the input matrix. Rotated matrix is returned in result. -/// \param angle Specifies the angle of rotation, in degrees. -/// \param x, y, z Specify the x, y and z coordinates of a vector, respectively -// -void ESUTIL_API esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); - -// -// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result -/// \param result Specifies the input matrix. new matrix is returned in result. -/// \param left, right Coordinates for the left and right vertical clipping planes -/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes -/// \param nearZ, farZ Distances to the near and far depth clipping planes. Both distances must be positive. -// -void ESUTIL_API esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ); - -// -/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result -/// \param result Specifies the input matrix. new matrix is returned in result. -/// \param fovy Field of view y angle in degrees -/// \param aspect Aspect ratio of screen -/// \param nearZ Near plane distance -/// \param farZ Far plane distance -// -void ESUTIL_API esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ); - -// -/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result -/// \param result Specifies the input matrix. new matrix is returned in result. -/// \param left, right Coordinates for the left and right vertical clipping planes -/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes -/// \param nearZ, farZ Distances to the near and far depth clipping planes. These values are negative if plane is behind the viewer -// -void ESUTIL_API esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ); - -// -/// \brief perform the following operation - result matrix = srcA matrix * srcB matrix -/// \param result Returns multiplied matrix -/// \param srcA, srcB Input matrices to be multiplied -// -void ESUTIL_API esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB); - -// -//// \brief return an indentity matrix -//// \param result returns identity matrix -// -void ESUTIL_API esMatrixLoadIdentity(ESMatrix *result); - -#ifdef __cplusplus -} -#endif - -#endif // ESUTIL_H diff --git a/gfx/angle/samples/gles2_book/Common/esUtil.vcproj b/gfx/angle/samples/gles2_book/Common/esUtil.vcproj deleted file mode 100644 index aea0a3c999a6..000000000000 --- a/gfx/angle/samples/gles2_book/Common/esUtil.vcproj +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/Common/esUtil_win.h b/gfx/angle/samples/gles2_book/Common/esUtil_win.h deleted file mode 100644 index 8ba340693fa4..000000000000 --- a/gfx/angle/samples/gles2_book/Common/esUtil_win.h +++ /dev/null @@ -1,65 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// esUtil_win.h -// -// API-neutral interface for creating windows. Implementation needs to be provided per-platform. - -#ifndef ESUTIL_WIN_H -#define ESUTIL_WIN_H - -/// -// Includes -// - -#ifdef __cplusplus - -extern "C" { -#endif - - -/// -// Macros -// - -/// -// Types -// - -/// -// Public Functions -// - -/// -// WinCreate() -// -// Create Win32 instance and window -// -GLboolean WinCreate ( ESContext *esContext, LPCTSTR title ); - -/// -// WinLoop() -// -// Start main windows loop -// -void WinLoop ( ESContext *esContext ); - -/// -// WinTGALoad() -// -// TGA loader win32 implementation -// -int WinTGALoad ( const char *fileName, char **buffer, int *width, int *height ); - -#ifdef __cplusplus -} -#endif - -#endif // ESUTIL_WIN_H diff --git a/gfx/angle/samples/gles2_book/Hello_Triangle/Hello_Triangle.c b/gfx/angle/samples/gles2_book/Hello_Triangle/Hello_Triangle.c deleted file mode 100644 index b0e3a4c81cfa..000000000000 --- a/gfx/angle/samples/gles2_book/Hello_Triangle/Hello_Triangle.c +++ /dev/null @@ -1,194 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// Hello_Triangle.c -// -// This is a simple example that draws a single triangle with -// a minimal vertex/fragment shader. The purpose of this -// example is to demonstrate the basic concepts of -// OpenGL ES 2.0 rendering. -#include -#include "esUtil.h" - -typedef struct -{ - // Handle to a program object - GLuint programObject; - -} UserData; - -/// -// Create a shader object, load the shader source, and -// compile the shader. -// -GLuint LoadShader ( GLenum type, const char *shaderSrc ) -{ - GLuint shader; - GLint compiled; - - // Create the shader object - shader = glCreateShader ( type ); - - if ( shader == 0 ) - return 0; - - // Load the shader source - glShaderSource ( shader, 1, &shaderSrc, NULL ); - - // Compile the shader - glCompileShader ( shader ); - - // Check the compile status - glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled ); - - if ( !compiled ) - { - GLint infoLen = 0; - - glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen ); - - if ( infoLen > 1 ) - { - char* infoLog = malloc (sizeof(char) * infoLen ); - - glGetShaderInfoLog ( shader, infoLen, NULL, infoLog ); - esLogMessage ( "Error compiling shader:\n%s\n", infoLog ); - - free ( infoLog ); - } - - glDeleteShader ( shader ); - return 0; - } - - return shader; - -} - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLbyte vShaderStr[] = - "attribute vec4 vPosition; \n" - "void main() \n" - "{ \n" - " gl_Position = vPosition; \n" - "} \n"; - - GLbyte fShaderStr[] = - "precision mediump float;\n"\ - "void main() \n" - "{ \n" - " gl_FragColor = vec4 ( 1.0, 0.0, 0.0, 1.0 );\n" - "} \n"; - - GLuint vertexShader; - GLuint fragmentShader; - GLuint programObject; - GLint linked; - - // Load the vertex/fragment shaders - vertexShader = LoadShader ( GL_VERTEX_SHADER, vShaderStr ); - fragmentShader = LoadShader ( GL_FRAGMENT_SHADER, fShaderStr ); - - // Create the program object - programObject = glCreateProgram ( ); - - if ( programObject == 0 ) - return 0; - - glAttachShader ( programObject, vertexShader ); - glAttachShader ( programObject, fragmentShader ); - - // Bind vPosition to attribute 0 - glBindAttribLocation ( programObject, 0, "vPosition" ); - - // Link the program - glLinkProgram ( programObject ); - - // Check the link status - glGetProgramiv ( programObject, GL_LINK_STATUS, &linked ); - - if ( !linked ) - { - GLint infoLen = 0; - - glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen ); - - if ( infoLen > 1 ) - { - char* infoLog = malloc (sizeof(char) * infoLen ); - - glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog ); - esLogMessage ( "Error linking program:\n%s\n", infoLog ); - - free ( infoLog ); - } - - glDeleteProgram ( programObject ); - return FALSE; - } - - // Store the program object - userData->programObject = programObject; - - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - return TRUE; -} - -/// -// Draw a triangle using the shader pair created in Init() -// -void Draw ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLfloat vVertices[] = { 0.0f, 0.5f, 0.0f, - -0.5f, -0.5f, 0.0f, - 0.5f, -0.5f, 0.0f }; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - // Clear the color buffer - glClear ( GL_COLOR_BUFFER_BIT ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex data - glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, vVertices ); - glEnableVertexAttribArray ( 0 ); - - glDrawArrays ( GL_TRIANGLES, 0, 3 ); - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("Hello Triangle"), 320, 240, ES_WINDOW_RGB ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - - esMainLoop ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/Hello_Triangle/Hello_Triangle.vcproj b/gfx/angle/samples/gles2_book/Hello_Triangle/Hello_Triangle.vcproj deleted file mode 100644 index b43580a178ec..000000000000 --- a/gfx/angle/samples/gles2_book/Hello_Triangle/Hello_Triangle.vcproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/MipMap2D/MipMap2D.c b/gfx/angle/samples/gles2_book/MipMap2D/MipMap2D.c deleted file mode 100644 index bc70cd4c08c8..000000000000 --- a/gfx/angle/samples/gles2_book/MipMap2D/MipMap2D.c +++ /dev/null @@ -1,346 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// MipMap2D.c -// -// This is a simple example that demonstrates generating a mipmap chain -// and rendering with it -// -#include -#include "esUtil.h" - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint positionLoc; - GLint texCoordLoc; - - // Sampler location - GLint samplerLoc; - - // Offset location - GLint offsetLoc; - - // Texture handle - GLuint textureId; - -} UserData; - - -/// -// From an RGB8 source image, generate the next level mipmap -// -GLboolean GenMipMap2D( GLubyte *src, GLubyte **dst, int srcWidth, int srcHeight, int *dstWidth, int *dstHeight ) -{ - int x, - y; - int texelSize = 3; - - *dstWidth = srcWidth / 2; - if ( *dstWidth <= 0 ) - *dstWidth = 1; - - *dstHeight = srcHeight / 2; - if ( *dstHeight <= 0 ) - *dstHeight = 1; - - *dst = malloc ( sizeof(GLubyte) * texelSize * (*dstWidth) * (*dstHeight) ); - if ( *dst == NULL ) - return GL_FALSE; - - for ( y = 0; y < *dstHeight; y++ ) - { - for( x = 0; x < *dstWidth; x++ ) - { - int srcIndex[4]; - float r = 0.0f, - g = 0.0f, - b = 0.0f; - int sample; - - // Compute the offsets for 2x2 grid of pixels in previous - // image to perform box filter - srcIndex[0] = - (((y * 2) * srcWidth) + (x * 2)) * texelSize; - srcIndex[1] = - (((y * 2) * srcWidth) + (x * 2 + 1)) * texelSize; - srcIndex[2] = - ((((y * 2) + 1) * srcWidth) + (x * 2)) * texelSize; - srcIndex[3] = - ((((y * 2) + 1) * srcWidth) + (x * 2 + 1)) * texelSize; - - // Sum all pixels - for ( sample = 0; sample < 4; sample++ ) - { - r += src[srcIndex[sample]]; - g += src[srcIndex[sample] + 1]; - b += src[srcIndex[sample] + 2]; - } - - // Average results - r /= 4.0; - g /= 4.0; - b /= 4.0; - - // Store resulting pixels - (*dst)[ ( y * (*dstWidth) + x ) * texelSize ] = (GLubyte)( r ); - (*dst)[ ( y * (*dstWidth) + x ) * texelSize + 1] = (GLubyte)( g ); - (*dst)[ ( y * (*dstWidth) + x ) * texelSize + 2] = (GLubyte)( b ); - } - } - - return GL_TRUE; -} - -/// -// Generate an RGB8 checkerboard image -// -GLubyte* GenCheckImage( int width, int height, int checkSize ) -{ - int x, - y; - GLubyte *pixels = malloc( width * height * 3 ); - - if ( pixels == NULL ) - return NULL; - - for ( y = 0; y < height; y++ ) - for ( x = 0; x < width; x++ ) - { - GLubyte rColor = 0; - GLubyte bColor = 0; - - if ( ( x / checkSize ) % 2 == 0 ) - { - rColor = 255 * ( ( y / checkSize ) % 2 ); - bColor = 255 * ( 1 - ( ( y / checkSize ) % 2 ) ); - } - else - { - bColor = 255 * ( ( y / checkSize ) % 2 ); - rColor = 255 * ( 1 - ( ( y / checkSize ) % 2 ) ); - } - - pixels[(y * height + x) * 3] = rColor; - pixels[(y * height + x) * 3 + 1] = 0; - pixels[(y * height + x) * 3 + 2] = bColor; - } - - return pixels; -} - -/// -// Create a mipmapped 2D texture image -// -GLuint CreateMipMappedTexture2D( ) -{ - // Texture object handle - GLuint textureId; - int width = 256, - height = 256; - int level; - GLubyte *pixels; - GLubyte *prevImage; - GLubyte *newImage = NULL; - - pixels = GenCheckImage( width, height, 8 ); - if ( pixels == NULL ) - return 0; - - // Generate a texture object - glGenTextures ( 1, &textureId ); - - // Bind the texture object - glBindTexture ( GL_TEXTURE_2D, textureId ); - - // Load mipmap level 0 - glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, width, height, - 0, GL_RGB, GL_UNSIGNED_BYTE, pixels ); - - level = 1; - prevImage = &pixels[0]; - - while ( width > 1 && height > 1 ) - { - int newWidth, - newHeight; - - // Generate the next mipmap level - GenMipMap2D( prevImage, &newImage, width, height, - &newWidth, &newHeight ); - - // Load the mipmap level - glTexImage2D( GL_TEXTURE_2D, level, GL_RGB, - newWidth, newHeight, 0, GL_RGB, - GL_UNSIGNED_BYTE, newImage ); - - // Free the previous image - free ( prevImage ); - - // Set the previous image for the next iteration - prevImage = newImage; - level++; - - // Half the width and height - width = newWidth; - height = newHeight; - } - - free ( newImage ); - - // Set the filtering mode - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - - return textureId; - -} - - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLbyte vShaderStr[] = - "uniform float u_offset; \n" - "attribute vec4 a_position; \n" - "attribute vec2 a_texCoord; \n" - "varying vec2 v_texCoord; \n" - "void main() \n" - "{ \n" - " gl_Position = a_position; \n" - " gl_Position.x += u_offset;\n" - " v_texCoord = a_texCoord; \n" - "} \n"; - - GLbyte fShaderStr[] = - "precision mediump float; \n" - "varying vec2 v_texCoord; \n" - "uniform sampler2D s_texture; \n" - "void main() \n" - "{ \n" - " gl_FragColor = texture2D( s_texture, v_texCoord );\n" - "} \n"; - - // Load the shaders and get a linked program object - userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); - - // Get the attribute locations - userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" ); - userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" ); - - // Get the sampler location - userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" ); - - // Get the offset location - userData->offsetLoc = glGetUniformLocation( userData->programObject, "u_offset" ); - - // Load the texture - userData->textureId = CreateMipMappedTexture2D (); - - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - return TRUE; -} - -/// -// Draw a triangle using the shader pair created in Init() -// -void Draw ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLfloat vVertices[] = { -0.5f, 0.5f, 0.0f, 1.5f, // Position 0 - 0.0f, 0.0f, // TexCoord 0 - -0.5f, -0.5f, 0.0f, 0.75f, // Position 1 - 0.0f, 1.0f, // TexCoord 1 - 0.5f, -0.5f, 0.0f, 0.75f, // Position 2 - 1.0f, 1.0f, // TexCoord 2 - 0.5f, 0.5f, 0.0f, 1.5f, // Position 3 - 1.0f, 0.0f // TexCoord 3 - }; - GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - // Clear the color buffer - glClear ( GL_COLOR_BUFFER_BIT ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex position - glVertexAttribPointer ( userData->positionLoc, 4, GL_FLOAT, - GL_FALSE, 6 * sizeof(GLfloat), vVertices ); - // Load the texture coordinate - glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT, - GL_FALSE, 6 * sizeof(GLfloat), &vVertices[4] ); - - glEnableVertexAttribArray ( userData->positionLoc ); - glEnableVertexAttribArray ( userData->texCoordLoc ); - - // Bind the texture - glActiveTexture ( GL_TEXTURE0 ); - glBindTexture ( GL_TEXTURE_2D, userData->textureId ); - - // Set the sampler texture unit to 0 - glUniform1i ( userData->samplerLoc, 0 ); - - // Draw quad with nearest sampling - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - glUniform1f ( userData->offsetLoc, -0.6f ); - glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices ); - - // Draw quad with trilinear filtering - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - glUniform1f ( userData->offsetLoc, 0.6f ); - glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices ); - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); -} - -/// -// Cleanup -// -void ShutDown ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Delete texture object - glDeleteTextures ( 1, &userData->textureId ); - - // Delete program object - glDeleteProgram ( userData->programObject ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("MipMap 2D"), 320, 240, ES_WINDOW_RGB ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/MipMap2D/MipMap2D.vcproj b/gfx/angle/samples/gles2_book/MipMap2D/MipMap2D.vcproj deleted file mode 100644 index 4d7e07ed7189..000000000000 --- a/gfx/angle/samples/gles2_book/MipMap2D/MipMap2D.vcproj +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/MultiTexture/MultiTexture.c b/gfx/angle/samples/gles2_book/MultiTexture/MultiTexture.c deleted file mode 100644 index bb2224a34cd2..000000000000 --- a/gfx/angle/samples/gles2_book/MultiTexture/MultiTexture.c +++ /dev/null @@ -1,213 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// MultiTexture.c -// -// This is an example that draws a quad with a basemap and -// lightmap to demonstrate multitexturing. -// -#include -#include "esUtil.h" - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint positionLoc; - GLint texCoordLoc; - - // Sampler locations - GLint baseMapLoc; - GLint lightMapLoc; - - // Texture handle - GLuint baseMapTexId; - GLuint lightMapTexId; - -} UserData; - - -/// -// Load texture from disk -// -GLuint LoadTexture ( char *fileName ) -{ - int width, - height; - char *buffer = esLoadTGA ( fileName, &width, &height ); - GLuint texId; - - if ( buffer == NULL ) - { - esLogMessage ( "Error loading (%s) image.\n", fileName ); - return 0; - } - - glGenTextures ( 1, &texId ); - glBindTexture ( GL_TEXTURE_2D, texId ); - - glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - - free ( buffer ); - - return texId; -} - - - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLbyte vShaderStr[] = - "attribute vec4 a_position; \n" - "attribute vec2 a_texCoord; \n" - "varying vec2 v_texCoord; \n" - "void main() \n" - "{ \n" - " gl_Position = a_position; \n" - " v_texCoord = a_texCoord; \n" - "} \n"; - - GLbyte fShaderStr[] = - "precision mediump float; \n" - "varying vec2 v_texCoord; \n" - "uniform sampler2D s_baseMap; \n" - "uniform sampler2D s_lightMap; \n" - "void main() \n" - "{ \n" - " vec4 baseColor; \n" - " vec4 lightColor; \n" - " \n" - " baseColor = texture2D( s_baseMap, v_texCoord ); \n" - " lightColor = texture2D( s_lightMap, v_texCoord ); \n" - " gl_FragColor = baseColor * (lightColor + 0.25); \n" - "} \n"; - - // Load the shaders and get a linked program object - userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); - - // Get the attribute locations - userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" ); - userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" ); - - // Get the sampler location - userData->baseMapLoc = glGetUniformLocation ( userData->programObject, "s_baseMap" ); - userData->lightMapLoc = glGetUniformLocation ( userData->programObject, "s_lightMap" ); - - // Load the textures - userData->baseMapTexId = LoadTexture ( "basemap.tga" ); - userData->lightMapTexId = LoadTexture ( "lightmap.tga" ); - - if ( userData->baseMapTexId == 0 || userData->lightMapTexId == 0 ) - return FALSE; - - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - return TRUE; -} - -/// -// Draw a triangle using the shader pair created in Init() -// -void Draw ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLfloat vVertices[] = { -0.5f, 0.5f, 0.0f, // Position 0 - 0.0f, 0.0f, // TexCoord 0 - -0.5f, -0.5f, 0.0f, // Position 1 - 0.0f, 1.0f, // TexCoord 1 - 0.5f, -0.5f, 0.0f, // Position 2 - 1.0f, 1.0f, // TexCoord 2 - 0.5f, 0.5f, 0.0f, // Position 3 - 1.0f, 0.0f // TexCoord 3 - }; - GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - // Clear the color buffer - glClear ( GL_COLOR_BUFFER_BIT ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex position - glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT, - GL_FALSE, 5 * sizeof(GLfloat), vVertices ); - // Load the texture coordinate - glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT, - GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3] ); - - glEnableVertexAttribArray ( userData->positionLoc ); - glEnableVertexAttribArray ( userData->texCoordLoc ); - - // Bind the base map - glActiveTexture ( GL_TEXTURE0 ); - glBindTexture ( GL_TEXTURE_2D, userData->baseMapTexId ); - - // Set the base map sampler to texture unit to 0 - glUniform1i ( userData->baseMapLoc, 0 ); - - // Bind the light map - glActiveTexture ( GL_TEXTURE1 ); - glBindTexture ( GL_TEXTURE_2D, userData->lightMapTexId ); - - // Set the light map sampler to texture unit 1 - glUniform1i ( userData->lightMapLoc, 1 ); - - glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices ); - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); -} - -/// -// Cleanup -// -void ShutDown ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Delete texture object - glDeleteTextures ( 1, &userData->baseMapTexId ); - glDeleteTextures ( 1, &userData->lightMapTexId ); - - // Delete program object - glDeleteProgram ( userData->programObject ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("MultiTexture"), 320, 240, ES_WINDOW_RGB ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/MultiTexture/MultiTexture.vcproj b/gfx/angle/samples/gles2_book/MultiTexture/MultiTexture.vcproj deleted file mode 100644 index 0bd4dd09a212..000000000000 --- a/gfx/angle/samples/gles2_book/MultiTexture/MultiTexture.vcproj +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/MultiTexture/basemap.tga b/gfx/angle/samples/gles2_book/MultiTexture/basemap.tga deleted file mode 100644 index 8acafae236cd..000000000000 Binary files a/gfx/angle/samples/gles2_book/MultiTexture/basemap.tga and /dev/null differ diff --git a/gfx/angle/samples/gles2_book/MultiTexture/lightmap.tga b/gfx/angle/samples/gles2_book/MultiTexture/lightmap.tga deleted file mode 100644 index d95b262837d7..000000000000 Binary files a/gfx/angle/samples/gles2_book/MultiTexture/lightmap.tga and /dev/null differ diff --git a/gfx/angle/samples/gles2_book/ParticleSystem/ParticleSystem.c b/gfx/angle/samples/gles2_book/ParticleSystem/ParticleSystem.c deleted file mode 100644 index 22141334c8fc..000000000000 --- a/gfx/angle/samples/gles2_book/ParticleSystem/ParticleSystem.c +++ /dev/null @@ -1,294 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// ParticleSystem.c -// -// This is an example that demonstrates rendering a particle system -// using a vertex shader and point sprites. -// -#include -#include -#include "esUtil.h" - -#define NUM_PARTICLES 1000 -#define PARTICLE_SIZE 7 - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint lifetimeLoc; - GLint startPositionLoc; - GLint endPositionLoc; - - // Uniform location - GLint timeLoc; - GLint colorLoc; - GLint centerPositionLoc; - GLint samplerLoc; - - // Texture handle - GLuint textureId; - - // Particle vertex data - float particleData[ NUM_PARTICLES * PARTICLE_SIZE ]; - - // Current time - float time; - -} UserData; - -/// -// Load texture from disk -// -GLuint LoadTexture ( char *fileName ) -{ - int width, - height; - char *buffer = esLoadTGA ( fileName, &width, &height ); - GLuint texId; - - if ( buffer == NULL ) - { - esLogMessage ( "Error loading (%s) image.\n", fileName ); - return 0; - } - - glGenTextures ( 1, &texId ); - glBindTexture ( GL_TEXTURE_2D, texId ); - - glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - - free ( buffer ); - - return texId; -} - - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - int i; - - GLbyte vShaderStr[] = - "uniform float u_time; \n" - "uniform vec3 u_centerPosition; \n" - "attribute float a_lifetime; \n" - "attribute vec3 a_startPosition; \n" - "attribute vec3 a_endPosition; \n" - "varying float v_lifetime; \n" - "void main() \n" - "{ \n" - " if ( u_time <= a_lifetime ) \n" - " { \n" - " gl_Position.xyz = a_startPosition + \n" - " (u_time * a_endPosition); \n" - " gl_Position.xyz += u_centerPosition; \n" - " gl_Position.w = 1.0; \n" - " } \n" - " else \n" - " gl_Position = vec4( -1000, -1000, 0, 0 ); \n" - " v_lifetime = 1.0 - ( u_time / a_lifetime ); \n" - " v_lifetime = clamp ( v_lifetime, 0.0, 1.0 ); \n" - " gl_PointSize = ( v_lifetime * v_lifetime ) * 40.0; \n" - "}"; - - GLbyte fShaderStr[] = - "precision mediump float; \n" - "uniform vec4 u_color; \n" - "varying float v_lifetime; \n" - "uniform sampler2D s_texture; \n" - "void main() \n" - "{ \n" - " vec4 texColor; \n" - " texColor = texture2D( s_texture, gl_PointCoord ); \n" - " gl_FragColor = vec4( u_color ) * texColor; \n" - " gl_FragColor.a *= v_lifetime; \n" - "} \n"; - - // Load the shaders and get a linked program object - userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); - - // Get the attribute locations - userData->lifetimeLoc = glGetAttribLocation ( userData->programObject, "a_lifetime" ); - userData->startPositionLoc = glGetAttribLocation ( userData->programObject, "a_startPosition" ); - userData->endPositionLoc = glGetAttribLocation ( userData->programObject, "a_endPosition" ); - - // Get the uniform locations - userData->timeLoc = glGetUniformLocation ( userData->programObject, "u_time" ); - userData->centerPositionLoc = glGetUniformLocation ( userData->programObject, "u_centerPosition" ); - userData->colorLoc = glGetUniformLocation ( userData->programObject, "u_color" ); - userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" ); - - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - - // Fill in particle data array - srand ( 0 ); - for ( i = 0; i < NUM_PARTICLES; i++ ) - { - float *particleData = &userData->particleData[i * PARTICLE_SIZE]; - - // Lifetime of particle - (*particleData++) = ( (float)(rand() % 10000) / 10000.0f ); - - // End position of particle - (*particleData++) = ( (float)(rand() % 10000) / 5000.0f ) - 1.0f; - (*particleData++) = ( (float)(rand() % 10000) / 5000.0f ) - 1.0f; - (*particleData++) = ( (float)(rand() % 10000) / 5000.0f ) - 1.0f; - - // Start position of particle - (*particleData++) = ( (float)(rand() % 10000) / 40000.0f ) - 0.125f; - (*particleData++) = ( (float)(rand() % 10000) / 40000.0f ) - 0.125f; - (*particleData++) = ( (float)(rand() % 10000) / 40000.0f ) - 0.125f; - - } - - // Initialize time to cause reset on first update - userData->time = 1.0f; - - userData->textureId = LoadTexture ( "smoke.tga" ); - if ( userData->textureId <= 0 ) - { - return FALSE; - } - - return TRUE; -} - -/// -// Update time-based variables -// -void Update ( ESContext *esContext, float deltaTime ) -{ - UserData *userData = esContext->userData; - - userData->time += deltaTime; - - if ( userData->time >= 1.0f ) - { - float centerPos[3]; - float color[4]; - - userData->time = 0.0f; - - // Pick a new start location and color - centerPos[0] = ( (float)(rand() % 10000) / 10000.0f ) - 0.5f; - centerPos[1] = ( (float)(rand() % 10000) / 10000.0f ) - 0.5f; - centerPos[2] = ( (float)(rand() % 10000) / 10000.0f ) - 0.5f; - - glUniform3fv ( userData->centerPositionLoc, 1, ¢erPos[0] ); - - // Random color - color[0] = ( (float)(rand() % 10000) / 20000.0f ) + 0.5f; - color[1] = ( (float)(rand() % 10000) / 20000.0f ) + 0.5f; - color[2] = ( (float)(rand() % 10000) / 20000.0f ) + 0.5f; - color[3] = 0.5; - - glUniform4fv ( userData->colorLoc, 1, &color[0] ); - } - - // Load uniform time variable - glUniform1f ( userData->timeLoc, userData->time ); -} - -/// -// Draw a triangle using the shader pair created in Init() -// -void Draw ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - // Clear the color buffer - glClear ( GL_COLOR_BUFFER_BIT ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex attributes - glVertexAttribPointer ( userData->lifetimeLoc, 1, GL_FLOAT, - GL_FALSE, PARTICLE_SIZE * sizeof(GLfloat), - userData->particleData ); - - glVertexAttribPointer ( userData->endPositionLoc, 3, GL_FLOAT, - GL_FALSE, PARTICLE_SIZE * sizeof(GLfloat), - &userData->particleData[1] ); - - glVertexAttribPointer ( userData->startPositionLoc, 3, GL_FLOAT, - GL_FALSE, PARTICLE_SIZE * sizeof(GLfloat), - &userData->particleData[4] ); - - - glEnableVertexAttribArray ( userData->lifetimeLoc ); - glEnableVertexAttribArray ( userData->endPositionLoc ); - glEnableVertexAttribArray ( userData->startPositionLoc ); - // Blend particles - glEnable ( GL_BLEND ); - glBlendFunc ( GL_SRC_ALPHA, GL_ONE ); - - // Bind the texture - glActiveTexture ( GL_TEXTURE0 ); - glBindTexture ( GL_TEXTURE_2D, userData->textureId ); - glEnable ( GL_TEXTURE_2D ); - - // Set the sampler texture unit to 0 - glUniform1i ( userData->samplerLoc, 0 ); - - glDrawArrays( GL_POINTS, 0, NUM_PARTICLES ); - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); -} - -/// -// Cleanup -// -void ShutDown ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Delete texture object - glDeleteTextures ( 1, &userData->textureId ); - - // Delete program object - glDeleteProgram ( userData->programObject ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("ParticleSystem"), 640, 480, ES_WINDOW_RGB ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - esRegisterUpdateFunc ( &esContext, Update ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/ParticleSystem/ParticleSystem.vcproj b/gfx/angle/samples/gles2_book/ParticleSystem/ParticleSystem.vcproj deleted file mode 100644 index ecaaecae338b..000000000000 --- a/gfx/angle/samples/gles2_book/ParticleSystem/ParticleSystem.vcproj +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/ParticleSystem/smoke.tga b/gfx/angle/samples/gles2_book/ParticleSystem/smoke.tga deleted file mode 100644 index 06a0705c7e67..000000000000 Binary files a/gfx/angle/samples/gles2_book/ParticleSystem/smoke.tga and /dev/null differ diff --git a/gfx/angle/samples/gles2_book/PostSubBuffer/PostSubBuffer.c b/gfx/angle/samples/gles2_book/PostSubBuffer/PostSubBuffer.c deleted file mode 100644 index 0096ec31b03d..000000000000 --- a/gfx/angle/samples/gles2_book/PostSubBuffer/PostSubBuffer.c +++ /dev/null @@ -1,204 +0,0 @@ -// Based on a sample from: -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// PostSubBuffer.c -// -// This is a simple example that draws a rotating cube in perspective -// using a vertex shader to transform the object, posting only a subrectangle -// to the window surface. -// -#include -#include "esUtil.h" - -#define WINDOW_WIDTH 320 -#define WINDOW_HEIGHT 240 - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint positionLoc; - - // Uniform locations - GLint mvpLoc; - - // Vertex daata - GLfloat *vertices; - GLushort *indices; - int numIndices; - - // Rotation angle - GLfloat angle; - - // MVP matrix - ESMatrix mvpMatrix; -} UserData; - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLbyte vShaderStr[] = - "uniform mat4 u_mvpMatrix; \n" - "attribute vec4 a_position; \n" - "void main() \n" - "{ \n" - " gl_Position = u_mvpMatrix * a_position; \n" - "} \n"; - - GLbyte fShaderStr[] = - "precision mediump float; \n" - "void main() \n" - "{ \n" - " gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); \n" - "} \n"; - - // Load the shaders and get a linked program object - userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); - - // Get the attribute locations - userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" ); - - // Get the uniform locations - userData->mvpLoc = glGetUniformLocation( userData->programObject, "u_mvpMatrix" ); - - // Generate the vertex data - userData->numIndices = esGenCube( 1.0, &userData->vertices, - NULL, NULL, &userData->indices ); - - // Starting rotation angle for the cube - userData->angle = 45.0f; - - // Clear the whole window surface. - glClearColor ( 0.0f, 0.0f, 1.0f, 0.0f ); - glClear ( GL_COLOR_BUFFER_BIT ); - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); - - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - return TRUE; -} - - -/// -// Update MVP matrix based on time -// -void Update ( ESContext *esContext, float deltaTime ) -{ - UserData *userData = (UserData*) esContext->userData; - ESMatrix perspective; - ESMatrix modelview; - float aspect; - - // Compute a rotation angle based on time to rotate the cube - userData->angle += ( deltaTime * 40.0f ); - if( userData->angle >= 360.0f ) - userData->angle -= 360.0f; - - // Compute the window aspect ratio - aspect = (GLfloat) esContext->width / (GLfloat) esContext->height; - - // Generate a perspective matrix with a 60 degree FOV - esMatrixLoadIdentity( &perspective ); - esPerspective( &perspective, 60.0f, aspect, 1.0f, 20.0f ); - - // Generate a model view matrix to rotate/translate the cube - esMatrixLoadIdentity( &modelview ); - - // Translate away from the viewer - esTranslate( &modelview, 0.0, 0.0, -2.0 ); - - // Rotate the cube - esRotate( &modelview, userData->angle, 1.0, 0.0, 1.0 ); - - // Compute the final MVP by multiplying the - // modevleiw and perspective matrices together - esMatrixMultiply( &userData->mvpMatrix, &modelview, &perspective ); -} - -/// -// Draw a triangle using the shader pair created in Init() -// -void Draw ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - - // Clear the color buffer - glClear ( GL_COLOR_BUFFER_BIT ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex position - glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT, - GL_FALSE, 3 * sizeof(GLfloat), userData->vertices ); - - glEnableVertexAttribArray ( userData->positionLoc ); - - - // Load the MVP matrix - glUniformMatrix4fv( userData->mvpLoc, 1, GL_FALSE, (GLfloat*) &userData->mvpMatrix.m[0][0] ); - - // Draw the cube - glDrawElements ( GL_TRIANGLES, userData->numIndices, GL_UNSIGNED_SHORT, userData->indices ); - - eglPostSubBufferNV ( esContext->eglDisplay, esContext->eglSurface, 60, 60, WINDOW_WIDTH - 120, WINDOW_HEIGHT - 120 ); -} - -/// -// Cleanup -// -void ShutDown ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - if ( userData->vertices != NULL ) - { - free ( userData->vertices ); - } - - if ( userData->indices != NULL ) - { - free ( userData->indices ); - } - - // Delete program object - glDeleteProgram ( userData->programObject ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("Simple Vertex Shader"), WINDOW_WIDTH, WINDOW_HEIGHT, ES_WINDOW_RGB | ES_WINDOW_POST_SUB_BUFFER_SUPPORTED ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - esRegisterUpdateFunc ( &esContext, Update ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/PostSubBuffer/PostSubBuffer.vcproj b/gfx/angle/samples/gles2_book/PostSubBuffer/PostSubBuffer.vcproj deleted file mode 100644 index e123d1d760b0..000000000000 --- a/gfx/angle/samples/gles2_book/PostSubBuffer/PostSubBuffer.vcproj +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/Simple_Texture2D/Simple_Texture2D.c b/gfx/angle/samples/gles2_book/Simple_Texture2D/Simple_Texture2D.c deleted file mode 100644 index b074608a7570..000000000000 --- a/gfx/angle/samples/gles2_book/Simple_Texture2D/Simple_Texture2D.c +++ /dev/null @@ -1,198 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// Simple_Texture2D.c -// -// This is a simple example that draws a quad with a 2D -// texture image. The purpose of this example is to demonstrate -// the basics of 2D texturing -// -#include -#include "esUtil.h" - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint positionLoc; - GLint texCoordLoc; - - // Sampler location - GLint samplerLoc; - - // Texture handle - GLuint textureId; - -} UserData; - -/// -// Create a simple 2x2 texture image with four different colors -// -GLuint CreateSimpleTexture2D( ) -{ - // Texture object handle - GLuint textureId; - - // 2x2 Image, 3 bytes per pixel (R, G, B) - GLubyte pixels[4 * 3] = - { - 255, 0, 0, // Red - 0, 255, 0, // Green - 0, 0, 255, // Blue - 255, 255, 0 // Yellow - }; - - // Use tightly packed data - glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 ); - - // Generate a texture object - glGenTextures ( 1, &textureId ); - - // Bind the texture object - glBindTexture ( GL_TEXTURE_2D, textureId ); - - // Load the texture - glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels ); - - // Set the filtering mode - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - - return textureId; - -} - - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLbyte vShaderStr[] = - "attribute vec4 a_position; \n" - "attribute vec2 a_texCoord; \n" - "varying vec2 v_texCoord; \n" - "void main() \n" - "{ \n" - " gl_Position = a_position; \n" - " v_texCoord = a_texCoord; \n" - "} \n"; - - GLbyte fShaderStr[] = - "precision mediump float; \n" - "varying vec2 v_texCoord; \n" - "uniform sampler2D s_texture; \n" - "void main() \n" - "{ \n" - " gl_FragColor = texture2D( s_texture, v_texCoord );\n" - "} \n"; - - // Load the shaders and get a linked program object - userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); - - // Get the attribute locations - userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" ); - userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" ); - - // Get the sampler location - userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" ); - - // Load the texture - userData->textureId = CreateSimpleTexture2D (); - - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - return TRUE; -} - -/// -// Draw a triangle using the shader pair created in Init() -// -void Draw ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLfloat vVertices[] = { -0.5f, 0.5f, 0.0f, // Position 0 - 0.0f, 0.0f, // TexCoord 0 - -0.5f, -0.5f, 0.0f, // Position 1 - 0.0f, 1.0f, // TexCoord 1 - 0.5f, -0.5f, 0.0f, // Position 2 - 1.0f, 1.0f, // TexCoord 2 - 0.5f, 0.5f, 0.0f, // Position 3 - 1.0f, 0.0f // TexCoord 3 - }; - GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - // Clear the color buffer - glClear ( GL_COLOR_BUFFER_BIT ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex position - glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT, - GL_FALSE, 5 * sizeof(GLfloat), vVertices ); - // Load the texture coordinate - glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT, - GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3] ); - - glEnableVertexAttribArray ( userData->positionLoc ); - glEnableVertexAttribArray ( userData->texCoordLoc ); - - // Bind the texture - glActiveTexture ( GL_TEXTURE0 ); - glBindTexture ( GL_TEXTURE_2D, userData->textureId ); - - // Set the sampler texture unit to 0 - glUniform1i ( userData->samplerLoc, 0 ); - - glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices ); - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); -} - -/// -// Cleanup -// -void ShutDown ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Delete texture object - glDeleteTextures ( 1, &userData->textureId ); - - // Delete program object - glDeleteProgram ( userData->programObject ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("Simple Texture 2D"), 320, 240, ES_WINDOW_RGB ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/Simple_Texture2D/Simple_Texture2D.vcproj b/gfx/angle/samples/gles2_book/Simple_Texture2D/Simple_Texture2D.vcproj deleted file mode 100644 index f21eb8060844..000000000000 --- a/gfx/angle/samples/gles2_book/Simple_Texture2D/Simple_Texture2D.vcproj +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/Simple_TextureCubemap/Simple_TextureCubemap.c b/gfx/angle/samples/gles2_book/Simple_TextureCubemap/Simple_TextureCubemap.c deleted file mode 100644 index 302d844f5979..000000000000 --- a/gfx/angle/samples/gles2_book/Simple_TextureCubemap/Simple_TextureCubemap.c +++ /dev/null @@ -1,229 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// Simple_TextureCubemap.c -// -// This is a simple example that draws a sphere with a cubemap image applied. -// -#include -#include "esUtil.h" - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint positionLoc; - GLint normalLoc; - - // Sampler location - GLint samplerLoc; - - // Texture handle - GLuint textureId; - - // Vertex data - int numIndices; - GLfloat *vertices; - GLfloat *normals; - GLushort *indices; - -} UserData; - -/// -// Create a simple cubemap with a 1x1 face with a different -// color for each face -GLuint CreateSimpleTextureCubemap( ) -{ - GLuint textureId; - // Six 1x1 RGB faces - GLubyte cubePixels[6][3] = - { - // Face 0 - Red - 255, 0, 0, - // Face 1 - Green, - 0, 255, 0, - // Face 3 - Blue - 0, 0, 255, - // Face 4 - Yellow - 255, 255, 0, - // Face 5 - Purple - 255, 0, 255, - // Face 6 - White - 255, 255, 255 - }; - - // Generate a texture object - glGenTextures ( 1, &textureId ); - - // Bind the texture object - glBindTexture ( GL_TEXTURE_CUBE_MAP, textureId ); - - // Load the cube face - Positive X - glTexImage2D ( GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 1, 0, - GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[0] ); - - // Load the cube face - Negative X - glTexImage2D ( GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 1, 0, - GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[1] ); - - // Load the cube face - Positive Y - glTexImage2D ( GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 1, 0, - GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[2] ); - - // Load the cube face - Negative Y - glTexImage2D ( GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 1, 0, - GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[3] ); - - // Load the cube face - Positive Z - glTexImage2D ( GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 1, 0, - GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[4] ); - - // Load the cube face - Negative Z - glTexImage2D ( GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 1, 0, - GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[5] ); - - // Set the filtering mode - glTexParameteri ( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - glTexParameteri ( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - - return textureId; - -} - - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLbyte vShaderStr[] = - "attribute vec4 a_position; \n" - "attribute vec3 a_normal; \n" - "varying vec3 v_normal; \n" - "void main() \n" - "{ \n" - " gl_Position = a_position; \n" - " v_normal = a_normal; \n" - "} \n"; - - GLbyte fShaderStr[] = - "precision mediump float; \n" - "varying vec3 v_normal; \n" - "uniform samplerCube s_texture; \n" - "void main() \n" - "{ \n" - " gl_FragColor = textureCube( s_texture, v_normal );\n" - "} \n"; - - // Load the shaders and get a linked program object - userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); - - // Get the attribute locations - userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" ); - userData->normalLoc = glGetAttribLocation ( userData->programObject, "a_normal" ); - - // Get the sampler locations - userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" ); - - // Load the texture - userData->textureId = CreateSimpleTextureCubemap (); - - // Generate the vertex data - userData->numIndices = esGenSphere ( 20, 0.75f, &userData->vertices, &userData->normals, - NULL, &userData->indices ); - - - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - return TRUE; -} - -/// -// Draw a triangle using the shader pair created in Init() -// -void Draw ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - // Clear the color buffer - glClear ( GL_COLOR_BUFFER_BIT ); - - - glCullFace ( GL_BACK ); - glEnable ( GL_CULL_FACE ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex position - glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT, - GL_FALSE, 0, userData->vertices ); - // Load the normal - glVertexAttribPointer ( userData->normalLoc, 3, GL_FLOAT, - GL_FALSE, 0, userData->normals ); - - glEnableVertexAttribArray ( userData->positionLoc ); - glEnableVertexAttribArray ( userData->normalLoc ); - - // Bind the texture - glActiveTexture ( GL_TEXTURE0 ); - glBindTexture ( GL_TEXTURE_CUBE_MAP, userData->textureId ); - - // Set the sampler texture unit to 0 - glUniform1i ( userData->samplerLoc, 0 ); - - glDrawElements ( GL_TRIANGLES, userData->numIndices, - GL_UNSIGNED_SHORT, userData->indices ); - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); -} - -/// -// Cleanup -// -void ShutDown ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Delete texture object - glDeleteTextures ( 1, &userData->textureId ); - - // Delete program object - glDeleteProgram ( userData->programObject ); - - free ( userData->vertices ); - free ( userData->normals ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("Simple Texture Cubemap"), 320, 240, ES_WINDOW_RGB ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/Simple_TextureCubemap/Simple_TextureCubemap.vcproj b/gfx/angle/samples/gles2_book/Simple_TextureCubemap/Simple_TextureCubemap.vcproj deleted file mode 100644 index 0ae5e6a84a0e..000000000000 --- a/gfx/angle/samples/gles2_book/Simple_TextureCubemap/Simple_TextureCubemap.vcproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/Simple_VertexShader/Simple_VertexShader.c b/gfx/angle/samples/gles2_book/Simple_VertexShader/Simple_VertexShader.c deleted file mode 100644 index df5c98d612f3..000000000000 --- a/gfx/angle/samples/gles2_book/Simple_VertexShader/Simple_VertexShader.c +++ /dev/null @@ -1,194 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// Simple_VertexShader.c -// -// This is a simple example that draws a rotating cube in perspective -// using a vertex shader to transform the object -// -#include -#include "esUtil.h" - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint positionLoc; - - // Uniform locations - GLint mvpLoc; - - // Vertex daata - GLfloat *vertices; - GLushort *indices; - int numIndices; - - // Rotation angle - GLfloat angle; - - // MVP matrix - ESMatrix mvpMatrix; -} UserData; - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLbyte vShaderStr[] = - "uniform mat4 u_mvpMatrix; \n" - "attribute vec4 a_position; \n" - "void main() \n" - "{ \n" - " gl_Position = u_mvpMatrix * a_position; \n" - "} \n"; - - GLbyte fShaderStr[] = - "precision mediump float; \n" - "void main() \n" - "{ \n" - " gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); \n" - "} \n"; - - // Load the shaders and get a linked program object - userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); - - // Get the attribute locations - userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" ); - - // Get the uniform locations - userData->mvpLoc = glGetUniformLocation( userData->programObject, "u_mvpMatrix" ); - - // Generate the vertex data - userData->numIndices = esGenCube( 1.0, &userData->vertices, - NULL, NULL, &userData->indices ); - - // Starting rotation angle for the cube - userData->angle = 45.0f; - - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - return TRUE; -} - - -/// -// Update MVP matrix based on time -// -void Update ( ESContext *esContext, float deltaTime ) -{ - UserData *userData = (UserData*) esContext->userData; - ESMatrix perspective; - ESMatrix modelview; - float aspect; - - // Compute a rotation angle based on time to rotate the cube - userData->angle += ( deltaTime * 40.0f ); - if( userData->angle >= 360.0f ) - userData->angle -= 360.0f; - - // Compute the window aspect ratio - aspect = (GLfloat) esContext->width / (GLfloat) esContext->height; - - // Generate a perspective matrix with a 60 degree FOV - esMatrixLoadIdentity( &perspective ); - esPerspective( &perspective, 60.0f, aspect, 1.0f, 20.0f ); - - // Generate a model view matrix to rotate/translate the cube - esMatrixLoadIdentity( &modelview ); - - // Translate away from the viewer - esTranslate( &modelview, 0.0, 0.0, -2.0 ); - - // Rotate the cube - esRotate( &modelview, userData->angle, 1.0, 0.0, 1.0 ); - - // Compute the final MVP by multiplying the - // modevleiw and perspective matrices together - esMatrixMultiply( &userData->mvpMatrix, &modelview, &perspective ); -} - -/// -// Draw a triangle using the shader pair created in Init() -// -void Draw ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - - // Clear the color buffer - glClear ( GL_COLOR_BUFFER_BIT ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex position - glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT, - GL_FALSE, 3 * sizeof(GLfloat), userData->vertices ); - - glEnableVertexAttribArray ( userData->positionLoc ); - - - // Load the MVP matrix - glUniformMatrix4fv( userData->mvpLoc, 1, GL_FALSE, (GLfloat*) &userData->mvpMatrix.m[0][0] ); - - // Draw the cube - glDrawElements ( GL_TRIANGLES, userData->numIndices, GL_UNSIGNED_SHORT, userData->indices ); - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); -} - -/// -// Cleanup -// -void ShutDown ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - if ( userData->vertices != NULL ) - { - free ( userData->vertices ); - } - - if ( userData->indices != NULL ) - { - free ( userData->indices ); - } - - // Delete program object - glDeleteProgram ( userData->programObject ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("Simple Vertex Shader"), 320, 240, ES_WINDOW_RGB ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - esRegisterUpdateFunc ( &esContext, Update ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/Simple_VertexShader/Simple_VertexShader.vcproj b/gfx/angle/samples/gles2_book/Simple_VertexShader/Simple_VertexShader.vcproj deleted file mode 100644 index 57c3688e4d85..000000000000 --- a/gfx/angle/samples/gles2_book/Simple_VertexShader/Simple_VertexShader.vcproj +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/Stencil_Test/Stencil_Test.c b/gfx/angle/samples/gles2_book/Stencil_Test/Stencil_Test.c deleted file mode 100644 index 4996ccfcaac2..000000000000 --- a/gfx/angle/samples/gles2_book/Stencil_Test/Stencil_Test.c +++ /dev/null @@ -1,273 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// Stencil_Test.c -// -// This example shows various stencil buffer -// operations. -// -#include -#include "esUtil.h" - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint positionLoc; - - // Uniform locations - GLint colorLoc; - -} UserData; - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLbyte vShaderStr[] = - "attribute vec4 a_position; \n" - "void main() \n" - "{ \n" - " gl_Position = a_position; \n" - "} \n"; - - GLbyte fShaderStr[] = - "precision mediump float; \n" - "uniform vec4 u_color; \n" - "void main() \n" - "{ \n" - " gl_FragColor = u_color; \n" - "} \n"; - - // Load the shaders and get a linked program object - userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); - - // Get the attribute locations - userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" ); - - // Get the sampler location - userData->colorLoc = glGetUniformLocation ( userData->programObject, "u_color" ); - - // Set the clear color - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - - // Set the stencil clear value - glClearStencil ( 0x1 ); - - // Set the depth clear value - glClearDepthf( 0.75f ); - - // Enable the depth and stencil tests - glEnable( GL_DEPTH_TEST ); - glEnable( GL_STENCIL_TEST ); - - return TRUE; -} - -/// -// Initialize the stencil buffer values, and then use those -// values to control rendering -// -void Draw ( ESContext *esContext ) -{ - int i; - - UserData *userData = esContext->userData; - - GLfloat vVertices[] = { - -0.75f, 0.25f, 0.50f, // Quad #0 - -0.25f, 0.25f, 0.50f, - -0.25f, 0.75f, 0.50f, - -0.75f, 0.75f, 0.50f, - 0.25f, 0.25f, 0.90f, // Quad #1 - 0.75f, 0.25f, 0.90f, - 0.75f, 0.75f, 0.90f, - 0.25f, 0.75f, 0.90f, - -0.75f, -0.75f, 0.50f, // Quad #2 - -0.25f, -0.75f, 0.50f, - -0.25f, -0.25f, 0.50f, - -0.75f, -0.25f, 0.50f, - 0.25f, -0.75f, 0.50f, // Quad #3 - 0.75f, -0.75f, 0.50f, - 0.75f, -0.25f, 0.50f, - 0.25f, -0.25f, 0.50f, - -1.00f, -1.00f, 0.00f, // Big Quad - 1.00f, -1.00f, 0.00f, - 1.00f, 1.00f, 0.00f, - -1.00f, 1.00f, 0.00f - }; - - GLubyte indices[][6] = { - { 0, 1, 2, 0, 2, 3 }, // Quad #0 - { 4, 5, 6, 4, 6, 7 }, // Quad #1 - { 8, 9, 10, 8, 10, 11 }, // Quad #2 - { 12, 13, 14, 12, 14, 15 }, // Quad #3 - { 16, 17, 18, 16, 18, 19 } // Big Quad - }; - -#define NumTests 4 - GLfloat colors[NumTests][4] = { - { 1.0f, 0.0f, 0.0f, 1.0f }, - { 0.0f, 1.0f, 0.0f, 1.0f }, - { 0.0f, 0.0f, 1.0f, 1.0f }, - { 1.0f, 1.0f, 0.0f, 0.0f } - }; - - GLint numStencilBits; - GLuint stencilValues[NumTests] = { - 0x7, // Result of test 0 - 0x0, // Result of test 1 - 0x2, // Result of test 2 - 0xff // Result of test 3. We need to fill this - // value in a run-time - }; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - // Clear the color, depth, and stencil buffers. At this - // point, the stencil buffer will be 0x1 for all pixels - glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex position - glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT, - GL_FALSE, 0, vVertices ); - - glEnableVertexAttribArray ( userData->positionLoc ); - - // Test 0: - // - // Initialize upper-left region. In this case, the - // stencil-buffer values will be replaced because the - // stencil test for the rendered pixels will fail the - // stencil test, which is - // - // ref mask stencil mask - // ( 0x7 & 0x3 ) < ( 0x1 & 0x7 ) - // - // The value in the stencil buffer for these pixels will - // be 0x7. - // - glStencilFunc( GL_LESS, 0x7, 0x3 ); - glStencilOp( GL_REPLACE, GL_DECR, GL_DECR ); - glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[0] ); - - // Test 1: - // - // Initialize the upper-right region. Here, we'll decrement - // the stencil-buffer values where the stencil test passes - // but the depth test fails. The stencil test is - // - // ref mask stencil mask - // ( 0x3 & 0x3 ) > ( 0x1 & 0x3 ) - // - // but where the geometry fails the depth test. The - // stencil values for these pixels will be 0x0. - // - glStencilFunc( GL_GREATER, 0x3, 0x3 ); - glStencilOp( GL_KEEP, GL_DECR, GL_KEEP ); - glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[1] ); - - // Test 2: - // - // Initialize the lower-left region. Here we'll increment - // (with saturation) the stencil value where both the - // stencil and depth tests pass. The stencil test for - // these pixels will be - // - // ref mask stencil mask - // ( 0x1 & 0x3 ) == ( 0x1 & 0x3 ) - // - // The stencil values for these pixels will be 0x2. - // - glStencilFunc( GL_EQUAL, 0x1, 0x3 ); - glStencilOp( GL_KEEP, GL_INCR, GL_INCR ); - glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[2] ); - - // Test 3: - // - // Finally, initialize the lower-right region. We'll invert - // the stencil value where the stencil tests fails. The - // stencil test for these pixels will be - // - // ref mask stencil mask - // ( 0x2 & 0x1 ) == ( 0x1 & 0x1 ) - // - // The stencil value here will be set to ~((2^s-1) & 0x1), - // (with the 0x1 being from the stencil clear value), - // where 's' is the number of bits in the stencil buffer - // - glStencilFunc( GL_EQUAL, 0x2, 0x1 ); - glStencilOp( GL_INVERT, GL_KEEP, GL_KEEP ); - glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[3] ); - - // Since we don't know at compile time how many stecil bits are present, - // we'll query, and update the value correct value in the - // stencilValues arrays for the fourth tests. We'll use this value - // later in rendering. - glGetIntegerv( GL_STENCIL_BITS, &numStencilBits ); - - stencilValues[3] = ~(((1 << numStencilBits) - 1) & 0x1) & 0xff; - - // Use the stencil buffer for controlling where rendering will - // occur. We diable writing to the stencil buffer so we - // can test against them without modifying the values we - // generated. - glStencilMask( 0x0 ); - - for ( i = 0; i < NumTests; ++i ) - { - glStencilFunc( GL_EQUAL, stencilValues[i], 0xff ); - glUniform4fv( userData->colorLoc, 1, colors[i] ); - glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[4] ); - } - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); -} - -/// -// Cleanup -// -void ShutDown ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Delete program object - glDeleteProgram ( userData->programObject ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("Stencil Test"), 320, 240, - ES_WINDOW_RGB | ES_WINDOW_DEPTH | ES_WINDOW_STENCIL ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/Stencil_Test/Stencil_Test.vcproj b/gfx/angle/samples/gles2_book/Stencil_Test/Stencil_Test.vcproj deleted file mode 100644 index dd3a2d962b85..000000000000 --- a/gfx/angle/samples/gles2_book/Stencil_Test/Stencil_Test.vcproj +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/gles2_book/TextureWrap/TextureWrap.c b/gfx/angle/samples/gles2_book/TextureWrap/TextureWrap.c deleted file mode 100644 index 3e958ddf41bc..000000000000 --- a/gfx/angle/samples/gles2_book/TextureWrap/TextureWrap.c +++ /dev/null @@ -1,254 +0,0 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -// TextureWrap.c -// -// This is an example that demonstrates the three texture -// wrap modes available on 2D textures -// -#include -#include "esUtil.h" - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint positionLoc; - GLint texCoordLoc; - - // Sampler location - GLint samplerLoc; - - // Offset location - GLint offsetLoc; - - // Texture handle - GLuint textureId; - -} UserData; - -/// -// Generate an RGB8 checkerboard image -// -GLubyte* GenCheckImage( int width, int height, int checkSize ) -{ - int x, - y; - GLubyte *pixels = malloc( width * height * 3 ); - - if ( pixels == NULL ) - return NULL; - - for ( y = 0; y < height; y++ ) - for ( x = 0; x < width; x++ ) - { - GLubyte rColor = 0; - GLubyte bColor = 0; - - if ( ( x / checkSize ) % 2 == 0 ) - { - rColor = 255 * ( ( y / checkSize ) % 2 ); - bColor = 255 * ( 1 - ( ( y / checkSize ) % 2 ) ); - } - else - { - bColor = 255 * ( ( y / checkSize ) % 2 ); - rColor = 255 * ( 1 - ( ( y / checkSize ) % 2 ) ); - } - - pixels[(y * height + x) * 3] = rColor; - pixels[(y * height + x) * 3 + 1] = 0; - pixels[(y * height + x) * 3 + 2] = bColor; - } - - return pixels; -} - -/// -// Create a mipmapped 2D texture image -// -GLuint CreateTexture2D( ) -{ - // Texture object handle - GLuint textureId; - int width = 256, - height = 256; - GLubyte *pixels; - - pixels = GenCheckImage( width, height, 64 ); - if ( pixels == NULL ) - return 0; - - // Generate a texture object - glGenTextures ( 1, &textureId ); - - // Bind the texture object - glBindTexture ( GL_TEXTURE_2D, textureId ); - - // Load mipmap level 0 - glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, width, height, - 0, GL_RGB, GL_UNSIGNED_BYTE, pixels ); - - // Set the filtering mode - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - - return textureId; - -} - - -/// -// Initialize the shader and program object -// -int Init ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLbyte vShaderStr[] = - "uniform float u_offset; \n" - "attribute vec4 a_position; \n" - "attribute vec2 a_texCoord; \n" - "varying vec2 v_texCoord; \n" - "void main() \n" - "{ \n" - " gl_Position = a_position; \n" - " gl_Position.x += u_offset;\n" - " v_texCoord = a_texCoord; \n" - "} \n"; - - GLbyte fShaderStr[] = - "precision mediump float; \n" - "varying vec2 v_texCoord; \n" - "uniform sampler2D s_texture; \n" - "void main() \n" - "{ \n" - " gl_FragColor = texture2D( s_texture, v_texCoord );\n" - "} \n"; - - // Load the shaders and get a linked program object - userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); - - // Get the attribute locations - userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" ); - userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" ); - - // Get the sampler location - userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" ); - - // Get the offset location - userData->offsetLoc = glGetUniformLocation( userData->programObject, "u_offset" ); - - // Load the texture - userData->textureId = CreateTexture2D (); - - glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); - return TRUE; -} - -/// -// Draw a triangle using the shader pair created in Init() -// -void Draw ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - GLfloat vVertices[] = { -0.3f, 0.3f, 0.0f, 1.0f, // Position 0 - -1.0f, -1.0f, // TexCoord 0 - -0.3f, -0.3f, 0.0f, 1.0f, // Position 1 - -1.0f, 2.0f, // TexCoord 1 - 0.3f, -0.3f, 0.0f, 1.0f, // Position 2 - 2.0f, 2.0f, // TexCoord 2 - 0.3f, 0.3f, 0.0f, 1.0f, // Position 3 - 2.0f, -1.0f // TexCoord 3 - }; - GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; - - // Set the viewport - glViewport ( 0, 0, esContext->width, esContext->height ); - - // Clear the color buffer - glClear ( GL_COLOR_BUFFER_BIT ); - - // Use the program object - glUseProgram ( userData->programObject ); - - // Load the vertex position - glVertexAttribPointer ( userData->positionLoc, 4, GL_FLOAT, - GL_FALSE, 6 * sizeof(GLfloat), vVertices ); - // Load the texture coordinate - glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT, - GL_FALSE, 6 * sizeof(GLfloat), &vVertices[4] ); - - glEnableVertexAttribArray ( userData->positionLoc ); - glEnableVertexAttribArray ( userData->texCoordLoc ); - - // Bind the texture - glActiveTexture ( GL_TEXTURE0 ); - glBindTexture ( GL_TEXTURE_2D, userData->textureId ); - - // Set the sampler texture unit to 0 - glUniform1i ( userData->samplerLoc, 0 ); - - // Draw quad with repeat wrap mode - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); - glUniform1f ( userData->offsetLoc, -0.7f ); - glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices ); - - // Draw quad with clamp to edge wrap mode - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - glUniform1f ( userData->offsetLoc, 0.0f ); - glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices ); - - // Draw quad with mirrored repeat - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT ); - glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT ); - glUniform1f ( userData->offsetLoc, 0.7f ); - glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices ); - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); -} - -/// -// Cleanup -// -void ShutDown ( ESContext *esContext ) -{ - UserData *userData = esContext->userData; - - // Delete texture object - glDeleteTextures ( 1, &userData->textureId ); - - // Delete program object - glDeleteProgram ( userData->programObject ); -} - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, TEXT("Texture Wrap"), 640, 480, ES_WINDOW_RGB ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/gfx/angle/samples/gles2_book/TextureWrap/TextureWrap.vcproj b/gfx/angle/samples/gles2_book/TextureWrap/TextureWrap.vcproj deleted file mode 100644 index e0dc01aa88c8..000000000000 --- a/gfx/angle/samples/gles2_book/TextureWrap/TextureWrap.vcproj +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/samples.sln b/gfx/angle/samples/samples.sln deleted file mode 100644 index f7216a5f6781..000000000000 --- a/gfx/angle/samples/samples.sln +++ /dev/null @@ -1,210 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "esUtil", "gles2_book\Common\esUtil.vcproj", "{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}" - ProjectSection(ProjectDependencies) = postProject - {B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78} - {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6} = {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hello_Triangle", "gles2_book\Hello_Triangle\Hello_Triangle.vcproj", "{8278251F-6C1F-4D80-8499-FA7B590FAFE6}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MipMap2D", "gles2_book\MipMap2D\MipMap2D.vcproj", "{4E69AC1F-1C7A-4D58-917C-E764FBEB489A}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MultiTexture", "gles2_book\MultiTexture\MultiTexture.vcproj", "{120CFF94-ED4B-4C5B-9587-9E40889F15F7}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ParticleSystem", "gles2_book\ParticleSystem\ParticleSystem.vcproj", "{B9E5BFFC-D843-4E0E-9D3E-23913A613473}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple_Texture2D", "gles2_book\Simple_Texture2D\Simple_Texture2D.vcproj", "{2E54D748-781B-4DF2-A1DD-B9384A821810}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple_TextureCubemap", "gles2_book\Simple_TextureCubemap\Simple_TextureCubemap.vcproj", "{5EE56061-643D-406E-B42D-4299D2411056}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple_VertexShader", "gles2_book\Simple_VertexShader\Simple_VertexShader.vcproj", "{667CE95F-5DD8-4395-8C18-5CA8A175B12D}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Stencil_Test", "gles2_book\Stencil_Test\Stencil_Test.vcproj", "{EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextureWrap", "gles2_book\TextureWrap\TextureWrap.vcproj", "{CC1DE9A2-B456-4565-9C21-932253E969B9}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEGL", "..\src\libEGL\libEGL.vcproj", "{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}" - ProjectSection(ProjectDependencies) = postProject - {B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "..\src\libGLESv2\libGLESv2.vcproj", "{B5871A7A-968C-42E3-A33B-981E6F448E78}" - ProjectSection(ProjectDependencies) = postProject - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "..\src\compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}" - ProjectSection(ProjectDependencies) = postProject - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "essl_to_hlsl", "translator\essl_to_hlsl.vcproj", "{E12EA115-EBC7-47C2-B651-30A0CE986025}" - ProjectSection(ProjectDependencies) = postProject - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_common", "..\src\compiler\translator_common.vcproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}" - ProjectSection(ProjectDependencies) = postProject - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325} = {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PostSubBuffer", "gles2_book\PostSubBuffer\PostSubBuffer.vcproj", "{667CE95F-5DD8-4495-8C18-5CA8A175B12D}" - ProjectSection(ProjectDependencies) = postProject - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preprocessor", "..\src\compiler\preprocessor\new\preprocessor.vcproj", "{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Debug|Win32.ActiveCfg = Debug|Win32 - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Debug|Win32.Build.0 = Debug|Win32 - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Debug|x64.ActiveCfg = Debug|Win32 - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Release|Win32.ActiveCfg = Release|Win32 - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Release|Win32.Build.0 = Release|Win32 - {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Release|x64.ActiveCfg = Release|Win32 - {8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Debug|Win32.ActiveCfg = Debug|Win32 - {8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Debug|Win32.Build.0 = Debug|Win32 - {8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Debug|x64.ActiveCfg = Debug|Win32 - {8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Release|Win32.ActiveCfg = Release|Win32 - {8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Release|Win32.Build.0 = Release|Win32 - {8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Release|x64.ActiveCfg = Release|Win32 - {4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Debug|Win32.ActiveCfg = Debug|Win32 - {4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Debug|Win32.Build.0 = Debug|Win32 - {4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Debug|x64.ActiveCfg = Debug|Win32 - {4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Release|Win32.ActiveCfg = Release|Win32 - {4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Release|Win32.Build.0 = Release|Win32 - {4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Release|x64.ActiveCfg = Release|Win32 - {120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Debug|Win32.ActiveCfg = Debug|Win32 - {120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Debug|Win32.Build.0 = Debug|Win32 - {120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Debug|x64.ActiveCfg = Debug|Win32 - {120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Release|Win32.ActiveCfg = Release|Win32 - {120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Release|Win32.Build.0 = Release|Win32 - {120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Release|x64.ActiveCfg = Release|Win32 - {B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Debug|Win32.ActiveCfg = Debug|Win32 - {B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Debug|Win32.Build.0 = Debug|Win32 - {B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Debug|x64.ActiveCfg = Debug|Win32 - {B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Release|Win32.ActiveCfg = Release|Win32 - {B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Release|Win32.Build.0 = Release|Win32 - {B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Release|x64.ActiveCfg = Release|Win32 - {2E54D748-781B-4DF2-A1DD-B9384A821810}.Debug|Win32.ActiveCfg = Debug|Win32 - {2E54D748-781B-4DF2-A1DD-B9384A821810}.Debug|Win32.Build.0 = Debug|Win32 - {2E54D748-781B-4DF2-A1DD-B9384A821810}.Debug|x64.ActiveCfg = Debug|Win32 - {2E54D748-781B-4DF2-A1DD-B9384A821810}.Release|Win32.ActiveCfg = Release|Win32 - {2E54D748-781B-4DF2-A1DD-B9384A821810}.Release|Win32.Build.0 = Release|Win32 - {2E54D748-781B-4DF2-A1DD-B9384A821810}.Release|x64.ActiveCfg = Release|Win32 - {5EE56061-643D-406E-B42D-4299D2411056}.Debug|Win32.ActiveCfg = Debug|Win32 - {5EE56061-643D-406E-B42D-4299D2411056}.Debug|Win32.Build.0 = Debug|Win32 - {5EE56061-643D-406E-B42D-4299D2411056}.Debug|x64.ActiveCfg = Debug|Win32 - {5EE56061-643D-406E-B42D-4299D2411056}.Release|Win32.ActiveCfg = Release|Win32 - {5EE56061-643D-406E-B42D-4299D2411056}.Release|Win32.Build.0 = Release|Win32 - {5EE56061-643D-406E-B42D-4299D2411056}.Release|x64.ActiveCfg = Release|Win32 - {667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Debug|Win32.ActiveCfg = Debug|Win32 - {667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Debug|Win32.Build.0 = Debug|Win32 - {667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Debug|x64.ActiveCfg = Debug|Win32 - {667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Release|Win32.ActiveCfg = Release|Win32 - {667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Release|Win32.Build.0 = Release|Win32 - {667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Release|x64.ActiveCfg = Release|Win32 - {EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Debug|Win32.ActiveCfg = Debug|Win32 - {EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Debug|Win32.Build.0 = Debug|Win32 - {EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Debug|x64.ActiveCfg = Debug|Win32 - {EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Release|Win32.ActiveCfg = Release|Win32 - {EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Release|Win32.Build.0 = Release|Win32 - {EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Release|x64.ActiveCfg = Release|Win32 - {CC1DE9A2-B456-4565-9C21-932253E969B9}.Debug|Win32.ActiveCfg = Debug|Win32 - {CC1DE9A2-B456-4565-9C21-932253E969B9}.Debug|Win32.Build.0 = Debug|Win32 - {CC1DE9A2-B456-4565-9C21-932253E969B9}.Debug|x64.ActiveCfg = Debug|Win32 - {CC1DE9A2-B456-4565-9C21-932253E969B9}.Release|Win32.ActiveCfg = Release|Win32 - {CC1DE9A2-B456-4565-9C21-932253E969B9}.Release|Win32.Build.0 = Release|Win32 - {CC1DE9A2-B456-4565-9C21-932253E969B9}.Release|x64.ActiveCfg = Release|Win32 - {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.ActiveCfg = Debug|Win32 - {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.Build.0 = Debug|Win32 - {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.ActiveCfg = Debug|x64 - {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.Build.0 = Debug|x64 - {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.ActiveCfg = Release|Win32 - {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.Build.0 = Release|Win32 - {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.ActiveCfg = Release|x64 - {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.Build.0 = Release|x64 - {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.ActiveCfg = Debug|Win32 - {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32 - {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.ActiveCfg = Debug|x64 - {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.Build.0 = Debug|x64 - {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32 - {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32 - {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.ActiveCfg = Release|x64 - {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.Build.0 = Release|x64 - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32 - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32 - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.ActiveCfg = Debug|x64 - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.Build.0 = Debug|x64 - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32 - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.Build.0 = Release|Win32 - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.ActiveCfg = Release|x64 - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.Build.0 = Release|x64 - {E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.ActiveCfg = Debug|Win32 - {E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.Build.0 = Debug|Win32 - {E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|x64.ActiveCfg = Debug|Win32 - {E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|Win32.ActiveCfg = Release|Win32 - {E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|Win32.Build.0 = Release|Win32 - {E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|x64.ActiveCfg = Release|Win32 - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.ActiveCfg = Debug|Win32 - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.Build.0 = Debug|Win32 - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.ActiveCfg = Debug|x64 - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.Build.0 = Debug|x64 - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.ActiveCfg = Release|Win32 - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.Build.0 = Release|Win32 - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.ActiveCfg = Release|x64 - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.Build.0 = Release|x64 - {667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Debug|Win32.ActiveCfg = Debug|Win32 - {667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Debug|Win32.Build.0 = Debug|Win32 - {667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Debug|x64.ActiveCfg = Debug|Win32 - {667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Release|Win32.ActiveCfg = Release|Win32 - {667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Release|Win32.Build.0 = Release|Win32 - {667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Release|x64.ActiveCfg = Release|Win32 - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|Win32.ActiveCfg = Debug|Win32 - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|Win32.Build.0 = Debug|Win32 - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|x64.ActiveCfg = Debug|x64 - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|x64.Build.0 = Debug|x64 - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|Win32.ActiveCfg = Release|Win32 - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|Win32.Build.0 = Release|Win32 - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|x64.ActiveCfg = Release|x64 - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/gfx/angle/samples/translator/essl_to_glsl.vcproj b/gfx/angle/samples/translator/essl_to_glsl.vcproj deleted file mode 100644 index 0a0c09779ba3..000000000000 --- a/gfx/angle/samples/translator/essl_to_glsl.vcproj +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/translator/essl_to_hlsl.vcproj b/gfx/angle/samples/translator/essl_to_hlsl.vcproj deleted file mode 100644 index eaa8070385f3..000000000000 --- a/gfx/angle/samples/translator/essl_to_hlsl.vcproj +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/samples/translator/translator.cpp b/gfx/angle/samples/translator/translator.cpp deleted file mode 100644 index 6766bf16ca7a..000000000000 --- a/gfx/angle/samples/translator/translator.cpp +++ /dev/null @@ -1,376 +0,0 @@ -// -// Copyright (c) 2002-2010 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 "GLSLANG/ShaderLang.h" - -#include -#include -#include -#include -#include -#include - -// -// Return codes from main. -// -enum TFailCode { - ESuccess = 0, - EFailUsage, - EFailCompile, - EFailCompilerCreate, -}; - -static void usage(); -static ShShaderType FindShaderType(const char* fileName); -static bool CompileFile(char* fileName, ShHandle compiler, int compileOptions); -static void LogMsg(const char* msg, const char* name, const int num, const char* logName); -static void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType, bool mapLongVariableNames); - -// If NUM_SOURCE_STRINGS is set to a value > 1, the input file data is -// broken into that many chunks. -const unsigned int NUM_SOURCE_STRINGS = 2; -typedef std::vector ShaderSource; -static bool ReadShaderSource(const char* fileName, ShaderSource& source); -static void FreeShaderSource(ShaderSource& source); - -// -// Set up the per compile resources -// -void GenerateResources(ShBuiltInResources* resources) -{ - ShInitBuiltInResources(resources); - - resources->MaxVertexAttribs = 8; - resources->MaxVertexUniformVectors = 128; - resources->MaxVaryingVectors = 8; - resources->MaxVertexTextureImageUnits = 0; - resources->MaxCombinedTextureImageUnits = 8; - resources->MaxTextureImageUnits = 8; - resources->MaxFragmentUniformVectors = 16; - resources->MaxDrawBuffers = 1; - - resources->OES_standard_derivatives = 0; - resources->OES_EGL_image_external = 0; -} - -int main(int argc, char* argv[]) -{ - TFailCode failCode = ESuccess; - - int compileOptions = 0; - int numCompiles = 0; - ShHandle vertexCompiler = 0; - ShHandle fragmentCompiler = 0; - char* buffer = 0; - int bufferLen = 0; - int numAttribs = 0, numUniforms = 0; - ShShaderSpec spec = SH_GLES2_SPEC; - ShShaderOutput output = SH_ESSL_OUTPUT; - - ShInitialize(); - - ShBuiltInResources resources; - GenerateResources(&resources); - - argc--; - argv++; - for (; (argc >= 1) && (failCode == ESuccess); argc--, argv++) { - if (argv[0][0] == '-') { - switch (argv[0][1]) { - case 'i': compileOptions |= SH_INTERMEDIATE_TREE; break; - case 'm': compileOptions |= SH_MAP_LONG_VARIABLE_NAMES; break; - case 'o': compileOptions |= SH_OBJECT_CODE; break; - case 'u': compileOptions |= SH_ATTRIBUTES_UNIFORMS; break; - case 'l': compileOptions |= SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX; break; - case 'e': compileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS; break; - case 'd': compileOptions |= SH_DEPENDENCY_GRAPH; break; - case 't': compileOptions |= SH_TIMING_RESTRICTIONS; break; - case 's': - if (argv[0][2] == '=') { - switch (argv[0][3]) { - case 'e': spec = SH_GLES2_SPEC; break; - case 'w': spec = SH_WEBGL_SPEC; break; - case 'c': spec = SH_CSS_SHADERS_SPEC; break; - default: failCode = EFailUsage; - } - } else { - failCode = EFailUsage; - } - break; - case 'b': - if (argv[0][2] == '=') { - switch (argv[0][3]) { - case 'e': output = SH_ESSL_OUTPUT; break; - case 'g': output = SH_GLSL_OUTPUT; break; - case 'h': output = SH_HLSL_OUTPUT; break; - default: failCode = EFailUsage; - } - } else { - failCode = EFailUsage; - } - break; - case 'x': - if (argv[0][2] == '=') { - switch (argv[0][3]) { - case 'i': resources.OES_EGL_image_external = 1; break; - case 'd': resources.OES_standard_derivatives = 1; break; - case 'r': resources.ARB_texture_rectangle = 1; break; - default: failCode = EFailUsage; - } - } else { - failCode = EFailUsage; - } - break; - default: failCode = EFailUsage; - } - } else { - ShHandle compiler = 0; - switch (FindShaderType(argv[0])) { - case SH_VERTEX_SHADER: - if (vertexCompiler == 0) - vertexCompiler = ShConstructCompiler( - SH_VERTEX_SHADER, spec, output, &resources); - compiler = vertexCompiler; - break; - case SH_FRAGMENT_SHADER: - if (fragmentCompiler == 0) - fragmentCompiler = ShConstructCompiler( - SH_FRAGMENT_SHADER, spec, output, &resources); - compiler = fragmentCompiler; - break; - default: break; - } - if (compiler) { - bool compiled = CompileFile(argv[0], compiler, compileOptions); - - LogMsg("BEGIN", "COMPILER", numCompiles, "INFO LOG"); - ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &bufferLen); - buffer = (char*) realloc(buffer, bufferLen * sizeof(char)); - ShGetInfoLog(compiler, buffer); - puts(buffer); - LogMsg("END", "COMPILER", numCompiles, "INFO LOG"); - printf("\n\n"); - - if (compiled && (compileOptions & SH_OBJECT_CODE)) { - LogMsg("BEGIN", "COMPILER", numCompiles, "OBJ CODE"); - ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &bufferLen); - buffer = (char*) realloc(buffer, bufferLen * sizeof(char)); - ShGetObjectCode(compiler, buffer); - puts(buffer); - LogMsg("END", "COMPILER", numCompiles, "OBJ CODE"); - printf("\n\n"); - } - if (compiled && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) { - LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE ATTRIBS"); - PrintActiveVariables(compiler, SH_ACTIVE_ATTRIBUTES, (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) != 0); - LogMsg("END", "COMPILER", numCompiles, "ACTIVE ATTRIBS"); - printf("\n\n"); - - LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE UNIFORMS"); - PrintActiveVariables(compiler, SH_ACTIVE_UNIFORMS, (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) != 0); - LogMsg("END", "COMPILER", numCompiles, "ACTIVE UNIFORMS"); - printf("\n\n"); - } - if (!compiled) - failCode = EFailCompile; - ++numCompiles; - } else { - failCode = EFailCompilerCreate; - } - } - } - - if ((vertexCompiler == 0) && (fragmentCompiler == 0)) - failCode = EFailUsage; - if (failCode == EFailUsage) - usage(); - - if (vertexCompiler) - ShDestruct(vertexCompiler); - if (fragmentCompiler) - ShDestruct(fragmentCompiler); - if (buffer) - free(buffer); - ShFinalize(); - - return failCode; -} - -// -// print usage to stdout -// -void usage() -{ - printf("Usage: translate [-i -m -o -u -l -e -b=e -b=g -b=h -x=i -x=d] file1 file2 ...\n" - "Where: filename : filename ending in .frag or .vert\n" - " -i : print intermediate tree\n" - " -m : map long variable names\n" - " -o : print translated code\n" - " -u : print active attribs and uniforms\n" - " -l : unroll for-loops with integer indices\n" - " -e : emulate certain built-in functions (workaround for driver bugs)\n" - " -t : enforce experimental timing restrictions\n" - " -d : print dependency graph used to enforce timing restrictions\n" - " -s=e : use GLES2 spec (this is by default)\n" - " -s=w : use WebGL spec\n" - " -s=c : use CSS Shaders spec\n" - " -b=e : output GLSL ES code (this is by default)\n" - " -b=g : output GLSL code\n" - " -b=h : output HLSL code\n" - " -x=i : enable GL_OES_EGL_image_external\n" - " -x=d : enable GL_OES_EGL_standard_derivatives\n" - " -x=r : enable ARB_texture_rectangle\n"); -} - -// -// Deduce the shader type from the filename. Files must end in one of the -// following extensions: -// -// .frag* = fragment shader -// .vert* = vertex shader -// -ShShaderType FindShaderType(const char* fileName) -{ - assert(fileName); - - const char* ext = strrchr(fileName, '.'); - - if (ext && strcmp(ext, ".sl") == 0) - for (; ext > fileName && ext[0] != '.'; ext--); - - ext = strrchr(fileName, '.'); - if (ext) { - if (strncmp(ext, ".frag", 4) == 0) return SH_FRAGMENT_SHADER; - if (strncmp(ext, ".vert", 4) == 0) return SH_VERTEX_SHADER; - } - - return SH_FRAGMENT_SHADER; -} - -// -// Read a file's data into a string, and compile it using ShCompile -// -bool CompileFile(char* fileName, ShHandle compiler, int compileOptions) -{ - ShaderSource source; - if (!ReadShaderSource(fileName, source)) - return false; - - int ret = ShCompile(compiler, &source[0], source.size(), compileOptions); - - FreeShaderSource(source); - return ret ? true : false; -} - -void LogMsg(const char* msg, const char* name, const int num, const char* logName) -{ - printf("#### %s %s %d %s ####\n", msg, name, num, logName); -} - -void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType, bool mapLongVariableNames) -{ - int nameSize = 0; - switch (varType) { - case SH_ACTIVE_ATTRIBUTES: - ShGetInfo(compiler, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &nameSize); - break; - case SH_ACTIVE_UNIFORMS: - ShGetInfo(compiler, SH_ACTIVE_UNIFORM_MAX_LENGTH, &nameSize); - break; - default: assert(0); - } - if (nameSize <= 1) return; - char* name = new char[nameSize]; - - char* mappedName = NULL; - if (mapLongVariableNames) { - int mappedNameSize = 0; - ShGetInfo(compiler, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameSize); - mappedName = new char[mappedNameSize]; - } - - int activeVars = 0, size = 0; - ShDataType type = SH_NONE; - const char* typeName = NULL; - ShGetInfo(compiler, varType, &activeVars); - for (int i = 0; i < activeVars; ++i) { - switch (varType) { - case SH_ACTIVE_ATTRIBUTES: - ShGetActiveAttrib(compiler, i, NULL, &size, &type, name, mappedName); - break; - case SH_ACTIVE_UNIFORMS: - ShGetActiveUniform(compiler, i, NULL, &size, &type, name, mappedName); - break; - default: assert(0); - } - switch (type) { - case SH_FLOAT: typeName = "GL_FLOAT"; break; - case SH_FLOAT_VEC2: typeName = "GL_FLOAT_VEC2"; break; - case SH_FLOAT_VEC3: typeName = "GL_FLOAT_VEC3"; break; - case SH_FLOAT_VEC4: typeName = "GL_FLOAT_VEC4"; break; - case SH_INT: typeName = "GL_INT"; break; - case SH_INT_VEC2: typeName = "GL_INT_VEC2"; break; - case SH_INT_VEC3: typeName = "GL_INT_VEC3"; break; - case SH_INT_VEC4: typeName = "GL_INT_VEC4"; break; - case SH_BOOL: typeName = "GL_BOOL"; break; - case SH_BOOL_VEC2: typeName = "GL_BOOL_VEC2"; break; - case SH_BOOL_VEC3: typeName = "GL_BOOL_VEC3"; break; - case SH_BOOL_VEC4: typeName = "GL_BOOL_VEC4"; break; - case SH_FLOAT_MAT2: typeName = "GL_FLOAT_MAT2"; break; - case SH_FLOAT_MAT3: typeName = "GL_FLOAT_MAT3"; break; - case SH_FLOAT_MAT4: typeName = "GL_FLOAT_MAT4"; break; - case SH_SAMPLER_2D: typeName = "GL_SAMPLER_2D"; break; - case SH_SAMPLER_CUBE: typeName = "GL_SAMPLER_CUBE"; break; - case SH_SAMPLER_EXTERNAL_OES: typeName = "GL_SAMPLER_EXTERNAL_OES"; break; - default: assert(0); - } - printf("%d: name:%s type:%s size:%d", i, name, typeName, size); - if (mapLongVariableNames) - printf(" mapped name:%s", mappedName); - printf("\n"); - } - delete [] name; - if (mappedName) - delete [] mappedName; -} - -static bool ReadShaderSource(const char* fileName, ShaderSource& source) { - FILE* in = fopen(fileName, "rb"); - if (!in) { - printf("Error: unable to open input file: %s\n", fileName); - return false; - } - - // Obtain file size. - fseek(in, 0, SEEK_END); - int count = ftell(in); - rewind(in); - - int len = (int)ceil((float)count / (float)NUM_SOURCE_STRINGS); - source.reserve(NUM_SOURCE_STRINGS); - // Notice the usage of do-while instead of a while loop here. - // It is there to handle empty files in which case a single empty - // string is added to vector. - do { - char* data = new char[len + 1]; - int nread = fread(data, 1, len, in); - data[nread] = '\0'; - source.push_back(data); - - count -= nread; - } while (count > 0); - - fclose(in); - return true; -} - -static void FreeShaderSource(ShaderSource& source) { - for (ShaderSource::size_type i = 0; i < source.size(); ++i) { - delete [] source[i]; - } - source.clear(); -} - diff --git a/gfx/angle/src/ANGLE.sln b/gfx/angle/src/ANGLE.sln index 084d97f40aef..81c1382fc088 100644 --- a/gfx/angle/src/ANGLE.sln +++ b/gfx/angle/src/ANGLE.sln @@ -1,27 +1,15 @@  -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEGL", "libEGL\libEGL.vcproj", "{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}" - ProjectSection(ProjectDependencies) = postProject - {B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78} - EndProjectSection +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEGL", "libEGL\libEGL.vcxproj", "{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "libGLESv2\libGLESv2.vcproj", "{B5871A7A-968C-42E3-A33B-981E6F448E78}" - ProjectSection(ProjectDependencies) = postProject - {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "libGLESv2\libGLESv2.vcxproj", "{B5871A7A-968C-42E3-A33B-981E6F448E78}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}" - ProjectSection(ProjectDependencies) = postProject - {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "compiler\translator_hlsl.vcxproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_common", "compiler\translator_common.vcproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}" - ProjectSection(ProjectDependencies) = postProject - {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325} = {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_common", "compiler\translator_common.vcxproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preprocessor", "compiler\preprocessor\new\preprocessor.vcproj", "{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preprocessor", "compiler\preprocessor\preprocessor.vcxproj", "{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/gfx/angle/src/build_angle.gyp b/gfx/angle/src/build_angle.gyp index aa7fbc659b07..6adf1423ae71 100644 --- a/gfx/angle/src/build_angle.gyp +++ b/gfx/angle/src/build_angle.gyp @@ -3,332 +3,8 @@ # found in the LICENSE file. { - 'variables': { - 'angle_code': 1, - }, - 'target_defaults': { - 'defines': [ - 'ANGLE_DISABLE_TRACE', - 'ANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL0', - 'ANGLE_USE_NEW_PREPROCESSOR=1', - ], - }, - 'targets': [ - { - 'target_name': 'preprocessor', - 'type': 'static_library', - 'include_dirs': [ - ], - 'sources': [ - 'compiler/preprocessor/new/Diagnostics.cpp', - 'compiler/preprocessor/new/Diagnostics.h', - 'compiler/preprocessor/new/DirectiveHandler.cpp', - 'compiler/preprocessor/new/DirectiveHandler.h', - 'compiler/preprocessor/new/DirectiveParser.cpp', - 'compiler/preprocessor/new/DirectiveParser.h', - 'compiler/preprocessor/new/ExpressionParser.cpp', - 'compiler/preprocessor/new/ExpressionParser.h', - 'compiler/preprocessor/new/Input.cpp', - 'compiler/preprocessor/new/Input.h', - 'compiler/preprocessor/new/Lexer.cpp', - 'compiler/preprocessor/new/Lexer.h', - 'compiler/preprocessor/new/Macro.cpp', - 'compiler/preprocessor/new/Macro.h', - 'compiler/preprocessor/new/MacroExpander.cpp', - 'compiler/preprocessor/new/MacroExpander.h', - 'compiler/preprocessor/new/numeric_lex.h', - 'compiler/preprocessor/new/pp_utils.h', - 'compiler/preprocessor/new/Preprocessor.cpp', - 'compiler/preprocessor/new/Preprocessor.h', - 'compiler/preprocessor/new/SourceLocation.h', - 'compiler/preprocessor/new/Token.cpp', - 'compiler/preprocessor/new/Token.h', - 'compiler/preprocessor/new/Tokenizer.cpp', - 'compiler/preprocessor/new/Tokenizer.h', - ], - }, - { - 'target_name': 'translator_common', - 'type': 'static_library', - 'dependencies': ['preprocessor'], - 'include_dirs': [ - '.', - '../include', - ], - 'defines': [ - 'COMPILER_IMPLEMENTATION', - ], - 'sources': [ - 'compiler/BaseTypes.h', - 'compiler/BuiltInFunctionEmulator.cpp', - 'compiler/BuiltInFunctionEmulator.h', - 'compiler/Common.h', - 'compiler/Compiler.cpp', - 'compiler/ConstantUnion.h', - 'compiler/debug.cpp', - 'compiler/debug.h', - 'compiler/DetectRecursion.cpp', - 'compiler/DetectRecursion.h', - 'compiler/Diagnostics.h', - 'compiler/Diagnostics.cpp', - 'compiler/DirectiveHandler.h', - 'compiler/DirectiveHandler.cpp', - 'compiler/ExtensionBehavior.h', - 'compiler/ForLoopUnroll.cpp', - 'compiler/ForLoopUnroll.h', - 'compiler/glslang.h', - 'compiler/glslang_lex.cpp', - 'compiler/glslang_tab.cpp', - 'compiler/glslang_tab.h', - 'compiler/InfoSink.cpp', - 'compiler/InfoSink.h', - 'compiler/Initialize.cpp', - 'compiler/Initialize.h', - 'compiler/InitializeDll.cpp', - 'compiler/InitializeDll.h', - 'compiler/InitializeGlobals.h', - 'compiler/InitializeParseContext.cpp', - 'compiler/InitializeParseContext.h', - 'compiler/Intermediate.cpp', - 'compiler/intermediate.h', - 'compiler/intermOut.cpp', - 'compiler/IntermTraverse.cpp', - 'compiler/localintermediate.h', - 'compiler/MapLongVariableNames.cpp', - 'compiler/MapLongVariableNames.h', - 'compiler/MMap.h', - 'compiler/osinclude.h', - 'compiler/parseConst.cpp', - 'compiler/ParseHelper.cpp', - 'compiler/ParseHelper.h', - 'compiler/PoolAlloc.cpp', - 'compiler/PoolAlloc.h', - 'compiler/QualifierAlive.cpp', - 'compiler/QualifierAlive.h', - 'compiler/RemoveTree.cpp', - 'compiler/RemoveTree.h', - 'compiler/RenameFunction.h', - 'compiler/ShHandle.h', - 'compiler/SymbolTable.cpp', - 'compiler/SymbolTable.h', - 'compiler/Types.h', - 'compiler/util.cpp', - 'compiler/util.h', - 'compiler/ValidateLimitations.cpp', - 'compiler/ValidateLimitations.h', - 'compiler/VariableInfo.cpp', - 'compiler/VariableInfo.h', - # Old preprocessor - 'compiler/preprocessor/atom.c', - 'compiler/preprocessor/atom.h', - 'compiler/preprocessor/compile.h', - 'compiler/preprocessor/cpp.c', - 'compiler/preprocessor/cpp.h', - 'compiler/preprocessor/cppstruct.c', - 'compiler/preprocessor/length_limits.h', - 'compiler/preprocessor/memory.c', - 'compiler/preprocessor/memory.h', - 'compiler/preprocessor/parser.h', - 'compiler/preprocessor/preprocess.h', - 'compiler/preprocessor/scanner.c', - 'compiler/preprocessor/scanner.h', - 'compiler/preprocessor/slglobals.h', - 'compiler/preprocessor/symbols.c', - 'compiler/preprocessor/symbols.h', - 'compiler/preprocessor/tokens.c', - 'compiler/preprocessor/tokens.h', - # Dependency graph - 'compiler/depgraph/DependencyGraph.cpp', - 'compiler/depgraph/DependencyGraph.h', - 'compiler/depgraph/DependencyGraphBuilder.cpp', - 'compiler/depgraph/DependencyGraphBuilder.h', - 'compiler/depgraph/DependencyGraphOutput.cpp', - 'compiler/depgraph/DependencyGraphOutput.h', - 'compiler/depgraph/DependencyGraphTraverse.cpp', - # Timing restrictions - 'compiler/timing/RestrictFragmentShaderTiming.cpp', - 'compiler/timing/RestrictFragmentShaderTiming.h', - 'compiler/timing/RestrictVertexShaderTiming.cpp', - 'compiler/timing/RestrictVertexShaderTiming.h', - ], - 'conditions': [ - ['OS=="win"', { - 'sources': ['compiler/ossource_win.cpp'], - }, { # else: posix - 'sources': ['compiler/ossource_posix.cpp'], - }], - ], - }, - { - 'target_name': 'translator_glsl', - 'type': '<(component)', - 'dependencies': ['translator_common'], - 'include_dirs': [ - '.', - '../include', - ], - 'defines': [ - 'COMPILER_IMPLEMENTATION', - ], - 'sources': [ - 'compiler/CodeGenGLSL.cpp', - 'compiler/OutputESSL.cpp', - 'compiler/OutputESSL.h', - 'compiler/OutputGLSLBase.cpp', - 'compiler/OutputGLSLBase.h', - 'compiler/OutputGLSL.cpp', - 'compiler/OutputGLSL.h', - 'compiler/ShaderLang.cpp', - 'compiler/TranslatorESSL.cpp', - 'compiler/TranslatorESSL.h', - 'compiler/TranslatorGLSL.cpp', - 'compiler/TranslatorGLSL.h', - 'compiler/VersionGLSL.cpp', - 'compiler/VersionGLSL.h', - ], - }, - ], - 'conditions': [ - ['OS=="win"', { - 'targets': [ - { - 'target_name': 'translator_hlsl', - 'type': '<(component)', - 'dependencies': ['translator_common'], - 'include_dirs': [ - '.', - '../include', - ], - 'defines': [ - 'COMPILER_IMPLEMENTATION', - ], - 'sources': [ - 'compiler/ShaderLang.cpp', - 'compiler/DetectDiscontinuity.cpp', - 'compiler/DetectDiscontinuity.h', - 'compiler/CodeGenHLSL.cpp', - 'compiler/OutputHLSL.cpp', - 'compiler/OutputHLSL.h', - 'compiler/TranslatorHLSL.cpp', - 'compiler/TranslatorHLSL.h', - 'compiler/UnfoldShortCircuit.cpp', - 'compiler/UnfoldShortCircuit.h', - 'compiler/SearchSymbol.cpp', - 'compiler/SearchSymbol.h', - ], - }, - { - 'target_name': 'libGLESv2', - 'type': 'shared_library', - 'dependencies': ['translator_hlsl'], - 'include_dirs': [ - '.', - '../include', - '$(DXSDK_DIR)/include', - ], - 'sources': [ - 'common/angleutils.h', - 'common/debug.cpp', - 'common/debug.h', - 'common/RefCountObject.cpp', - 'common/RefCountObject.h', - 'common/version.h', - 'libGLESv2/IndexDataManager.cpp', - 'libGLESv2/IndexDataManager.h', - 'libGLESv2/vertexconversion.h', - 'libGLESv2/VertexDataManager.cpp', - 'libGLESv2/VertexDataManager.h', - 'libGLESv2/BinaryStream.h', - 'libGLESv2/Blit.cpp', - 'libGLESv2/Blit.h', - 'libGLESv2/Buffer.cpp', - 'libGLESv2/Buffer.h', - 'libGLESv2/Context.cpp', - 'libGLESv2/Context.h', - 'libGLESv2/Fence.cpp', - 'libGLESv2/Fence.h', - 'libGLESv2/Framebuffer.cpp', - 'libGLESv2/Framebuffer.h', - 'libGLESv2/HandleAllocator.cpp', - 'libGLESv2/HandleAllocator.h', - 'libGLESv2/libGLESv2.cpp', - 'libGLESv2/libGLESv2.def', - 'libGLESv2/libGLESv2.rc', - 'libGLESv2/main.cpp', - 'libGLESv2/main.h', - 'libGLESv2/mathutil.h', - 'libGLESv2/Program.cpp', - 'libGLESv2/Program.h', - 'libGLESv2/ProgramBinary.cpp', - 'libGLESv2/ProgramBinary.h', - 'libGLESv2/Query.h', - 'libGLESv2/Query.cpp', - 'libGLESv2/Renderbuffer.cpp', - 'libGLESv2/Renderbuffer.h', - 'libGLESv2/ResourceManager.cpp', - 'libGLESv2/ResourceManager.h', - 'libGLESv2/Shader.cpp', - 'libGLESv2/Shader.h', - 'libGLESv2/Texture.cpp', - 'libGLESv2/TextureSSE2.cpp', - 'libGLESv2/Texture.h', - 'libGLESv2/utilities.cpp', - 'libGLESv2/utilities.h', - ], - 'msvs_settings': { - 'VCLinkerTool': { - 'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'], - 'AdditionalDependencies': [ - 'd3d9.lib', - 'd3dx9.lib', - 'd3dcompiler.lib', - ], - } - }, - }, - { - 'target_name': 'libEGL', - 'type': 'shared_library', - 'dependencies': ['libGLESv2'], - 'include_dirs': [ - '.', - '../include', - ], - 'sources': [ - 'common/angleutils.h', - 'common/debug.cpp', - 'common/debug.h', - 'common/RefCountObject.cpp', - 'common/RefCountObject.h', - 'common/version.h', - 'libEGL/Config.cpp', - 'libEGL/Config.h', - 'libEGL/Display.cpp', - 'libEGL/Display.h', - 'libEGL/libEGL.cpp', - 'libEGL/libEGL.def', - 'libEGL/libEGL.rc', - 'libEGL/main.cpp', - 'libEGL/main.h', - 'libEGL/Surface.cpp', - 'libEGL/Surface.h', - ], - 'msvs_settings': { - 'VCLinkerTool': { - 'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'], - 'AdditionalDependencies': [ - 'd3d9.lib', - 'dxguid.lib', - 'dwmapi.lib', - ], - 'DelayLoadDLLs': [ - 'dwmapi.dll', - ] - } - }, - }, - ], - }], + 'includes': [ + 'build_angle.gypi', ], } diff --git a/gfx/angle/src/build_angle.gypi b/gfx/angle/src/build_angle.gypi new file mode 100644 index 000000000000..da23a96e8578 --- /dev/null +++ b/gfx/angle/src/build_angle.gypi @@ -0,0 +1,328 @@ +# Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + 'angle_code': 1, + }, + 'target_defaults': { + 'defines': [ + 'ANGLE_DISABLE_TRACE', + 'ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ L"d3dcompiler_46.dll", L"d3dcompiler_43.dll" }', + ], + }, + 'targets': [ + { + 'target_name': 'preprocessor', + 'type': 'static_library', + 'include_dirs': [ + ], + 'sources': [ + 'compiler/preprocessor/Diagnostics.cpp', + 'compiler/preprocessor/Diagnostics.h', + 'compiler/preprocessor/DirectiveHandler.cpp', + 'compiler/preprocessor/DirectiveHandler.h', + 'compiler/preprocessor/DirectiveParser.cpp', + 'compiler/preprocessor/DirectiveParser.h', + 'compiler/preprocessor/ExpressionParser.cpp', + 'compiler/preprocessor/ExpressionParser.h', + 'compiler/preprocessor/Input.cpp', + 'compiler/preprocessor/Input.h', + 'compiler/preprocessor/length_limits.h', + 'compiler/preprocessor/Lexer.cpp', + 'compiler/preprocessor/Lexer.h', + 'compiler/preprocessor/Macro.cpp', + 'compiler/preprocessor/Macro.h', + 'compiler/preprocessor/MacroExpander.cpp', + 'compiler/preprocessor/MacroExpander.h', + 'compiler/preprocessor/numeric_lex.h', + 'compiler/preprocessor/pp_utils.h', + 'compiler/preprocessor/Preprocessor.cpp', + 'compiler/preprocessor/Preprocessor.h', + 'compiler/preprocessor/SourceLocation.h', + 'compiler/preprocessor/Token.cpp', + 'compiler/preprocessor/Token.h', + 'compiler/preprocessor/Tokenizer.cpp', + 'compiler/preprocessor/Tokenizer.h', + ], + }, + { + 'target_name': 'translator_common', + 'type': 'static_library', + 'dependencies': ['preprocessor'], + 'include_dirs': [ + '.', + '../include', + ], + 'defines': [ + 'COMPILER_IMPLEMENTATION', + ], + 'sources': [ + 'compiler/BaseTypes.h', + 'compiler/BuiltInFunctionEmulator.cpp', + 'compiler/BuiltInFunctionEmulator.h', + 'compiler/Common.h', + 'compiler/Compiler.cpp', + 'compiler/ConstantUnion.h', + 'compiler/debug.cpp', + 'compiler/debug.h', + 'compiler/DetectRecursion.cpp', + 'compiler/DetectRecursion.h', + 'compiler/Diagnostics.h', + 'compiler/Diagnostics.cpp', + 'compiler/DirectiveHandler.h', + 'compiler/DirectiveHandler.cpp', + 'compiler/ExtensionBehavior.h', + 'compiler/ForLoopUnroll.cpp', + 'compiler/ForLoopUnroll.h', + 'compiler/glslang.h', + 'compiler/glslang_lex.cpp', + 'compiler/glslang_tab.cpp', + 'compiler/glslang_tab.h', + 'compiler/HashNames.h', + 'compiler/InfoSink.cpp', + 'compiler/InfoSink.h', + 'compiler/Initialize.cpp', + 'compiler/Initialize.h', + 'compiler/InitializeDll.cpp', + 'compiler/InitializeDll.h', + 'compiler/InitializeGlobals.h', + 'compiler/InitializeParseContext.cpp', + 'compiler/InitializeParseContext.h', + 'compiler/Intermediate.cpp', + 'compiler/intermediate.h', + 'compiler/intermOut.cpp', + 'compiler/IntermTraverse.cpp', + 'compiler/localintermediate.h', + 'compiler/MapLongVariableNames.cpp', + 'compiler/MapLongVariableNames.h', + 'compiler/MMap.h', + 'compiler/osinclude.h', + 'compiler/parseConst.cpp', + 'compiler/ParseHelper.cpp', + 'compiler/ParseHelper.h', + 'compiler/PoolAlloc.cpp', + 'compiler/PoolAlloc.h', + 'compiler/QualifierAlive.cpp', + 'compiler/QualifierAlive.h', + 'compiler/RemoveTree.cpp', + 'compiler/RemoveTree.h', + 'compiler/RenameFunction.h', + 'compiler/ShHandle.h', + 'compiler/SymbolTable.cpp', + 'compiler/SymbolTable.h', + 'compiler/Types.h', + 'compiler/util.cpp', + 'compiler/util.h', + 'compiler/ValidateLimitations.cpp', + 'compiler/ValidateLimitations.h', + 'compiler/VariableInfo.cpp', + 'compiler/VariableInfo.h', + 'compiler/VariablePacker.cpp', + 'compiler/VariablePacker.h', + # Dependency graph + 'compiler/depgraph/DependencyGraph.cpp', + 'compiler/depgraph/DependencyGraph.h', + 'compiler/depgraph/DependencyGraphBuilder.cpp', + 'compiler/depgraph/DependencyGraphBuilder.h', + 'compiler/depgraph/DependencyGraphOutput.cpp', + 'compiler/depgraph/DependencyGraphOutput.h', + 'compiler/depgraph/DependencyGraphTraverse.cpp', + # Timing restrictions + 'compiler/timing/RestrictFragmentShaderTiming.cpp', + 'compiler/timing/RestrictFragmentShaderTiming.h', + 'compiler/timing/RestrictVertexShaderTiming.cpp', + 'compiler/timing/RestrictVertexShaderTiming.h', + ], + 'conditions': [ + ['OS=="win"', { + 'sources': ['compiler/ossource_win.cpp'], + }, { # else: posix + 'sources': ['compiler/ossource_posix.cpp'], + }], + ], + }, + { + 'target_name': 'translator_glsl', + 'type': '<(component)', + 'dependencies': ['translator_common'], + 'include_dirs': [ + '.', + '../include', + ], + 'defines': [ + 'COMPILER_IMPLEMENTATION', + ], + 'sources': [ + 'compiler/CodeGenGLSL.cpp', + 'compiler/OutputESSL.cpp', + 'compiler/OutputESSL.h', + 'compiler/OutputGLSLBase.cpp', + 'compiler/OutputGLSLBase.h', + 'compiler/OutputGLSL.cpp', + 'compiler/OutputGLSL.h', + 'compiler/ShaderLang.cpp', + 'compiler/TranslatorESSL.cpp', + 'compiler/TranslatorESSL.h', + 'compiler/TranslatorGLSL.cpp', + 'compiler/TranslatorGLSL.h', + 'compiler/VersionGLSL.cpp', + 'compiler/VersionGLSL.h', + ], + }, + ], + 'conditions': [ + ['OS=="win"', { + 'targets': [ + { + 'target_name': 'translator_hlsl', + 'type': '<(component)', + 'dependencies': ['translator_common'], + 'include_dirs': [ + '.', + '../include', + ], + 'defines': [ + 'COMPILER_IMPLEMENTATION', + ], + 'sources': [ + 'compiler/ShaderLang.cpp', + 'compiler/DetectDiscontinuity.cpp', + 'compiler/DetectDiscontinuity.h', + 'compiler/CodeGenHLSL.cpp', + 'compiler/OutputHLSL.cpp', + 'compiler/OutputHLSL.h', + 'compiler/TranslatorHLSL.cpp', + 'compiler/TranslatorHLSL.h', + 'compiler/UnfoldShortCircuit.cpp', + 'compiler/UnfoldShortCircuit.h', + 'compiler/SearchSymbol.cpp', + 'compiler/SearchSymbol.h', + ], + }, + { + 'target_name': 'libGLESv2', + 'type': 'shared_library', + 'dependencies': ['translator_hlsl'], + 'include_dirs': [ + '.', + '../include', + '$(DXSDK_DIR)/include', + ], + 'sources': [ + 'common/angleutils.h', + 'common/debug.cpp', + 'common/debug.h', + 'common/RefCountObject.cpp', + 'common/RefCountObject.h', + 'common/version.h', + 'libGLESv2/IndexDataManager.cpp', + 'libGLESv2/IndexDataManager.h', + 'libGLESv2/vertexconversion.h', + 'libGLESv2/VertexDataManager.cpp', + 'libGLESv2/VertexDataManager.h', + 'libGLESv2/BinaryStream.h', + 'libGLESv2/Blit.cpp', + 'libGLESv2/Blit.h', + 'libGLESv2/Buffer.cpp', + 'libGLESv2/Buffer.h', + 'libGLESv2/Context.cpp', + 'libGLESv2/Context.h', + 'libGLESv2/D3DConstantTable.cpp', + 'libGLESv2/D3DConstantTable.h', + 'libGLESv2/Fence.cpp', + 'libGLESv2/Fence.h', + 'libGLESv2/Float16ToFloat32.cpp', + 'libGLESv2/Framebuffer.cpp', + 'libGLESv2/Framebuffer.h', + 'libGLESv2/HandleAllocator.cpp', + 'libGLESv2/HandleAllocator.h', + 'libGLESv2/libGLESv2.cpp', + 'libGLESv2/libGLESv2.def', + 'libGLESv2/libGLESv2.rc', + 'libGLESv2/main.cpp', + 'libGLESv2/main.h', + 'libGLESv2/mathutil.h', + 'libGLESv2/Program.cpp', + 'libGLESv2/Program.h', + 'libGLESv2/ProgramBinary.cpp', + 'libGLESv2/ProgramBinary.h', + 'libGLESv2/Query.h', + 'libGLESv2/Query.cpp', + 'libGLESv2/Renderbuffer.cpp', + 'libGLESv2/Renderbuffer.h', + 'libGLESv2/ResourceManager.cpp', + 'libGLESv2/ResourceManager.h', + 'libGLESv2/Shader.cpp', + 'libGLESv2/Shader.h', + 'libGLESv2/Texture.cpp', + 'libGLESv2/TextureSSE2.cpp', + 'libGLESv2/Texture.h', + 'libGLESv2/utilities.cpp', + 'libGLESv2/utilities.h', + ], + 'msvs_settings': { + 'VCLinkerTool': { + 'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'], + 'AdditionalDependencies': [ + 'd3d9.lib', + ], + } + }, + }, + { + 'target_name': 'libEGL', + 'type': 'shared_library', + 'dependencies': ['libGLESv2'], + 'include_dirs': [ + '.', + '../include', + '$(DXSDK_DIR)/include', + ], + 'sources': [ + 'common/angleutils.h', + 'common/debug.cpp', + 'common/debug.h', + 'common/RefCountObject.cpp', + 'common/RefCountObject.h', + 'common/version.h', + 'libEGL/Config.cpp', + 'libEGL/Config.h', + 'libEGL/Display.cpp', + 'libEGL/Display.h', + 'libEGL/libEGL.cpp', + 'libEGL/libEGL.def', + 'libEGL/libEGL.rc', + 'libEGL/main.cpp', + 'libEGL/main.h', + 'libEGL/Surface.cpp', + 'libEGL/Surface.h', + ], + 'msvs_settings': { + 'VCLinkerTool': { + 'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'], + 'AdditionalDependencies': [ + 'd3d9.lib', + 'dxguid.lib', + 'dwmapi.lib', + ], + 'DelayLoadDLLs': [ + 'dwmapi.dll', + ] + } + }, + }, + ], + }], + ], +} + +# Local Variables: +# tab-width:2 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=2 shiftwidth=2: +# Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. diff --git a/gfx/angle/src/common/debug.cpp b/gfx/angle/src/common/debug.cpp index b2238f97084b..c45b2a1ce910 100644 --- a/gfx/angle/src/common/debug.cpp +++ b/gfx/angle/src/common/debug.cpp @@ -84,6 +84,12 @@ bool perfActive() ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...) { #if !defined(ANGLE_DISABLE_PERF) +#if defined(ANGLE_DISABLE_TRACE) + if (!perfActive()) + { + return; + } +#endif va_list vararg; va_start(vararg, format); output(true, reinterpret_cast(D3DPERF_BeginEvent), format, vararg); diff --git a/gfx/angle/src/common/version.h b/gfx/angle/src/common/version.h index ce0c2c0cd24d..0a4c6104b03d 100644 --- a/gfx/angle/src/common/version.h +++ b/gfx/angle/src/common/version.h @@ -1,7 +1,7 @@ #define MAJOR_VERSION 1 #define MINOR_VERSION 0 #define BUILD_VERSION 0 -#define BUILD_REVISION 1267 +#define BUILD_REVISION 1560 #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) diff --git a/gfx/angle/src/compiler/Compiler.cpp b/gfx/angle/src/compiler/Compiler.cpp index 9e7f75c33a54..ab12ac93e45a 100644 --- a/gfx/angle/src/compiler/Compiler.cpp +++ b/gfx/angle/src/compiler/Compiler.cpp @@ -124,6 +124,8 @@ bool TCompiler::Init(const ShBuiltInResources& resources) return false; InitExtensionBehavior(resources, extensionBehavior); + hashFunction = resources.HashFunction; + return true; } @@ -193,7 +195,8 @@ bool TCompiler::compile(const char* const shaderStrings[], // Call mapLongVariableNames() before collectAttribsUniforms() so in // collectAttribsUniforms() we already have the mapped symbol names and // we could composite mapped and original variable names. - if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES)) + // Also, if we hash all the names, then no need to do this for long names. + if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) && hashFunction == NULL) mapLongVariableNames(root); if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) { @@ -242,6 +245,8 @@ void TCompiler::clearResults() uniforms.clear(); builtInFunctionEmulator.Cleanup(); + + nameMap.clear(); } bool TCompiler::detectRecursion(TIntermNode* root) @@ -317,7 +322,7 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root) void TCompiler::collectAttribsUniforms(TIntermNode* root) { - CollectAttribsUniforms collect(attribs, uniforms); + CollectAttribsUniforms collect(attribs, uniforms, hashFunction); root->traverse(&collect); } diff --git a/gfx/angle/src/compiler/Diagnostics.cpp b/gfx/angle/src/compiler/Diagnostics.cpp index 89276167c6df..5bfd2199e816 100644 --- a/gfx/angle/src/compiler/Diagnostics.cpp +++ b/gfx/angle/src/compiler/Diagnostics.cpp @@ -6,9 +6,9 @@ #include "compiler/Diagnostics.h" -#include "compiler/compilerdebug.h" +#include "compiler/compiler_debug.h" #include "compiler/InfoSink.h" -#include "compiler/preprocessor/new/SourceLocation.h" +#include "compiler/preprocessor/SourceLocation.h" TDiagnostics::TDiagnostics(TInfoSink& infoSink) : mInfoSink(infoSink), diff --git a/gfx/angle/src/compiler/Diagnostics.h b/gfx/angle/src/compiler/Diagnostics.h index 3670414b03d3..43dfcb71c694 100644 --- a/gfx/angle/src/compiler/Diagnostics.h +++ b/gfx/angle/src/compiler/Diagnostics.h @@ -7,7 +7,7 @@ #ifndef COMPILER_DIAGNOSTICS_H_ #define COMPILER_DIAGNOSTICS_H_ -#include "compiler/preprocessor/new/Diagnostics.h" +#include "compiler/preprocessor/Diagnostics.h" class TInfoSink; diff --git a/gfx/angle/src/compiler/DirectiveHandler.cpp b/gfx/angle/src/compiler/DirectiveHandler.cpp index bab3dbc3d4bd..aff5dbc0b8cb 100644 --- a/gfx/angle/src/compiler/DirectiveHandler.cpp +++ b/gfx/angle/src/compiler/DirectiveHandler.cpp @@ -8,7 +8,7 @@ #include -#include "compiler/compilerdebug.h" +#include "compiler/compiler_debug.h" #include "compiler/Diagnostics.h" static TBehavior getBehavior(const std::string& str) diff --git a/gfx/angle/src/compiler/DirectiveHandler.h b/gfx/angle/src/compiler/DirectiveHandler.h index 21d3dfc31526..a08b7a86d9cf 100644 --- a/gfx/angle/src/compiler/DirectiveHandler.h +++ b/gfx/angle/src/compiler/DirectiveHandler.h @@ -9,7 +9,7 @@ #include "compiler/ExtensionBehavior.h" #include "compiler/Pragma.h" -#include "compiler/preprocessor/new/DirectiveHandler.h" +#include "compiler/preprocessor/DirectiveHandler.h" class TDiagnostics; diff --git a/gfx/angle/src/compiler/HashNames.h b/gfx/angle/src/compiler/HashNames.h new file mode 100644 index 000000000000..d2141e2d8537 --- /dev/null +++ b/gfx/angle/src/compiler/HashNames.h @@ -0,0 +1,19 @@ +// +// 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_HASH_NAMES_H_ +#define COMPILER_HASH_NAMES_H_ + +#include + +#include "compiler/intermediate.h" +#include "GLSLANG/ShaderLang.h" + +#define HASHED_NAME_PREFIX "webgl_" + +typedef std::map NameMap; + +#endif // COMPILER_HASH_NAMES_H_ diff --git a/gfx/angle/src/compiler/Intermediate.cpp b/gfx/angle/src/compiler/Intermediate.cpp index 92c450530e71..9032b3ae8eda 100644 --- a/gfx/angle/src/compiler/Intermediate.cpp +++ b/gfx/angle/src/compiler/Intermediate.cpp @@ -12,6 +12,7 @@ #include #include +#include "compiler/HashNames.h" #include "compiler/localintermediate.h" #include "compiler/QualifierAlive.h" #include "compiler/RemoveTree.h" @@ -1445,3 +1446,14 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC return addConstantUnion(leftUnionArray, TType(promoteTo, t.getPrecision(), t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node->getLine()); } +// static +TString TIntermTraverser::hash(const TString& name, ShHashFunction64 hashFunction) +{ + if (hashFunction == NULL || name.empty()) + return name; + khronos_uint64_t number = (*hashFunction)(name.c_str(), name.length()); + TStringStream stream; + stream << HASHED_NAME_PREFIX << std::hex << number; + TString hashedName = stream.str(); + return hashedName; +} diff --git a/gfx/angle/src/compiler/OutputESSL.cpp b/gfx/angle/src/compiler/OutputESSL.cpp index 64ee92d44e15..03317528d9fa 100644 --- a/gfx/angle/src/compiler/OutputESSL.cpp +++ b/gfx/angle/src/compiler/OutputESSL.cpp @@ -6,8 +6,11 @@ #include "compiler/OutputESSL.h" -TOutputESSL::TOutputESSL(TInfoSinkBase& objSink) - : TOutputGLSLBase(objSink) +TOutputESSL::TOutputESSL(TInfoSinkBase& objSink, + ShHashFunction64 hashFunction, + NameMap& nameMap, + TSymbolTable& symbolTable) + : TOutputGLSLBase(objSink, hashFunction, nameMap, symbolTable) { } diff --git a/gfx/angle/src/compiler/OutputESSL.h b/gfx/angle/src/compiler/OutputESSL.h index 4fa73c8047ab..dd8c5abf46b9 100644 --- a/gfx/angle/src/compiler/OutputESSL.h +++ b/gfx/angle/src/compiler/OutputESSL.h @@ -12,7 +12,10 @@ class TOutputESSL : public TOutputGLSLBase { public: - TOutputESSL(TInfoSinkBase& objSink); + TOutputESSL(TInfoSinkBase& objSink, + ShHashFunction64 hashFunction, + NameMap& nameMap, + TSymbolTable& symbolTable); protected: virtual bool writeVariablePrecision(TPrecision precision); diff --git a/gfx/angle/src/compiler/OutputGLSL.cpp b/gfx/angle/src/compiler/OutputGLSL.cpp index dd31b4b58bc0..58730421952f 100644 --- a/gfx/angle/src/compiler/OutputGLSL.cpp +++ b/gfx/angle/src/compiler/OutputGLSL.cpp @@ -6,8 +6,11 @@ #include "compiler/OutputGLSL.h" -TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink) - : TOutputGLSLBase(objSink) +TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink, + ShHashFunction64 hashFunction, + NameMap& nameMap, + TSymbolTable& symbolTable) + : TOutputGLSLBase(objSink, hashFunction, nameMap, symbolTable) { } diff --git a/gfx/angle/src/compiler/OutputGLSL.h b/gfx/angle/src/compiler/OutputGLSL.h index 0fe2356eb734..90302120d9d7 100644 --- a/gfx/angle/src/compiler/OutputGLSL.h +++ b/gfx/angle/src/compiler/OutputGLSL.h @@ -12,7 +12,10 @@ class TOutputGLSL : public TOutputGLSLBase { public: - TOutputGLSL(TInfoSinkBase& objSink); + TOutputGLSL(TInfoSinkBase& objSink, + ShHashFunction64 hashFunction, + NameMap& nameMap, + TSymbolTable& symbolTable); protected: virtual bool writeVariablePrecision(TPrecision); diff --git a/gfx/angle/src/compiler/OutputGLSLBase.cpp b/gfx/angle/src/compiler/OutputGLSLBase.cpp index a6fe9d11a128..10239688b49f 100644 --- a/gfx/angle/src/compiler/OutputGLSLBase.cpp +++ b/gfx/angle/src/compiler/OutputGLSLBase.cpp @@ -5,39 +5,10 @@ // #include "compiler/OutputGLSLBase.h" -#include "compiler/compilerdebug.h" +#include "compiler/compiler_debug.h" namespace { -TString getTypeName(const TType& type) -{ - TInfoSinkBase out; - if (type.isMatrix()) - { - out << "mat"; - out << type.getNominalSize(); - } - else if (type.isVector()) - { - switch (type.getBasicType()) - { - case EbtFloat: out << "vec"; break; - case EbtInt: out << "ivec"; break; - case EbtBool: out << "bvec"; break; - default: UNREACHABLE(); break; - } - out << type.getNominalSize(); - } - else - { - if (type.getBasicType() == EbtStruct) - out << type.getTypeName(); - else - out << type.getBasicString(); - } - return TString(out.c_str()); -} - TString arrayBrackets(const TType& type) { ASSERT(type.isArray()); @@ -66,10 +37,16 @@ bool isSingleStatement(TIntermNode* node) { } } // namespace -TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase& objSink) +TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase& objSink, + ShHashFunction64 hashFunction, + NameMap& nameMap, + TSymbolTable& symbolTable) : TIntermTraverser(true, true, true), mObjSink(objSink), - mDeclaringVariables(false) + mDeclaringVariables(false), + mHashFunction(hashFunction), + mNameMap(nameMap), + mSymbolTable(symbolTable) { } @@ -101,7 +78,7 @@ void TOutputGLSLBase::writeVariableType(const TType& type) if ((type.getBasicType() == EbtStruct) && (mDeclaredStructs.find(type.getTypeName()) == mDeclaredStructs.end())) { - out << "struct " << type.getTypeName() << "{\n"; + out << "struct " << hashName(type.getTypeName()) << "{\n"; const TTypeList* structure = type.getStruct(); ASSERT(structure != NULL); for (size_t i = 0; i < structure->size(); ++i) @@ -110,7 +87,7 @@ void TOutputGLSLBase::writeVariableType(const TType& type) ASSERT(fieldType != NULL); if (writeVariablePrecision(fieldType->getPrecision())) out << " "; - out << getTypeName(*fieldType) << " " << fieldType->getFieldName(); + out << getTypeName(*fieldType) << " " << hashName(fieldType->getFieldName()); if (fieldType->isArray()) out << arrayBrackets(*fieldType); out << ";\n"; @@ -140,7 +117,7 @@ void TOutputGLSLBase::writeFunctionParameters(const TIntermSequence& args) const TString& name = arg->getSymbol(); if (!name.empty()) - out << " " << name; + out << " " << hashName(name); if (type.isArray()) out << arrayBrackets(type); @@ -157,7 +134,7 @@ const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type, if (type.getBasicType() == EbtStruct) { - out << type.getTypeName() << "("; + out << hashName(type.getTypeName()) << "("; const TTypeList* structure = type.getStruct(); ASSERT(structure != NULL); for (size_t i = 0; i < structure->size(); ++i) @@ -196,7 +173,7 @@ void TOutputGLSLBase::visitSymbol(TIntermSymbol* node) if (mLoopUnroll.NeedsToReplaceSymbolWithValue(node)) out << mLoopUnroll.GetLoopIndexValue(node); else - out << node->getSymbol(); + out << hashVariableName(node->getSymbol()); if (mDeclaringVariables && node->getType().isArray()) out << arrayBrackets(node->getType()); @@ -243,7 +220,7 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node) { out << "."; // TODO(alokp): ASSERT - out << node->getType().getFieldName(); + out << hashName(node->getType().getFieldName()); visitChildren = false; } break; @@ -467,7 +444,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node) // Function declaration. ASSERT(visit == PreVisit); writeVariableType(node->getType()); - out << " " << node->getName(); + out << " " << hashName(node->getName()); out << "("; writeFunctionParameters(node->getSequence()); @@ -480,7 +457,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node) // Function definition. ASSERT(visit == PreVisit); writeVariableType(node->getType()); - out << " " << TFunction::unmangleName(node->getName()); + out << " " << hashFunctionName(node->getName()); incrementDepth(); // Function definition node contains one or two children nodes @@ -510,8 +487,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node) // Function call. if (visit == PreVisit) { - TString functionName = TFunction::unmangleName(node->getName()); - out << functionName << "("; + out << hashFunctionName(node->getName()) << "("; } else if (visit == InVisit) { @@ -572,7 +548,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node) { const TType& type = node->getType(); ASSERT(type.getBasicType() == EbtStruct); - out << type.getTypeName() << "("; + out << hashName(type.getTypeName()) << "("; } else if (visit == InVisit) { @@ -718,3 +694,59 @@ void TOutputGLSLBase::visitCodeBlock(TIntermNode* node) { out << "{\n}\n"; // Empty code block. } } + +TString TOutputGLSLBase::getTypeName(const TType& type) +{ + TInfoSinkBase out; + if (type.isMatrix()) + { + out << "mat"; + out << type.getNominalSize(); + } + else if (type.isVector()) + { + switch (type.getBasicType()) + { + case EbtFloat: out << "vec"; break; + case EbtInt: out << "ivec"; break; + case EbtBool: out << "bvec"; break; + default: UNREACHABLE(); break; + } + out << type.getNominalSize(); + } + else + { + if (type.getBasicType() == EbtStruct) + out << hashName(type.getTypeName()); + else + out << type.getBasicString(); + } + return TString(out.c_str()); +} + +TString TOutputGLSLBase::hashName(const TString& name) +{ + if (mHashFunction == NULL || name.empty()) + return name; + NameMap::const_iterator it = mNameMap.find(name.c_str()); + if (it != mNameMap.end()) + return it->second.c_str(); + TString hashedName = TIntermTraverser::hash(name, mHashFunction); + mNameMap[name.c_str()] = hashedName.c_str(); + return hashedName; +} + +TString TOutputGLSLBase::hashVariableName(const TString& name) +{ + if (mSymbolTable.findBuiltIn(name) != NULL) + return name; + return hashName(name); +} + +TString TOutputGLSLBase::hashFunctionName(const TString& mangled_name) +{ + TString name = TFunction::unmangleName(mangled_name); + if (mSymbolTable.findBuiltIn(mangled_name) != NULL || name == "main") + return name; + return hashName(name); +} diff --git a/gfx/angle/src/compiler/OutputGLSLBase.h b/gfx/angle/src/compiler/OutputGLSLBase.h index efd0b5fc2d8f..01e9d4a66726 100644 --- a/gfx/angle/src/compiler/OutputGLSLBase.h +++ b/gfx/angle/src/compiler/OutputGLSLBase.h @@ -16,7 +16,10 @@ class TOutputGLSLBase : public TIntermTraverser { public: - TOutputGLSLBase(TInfoSinkBase& objSink); + TOutputGLSLBase(TInfoSinkBase& objSink, + ShHashFunction64 hashFunction, + NameMap& nameMap, + TSymbolTable& symbolTable); protected: TInfoSinkBase& objSink() { return mObjSink; } @@ -25,6 +28,7 @@ protected: virtual bool writeVariablePrecision(TPrecision precision) = 0; void writeFunctionParameters(const TIntermSequence& args); const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion); + TString getTypeName(const TType& type); virtual void visitSymbol(TIntermSymbol* node); virtual void visitConstantUnion(TIntermConstantUnion* node); @@ -37,6 +41,15 @@ protected: void visitCodeBlock(TIntermNode* node); + + // Return the original name if hash function pointer is NULL; + // otherwise return the hashed name. + TString hashName(const TString& name); + // Same as hashName(), but without hashing built-in variables. + TString hashVariableName(const TString& name); + // Same as hashName(), but without hashing built-in functions. + TString hashFunctionName(const TString& mangled_name); + private: TInfoSinkBase& mObjSink; bool mDeclaringVariables; @@ -48,6 +61,12 @@ private: DeclaredStructs mDeclaredStructs; ForLoopUnroll mLoopUnroll; + + // name hashing. + ShHashFunction64 mHashFunction; + NameMap& mNameMap; + + TSymbolTable& mSymbolTable; }; #endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ diff --git a/gfx/angle/src/compiler/OutputHLSL.cpp b/gfx/angle/src/compiler/OutputHLSL.cpp index 943f0c4775d8..39a0b8eb36e5 100644 --- a/gfx/angle/src/compiler/OutputHLSL.cpp +++ b/gfx/angle/src/compiler/OutputHLSL.cpp @@ -7,7 +7,7 @@ #include "compiler/OutputHLSL.h" #include "common/angleutils.h" -#include "compiler/compilerdebug.h" +#include "compiler/compiler_debug.h" #include "compiler/InfoSink.h" #include "compiler/UnfoldShortCircuit.h" #include "compiler/SearchSymbol.h" @@ -1340,7 +1340,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) case EOpPrototype: if (visit == PreVisit) { - out << typeString(node->getType()) << " " << decorate(node->getName()) << "("; + out << typeString(node->getType()) << " " << decorate(node->getName()) << (mOutputLod0Function ? "Lod0(" : "("); TIntermSequence &arguments = node->getSequence(); @@ -1362,6 +1362,14 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) out << ");\n"; + // Also prototype the Lod0 variant if needed + if (mContainsLoopDiscontinuity && !mOutputLod0Function) + { + mOutputLod0Function = true; + node->traverse(this); + mOutputLod0Function = false; + } + return false; } break; diff --git a/gfx/angle/src/compiler/ParseHelper.cpp b/gfx/angle/src/compiler/ParseHelper.cpp index db1323dd9d92..6ab99fe84b10 100644 --- a/gfx/angle/src/compiler/ParseHelper.cpp +++ b/gfx/angle/src/compiler/ParseHelper.cpp @@ -10,7 +10,7 @@ #include #include "compiler/glslang.h" -#include "compiler/preprocessor/new/SourceLocation.h" +#include "compiler/preprocessor/SourceLocation.h" /////////////////////////////////////////////////////////////////////// // @@ -846,14 +846,26 @@ bool TParseContext::arraySetMaxSize(TIntermSymbol *node, TType* type, int size, // // Returns true if there was an error. // -bool TParseContext::nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type) +bool TParseContext::nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type, bool array) { - // - // Make the qualifier make sense. - // - if (type.qualifier == EvqConst) { + if (type.qualifier == EvqConst) + { + // Make the qualifier make sense. type.qualifier = EvqTemporary; - error(line, "variables with qualifier 'const' must be initialized", identifier.c_str()); + + if (array) + { + error(line, "arrays may not be declared constant since they cannot be initialized", identifier.c_str()); + } + else if (type.isStructureContainingArrays()) + { + error(line, "structures containing arrays may not be declared constant since they cannot be initialized", identifier.c_str()); + } + else + { + error(line, "variables with qualifier 'const' must be initialized", identifier.c_str()); + } + return true; } diff --git a/gfx/angle/src/compiler/ParseHelper.h b/gfx/angle/src/compiler/ParseHelper.h index 640516171f3b..668e52a256c1 100644 --- a/gfx/angle/src/compiler/ParseHelper.h +++ b/gfx/angle/src/compiler/ParseHelper.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -9,7 +9,7 @@ #include "compiler/Diagnostics.h" #include "compiler/DirectiveHandler.h" #include "compiler/localintermediate.h" -#include "compiler/preprocessor/new/Preprocessor.h" +#include "compiler/preprocessor/Preprocessor.h" #include "compiler/ShHandle.h" #include "compiler/SymbolTable.h" @@ -97,7 +97,7 @@ struct TParseContext { bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason); bool structQualifierErrorCheck(int line, const TPublicType& pType); bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type); - bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type); + bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type, bool array); bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type, TVariable*& variable); bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type); bool extensionErrorCheck(int line, const TString&); diff --git a/gfx/angle/src/compiler/ShHandle.h b/gfx/angle/src/compiler/ShHandle.h index 6ba302ad044e..23f0cf3698e3 100644 --- a/gfx/angle/src/compiler/ShHandle.h +++ b/gfx/angle/src/compiler/ShHandle.h @@ -18,6 +18,7 @@ #include "compiler/BuiltInFunctionEmulator.h" #include "compiler/ExtensionBehavior.h" +#include "compiler/HashNames.h" #include "compiler/InfoSink.h" #include "compiler/SymbolTable.h" #include "compiler/VariableInfo.h" @@ -68,6 +69,10 @@ public: const TVariableInfoList& getUniforms() const { return uniforms; } int getMappedNameMaxLength() const; + ShHashFunction64 getHashFunction() const { return hashFunction; } + NameMap& getNameMap() { return nameMap; } + TSymbolTable& getSymbolTable() { return symbolTable; } + protected: ShShaderType getShaderType() const { return shaderType; } ShShaderSpec getShaderSpec() const { return shaderSpec; } @@ -124,6 +129,10 @@ private: // Cached copy of the ref-counted singleton. LongNameMap* longNameMap; + + // name hashing. + ShHashFunction64 hashFunction; + NameMap nameMap; }; // diff --git a/gfx/angle/src/compiler/ShaderLang.cpp b/gfx/angle/src/compiler/ShaderLang.cpp index 56f5c7f2ec00..ab56538c1ebb 100644 --- a/gfx/angle/src/compiler/ShaderLang.cpp +++ b/gfx/angle/src/compiler/ShaderLang.cpp @@ -125,6 +125,9 @@ void ShInitBuiltInResources(ShBuiltInResources* resources) resources->OES_standard_derivatives = 0; resources->OES_EGL_image_external = 0; resources->ARB_texture_rectangle = 0; + + // Disable name hashing by default. + resources->HashFunction = NULL; } // @@ -224,6 +227,22 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params) // handle array and struct dereferences. *params = 1 + MAX_SYMBOL_NAME_LEN; break; + case SH_NAME_MAX_LENGTH: + *params = 1 + MAX_SYMBOL_NAME_LEN; + break; + case SH_HASHED_NAME_MAX_LENGTH: + if (compiler->getHashFunction() == NULL) { + *params = 0; + } else { + // 64 bits hashing output requires 16 bytes for hex + // representation. + const char HashedNamePrefix[] = HASHED_NAME_PREFIX; + *params = 16 + sizeof(HashedNamePrefix); + } + break; + case SH_HASHED_NAMES_COUNT: + *params = compiler->getNameMap().size(); + break; default: UNREACHABLE(); } } @@ -283,3 +302,46 @@ void ShGetActiveUniform(const ShHandle handle, getVariableInfo(SH_ACTIVE_UNIFORMS, handle, index, length, size, type, name, mappedName); } + +void ShGetNameHashingEntry(const ShHandle handle, + int index, + char* name, + char* hashedName) +{ + if (!handle || !name || !hashedName || index < 0) + return; + + TShHandleBase* base = static_cast(handle); + TCompiler* compiler = base->getAsCompiler(); + if (!compiler) return; + + const NameMap& nameMap = compiler->getNameMap(); + if (index >= static_cast(nameMap.size())) + return; + + NameMap::const_iterator it = nameMap.begin(); + for (int i = 0; i < index; ++i) + ++it; + + size_t len = it->first.length() + 1; + int max_len = 0; + ShGetInfo(handle, SH_NAME_MAX_LENGTH, &max_len); + if (static_cast(len) > max_len) { + ASSERT(false); + len = max_len; + } + strncpy(name, it->first.c_str(), len); + // To be on the safe side in case the source is longer than expected. + name[len] = '\0'; + + len = it->second.length() + 1; + max_len = 0; + ShGetInfo(handle, SH_HASHED_NAME_MAX_LENGTH, &max_len); + if (static_cast(len) > max_len) { + ASSERT(false); + len = max_len; + } + strncpy(hashedName, it->second.c_str(), len); + // To be on the safe side in case the source is longer than expected. + hashedName[len] = '\0'; +} diff --git a/gfx/angle/src/compiler/SymbolTable.cpp b/gfx/angle/src/compiler/SymbolTable.cpp index 68f029d0e63c..847c1e40858d 100644 --- a/gfx/angle/src/compiler/SymbolTable.cpp +++ b/gfx/angle/src/compiler/SymbolTable.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -20,9 +20,16 @@ #include "common/angleutils.h" -// -// TType helper function needs a place to live. -// +TType::TType(const TPublicType &p) : + type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize), + maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0) +{ + if (p.userDef) { + structure = p.userDef->getStruct(); + typeName = NewPoolTString(p.userDef->getTypeName().c_str()); + computeDeepestStructNesting(); + } +} // // Recursively generate mangled names. @@ -92,6 +99,25 @@ void TType::computeDeepestStructNesting() deepestStructNesting = 1 + maxNesting; } +bool TType::isStructureContainingArrays() const +{ + if (!structure) + { + return false; + } + + for (TTypeList::const_iterator member = structure->begin(); member != structure->end(); member++) + { + if (member->type->isArray() || + member->type->isStructureContainingArrays()) + { + return true; + } + } + + return false; +} + // // Dump functions. // diff --git a/gfx/angle/src/compiler/TranslatorESSL.cpp b/gfx/angle/src/compiler/TranslatorESSL.cpp index e3a2c2a80240..f718f1ef8646 100644 --- a/gfx/angle/src/compiler/TranslatorESSL.cpp +++ b/gfx/angle/src/compiler/TranslatorESSL.cpp @@ -23,7 +23,7 @@ void TranslatorESSL::translate(TIntermNode* root) { sink, getShaderType() == SH_FRAGMENT_SHADER); // Write translated shader. - TOutputESSL outputESSL(sink); + TOutputESSL outputESSL(sink, getHashFunction(), getNameMap(), getSymbolTable()); root->traverse(&outputESSL); } diff --git a/gfx/angle/src/compiler/TranslatorGLSL.cpp b/gfx/angle/src/compiler/TranslatorGLSL.cpp index bb07a1eb4e8f..1e3ff381ea38 100644 --- a/gfx/angle/src/compiler/TranslatorGLSL.cpp +++ b/gfx/angle/src/compiler/TranslatorGLSL.cpp @@ -36,6 +36,6 @@ void TranslatorGLSL::translate(TIntermNode* root) { sink, false); // Write translated shader. - TOutputGLSL outputGLSL(sink); + TOutputGLSL outputGLSL(sink, getHashFunction(), getNameMap(), getSymbolTable()); root->traverse(&outputGLSL); } diff --git a/gfx/angle/src/compiler/Types.h b/gfx/angle/src/compiler/Types.h index 86a02e9a4224..fec7adbce6bd 100644 --- a/gfx/angle/src/compiler/Types.h +++ b/gfx/angle/src/compiler/Types.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -9,12 +9,14 @@ #include "compiler/BaseTypes.h" #include "compiler/Common.h" -#include "compiler/compilerdebug.h" +#include "compiler/compiler_debug.h" + +class TType; +struct TPublicType; // // Need to have association of line numbers to types in a list for building structs. // -class TType; struct TTypeLine { TType* type; int line; @@ -27,59 +29,14 @@ inline TTypeList* NewPoolTTypeList() return new(memory) TTypeList; } -// -// This is a workaround for a problem with the yacc stack, It can't have -// types that it thinks have non-trivial constructors. It should -// just be used while recognizing the grammar, not anything else. Pointers -// could be used, but also trying to avoid lots of memory management overhead. -// -// Not as bad as it looks, there is no actual assumption that the fields -// match up or are name the same or anything like that. -// -class TPublicType { -public: - TBasicType type; - TQualifier qualifier; - TPrecision precision; - int size; // size of vector or matrix, not size of array - bool matrix; - bool array; - int arraySize; - TType* userDef; - int line; - - void setBasic(TBasicType bt, TQualifier q, int ln = 0) - { - type = bt; - qualifier = q; - precision = EbpUndefined; - size = 1; - matrix = false; - array = false; - arraySize = 0; - userDef = 0; - line = ln; - } - - void setAggregate(int s, bool m = false) - { - size = s; - matrix = m; - } - - void setArray(bool a, int s = 0) - { - array = a; - arraySize = s; - } -}; - typedef TMap TStructureMap; typedef TMap::iterator TStructureMapIterator; + // // Base class for things that have a type. // -class TType { +class TType +{ public: POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) TType() {} @@ -88,16 +45,7 @@ public: maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0) { } - explicit TType(const TPublicType &p) : - type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize), - maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0) - { - if (p.userDef) { - structure = p.userDef->getStruct(); - typeName = NewPoolTString(p.userDef->getTypeName().c_str()); - computeDeepestStructNesting(); - } - } + explicit TType(const TPublicType &p); TType(TTypeList* userDef, const TString& n, TPrecision p = EbpUndefined) : type(EbtStruct), precision(p), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0), maxArraySize(0), arrayInformationType(0), structure(userDef), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0) @@ -284,6 +232,8 @@ public: // deepest field (nesting2.field1.position). int getDeepestStructNesting() const { return deepestStructNesting; } + bool isStructureContainingArrays() const; + protected: void buildMangledName(TString&); int getStructSize() const; @@ -308,4 +258,61 @@ protected: TString *typeName; // for structure field type name }; +// +// This is a workaround for a problem with the yacc stack, It can't have +// types that it thinks have non-trivial constructors. It should +// just be used while recognizing the grammar, not anything else. Pointers +// could be used, but also trying to avoid lots of memory management overhead. +// +// Not as bad as it looks, there is no actual assumption that the fields +// match up or are name the same or anything like that. +// +struct TPublicType +{ + TBasicType type; + TQualifier qualifier; + TPrecision precision; + int size; // size of vector or matrix, not size of array + bool matrix; + bool array; + int arraySize; + TType* userDef; + int line; + + void setBasic(TBasicType bt, TQualifier q, int ln = 0) + { + type = bt; + qualifier = q; + precision = EbpUndefined; + size = 1; + matrix = false; + array = false; + arraySize = 0; + userDef = 0; + line = ln; + } + + void setAggregate(int s, bool m = false) + { + size = s; + matrix = m; + } + + void setArray(bool a, int s = 0) + { + array = a; + arraySize = s; + } + + bool isStructureContainingArrays() const + { + if (!userDef) + { + return false; + } + + return userDef->isStructureContainingArrays(); + } +}; + #endif // _TYPES_INCLUDED_ diff --git a/gfx/angle/src/compiler/UnfoldShortCircuit.cpp b/gfx/angle/src/compiler/UnfoldShortCircuit.cpp index 1782ebc90c8a..e22a75f26dfa 100644 --- a/gfx/angle/src/compiler/UnfoldShortCircuit.cpp +++ b/gfx/angle/src/compiler/UnfoldShortCircuit.cpp @@ -95,9 +95,9 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node) mTemporaryIndex = i + 1; } return false; + default: + return true; } - - return true; } bool UnfoldShortCircuit::visitSelection(Visit visit, TIntermSelection *node) diff --git a/gfx/angle/src/compiler/VariableInfo.cpp b/gfx/angle/src/compiler/VariableInfo.cpp index 3ff283627b8b..eb6bea9b0fb6 100644 --- a/gfx/angle/src/compiler/VariableInfo.cpp +++ b/gfx/angle/src/compiler/VariableInfo.cpp @@ -77,23 +77,25 @@ static void getBuiltInVariableInfo(const TType& type, static void getUserDefinedVariableInfo(const TType& type, const TString& name, const TString& mappedName, - TVariableInfoList& infoList); + TVariableInfoList& infoList, + ShHashFunction64 hashFunction); // Returns info for an attribute or uniform. static void getVariableInfo(const TType& type, const TString& name, const TString& mappedName, - TVariableInfoList& infoList) + TVariableInfoList& infoList, + ShHashFunction64 hashFunction) { if (type.getBasicType() == EbtStruct) { if (type.isArray()) { for (int i = 0; i < type.getArraySize(); ++i) { TString lname = name + arrayBrackets(i); TString lmappedName = mappedName + arrayBrackets(i); - getUserDefinedVariableInfo(type, lname, lmappedName, infoList); + getUserDefinedVariableInfo(type, lname, lmappedName, infoList, hashFunction); } } else { - getUserDefinedVariableInfo(type, name, mappedName, infoList); + getUserDefinedVariableInfo(type, name, mappedName, infoList, hashFunction); } } else { getBuiltInVariableInfo(type, name, mappedName, infoList); @@ -124,7 +126,8 @@ void getBuiltInVariableInfo(const TType& type, void getUserDefinedVariableInfo(const TType& type, const TString& name, const TString& mappedName, - TVariableInfoList& infoList) + TVariableInfoList& infoList, + ShHashFunction64 hashFunction) { ASSERT(type.getBasicType() == EbtStruct); @@ -133,8 +136,9 @@ void getUserDefinedVariableInfo(const TType& type, const TType* fieldType = (*structure)[i].type; getVariableInfo(*fieldType, name + "." + fieldType->getFieldName(), - mappedName + "." + fieldType->getFieldName(), - infoList); + mappedName + "." + TIntermTraverser::hash(fieldType->getFieldName(), hashFunction), + infoList, + hashFunction); } } @@ -149,9 +153,11 @@ TVariableInfo::TVariableInfo(ShDataType type, int size) } CollectAttribsUniforms::CollectAttribsUniforms(TVariableInfoList& attribs, - TVariableInfoList& uniforms) + TVariableInfoList& uniforms, + ShHashFunction64 hashFunction) : mAttribs(attribs), - mUniforms(uniforms) + mUniforms(uniforms), + mHashFunction(hashFunction) { } @@ -206,10 +212,16 @@ bool CollectAttribsUniforms::visitAggregate(Visit, TIntermAggregate* node) // cannot be initialized in a shader, we must have only // TIntermSymbol nodes in the sequence. ASSERT(variable != NULL); + TString processedSymbol; + if (mHashFunction == NULL) + processedSymbol = variable->getSymbol(); + else + processedSymbol = TIntermTraverser::hash(variable->getOriginalSymbol(), mHashFunction); getVariableInfo(variable->getType(), variable->getOriginalSymbol(), - variable->getSymbol(), - infoList); + processedSymbol, + infoList, + mHashFunction); } } break; diff --git a/gfx/angle/src/compiler/VariableInfo.h b/gfx/angle/src/compiler/VariableInfo.h index fdcc08f5b511..4130a589f501 100644 --- a/gfx/angle/src/compiler/VariableInfo.h +++ b/gfx/angle/src/compiler/VariableInfo.h @@ -27,7 +27,8 @@ typedef std::vector TVariableInfoList; class CollectAttribsUniforms : public TIntermTraverser { public: CollectAttribsUniforms(TVariableInfoList& attribs, - TVariableInfoList& uniforms); + TVariableInfoList& uniforms, + ShHashFunction64 hashFunction); virtual void visitSymbol(TIntermSymbol*); virtual void visitConstantUnion(TIntermConstantUnion*); @@ -41,6 +42,8 @@ public: private: TVariableInfoList& mAttribs; TVariableInfoList& mUniforms; + + ShHashFunction64 mHashFunction; }; #endif // COMPILER_VARIABLE_INFO_H_ diff --git a/gfx/angle/src/compiler/VersionGLSL.cpp b/gfx/angle/src/compiler/VersionGLSL.cpp index 26cee052707e..7a82bb4dc17d 100644 --- a/gfx/angle/src/compiler/VersionGLSL.cpp +++ b/gfx/angle/src/compiler/VersionGLSL.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -9,17 +9,22 @@ static const int GLSL_VERSION_110 = 110; static const int GLSL_VERSION_120 = 120; -// We need to scan for three things: +// We need to scan for the following: // 1. "invariant" keyword: This can occur in both - vertex and fragment shaders // but only at the global scope. // 2. "gl_PointCoord" built-in variable: This can only occur in fragment shader // but inside any scope. // 3. Call to a matrix constructor with another matrix as argument. // (These constructors were reserved in GLSL version 1.10.) -// -// If it weren't for (3) then we would only need to scan the global -// scope of the vertex shader. However, we need to scan the entire -// shader in both cases. +// 4. Arrays as "out" function parameters. +// GLSL spec section 6.1.1: "When calling a function, expressions that do +// not evaluate to l-values cannot be passed to parameters declared as +// out or inout." +// GLSL 1.1 section 5.8: "Other binary or unary expressions, +// non-dereferenced arrays, function names, swizzles with repeated fields, +// and constants cannot be l-values." +// GLSL 1.2 relaxed the restriction on arrays, section 5.8: "Variables that +// are built-in types, entire structures or arrays... are all l-values." // // TODO(alokp): The following two cases of invariant decalaration get lost // during parsing - they do not get carried over to the intermediate tree. @@ -79,6 +84,26 @@ bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate* node) } break; } + case EOpParameters: { + const TIntermSequence& params = node->getSequence(); + for (TIntermSequence::const_iterator iter = params.begin(); + iter != params.end(); ++iter) + { + const TIntermTyped* param = (*iter)->getAsTyped(); + if (param->isArray()) + { + TQualifier qualifier = param->getQualifier(); + if ((qualifier == EvqOut) || (qualifier == EvqInOut)) + { + updateVersion(GLSL_VERSION_120); + break; + } + } + } + // Fully processed. No need to visit children. + visitChildren = false; + break; + } case EOpConstructMat2: case EOpConstructMat3: case EOpConstructMat4: { diff --git a/gfx/angle/src/compiler/VersionGLSL.h b/gfx/angle/src/compiler/VersionGLSL.h index 376fcb84861a..1c1cb1ab97b9 100644 --- a/gfx/angle/src/compiler/VersionGLSL.h +++ b/gfx/angle/src/compiler/VersionGLSL.h @@ -22,14 +22,18 @@ // - c++ style name hiding rules. // - built-in variable gl_PointCoord for fragment shaders. // - matrix constructors taking matrix as argument. +// - array as "out" function parameters // class TVersionGLSL : public TIntermTraverser { public: TVersionGLSL(ShShaderType type); - // Returns 120 if "invariant" keyword, "gl_PointCoord", or - // matrix/matrix constructors are used in the shader. Else 110 is - // returned. + // Returns 120 if the following is used the shader: + // - "invariant", + // - "gl_PointCoord", + // - matrix/matrix constructors + // - array "out" parameters + // Else 110 is returned. int getVersion() { return mVersion; } virtual void visitSymbol(TIntermSymbol*); diff --git a/gfx/angle/src/compiler/compilerdebug.cpp b/gfx/angle/src/compiler/compiler_debug.cpp similarity index 90% rename from gfx/angle/src/compiler/compilerdebug.cpp rename to gfx/angle/src/compiler/compiler_debug.cpp index acd80c1db649..8461350b0ac7 100644 --- a/gfx/angle/src/compiler/compilerdebug.cpp +++ b/gfx/angle/src/compiler/compiler_debug.cpp @@ -4,9 +4,9 @@ // found in the LICENSE file. // -// debug.cpp: Debugging utilities. +// compiler_debug.cpp: Debugging utilities. -#include "compiler/compilerdebug.h" +#include "compiler/compiler_debug.h" #include #include diff --git a/gfx/angle/src/compiler/compilerdebug.h b/gfx/angle/src/compiler/compiler_debug.h similarity index 96% rename from gfx/angle/src/compiler/compilerdebug.h rename to gfx/angle/src/compiler/compiler_debug.h index 3ac6dcf95098..5405d261aa22 100644 --- a/gfx/angle/src/compiler/compilerdebug.h +++ b/gfx/angle/src/compiler/compiler_debug.h @@ -4,7 +4,7 @@ // found in the LICENSE file. // -// compilerdebug.h: Debugging utilities. +// compiler_debug.h: Debugging utilities. #ifndef COMPILER_DEBUG_H_ #define COMPILER_DEBUG_H_ diff --git a/gfx/angle/src/compiler/glslang.l b/gfx/angle/src/compiler/glslang.l index e0483e2ea9bd..8300ff63f704 100644 --- a/gfx/angle/src/compiler/glslang.l +++ b/gfx/angle/src/compiler/glslang.l @@ -38,7 +38,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). %{ #include "compiler/glslang.h" #include "compiler/ParseHelper.h" -#include "compiler/preprocessor/new/Token.h" +#include "compiler/preprocessor/Token.h" #include "compiler/util.h" #include "glslang_tab.h" @@ -272,146 +272,13 @@ O [0-7] %% -// Old preprocessor interface. -extern "C" { -#include "compiler/preprocessor/preprocess.h" - -extern int InitPreprocessor(); -extern int FinalizePreprocessor(); -extern void PredefineIntMacro(const char *name, int value); - -#define SETUP_CONTEXT(pp) \ - TParseContext* context = (TParseContext*) pp->pC; \ - struct yyguts_t* yyg = (struct yyguts_t*) context->scanner; - -// Preprocessor callbacks. -void CPPDebugLogMsg(const char *msg) -{ - SETUP_CONTEXT(cpp); - context->trace(msg); -} - -void CPPWarningToInfoLog(const char *msg) -{ - SETUP_CONTEXT(cpp); - context->warning(yylineno, msg, ""); -} - -void CPPShInfoLogMsg(const char *msg) -{ - SETUP_CONTEXT(cpp); - context->error(yylineno, msg, ""); - context->recover(); -} - -void CPPErrorToInfoLog(const char *msg) -{ - SETUP_CONTEXT(cpp); - context->error(yylineno, msg, ""); - context->recover(); -} - -void SetLineNumber(int line) -{ - SETUP_CONTEXT(cpp); - int string = 0; - DecodeSourceLoc(yylineno, &string, NULL); - yylineno = EncodeSourceLoc(string, line); -} - -void SetStringNumber(int string) -{ - SETUP_CONTEXT(cpp); - int line = 0; - DecodeSourceLoc(yylineno, NULL, &line); - yylineno = EncodeSourceLoc(string, line); -} - -int GetStringNumber() -{ - SETUP_CONTEXT(cpp); - int string = 0; - DecodeSourceLoc(yylineno, &string, NULL); - return string; -} - -int GetLineNumber() -{ - SETUP_CONTEXT(cpp); - int line = 0; - DecodeSourceLoc(yylineno, NULL, &line); - return line; -} - -void IncLineNumber() -{ - SETUP_CONTEXT(cpp); - int string = 0, line = 0; - DecodeSourceLoc(yylineno, &string, &line); - yylineno = EncodeSourceLoc(string, ++line); -} - -void DecLineNumber() -{ - SETUP_CONTEXT(cpp); - int string = 0, line = 0; - DecodeSourceLoc(yylineno, &string, &line); - yylineno = EncodeSourceLoc(string, --line); -} - -void HandlePragma(const char **tokens, int numTokens) -{ - SETUP_CONTEXT(cpp); - - if (numTokens != 4) return; - if (strcmp(tokens[1], "(") != 0) return; - if (strcmp(tokens[3], ")") != 0) return; - - context->handlePragmaDirective(yylineno, tokens[0], tokens[2]); -} - -void StoreStr(const char *string) -{ - SETUP_CONTEXT(cpp); - TString strSrc; - strSrc = TString(string); - - context->HashErrMsg = context->HashErrMsg + " " + strSrc; -} - -const char* GetStrfromTStr(void) -{ - SETUP_CONTEXT(cpp); - cpp->ErrMsg = context->HashErrMsg.c_str(); - return cpp->ErrMsg; -} - -void ResetTString(void) -{ - SETUP_CONTEXT(cpp); - context->HashErrMsg = ""; -} - -void updateExtensionBehavior(const char* extName, const char* behavior) -{ - SETUP_CONTEXT(cpp); - context->handleExtensionDirective(yylineno, extName, behavior); -} -} // extern "C" - int string_input(char* buf, int max_size, yyscan_t yyscanner) { - int len = 0; - -#if ANGLE_USE_NEW_PREPROCESSOR pp::Token token; yyget_extra(yyscanner)->preprocessor.lex(&token); - len = token.type == pp::Token::LAST ? 0 : token.text.size(); + int len = token.type == pp::Token::LAST ? 0 : token.text.size(); if ((len > 0) && (len < max_size)) memcpy(buf, token.text.c_str(), len); yyset_lineno(EncodeSourceLoc(token.location.file, token.location.line), yyscanner); -#else - len = yylex_CPP(buf, max_size); -#endif // ANGLE_USE_NEW_PREPROCESSOR if (len >= max_size) YY_FATAL_ERROR("Input buffer overflow"); @@ -471,9 +338,6 @@ int glslang_finalize(TParseContext* context) { context->scanner = NULL; yylex_destroy(scanner); -#if !ANGLE_USE_NEW_PREPROCESSOR - FinalizePreprocessor(); -#endif return 0; } @@ -484,27 +348,14 @@ int glslang_scan(int count, const char* const string[], const int length[], context->AfterEOF = false; // Initialize preprocessor. -#if ANGLE_USE_NEW_PREPROCESSOR if (!context->preprocessor.init(count, string, length)) return 1; -#else - if (InitPreprocessor()) - return 1; - cpp->pC = context; - cpp->pastFirstStatement = 0; - if (InitScannerInput(cpp, count, string, length)) - return 1; -#endif // ANGLE_USE_NEW_PREPROCESSOR // Define extension macros. const TExtensionBehavior& extBehavior = context->extensionBehavior(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); iter != extBehavior.end(); ++iter) { -#if ANGLE_USE_NEW_PREPROCESSOR context->preprocessor.predefineMacro(iter->first.c_str(), 1); -#else - PredefineIntMacro(iter->first.c_str(), 1); -#endif } return 0; } diff --git a/gfx/angle/src/compiler/glslang.y b/gfx/angle/src/compiler/glslang.y index 081a6990981a..39c9cee26ea1 100644 --- a/gfx/angle/src/compiler/glslang.y +++ b/gfx/angle/src/compiler/glslang.y @@ -1200,7 +1200,7 @@ init_declarator_list if (context->structQualifierErrorCheck($3.line, $$.type)) context->recover(); - if (context->nonInitConstErrorCheck($3.line, *$3.string, $$.type)) + if (context->nonInitConstErrorCheck($3.line, *$3.string, $$.type, false)) context->recover(); TVariable* variable = 0; @@ -1213,7 +1213,7 @@ init_declarator_list if (context->structQualifierErrorCheck($3.line, $1.type)) context->recover(); - if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type)) + if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type, true)) context->recover(); $$ = $1; @@ -1231,7 +1231,7 @@ init_declarator_list if (context->structQualifierErrorCheck($3.line, $1.type)) context->recover(); - if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type)) + if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type, true)) context->recover(); $$ = $1; @@ -1285,7 +1285,7 @@ single_declaration if (context->structQualifierErrorCheck($2.line, $$.type)) context->recover(); - if (context->nonInitConstErrorCheck($2.line, *$2.string, $$.type)) + if (context->nonInitConstErrorCheck($2.line, *$2.string, $$.type, false)) context->recover(); $$.type = $1; @@ -1316,7 +1316,7 @@ single_declaration if (context->structQualifierErrorCheck($2.line, $1)) context->recover(); - if (context->nonInitConstErrorCheck($2.line, *$2.string, $1)) + if (context->nonInitConstErrorCheck($2.line, *$2.string, $1, true)) context->recover(); $$.type = $1; diff --git a/gfx/angle/src/compiler/glslang_lex.cpp b/gfx/angle/src/compiler/glslang_lex.cpp index 175b6ba6b316..66ae97e83660 100644 --- a/gfx/angle/src/compiler/glslang_lex.cpp +++ b/gfx/angle/src/compiler/glslang_lex.cpp @@ -807,7 +807,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). #include "compiler/glslang.h" #include "compiler/ParseHelper.h" -#include "compiler/preprocessor/new/Token.h" +#include "compiler/preprocessor/Token.h" #include "compiler/util.h" #include "glslang_tab.h" @@ -2948,146 +2948,13 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -// Old preprocessor interface. -extern "C" { -#include "compiler/preprocessor/preprocess.h" - -extern int InitPreprocessor(); -extern int FinalizePreprocessor(); -extern void PredefineIntMacro(const char *name, int value); - -#define SETUP_CONTEXT(pp) \ - TParseContext* context = (TParseContext*) pp->pC; \ - struct yyguts_t* yyg = (struct yyguts_t*) context->scanner; - -// Preprocessor callbacks. -void CPPDebugLogMsg(const char *msg) -{ - SETUP_CONTEXT(cpp); - context->trace(msg); -} - -void CPPWarningToInfoLog(const char *msg) -{ - SETUP_CONTEXT(cpp); - context->warning(yylineno, msg, ""); -} - -void CPPShInfoLogMsg(const char *msg) -{ - SETUP_CONTEXT(cpp); - context->error(yylineno, msg, ""); - context->recover(); -} - -void CPPErrorToInfoLog(const char *msg) -{ - SETUP_CONTEXT(cpp); - context->error(yylineno, msg, ""); - context->recover(); -} - -void SetLineNumber(int line) -{ - SETUP_CONTEXT(cpp); - int string = 0; - DecodeSourceLoc(yylineno, &string, NULL); - yylineno = EncodeSourceLoc(string, line); -} - -void SetStringNumber(int string) -{ - SETUP_CONTEXT(cpp); - int line = 0; - DecodeSourceLoc(yylineno, NULL, &line); - yylineno = EncodeSourceLoc(string, line); -} - -int GetStringNumber() -{ - SETUP_CONTEXT(cpp); - int string = 0; - DecodeSourceLoc(yylineno, &string, NULL); - return string; -} - -int GetLineNumber() -{ - SETUP_CONTEXT(cpp); - int line = 0; - DecodeSourceLoc(yylineno, NULL, &line); - return line; -} - -void IncLineNumber() -{ - SETUP_CONTEXT(cpp); - int string = 0, line = 0; - DecodeSourceLoc(yylineno, &string, &line); - yylineno = EncodeSourceLoc(string, ++line); -} - -void DecLineNumber() -{ - SETUP_CONTEXT(cpp); - int string = 0, line = 0; - DecodeSourceLoc(yylineno, &string, &line); - yylineno = EncodeSourceLoc(string, --line); -} - -void HandlePragma(const char **tokens, int numTokens) -{ - SETUP_CONTEXT(cpp); - - if (numTokens != 4) return; - if (strcmp(tokens[1], "(") != 0) return; - if (strcmp(tokens[3], ")") != 0) return; - - context->handlePragmaDirective(yylineno, tokens[0], tokens[2]); -} - -void StoreStr(const char *string) -{ - SETUP_CONTEXT(cpp); - TString strSrc; - strSrc = TString(string); - - context->HashErrMsg = context->HashErrMsg + " " + strSrc; -} - -const char* GetStrfromTStr(void) -{ - SETUP_CONTEXT(cpp); - cpp->ErrMsg = context->HashErrMsg.c_str(); - return cpp->ErrMsg; -} - -void ResetTString(void) -{ - SETUP_CONTEXT(cpp); - context->HashErrMsg = ""; -} - -void updateExtensionBehavior(const char* extName, const char* behavior) -{ - SETUP_CONTEXT(cpp); - context->handleExtensionDirective(yylineno, extName, behavior); -} -} // extern "C" - int string_input(char* buf, int max_size, yyscan_t yyscanner) { - int len = 0; - -#if ANGLE_USE_NEW_PREPROCESSOR pp::Token token; yyget_extra(yyscanner)->preprocessor.lex(&token); - len = token.type == pp::Token::LAST ? 0 : token.text.size(); + int len = token.type == pp::Token::LAST ? 0 : token.text.size(); if ((len > 0) && (len < max_size)) memcpy(buf, token.text.c_str(), len); yyset_lineno(EncodeSourceLoc(token.location.file, token.location.line),yyscanner); -#else - len = yylex_CPP(buf, max_size); -#endif // ANGLE_USE_NEW_PREPROCESSOR if (len >= max_size) YY_FATAL_ERROR("Input buffer overflow"); @@ -3147,9 +3014,6 @@ int glslang_finalize(TParseContext* context) { context->scanner = NULL; yylex_destroy(scanner); -#if !ANGLE_USE_NEW_PREPROCESSOR - FinalizePreprocessor(); -#endif return 0; } @@ -3160,27 +3024,14 @@ int glslang_scan(int count, const char* const string[], const int length[], context->AfterEOF = false; // Initialize preprocessor. -#if ANGLE_USE_NEW_PREPROCESSOR if (!context->preprocessor.init(count, string, length)) return 1; -#else - if (InitPreprocessor()) - return 1; - cpp->pC = context; - cpp->pastFirstStatement = 0; - if (InitScannerInput(cpp, count, string, length)) - return 1; -#endif // ANGLE_USE_NEW_PREPROCESSOR // Define extension macros. const TExtensionBehavior& extBehavior = context->extensionBehavior(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); iter != extBehavior.end(); ++iter) { -#if ANGLE_USE_NEW_PREPROCESSOR context->preprocessor.predefineMacro(iter->first.c_str(), 1); -#else - PredefineIntMacro(iter->first.c_str(), 1); -#endif } return 0; } diff --git a/gfx/angle/src/compiler/glslang_tab.cpp b/gfx/angle/src/compiler/glslang_tab.cpp index 2de25dfbd42c..046b40f16dac 100644 --- a/gfx/angle/src/compiler/glslang_tab.cpp +++ b/gfx/angle/src/compiler/glslang_tab.cpp @@ -3333,7 +3333,7 @@ yyreduce: if (context->structQualifierErrorCheck((yyvsp[(3) - (3)].lex).line, (yyval.interm).type)) context->recover(); - if (context->nonInitConstErrorCheck((yyvsp[(3) - (3)].lex).line, *(yyvsp[(3) - (3)].lex).string, (yyval.interm).type)) + if (context->nonInitConstErrorCheck((yyvsp[(3) - (3)].lex).line, *(yyvsp[(3) - (3)].lex).string, (yyval.interm).type, false)) context->recover(); TVariable* variable = 0; @@ -3350,7 +3350,7 @@ yyreduce: if (context->structQualifierErrorCheck((yyvsp[(3) - (5)].lex).line, (yyvsp[(1) - (5)].interm).type)) context->recover(); - if (context->nonInitConstErrorCheck((yyvsp[(3) - (5)].lex).line, *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type)) + if (context->nonInitConstErrorCheck((yyvsp[(3) - (5)].lex).line, *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type, true)) context->recover(); (yyval.interm) = (yyvsp[(1) - (5)].interm); @@ -3372,7 +3372,7 @@ yyreduce: if (context->structQualifierErrorCheck((yyvsp[(3) - (6)].lex).line, (yyvsp[(1) - (6)].interm).type)) context->recover(); - if (context->nonInitConstErrorCheck((yyvsp[(3) - (6)].lex).line, *(yyvsp[(3) - (6)].lex).string, (yyvsp[(1) - (6)].interm).type)) + if (context->nonInitConstErrorCheck((yyvsp[(3) - (6)].lex).line, *(yyvsp[(3) - (6)].lex).string, (yyvsp[(1) - (6)].interm).type, true)) context->recover(); (yyval.interm) = (yyvsp[(1) - (6)].interm); @@ -3435,7 +3435,7 @@ yyreduce: if (context->structQualifierErrorCheck((yyvsp[(2) - (2)].lex).line, (yyval.interm).type)) context->recover(); - if (context->nonInitConstErrorCheck((yyvsp[(2) - (2)].lex).line, *(yyvsp[(2) - (2)].lex).string, (yyval.interm).type)) + if (context->nonInitConstErrorCheck((yyvsp[(2) - (2)].lex).line, *(yyvsp[(2) - (2)].lex).string, (yyval.interm).type, false)) context->recover(); (yyval.interm).type = (yyvsp[(1) - (2)].interm.type); @@ -3474,7 +3474,7 @@ yyreduce: if (context->structQualifierErrorCheck((yyvsp[(2) - (5)].lex).line, (yyvsp[(1) - (5)].interm.type))) context->recover(); - if (context->nonInitConstErrorCheck((yyvsp[(2) - (5)].lex).line, *(yyvsp[(2) - (5)].lex).string, (yyvsp[(1) - (5)].interm.type))) + if (context->nonInitConstErrorCheck((yyvsp[(2) - (5)].lex).line, *(yyvsp[(2) - (5)].lex).string, (yyvsp[(1) - (5)].interm.type), true)) context->recover(); (yyval.interm).type = (yyvsp[(1) - (5)].interm.type); diff --git a/gfx/angle/src/compiler/intermediate.h b/gfx/angle/src/compiler/intermediate.h index af78fa00ef57..293db94b0463 100644 --- a/gfx/angle/src/compiler/intermediate.h +++ b/gfx/angle/src/compiler/intermediate.h @@ -16,6 +16,8 @@ #ifndef __INTERMEDIATE_H #define __INTERMEDIATE_H +#include "GLSLANG/ShaderLang.h" + #include "compiler/Common.h" #include "compiler/Types.h" #include "compiler/ConstantUnion.h" @@ -545,6 +547,10 @@ public: void incrementDepth() {depth++;} void decrementDepth() {depth--;} + // Return the original name if hash function pointer is NULL; + // otherwise return the hashed name. + static TString hash(const TString& name, ShHashFunction64 hashFunction); + const bool preVisit; const bool inVisit; const bool postVisit; diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h index fc0f9dd66eed..6912de22db27 100644 --- a/gfx/angle/src/compiler/osinclude.h +++ b/gfx/angle/src/compiler/osinclude.h @@ -24,9 +24,7 @@ #error Unsupported platform. #endif -#if defined(ANGLE_USE_NSPR) -#include "prthread.h" -#elif defined(ANGLE_OS_WIN) +#if defined(ANGLE_OS_WIN) #define STRICT #define VC_EXTRALEAN 1 #include @@ -34,24 +32,21 @@ #include #include #include -#endif // ANGLE_USE_NSPR +#endif // ANGLE_OS_WIN -#include "compiler/compilerdebug.h" +#include "compiler/compiler_debug.h" // // Thread Local Storage Operations // -#if defined(ANGLE_USE_NSPR) -typedef unsigned OS_TLSIndex; -#define OS_INVALID_TLS_INDEX 0xFFFFFFFF -#elif defined(ANGLE_OS_WIN) +#if defined(ANGLE_OS_WIN) typedef DWORD OS_TLSIndex; #define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES) #elif defined(ANGLE_OS_POSIX) typedef unsigned int OS_TLSIndex; #define OS_INVALID_TLS_INDEX 0xFFFFFFFF -#endif // ANGLE_USE_NSPR +#endif // ANGLE_OS_WIN OS_TLSIndex OS_AllocTLSIndex(); bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue); @@ -60,9 +55,7 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex); inline void* OS_GetTLSValue(OS_TLSIndex nIndex) { ASSERT(nIndex != OS_INVALID_TLS_INDEX); -#if defined(ANGLE_USE_NSPR) - return PR_GetThreadPrivate(nIndex); -#elif defined(ANGLE_OS_WIN) +#if defined(ANGLE_OS_WIN) return TlsGetValue(nIndex); #elif defined(ANGLE_OS_POSIX) return pthread_getspecific(nIndex); diff --git a/gfx/angle/src/compiler/ossource_nspr.cpp b/gfx/angle/src/compiler/ossource_nspr.cpp index 9e08fec4cf9a..e69de29bb2d1 100644 --- a/gfx/angle/src/compiler/ossource_nspr.cpp +++ b/gfx/angle/src/compiler/ossource_nspr.cpp @@ -1,43 +0,0 @@ -// -// Copyright (c) 2002-2010 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 file contains the nspr specific functions -// -#include "compiler/osinclude.h" - -// -// Thread Local Storage Operations -// -OS_TLSIndex OS_AllocTLSIndex() -{ - unsigned index; - PRStatus status = PR_NewThreadPrivateIndex(&index, NULL); - - if (status) { - assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage"); - return OS_INVALID_TLS_INDEX; - } - - return index; -} - -bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue) -{ - if (nIndex == OS_INVALID_TLS_INDEX) { - assert(0 && "OS_SetTLSValue(): Invalid TLS Index"); - return false; - } - - return PR_SetThreadPrivate(nIndex, lpvValue) == 0; -} - -bool OS_FreeTLSIndex(OS_TLSIndex nIndex) -{ - // Can't delete TLS keys with nspr - return true; -} - diff --git a/gfx/angle/src/compiler/preprocessor/new/Diagnostics.h b/gfx/angle/src/compiler/preprocessor/Diagnostics.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Diagnostics.h rename to gfx/angle/src/compiler/preprocessor/Diagnostics.h diff --git a/gfx/angle/src/compiler/preprocessor/new/DirectiveHandler.h b/gfx/angle/src/compiler/preprocessor/DirectiveHandler.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/DirectiveHandler.h rename to gfx/angle/src/compiler/preprocessor/DirectiveHandler.h diff --git a/gfx/angle/src/compiler/preprocessor/new/DirectiveParser.cpp b/gfx/angle/src/compiler/preprocessor/DirectiveParser.cpp similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/DirectiveParser.cpp rename to gfx/angle/src/compiler/preprocessor/DirectiveParser.cpp diff --git a/gfx/angle/src/compiler/preprocessor/new/DirectiveParser.h b/gfx/angle/src/compiler/preprocessor/DirectiveParser.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/DirectiveParser.h rename to gfx/angle/src/compiler/preprocessor/DirectiveParser.h diff --git a/gfx/angle/src/compiler/preprocessor/new/ExpressionParser.cpp b/gfx/angle/src/compiler/preprocessor/ExpressionParser.cpp similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/ExpressionParser.cpp rename to gfx/angle/src/compiler/preprocessor/ExpressionParser.cpp diff --git a/gfx/angle/src/compiler/preprocessor/new/ExpressionParser.h b/gfx/angle/src/compiler/preprocessor/ExpressionParser.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/ExpressionParser.h rename to gfx/angle/src/compiler/preprocessor/ExpressionParser.h diff --git a/gfx/angle/src/compiler/preprocessor/new/ExpressionParser.y b/gfx/angle/src/compiler/preprocessor/ExpressionParser.y similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/ExpressionParser.y rename to gfx/angle/src/compiler/preprocessor/ExpressionParser.y diff --git a/gfx/angle/src/compiler/preprocessor/new/Input.cpp b/gfx/angle/src/compiler/preprocessor/Input.cpp similarity index 88% rename from gfx/angle/src/compiler/preprocessor/new/Input.cpp rename to gfx/angle/src/compiler/preprocessor/Input.cpp index c3de95f313d5..11868c1cd5b9 100644 --- a/gfx/angle/src/compiler/preprocessor/new/Input.cpp +++ b/gfx/angle/src/compiler/preprocessor/Input.cpp @@ -26,7 +26,7 @@ Input::Input(int count, const char* const string[], const int length[]) : for (int i = 0; i < mCount; ++i) { int len = length ? length[i] : -1; - mLength.push_back(len < 0 ? strlen(mString[i]) : len); + mLength.push_back(len < 0 ? std::strlen(mString[i]) : len); } } @@ -37,7 +37,7 @@ int Input::read(char* buf, int maxSize) { int size = mLength[mReadLoc.sIndex] - mReadLoc.cIndex; size = std::min(size, maxSize); - memcpy(buf + nRead, mString[mReadLoc.sIndex] + mReadLoc.cIndex, size); + std::memcpy(buf + nRead, mString[mReadLoc.sIndex] + mReadLoc.cIndex, size); nRead += size; mReadLoc.cIndex += size; diff --git a/gfx/angle/src/compiler/preprocessor/new/Input.h b/gfx/angle/src/compiler/preprocessor/Input.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Input.h rename to gfx/angle/src/compiler/preprocessor/Input.h diff --git a/gfx/angle/src/compiler/preprocessor/new/Lexer.cpp b/gfx/angle/src/compiler/preprocessor/Lexer.cpp similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Lexer.cpp rename to gfx/angle/src/compiler/preprocessor/Lexer.cpp diff --git a/gfx/angle/src/compiler/preprocessor/new/Lexer.h b/gfx/angle/src/compiler/preprocessor/Lexer.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Lexer.h rename to gfx/angle/src/compiler/preprocessor/Lexer.h diff --git a/gfx/angle/src/compiler/preprocessor/new/Macro.cpp b/gfx/angle/src/compiler/preprocessor/Macro.cpp similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Macro.cpp rename to gfx/angle/src/compiler/preprocessor/Macro.cpp diff --git a/gfx/angle/src/compiler/preprocessor/new/Macro.h b/gfx/angle/src/compiler/preprocessor/Macro.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Macro.h rename to gfx/angle/src/compiler/preprocessor/Macro.h diff --git a/gfx/angle/src/compiler/preprocessor/new/MacroExpander.cpp b/gfx/angle/src/compiler/preprocessor/MacroExpander.cpp similarity index 96% rename from gfx/angle/src/compiler/preprocessor/new/MacroExpander.cpp rename to gfx/angle/src/compiler/preprocessor/MacroExpander.cpp index 701cec9a4b88..086cd786c52e 100644 --- a/gfx/angle/src/compiler/preprocessor/new/MacroExpander.cpp +++ b/gfx/angle/src/compiler/preprocessor/MacroExpander.cpp @@ -57,7 +57,7 @@ MacroExpander::MacroExpander(Lexer* lexer, MacroExpander::~MacroExpander() { - for (size_t i = 0; i < mContextStack.size(); ++i) + for (std::size_t i = 0; i < mContextStack.size(); ++i) { delete mContextStack[i]; } @@ -224,7 +224,7 @@ bool MacroExpander::expandMacro(const Macro& macro, replaceMacroParams(macro, args, replacements); } - for (size_t i = 0; i < replacements->size(); ++i) + for (std::size_t i = 0; i < replacements->size(); ++i) { Token& repl = replacements->at(i); if (i == 0) @@ -311,7 +311,7 @@ bool MacroExpander::collectMacroArgs(const Macro& macro, // Pre-expand each argument before substitution. // This step expands each argument individually before they are // inserted into the macro body. - for (size_t i = 0; i < args->size(); ++i) + for (std::size_t i = 0; i < args->size(); ++i) { MacroArg& arg = args->at(i); TokenLexer lexer(&arg); @@ -332,7 +332,7 @@ void MacroExpander::replaceMacroParams(const Macro& macro, const std::vector& args, std::vector* replacements) { - for (size_t i = 0; i < macro.replacements.size(); ++i) + for (std::size_t i = 0; i < macro.replacements.size(); ++i) { const Token& repl = macro.replacements[i]; if (repl.type != Token::IDENTIFIER) @@ -352,13 +352,13 @@ void MacroExpander::replaceMacroParams(const Macro& macro, continue; } - size_t iArg = std::distance(macro.parameters.begin(), iter); + std::size_t iArg = std::distance(macro.parameters.begin(), iter); const MacroArg& arg = args[iArg]; if (arg.empty()) { continue; } - size_t iRepl = replacements->size(); + std::size_t iRepl = replacements->size(); replacements->insert(replacements->end(), arg.begin(), arg.end()); // The replacement token inherits padding properties from // macro replacement token. diff --git a/gfx/angle/src/compiler/preprocessor/new/MacroExpander.h b/gfx/angle/src/compiler/preprocessor/MacroExpander.h similarity index 98% rename from gfx/angle/src/compiler/preprocessor/new/MacroExpander.h rename to gfx/angle/src/compiler/preprocessor/MacroExpander.h index 7c5c543871c5..21b67571f196 100644 --- a/gfx/angle/src/compiler/preprocessor/new/MacroExpander.h +++ b/gfx/angle/src/compiler/preprocessor/MacroExpander.h @@ -53,7 +53,7 @@ class MacroExpander : public Lexer struct MacroContext { const Macro* macro; - size_t index; + std::size_t index; std::vector replacements; MacroContext() : macro(0), index(0) { } diff --git a/gfx/angle/src/compiler/preprocessor/new/Preprocessor.cpp b/gfx/angle/src/compiler/preprocessor/Preprocessor.cpp similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Preprocessor.cpp rename to gfx/angle/src/compiler/preprocessor/Preprocessor.cpp diff --git a/gfx/angle/src/compiler/preprocessor/new/Preprocessor.h b/gfx/angle/src/compiler/preprocessor/Preprocessor.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Preprocessor.h rename to gfx/angle/src/compiler/preprocessor/Preprocessor.h diff --git a/gfx/angle/src/compiler/preprocessor/new/PreprocessorDiagnostics.cpp b/gfx/angle/src/compiler/preprocessor/PreprocessorDiagnostics.cpp similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/PreprocessorDiagnostics.cpp rename to gfx/angle/src/compiler/preprocessor/PreprocessorDiagnostics.cpp diff --git a/gfx/angle/src/compiler/preprocessor/new/PreprocessorDirectiveHandler.cpp b/gfx/angle/src/compiler/preprocessor/PreprocessorDirectiveHandler.cpp similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/PreprocessorDirectiveHandler.cpp rename to gfx/angle/src/compiler/preprocessor/PreprocessorDirectiveHandler.cpp diff --git a/gfx/angle/src/compiler/preprocessor/new/SourceLocation.h b/gfx/angle/src/compiler/preprocessor/SourceLocation.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/SourceLocation.h rename to gfx/angle/src/compiler/preprocessor/SourceLocation.h diff --git a/gfx/angle/src/compiler/preprocessor/new/Token.cpp b/gfx/angle/src/compiler/preprocessor/Token.cpp similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Token.cpp rename to gfx/angle/src/compiler/preprocessor/Token.cpp diff --git a/gfx/angle/src/compiler/preprocessor/new/Token.h b/gfx/angle/src/compiler/preprocessor/Token.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Token.h rename to gfx/angle/src/compiler/preprocessor/Token.h diff --git a/gfx/angle/src/compiler/preprocessor/new/Tokenizer.cpp b/gfx/angle/src/compiler/preprocessor/Tokenizer.cpp similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Tokenizer.cpp rename to gfx/angle/src/compiler/preprocessor/Tokenizer.cpp diff --git a/gfx/angle/src/compiler/preprocessor/new/Tokenizer.h b/gfx/angle/src/compiler/preprocessor/Tokenizer.h similarity index 96% rename from gfx/angle/src/compiler/preprocessor/new/Tokenizer.h rename to gfx/angle/src/compiler/preprocessor/Tokenizer.h index a594d2d865c9..c603135fc77d 100644 --- a/gfx/angle/src/compiler/preprocessor/new/Tokenizer.h +++ b/gfx/angle/src/compiler/preprocessor/Tokenizer.h @@ -32,7 +32,7 @@ class Tokenizer : public Lexer bool leadingSpace; bool lineStart; }; - static const size_t kMaxTokenLength; + static const std::size_t kMaxTokenLength; Tokenizer(Diagnostics* diagnostics); ~Tokenizer(); diff --git a/gfx/angle/src/compiler/preprocessor/new/Tokenizer.l b/gfx/angle/src/compiler/preprocessor/Tokenizer.l similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/Tokenizer.l rename to gfx/angle/src/compiler/preprocessor/Tokenizer.l diff --git a/gfx/angle/src/compiler/preprocessor/atom.c b/gfx/angle/src/compiler/preprocessor/atom.c deleted file mode 100644 index 2ddce69a1587..000000000000 --- a/gfx/angle/src/compiler/preprocessor/atom.c +++ /dev/null @@ -1,732 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ - -// -// atom.c -// - -#include -#include -#include - -#include "common/angleutils.h" -#include "compiler/compilerdebug.h" -#include "compiler/preprocessor/slglobals.h" - -#undef malloc -#undef realloc -#undef free - -/////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////// String table: ////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - -static const struct { - int val; - const char *str; -} tokens[] = { - { CPP_AND_OP, "&&" }, - { CPP_AND_ASSIGN, "&=" }, - { CPP_SUB_ASSIGN, "-=" }, - { CPP_MOD_ASSIGN, "%=" }, - { CPP_ADD_ASSIGN, "+=" }, - { CPP_DIV_ASSIGN, "/=" }, - { CPP_MUL_ASSIGN, "*=" }, - { CPP_RIGHT_BRACKET, ":>" }, - { CPP_EQ_OP, "==" }, - { CPP_XOR_OP, "^^" }, - { CPP_XOR_ASSIGN, "^=" }, - { CPP_FLOATCONSTANT, "" }, - { CPP_GE_OP, ">=" }, - { CPP_RIGHT_OP, ">>" }, - { CPP_RIGHT_ASSIGN, ">>=" }, - { CPP_IDENTIFIER, "" }, - { CPP_INTCONSTANT, "" }, - { CPP_LE_OP, "<=" }, - { CPP_LEFT_OP, "<<" }, - { CPP_LEFT_ASSIGN, "<<=" }, - { CPP_LEFT_BRACKET, "<:" }, - { CPP_LEFT_BRACE, "<%" }, - { CPP_DEC_OP, "--" }, - { CPP_RIGHT_BRACE, "%>" }, - { CPP_NE_OP, "!=" }, - { CPP_OR_OP, "||" }, - { CPP_OR_ASSIGN, "|=" }, - { CPP_INC_OP, "++" }, - { CPP_STRCONSTANT, "" }, - { CPP_TYPEIDENTIFIER, "" }, -}; - -/////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////// String table: ////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - -#define INIT_STRING_TABLE_SIZE 16384 - -typedef struct StringTable_Rec { - char *strings; - int nextFree; - int size; -} StringTable; - -/* - * InitStringTable() - Initialize the string table. - * - */ - -static int InitStringTable(StringTable *stable) -{ - stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE); - if (!stable->strings) - return 0; - // Zero-th offset means "empty" so don't use it. - stable->nextFree = 1; - stable->size = INIT_STRING_TABLE_SIZE; - return 1; -} // InitStringTable - -/* - * FreeStringTable() - Free the string table. - * - */ - -static void FreeStringTable(StringTable *stable) -{ - if (stable->strings) - free(stable->strings); - stable->strings = NULL; - stable->nextFree = 0; - stable->size = 0; -} // FreeStringTable - -/* - * HashString() - Hash a string with the base hash function. - * - */ - -static int HashString(const char *s) -{ - int hval = 0; - - while (*s) { - hval = (hval*13507 + *s*197) ^ (hval >> 2); - s++; - } - return hval & 0x7fffffff; -} // HashString - -/* - * HashString2() - Hash a string with the incrimenting hash function. - * - */ - -static int HashString2(const char *s) -{ - int hval = 0; - - while (*s) { - hval = (hval*729 + *s*37) ^ (hval >> 1); - s++; - } - return hval; -} // HashString2 - -/* - * AddString() - Add a string to a string table. Return it's offset. - * - */ - -static int AddString(StringTable *stable, const char *s) -{ - int len, loc; - char *str; - - len = (int) strlen(s); - while (stable->nextFree + len + 1 >= stable->size) { - assert(stable->size < 1000000); - str = (char *) malloc(stable->size*2); - memcpy(str, stable->strings, stable->size); - free(stable->strings); - stable->strings = str; - stable->size = stable->size*2; - } - loc = stable->nextFree; - strcpy(&stable->strings[loc], s); - stable->nextFree += len + 1; - return loc; -} // AddString - -/////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////// Hash table: /////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - -#define INIT_HASH_TABLE_SIZE 2047 -#define HASH_TABLE_MAX_COLLISIONS 3 - -typedef struct HashEntry_Rec { - int index; // String table offset of string representation - int value; // Atom (symbol) value -} HashEntry; - -typedef struct HashTable_Rec { - HashEntry *entry; - int size; - int entries; - int counts[HASH_TABLE_MAX_COLLISIONS + 1]; -} HashTable; - -/* - * InitHashTable() - Initialize the hash table. - * - */ - -static int InitHashTable(HashTable *htable, int fsize) -{ - int ii; - - htable->entry = (HashEntry *) malloc(sizeof(HashEntry)*fsize); - if (!htable->entry) - return 0; - htable->size = fsize; - for (ii = 0; ii < fsize; ii++) { - htable->entry[ii].index = 0; - htable->entry[ii].value = 0; - } - htable->entries = 0; - for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) - htable->counts[ii] = 0; - return 1; -} // InitHashTable - -/* - * FreeHashTable() - Free the hash table. - * - */ - -static void FreeHashTable(HashTable *htable) -{ - if (htable->entry) - free(htable->entry); - htable->entry = NULL; - htable->size = 0; - htable->entries = 0; -} // FreeHashTable - -/* - * Empty() - See if a hash table entry is empty. - * - */ - -static int Empty(HashTable *htable, int hashloc) -{ - assert(hashloc >= 0 && hashloc < htable->size); - if (htable->entry[hashloc].index == 0) { - return 1; - } else { - return 0; - } -} // Empty - -/* - * Match() - See if a hash table entry is matches a string. - * - */ - -static int Match(HashTable *htable, StringTable *stable, const char *s, int hashloc) -{ - int strloc; - - strloc = htable->entry[hashloc].index; - if (!strcmp(s, &stable->strings[strloc])) { - return 1; - } else { - return 0; - } -} // Match - -/////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////// Atom table: /////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - -#define INIT_ATOM_TABLE_SIZE 1024 - - -struct AtomTable_Rec { - StringTable stable; // String table. - HashTable htable; // Hashes string to atom number and token value. Multiple strings can - // have the same token value but each unique string is a unique atom. - int *amap; // Maps atom value to offset in string table. Atoms all map to unique - // strings except for some undefined values in the lower, fixed part - // of the atom table that map to "". The lowest 256 atoms - // correspond to single character ASCII values except for alphanumeric - // characters and '_', which can be other tokens. Next come the - // language tokens with their atom values equal to the token value. - // Then come predefined atoms, followed by user specified identifiers. - int *arev; // Reversed atom for symbol table use. - int nextFree; - int size; -}; - -static AtomTable latable = { { NULL, 0, 0 }, { NULL, 0, 0, {0} }, NULL, NULL, 0, 0 }; -AtomTable *atable = &latable; - -static int AddAtomFixed(AtomTable *atable, const char *s, int atom); - -/* - * GrowAtomTable() - Grow the atom table to at least "size" if it's smaller. - * - */ - -static int GrowAtomTable(AtomTable *atable, int size) -{ - int *newmap, *newrev; - - if (atable->size < size) { - if (atable->amap) { - newmap = realloc(atable->amap, sizeof(int)*size); - newrev = realloc(atable->arev, sizeof(int)*size); - } else { - newmap = malloc(sizeof(int)*size); - newrev = malloc(sizeof(int)*size); - atable->size = 0; - } - if (!newmap || !newrev) { - abort(); - } - memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int)); - memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int)); - atable->amap = newmap; - atable->arev = newrev; - atable->size = size; - } - return 0; -} // GrowAtomTable - -/* - * lReverse() - Reverse the bottom 20 bits of a 32 bit int. - * - */ - -static int lReverse(int fval) -{ - unsigned int in = fval; - int result = 0, cnt = 0; - - while(in) { - result <<= 1; - result |= in&1; - in >>= 1; - cnt++; - } - - // Don't use all 31 bits. One million atoms is plenty and sometimes the - // upper bits are used for other things. - - if (cnt < 20) - result <<= 20 - cnt; - return result; -} // lReverse - -/* - * AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1. - * - */ - -static int AllocateAtom(AtomTable *atable) -{ - if (atable->nextFree >= atable->size) - GrowAtomTable(atable, atable->nextFree*2); - atable->amap[atable->nextFree] = -1; - atable->arev[atable->nextFree] = lReverse(atable->nextFree); - atable->nextFree++; - return atable->nextFree - 1; -} // AllocateAtom - -/* - * SetAtomValue() - Allocate a new atom associated with "hashindex". - * - */ - -static void SetAtomValue(AtomTable *atable, int atomnumber, int hashindex) -{ - atable->amap[atomnumber] = atable->htable.entry[hashindex].index; - atable->htable.entry[hashindex].value = atomnumber; -} // SetAtomValue - -/* - * FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full. - * - */ - -static int FindHashLoc(AtomTable *atable, const char *s) -{ - int hashloc, hashdelta, count; - int FoundEmptySlot = 0; - int collision[HASH_TABLE_MAX_COLLISIONS + 1]; - - hashloc = HashString(s) % atable->htable.size; - if (!Empty(&atable->htable, hashloc)) { - if (Match(&atable->htable, &atable->stable, s, hashloc)) - return hashloc; - collision[0] = hashloc; - hashdelta = HashString2(s); - count = 0; - while (count < HASH_TABLE_MAX_COLLISIONS) { - hashloc = ((hashloc + hashdelta) & 0x7fffffff) % atable->htable.size; - if (!Empty(&atable->htable, hashloc)) { - if (Match(&atable->htable, &atable->stable, s, hashloc)) { - return hashloc; - } - } else { - FoundEmptySlot = 1; - break; - } - count++; - collision[count] = hashloc; - } - - if (!FoundEmptySlot) { - if (cpp->options.DumpAtomTable) { - int ii; - char str[200]; - snprintf(str, sizeof(str), "*** Hash failed with more than %d collisions. Must increase hash table size. ***", - HASH_TABLE_MAX_COLLISIONS); - CPPShInfoLogMsg(str); - - snprintf(str, sizeof(str), "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta); - CPPShInfoLogMsg(str); - for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) { - snprintf(str, sizeof(str), "*** Collides on try %d at hash entry %04x with \"%s\"", - ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value)); - CPPShInfoLogMsg(str); - } - } - return -1; - } else { - atable->htable.counts[count]++; - } - } - return hashloc; -} // FindHashLoc - -/* - * IncreaseHashTableSize() - * - */ - -static int IncreaseHashTableSize(AtomTable *atable) -{ - int ii, strloc, oldhashloc, value, size; - AtomTable oldtable; - char *s; - - // Save the old atom table and create a new one: - - oldtable = *atable; - size = oldtable.htable.size*2 + 1; - if (!InitAtomTable(atable, size)) - return 0; - - // Add all the existing values to the new atom table preserving their atom values: - - for (ii = atable->nextFree; ii < oldtable.nextFree; ii++) { - strloc = oldtable.amap[ii]; - s = &oldtable.stable.strings[strloc]; - oldhashloc = FindHashLoc(&oldtable, s); - assert(oldhashloc >= 0); - value = oldtable.htable.entry[oldhashloc].value; - AddAtomFixed(atable, s, value); - } - FreeAtomTable(&oldtable); - return 1; -} // IncreaseHashTableSize - -/* - * LookUpAddStringHash() - Lookup a string in the hash table. If it's not there, add it and - * initialize the atom value in the hash table to 0. Return the hash table index. - */ - -static int LookUpAddStringHash(AtomTable *atable, const char *s) -{ - int hashloc, strloc; - - while(1) { - hashloc = FindHashLoc(atable, s); - if (hashloc >= 0) - break; - IncreaseHashTableSize(atable); - } - - if (Empty(&atable->htable, hashloc)) { - atable->htable.entries++; - strloc = AddString(&atable->stable, s); - atable->htable.entry[hashloc].index = strloc; - atable->htable.entry[hashloc].value = 0; - } - return hashloc; -} // LookUpAddStringHash - -/* - * LookUpAddString() - Lookup a string in the hash table. If it's not there, add it and - * initialize the atom value in the hash table to the next atom number. - * Return the atom value of string. - */ - -int LookUpAddString(AtomTable *atable, const char *s) -{ - int hashindex, atom; - - hashindex = LookUpAddStringHash(atable, s); - atom = atable->htable.entry[hashindex].value; - if (atom == 0) { - atom = AllocateAtom(atable); - SetAtomValue(atable, atom, hashindex); - } - return atom; -} // LookUpAddString - -/* - * GetAtomString() - * - */ - -const char *GetAtomString(AtomTable *atable, int atom) -{ - int soffset; - - if (atom > 0 && atom < atable->nextFree) { - soffset = atable->amap[atom]; - if (soffset > 0 && soffset < atable->stable.nextFree) { - return &atable->stable.strings[soffset]; - } else { - return ""; - } - } else { - if (atom == 0) { - return ""; - } else { - if (atom == EOF) { - return ""; - } else { - return ""; - } - } - } -} // GetAtomString - -/* - * GetReversedAtom() - * - */ - -int GetReversedAtom(AtomTable *atable, int atom) -{ - if (atom > 0 && atom < atable->nextFree) { - return atable->arev[atom]; - } else { - return 0; - } -} // GetReversedAtom - -/* - * AddAtom() - Add a string to the atom, hash and string tables if it isn't already there. - * Return it's atom index. - */ - -int AddAtom(AtomTable *atable, const char *s) -{ - int atom; - - atom = LookUpAddString(atable, s); - return atom; -} // AddAtom - -/* - * AddAtomFixed() - Add an atom to the hash and string tables if it isn't already there. - * Assign it the atom value of "atom". - */ - -static int AddAtomFixed(AtomTable *atable, const char *s, int atom) -{ - int hashindex, lsize; - - hashindex = LookUpAddStringHash(atable, s); - if (atable->nextFree >= atable->size || atom >= atable->size) { - lsize = atable->size*2; - if (lsize <= atom) - lsize = atom + 1; - GrowAtomTable(atable, lsize); - } - atable->amap[atom] = atable->htable.entry[hashindex].index; - atable->htable.entry[hashindex].value = atom; - //if (atom >= atable->nextFree) - // atable->nextFree = atom + 1; - while (atom >= atable->nextFree) { - atable->arev[atable->nextFree] = lReverse(atable->nextFree); - atable->nextFree++; - } - return atom; -} // AddAtomFixed - -/* - * InitAtomTable() - Initialize the atom table. - * - */ - -int InitAtomTable(AtomTable *atable, int htsize) -{ - unsigned int ii; - - htsize = htsize <= 0 ? INIT_HASH_TABLE_SIZE : htsize; - if (!InitStringTable(&atable->stable)) - return 0; - if (!InitHashTable(&atable->htable, htsize)) - return 0; - - atable->nextFree = 0; - atable->amap = NULL; - atable->size = 0; - GrowAtomTable(atable, INIT_ATOM_TABLE_SIZE); - if (!atable->amap) - return 0; - - // Initialize lower part of atom table to "" atom: - - AddAtomFixed(atable, "", 0); - for (ii = 0; ii < FIRST_USER_TOKEN_SY; ii++) - atable->amap[ii] = atable->amap[0]; - - // Add single character tokens to the atom table: - - { - const char *s = "~!%^&*()-+=|,.<>/?;:[]{}#"; - char t[2]; - - t[1] = '\0'; - while (*s) { - t[0] = *s; - AddAtomFixed(atable, t, s[0]); - s++; - } - } - - // Add multiple character scanner tokens : - - for (ii = 0; ii < sizeof(tokens)/sizeof(tokens[0]); ii++) - AddAtomFixed(atable, tokens[ii].str, tokens[ii].val); - - // Add error symbol if running in error mode: - - if (cpp->options.ErrorMode) - AddAtomFixed(atable, "error", ERROR_SY); - - AddAtom(atable, "<*** end fixed atoms ***>"); - - return 1; -} // InitAtomTable - -/////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////// Debug Printing Functions: ////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - -/* - * PrintAtomTable() - * - */ - -void PrintAtomTable(AtomTable *atable) -{ - int ii; - char str[200]; - - for (ii = 0; ii < atable->nextFree; ii++) { - snprintf(str, sizeof(str), "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]); - CPPDebugLogMsg(str); - } - snprintf(str, sizeof(str), "Hash table: size=%d, entries=%d, collisions=", - atable->htable.size, atable->htable.entries); - CPPDebugLogMsg(str); - for (ii = 0; ii < HASH_TABLE_MAX_COLLISIONS; ii++) { - snprintf(str, sizeof(str), " %d", atable->htable.counts[ii]); - CPPDebugLogMsg(str); - } - -} // PrintAtomTable - - -/* - * GetStringOfAtom() - * - */ - -char* GetStringOfAtom(AtomTable *atable, int atom) -{ - char* chr_str; - chr_str=&atable->stable.strings[atable->amap[atom]]; - return chr_str; -} // GetStringOfAtom - -/* - * FreeAtomTable() - Free the atom table and associated memory - * - */ - -void FreeAtomTable(AtomTable *atable) -{ - FreeStringTable(&atable->stable); - FreeHashTable(&atable->htable); - if (atable->amap) - free(atable->amap); - if (atable->arev) - free(atable->arev); - atable->amap = NULL; - atable->arev = NULL; - atable->nextFree = 0; - atable->size = 0; -} // FreeAtomTable - -/////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////// End of atom.c /////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - diff --git a/gfx/angle/src/compiler/preprocessor/atom.h b/gfx/angle/src/compiler/preprocessor/atom.h deleted file mode 100644 index 1d84c325155a..000000000000 --- a/gfx/angle/src/compiler/preprocessor/atom.h +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// atom.h -// - -#if !defined(__ATOM_H) -#define __ATOM_H 1 - -typedef struct AtomTable_Rec AtomTable; - -extern AtomTable *atable; - -int InitAtomTable(AtomTable *atable, int htsize); -void FreeAtomTable(AtomTable *atable); -int AddAtom(AtomTable *atable, const char *s); -void PrintAtomTable(AtomTable *atable); -int LookUpAddString(AtomTable *atable, const char *s); -const char *GetAtomString(AtomTable *atable, int atom); -int GetReversedAtom(AtomTable *atable, int atom); -char* GetStringOfAtom(AtomTable *atable, int atom); -#endif // !defined(__ATOM_H) diff --git a/gfx/angle/src/compiler/preprocessor/compile.h b/gfx/angle/src/compiler/preprocessor/compile.h deleted file mode 100644 index 11808531ccb6..000000000000 --- a/gfx/angle/src/compiler/preprocessor/compile.h +++ /dev/null @@ -1,100 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// compile.h -// - -#if !defined(__COMPILE_H) -#define __COMPILE_H 1 - -int InitCPPStruct(void); - -typedef struct Options_Rec{ - const char *profileString; - int ErrorMode; - int Quiet; - - // Debug The Compiler options: - int DumpAtomTable; -} Options; - -#define MAX_IF_NESTING 64 -struct CPPStruct_Rec { - // Public members - SourceLoc *pLastSourceLoc; // Set at the start of each statement by the tree walkers - Options options; // Compile options and parameters - - // Private members - SourceLoc lastSourceLoc; - - // Scanner data: - - SourceLoc *tokenLoc; // Source location of most recent token seen by the scanner - int mostRecentToken; // Most recent token seen by the scanner - InputSrc *currentInput; - int previous_token; - int pastFirstStatement; // used to make sure that #version is the first statement seen in the file, if present - - void *pC; // storing the parseContext of the compile object in cpp. - - // Private members: - SourceLoc ltokenLoc; - int ifdepth; //current #if-#else-#endif nesting in the cpp.c file (pre-processor) - int elsedepth[MAX_IF_NESTING];//Keep a track of #if depth..Max allowed is 64. - int elsetracker; //#if-#else and #endif constructs...Counter. - const char *ErrMsg; - int CompileError; //Indicate compile error when #error, #else,#elif mismatch. - - // - // Globals used to communicate between PaParseStrings() and yy_input()and - // also across the files.(gen_glslang.cpp and scanner.c) - // - int PaWhichStr; // which string we're parsing - const int* PaStrLen; // array of lengths of the PaArgv strings - int PaArgc; // count of strings in the array - const char* const* PaArgv; // our array of strings to parse - unsigned int tokensBeforeEOF : 1; -}; - -#endif // !defined(__COMPILE_H) diff --git a/gfx/angle/src/compiler/preprocessor/cpp.c b/gfx/angle/src/compiler/preprocessor/cpp.c deleted file mode 100644 index 8a1076b9dff3..000000000000 --- a/gfx/angle/src/compiler/preprocessor/cpp.c +++ /dev/null @@ -1,1118 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// cpp.c -// - -#include -#include -#include -#include -#include - -#include "common/angleutils.h" -#include "compiler/preprocessor/slglobals.h" - -#if defined(_MSC_VER) -#pragma warning(disable: 4054) -#pragma warning(disable: 4152) -#pragma warning(disable: 4706) -#endif - -static int CPPif(yystypepp * yylvalpp); - -/* Don't use memory.c's replacements, as we clean up properly here */ -#undef malloc -#undef free - -static int bindAtom = 0; -static int constAtom = 0; -static int defaultAtom = 0; -static int defineAtom = 0; -static int definedAtom = 0; -static int elseAtom = 0; -static int elifAtom = 0; -static int endifAtom = 0; -static int ifAtom = 0; -static int ifdefAtom = 0; -static int ifndefAtom = 0; -static int includeAtom = 0; -static int lineAtom = 0; -static int pragmaAtom = 0; -static int texunitAtom = 0; -static int undefAtom = 0; -static int errorAtom = 0; -static int __LINE__Atom = 0; -static int __FILE__Atom = 0; -static int __VERSION__Atom = 0; -static int versionAtom = 0; -static int extensionAtom = 0; - -static Scope *macros = 0; -#define MAX_MACRO_ARGS 64 - -static SourceLoc ifloc; /* outermost #if */ - -int InitCPP(void) -{ - char buffer[64], *t; - const char *f; - - // Add various atoms needed by the CPP line scanner: - bindAtom = LookUpAddString(atable, "bind"); - constAtom = LookUpAddString(atable, "const"); - defaultAtom = LookUpAddString(atable, "default"); - defineAtom = LookUpAddString(atable, "define"); - definedAtom = LookUpAddString(atable, "defined"); - elifAtom = LookUpAddString(atable, "elif"); - elseAtom = LookUpAddString(atable, "else"); - endifAtom = LookUpAddString(atable, "endif"); - ifAtom = LookUpAddString(atable, "if"); - ifdefAtom = LookUpAddString(atable, "ifdef"); - ifndefAtom = LookUpAddString(atable, "ifndef"); - includeAtom = LookUpAddString(atable, "include"); - lineAtom = LookUpAddString(atable, "line"); - pragmaAtom = LookUpAddString(atable, "pragma"); - texunitAtom = LookUpAddString(atable, "texunit"); - undefAtom = LookUpAddString(atable, "undef"); - errorAtom = LookUpAddString(atable, "error"); - __LINE__Atom = LookUpAddString(atable, "__LINE__"); - __FILE__Atom = LookUpAddString(atable, "__FILE__"); - __VERSION__Atom = LookUpAddString(atable, "__VERSION__"); - versionAtom = LookUpAddString(atable, "version"); - extensionAtom = LookUpAddString(atable, "extension"); - macros = NewScopeInPool(mem_CreatePool(0, 0)); - strcpy(buffer, "PROFILE_"); - t = buffer + strlen(buffer); - f = cpp->options.profileString; - while ((isalnum(*f) || *f == '_') && t < buffer + sizeof(buffer) - 1) - *t++ = toupper(*f++); - *t = 0; - - PredefineIntMacro("GL_ES", 1); - PredefineIntMacro("GL_FRAGMENT_PRECISION_HIGH", 1); - - return 1; -} // InitCPP - -int FreeCPP(void) -{ - if (macros) - { - mem_FreePool(macros->pool); - macros = 0; - } - - return 1; -} - -int FinalCPP(void) -{ - if (cpp->ifdepth) - CPPErrorToInfoLog("#if mismatch"); - return 1; -} - -static int CPPdefine(yystypepp * yylvalpp) -{ - int token, name, args[MAX_MACRO_ARGS], argc; - const char *message; - MacroSymbol mac; - Symbol *symb; - SourceLoc dummyLoc; - memset(&mac, 0, sizeof(mac)); - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token != CPP_IDENTIFIER) { - CPPErrorToInfoLog("#define"); - return token; - } - name = yylvalpp->sc_ident; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token == '(' && !yylvalpp->sc_int) { - // gather arguments - argc = 0; - do { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (argc == 0 && token == ')') break; - if (token != CPP_IDENTIFIER) { - CPPErrorToInfoLog("#define"); - return token; - } - if (argc < MAX_MACRO_ARGS) - args[argc++] = yylvalpp->sc_ident; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } while (token == ','); - if (token != ')') { - CPPErrorToInfoLog("#define"); - return token; - } - mac.argc = argc; - mac.args = mem_Alloc(macros->pool, argc * sizeof(int)); - memcpy(mac.args, args, argc * sizeof(int)); - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } - mac.body = NewTokenStream(GetAtomString(atable, name), macros->pool); - while (token != '\n') { - if (token == '\\') { - CPPErrorToInfoLog("The line continuation character (\\) is not part of the OpenGL ES Shading Language"); - return token; - } else if (token <= 0) { // EOF or error - CPPErrorToInfoLog("unexpected end of input in #define preprocessor directive - expected a newline"); - return 0; - } - RecordToken(mac.body, token, yylvalpp); - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - }; - - symb = LookUpSymbol(macros, name); - if (symb) { - if (!symb->details.mac.undef) { - // already defined -- need to make sure they are identical - if (symb->details.mac.argc != mac.argc) goto error; - for (argc=0; argc < mac.argc; argc++) - if (symb->details.mac.args[argc] != mac.args[argc]) - goto error; - RewindTokenStream(symb->details.mac.body); - RewindTokenStream(mac.body); - do { - int old_lval, old_token; - old_token = ReadToken(symb->details.mac.body, yylvalpp); - old_lval = yylvalpp->sc_int; - token = ReadToken(mac.body, yylvalpp); - if (token != old_token || yylvalpp->sc_int != old_lval) { - error: - StoreStr("Macro Redefined"); - StoreStr(GetStringOfAtom(atable,name)); - message=GetStrfromTStr(); - DecLineNumber(); - CPPShInfoLogMsg(message); - IncLineNumber(); - ResetTString(); - break; } - } while (token > 0); - } - //FreeMacro(&symb->details.mac); - } else { - dummyLoc.file = 0; - dummyLoc.line = 0; - symb = AddSymbol(&dummyLoc, macros, name, MACRO_S); - } - symb->details.mac = mac; - return '\n'; -} // CPPdefine - -static int CPPundef(yystypepp * yylvalpp) -{ - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - Symbol *symb; - if(token == '\n'){ - CPPErrorToInfoLog("#undef"); - return token; - } - if (token != CPP_IDENTIFIER) - goto error; - symb = LookUpSymbol(macros, yylvalpp->sc_ident); - if (symb) { - symb->details.mac.undef = 1; - } - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token != '\n') { - error: - CPPErrorToInfoLog("#undef"); - } - return token; -} // CPPundef - -/* CPPelse -- skip forward to appropriate spot. This is actually used -** to skip to and #endif after seeing an #else, AND to skip to a #else, -** #elif, or #endif after a #if/#ifdef/#ifndef/#elif test was false -*/ - -static int CPPelse(int matchelse, yystypepp * yylvalpp) -{ - int atom,depth=0; - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - - while (token > 0) { - if (token != '#') { - while (token != '\n') { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token <= 0) { // EOF or error - CPPErrorToInfoLog("unexpected end of input in #else preprocessor directive - expected a newline"); - return 0; - } - } - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - continue; - } - if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != CPP_IDENTIFIER) - continue; - atom = yylvalpp->sc_ident; - if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom){ - depth++; cpp->ifdepth++; cpp->elsetracker++; - if (cpp->ifdepth > MAX_IF_NESTING) { - CPPErrorToInfoLog("max #if nesting depth exceeded"); - cpp->CompileError = 1; - return 0; - } - // sanity check elsetracker - if (cpp->elsetracker < 0 || cpp->elsetracker >= MAX_IF_NESTING) { - CPPErrorToInfoLog("mismatched #if/#endif statements"); - cpp->CompileError = 1; - return 0; - } - cpp->elsedepth[cpp->elsetracker] = 0; - } - else if (atom == endifAtom) { - if(--depth<0){ - if (cpp->elsetracker) - --cpp->elsetracker; - if (cpp->ifdepth) - --cpp->ifdepth; - break; - } - --cpp->elsetracker; - --cpp->ifdepth; - } - else if (((int)(matchelse) != 0)&& depth==0) { - if (atom == elseAtom ) { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token != '\n') { - CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline"); - while (token != '\n') { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token <= 0) { // EOF or error - CPPErrorToInfoLog("unexpected end of input following #else preprocessor directive - expected a newline"); - return 0; - } - } - } - break; - } - else if (atom == elifAtom) { - /* we decrement cpp->ifdepth here, because CPPif will increment - * it and we really want to leave it alone */ - if (cpp->ifdepth){ - --cpp->ifdepth; - --cpp->elsetracker; - } - return CPPif(yylvalpp); - } - } - else if((atom==elseAtom) && (!ChkCorrectElseNesting())){ - CPPErrorToInfoLog("#else after a #else"); - cpp->CompileError=1; - return 0; - } - }; - return token; -} - -enum eval_prec { - MIN_PREC, - COND, LOGOR, LOGAND, OR, XOR, AND, EQUAL, RELATION, SHIFT, ADD, MUL, UNARY, - MAX_PREC -}; - -static int op_logor(int a, int b) { return a || b; } -static int op_logand(int a, int b) { return a && b; } -static int op_or(int a, int b) { return a | b; } -static int op_xor(int a, int b) { return a ^ b; } -static int op_and(int a, int b) { return a & b; } -static int op_eq(int a, int b) { return a == b; } -static int op_ne(int a, int b) { return a != b; } -static int op_ge(int a, int b) { return a >= b; } -static int op_le(int a, int b) { return a <= b; } -static int op_gt(int a, int b) { return a > b; } -static int op_lt(int a, int b) { return a < b; } -static int op_shl(int a, int b) { return a << b; } -static int op_shr(int a, int b) { return a >> b; } -static int op_add(int a, int b) { return a + b; } -static int op_sub(int a, int b) { return a - b; } -static int op_mul(int a, int b) { return a * b; } -static int op_div(int a, int b) { return a / b; } -static int op_mod(int a, int b) { return a % b; } -static int op_pos(int a) { return a; } -static int op_neg(int a) { return -a; } -static int op_cmpl(int a) { return ~a; } -static int op_not(int a) { return !a; } - -struct { - int token, prec, (*op)(int, int); -} binop[] = { - { CPP_OR_OP, LOGOR, op_logor }, - { CPP_AND_OP, LOGAND, op_logand }, - { '|', OR, op_or }, - { '^', XOR, op_xor }, - { '&', AND, op_and }, - { CPP_EQ_OP, EQUAL, op_eq }, - { CPP_NE_OP, EQUAL, op_ne }, - { '>', RELATION, op_gt }, - { CPP_GE_OP, RELATION, op_ge }, - { '<', RELATION, op_lt }, - { CPP_LE_OP, RELATION, op_le }, - { CPP_LEFT_OP, SHIFT, op_shl }, - { CPP_RIGHT_OP, SHIFT, op_shr }, - { '+', ADD, op_add }, - { '-', ADD, op_sub }, - { '*', MUL, op_mul }, - { '/', MUL, op_div }, - { '%', MUL, op_mod }, -}; - -struct { - int token, (*op)(int); -} unop[] = { - { '+', op_pos }, - { '-', op_neg }, - { '~', op_cmpl }, - { '!', op_not }, -}; - -#define ALEN(A) (sizeof(A)/sizeof(A[0])) - -static int eval(int token, int prec, int *res, int *err, yystypepp * yylvalpp) -{ - int i, val; - Symbol *s; - if (token == CPP_IDENTIFIER) { - if (yylvalpp->sc_ident == definedAtom) { - int needclose = 0; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token == '(') { - needclose = 1; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } - if (token != CPP_IDENTIFIER) - goto error; - *res = (s = LookUpSymbol(macros, yylvalpp->sc_ident)) - ? !s->details.mac.undef : 0; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (needclose) { - if (token != ')') - goto error; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } - } else if (MacroExpand(yylvalpp->sc_ident, yylvalpp)) { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - return eval(token, prec, res, err, yylvalpp); - } else { - goto error; - } - } else if (token == CPP_INTCONSTANT) { - *res = yylvalpp->sc_int; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } else if (token == '(') { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - token = eval(token, MIN_PREC, res, err, yylvalpp); - if (!*err) { - if (token != ')') - goto error; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } - } else { - for (i = ALEN(unop) - 1; i >= 0; i--) { - if (unop[i].token == token) - break; - } - if (i >= 0) { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - token = eval(token, UNARY, res, err, yylvalpp); - *res = unop[i].op(*res); - } else { - goto error; - } - } - while (!*err) { - if (token == ')' || token == '\n') break; - for (i = ALEN(binop) - 1; i >= 0; i--) { - if (binop[i].token == token) - break; - } - if (i < 0 || binop[i].prec <= prec) - break; - val = *res; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - token = eval(token, binop[i].prec, res, err, yylvalpp); - - if (binop[i].op == op_div || binop[i].op == op_mod) - { - if (*res == 0) - { - CPPErrorToInfoLog("preprocessor divide or modulo by zero"); - *err = 1; - return token; - } - } - - *res = binop[i].op(val, *res); - } - return token; -error: - CPPErrorToInfoLog("incorrect preprocessor directive"); - *err = 1; - *res = 0; - return token; -} // eval - -static int CPPif(yystypepp * yylvalpp) { - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - int res = 0, err = 0; - - if (!cpp->ifdepth++) - ifloc = *cpp->tokenLoc; - if(cpp->ifdepth > MAX_IF_NESTING){ - CPPErrorToInfoLog("max #if nesting depth exceeded"); - cpp->CompileError = 1; - return 0; - } - cpp->elsetracker++; - // sanity check elsetracker - if (cpp->elsetracker < 0 || cpp->elsetracker >= MAX_IF_NESTING) { - CPPErrorToInfoLog("mismatched #if/#endif statements"); - cpp->CompileError = 1; - return 0; - } - cpp->elsedepth[cpp->elsetracker] = 0; - - token = eval(token, MIN_PREC, &res, &err, yylvalpp); - if (token != '\n') { - CPPWarningToInfoLog("unexpected tokens following #if preprocessor directive - expected a newline"); - while (token != '\n') { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token <= 0) { // EOF or error - CPPErrorToInfoLog("unexpected end of input in #if preprocessor directive - expected a newline"); - return 0; - } - } - } - if (!res && !err) { - token = CPPelse(1, yylvalpp); - } - - return token; -} // CPPif - -static int CPPifdef(int defined, yystypepp * yylvalpp) -{ - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - int name = yylvalpp->sc_ident; - if(++cpp->ifdepth > MAX_IF_NESTING){ - CPPErrorToInfoLog("max #if nesting depth exceeded"); - cpp->CompileError = 1; - return 0; - } - cpp->elsetracker++; - // sanity check elsetracker - if (cpp->elsetracker < 0 || cpp->elsetracker >= MAX_IF_NESTING) { - CPPErrorToInfoLog("mismatched #if/#endif statements"); - cpp->CompileError = 1; - return 0; - } - cpp->elsedepth[cpp->elsetracker] = 0; - - if (token != CPP_IDENTIFIER) { - defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef"); - } else { - Symbol *s = LookUpSymbol(macros, name); - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token != '\n') { - CPPWarningToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline"); - while (token != '\n') { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token <= 0) { // EOF or error - CPPErrorToInfoLog("unexpected end of input in #ifdef preprocessor directive - expected a newline"); - return 0; - } - } - } - if (((s && !s->details.mac.undef) ? 1 : 0) != defined) - token = CPPelse(1, yylvalpp); - } - return token; -} // CPPifdef - -static int CPPline(yystypepp * yylvalpp) -{ - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if(token=='\n'){ - DecLineNumber(); - CPPErrorToInfoLog("#line"); - IncLineNumber(); - return token; - } - else if (token == CPP_INTCONSTANT) { - yylvalpp->sc_int=atoi(yylvalpp->symbol_name); - SetLineNumber(yylvalpp->sc_int); - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - - if (token == CPP_INTCONSTANT) { - yylvalpp->sc_int=atoi(yylvalpp->symbol_name); - SetStringNumber(yylvalpp->sc_int); - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if(token!='\n') - CPPErrorToInfoLog("#line"); - } - else if (token == '\n'){ - return token; - } - else{ - CPPErrorToInfoLog("#line"); - } - } - else{ - CPPErrorToInfoLog("#line"); - } - return token; -} - -static int CPPerror(yystypepp * yylvalpp) { - - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - const char *message; - - while (token != '\n') { - if (token <= 0){ - CPPErrorToInfoLog("unexpected end of input in #error preprocessor directive - expected a newline"); - return 0; - }else if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){ - StoreStr(yylvalpp->symbol_name); - }else if(token == CPP_IDENTIFIER || token == CPP_STRCONSTANT){ - StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident)); - }else { - StoreStr(GetStringOfAtom(atable,token)); - } - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } - DecLineNumber(); - //store this msg into the shader's information log..set the Compile Error flag!!!! - message=GetStrfromTStr(); - CPPShInfoLogMsg(message); - ResetTString(); - cpp->CompileError=1; - IncLineNumber(); - return '\n'; -}//CPPerror - -static int CPPpragma(yystypepp * yylvalpp) -{ - char SrcStrName[2]; - char** allTokens; - int tokenCount = 0; - int maxTokenCount = 10; - const char* SrcStr; - int i; - - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - - if (token=='\n') { - DecLineNumber(); - CPPErrorToInfoLog("#pragma"); - IncLineNumber(); - return token; - } - - allTokens = (char**)malloc(sizeof(char*) * maxTokenCount); - - while (token != '\n') { - if (tokenCount >= maxTokenCount) { - maxTokenCount *= 2; - allTokens = (char**)realloc((char**)allTokens, sizeof(char*) * maxTokenCount); - } - switch (token) { - case CPP_IDENTIFIER: - SrcStr = GetAtomString(atable, yylvalpp->sc_ident); - allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1); - strcpy(allTokens[tokenCount++], SrcStr); - break; - case CPP_INTCONSTANT: - SrcStr = yylvalpp->symbol_name; - allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1); - strcpy(allTokens[tokenCount++], SrcStr); - break; - case CPP_FLOATCONSTANT: - SrcStr = yylvalpp->symbol_name; - allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1); - strcpy(allTokens[tokenCount++], SrcStr); - break; - case -1: - // EOF - CPPShInfoLogMsg("#pragma directive must end with a newline"); - goto freeMemoryAndReturnToken; - default: - SrcStrName[0] = token; - SrcStrName[1] = '\0'; - allTokens[tokenCount] = (char*)malloc(2); - strcpy(allTokens[tokenCount++], SrcStrName); - } - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } - - HandlePragma((const char**)allTokens, tokenCount); - -freeMemoryAndReturnToken: - for (i = 0; i < tokenCount; ++i) { - free (allTokens[i]); - } - free (allTokens); - - return token; -} // CPPpragma - -#define ESSL_VERSION_NUMBER 100 -#define ESSL_VERSION_STRING "100" - -static int CPPversion(yystypepp * yylvalpp) -{ - - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - - if (cpp->pastFirstStatement == 1) - CPPShInfoLogMsg("#version must occur before any other statement in the program"); - - if(token=='\n'){ - DecLineNumber(); - CPPErrorToInfoLog("#version"); - IncLineNumber(); - return token; - } - if (token != CPP_INTCONSTANT) - CPPErrorToInfoLog("#version"); - - yylvalpp->sc_int=atoi(yylvalpp->symbol_name); - //SetVersionNumber(yylvalpp->sc_int); - - if (yylvalpp->sc_int != ESSL_VERSION_NUMBER) - CPPShInfoLogMsg("Version number not supported by ESSL"); - - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - - if (token == '\n'){ - return token; - } - else{ - CPPErrorToInfoLog("#version"); - } - return token; -} // CPPversion - -static int CPPextension(yystypepp * yylvalpp) -{ - - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - char extensionName[MAX_SYMBOL_NAME_LEN + 1]; - - if(token=='\n'){ - DecLineNumber(); - CPPShInfoLogMsg("extension name not specified"); - IncLineNumber(); - return token; - } - - if (token != CPP_IDENTIFIER) - CPPErrorToInfoLog("#extension"); - - strncpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident), MAX_SYMBOL_NAME_LEN); - extensionName[MAX_SYMBOL_NAME_LEN] = '\0'; - - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token != ':') { - CPPShInfoLogMsg("':' missing after extension name"); - return token; - } - - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token != CPP_IDENTIFIER) { - CPPShInfoLogMsg("behavior for extension not specified"); - return token; - } - - updateExtensionBehavior(extensionName, GetAtomString(atable, yylvalpp->sc_ident)); - - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token == '\n'){ - return token; - } - else{ - CPPErrorToInfoLog("#extension"); - } - return token; -} // CPPextension - -int readCPPline(yystypepp * yylvalpp) -{ - int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - const char *message; - - if (token == CPP_IDENTIFIER) { - if (yylvalpp->sc_ident == defineAtom) { - token = CPPdefine(yylvalpp); - } else if (yylvalpp->sc_ident == elseAtom) { - if(ChkCorrectElseNesting()){ - if (!cpp->ifdepth ){ - CPPErrorToInfoLog("#else mismatch"); - cpp->CompileError=1; - return 0; - } - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token != '\n') { - CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline"); - while (token != '\n') { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token <= 0) { // EOF or error - CPPErrorToInfoLog("unexpected end of input in #ifdef preprocessor directive - expected a newline"); - return 0; - } - } - } - token = CPPelse(0, yylvalpp); - }else{ - CPPErrorToInfoLog("#else after a #else"); - cpp->ifdepth = 0; - cpp->elsetracker = 0; - cpp->pastFirstStatement = 1; - cpp->CompileError = 1; - return 0; - } - } else if (yylvalpp->sc_ident == elifAtom) { - if (!cpp->ifdepth){ - CPPErrorToInfoLog("#elif mismatch"); - cpp->CompileError=1; - return 0; - } - // this token is really a dont care, but we still need to eat the tokens - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - while (token != '\n') { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token <= 0) { // EOF or error - CPPErrorToInfoLog("unexpect tokens following #elif preprocessor directive - expected a newline"); - cpp->CompileError = 1; - return 0; - } - } - token = CPPelse(0, yylvalpp); - } else if (yylvalpp->sc_ident == endifAtom) { - if (!cpp->ifdepth){ - CPPErrorToInfoLog("#endif mismatch"); - cpp->CompileError=1; - return 0; - } - else - --cpp->ifdepth; - - if (cpp->elsetracker) - --cpp->elsetracker; - - } else if (yylvalpp->sc_ident == ifAtom) { - token = CPPif(yylvalpp); - } else if (yylvalpp->sc_ident == ifdefAtom) { - token = CPPifdef(1, yylvalpp); - } else if (yylvalpp->sc_ident == ifndefAtom) { - token = CPPifdef(0, yylvalpp); - } else if (yylvalpp->sc_ident == lineAtom) { - token = CPPline(yylvalpp); - } else if (yylvalpp->sc_ident == pragmaAtom) { - token = CPPpragma(yylvalpp); - } else if (yylvalpp->sc_ident == undefAtom) { - token = CPPundef(yylvalpp); - } else if (yylvalpp->sc_ident == errorAtom) { - token = CPPerror(yylvalpp); - } else if (yylvalpp->sc_ident == versionAtom) { - token = CPPversion(yylvalpp); - } else if (yylvalpp->sc_ident == extensionAtom) { - token = CPPextension(yylvalpp); - } else { - StoreStr("Invalid Directive"); - StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident)); - message=GetStrfromTStr(); - CPPShInfoLogMsg(message); - ResetTString(); - } - } - while (token != '\n' && token != 0 && token != EOF) { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } - - cpp->pastFirstStatement = 1; - - return token; -} // readCPPline - -void FreeMacro(MacroSymbol *s) { - DeleteTokenStream(s->body); -} - -void PredefineIntMacro(const char *name, int value) { - SourceLoc location = {0, 0}; - Symbol *symbol = NULL; - MacroSymbol macro = {0, NULL, NULL, 0, 0}; - yystypepp val = {0, 0.0, 0, {0}}; - int atom = 0; - - macro.body = NewTokenStream(name, macros->pool); - val.sc_int = value; - snprintf(val.symbol_name, MAX_SYMBOL_NAME_LEN+1, "%d", value); - RecordToken(macro.body, CPP_INTCONSTANT, &val); - atom = LookUpAddString(atable, name); - symbol = AddSymbol(&location, macros, atom, MACRO_S); - symbol->details.mac = macro; -} - -static int eof_scan(InputSrc *in, yystypepp * yylvalpp) { return -1; } -static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) { } - -static void PushEofSrc() { - InputSrc *in = malloc(sizeof(InputSrc)); - memset(in, 0, sizeof(InputSrc)); - in->scan = eof_scan; - in->getch = eof_scan; - in->ungetch = noop; - in->prev = cpp->currentInput; - cpp->currentInput = in; -} - -static void PopEofSrc() { - if (cpp->currentInput->scan == eof_scan) { - InputSrc *in = cpp->currentInput; - cpp->currentInput = in->prev; - free(in); - } -} - -static TokenStream *PrescanMacroArg(TokenStream *a, yystypepp * yylvalpp) { - int token; - TokenStream *n; - RewindTokenStream(a); - do { - token = ReadToken(a, yylvalpp); - if (token == CPP_IDENTIFIER && LookUpSymbol(macros, yylvalpp->sc_ident)) - break; - } while (token > 0); - if (token <= 0) return a; - n = NewTokenStream("macro arg", 0); - PushEofSrc(); - ReadFromTokenStream(a, 0, 0); - while ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) > 0) { - if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->sc_ident, yylvalpp)) - continue; - RecordToken(n, token, yylvalpp); - } - PopEofSrc(); - DeleteTokenStream(a); - return n; -} // PrescanMacroArg - -typedef struct MacroInputSrc { - InputSrc base; - MacroSymbol *mac; - TokenStream **args; -} MacroInputSrc; - -/* macro_scan --- -** return the next token for a macro expanion, handling macro args -*/ -static int macro_scan(MacroInputSrc *in, yystypepp * yylvalpp) { - int i; - int token = ReadToken(in->mac->body, yylvalpp); - if (token == CPP_IDENTIFIER) { - for (i = in->mac->argc-1; i>=0; i--) - if (in->mac->args[i] == yylvalpp->sc_ident) break; - if (i >= 0) { - ReadFromTokenStream(in->args[i], yylvalpp->sc_ident, 0); - return cpp->currentInput->scan(cpp->currentInput, yylvalpp); - } - } - if (token > 0) return token; - in->mac->busy = 0; - cpp->currentInput = in->base.prev; - if (in->args) { - for (i=in->mac->argc-1; i>=0; i--) - DeleteTokenStream(in->args[i]); - free(in->args); - } - free(in); - return cpp->currentInput->scan(cpp->currentInput, yylvalpp); -} // macro_scan - -/* MacroExpand -** check an identifier (atom) to see if it a macro that should be expanded. -** If it is, push an InputSrc that will produce the appropriate expansion -** and return TRUE. If not, return FALSE. -*/ - -int MacroExpand(int atom, yystypepp * yylvalpp) -{ - Symbol *sym = LookUpSymbol(macros, atom); - MacroInputSrc *in; - int i,j, token, depth=0; - const char *message; - if (atom == __LINE__Atom) { - yylvalpp->sc_int = GetLineNumber(); - snprintf(yylvalpp->symbol_name, MAX_SYMBOL_NAME_LEN+1, "%d", yylvalpp->sc_int); - UngetToken(CPP_INTCONSTANT, yylvalpp); - return 1; - } - if (atom == __FILE__Atom) { - yylvalpp->sc_int = GetStringNumber(); - snprintf(yylvalpp->symbol_name, MAX_SYMBOL_NAME_LEN+1, "%d", yylvalpp->sc_int); - UngetToken(CPP_INTCONSTANT, yylvalpp); - return 1; - } - if (atom == __VERSION__Atom) { - strcpy(yylvalpp->symbol_name,ESSL_VERSION_STRING); - yylvalpp->sc_int = atoi(yylvalpp->symbol_name); - UngetToken(CPP_INTCONSTANT, yylvalpp); - return 1; - } - if (!sym || sym->details.mac.undef) return 0; - if (sym->details.mac.busy) return 0; // no recursive expansions - in = malloc(sizeof(*in)); - memset(in, 0, sizeof(*in)); - in->base.scan = (void *)macro_scan; - in->base.line = cpp->currentInput->line; - in->base.name = cpp->currentInput->name; - in->mac = &sym->details.mac; - if (sym->details.mac.args) { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token != '(') { - UngetToken(token, yylvalpp); - yylvalpp->sc_ident = atom; - return 0; - } - in->args = malloc(in->mac->argc * sizeof(TokenStream *)); - for (i=0; imac->argc; i++) - in->args[i] = NewTokenStream("macro arg", 0); - i=0;j=0; - do{ - depth = 0; - while(1) { - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token <= 0) { - StoreStr("EOF in Macro "); - StoreStr(GetStringOfAtom(atable,atom)); - message=GetStrfromTStr(); - CPPShInfoLogMsg(message); - ResetTString(); - return 1; - } - if((in->mac->argc==0) && (token!=')')) break; - if (depth == 0 && (token == ',' || token == ')')) break; - if (token == '(') depth++; - if (token == ')') depth--; - RecordToken(in->args[i], token, yylvalpp); - j=1; - } - if (token == ')') { - if((in->mac->argc==1) &&j==0) - break; - i++; - break; - } - i++; - }while(i < in->mac->argc); - - if (i < in->mac->argc) { - StoreStr("Too few args in Macro "); - StoreStr(GetStringOfAtom(atable,atom)); - message=GetStrfromTStr(); - CPPShInfoLogMsg(message); - ResetTString(); - } else if (token != ')') { - depth=0; - while (token >= 0 && (depth > 0 || token != ')')) { - if (token == ')') depth--; - token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - if (token == '(') depth++; - } - - if (token <= 0) { - StoreStr("EOF in Macro "); - StoreStr(GetStringOfAtom(atable,atom)); - message=GetStrfromTStr(); - CPPShInfoLogMsg(message); - ResetTString(); - return 1; - } - StoreStr("Too many args in Macro "); - StoreStr(GetStringOfAtom(atable,atom)); - message=GetStrfromTStr(); - CPPShInfoLogMsg(message); - ResetTString(); - } - for (i=0; imac->argc; i++) { - in->args[i] = PrescanMacroArg(in->args[i], yylvalpp); - } - } -#if 0 - printf(" <%s:%d>found macro %s\n", GetAtomString(atable, loc.file), - loc.line, GetAtomString(atable, atom)); - for (i=0; imac->argc; i++) { - printf("\targ %s = '", GetAtomString(atable, in->mac->args[i])); - DumpTokenStream(stdout, in->args[i]); - printf("'\n"); - } -#endif - /*retain the input source*/ - in->base.prev = cpp->currentInput; - sym->details.mac.busy = 1; - RewindTokenStream(sym->details.mac.body); - cpp->currentInput = &in->base; - return 1; -} // MacroExpand - -int ChkCorrectElseNesting(void) -{ - // sanity check to make sure elsetracker is in a valid range - if (cpp->elsetracker < 0 || cpp->elsetracker >= MAX_IF_NESTING) { - return 0; - } - - if (cpp->elsedepth[cpp->elsetracker] == 0) { - cpp->elsedepth[cpp->elsetracker] = 1; - return 1; - } - return 0; -} - - diff --git a/gfx/angle/src/compiler/preprocessor/cpp.h b/gfx/angle/src/compiler/preprocessor/cpp.h deleted file mode 100644 index 802e23ef07eb..000000000000 --- a/gfx/angle/src/compiler/preprocessor/cpp.h +++ /dev/null @@ -1,86 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// cpp.h -// - -#if !defined(__CPP_H) -#define __CPP_H 1 - -#include "compiler/preprocessor/parser.h" -#include "compiler/preprocessor/tokens.h" - -int InitCPP(void); -int FinalCPP(void); -int readCPPline(yystypepp * yylvalpp); -int MacroExpand(int atom, yystypepp * yylvalpp); -int ChkCorrectElseNesting(void); - -typedef struct MacroSymbol { - int argc; - int *args; - TokenStream *body; - unsigned busy:1; - unsigned undef:1; -} MacroSymbol; - -void FreeMacro(MacroSymbol *); -void PredefineIntMacro(const char *name, int value); - -void CPPDebugLogMsg(const char *msg); // Prints information into debug log -void CPPShInfoLogMsg(const char*); // Store cpp Err Msg into Sh.Info.Log -void CPPWarningToInfoLog(const char *msg); // Prints warning messages into info log -void HandlePragma(const char**, int numTokens); // #pragma directive container. -void ResetTString(void); // #error Message as TString. -void CPPErrorToInfoLog(const char*); // Stick all cpp errors into Sh.Info.log. -void StoreStr(const char*); // Store the TString in Parse Context. -void SetLineNumber(int); // Set line number. -void SetStringNumber(int); // Set string number. -int GetLineNumber(void); // Get the current String Number. -int GetStringNumber(void); // Get the current String Number. -const char* GetStrfromTStr(void); // Convert TString to String. -void updateExtensionBehavior(const char* extName, const char* behavior); -int FreeCPP(void); - -#endif // !(defined(__CPP_H) diff --git a/gfx/angle/src/compiler/preprocessor/cppstruct.c b/gfx/angle/src/compiler/preprocessor/cppstruct.c deleted file mode 100644 index 58cff31091dc..000000000000 --- a/gfx/angle/src/compiler/preprocessor/cppstruct.c +++ /dev/null @@ -1,152 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// cppstruct.c -// - -#include -#include - -#include "compiler/preprocessor/slglobals.h" - -CPPStruct *cpp = NULL; -static int refCount = 0; - -int InitPreprocessor(void); -int ResetPreprocessor(void); -int FreeCPPStruct(void); -int FinalizePreprocessor(void); - -/* - * InitCPPStruct() - Initilaize the CPP structure. - * - */ - -int InitCPPStruct(void) -{ - int len; - char *p; - - cpp = (CPPStruct *) malloc(sizeof(CPPStruct)); - if (cpp == NULL) - return 0; - - refCount++; - - // Initialize public members: - cpp->pLastSourceLoc = &cpp->lastSourceLoc; - - p = (char *) &cpp->options; - len = sizeof(cpp->options); - while (--len >= 0) - p[len] = 0; - - ResetPreprocessor(); - return 1; -} // InitCPPStruct - -int ResetPreprocessor(void) -{ - // Initialize private members: - - cpp->lastSourceLoc.file = 0; - cpp->lastSourceLoc.line = 0; - cpp->pC = 0; - cpp->CompileError = 0; - cpp->ifdepth = 0; - for(cpp->elsetracker = 0; cpp->elsetracker < MAX_IF_NESTING; cpp->elsetracker++) - cpp->elsedepth[cpp->elsetracker] = 0; - cpp->elsetracker = 0; - cpp->tokensBeforeEOF = 0; - return 1; -} - -//Intializing the Preprocessor. - -int InitPreprocessor(void) -{ - # define CPP_STUFF true - # ifdef CPP_STUFF - FreeCPPStruct(); - InitCPPStruct(); - cpp->options.Quiet = 1; - cpp->options.profileString = "generic"; - if (!InitAtomTable(atable, 0)) - return 1; - if (!InitScanner(cpp)) - return 1; - # endif - return 0; -} - -//FreeCPPStruct() - Free the CPP structure. - -int FreeCPPStruct(void) -{ - if (refCount) - { - free(cpp); - refCount--; - } - - return 1; -} - -//Finalizing the Preprocessor. - -int FinalizePreprocessor(void) -{ - # define CPP_STUFF true - # ifdef CPP_STUFF - FreeAtomTable(atable); - FreeCPPStruct(); - FreeScanner(); - # endif - return 0; -} - - -/////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////// End of cppstruct.c ////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gfx/angle/src/compiler/preprocessor/new/generate_parser.sh b/gfx/angle/src/compiler/preprocessor/generate_parser.sh old mode 100755 new mode 100644 similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/generate_parser.sh rename to gfx/angle/src/compiler/preprocessor/generate_parser.sh diff --git a/gfx/angle/src/compiler/preprocessor/memory.c b/gfx/angle/src/compiler/preprocessor/memory.c deleted file mode 100644 index 029521a55928..000000000000 --- a/gfx/angle/src/compiler/preprocessor/memory.c +++ /dev/null @@ -1,158 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -#include -#include -#include - -#ifndef _MSC_VER -#include -#endif - -#include "compiler/preprocessor/memory.h" - -#if defined(_MSC_VER) -#pragma warning(disable: 4706) -#endif - -// default alignment and chunksize, if called with 0 arguments -#define CHUNKSIZE (64*1024) -#define ALIGN 8 - -// we need to call the `real' malloc and free, not our replacements -#undef malloc -#undef free - -struct chunk { - struct chunk *next; -}; - -struct cleanup { - struct cleanup *next; - void (*fn)(void *); - void *arg; -}; - -struct MemoryPool_rec { - struct chunk *next; - uintptr_t free, end; - size_t chunksize; - uintptr_t alignmask; - struct cleanup *cleanup; -}; - -MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align) -{ - MemoryPool *pool; - - if (align == 0) align = ALIGN; - if (chunksize == 0) chunksize = CHUNKSIZE; - if (align & (align-1)) return 0; - if (chunksize < sizeof(MemoryPool)) return 0; - if (chunksize & (align-1)) return 0; - if (!(pool = malloc(chunksize))) return 0; - pool->next = 0; - pool->chunksize = chunksize; - pool->alignmask = (uintptr_t)(align)-1; - pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask; - pool->end = (uintptr_t)pool + chunksize; - pool->cleanup = 0; - return pool; -} - -void mem_FreePool(MemoryPool *pool) -{ - struct cleanup *cleanup; - struct chunk *p, *next; - - for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) { - cleanup->fn(cleanup->arg); - } - for (p = (struct chunk *)pool; p; p = next) { - next = p->next; - free(p); - } -} - -void *mem_Alloc(MemoryPool *pool, size_t size) -{ - struct chunk *ch; - void *rv = (void *)pool->free; - size = (size + pool->alignmask) & ~pool->alignmask; - if (size <= 0) size = pool->alignmask; - pool->free += size; - if (pool->free > pool->end || pool->free < (uintptr_t)rv) { - size_t minreq = (size + sizeof(struct chunk) + pool->alignmask) - & ~pool->alignmask; - pool->free = (uintptr_t)rv; - if (minreq >= pool->chunksize) { - // request size is too big for the chunksize, so allocate it as - // a single chunk of the right size - ch = malloc(minreq); - if (!ch) return 0; - } else { - ch = malloc(pool->chunksize); - if (!ch) return 0; - pool->free = (uintptr_t)ch + minreq; - pool->end = (uintptr_t)ch + pool->chunksize; - } - ch->next = pool->next; - pool->next = ch; - rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask); - } - return rv; -} - -int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) { - struct cleanup *cleanup; - - pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1); - cleanup = mem_Alloc(pool, sizeof(struct cleanup)); - if (!cleanup) return -1; - cleanup->next = pool->cleanup; - cleanup->fn = fn; - cleanup->arg = arg; - pool->cleanup = cleanup; - return 0; -} diff --git a/gfx/angle/src/compiler/preprocessor/memory.h b/gfx/angle/src/compiler/preprocessor/memory.h deleted file mode 100644 index 5fcadb32f673..000000000000 --- a/gfx/angle/src/compiler/preprocessor/memory.h +++ /dev/null @@ -1,58 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -#ifndef __MEMORY_H -#define __MEMORY_H - -#include - -typedef struct MemoryPool_rec MemoryPool; - -extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align); -extern void mem_FreePool(MemoryPool *); -extern void *mem_Alloc(MemoryPool *p, size_t size); -extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize); -extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg); - -#endif /* __MEMORY_H */ diff --git a/gfx/angle/src/compiler/preprocessor/new/preprocessor.vcproj b/gfx/angle/src/compiler/preprocessor/new/preprocessor.vcproj deleted file mode 100644 index c4b5d752e34d..000000000000 --- a/gfx/angle/src/compiler/preprocessor/new/preprocessor.vcproj +++ /dev/null @@ -1,399 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/src/compiler/preprocessor/new/numeric_lex.h b/gfx/angle/src/compiler/preprocessor/numeric_lex.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/numeric_lex.h rename to gfx/angle/src/compiler/preprocessor/numeric_lex.h diff --git a/gfx/angle/src/compiler/preprocessor/parser.h b/gfx/angle/src/compiler/preprocessor/parser.h deleted file mode 100644 index f67342b670cc..000000000000 --- a/gfx/angle/src/compiler/preprocessor/parser.h +++ /dev/null @@ -1,93 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ - -#ifndef BISON_PARSER_H -# define BISON_PARSER_H - -#ifndef yystypepp -typedef struct { - int sc_int; - float sc_fval; - int sc_ident; - char symbol_name[MAX_SYMBOL_NAME_LEN+1]; -} yystypepp; - -# define YYSTYPE_IS_TRIVIAL 1 -#endif -# define CPP_AND_OP 257 -# define CPP_SUB_ASSIGN 259 -# define CPP_MOD_ASSIGN 260 -# define CPP_ADD_ASSIGN 261 -# define CPP_DIV_ASSIGN 262 -# define CPP_MUL_ASSIGN 263 -# define CPP_EQ_OP 264 -# define CPP_XOR_OP 265 -# define ERROR_SY 266 -# define CPP_FLOATCONSTANT 267 -# define CPP_GE_OP 268 -# define CPP_RIGHT_OP 269 -# define CPP_IDENTIFIER 270 -# define CPP_INTCONSTANT 271 -# define CPP_LE_OP 272 -# define CPP_LEFT_OP 273 -# define CPP_DEC_OP 274 -# define CPP_NE_OP 275 -# define CPP_OR_OP 276 -# define CPP_INC_OP 277 -# define CPP_STRCONSTANT 278 -# define CPP_TYPEIDENTIFIER 279 - -# define FIRST_USER_TOKEN_SY 289 - -# define CPP_RIGHT_ASSIGN 280 -# define CPP_LEFT_ASSIGN 281 -# define CPP_AND_ASSIGN 282 -# define CPP_OR_ASSIGN 283 -# define CPP_XOR_ASSIGN 284 -# define CPP_LEFT_BRACKET 285 -# define CPP_RIGHT_BRACKET 286 -# define CPP_LEFT_BRACE 287 -# define CPP_RIGHT_BRACE 288 - -#endif /* not BISON_PARSER_H */ diff --git a/gfx/angle/src/compiler/preprocessor/new/pp_utils.h b/gfx/angle/src/compiler/preprocessor/pp_utils.h similarity index 100% rename from gfx/angle/src/compiler/preprocessor/new/pp_utils.h rename to gfx/angle/src/compiler/preprocessor/pp_utils.h diff --git a/gfx/angle/src/compiler/preprocessor/preprocess.h b/gfx/angle/src/compiler/preprocessor/preprocess.h deleted file mode 100644 index 15056da2c9eb..000000000000 --- a/gfx/angle/src/compiler/preprocessor/preprocess.h +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ - -#include "compiler/preprocessor/slglobals.h" -extern CPPStruct *cpp; -int InitCPPStruct(void); -int InitScanner(CPPStruct *cpp); -int InitAtomTable(AtomTable *atable, int htsize); -char* GetStringOfAtom(AtomTable *atable, int atom); diff --git a/gfx/angle/src/compiler/preprocessor/preprocessor.vcxproj b/gfx/angle/src/compiler/preprocessor/preprocessor.vcxproj new file mode 100644 index 000000000000..b39b0e737138 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/preprocessor.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325} + preprocessor + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + true + EditAndContinue + 4100;4127;4189;4239;4244;4245;4512;4702;4267;%(DisableSpecificWarnings) + + + + + X64 + + + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + true + ProgramDatabase + 4100;4127;4189;4239;4244;4245;4512;4702;4718;4267;%(DisableSpecificWarnings) + + + + + MaxSpeed + AnySuitable + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + + + Level4 + true + ProgramDatabase + 4100;4127;4189;4239;4244;4245;4512;4702;4718;4267;%(DisableSpecificWarnings) + + + + + X64 + + + MaxSpeed + AnySuitable + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + + + Level4 + true + ProgramDatabase + 4100;4127;4189;4239;4244;4245;4512;4702;4718;4267;%(DisableSpecificWarnings) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gfx/angle/src/compiler/preprocessor/preprocessor.vcxproj.filters b/gfx/angle/src/compiler/preprocessor/preprocessor.vcxproj.filters new file mode 100644 index 000000000000..2df91e2f749f --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/preprocessor.vcxproj.filters @@ -0,0 +1,95 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/gfx/angle/src/compiler/preprocessor/scanner.c b/gfx/angle/src/compiler/preprocessor/scanner.c deleted file mode 100644 index fde853c1e0f2..000000000000 --- a/gfx/angle/src/compiler/preprocessor/scanner.c +++ /dev/null @@ -1,698 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// scanner.c -// - -#include -#include -#include -#include -#include - -#if 0 - #include -#else - #define isinff(x) (((*(int *)&(x) & 0x7f800000L)==0x7f800000L) && \ - ((*(int *)&(x) & 0x007fffffL)==0000000000L)) -#endif - -#include "compiler/preprocessor/slglobals.h" -#include "compiler/util.h" - -typedef struct StringInputSrc { - InputSrc base; - char *p; -} StringInputSrc; - -static int ScanFromString(const char *s); - -static int eof_scan(InputSrc *is, yystypepp * yylvalpp) -{ - return EOF; -} // eof_scan - -static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) {} - -static InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop, 0, 0 }; - -static int byte_scan(InputSrc *, yystypepp * yylvalpp); - -#define EOL_SY '\n' - -#if defined(_MSC_VER) - #define DBG_BREAKPOINT() __asm int 3 -#elif defined(_M_AMD64) - #define DBG_BREAKPOINT() assert(!"Dbg_Breakpoint"); -#else - #define DBG_BREAKPOINT() -#endif - -#if defined(_MSC_VER) && !defined(_M_AMD64) - __int64 RDTSC ( void ) { - - __int64 v; - - __asm __emit 0x0f - __asm __emit 0x31 - __asm mov dword ptr v, eax - __asm mov dword ptr v+4, edx - - return v; - } -#endif - - -int InitScanner(CPPStruct *cpp) -{ - // Add various atoms needed by the CPP line scanner: - if (!InitCPP()) - return 0; - - cpp->mostRecentToken = 0; - cpp->tokenLoc = &cpp->ltokenLoc; - - cpp->ltokenLoc.file = 0; - cpp->ltokenLoc.line = 0; - - cpp->currentInput = &eof_inputsrc; - cpp->previous_token = '\n'; - cpp->pastFirstStatement = 0; - - return 1; -} // InitScanner - -int FreeScanner(void) -{ - return (FreeCPP()); -} - -int InitScannerInput(CPPStruct *cpp, int count, const char* const string[], const int length[]) -{ - cpp->PaWhichStr = 0; - cpp->PaArgv = string; - cpp->PaArgc = count; - cpp->PaStrLen = length; - ScanFromString(string[0]); - return 0; -} - -/* - * str_getch() - * takes care of reading from multiple strings. - * returns the next-char from the input stream. - * returns EOF when the complete shader is parsed. - */ -static int str_getch(StringInputSrc *in) -{ - for(;;){ - if (*in->p){ - if (*in->p == '\n') { - in->base.line++; - IncLineNumber(); - } - return *in->p++; - } - if(++(cpp->PaWhichStr) < cpp->PaArgc){ - free(in); - SetStringNumber(cpp->PaWhichStr); - SetLineNumber(1); - ScanFromString(cpp->PaArgv[cpp->PaWhichStr]); - in=(StringInputSrc*)cpp->currentInput; - continue; - } - else{ - cpp->currentInput = in->base.prev; - cpp->PaWhichStr=0; - free(in); - return EOF; - } - } -} // str_getch - -static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) { - if (in->p[-1] == ch)in->p--; - else { - *(in->p)='\0'; //this would take care of shifting to the previous string. - cpp->PaWhichStr--; - } - if (ch == '\n') { - in->base.line--; - DecLineNumber(); - } -} // str_ungetch - -int ScanFromString(const char *s) -{ - - StringInputSrc *in = malloc(sizeof(StringInputSrc)); - memset(in, 0, sizeof(StringInputSrc)); - in->p = (char*) s; - in->base.line = 1; - in->base.scan = byte_scan; - in->base.getch = (int (*)(InputSrc *, yystypepp *))str_getch; - in->base.ungetch = (void (*)(InputSrc *, int, yystypepp *))str_ungetch; - in->base.prev = cpp->currentInput; - cpp->currentInput = &in->base; - - return 1; -} // ScanFromString; - - -/////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////// Floating point constants: ///////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - -#define APPEND_CHAR_S(ch, str, len, max_len) \ - if (len < max_len) { \ - str[len++] = ch; \ - } else if (!alreadyComplained) { \ - CPPErrorToInfoLog("BUFFER OVERFLOW"); \ - alreadyComplained = 1; \ - } - -/* - * lFloatConst() - Scan a floating point constant. Assumes that the scanner - * has seen at least one digit, followed by either a decimal '.' or the - * letter 'e'. - * ch - '.' or 'e' - * len - length of string already copied into yylvalpp->symbol_name. - */ - -static int lFloatConst(int ch, int len, yystypepp * yylvalpp) -{ - int alreadyComplained = 0; - assert((ch == '.') || (ch == 'e') || (ch == 'E')); - - if (ch == '.') { - do { - APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } while (ch >= '0' && ch <= '9'); - } - - // Exponent: - if (ch == 'e' || ch == 'E') { - APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '+') { - APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } else if (ch == '-') { - APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } - if (ch >= '0' && ch <= '9') { - while (ch >= '0' && ch <= '9') { - APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } - } else { - CPPErrorToInfoLog("EXPONENT INVALID"); - } - } - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - - assert(len <= MAX_SYMBOL_NAME_LEN); - yylvalpp->symbol_name[len] = '\0'; - yylvalpp->sc_fval = (float) atof_dot(yylvalpp->symbol_name); - if (isinff(yylvalpp->sc_fval)) { - CPPErrorToInfoLog("FLOAT CONSTANT OVERFLOW"); - } - return CPP_FLOATCONSTANT; -} // lFloatConst - -/////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////// Normal Scanner ////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - -static int byte_scan(InputSrc *in, yystypepp * yylvalpp) -{ - char string_val[MAX_STRING_LEN + 1]; - int alreadyComplained = 0; - int len, ch, ii, ival = 0; - - for (;;) { - yylvalpp->sc_int = 0; - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - - while (ch == ' ' || ch == '\t' || ch == '\r') { - yylvalpp->sc_int = 1; - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } - - cpp->ltokenLoc.file = cpp->currentInput->name; - cpp->ltokenLoc.line = cpp->currentInput->line; - alreadyComplained = 0; - len = 0; - switch (ch) { - default: - return ch; // Single character token - case EOF: - return -1; - case 'A': case 'B': case 'C': case 'D': case 'E': - case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'L': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': case 'Y': - case 'Z': case '_': - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': - case 'z': - do { - APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } while ((ch >= 'a' && ch <= 'z') || - (ch >= 'A' && ch <= 'Z') || - (ch >= '0' && ch <= '9') || - ch == '_'); - assert(len <= MAX_SYMBOL_NAME_LEN); - yylvalpp->symbol_name[len] = '\0'; - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - yylvalpp->sc_ident = LookUpAddString(atable, yylvalpp->symbol_name); - return CPP_IDENTIFIER; - break; - case '0': - APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == 'x' || ch == 'X') { // hexadecimal integer constants - APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if ((ch >= '0' && ch <= '9') || - (ch >= 'A' && ch <= 'F') || - (ch >= 'a' && ch <= 'f')) - { - ival = 0; - do { - if ((ival <= 0x0fffffff) && (len < MAX_SYMBOL_NAME_LEN)) { - yylvalpp->symbol_name[len++] = ch; - if (ch >= '0' && ch <= '9') { - ii = ch - '0'; - } else if (ch >= 'A' && ch <= 'F') { - ii = ch - 'A' + 10; - } else { - ii = ch - 'a' + 10; - } - ival = (ival << 4) | ii; - } else if (!alreadyComplained) { - CPPErrorToInfoLog("HEX CONSTANT OVERFLOW"); - alreadyComplained = 1; - } - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } while ((ch >= '0' && ch <= '9') || - (ch >= 'A' && ch <= 'F') || - (ch >= 'a' && ch <= 'f')); - } else { - CPPErrorToInfoLog("HEX CONSTANT INVALID"); - } - assert(len <= MAX_SYMBOL_NAME_LEN); - yylvalpp->symbol_name[len] = '\0'; - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - yylvalpp->sc_int = ival; - return CPP_INTCONSTANT; - } else if (ch >= '0' && ch <= '7') { // octal integer constants - ival = 0; - do { - if ((ival <= 0x1fffffff) && (len < MAX_SYMBOL_NAME_LEN)) { - yylvalpp->symbol_name[len++] = ch; - ii = ch - '0'; - ival = (ival << 3) | ii; - } else if (!alreadyComplained) { - CPPErrorToInfoLog("OCT CONSTANT OVERFLOW"); - alreadyComplained = 1; - } - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } while (ch >= '0' && ch <= '7'); - if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') - return lFloatConst(ch, len, yylvalpp); - assert(len <= MAX_SYMBOL_NAME_LEN); - yylvalpp->symbol_name[len] = '\0'; - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - yylvalpp->sc_int = ival; - return CPP_INTCONSTANT; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - ch = '0'; - } - // Fall through... - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - do { - APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } while (ch >= '0' && ch <= '9'); - if (ch == '.' || ch == 'e' || ch == 'E') { - return lFloatConst(ch, len, yylvalpp); - } else { - assert(len <= MAX_SYMBOL_NAME_LEN); - yylvalpp->symbol_name[len] = '\0'; - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - ival = 0; - for (ii = 0; ii < len; ii++) { - ch = yylvalpp->symbol_name[ii] - '0'; - ival = ival*10 + ch; - if ((ival > 214748364) || (ival == 214748364 && ch >= 8)) { - CPPErrorToInfoLog("INTEGER CONSTANT OVERFLOW"); - break; - } - } - yylvalpp->sc_int = ival; - if(ival==0) - strcpy(yylvalpp->symbol_name,"0"); - return CPP_INTCONSTANT; - } - break; - case '-': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '-') { - return CPP_DEC_OP; - } else if (ch == '=') { - return CPP_SUB_ASSIGN; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '-'; - } - case '+': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '+') { - return CPP_INC_OP; - } else if (ch == '=') { - return CPP_ADD_ASSIGN; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '+'; - } - case '*': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '=') { - return CPP_MUL_ASSIGN; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '*'; - } - case '%': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '=') { - return CPP_MOD_ASSIGN; - } else if (ch == '>'){ - return CPP_RIGHT_BRACE; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '%'; - } - case ':': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '>') { - return CPP_RIGHT_BRACKET; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return ':'; - } - case '^': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '^') { - return CPP_XOR_OP; - } else { - if (ch == '=') - return CPP_XOR_ASSIGN; - else{ - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '^'; - } - } - - case '=': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '=') { - return CPP_EQ_OP; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '='; - } - case '!': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '=') { - return CPP_NE_OP; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '!'; - } - case '|': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '|') { - return CPP_OR_OP; - } else { - if (ch == '=') - return CPP_OR_ASSIGN; - else{ - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '|'; - } - } - case '&': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '&') { - return CPP_AND_OP; - } else { - if (ch == '=') - return CPP_AND_ASSIGN; - else{ - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '&'; - } - } - case '<': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '<') { - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if(ch == '=') - return CPP_LEFT_ASSIGN; - else{ - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return CPP_LEFT_OP; - } - } else { - if (ch == '=') { - return CPP_LE_OP; - } else { - if (ch == '%') - return CPP_LEFT_BRACE; - else if (ch == ':') - return CPP_LEFT_BRACKET; - else{ - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '<'; - } - } - } - case '>': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '>') { - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if(ch == '=') - return CPP_RIGHT_ASSIGN; - else{ - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return CPP_RIGHT_OP; - } - } else { - if (ch == '=') { - return CPP_GE_OP; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '>'; - } - } - case '.': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch >= '0' && ch <= '9') { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return lFloatConst('.', 0, yylvalpp); - } else { - if (ch == '.') { - return -1; // Special EOF hack - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '.'; - } - } - case '/': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == '/') { - do { - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } while (ch != '\n' && ch != EOF); - if (ch == EOF) - return -1; - return '\n'; - } else if (ch == '*') { - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - do { - while (ch != '*') { - if (ch == EOF) { - CPPErrorToInfoLog("EOF IN COMMENT"); - return -1; - } - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == EOF) { - CPPErrorToInfoLog("EOF IN COMMENT"); - return -1; - } - } while (ch != '/'); - // Go try it again... - } else if (ch == '=') { - return CPP_DIV_ASSIGN; - } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return '/'; - } - break; - case '"': - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - while (ch != '"' && ch != '\n' && ch != EOF) { - if (ch == '\\') { - CPPErrorToInfoLog("The line continuation character (\\) is not part of the OpenGL ES Shading Language"); - return -1; - } - APPEND_CHAR_S(ch, string_val, len, MAX_STRING_LEN); - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - }; - assert(len <= MAX_STRING_LEN); - string_val[len] = '\0'; - if (ch == '"') { - yylvalpp->sc_ident = LookUpAddString(atable, string_val); - return CPP_STRCONSTANT; - } else { - CPPErrorToInfoLog("EOL IN STRING"); - return ERROR_SY; - } - break; - } - } -} // byte_scan - -int yylex_CPP(char* buf, int maxSize) -{ - yystypepp yylvalpp; - int token = '\n'; - - for(;;) { - - char* tokenString = 0; - token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp); - if(check_EOF(token)) - return 0; - if (token < 0) { - // This check may need to be improved to support UTF-8 - // characters in comments. - CPPErrorToInfoLog("preprocessor encountered non-ASCII character in shader source"); - return 0; - } - if (token == '#') { - if (cpp->previous_token == '\n'|| cpp->previous_token == 0) { - token = readCPPline(&yylvalpp); - if(check_EOF(token)) - return 0; - continue; - } else { - CPPErrorToInfoLog("preprocessor command must not be preceded by any other statement in that line"); - return 0; - } - } - cpp->previous_token = token; - // expand macros - if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) { - cpp->pastFirstStatement = 1; - continue; - } - - if (token == '\n') - continue; - cpp->pastFirstStatement = 1; - - if (token == CPP_IDENTIFIER) { - tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident); - } else if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){ - tokenString = yylvalpp.symbol_name; - } else { - tokenString = GetStringOfAtom(atable,token); - } - - if (tokenString) { - int len = strlen(tokenString); - cpp->tokensBeforeEOF = 1; - if (len >= maxSize) { - return maxSize; - } else if (len > 0) { - strcpy(buf, tokenString); - return len; - } - - return 0; - } - } -} // yylex - -//Checks if the token just read is EOF or not. -int check_EOF(int token) -{ - if(token==-1){ - if(cpp->ifdepth >0){ - CPPErrorToInfoLog("#endif missing!! Compilation stopped"); - cpp->CompileError=1; - } - return 1; - } - return 0; -} - -/////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////// End of scanner.c ////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - diff --git a/gfx/angle/src/compiler/preprocessor/scanner.h b/gfx/angle/src/compiler/preprocessor/scanner.h deleted file mode 100644 index b67c1d644e9b..000000000000 --- a/gfx/angle/src/compiler/preprocessor/scanner.h +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// scanner.h -// - -#if !defined(__SCANNER_H) -#define __SCANNER_H 1 - -#include "compiler/preprocessor/length_limits.h" -#include "compiler/preprocessor/parser.h" - -// Not really atom table stuff but needed first... - -typedef struct SourceLoc_Rec { - unsigned short file, line; -} SourceLoc; - -int yylex_CPP(char* buf, int maxSize); - -typedef struct InputSrc { - struct InputSrc *prev; - int (*scan)(struct InputSrc *, yystypepp *); - int (*getch)(struct InputSrc *, yystypepp *); - void (*ungetch)(struct InputSrc *, int, yystypepp *); - int name; /* atom */ - int line; -} InputSrc; - -int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner. -int InitScannerInput(CPPStruct *cpp, int count, const char* const string[], const int length[]); -int check_EOF(int); // check if we hit a EOF abruptly -void CPPErrorToInfoLog(const char *); // sticking the msg,line into the Shader's.Info.log -void SetLineNumber(int); -void SetStringNumber(int); -void IncLineNumber(void); -void DecLineNumber(void); -int FreeScanner(void); // Free the cpp scanner -#endif // !(defined(__SCANNER_H) - diff --git a/gfx/angle/src/compiler/preprocessor/slglobals.h b/gfx/angle/src/compiler/preprocessor/slglobals.h deleted file mode 100644 index 463462664301..000000000000 --- a/gfx/angle/src/compiler/preprocessor/slglobals.h +++ /dev/null @@ -1,82 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// slglobals.h -// - -#if !defined(__SLGLOBALS_H) -#define __SLGLOBALS_H 1 - -typedef struct CPPStruct_Rec CPPStruct; - -extern CPPStruct *cpp; - -#undef CPPC_DEBUG_THE_COMPILER -#if defined(_DEBUG) -#define CPPC_DEBUG_THE_COMPILER 1 -#endif - -#undef CPPC_ENABLE_TOOLS -#define CPPC_ENABLE_TOOLS 1 - -#include "compiler/preprocessor/memory.h" -#include "compiler/preprocessor/atom.h" -#include "compiler/preprocessor/scanner.h" -#include "compiler/preprocessor/cpp.h" -#include "compiler/preprocessor/tokens.h" -#include "compiler/preprocessor/symbols.h" -#include "compiler/preprocessor/compile.h" -#if !defined(NO_PARSER) -#include "compiler/preprocessor/parser.h" -#endif - -#if !defined(NULL) -#define NULL 0 -#endif - -#endif // !(defined(__SLGLOBALS_H) - - - - diff --git a/gfx/angle/src/compiler/preprocessor/symbols.c b/gfx/angle/src/compiler/preprocessor/symbols.c deleted file mode 100644 index f18b2569b378..000000000000 --- a/gfx/angle/src/compiler/preprocessor/symbols.c +++ /dev/null @@ -1,288 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// symbols.c -// - -#include -#include -#include - -#include "compiler/preprocessor/slglobals.h" - -#if defined(_MSC_VER) -#pragma warning(disable: 4706) -#endif - -/////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////// Symbol Table Variables: /////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - -Scope *ScopeList = NULL; -Scope *CurrentScope = NULL; -Scope *GlobalScope = NULL; - -static void unlinkScope(void *_scope) { - Scope *scope = _scope; - - if (scope->next) - scope->next->prev = scope->prev; - if (scope->prev) - scope->prev->next = scope->next; - else - ScopeList = scope->next; -} - -/* - * NewScope() - * - */ -Scope *NewScopeInPool(MemoryPool *pool) -{ - Scope *lScope; - - lScope = mem_Alloc(pool, sizeof(Scope)); - lScope->pool = pool; - lScope->parent = NULL; - lScope->funScope = NULL; - lScope->symbols = NULL; - - lScope->level = 0; - - lScope->programs = NULL; - if ((lScope->next = ScopeList)) - ScopeList->prev = lScope; - lScope->prev = 0; - ScopeList = lScope; - mem_AddCleanup(pool, unlinkScope, lScope); - return lScope; -} // NewScope - -/* - * PushScope() - * - */ - -void PushScope(Scope *fScope) -{ - Scope *lScope; - - if (CurrentScope) { - fScope->level = CurrentScope->level + 1; - if (fScope->level == 1) { - if (!GlobalScope) { - /* HACK - CTD -- if GlobalScope==NULL and level==1, we're - * defining a function in the superglobal scope. Things - * will break if we leave the level as 1, so we arbitrarily - * set it to 2 */ - fScope->level = 2; - } - } - if (fScope->level >= 2) { - lScope = fScope; - while (lScope->level > 2) - lScope = lScope->next; - fScope->funScope = lScope; - } - } else { - fScope->level = 0; - } - fScope->parent = CurrentScope; - CurrentScope = fScope; -} // PushScope - -/* - * PopScope() - * - */ - -Scope *PopScope(void) -{ - Scope *lScope; - - lScope = CurrentScope; - if (CurrentScope) - CurrentScope = CurrentScope->parent; - return lScope; -} // PopScope - -/* - * NewSymbol() - Allocate a new symbol node; - * - */ - -Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind) -{ - Symbol *lSymb; - char *pch; - unsigned int ii; - - lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol)); - lSymb->left = NULL; - lSymb->right = NULL; - lSymb->next = NULL; - lSymb->name = name; - lSymb->loc = *loc; - lSymb->kind = kind; - - // Clear union area: - - pch = (char *) &lSymb->details; - for (ii = 0; ii < sizeof(lSymb->details); ii++) - *pch++ = 0; - return lSymb; -} // NewSymbol - -/* - * lAddToTree() - Using a binary tree is not a good idea for basic atom values because they - * are generated in order. We'll fix this later (by reversing the bit pattern). - */ - -static void lAddToTree(Symbol **fSymbols, Symbol *fSymb) -{ - Symbol *lSymb; - int lrev, frev; - - lSymb = *fSymbols; - if (lSymb) { - frev = GetReversedAtom(atable, fSymb->name); - while (lSymb) { - lrev = GetReversedAtom(atable, lSymb->name); - if (lrev == frev) { - CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)"); - break; - } else { - if (lrev > frev) { - if (lSymb->left) { - lSymb = lSymb->left; - } else { - lSymb->left = fSymb; - break; - } - } else { - if (lSymb->right) { - lSymb = lSymb->right; - } else { - lSymb->right = fSymb; - break; - } - } - } - } - } else { - *fSymbols = fSymb; - } -} // lAddToTree - - -/* - * AddSymbol() - Add a variable, type, or function name to a scope. - * - */ - -Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind) -{ - Symbol *lSymb; - - if (!fScope) - fScope = CurrentScope; - lSymb = NewSymbol(loc, fScope, atom, kind); - lAddToTree(&fScope->symbols, lSymb); - return lSymb; -} // AddSymbol - - -/*********************************************************************************************/ -/************************************ Symbol Semantic Functions ******************************/ -/*********************************************************************************************/ - -/* - * LookUpLocalSymbol() - * - */ - -Symbol *LookUpLocalSymbol(Scope *fScope, int atom) -{ - Symbol *lSymb; - int rname, ratom; - - ratom = GetReversedAtom(atable, atom); - if (!fScope) - fScope = CurrentScope; - lSymb = fScope->symbols; - while (lSymb) { - rname = GetReversedAtom(atable, lSymb->name); - if (rname == ratom) { - return lSymb; - } else { - if (rname > ratom) { - lSymb = lSymb->left; - } else { - lSymb = lSymb->right; - } - } - } - return NULL; -} // LookUpLocalSymbol - -/* - * LookUpSymbol() - * - */ - -Symbol *LookUpSymbol(Scope *fScope, int atom) -{ - Symbol *lSymb; - - if (!fScope) - fScope = CurrentScope; - while (fScope) { - lSymb = LookUpLocalSymbol(fScope, atom); - if (lSymb) - return lSymb; - fScope = fScope->parent; - } - return NULL; -} // LookUpSymbol - diff --git a/gfx/angle/src/compiler/preprocessor/symbols.h b/gfx/angle/src/compiler/preprocessor/symbols.h deleted file mode 100644 index e7d0b075fa0b..000000000000 --- a/gfx/angle/src/compiler/preprocessor/symbols.h +++ /dev/null @@ -1,111 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// symbols.h -// - -#if !defined(__SYMBOLS_H) -#define __SYMBOLS_H 1 - -#include "compiler/preprocessor/memory.h" - -typedef enum symbolkind { - MACRO_S -} symbolkind; - -// Typedefs for things defined here in "symbols.h": - -typedef struct Scope_Rec Scope; -typedef struct Symbol_Rec Symbol; - -typedef struct SymbolList_Rec { - struct SymbolList_Rec *next; - Symbol *symb; -} SymbolList; - -struct Scope_Rec { - Scope *next, *prev; // doubly-linked list of all scopes - Scope *parent; - Scope *funScope; // Points to base scope of enclosing function - MemoryPool *pool; // pool used for allocation in this scope - Symbol *symbols; - - int level; // 0 = super globals, 1 = globals, etc. - - // Only used at global scope (level 1): - SymbolList *programs; // List of programs for this compilation. -}; - - -// Symbol table is a simple binary tree. - -#include "compiler/preprocessor/cpp.h" // to get MacroSymbol def - -struct Symbol_Rec { - Symbol *left, *right; - Symbol *next; - int name; // Name atom - SourceLoc loc; - symbolkind kind; - union { - MacroSymbol mac; - } details; -}; - -extern Scope *CurrentScope; -extern Scope *GlobalScope; -extern Scope *ScopeList; - -Scope *NewScopeInPool(MemoryPool *); -#define NewScope() NewScopeInPool(CurrentScope->pool) -void PushScope(Scope *fScope); -Scope *PopScope(void); -Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind); -Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind); -Symbol *LookUpLocalSymbol(Scope *fScope, int atom); -Symbol *LookUpSymbol(Scope *fScope, int atom); - - -#endif // !defined(__SYMBOLS_H) - diff --git a/gfx/angle/src/compiler/preprocessor/tokens.c b/gfx/angle/src/compiler/preprocessor/tokens.c deleted file mode 100644 index 57168f67ebf3..000000000000 --- a/gfx/angle/src/compiler/preprocessor/tokens.c +++ /dev/null @@ -1,467 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// tokens.c -// - -#include -#include -#include -#include - -#include "common/angleutils.h" -#include "compiler/compilerdebug.h" -#include "compiler/preprocessor/slglobals.h" -#include "compiler/util.h" - -#if defined(_MSC_VER) -#pragma warning(disable: 4054) -#pragma warning(disable: 4152) -#endif - -/////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////// Preprocessor and Token Recorder and Playback: //////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - -/* - * idstr() - * Copy a string to a malloc'ed block and convert it into something suitable - * for an ID - * - */ - -static char *idstr(const char *fstr, MemoryPool *pool) -{ - size_t len; - char *str, *t; - const char *f; - - len = strlen(fstr); - if (!pool) - str = (char *) malloc(len + 1); - else - str = (char *) mem_Alloc(pool, len + 1); - - for (f=fstr, t=str; *f; f++) { - if (isalnum(*f)) *t++ = *f; - else if (*f == '.' || *f == '/') *t++ = '_'; - } - *t = 0; - return str; -} // idstr - - -/* - * lNewBlock() - * - */ - -static TokenBlock *lNewBlock(TokenStream *fTok, MemoryPool *pool) -{ - TokenBlock *lBlock; - - if (!pool) - lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256); - else - lBlock = (TokenBlock *) mem_Alloc(pool, sizeof(TokenBlock) + 256); - lBlock->count = 0; - lBlock->current = 0; - lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock); - lBlock->max = 256; - lBlock->next = NULL; - if (fTok->head) { - fTok->current->next = lBlock; - } else { - fTok->head = lBlock; - } - fTok->current = lBlock; - return lBlock; -} // lNewBlock - -/* - * lAddByte() - * - */ - -static void lAddByte(TokenStream *fTok, unsigned char fVal) -{ - TokenBlock *lBlock; - lBlock = fTok->current; - if (lBlock->count >= lBlock->max) - lBlock = lNewBlock(fTok, 0); - lBlock->data[lBlock->count++] = fVal; -} // lAddByte - - - -/* - * lReadByte() - Get the next byte from a stream. - * - */ - -static int lReadByte(TokenStream *pTok) -{ - TokenBlock *lBlock; - int lval = -1; - - lBlock = pTok->current; - if (lBlock) { - if (lBlock->current >= lBlock->count) { - lBlock = lBlock->next; - if (lBlock) - lBlock->current = 0; - pTok->current = lBlock; - } - if (lBlock) - lval = lBlock->data[lBlock->current++]; - } - return lval; -} // lReadByte - -/////////////////////////////////////// Global Functions:////////////////////////////////////// - -/* - * NewTokenStream() - * - */ - -TokenStream *NewTokenStream(const char *name, MemoryPool *pool) -{ - TokenStream *pTok; - - if (!pool) - pTok = (TokenStream *) malloc(sizeof(TokenStream)); - else - pTok = (TokenStream*)mem_Alloc(pool, sizeof(TokenStream)); - pTok->next = NULL; - pTok->name = idstr(name, pool); - pTok->head = NULL; - pTok->current = NULL; - lNewBlock(pTok, pool); - return pTok; -} // NewTokenStream - -/* - * DeleteTokenStream() - * - */ - -void DeleteTokenStream(TokenStream *pTok) -{ - TokenBlock *pBlock, *nBlock; - - if (pTok) { - pBlock = pTok->head; - while (pBlock) { - nBlock = pBlock->next; - free(pBlock); - pBlock = nBlock; - } - if (pTok->name) - free(pTok->name); - free(pTok); - } -} // DeleteTokenStream - -/* - * RecordToken() - Add a token to the end of a list for later playback or printout. - * - */ - -void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp) -{ - const char *s; - char *str=NULL; - - if (token > 256) - lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80)); - else - lAddByte(pTok, (unsigned char)(token & 0x7f)); - switch (token) { - case CPP_IDENTIFIER: - case CPP_TYPEIDENTIFIER: - case CPP_STRCONSTANT: - s = GetAtomString(atable, yylvalpp->sc_ident); - while (*s) - lAddByte(pTok, (unsigned char) *s++); - lAddByte(pTok, 0); - break; - case CPP_FLOATCONSTANT: - case CPP_INTCONSTANT: - str=yylvalpp->symbol_name; - while (*str){ - lAddByte(pTok, (unsigned char) *str++); - } - lAddByte(pTok, 0); - break; - case '(': - lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0)); - default: - break; - } -} // RecordToken - -/* - * RewindTokenStream() - Reset a token stream in preperation for reading. - * - */ - -void RewindTokenStream(TokenStream *pTok) -{ - if (pTok->head) { - pTok->current = pTok->head; - pTok->current->current = 0; - } -} // RewindTokenStream - -/* - * ReadToken() - Read the next token from a stream. - * - */ - -int ReadToken(TokenStream *pTok, yystypepp * yylvalpp) -{ - char symbol_name[MAX_SYMBOL_NAME_LEN + 1]; - char string_val[MAX_STRING_LEN + 1]; - int ltoken, len; - char ch; - int base, accum; - char ch_val; - - ltoken = lReadByte(pTok); - if (ltoken >= 0) { - if (ltoken > 127) - ltoken += 128; - switch (ltoken) { - case CPP_IDENTIFIER: - case CPP_TYPEIDENTIFIER: - len = 0; - ch = lReadByte(pTok); - while ((ch >= 'a' && ch <= 'z') || - (ch >= 'A' && ch <= 'Z') || - (ch >= '0' && ch <= '9') || - ch == '_') - { - if (len < MAX_SYMBOL_NAME_LEN) { - symbol_name[len++] = ch; - ch = lReadByte(pTok); - } - } - symbol_name[len] = '\0'; - assert(ch == '\0'); - yylvalpp->sc_ident = LookUpAddString(atable, symbol_name); - return CPP_IDENTIFIER; - break; - case CPP_STRCONSTANT: - len = 0; - while ((ch = lReadByte(pTok)) != 0) - if (len < MAX_STRING_LEN) - string_val[len++] = ch; - string_val[len] = '\0'; - yylvalpp->sc_ident = LookUpAddString(atable, string_val); - break; - case CPP_FLOATCONSTANT: - len = 0; - ch = lReadByte(pTok); - while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-')) - { - if (len < MAX_SYMBOL_NAME_LEN) { - symbol_name[len++] = ch; - ch = lReadByte(pTok); - } - } - symbol_name[len] = '\0'; - assert(ch == '\0'); - strcpy(yylvalpp->symbol_name,symbol_name); - yylvalpp->sc_fval=(float)atof_dot(yylvalpp->symbol_name); - break; - case CPP_INTCONSTANT: - len = 0; - accum = 0; - ch = lReadByte(pTok); - if (ch == '0') { - symbol_name[len++] = ch; - ch = lReadByte(pTok); - if (ch == 'x' || ch == 'X') { - symbol_name[len++] = ch; - base = 16; - ch = lReadByte(pTok); - } else { - base = 8; - } - } else { - base = 10; - } - - while (len < MAX_SYMBOL_NAME_LEN) - { - ch_val = -1; - if (isdigit(ch)) - ch_val = ch - '0'; - else if (isxdigit(ch)) - ch_val = tolower(ch) - 'a' + 10; - - if (ch_val < 0 || ch_val >= base) - break; - - symbol_name[len++] = ch; - accum = accum * base + ch_val; - ch = lReadByte(pTok); - } - symbol_name[len] = '\0'; - assert(ch == '\0'); - strcpy(yylvalpp->symbol_name, symbol_name); - yylvalpp->sc_int = accum; - break; - case '(': - yylvalpp->sc_int = lReadByte(pTok); - break; - } - return ltoken; - } - return EOF_SY; -} // ReadToken - -typedef struct TokenInputSrc { - InputSrc base; - TokenStream *tokens; - int (*final)(CPPStruct *); -} TokenInputSrc; - -static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp) -{ - int token = ReadToken(in->tokens, yylvalpp); - int (*final)(CPPStruct *); - cpp->tokenLoc->file = cpp->currentInput->name; - cpp->tokenLoc->line = cpp->currentInput->line; - if (token == '\n') { - in->base.line++; - return token; - } - if (token > 0) return token; - cpp->currentInput = in->base.prev; - final = in->final; - free(in); - if (final && !final(cpp)) return -1; - return cpp->currentInput->scan(cpp->currentInput, yylvalpp); -} - -int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *)) -{ - TokenInputSrc *in = malloc(sizeof(TokenInputSrc)); - memset(in, 0, sizeof(TokenInputSrc)); - in->base.name = name; - in->base.prev = cpp->currentInput; - in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token; - in->base.line = 1; - in->tokens = ts; - in->final = final; - RewindTokenStream(ts); - cpp->currentInput = &in->base; - return 1; -} - -typedef struct UngotToken { - InputSrc base; - int token; - yystypepp lval; -} UngotToken; - -static int reget_token(UngotToken *t, yystypepp * yylvalpp) -{ - int token = t->token; - *yylvalpp = t->lval; - cpp->currentInput = t->base.prev; - free(t); - return token; -} - -void UngetToken(int token, yystypepp * yylvalpp) { - UngotToken *t = malloc(sizeof(UngotToken)); - memset(t, 0, sizeof(UngotToken)); - t->token = token; - t->lval = *yylvalpp; - t->base.scan = (void *)reget_token; - t->base.prev = cpp->currentInput; - t->base.name = cpp->currentInput->name; - t->base.line = cpp->currentInput->line; - cpp->currentInput = &t->base; -} - - -void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) { - int token; - char str[100]; - - if (fp == 0) fp = stdout; - RewindTokenStream(s); - while ((token = ReadToken(s, yylvalpp)) > 0) { - switch (token) { - case CPP_IDENTIFIER: - case CPP_TYPEIDENTIFIER: - snprintf(str, sizeof(str), "%s ", GetAtomString(atable, yylvalpp->sc_ident)); - break; - case CPP_STRCONSTANT: - snprintf(str, sizeof(str), "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident)); - break; - case CPP_FLOATCONSTANT: - //printf("%g9.6 ", yylvalpp->sc_fval); - break; - case CPP_INTCONSTANT: - //printf("%d ", yylvalpp->sc_int); - break; - default: - if (token >= 127) - snprintf(str, sizeof(str), "%s ", GetAtomString(atable, token)); - else - snprintf(str, sizeof(str), "%c", token); - break; - } - CPPDebugLogMsg(str); - } -} - -/////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////// End of tokens.c /////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gfx/angle/src/compiler/preprocessor/tokens.h b/gfx/angle/src/compiler/preprocessor/tokens.h deleted file mode 100644 index dbf4a2ccfe25..000000000000 --- a/gfx/angle/src/compiler/preprocessor/tokens.h +++ /dev/null @@ -1,90 +0,0 @@ -/****************************************************************************\ -Copyright (c) 2002, NVIDIA Corporation. - -NVIDIA Corporation("NVIDIA") supplies this software to you in -consideration of your agreement to the following terms, and your use, -installation, modification or redistribution of this NVIDIA software -constitutes acceptance of these terms. If you do not agree with these -terms, please do not use, install, modify or redistribute this NVIDIA -software. - -In consideration of your agreement to abide by the following terms, and -subject to these terms, NVIDIA grants you a personal, non-exclusive -license, under NVIDIA's copyrights in this original NVIDIA software (the -"NVIDIA Software"), to use, reproduce, modify and redistribute the -NVIDIA Software, with or without modifications, in source and/or binary -forms; provided that if you redistribute the NVIDIA Software, you must -retain the copyright notice of NVIDIA, this notice and the following -text and disclaimers in all such redistributions of the NVIDIA Software. -Neither the name, trademarks, service marks nor logos of NVIDIA -Corporation may be used to endorse or promote products derived from the -NVIDIA Software without specific prior written permission from NVIDIA. -Except as expressly stated in this notice, no other rights or licenses -express or implied, are granted by NVIDIA herein, including but not -limited to any patent rights that may be infringed by your derivative -works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. - -THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, -INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER -PRODUCTS. - -IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, -INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY -OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE -NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, -TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\****************************************************************************/ -// -// tokens.h -// - -#if !defined(__TOKENS_H) -#define __TOKENS_H 1 - -#include -#include "compiler/preprocessor/parser.h" - -#define EOF_SY (-1) - -typedef struct TokenBlock_Rec TokenBlock; - -typedef struct TokenStream_Rec { - struct TokenStream_Rec *next; - char *name; - TokenBlock *head; - TokenBlock *current; -} TokenStream; - -struct TokenBlock_Rec { - TokenBlock *next; - int current; - int count; - int max; - unsigned char *data; -}; - -extern TokenStream stdlib_cpp_stream; - - -TokenStream *NewTokenStream(const char *name, MemoryPool *pool); -void DeleteTokenStream(TokenStream *pTok); -void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp); -void RewindTokenStream(TokenStream *pTok); -int ReadToken(TokenStream *pTok, yystypepp * yylvalpp); -int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *)); -void UngetToken(int, yystypepp * yylvalpp); - -#if defined(CPPC_ENABLE_TOOLS) - -void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp); - -#endif // defined(CPPC_ENABLE_TOOLS) - -#endif // !defined(__TOKENS_H) diff --git a/gfx/angle/src/compiler/translator_common.vcproj b/gfx/angle/src/compiler/translator_common.vcproj deleted file mode 100644 index aa5d0f6ee59b..000000000000 --- a/gfx/angle/src/compiler/translator_common.vcproj +++ /dev/null @@ -1,787 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/src/compiler/translator_common.vcxproj b/gfx/angle/src/compiler/translator_common.vcxproj new file mode 100644 index 000000000000..0f383db84e9b --- /dev/null +++ b/gfx/angle/src/compiler/translator_common.vcxproj @@ -0,0 +1,282 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} + compiler + Win32Proj + + + + StaticLibrary + NotSet + true + + + StaticLibrary + NotSet + + + StaticLibrary + NotSet + true + + + StaticLibrary + NotSet + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\common\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(Configuration)\common\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + + Disabled + $(ProjectDir);$(ProjectDir)../;$(ProjectDir)../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + true + EditAndContinue + 4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings) + + + + + X64 + + + Disabled + $(ProjectDir);$(ProjectDir)../;$(ProjectDir)../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + true + ProgramDatabase + 4100;4127;4189;4239;4244;4245;4267;4512;4702;4718;%(DisableSpecificWarnings) + + + + + MaxSpeed + AnySuitable + $(ProjectDir);$(ProjectDir)../;$(ProjectDir)../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + + + Level4 + true + ProgramDatabase + 4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings) + + + + + X64 + + + MaxSpeed + AnySuitable + $(ProjectDir);$(ProjectDir)../;$(ProjectDir)../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + + + Level4 + true + ProgramDatabase + 4100;4127;4189;4239;4244;4245;4267;4512;4702;4718;%(DisableSpecificWarnings) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %(AdditionalInputs) + %(Outputs) + + + + + %(AdditionalInputs) + %(Outputs) + + + + + %(AdditionalInputs) + %(Outputs) + + + + + %(AdditionalInputs) + %(Outputs) + + + + + + + %(Outputs) + + + + + %(Outputs) + + + + + %(Outputs) + + + + + %(Outputs) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {fbe32df3-0fb0-4f2f-a424-2c21bd7bc325} + false + true + false + true + true + + + + + + \ No newline at end of file diff --git a/gfx/angle/src/compiler/translator_common.vcxproj.filters b/gfx/angle/src/compiler/translator_common.vcxproj.filters new file mode 100644 index 000000000000..2de92438c869 --- /dev/null +++ b/gfx/angle/src/compiler/translator_common.vcxproj.filters @@ -0,0 +1,268 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {eb8da157-b29c-43c3-880d-54679e176dc5} + + + {b5410d3a-c3c8-4ae6-843a-b000d652632e} + + + {a9847611-dcd5-4c89-8262-a22b96c7c98d} + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {094f7115-35d3-4c63-870c-ab5f393dc2c2} + + + {5f5742e9-15e1-43b4-b1e7-0c118be14e04} + + + {c4007e35-3c11-44d6-95f7-bb81db528068} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\generated + + + Source Files\generated + + + Source Files\depgraph + + + Source Files\depgraph + + + Source Files\depgraph + + + Source Files\depgraph + + + Source Files\timing + + + Source Files\timing + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files\generated + + + Header Files\timing + + + Header Files\timing + + + Header Files\depgraph + + + Header Files\depgraph + + + Header Files\depgraph + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/gfx/angle/src/compiler/translator_hlsl.vcproj b/gfx/angle/src/compiler/translator_hlsl.vcproj deleted file mode 100644 index 221d04896cbf..000000000000 --- a/gfx/angle/src/compiler/translator_hlsl.vcproj +++ /dev/null @@ -1,347 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/src/compiler/translator_hlsl.vcxproj b/gfx/angle/src/compiler/translator_hlsl.vcxproj new file mode 100644 index 000000000000..4ebc11c43a19 --- /dev/null +++ b/gfx/angle/src/compiler/translator_hlsl.vcxproj @@ -0,0 +1,172 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} + CrossCompilerHLSL + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\hlsl\ + $(SolutionDir)$(Configuration)\ + $(Configuration)\hlsl\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + + Disabled + $(ProjectDir)../;$(ProjectDir)../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + true + EditAndContinue + 4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings) + + + + + MaxSpeed + AnySuitable + true + $(ProjectDir)../;$(ProjectDir)../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + true + + + Level4 + true + ProgramDatabase + 4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings) + + + + + X64 + + + Disabled + $(ProjectDir)../;$(ProjectDir)../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + 4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings) + ProgramDatabase + true + + + + + X64 + + + MaxSpeed + AnySuitable + true + $(ProjectDir)../;$(ProjectDir)../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + true + + + Level4 + 4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings) + ProgramDatabase + true + + + + + + + + + + + + + + + + + + + + {5b3a6db8-1e7e-40d7-92b9-da8aae619fad} + false + true + false + true + true + + + + + + \ No newline at end of file diff --git a/gfx/angle/src/compiler/translator_hlsl.vcxproj.filters b/gfx/angle/src/compiler/translator_hlsl.vcxproj.filters new file mode 100644 index 000000000000..beee069eb39d --- /dev/null +++ b/gfx/angle/src/compiler/translator_hlsl.vcxproj.filters @@ -0,0 +1,50 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/gfx/angle/src/libEGL/Display.cpp b/gfx/angle/src/libEGL/Display.cpp index a2dee6d96483..0d40ad7bb5e8 100644 --- a/gfx/angle/src/libEGL/Display.cpp +++ b/gfx/angle/src/libEGL/Display.cpp @@ -70,7 +70,8 @@ egl::Display *Display::getDisplay(EGLNativeDisplayType displayId) Display::Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software) : mDc(deviceContext) { mD3d9Module = NULL; - + mD3dCompilerModule = NULL; + mD3d9 = NULL; mD3d9Ex = NULL; mDevice = NULL; @@ -128,6 +129,31 @@ bool Display::initialize() typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT, IDirect3D9Ex**); Direct3DCreate9ExFunc Direct3DCreate9ExPtr = reinterpret_cast(GetProcAddress(mD3d9Module, "Direct3DCreate9Ex")); + #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 (int i = 0; i < sizeof(d3dCompilerNames) / sizeof(*d3dCompilerNames); ++i) + { + if (GetModuleHandleEx(0, d3dCompilerNames[i], &mD3dCompilerModule)) + { + break; + } + } + #else + // Load the version of the D3DCompiler DLL associated with the Direct3D version ANGLE was built with. + mD3dCompilerModule = LoadLibrary(D3DCOMPILER_DLL); + #endif // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES + + if (!mD3dCompilerModule) + { + terminate(); + return false; + } + + mD3DCompileFunc = reinterpret_cast(GetProcAddress(mD3dCompilerModule, "D3DCompile")); + ASSERT(mD3DCompileFunc); + // Use Direct3D9Ex if available. Among other things, this version is less // inclined to report a lost context, for example when the user switches // desktop. Direct3D9Ex is available in Windows Vista and later if suitable drivers are available. @@ -231,7 +257,7 @@ bool Display::initialize() ConfigSet configSet; - for (int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(D3DFORMAT); formatIndex++) + for (unsigned int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(D3DFORMAT); formatIndex++) { D3DFORMAT renderTargetFormat = renderTargetFormats[formatIndex]; @@ -239,7 +265,7 @@ bool Display::initialize() if (SUCCEEDED(result)) { - for (int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(D3DFORMAT); depthStencilIndex++) + for (unsigned int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(D3DFORMAT); depthStencilIndex++) { D3DFORMAT depthStencilFormat = depthStencilFormats[depthStencilIndex]; HRESULT result = D3D_OK; @@ -367,6 +393,12 @@ void Display::terminate() { mD3d9Module = NULL; } + + if (mD3dCompilerModule) + { + FreeLibrary(mD3dCompilerModule); + mD3dCompilerModule = NULL; + } } void Display::startScene() @@ -1236,6 +1268,11 @@ IDirect3DVertexShader9 *Display::createVertexShader(const DWORD *function, size_ return mVertexShaderCache.create(function, length); } +HRESULT Display::compileShaderSource(const char* hlsl, const char* sourceName, const char* profile, DWORD flags, ID3DBlob** binary, ID3DBlob** errorMessage) +{ + return mD3DCompileFunc(hlsl, strlen(hlsl), sourceName, NULL, NULL, "main", profile, flags, 0, binary, errorMessage); +} + IDirect3DPixelShader9 *Display::createPixelShader(const DWORD *function, size_t length) { return mPixelShaderCache.create(function, length); diff --git a/gfx/angle/src/libEGL/Display.h b/gfx/angle/src/libEGL/Display.h index 23b57b74c66f..aedc8e77dca0 100644 --- a/gfx/angle/src/libEGL/Display.h +++ b/gfx/angle/src/libEGL/Display.h @@ -16,6 +16,7 @@ #endif #include #include +#include #include #include @@ -109,6 +110,8 @@ class Display virtual IDirect3DVertexShader9 *createVertexShader(const DWORD *function, size_t length); virtual IDirect3DPixelShader9 *createPixelShader(const DWORD *function, size_t length); + virtual HRESULT compileShaderSource(const char* hlsl, const char* sourceName, const char* profile, DWORD flags, ID3DBlob** binary, ID3DBlob** errorMessage); + private: DISALLOW_COPY_AND_ASSIGN(Display); @@ -161,6 +164,21 @@ class Display void initExtensionString(); std::string mExtensionString; + + typedef HRESULT (WINAPI *D3DCompileFunc)(LPCVOID pSrcData, + SIZE_T SrcDataSize, + LPCSTR pSourceName, + CONST D3D_SHADER_MACRO* pDefines, + ID3DInclude* pInclude, + LPCSTR pEntrypoint, + LPCSTR pTarget, + UINT Flags1, + UINT Flags2, + ID3DBlob** ppCode, + ID3DBlob** ppErrorMsgs); + + HMODULE mD3dCompilerModule; + D3DCompileFunc mD3DCompileFunc; }; } diff --git a/gfx/angle/src/libEGL/Makefile.in b/gfx/angle/src/libEGL/Makefile.in index 3f102627aa6d..8f9ad8a1efae 100644 --- a/gfx/angle/src/libEGL/Makefile.in +++ b/gfx/angle/src/libEGL/Makefile.in @@ -1,4 +1,3 @@ -# # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. @@ -12,40 +11,25 @@ include $(DEPTH)/config/autoconf.mk MODULE = libegl # On Windows, we don't automatically get "lib" prepended, but we need it. -LIBRARY_NAME = libEGL -MODULE_NAME = libegl -FORCE_SHARED_LIB=1 +LIBRARY_NAME = libEGL +MODULE_NAME = libegl +FORCE_SHARED_LIB = 1 # ANGLE uses the STL, so we can't use our derpy STL wrappers. -STL_FLAGS= +STL_FLAGS = # ANGLE uses exceptions internally, so we need to have exception handling # support -ENABLE_CXX_EXCEPTIONS=1 +ENABLE_CXX_EXCEPTIONS = 1 # Since we're building off in our own world, we don't want to have # mozilla-config.h and -DMOZILLA_CLIENT automatically included and defined, so # we just overwrite OS_COMPILE_C(XX)FLAGS. -OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) +OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS) -LOCAL_INCLUDES = \ - -I$(srcdir)/../../include \ - -I$(srcdir)/.. \ - -I"$(MOZ_DIRECTX_SDK_PATH)/include" \ - -VPATH += $(srcdir)/.. \ - $(srcdir)/../compiler \ - $(srcdir)/../compiler/preprocessor \ - $(srcdir)/../compiler/preprocessor/new \ - $(srcdir)/../common \ - $(NULL) - -# Translator/compiler first - DEFINES += -DANGLE_BUILD -DNOMINMAX -DLIBEGL_EXPORTS -D_CRT_SECURE_NO_DEPRECATE -#these defines are from ANGLE's build_angle.gyp DEFINES += -DANGLE_DISABLE_TRACE DEFINES += -DANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL0 @@ -53,9 +37,26 @@ ifndef MOZ_DEBUG DEFINES += -D_SECURE_SCL=0 endif -CPPSRCS = \ +# Below is a transcription of the EGL target from build_angle.gypi. + +# Target: 'libEGL' +# Links with: 'libGLESv2' +LOCAL_INCLUDES = \ + -I$(srcdir)/../../include \ + -I$(srcdir)/../../include/KHR \ + -I$(srcdir)/.. \ + -I"$(MOZ_DIRECTX_SDK_PATH)/include" + +VPATH += $(srcdir)/../common +# src/common: +CPPSRCS += \ debug.cpp \ RefCountObject.cpp \ + $(NULL) + +VPATH += $(srcdir)/../libEGL +# src/libEGL: +CPPSRCS += \ Config.cpp \ Display.cpp \ libEGL.cpp \ @@ -64,7 +65,7 @@ CPPSRCS = \ $(NULL) DEFFILE = $(srcdir)/libEGL.def -RCFILE = $(srcdir)/libEGL.rc +RCFILE = $(srcdir)/libEGL.rc include $(topsrcdir)/config/rules.mk diff --git a/gfx/angle/src/libEGL/Surface.cpp b/gfx/angle/src/libEGL/Surface.cpp index 732c404b10bf..047a14fbda9b 100644 --- a/gfx/angle/src/libEGL/Surface.cpp +++ b/gfx/angle/src/libEGL/Surface.cpp @@ -309,6 +309,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) result = mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mBackBuffer); ASSERT(SUCCEEDED(result)); + InvalidateRect(mWindow, NULL, FALSE); } if (mConfig->mDepthStencilFormat != D3DFMT_UNKNOWN) diff --git a/gfx/angle/src/libEGL/libEGL.vcproj b/gfx/angle/src/libEGL/libEGL.vcproj deleted file mode 100644 index cf00538cd2e5..000000000000 --- a/gfx/angle/src/libEGL/libEGL.vcproj +++ /dev/null @@ -1,439 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/src/libEGL/libEGL.vcxproj b/gfx/angle/src/libEGL/libEGL.vcxproj new file mode 100644 index 000000000000..8978764cc26e --- /dev/null +++ b/gfx/angle/src/libEGL/libEGL.vcxproj @@ -0,0 +1,262 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6} + libEGL + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + $(LibraryPath) + $(LibraryPath) + $(LibraryPath) + $(LibraryPath) + + + + Disabled + $(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + true + EditAndContinue + 4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings) + + + d3d9.lib;dxguid.lib;dwmapi.lib;%(AdditionalDependencies) + libEGL.def + dwmapi.dll;%(DelayLoadDLLs) + true + Windows + false + + + MachineX86 + + + %40echo on +mkdir "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" +%40echo off + + + + + + MaxSpeed + AnySuitable + $(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + ANGLE_DISABLE_TRACE;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + + + Level4 + true + ProgramDatabase + 4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings) + + + d3d9.lib;dxguid.lib;dwmapi.lib;%(AdditionalDependencies) + libEGL.def + dwmapi.dll;%(DelayLoadDLLs) + true + Windows + true + true + false + + + MachineX86 + + + %40echo on +mkdir "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" +%40echo off + + + + + + X64 + + + Disabled + $(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + 4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings) + ProgramDatabase + true + + + d3d9.lib;dxguid.lib;dwmapi.lib;%(AdditionalDependencies) + libEGL.def + dwmapi.dll;%(DelayLoadDLLs) + true + Windows + false + + + MachineX64 + + + %40echo on +mkdir "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" +%40echo off + + + + + + X64 + + + MaxSpeed + AnySuitable + $(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + + + Level4 + 4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings) + ProgramDatabase + true + + + d3d9.lib;dxguid.lib;dwmapi.lib;%(AdditionalDependencies) + libEGL.def + dwmapi.dll;%(DelayLoadDLLs) + true + Windows + true + true + false + + + MachineX64 + + + %40echo on +mkdir "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" +%40echo off + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {b5871a7a-968c-42e3-a33b-981e6f448e78} + false + + + + + + \ No newline at end of file diff --git a/gfx/angle/src/libEGL/libEGL.vcxproj.filters b/gfx/angle/src/libEGL/libEGL.vcxproj.filters new file mode 100644 index 000000000000..9139e499c5e7 --- /dev/null +++ b/gfx/angle/src/libEGL/libEGL.vcxproj.filters @@ -0,0 +1,70 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + + + + \ No newline at end of file diff --git a/gfx/angle/src/libEGL/main.cpp b/gfx/angle/src/libEGL/main.cpp index e3a79ac898e6..dc24c4fb04e3 100644 --- a/gfx/angle/src/libEGL/main.cpp +++ b/gfx/angle/src/libEGL/main.cpp @@ -12,7 +12,7 @@ static DWORD currentTLS = TLS_OUT_OF_INDEXES; -BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) +extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) { switch (reason) { diff --git a/gfx/angle/src/libGLESv2/BinaryStream.h b/gfx/angle/src/libGLESv2/BinaryStream.h index eb48b10e4236..5f7213b8dadf 100644 --- a/gfx/angle/src/libGLESv2/BinaryStream.h +++ b/gfx/angle/src/libGLESv2/BinaryStream.h @@ -80,6 +80,17 @@ class BinaryInputStream mOffset += length; } + void skip(size_t length) + { + if (mOffset + length > mLength) + { + mError = true; + return; + } + + mOffset += length; + } + size_t offset() const { return mOffset; diff --git a/gfx/angle/src/libGLESv2/Blit.cpp b/gfx/angle/src/libGLESv2/Blit.cpp index 13ff4ca61e34..70071964ca4a 100644 --- a/gfx/angle/src/libGLESv2/Blit.cpp +++ b/gfx/angle/src/libGLESv2/Blit.cpp @@ -11,6 +11,7 @@ #include "common/debug.h" #include "libGLESv2/main.h" +#include "libGLESv2/utilities.h" namespace { @@ -42,7 +43,7 @@ const size_t g_shaderSize[] = namespace gl { Blit::Blit(Context *context) - : mContext(context), mQuadVertexBuffer(NULL), mQuadVertexDeclaration(NULL), mSavedRenderTarget(NULL), mSavedDepthStencil(NULL), mSavedStateBlock(NULL) + : mContext(context), mQuadVertexBuffer(NULL), mQuadVertexDeclaration(NULL), mSavedStateBlock(NULL), mSavedRenderTarget(NULL), mSavedDepthStencil(NULL) { initGeometry(); memset(mCompiledShaders, 0, sizeof(mCompiledShaders)); @@ -216,7 +217,8 @@ bool Blit::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFo source->GetDesc(&sourceDesc); dest->GetDesc(&destDesc); - if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET) // Can use StretchRect + if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET && + dx2es::IsFormatChannelEquivalent(destDesc.Format, destFormat)) // Can use StretchRect { RECT destRect = {xoffset, yoffset, xoffset + (sourceRect.right - sourceRect.left), yoffset + (sourceRect.bottom - sourceRect.top)}; HRESULT result = device->StretchRect(source, &sourceRect, dest, &destRect, D3DTEXF_POINT); diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Context.cpp index c854478184d2..b96f51eaa61c 100644 --- a/gfx/angle/src/libGLESv2/Context.cpp +++ b/gfx/angle/src/libGLESv2/Context.cpp @@ -289,7 +289,7 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) }; int max = 0; - for (int i = 0; i < sizeof(renderBufferFormats) / sizeof(D3DFORMAT); ++i) + for (unsigned int i = 0; i < sizeof(renderBufferFormats) / sizeof(D3DFORMAT); ++i) { bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1]; mDisplay->getMultiSampleSupport(renderBufferFormats[i], multisampleArray); @@ -370,10 +370,6 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) depthStencil->Release(); } - // Reset pixel shader to null to work around a bug that only happens with Intel GPUs. - // http://crbug.com/110343 - mDevice->SetPixelShader(NULL); - markAllStateDirty(); } @@ -1576,8 +1572,19 @@ bool Context::getIntegerv(GLenum pname, GLint *params) } } break; - case GL_IMPLEMENTATION_COLOR_READ_TYPE: *params = gl::IMPLEMENTATION_COLOR_READ_TYPE; break; - case GL_IMPLEMENTATION_COLOR_READ_FORMAT: *params = gl::IMPLEMENTATION_COLOR_READ_FORMAT; break; + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + { + GLenum format, type; + if (getCurrentReadFormatType(&format, &type)) + { + if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) + *params = format; + else + *params = type; + } + } + break; case GL_MAX_VIEWPORT_DIMS: { int maxDimension = std::max(getMaximumRenderbufferDimension(), getMaximumTextureDimension()); @@ -1672,7 +1679,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) break; case GL_TEXTURE_BINDING_2D: { - if (mState.activeSampler < 0 || mState.activeSampler > getMaximumCombinedTextureImageUnits() - 1) + if (mState.activeSampler > getMaximumCombinedTextureImageUnits() - 1) { error(GL_INVALID_OPERATION); return false; @@ -1683,7 +1690,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) break; case GL_TEXTURE_BINDING_CUBE_MAP: { - if (mState.activeSampler < 0 || mState.activeSampler > getMaximumCombinedTextureImageUnits() - 1) + if (mState.activeSampler > getMaximumCombinedTextureImageUnits() - 1) { error(GL_INVALID_OPERATION); return false; @@ -2496,7 +2503,7 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, return error(GL_INVALID_OPERATION); } - GLsizei outputPitch = ComputePitch(width, format, type, mState.packAlignment); + GLsizei outputPitch = ComputePitch(width, ConvertSizedInternalFormat(format, type), mState.packAlignment); // sized query sanity check if (bufSize) { @@ -2611,19 +2618,51 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, inputPitch = lock.Pitch; } + unsigned int fastPixelSize = 0; + + if (desc.Format == D3DFMT_A8R8G8B8 && + format == GL_BGRA_EXT && + type == GL_UNSIGNED_BYTE) + { + fastPixelSize = 4; + } + else if ((desc.Format == D3DFMT_A4R4G4B4 && + format == GL_BGRA_EXT && + type == GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT) || + (desc.Format == D3DFMT_A1R5G5B5 && + format == GL_BGRA_EXT && + type == GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT)) + { + fastPixelSize = 2; + } + else if (desc.Format == D3DFMT_A16B16G16R16F && + format == GL_RGBA && + type == GL_HALF_FLOAT_OES) + { + fastPixelSize = 8; + } + else if (desc.Format == D3DFMT_A32B32G32R32F && + format == GL_RGBA && + type == GL_FLOAT) + { + fastPixelSize = 16; + } + for (int j = 0; j < rect.bottom - rect.top; j++) { - if (desc.Format == D3DFMT_A8R8G8B8 && - format == GL_BGRA_EXT && - type == GL_UNSIGNED_BYTE) + if (fastPixelSize != 0) { - // Fast path for EXT_read_format_bgra, given - // an RGBA source buffer. Note that buffers with no - // alpha go through the slow path below. - // Note that this is also the combo exposed by IMPLEMENTATION_COLOR_READ_TYPE/FORMAT + // 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) * 4); + (rect.right - rect.left) * fastPixelSize); continue; } @@ -2698,14 +2737,10 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, case D3DFMT_A16B16G16R16F: { // float formats in D3D are stored rgba, rather than the other way round - float abgr[4]; - - D3DXFloat16To32Array(abgr, (D3DXFLOAT16*)(source + 8 * i + j * inputPitch), 4); - - a = abgr[3]; - b = abgr[2]; - g = abgr[1]; - r = abgr[0]; + r = float16ToFloat32(*((unsigned short*)(source + 8 * i + j * inputPitch) + 0)); + g = float16ToFloat32(*((unsigned short*)(source + 8 * i + j * inputPitch) + 1)); + b = float16ToFloat32(*((unsigned short*)(source + 8 * i + j * inputPitch) + 2)); + a = float16ToFloat32(*((unsigned short*)(source + 8 * i + j * inputPitch) + 3)); } break; default: @@ -2777,6 +2812,11 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, ((unsigned short)(63 * g + 0.5f) << 5) | ((unsigned short)(31 * r + 0.5f) << 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; @@ -3056,7 +3096,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan return error(GL_INVALID_OPERATION); } - if (!cullSkipsDraw(mode)) + if (!skipDraw(mode)) { mDisplay->startScene(); @@ -3141,12 +3181,12 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid applyShaders(); applyTextures(); - if (!getCurrentProgramBinary()->validateSamplers(false)) + if (!getCurrentProgramBinary()->validateSamplers(NULL)) { return error(GL_INVALID_OPERATION); } - if (!cullSkipsDraw(mode)) + if (!skipDraw(mode)) { mDisplay->startScene(); @@ -3586,6 +3626,29 @@ float Context::getTextureMaxAnisotropy() const return mMaxTextureAnisotropy; } +bool Context::getCurrentReadFormatType(GLenum *format, GLenum *type) +{ + Framebuffer *framebuffer = getReadFramebuffer(); + if (!framebuffer || framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) + { + return error(GL_INVALID_OPERATION, false); + } + + Renderbuffer *renderbuffer = framebuffer->getColorbuffer(); + if (!renderbuffer) + { + return error(GL_INVALID_OPERATION, false); + } + + if(!dx2es::ConvertReadBufferFormat(renderbuffer->getD3DFormat(), format, type)) + { + ASSERT(false); + return false; + } + + return true; +} + void Context::detachBuffer(GLuint buffer) { // [OpenGL ES 2.0.24] section 2.9 page 22: @@ -3738,9 +3801,31 @@ Texture *Context::getIncompleteTexture(TextureType type) return t; } -bool Context::cullSkipsDraw(GLenum drawMode) +bool Context::skipDraw(GLenum drawMode) { - return mState.cullFace && mState.cullMode == GL_FRONT_AND_BACK && isTriangleMode(drawMode); + if (drawMode == GL_POINTS) + { + // ProgramBinary assumes non-point rendering if gl_PointSize isn't written, + // which affects varying interpolation. Since the value of gl_PointSize is + // undefined when not written, just skip drawing to avoid unexpected results. + if (!getCurrentProgramBinary()->usesPointSize()) + { + // This is stictly speaking not an error, but developers should be + // notified of risking undefined behavior. + ERR("Point rendering without writing to gl_PointSize."); + + return true; + } + } + else if (isTriangleMode(drawMode)) + { + if (mState.cullFace && mState.cullMode == GL_FRONT_AND_BACK) + { + return true; + } + } + + return false; } bool Context::isTriangleMode(GLenum drawMode) diff --git a/gfx/angle/src/libGLESv2/Context.h b/gfx/angle/src/libGLESv2/Context.h index 6fa24caacd9d..2bbae76ef82c 100644 --- a/gfx/angle/src/libGLESv2/Context.h +++ b/gfx/angle/src/libGLESv2/Context.h @@ -80,8 +80,8 @@ enum MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3, MAX_DRAW_BUFFERS = 1, - IMPLEMENTATION_COLOR_READ_FORMAT = GL_BGRA_EXT, - IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_BYTE + GL_BGRA4_ANGLEX = 0x6ABC, + GL_BGR5_A1_ANGLEX = 0x6ABD }; enum QueryType @@ -510,6 +510,8 @@ class Context bool supportsInstancing() const; bool supportsTextureFilterAnisotropy() const; + bool getCurrentReadFormatType(GLenum *format, GLenum *type); + float getTextureMaxAnisotropy() const; void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, @@ -538,7 +540,7 @@ class Context Texture *getIncompleteTexture(TextureType type); - bool cullSkipsDraw(GLenum drawMode); + bool skipDraw(GLenum drawMode); bool isTriangleMode(GLenum drawMode); void initExtensionString(); diff --git a/gfx/angle/src/libGLESv2/D3DConstantTable.cpp b/gfx/angle/src/libGLESv2/D3DConstantTable.cpp new file mode 100644 index 000000000000..d0c01def7d81 --- /dev/null +++ b/gfx/angle/src/libGLESv2/D3DConstantTable.cpp @@ -0,0 +1,231 @@ +// +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// D3DConstantTable.cpp: Implements the D3DConstantTable class which parses +// information about constants from the CTAB comment in a D3D shader blob. +// Restructures the constant table as a hierarchy of constants in the same +// way as D3DX. + +#include "libGLESv2/D3DConstantTable.h" + +#include +#include +#include +#include + +#include "libGLESv2/BinaryStream.h" + +const static int SHADER_VERSION_MASK = D3DVS_VERSION(0, 0); +const static int FOURCC_CTAB = MAKEFOURCC('C','T','A','B'); + +namespace gl +{ +// These structs and constants correspond to the format of the constant table in a shader binary. +// They match the corresponding structures in d3dx9shader.h. +namespace ctab +{ +struct ConstantTable +{ + DWORD size; + DWORD creator; + DWORD version; + DWORD constants; + DWORD constantInfos; + DWORD flags; + DWORD target; +}; + +struct ConstantInfo +{ + DWORD name; + WORD registerSet; + WORD registerIndex; + WORD registerCount; + WORD reserved; + DWORD typeInfo; + DWORD defaultValue; +}; + +struct TypeInfo +{ + WORD typeClass; + WORD type; + WORD rows; + WORD columns; + WORD elements; + WORD structMembers; + DWORD structMemberInfos; +}; + +struct StructMemberInfo +{ + DWORD name; + DWORD typeInfo; +}; +} + +D3DConstant::D3DConstant(const char *base, const ctab::ConstantInfo *constantInfo) +{ + const ctab::TypeInfo *typeInfo = reinterpret_cast(base + constantInfo->typeInfo); + + name = base + constantInfo->name; + registerSet = static_cast(constantInfo->registerSet); + registerIndex = constantInfo->registerIndex; + registerCount = constantInfo->registerCount; + typeClass = static_cast(typeInfo->typeClass); + type = static_cast(typeInfo->type); + rows = typeInfo->rows; + columns = typeInfo->columns; + elements = typeInfo->elements; + + if (typeClass == CLASS_STRUCT) + { + addStructMembers(base, registerSet, registerIndex, registerIndex + registerCount, typeInfo); + } +} + +D3DConstant::D3DConstant(const char *base, RegisterSet registerSet, unsigned registerIndex, unsigned maxRegister, const ctab::StructMemberInfo *memberInfo) + : registerSet(registerSet), registerIndex(registerIndex) +{ + const ctab::TypeInfo *typeInfo = reinterpret_cast(base + memberInfo->typeInfo); + + name = base + memberInfo->name; + registerCount = std::min(static_cast(maxRegister - registerIndex), typeInfo->rows * typeInfo->elements); + typeClass = static_cast(typeInfo->typeClass); + type = static_cast(typeInfo->type); + rows = typeInfo->rows; + columns = typeInfo->columns; + elements = typeInfo->elements; + + if (typeClass == CLASS_STRUCT) + { + registerCount = addStructMembers(base, registerSet, registerIndex, maxRegister, typeInfo); + } +} + +D3DConstant::~D3DConstant() +{ + for (size_t j = 0; j < structMembers.size(); ++j) + { + for (size_t i = 0; i < structMembers[j].size(); ++i) + { + delete structMembers[j][i]; + } + } +} + +unsigned D3DConstant::addStructMembers(const char *base, RegisterSet registerSet, unsigned registerIndex, unsigned maxRegister, const ctab::TypeInfo *typeInfo) +{ + const ctab::StructMemberInfo *memberInfos = reinterpret_cast( + base + typeInfo->structMemberInfos); + + unsigned memberIndex = registerIndex; + + structMembers.resize(elements); + + for (unsigned j = 0; j < elements; ++j) + { + structMembers[j].resize(typeInfo->structMembers); + + for (unsigned i = 0; i < typeInfo->structMembers; ++i) + { + const ctab::TypeInfo *memberTypeInfo = reinterpret_cast( + base + memberInfos[i].typeInfo); + + D3DConstant *member = new D3DConstant(base, registerSet, memberIndex, maxRegister, memberInfos + i); + memberIndex += member->registerCount; + + structMembers[j][i] = member; + } + } + + return memberIndex - registerIndex; +} + +D3DConstantTable::D3DConstantTable(void *blob, size_t size) : mError(false) +{ + BinaryInputStream stream(blob, size); + + int version; + stream.read(&version); + if ((version & SHADER_VERSION_MASK) != SHADER_VERSION_MASK) + { + mError = true; + return; + } + + const ctab::ConstantTable* constantTable = NULL; + + while (!stream.error()) + { + int token; + stream.read(&token); + + if ((token & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT) + { + size_t length = ((token & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT) * sizeof(DWORD); + + int fourcc; + stream.read(&fourcc); + if (fourcc == FOURCC_CTAB) + { + constantTable = reinterpret_cast(static_cast(blob) + stream.offset()); + break; + } + + stream.skip(length - sizeof(fourcc)); + } + else if (token == D3DSIO_END) + { + break; + } + } + + mError = !constantTable || stream.error(); + if (mError) + { + return; + } + + const char *base = reinterpret_cast(constantTable); + + mConstants.resize(constantTable->constants); + const ctab::ConstantInfo *constantInfos = + reinterpret_cast(base + constantTable->constantInfos); + for (size_t i = 0; i < constantTable->constants; ++i) + { + mConstants[i] = new D3DConstant(base, constantInfos + i); + } +} + +D3DConstantTable::~D3DConstantTable() +{ + for (size_t i = 0; i < mConstants.size(); ++i) + { + delete mConstants[i]; + } +} + +const D3DConstant *D3DConstantTable::getConstant(unsigned index) const +{ + return mConstants[index]; +} + +const D3DConstant *D3DConstantTable::getConstantByName(const char *name) const +{ + for (size_t i = 0; i < mConstants.size(); ++i) + { + const D3DConstant *constant = getConstant(i); + if (constant->name == name) + { + return constant; + } + } + + return NULL; +} + +} diff --git a/gfx/angle/src/libGLESv2/D3DConstantTable.h b/gfx/angle/src/libGLESv2/D3DConstantTable.h new file mode 100644 index 000000000000..b376911cf818 --- /dev/null +++ b/gfx/angle/src/libGLESv2/D3DConstantTable.h @@ -0,0 +1,117 @@ +// +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// D3DConstantTable.h: Implements the D3DConstantTable class which parses +// information about constants from the CTAB comment in a D3D shader blob. +// Restructures the constant table as a hierarchy of constants in the same +// way as D3DX. + +#ifndef LIBGLESV2_D3DCONSTANTTABLE_H_ +#define LIBGLESV2_D3DCONSTANTTABLE_H_ + +#include +#include + +#include "common/angleutils.h" + +namespace gl +{ + +namespace ctab +{ +struct ConstantTable; +struct ConstantInfo; +struct TypeInfo; +struct StructMemberInfo; +} + +struct D3DConstant +{ + // These enums match those in d3dx9shader.h. + enum Class + { + CLASS_SCALAR, + CLASS_VECTOR, + CLASS_MATRIX_ROWS, + CLASS_MATRIX_COLUMNS, + CLASS_OBJECT, + CLASS_STRUCT, + }; + + enum RegisterSet + { + RS_BOOL, + RS_INT4, + RS_FLOAT4, + RS_SAMPLER, + }; + + enum Type + { + PT_VOID, + PT_BOOL, + PT_INT, + PT_FLOAT, + PT_STRING, + PT_TEXTURE, + PT_TEXTURE1D, + PT_TEXTURE2D, + PT_TEXTURE3D, + PT_TEXTURECUBE, + PT_SAMPLER, + PT_SAMPLER1D, + PT_SAMPLER2D, + PT_SAMPLER3D, + PT_SAMPLERCUBE, + PT_PIXELSHADER, + PT_VERTEXSHADER, + PT_PIXELFRAGMENT, + PT_VERTEXFRAGMENT, + PT_UNSUPPORTED, + }; + + D3DConstant(const char *base, const ctab::ConstantInfo *constantInfo); + ~D3DConstant(); + + std::string name; + RegisterSet registerSet; + unsigned registerIndex; + unsigned registerCount; + Class typeClass; + Type type; + unsigned rows; + unsigned columns; + unsigned elements; + + // Array of structure members. + std::vector > structMembers; + + private: + D3DConstant(const char *base, RegisterSet registerSet, unsigned registerIndex, unsigned maxRegister, const ctab::StructMemberInfo *memberInfo); + unsigned addStructMembers(const char *base, RegisterSet registerSet, unsigned registerIndex, unsigned maxRegister, const ctab::TypeInfo *typeInfo); +}; + +class D3DConstantTable +{ + public: + D3DConstantTable(void *blob, size_t size); + ~D3DConstantTable(); + + bool error() const { return mError; } + + unsigned constants() const { return mConstants.size(); } + const D3DConstant *getConstant(unsigned index) const; + const D3DConstant *getConstantByName(const char *name) const; + + private: + DISALLOW_COPY_AND_ASSIGN(D3DConstantTable); + std::vector mConstants; + bool mError; +}; + +} + +#endif // LIBGLESV2_D3DCONSTANTTABLE_H_ diff --git a/gfx/angle/src/libGLESv2/Float16ToFloat32.cpp b/gfx/angle/src/libGLESv2/Float16ToFloat32.cpp new file mode 100644 index 000000000000..da3687ddd113 --- /dev/null +++ b/gfx/angle/src/libGLESv2/Float16ToFloat32.cpp @@ -0,0 +1,2203 @@ +// +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// This file is automatically generated. + +namespace gl +{ + +const static unsigned g_mantissa[2048] = { + 0x00000000, + 0x33800000, + 0x34000000, + 0x34400000, + 0x34800000, + 0x34a00000, + 0x34c00000, + 0x34e00000, + 0x35000000, + 0x35100000, + 0x35200000, + 0x35300000, + 0x35400000, + 0x35500000, + 0x35600000, + 0x35700000, + 0x35800000, + 0x35880000, + 0x35900000, + 0x35980000, + 0x35a00000, + 0x35a80000, + 0x35b00000, + 0x35b80000, + 0x35c00000, + 0x35c80000, + 0x35d00000, + 0x35d80000, + 0x35e00000, + 0x35e80000, + 0x35f00000, + 0x35f80000, + 0x36000000, + 0x36040000, + 0x36080000, + 0x360c0000, + 0x36100000, + 0x36140000, + 0x36180000, + 0x361c0000, + 0x36200000, + 0x36240000, + 0x36280000, + 0x362c0000, + 0x36300000, + 0x36340000, + 0x36380000, + 0x363c0000, + 0x36400000, + 0x36440000, + 0x36480000, + 0x364c0000, + 0x36500000, + 0x36540000, + 0x36580000, + 0x365c0000, + 0x36600000, + 0x36640000, + 0x36680000, + 0x366c0000, + 0x36700000, + 0x36740000, + 0x36780000, + 0x367c0000, + 0x36800000, + 0x36820000, + 0x36840000, + 0x36860000, + 0x36880000, + 0x368a0000, + 0x368c0000, + 0x368e0000, + 0x36900000, + 0x36920000, + 0x36940000, + 0x36960000, + 0x36980000, + 0x369a0000, + 0x369c0000, + 0x369e0000, + 0x36a00000, + 0x36a20000, + 0x36a40000, + 0x36a60000, + 0x36a80000, + 0x36aa0000, + 0x36ac0000, + 0x36ae0000, + 0x36b00000, + 0x36b20000, + 0x36b40000, + 0x36b60000, + 0x36b80000, + 0x36ba0000, + 0x36bc0000, + 0x36be0000, + 0x36c00000, + 0x36c20000, + 0x36c40000, + 0x36c60000, + 0x36c80000, + 0x36ca0000, + 0x36cc0000, + 0x36ce0000, + 0x36d00000, + 0x36d20000, + 0x36d40000, + 0x36d60000, + 0x36d80000, + 0x36da0000, + 0x36dc0000, + 0x36de0000, + 0x36e00000, + 0x36e20000, + 0x36e40000, + 0x36e60000, + 0x36e80000, + 0x36ea0000, + 0x36ec0000, + 0x36ee0000, + 0x36f00000, + 0x36f20000, + 0x36f40000, + 0x36f60000, + 0x36f80000, + 0x36fa0000, + 0x36fc0000, + 0x36fe0000, + 0x37000000, + 0x37010000, + 0x37020000, + 0x37030000, + 0x37040000, + 0x37050000, + 0x37060000, + 0x37070000, + 0x37080000, + 0x37090000, + 0x370a0000, + 0x370b0000, + 0x370c0000, + 0x370d0000, + 0x370e0000, + 0x370f0000, + 0x37100000, + 0x37110000, + 0x37120000, + 0x37130000, + 0x37140000, + 0x37150000, + 0x37160000, + 0x37170000, + 0x37180000, + 0x37190000, + 0x371a0000, + 0x371b0000, + 0x371c0000, + 0x371d0000, + 0x371e0000, + 0x371f0000, + 0x37200000, + 0x37210000, + 0x37220000, + 0x37230000, + 0x37240000, + 0x37250000, + 0x37260000, + 0x37270000, + 0x37280000, + 0x37290000, + 0x372a0000, + 0x372b0000, + 0x372c0000, + 0x372d0000, + 0x372e0000, + 0x372f0000, + 0x37300000, + 0x37310000, + 0x37320000, + 0x37330000, + 0x37340000, + 0x37350000, + 0x37360000, + 0x37370000, + 0x37380000, + 0x37390000, + 0x373a0000, + 0x373b0000, + 0x373c0000, + 0x373d0000, + 0x373e0000, + 0x373f0000, + 0x37400000, + 0x37410000, + 0x37420000, + 0x37430000, + 0x37440000, + 0x37450000, + 0x37460000, + 0x37470000, + 0x37480000, + 0x37490000, + 0x374a0000, + 0x374b0000, + 0x374c0000, + 0x374d0000, + 0x374e0000, + 0x374f0000, + 0x37500000, + 0x37510000, + 0x37520000, + 0x37530000, + 0x37540000, + 0x37550000, + 0x37560000, + 0x37570000, + 0x37580000, + 0x37590000, + 0x375a0000, + 0x375b0000, + 0x375c0000, + 0x375d0000, + 0x375e0000, + 0x375f0000, + 0x37600000, + 0x37610000, + 0x37620000, + 0x37630000, + 0x37640000, + 0x37650000, + 0x37660000, + 0x37670000, + 0x37680000, + 0x37690000, + 0x376a0000, + 0x376b0000, + 0x376c0000, + 0x376d0000, + 0x376e0000, + 0x376f0000, + 0x37700000, + 0x37710000, + 0x37720000, + 0x37730000, + 0x37740000, + 0x37750000, + 0x37760000, + 0x37770000, + 0x37780000, + 0x37790000, + 0x377a0000, + 0x377b0000, + 0x377c0000, + 0x377d0000, + 0x377e0000, + 0x377f0000, + 0x37800000, + 0x37808000, + 0x37810000, + 0x37818000, + 0x37820000, + 0x37828000, + 0x37830000, + 0x37838000, + 0x37840000, + 0x37848000, + 0x37850000, + 0x37858000, + 0x37860000, + 0x37868000, + 0x37870000, + 0x37878000, + 0x37880000, + 0x37888000, + 0x37890000, + 0x37898000, + 0x378a0000, + 0x378a8000, + 0x378b0000, + 0x378b8000, + 0x378c0000, + 0x378c8000, + 0x378d0000, + 0x378d8000, + 0x378e0000, + 0x378e8000, + 0x378f0000, + 0x378f8000, + 0x37900000, + 0x37908000, + 0x37910000, + 0x37918000, + 0x37920000, + 0x37928000, + 0x37930000, + 0x37938000, + 0x37940000, + 0x37948000, + 0x37950000, + 0x37958000, + 0x37960000, + 0x37968000, + 0x37970000, + 0x37978000, + 0x37980000, + 0x37988000, + 0x37990000, + 0x37998000, + 0x379a0000, + 0x379a8000, + 0x379b0000, + 0x379b8000, + 0x379c0000, + 0x379c8000, + 0x379d0000, + 0x379d8000, + 0x379e0000, + 0x379e8000, + 0x379f0000, + 0x379f8000, + 0x37a00000, + 0x37a08000, + 0x37a10000, + 0x37a18000, + 0x37a20000, + 0x37a28000, + 0x37a30000, + 0x37a38000, + 0x37a40000, + 0x37a48000, + 0x37a50000, + 0x37a58000, + 0x37a60000, + 0x37a68000, + 0x37a70000, + 0x37a78000, + 0x37a80000, + 0x37a88000, + 0x37a90000, + 0x37a98000, + 0x37aa0000, + 0x37aa8000, + 0x37ab0000, + 0x37ab8000, + 0x37ac0000, + 0x37ac8000, + 0x37ad0000, + 0x37ad8000, + 0x37ae0000, + 0x37ae8000, + 0x37af0000, + 0x37af8000, + 0x37b00000, + 0x37b08000, + 0x37b10000, + 0x37b18000, + 0x37b20000, + 0x37b28000, + 0x37b30000, + 0x37b38000, + 0x37b40000, + 0x37b48000, + 0x37b50000, + 0x37b58000, + 0x37b60000, + 0x37b68000, + 0x37b70000, + 0x37b78000, + 0x37b80000, + 0x37b88000, + 0x37b90000, + 0x37b98000, + 0x37ba0000, + 0x37ba8000, + 0x37bb0000, + 0x37bb8000, + 0x37bc0000, + 0x37bc8000, + 0x37bd0000, + 0x37bd8000, + 0x37be0000, + 0x37be8000, + 0x37bf0000, + 0x37bf8000, + 0x37c00000, + 0x37c08000, + 0x37c10000, + 0x37c18000, + 0x37c20000, + 0x37c28000, + 0x37c30000, + 0x37c38000, + 0x37c40000, + 0x37c48000, + 0x37c50000, + 0x37c58000, + 0x37c60000, + 0x37c68000, + 0x37c70000, + 0x37c78000, + 0x37c80000, + 0x37c88000, + 0x37c90000, + 0x37c98000, + 0x37ca0000, + 0x37ca8000, + 0x37cb0000, + 0x37cb8000, + 0x37cc0000, + 0x37cc8000, + 0x37cd0000, + 0x37cd8000, + 0x37ce0000, + 0x37ce8000, + 0x37cf0000, + 0x37cf8000, + 0x37d00000, + 0x37d08000, + 0x37d10000, + 0x37d18000, + 0x37d20000, + 0x37d28000, + 0x37d30000, + 0x37d38000, + 0x37d40000, + 0x37d48000, + 0x37d50000, + 0x37d58000, + 0x37d60000, + 0x37d68000, + 0x37d70000, + 0x37d78000, + 0x37d80000, + 0x37d88000, + 0x37d90000, + 0x37d98000, + 0x37da0000, + 0x37da8000, + 0x37db0000, + 0x37db8000, + 0x37dc0000, + 0x37dc8000, + 0x37dd0000, + 0x37dd8000, + 0x37de0000, + 0x37de8000, + 0x37df0000, + 0x37df8000, + 0x37e00000, + 0x37e08000, + 0x37e10000, + 0x37e18000, + 0x37e20000, + 0x37e28000, + 0x37e30000, + 0x37e38000, + 0x37e40000, + 0x37e48000, + 0x37e50000, + 0x37e58000, + 0x37e60000, + 0x37e68000, + 0x37e70000, + 0x37e78000, + 0x37e80000, + 0x37e88000, + 0x37e90000, + 0x37e98000, + 0x37ea0000, + 0x37ea8000, + 0x37eb0000, + 0x37eb8000, + 0x37ec0000, + 0x37ec8000, + 0x37ed0000, + 0x37ed8000, + 0x37ee0000, + 0x37ee8000, + 0x37ef0000, + 0x37ef8000, + 0x37f00000, + 0x37f08000, + 0x37f10000, + 0x37f18000, + 0x37f20000, + 0x37f28000, + 0x37f30000, + 0x37f38000, + 0x37f40000, + 0x37f48000, + 0x37f50000, + 0x37f58000, + 0x37f60000, + 0x37f68000, + 0x37f70000, + 0x37f78000, + 0x37f80000, + 0x37f88000, + 0x37f90000, + 0x37f98000, + 0x37fa0000, + 0x37fa8000, + 0x37fb0000, + 0x37fb8000, + 0x37fc0000, + 0x37fc8000, + 0x37fd0000, + 0x37fd8000, + 0x37fe0000, + 0x37fe8000, + 0x37ff0000, + 0x37ff8000, + 0x38000000, + 0x38004000, + 0x38008000, + 0x3800c000, + 0x38010000, + 0x38014000, + 0x38018000, + 0x3801c000, + 0x38020000, + 0x38024000, + 0x38028000, + 0x3802c000, + 0x38030000, + 0x38034000, + 0x38038000, + 0x3803c000, + 0x38040000, + 0x38044000, + 0x38048000, + 0x3804c000, + 0x38050000, + 0x38054000, + 0x38058000, + 0x3805c000, + 0x38060000, + 0x38064000, + 0x38068000, + 0x3806c000, + 0x38070000, + 0x38074000, + 0x38078000, + 0x3807c000, + 0x38080000, + 0x38084000, + 0x38088000, + 0x3808c000, + 0x38090000, + 0x38094000, + 0x38098000, + 0x3809c000, + 0x380a0000, + 0x380a4000, + 0x380a8000, + 0x380ac000, + 0x380b0000, + 0x380b4000, + 0x380b8000, + 0x380bc000, + 0x380c0000, + 0x380c4000, + 0x380c8000, + 0x380cc000, + 0x380d0000, + 0x380d4000, + 0x380d8000, + 0x380dc000, + 0x380e0000, + 0x380e4000, + 0x380e8000, + 0x380ec000, + 0x380f0000, + 0x380f4000, + 0x380f8000, + 0x380fc000, + 0x38100000, + 0x38104000, + 0x38108000, + 0x3810c000, + 0x38110000, + 0x38114000, + 0x38118000, + 0x3811c000, + 0x38120000, + 0x38124000, + 0x38128000, + 0x3812c000, + 0x38130000, + 0x38134000, + 0x38138000, + 0x3813c000, + 0x38140000, + 0x38144000, + 0x38148000, + 0x3814c000, + 0x38150000, + 0x38154000, + 0x38158000, + 0x3815c000, + 0x38160000, + 0x38164000, + 0x38168000, + 0x3816c000, + 0x38170000, + 0x38174000, + 0x38178000, + 0x3817c000, + 0x38180000, + 0x38184000, + 0x38188000, + 0x3818c000, + 0x38190000, + 0x38194000, + 0x38198000, + 0x3819c000, + 0x381a0000, + 0x381a4000, + 0x381a8000, + 0x381ac000, + 0x381b0000, + 0x381b4000, + 0x381b8000, + 0x381bc000, + 0x381c0000, + 0x381c4000, + 0x381c8000, + 0x381cc000, + 0x381d0000, + 0x381d4000, + 0x381d8000, + 0x381dc000, + 0x381e0000, + 0x381e4000, + 0x381e8000, + 0x381ec000, + 0x381f0000, + 0x381f4000, + 0x381f8000, + 0x381fc000, + 0x38200000, + 0x38204000, + 0x38208000, + 0x3820c000, + 0x38210000, + 0x38214000, + 0x38218000, + 0x3821c000, + 0x38220000, + 0x38224000, + 0x38228000, + 0x3822c000, + 0x38230000, + 0x38234000, + 0x38238000, + 0x3823c000, + 0x38240000, + 0x38244000, + 0x38248000, + 0x3824c000, + 0x38250000, + 0x38254000, + 0x38258000, + 0x3825c000, + 0x38260000, + 0x38264000, + 0x38268000, + 0x3826c000, + 0x38270000, + 0x38274000, + 0x38278000, + 0x3827c000, + 0x38280000, + 0x38284000, + 0x38288000, + 0x3828c000, + 0x38290000, + 0x38294000, + 0x38298000, + 0x3829c000, + 0x382a0000, + 0x382a4000, + 0x382a8000, + 0x382ac000, + 0x382b0000, + 0x382b4000, + 0x382b8000, + 0x382bc000, + 0x382c0000, + 0x382c4000, + 0x382c8000, + 0x382cc000, + 0x382d0000, + 0x382d4000, + 0x382d8000, + 0x382dc000, + 0x382e0000, + 0x382e4000, + 0x382e8000, + 0x382ec000, + 0x382f0000, + 0x382f4000, + 0x382f8000, + 0x382fc000, + 0x38300000, + 0x38304000, + 0x38308000, + 0x3830c000, + 0x38310000, + 0x38314000, + 0x38318000, + 0x3831c000, + 0x38320000, + 0x38324000, + 0x38328000, + 0x3832c000, + 0x38330000, + 0x38334000, + 0x38338000, + 0x3833c000, + 0x38340000, + 0x38344000, + 0x38348000, + 0x3834c000, + 0x38350000, + 0x38354000, + 0x38358000, + 0x3835c000, + 0x38360000, + 0x38364000, + 0x38368000, + 0x3836c000, + 0x38370000, + 0x38374000, + 0x38378000, + 0x3837c000, + 0x38380000, + 0x38384000, + 0x38388000, + 0x3838c000, + 0x38390000, + 0x38394000, + 0x38398000, + 0x3839c000, + 0x383a0000, + 0x383a4000, + 0x383a8000, + 0x383ac000, + 0x383b0000, + 0x383b4000, + 0x383b8000, + 0x383bc000, + 0x383c0000, + 0x383c4000, + 0x383c8000, + 0x383cc000, + 0x383d0000, + 0x383d4000, + 0x383d8000, + 0x383dc000, + 0x383e0000, + 0x383e4000, + 0x383e8000, + 0x383ec000, + 0x383f0000, + 0x383f4000, + 0x383f8000, + 0x383fc000, + 0x38400000, + 0x38404000, + 0x38408000, + 0x3840c000, + 0x38410000, + 0x38414000, + 0x38418000, + 0x3841c000, + 0x38420000, + 0x38424000, + 0x38428000, + 0x3842c000, + 0x38430000, + 0x38434000, + 0x38438000, + 0x3843c000, + 0x38440000, + 0x38444000, + 0x38448000, + 0x3844c000, + 0x38450000, + 0x38454000, + 0x38458000, + 0x3845c000, + 0x38460000, + 0x38464000, + 0x38468000, + 0x3846c000, + 0x38470000, + 0x38474000, + 0x38478000, + 0x3847c000, + 0x38480000, + 0x38484000, + 0x38488000, + 0x3848c000, + 0x38490000, + 0x38494000, + 0x38498000, + 0x3849c000, + 0x384a0000, + 0x384a4000, + 0x384a8000, + 0x384ac000, + 0x384b0000, + 0x384b4000, + 0x384b8000, + 0x384bc000, + 0x384c0000, + 0x384c4000, + 0x384c8000, + 0x384cc000, + 0x384d0000, + 0x384d4000, + 0x384d8000, + 0x384dc000, + 0x384e0000, + 0x384e4000, + 0x384e8000, + 0x384ec000, + 0x384f0000, + 0x384f4000, + 0x384f8000, + 0x384fc000, + 0x38500000, + 0x38504000, + 0x38508000, + 0x3850c000, + 0x38510000, + 0x38514000, + 0x38518000, + 0x3851c000, + 0x38520000, + 0x38524000, + 0x38528000, + 0x3852c000, + 0x38530000, + 0x38534000, + 0x38538000, + 0x3853c000, + 0x38540000, + 0x38544000, + 0x38548000, + 0x3854c000, + 0x38550000, + 0x38554000, + 0x38558000, + 0x3855c000, + 0x38560000, + 0x38564000, + 0x38568000, + 0x3856c000, + 0x38570000, + 0x38574000, + 0x38578000, + 0x3857c000, + 0x38580000, + 0x38584000, + 0x38588000, + 0x3858c000, + 0x38590000, + 0x38594000, + 0x38598000, + 0x3859c000, + 0x385a0000, + 0x385a4000, + 0x385a8000, + 0x385ac000, + 0x385b0000, + 0x385b4000, + 0x385b8000, + 0x385bc000, + 0x385c0000, + 0x385c4000, + 0x385c8000, + 0x385cc000, + 0x385d0000, + 0x385d4000, + 0x385d8000, + 0x385dc000, + 0x385e0000, + 0x385e4000, + 0x385e8000, + 0x385ec000, + 0x385f0000, + 0x385f4000, + 0x385f8000, + 0x385fc000, + 0x38600000, + 0x38604000, + 0x38608000, + 0x3860c000, + 0x38610000, + 0x38614000, + 0x38618000, + 0x3861c000, + 0x38620000, + 0x38624000, + 0x38628000, + 0x3862c000, + 0x38630000, + 0x38634000, + 0x38638000, + 0x3863c000, + 0x38640000, + 0x38644000, + 0x38648000, + 0x3864c000, + 0x38650000, + 0x38654000, + 0x38658000, + 0x3865c000, + 0x38660000, + 0x38664000, + 0x38668000, + 0x3866c000, + 0x38670000, + 0x38674000, + 0x38678000, + 0x3867c000, + 0x38680000, + 0x38684000, + 0x38688000, + 0x3868c000, + 0x38690000, + 0x38694000, + 0x38698000, + 0x3869c000, + 0x386a0000, + 0x386a4000, + 0x386a8000, + 0x386ac000, + 0x386b0000, + 0x386b4000, + 0x386b8000, + 0x386bc000, + 0x386c0000, + 0x386c4000, + 0x386c8000, + 0x386cc000, + 0x386d0000, + 0x386d4000, + 0x386d8000, + 0x386dc000, + 0x386e0000, + 0x386e4000, + 0x386e8000, + 0x386ec000, + 0x386f0000, + 0x386f4000, + 0x386f8000, + 0x386fc000, + 0x38700000, + 0x38704000, + 0x38708000, + 0x3870c000, + 0x38710000, + 0x38714000, + 0x38718000, + 0x3871c000, + 0x38720000, + 0x38724000, + 0x38728000, + 0x3872c000, + 0x38730000, + 0x38734000, + 0x38738000, + 0x3873c000, + 0x38740000, + 0x38744000, + 0x38748000, + 0x3874c000, + 0x38750000, + 0x38754000, + 0x38758000, + 0x3875c000, + 0x38760000, + 0x38764000, + 0x38768000, + 0x3876c000, + 0x38770000, + 0x38774000, + 0x38778000, + 0x3877c000, + 0x38780000, + 0x38784000, + 0x38788000, + 0x3878c000, + 0x38790000, + 0x38794000, + 0x38798000, + 0x3879c000, + 0x387a0000, + 0x387a4000, + 0x387a8000, + 0x387ac000, + 0x387b0000, + 0x387b4000, + 0x387b8000, + 0x387bc000, + 0x387c0000, + 0x387c4000, + 0x387c8000, + 0x387cc000, + 0x387d0000, + 0x387d4000, + 0x387d8000, + 0x387dc000, + 0x387e0000, + 0x387e4000, + 0x387e8000, + 0x387ec000, + 0x387f0000, + 0x387f4000, + 0x387f8000, + 0x387fc000, + 0x38000000, + 0x38002000, + 0x38004000, + 0x38006000, + 0x38008000, + 0x3800a000, + 0x3800c000, + 0x3800e000, + 0x38010000, + 0x38012000, + 0x38014000, + 0x38016000, + 0x38018000, + 0x3801a000, + 0x3801c000, + 0x3801e000, + 0x38020000, + 0x38022000, + 0x38024000, + 0x38026000, + 0x38028000, + 0x3802a000, + 0x3802c000, + 0x3802e000, + 0x38030000, + 0x38032000, + 0x38034000, + 0x38036000, + 0x38038000, + 0x3803a000, + 0x3803c000, + 0x3803e000, + 0x38040000, + 0x38042000, + 0x38044000, + 0x38046000, + 0x38048000, + 0x3804a000, + 0x3804c000, + 0x3804e000, + 0x38050000, + 0x38052000, + 0x38054000, + 0x38056000, + 0x38058000, + 0x3805a000, + 0x3805c000, + 0x3805e000, + 0x38060000, + 0x38062000, + 0x38064000, + 0x38066000, + 0x38068000, + 0x3806a000, + 0x3806c000, + 0x3806e000, + 0x38070000, + 0x38072000, + 0x38074000, + 0x38076000, + 0x38078000, + 0x3807a000, + 0x3807c000, + 0x3807e000, + 0x38080000, + 0x38082000, + 0x38084000, + 0x38086000, + 0x38088000, + 0x3808a000, + 0x3808c000, + 0x3808e000, + 0x38090000, + 0x38092000, + 0x38094000, + 0x38096000, + 0x38098000, + 0x3809a000, + 0x3809c000, + 0x3809e000, + 0x380a0000, + 0x380a2000, + 0x380a4000, + 0x380a6000, + 0x380a8000, + 0x380aa000, + 0x380ac000, + 0x380ae000, + 0x380b0000, + 0x380b2000, + 0x380b4000, + 0x380b6000, + 0x380b8000, + 0x380ba000, + 0x380bc000, + 0x380be000, + 0x380c0000, + 0x380c2000, + 0x380c4000, + 0x380c6000, + 0x380c8000, + 0x380ca000, + 0x380cc000, + 0x380ce000, + 0x380d0000, + 0x380d2000, + 0x380d4000, + 0x380d6000, + 0x380d8000, + 0x380da000, + 0x380dc000, + 0x380de000, + 0x380e0000, + 0x380e2000, + 0x380e4000, + 0x380e6000, + 0x380e8000, + 0x380ea000, + 0x380ec000, + 0x380ee000, + 0x380f0000, + 0x380f2000, + 0x380f4000, + 0x380f6000, + 0x380f8000, + 0x380fa000, + 0x380fc000, + 0x380fe000, + 0x38100000, + 0x38102000, + 0x38104000, + 0x38106000, + 0x38108000, + 0x3810a000, + 0x3810c000, + 0x3810e000, + 0x38110000, + 0x38112000, + 0x38114000, + 0x38116000, + 0x38118000, + 0x3811a000, + 0x3811c000, + 0x3811e000, + 0x38120000, + 0x38122000, + 0x38124000, + 0x38126000, + 0x38128000, + 0x3812a000, + 0x3812c000, + 0x3812e000, + 0x38130000, + 0x38132000, + 0x38134000, + 0x38136000, + 0x38138000, + 0x3813a000, + 0x3813c000, + 0x3813e000, + 0x38140000, + 0x38142000, + 0x38144000, + 0x38146000, + 0x38148000, + 0x3814a000, + 0x3814c000, + 0x3814e000, + 0x38150000, + 0x38152000, + 0x38154000, + 0x38156000, + 0x38158000, + 0x3815a000, + 0x3815c000, + 0x3815e000, + 0x38160000, + 0x38162000, + 0x38164000, + 0x38166000, + 0x38168000, + 0x3816a000, + 0x3816c000, + 0x3816e000, + 0x38170000, + 0x38172000, + 0x38174000, + 0x38176000, + 0x38178000, + 0x3817a000, + 0x3817c000, + 0x3817e000, + 0x38180000, + 0x38182000, + 0x38184000, + 0x38186000, + 0x38188000, + 0x3818a000, + 0x3818c000, + 0x3818e000, + 0x38190000, + 0x38192000, + 0x38194000, + 0x38196000, + 0x38198000, + 0x3819a000, + 0x3819c000, + 0x3819e000, + 0x381a0000, + 0x381a2000, + 0x381a4000, + 0x381a6000, + 0x381a8000, + 0x381aa000, + 0x381ac000, + 0x381ae000, + 0x381b0000, + 0x381b2000, + 0x381b4000, + 0x381b6000, + 0x381b8000, + 0x381ba000, + 0x381bc000, + 0x381be000, + 0x381c0000, + 0x381c2000, + 0x381c4000, + 0x381c6000, + 0x381c8000, + 0x381ca000, + 0x381cc000, + 0x381ce000, + 0x381d0000, + 0x381d2000, + 0x381d4000, + 0x381d6000, + 0x381d8000, + 0x381da000, + 0x381dc000, + 0x381de000, + 0x381e0000, + 0x381e2000, + 0x381e4000, + 0x381e6000, + 0x381e8000, + 0x381ea000, + 0x381ec000, + 0x381ee000, + 0x381f0000, + 0x381f2000, + 0x381f4000, + 0x381f6000, + 0x381f8000, + 0x381fa000, + 0x381fc000, + 0x381fe000, + 0x38200000, + 0x38202000, + 0x38204000, + 0x38206000, + 0x38208000, + 0x3820a000, + 0x3820c000, + 0x3820e000, + 0x38210000, + 0x38212000, + 0x38214000, + 0x38216000, + 0x38218000, + 0x3821a000, + 0x3821c000, + 0x3821e000, + 0x38220000, + 0x38222000, + 0x38224000, + 0x38226000, + 0x38228000, + 0x3822a000, + 0x3822c000, + 0x3822e000, + 0x38230000, + 0x38232000, + 0x38234000, + 0x38236000, + 0x38238000, + 0x3823a000, + 0x3823c000, + 0x3823e000, + 0x38240000, + 0x38242000, + 0x38244000, + 0x38246000, + 0x38248000, + 0x3824a000, + 0x3824c000, + 0x3824e000, + 0x38250000, + 0x38252000, + 0x38254000, + 0x38256000, + 0x38258000, + 0x3825a000, + 0x3825c000, + 0x3825e000, + 0x38260000, + 0x38262000, + 0x38264000, + 0x38266000, + 0x38268000, + 0x3826a000, + 0x3826c000, + 0x3826e000, + 0x38270000, + 0x38272000, + 0x38274000, + 0x38276000, + 0x38278000, + 0x3827a000, + 0x3827c000, + 0x3827e000, + 0x38280000, + 0x38282000, + 0x38284000, + 0x38286000, + 0x38288000, + 0x3828a000, + 0x3828c000, + 0x3828e000, + 0x38290000, + 0x38292000, + 0x38294000, + 0x38296000, + 0x38298000, + 0x3829a000, + 0x3829c000, + 0x3829e000, + 0x382a0000, + 0x382a2000, + 0x382a4000, + 0x382a6000, + 0x382a8000, + 0x382aa000, + 0x382ac000, + 0x382ae000, + 0x382b0000, + 0x382b2000, + 0x382b4000, + 0x382b6000, + 0x382b8000, + 0x382ba000, + 0x382bc000, + 0x382be000, + 0x382c0000, + 0x382c2000, + 0x382c4000, + 0x382c6000, + 0x382c8000, + 0x382ca000, + 0x382cc000, + 0x382ce000, + 0x382d0000, + 0x382d2000, + 0x382d4000, + 0x382d6000, + 0x382d8000, + 0x382da000, + 0x382dc000, + 0x382de000, + 0x382e0000, + 0x382e2000, + 0x382e4000, + 0x382e6000, + 0x382e8000, + 0x382ea000, + 0x382ec000, + 0x382ee000, + 0x382f0000, + 0x382f2000, + 0x382f4000, + 0x382f6000, + 0x382f8000, + 0x382fa000, + 0x382fc000, + 0x382fe000, + 0x38300000, + 0x38302000, + 0x38304000, + 0x38306000, + 0x38308000, + 0x3830a000, + 0x3830c000, + 0x3830e000, + 0x38310000, + 0x38312000, + 0x38314000, + 0x38316000, + 0x38318000, + 0x3831a000, + 0x3831c000, + 0x3831e000, + 0x38320000, + 0x38322000, + 0x38324000, + 0x38326000, + 0x38328000, + 0x3832a000, + 0x3832c000, + 0x3832e000, + 0x38330000, + 0x38332000, + 0x38334000, + 0x38336000, + 0x38338000, + 0x3833a000, + 0x3833c000, + 0x3833e000, + 0x38340000, + 0x38342000, + 0x38344000, + 0x38346000, + 0x38348000, + 0x3834a000, + 0x3834c000, + 0x3834e000, + 0x38350000, + 0x38352000, + 0x38354000, + 0x38356000, + 0x38358000, + 0x3835a000, + 0x3835c000, + 0x3835e000, + 0x38360000, + 0x38362000, + 0x38364000, + 0x38366000, + 0x38368000, + 0x3836a000, + 0x3836c000, + 0x3836e000, + 0x38370000, + 0x38372000, + 0x38374000, + 0x38376000, + 0x38378000, + 0x3837a000, + 0x3837c000, + 0x3837e000, + 0x38380000, + 0x38382000, + 0x38384000, + 0x38386000, + 0x38388000, + 0x3838a000, + 0x3838c000, + 0x3838e000, + 0x38390000, + 0x38392000, + 0x38394000, + 0x38396000, + 0x38398000, + 0x3839a000, + 0x3839c000, + 0x3839e000, + 0x383a0000, + 0x383a2000, + 0x383a4000, + 0x383a6000, + 0x383a8000, + 0x383aa000, + 0x383ac000, + 0x383ae000, + 0x383b0000, + 0x383b2000, + 0x383b4000, + 0x383b6000, + 0x383b8000, + 0x383ba000, + 0x383bc000, + 0x383be000, + 0x383c0000, + 0x383c2000, + 0x383c4000, + 0x383c6000, + 0x383c8000, + 0x383ca000, + 0x383cc000, + 0x383ce000, + 0x383d0000, + 0x383d2000, + 0x383d4000, + 0x383d6000, + 0x383d8000, + 0x383da000, + 0x383dc000, + 0x383de000, + 0x383e0000, + 0x383e2000, + 0x383e4000, + 0x383e6000, + 0x383e8000, + 0x383ea000, + 0x383ec000, + 0x383ee000, + 0x383f0000, + 0x383f2000, + 0x383f4000, + 0x383f6000, + 0x383f8000, + 0x383fa000, + 0x383fc000, + 0x383fe000, + 0x38400000, + 0x38402000, + 0x38404000, + 0x38406000, + 0x38408000, + 0x3840a000, + 0x3840c000, + 0x3840e000, + 0x38410000, + 0x38412000, + 0x38414000, + 0x38416000, + 0x38418000, + 0x3841a000, + 0x3841c000, + 0x3841e000, + 0x38420000, + 0x38422000, + 0x38424000, + 0x38426000, + 0x38428000, + 0x3842a000, + 0x3842c000, + 0x3842e000, + 0x38430000, + 0x38432000, + 0x38434000, + 0x38436000, + 0x38438000, + 0x3843a000, + 0x3843c000, + 0x3843e000, + 0x38440000, + 0x38442000, + 0x38444000, + 0x38446000, + 0x38448000, + 0x3844a000, + 0x3844c000, + 0x3844e000, + 0x38450000, + 0x38452000, + 0x38454000, + 0x38456000, + 0x38458000, + 0x3845a000, + 0x3845c000, + 0x3845e000, + 0x38460000, + 0x38462000, + 0x38464000, + 0x38466000, + 0x38468000, + 0x3846a000, + 0x3846c000, + 0x3846e000, + 0x38470000, + 0x38472000, + 0x38474000, + 0x38476000, + 0x38478000, + 0x3847a000, + 0x3847c000, + 0x3847e000, + 0x38480000, + 0x38482000, + 0x38484000, + 0x38486000, + 0x38488000, + 0x3848a000, + 0x3848c000, + 0x3848e000, + 0x38490000, + 0x38492000, + 0x38494000, + 0x38496000, + 0x38498000, + 0x3849a000, + 0x3849c000, + 0x3849e000, + 0x384a0000, + 0x384a2000, + 0x384a4000, + 0x384a6000, + 0x384a8000, + 0x384aa000, + 0x384ac000, + 0x384ae000, + 0x384b0000, + 0x384b2000, + 0x384b4000, + 0x384b6000, + 0x384b8000, + 0x384ba000, + 0x384bc000, + 0x384be000, + 0x384c0000, + 0x384c2000, + 0x384c4000, + 0x384c6000, + 0x384c8000, + 0x384ca000, + 0x384cc000, + 0x384ce000, + 0x384d0000, + 0x384d2000, + 0x384d4000, + 0x384d6000, + 0x384d8000, + 0x384da000, + 0x384dc000, + 0x384de000, + 0x384e0000, + 0x384e2000, + 0x384e4000, + 0x384e6000, + 0x384e8000, + 0x384ea000, + 0x384ec000, + 0x384ee000, + 0x384f0000, + 0x384f2000, + 0x384f4000, + 0x384f6000, + 0x384f8000, + 0x384fa000, + 0x384fc000, + 0x384fe000, + 0x38500000, + 0x38502000, + 0x38504000, + 0x38506000, + 0x38508000, + 0x3850a000, + 0x3850c000, + 0x3850e000, + 0x38510000, + 0x38512000, + 0x38514000, + 0x38516000, + 0x38518000, + 0x3851a000, + 0x3851c000, + 0x3851e000, + 0x38520000, + 0x38522000, + 0x38524000, + 0x38526000, + 0x38528000, + 0x3852a000, + 0x3852c000, + 0x3852e000, + 0x38530000, + 0x38532000, + 0x38534000, + 0x38536000, + 0x38538000, + 0x3853a000, + 0x3853c000, + 0x3853e000, + 0x38540000, + 0x38542000, + 0x38544000, + 0x38546000, + 0x38548000, + 0x3854a000, + 0x3854c000, + 0x3854e000, + 0x38550000, + 0x38552000, + 0x38554000, + 0x38556000, + 0x38558000, + 0x3855a000, + 0x3855c000, + 0x3855e000, + 0x38560000, + 0x38562000, + 0x38564000, + 0x38566000, + 0x38568000, + 0x3856a000, + 0x3856c000, + 0x3856e000, + 0x38570000, + 0x38572000, + 0x38574000, + 0x38576000, + 0x38578000, + 0x3857a000, + 0x3857c000, + 0x3857e000, + 0x38580000, + 0x38582000, + 0x38584000, + 0x38586000, + 0x38588000, + 0x3858a000, + 0x3858c000, + 0x3858e000, + 0x38590000, + 0x38592000, + 0x38594000, + 0x38596000, + 0x38598000, + 0x3859a000, + 0x3859c000, + 0x3859e000, + 0x385a0000, + 0x385a2000, + 0x385a4000, + 0x385a6000, + 0x385a8000, + 0x385aa000, + 0x385ac000, + 0x385ae000, + 0x385b0000, + 0x385b2000, + 0x385b4000, + 0x385b6000, + 0x385b8000, + 0x385ba000, + 0x385bc000, + 0x385be000, + 0x385c0000, + 0x385c2000, + 0x385c4000, + 0x385c6000, + 0x385c8000, + 0x385ca000, + 0x385cc000, + 0x385ce000, + 0x385d0000, + 0x385d2000, + 0x385d4000, + 0x385d6000, + 0x385d8000, + 0x385da000, + 0x385dc000, + 0x385de000, + 0x385e0000, + 0x385e2000, + 0x385e4000, + 0x385e6000, + 0x385e8000, + 0x385ea000, + 0x385ec000, + 0x385ee000, + 0x385f0000, + 0x385f2000, + 0x385f4000, + 0x385f6000, + 0x385f8000, + 0x385fa000, + 0x385fc000, + 0x385fe000, + 0x38600000, + 0x38602000, + 0x38604000, + 0x38606000, + 0x38608000, + 0x3860a000, + 0x3860c000, + 0x3860e000, + 0x38610000, + 0x38612000, + 0x38614000, + 0x38616000, + 0x38618000, + 0x3861a000, + 0x3861c000, + 0x3861e000, + 0x38620000, + 0x38622000, + 0x38624000, + 0x38626000, + 0x38628000, + 0x3862a000, + 0x3862c000, + 0x3862e000, + 0x38630000, + 0x38632000, + 0x38634000, + 0x38636000, + 0x38638000, + 0x3863a000, + 0x3863c000, + 0x3863e000, + 0x38640000, + 0x38642000, + 0x38644000, + 0x38646000, + 0x38648000, + 0x3864a000, + 0x3864c000, + 0x3864e000, + 0x38650000, + 0x38652000, + 0x38654000, + 0x38656000, + 0x38658000, + 0x3865a000, + 0x3865c000, + 0x3865e000, + 0x38660000, + 0x38662000, + 0x38664000, + 0x38666000, + 0x38668000, + 0x3866a000, + 0x3866c000, + 0x3866e000, + 0x38670000, + 0x38672000, + 0x38674000, + 0x38676000, + 0x38678000, + 0x3867a000, + 0x3867c000, + 0x3867e000, + 0x38680000, + 0x38682000, + 0x38684000, + 0x38686000, + 0x38688000, + 0x3868a000, + 0x3868c000, + 0x3868e000, + 0x38690000, + 0x38692000, + 0x38694000, + 0x38696000, + 0x38698000, + 0x3869a000, + 0x3869c000, + 0x3869e000, + 0x386a0000, + 0x386a2000, + 0x386a4000, + 0x386a6000, + 0x386a8000, + 0x386aa000, + 0x386ac000, + 0x386ae000, + 0x386b0000, + 0x386b2000, + 0x386b4000, + 0x386b6000, + 0x386b8000, + 0x386ba000, + 0x386bc000, + 0x386be000, + 0x386c0000, + 0x386c2000, + 0x386c4000, + 0x386c6000, + 0x386c8000, + 0x386ca000, + 0x386cc000, + 0x386ce000, + 0x386d0000, + 0x386d2000, + 0x386d4000, + 0x386d6000, + 0x386d8000, + 0x386da000, + 0x386dc000, + 0x386de000, + 0x386e0000, + 0x386e2000, + 0x386e4000, + 0x386e6000, + 0x386e8000, + 0x386ea000, + 0x386ec000, + 0x386ee000, + 0x386f0000, + 0x386f2000, + 0x386f4000, + 0x386f6000, + 0x386f8000, + 0x386fa000, + 0x386fc000, + 0x386fe000, + 0x38700000, + 0x38702000, + 0x38704000, + 0x38706000, + 0x38708000, + 0x3870a000, + 0x3870c000, + 0x3870e000, + 0x38710000, + 0x38712000, + 0x38714000, + 0x38716000, + 0x38718000, + 0x3871a000, + 0x3871c000, + 0x3871e000, + 0x38720000, + 0x38722000, + 0x38724000, + 0x38726000, + 0x38728000, + 0x3872a000, + 0x3872c000, + 0x3872e000, + 0x38730000, + 0x38732000, + 0x38734000, + 0x38736000, + 0x38738000, + 0x3873a000, + 0x3873c000, + 0x3873e000, + 0x38740000, + 0x38742000, + 0x38744000, + 0x38746000, + 0x38748000, + 0x3874a000, + 0x3874c000, + 0x3874e000, + 0x38750000, + 0x38752000, + 0x38754000, + 0x38756000, + 0x38758000, + 0x3875a000, + 0x3875c000, + 0x3875e000, + 0x38760000, + 0x38762000, + 0x38764000, + 0x38766000, + 0x38768000, + 0x3876a000, + 0x3876c000, + 0x3876e000, + 0x38770000, + 0x38772000, + 0x38774000, + 0x38776000, + 0x38778000, + 0x3877a000, + 0x3877c000, + 0x3877e000, + 0x38780000, + 0x38782000, + 0x38784000, + 0x38786000, + 0x38788000, + 0x3878a000, + 0x3878c000, + 0x3878e000, + 0x38790000, + 0x38792000, + 0x38794000, + 0x38796000, + 0x38798000, + 0x3879a000, + 0x3879c000, + 0x3879e000, + 0x387a0000, + 0x387a2000, + 0x387a4000, + 0x387a6000, + 0x387a8000, + 0x387aa000, + 0x387ac000, + 0x387ae000, + 0x387b0000, + 0x387b2000, + 0x387b4000, + 0x387b6000, + 0x387b8000, + 0x387ba000, + 0x387bc000, + 0x387be000, + 0x387c0000, + 0x387c2000, + 0x387c4000, + 0x387c6000, + 0x387c8000, + 0x387ca000, + 0x387cc000, + 0x387ce000, + 0x387d0000, + 0x387d2000, + 0x387d4000, + 0x387d6000, + 0x387d8000, + 0x387da000, + 0x387dc000, + 0x387de000, + 0x387e0000, + 0x387e2000, + 0x387e4000, + 0x387e6000, + 0x387e8000, + 0x387ea000, + 0x387ec000, + 0x387ee000, + 0x387f0000, + 0x387f2000, + 0x387f4000, + 0x387f6000, + 0x387f8000, + 0x387fa000, + 0x387fc000, + 0x387fe000, +}; + +const static unsigned g_exponent[64] = { + 0x00000000, + 0x00800000, + 0x01000000, + 0x01800000, + 0x02000000, + 0x02800000, + 0x03000000, + 0x03800000, + 0x04000000, + 0x04800000, + 0x05000000, + 0x05800000, + 0x06000000, + 0x06800000, + 0x07000000, + 0x07800000, + 0x08000000, + 0x08800000, + 0x09000000, + 0x09800000, + 0x0a000000, + 0x0a800000, + 0x0b000000, + 0x0b800000, + 0x0c000000, + 0x0c800000, + 0x0d000000, + 0x0d800000, + 0x0e000000, + 0x0e800000, + 0x0f000000, + 0x47800000, + 0x80000000, + 0x80800000, + 0x81000000, + 0x81800000, + 0x82000000, + 0x82800000, + 0x83000000, + 0x83800000, + 0x84000000, + 0x84800000, + 0x85000000, + 0x85800000, + 0x86000000, + 0x86800000, + 0x87000000, + 0x87800000, + 0x88000000, + 0x88800000, + 0x89000000, + 0x89800000, + 0x8a000000, + 0x8a800000, + 0x8b000000, + 0x8b800000, + 0x8c000000, + 0x8c800000, + 0x8d000000, + 0x8d800000, + 0x8e000000, + 0x8e800000, + 0x8f000000, + 0xc7800000, +}; + +const static unsigned g_offset[64] = { + 0x00000000, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000000, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, + 0x00000400, +}; + +float float16ToFloat32(unsigned short h) +{ + unsigned i32 = g_mantissa[g_offset[h >> 10] + (h & 0x3ff)] + g_exponent[h >> 10]; + return *(float*) &i32; +} +} + diff --git a/gfx/angle/src/libGLESv2/Float16ToFloat32.py b/gfx/angle/src/libGLESv2/Float16ToFloat32.py new file mode 100644 index 000000000000..cf039bfc21e2 --- /dev/null +++ b/gfx/angle/src/libGLESv2/Float16ToFloat32.py @@ -0,0 +1,78 @@ +# Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# + +# This script generates a function that converts 16-bit precision floating +# point numbers to 32-bit. +# It is based on ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf. + +def convertMantissa(i): + if i == 0: + return 0 + elif i < 1024: + m = i << 13 + e = 0 + while not (m & 0x00800000): + e -= 0x00800000 + m = m << 1 + m &= ~0x00800000 + e += 0x38800000 + return m | e + else: + return 0x38000000 + ((i - 1024) << 13) + +def convertExponent(i): + if i == 0: + return 0 + elif i in range(1, 31): + return i << 23 + elif i == 31: + return 0x47800000 + elif i == 32: + return 0x80000000 + elif i in range(33, 63): + return 0x80000000 + ((i - 32) << 23) + else: + return 0xC7800000 + +def convertOffset(i): + if i == 0 or i == 32: + return 0 + else: + return 1024 + +print """// +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// This file is automatically generated. + +namespace gl +{ +""" + +print "const static unsigned g_mantissa[2048] = {" +for i in range(0, 2048): + print " %#010x," % convertMantissa(i) +print "};\n" + +print "const static unsigned g_exponent[64] = {" +for i in range(0, 64): + print " %#010x," % convertExponent(i) +print "};\n" + +print "const static unsigned g_offset[64] = {" +for i in range(0, 64): + print " %#010x," % convertOffset(i) +print "};\n" + +print """float float16ToFloat32(unsigned short h) +{ + unsigned i32 = g_mantissa[g_offset[h >> 10] + (h & 0x3ff)] + g_exponent[h >> 10]; + return *(float*) &i32; +} +} +""" diff --git a/gfx/angle/src/libGLESv2/Framebuffer.cpp b/gfx/angle/src/libGLESv2/Framebuffer.cpp index 76d428340b3b..77d79c0be22b 100644 --- a/gfx/angle/src/libGLESv2/Framebuffer.cpp +++ b/gfx/angle/src/libGLESv2/Framebuffer.cpp @@ -301,24 +301,24 @@ GLenum Framebuffer::completeness() } else if (IsInternalTextureTarget(mColorbufferType)) { - GLenum internalformat = colorbuffer->getInternalFormat(); - D3DFORMAT d3dformat = colorbuffer->getD3DFormat(); + GLint internalformat = colorbuffer->getInternalFormat(); + GLenum format = gl::ExtractFormat(internalformat); - if (IsCompressed(internalformat) || - internalformat == GL_ALPHA || - internalformat == GL_LUMINANCE || - internalformat == GL_LUMINANCE_ALPHA) + if (IsCompressed(format) || + format == GL_ALPHA || + format == GL_LUMINANCE || + format == GL_LUMINANCE_ALPHA) { return GL_FRAMEBUFFER_UNSUPPORTED; } - if ((dx2es::IsFloat32Format(d3dformat) && !context->supportsFloat32RenderableTextures()) || - (dx2es::IsFloat16Format(d3dformat) && !context->supportsFloat16RenderableTextures())) + if ((gl::IsFloat32Format(internalformat) && !context->supportsFloat32RenderableTextures()) || + (gl::IsFloat16Format(internalformat) && !context->supportsFloat16RenderableTextures())) { return GL_FRAMEBUFFER_UNSUPPORTED; } - if (dx2es::IsDepthTextureFormat(d3dformat) || dx2es::IsStencilTextureFormat(d3dformat)) + if (gl::IsDepthTexture(internalformat) || gl::IsStencilTexture(internalformat)) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } @@ -361,7 +361,7 @@ GLenum Framebuffer::completeness() } else if (IsInternalTextureTarget(mDepthbufferType)) { - D3DFORMAT d3dformat = depthbuffer->getD3DFormat(); + GLint internalformat = depthbuffer->getInternalFormat(); // depth texture attachments require OES/ANGLE_depth_texture if (!context->supportsDepthTextures()) @@ -369,7 +369,7 @@ GLenum Framebuffer::completeness() return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } - if (!dx2es::IsDepthTextureFormat(d3dformat)) + if (!gl::IsDepthTexture(internalformat)) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } @@ -420,7 +420,7 @@ GLenum Framebuffer::completeness() } else if (IsInternalTextureTarget(mStencilbufferType)) { - D3DFORMAT d3dformat = stencilbuffer->getD3DFormat(); + GLint internalformat = stencilbuffer->getInternalFormat(); // texture stencil attachments come along as part // of OES_packed_depth_stencil + OES/ANGLE_depth_texture @@ -429,7 +429,7 @@ GLenum Framebuffer::completeness() return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } - if (!dx2es::IsStencilTextureFormat(d3dformat)) + if (!gl::IsStencilTexture(internalformat)) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in index 31704c0a8639..5d27c2ab77f0 100644 --- a/gfx/angle/src/libGLESv2/Makefile.in +++ b/gfx/angle/src/libGLESv2/Makefile.in @@ -12,157 +12,173 @@ include $(DEPTH)/config/autoconf.mk MODULE = libglesv2 # On Windows, we don't automatically get "lib" prepended, but we need it. -LIBRARY_NAME = libGLESv2 -MODULE_NAME = libglesv2 -FORCE_SHARED_LIB=1 +LIBRARY_NAME = libGLESv2 +MODULE_NAME = libglesv2 +FORCE_SHARED_LIB = 1 # ANGLE uses the STL, so we can't use our derpy STL wrappers. -STL_FLAGS= +STL_FLAGS = # ANGLE uses exceptions internally, so we need to have exception handling # support -ENABLE_CXX_EXCEPTIONS=1 +ENABLE_CXX_EXCEPTIONS = 1 # Since we're building off in our own world, we don't want to have # mozilla-config.h and -DMOZILLA_CLIENT automatically included and defined, so # we just overwrite OS_COMPILE_C(XX)FLAGS. -OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) +OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS) -LOCAL_INCLUDES = \ - -I$(srcdir)/../../include \ - -I$(srcdir)/.. \ - -I"$(MOZ_DIRECTX_SDK_PATH)/include" \ - - -VPATH += $(srcdir)/.. -VPATH += $(srcdir)/../compiler -VPATH += $(srcdir)/../compiler/preprocessor -VPATH += $(srcdir)/../compiler/preprocessor/new -VPATH += $(srcdir)/../compiler/timing -VPATH += $(srcdir)/../compiler/depgraph -VPATH += $(srcdir)/../common - -# Translator/compiler first - -CPPSRCS = \ - Diagnostics.cpp \ - PreprocessorDiagnostics.cpp \ - DirectiveHandler.cpp \ - PreprocessorDirectiveHandler.cpp \ - DirectiveParser.cpp \ - ExpressionParser.cpp \ - Macro.cpp \ - MacroExpander.cpp \ - Tokenizer.cpp \ - InitializeParseContext.cpp \ - DependencyGraph.cpp \ - DependencyGraphBuilder.cpp \ - DependencyGraphOutput.cpp \ - DependencyGraphTraverse.cpp \ - RestrictFragmentShaderTiming.cpp \ - RestrictVertexShaderTiming.cpp \ - Compiler.cpp \ - DetectRecursion.cpp \ - InfoSink.cpp \ - Initialize.cpp \ - InitializeDll.cpp \ - Intermediate.cpp \ - intermOut.cpp \ - IntermTraverse.cpp \ - parseConst.cpp \ - ParseHelper.cpp \ - PoolAlloc.cpp \ - QualifierAlive.cpp \ - RemoveTree.cpp \ - ShaderLang.cpp \ - SymbolTable.cpp \ - VariableInfo.cpp \ - compilerdebug.cpp \ - util.cpp \ - ValidateLimitations.cpp \ - ForLoopUnroll.cpp \ - MapLongVariableNames.cpp \ - spooky.cpp \ - BuiltInFunctionEmulator.cpp \ - Input.cpp \ - Lexer.cpp \ - Preprocessor.cpp \ - Token.cpp \ - VariablePacker.cpp \ - $(NULL) - -# flex/yacc generated files -CPPSRCS += \ - glslang_lex.cpp \ - glslang_tab.cpp \ - $(NULL) - -# HLSL translator backend -CPPSRCS += \ - CodeGenHLSL.cpp \ - OutputHLSL.cpp \ - TranslatorHLSL.cpp \ - SearchSymbol.cpp \ - OutputESSL.cpp \ - OutputGLSLBase.cpp \ - TranslatorESSL.cpp \ - DetectDiscontinuity.cpp \ - UnfoldShortCircuit.cpp \ - $(NULL) - -ifeq ($(MOZ_WIDGET_TOOLKIT),windows) -CPPSRCS += ossource_win.cpp $(NULL) -else -CPPSRCS += ossource_posix.cpp $(NULL) -endif - -CSRCS = \ - atom.c \ - cpp.c \ - cppstruct.c \ - memory.c \ - scanner.c \ - symbols.c \ - tokens.c \ - $(NULL) - DEFINES += -DANGLE_BUILD -DNOMINMAX -DLIBGLESV2_EXPORTS -D_CRT_SECURE_NO_DEPRECATE -#these defines are from ANGLE's build_angle.gyp -DEFINES += -DANGLE_DISABLE_TRACE -DEFINES += -DANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL0 - ifndef MOZ_DEBUG DEFINES += -D_SECURE_SCL=0 endif -CPPSRCS += \ - debug.cpp \ - Blit.cpp \ - Buffer.cpp \ - Context.cpp \ - Fence.cpp \ - Framebuffer.cpp \ - libGLESv2.cpp \ - main.cpp \ - Program.cpp \ - ProgramBinary.cpp \ - RefCountObject.cpp \ - Query.cpp \ - Renderbuffer.cpp \ - ResourceManager.cpp \ - Shader.cpp \ - Texture.cpp \ - TextureSSE2.cpp \ - utilities.cpp \ - HandleAllocator.cpp \ - IndexDataManager.cpp \ - VertexDataManager.cpp \ - $(NULL) +# The below is a rough translation of build_angle.gypi, +# copied from src/Makefile.in. +DEFINES += -DANGLE_DISABLE_TRACE +DEFINES += -DANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL0 +# Target: 'preprocessor' +# src/compiler/preprocessor: +VPATH += $(srcdir)/../compiler/preprocessor +CPPSRCS += \ + PreprocessorDiagnostics.cpp \ + PreprocessorDirectiveHandler.cpp \ + DirectiveParser.cpp \ + ExpressionParser.cpp \ + Input.cpp \ + Lexer.cpp \ + Macro.cpp \ + MacroExpander.cpp \ + Preprocessor.cpp \ + Token.cpp \ + Tokenizer.cpp \ + $(NULL) + +# Target: 'translator_common' +# Requires: 'preprocessor' +LOCAL_INCLUDES = \ + -I$(srcdir)/../../include \ + -I$(srcdir)/../../include/KHR \ + -I$(srcdir)/.. + +DEFINES += -DCOMPILER_IMPLEMENTATION + +VPATH += $(srcdir)/../compiler +# src/compiler: +CPPSRCS += \ + BuiltInFunctionEmulator.cpp \ + Compiler.cpp \ + compiler_debug.cpp \ + DetectRecursion.cpp \ + Diagnostics.cpp \ + DirectiveHandler.cpp \ + ForLoopUnroll.cpp \ + glslang_lex.cpp \ + glslang_tab.cpp \ + InfoSink.cpp \ + Initialize.cpp \ + InitializeDll.cpp \ + InitializeParseContext.cpp \ + Intermediate.cpp \ + intermOut.cpp \ + IntermTraverse.cpp \ + MapLongVariableNames.cpp \ + parseConst.cpp \ + ParseHelper.cpp \ + PoolAlloc.cpp \ + QualifierAlive.cpp \ + RemoveTree.cpp \ + spooky.cpp \ + SymbolTable.cpp \ + util.cpp \ + ValidateLimitations.cpp \ + VariableInfo.cpp \ + VariablePacker.cpp \ + $(NULL) + +VPATH += $(srcdir)/../compiler/depgraph +# src/compiler/depgraph: +CPPSRCS += \ + DependencyGraph.cpp \ + DependencyGraphBuilder.cpp \ + DependencyGraphOutput.cpp \ + DependencyGraphTraverse.cpp \ + $(NULL) + +VPATH += $(srcdir)/../compiler/timing +# src/compiler/timing: +CPPSRCS += \ + RestrictFragmentShaderTiming.cpp \ + RestrictVertexShaderTiming.cpp \ + $(NULL) + +ifeq ($(MOZ_WIDGET_TOOLKIT),windows) +CPPSRCS += ossource_win.cpp +else +CPPSRCS += ossource_posix.cpp +endif + +# Above should match the relevant targets from angle/Makefile.in. + +# Below is a transcription of more targets from build_angle.gypi. + +# Target: 'translator_hlsl' +# Requires: 'translator_common' + +# src/compiler: +CPPSRCS += \ + ShaderLang.cpp \ + DetectDiscontinuity.cpp \ + CodeGenHLSL.cpp \ + OutputHLSL.cpp \ + TranslatorHLSL.cpp \ + UnfoldShortCircuit.cpp \ + SearchSymbol.cpp \ + $(NULL) + +# Target: 'libGLESv2' +# Requires: 'translator_hlsl' +LOCAL_INCLUDES += -I"$(MOZ_DIRECTX_SDK_PATH)/include" + +VPATH += $(srcdir)/../common +# src/common: +CPPSRCS += \ + debug.cpp \ + RefCountObject.cpp \ + $(NULL) + +# src/libGLESv2: +CPPSRCS += \ + IndexDataManager.cpp \ + VertexDataManager.cpp \ + Blit.cpp \ + Buffer.cpp \ + Context.cpp \ + D3DConstantTable.cpp \ + Fence.cpp \ + Float16ToFloat32.cpp \ + Framebuffer.cpp \ + HandleAllocator.cpp \ + libGLESv2.cpp \ + main.cpp \ + Program.cpp \ + ProgramBinary.cpp \ + Query.cpp \ + Renderbuffer.cpp \ + ResourceManager.cpp \ + Shader.cpp \ + Texture.cpp \ + TextureSSE2.cpp \ + utilities.cpp \ + $(NULL) + DEFFILE = $(srcdir)/libGLESv2.def -RCFILE = $(srcdir)/libGLESv2.rc +RCFILE = $(srcdir)/libGLESv2.rc + +# End build_angle.gypi transcription. include $(topsrcdir)/config/rules.mk diff --git a/gfx/angle/src/libGLESv2/Program.h b/gfx/angle/src/libGLESv2/Program.h index 9f7f07b3bc36..1c4716bfe83b 100644 --- a/gfx/angle/src/libGLESv2/Program.h +++ b/gfx/angle/src/libGLESv2/Program.h @@ -10,7 +10,6 @@ #ifndef LIBGLESV2_PROGRAM_H_ #define LIBGLESV2_PROGRAM_H_ -#include #include #include diff --git a/gfx/angle/src/libGLESv2/ProgramBinary.cpp b/gfx/angle/src/libGLESv2/ProgramBinary.cpp index 61a272f8294c..3bdb555617f0 100644 --- a/gfx/angle/src/libGLESv2/ProgramBinary.cpp +++ b/gfx/angle/src/libGLESv2/ProgramBinary.cpp @@ -49,7 +49,10 @@ Uniform::~Uniform() bool Uniform::isArray() { - return _name.compare(0, 3, "ar_") == 0; + size_t dot = _name.find_last_of('.'); + if (dot == std::string::npos) dot = -1; + + return _name.compare(dot + 1, dot + 4, "ar_") == 0; } UniformLocation::UniformLocation(const std::string &_name, unsigned int element, unsigned int index) @@ -108,15 +111,8 @@ ProgramBinary::~ProgramBinary() mVertexExecutable->Release(); } - if (mConstantTablePS) - { - mConstantTablePS->Release(); - } - - if (mConstantTableVS) - { - mConstantTableVS->Release(); - } + delete mConstantTablePS; + delete mConstantTableVS; while (!mUniforms.empty()) { @@ -183,6 +179,11 @@ GLint ProgramBinary::getUsedSamplerRange(SamplerType type) } } +bool ProgramBinary::usesPointSize() const +{ + return mUsesPointSize; +} + // Returns the index of the texture image unit (0-19) corresponding to a Direct3D 9 sampler // index (0-15 for the pixel shader and 0-3 for the vertex shader). GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerIndex) @@ -1036,14 +1037,14 @@ void ProgramBinary::applyUniforms() } // Compiles the HLSL code of the attached shaders into executable binaries -ID3D10Blob *ProgramBinary::compileToBinary(InfoLog &infoLog, const char *hlsl, const char *profile, ID3DXConstantTable **constantTable) +ID3D10Blob *ProgramBinary::compileToBinary(InfoLog &infoLog, const char *hlsl, const char *profile, D3DConstantTable **constantTable) { if (!hlsl) { return NULL; } - DWORD result; + HRESULT result = S_OK; UINT flags = 0; std::string sourceText; if (perfActive()) @@ -1065,47 +1066,73 @@ ID3D10Blob *ProgramBinary::compileToBinary(InfoLog &infoLog, const char *hlsl, c sourceText = hlsl; } - ID3D10Blob *binary = NULL; - ID3D10Blob *errorMessage = NULL; - result = D3DCompile(hlsl, strlen(hlsl), g_fakepath, NULL, NULL, "main", profile, flags, 0, &binary, &errorMessage); - - if (errorMessage) + // 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[] = { - const char *message = (const char*)errorMessage->GetBufferPointer(); + 0, + D3DCOMPILE_AVOID_FLOW_CONTROL, + D3DCOMPILE_PREFER_FLOW_CONTROL + }; - infoLog.appendSanitized(message); - TRACE("\n%s", hlsl); - TRACE("\n%s", message); - - errorMessage->Release(); - errorMessage = NULL; - } - - if (FAILED(result)) + const static char * const extraFlagNames[] = { - if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) + "default", + "avoid flow control", + "prefer flow control" + }; + + for (int i = 0; i < sizeof(extraFlags) / sizeof(UINT); ++i) + { + ID3D10Blob *errorMessage = NULL; + ID3D10Blob *binary = NULL; + result = getDisplay()->compileShaderSource(hlsl, g_fakepath, profile, flags | extraFlags[i], &binary, &errorMessage); + if (errorMessage) { - error(GL_OUT_OF_MEMORY); + const char *message = (const char*)errorMessage->GetBufferPointer(); + + infoLog.appendSanitized(message); + TRACE("\n%s", hlsl); + TRACE("\n%s", message); + + errorMessage->Release(); + errorMessage = NULL; } - return NULL; - } - - result = D3DXGetShaderConstantTable(static_cast(binary->GetBufferPointer()), constantTable); - - if (FAILED(result)) - { - if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) + if (SUCCEEDED(result)) { - error(GL_OUT_OF_MEMORY); + D3DConstantTable *table = new D3DConstantTable(binary->GetBufferPointer(), binary->GetBufferSize()); + if (table->error()) + { + delete table; + binary->Release(); + return NULL; + } + + *constantTable = table; + + return binary; } + else + { + if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) + { + return error(GL_OUT_OF_MEMORY, (ID3D10Blob*) NULL); + } - binary->Release(); - - return NULL; + infoLog.append("Warning: D3D shader compilation failed with "); + infoLog.append(extraFlagNames[i]); + infoLog.append(" flags."); + if (i + 1 < sizeof(extraFlagNames) / sizeof(char*)) + { + infoLog.append(" Retrying with "); + infoLog.append(extraFlagNames[i + 1]); + infoLog.append(".\n"); + } + } } - return binary; + return NULL; } // Packs varyings into generic varying registers, using the algorithm from [OpenGL ES Shading Language 1.00 rev. 17] appendix A section 7 page 111 @@ -1330,7 +1357,8 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std:: } } - std::string varyingSemantic = (vertexShader->mUsesPointSize && sm3 ? "COLOR" : "TEXCOORD"); + mUsesPointSize = vertexShader->mUsesPointSize; + std::string varyingSemantic = (mUsesPointSize && sm3) ? "COLOR" : "TEXCOORD"; vertexHLSL += "struct VS_INPUT\n" "{\n"; @@ -1580,7 +1608,14 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std:: pixelHLSL += "[" + str(j) + "]"; } - pixelHLSL += " = input.v" + n + ";\n"; + switch (VariableColumnCount(varying->type)) + { + case 1: pixelHLSL += " = input.v" + n + ".x;\n"; break; + case 2: pixelHLSL += " = input.v" + n + ".xy;\n"; break; + case 3: pixelHLSL += " = input.v" + n + ".xyz;\n"; break; + case 4: pixelHLSL += " = input.v" + n + ";\n"; break; + default: UNREACHABLE(); + } } } } @@ -1650,6 +1685,7 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) stream.read(&mUsedVertexSamplerRange); stream.read(&mUsedPixelSamplerRange); + stream.read(&mUsesPointSize); unsigned int size; stream.read(&size); @@ -1778,6 +1814,7 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length) stream.write(mUsedVertexSamplerRange); stream.write(mUsedPixelSamplerRange); + stream.write(mUsesPointSize); stream.write(mUniforms.size()); for (unsigned int i = 0; i < mUniforms.size(); ++i) @@ -2030,22 +2067,13 @@ bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &at return true; } -bool ProgramBinary::linkUniforms(InfoLog &infoLog, GLenum shader, ID3DXConstantTable *constantTable) +bool ProgramBinary::linkUniforms(InfoLog &infoLog, GLenum shader, D3DConstantTable *constantTable) { - D3DXCONSTANTTABLE_DESC constantTableDescription; - - constantTable->GetDesc(&constantTableDescription); - - for (unsigned int constantIndex = 0; constantIndex < constantTableDescription.Constants; constantIndex++) + for (unsigned int constantIndex = 0; constantIndex < constantTable->constants(); constantIndex++) { - D3DXHANDLE constantHandle = constantTable->GetConstant(0, constantIndex); + const D3DConstant *constant = constantTable->getConstant(constantIndex); - D3DXCONSTANT_DESC constantDescription; - UINT descriptionCount = 1; - HRESULT result = constantTable->GetConstantDesc(constantHandle, &constantDescription, &descriptionCount); - ASSERT(SUCCEEDED(result)); - - if (!defineUniform(infoLog, shader, constantHandle, constantDescription)) + if (!defineUniform(infoLog, shader, constant)) { return false; } @@ -2056,23 +2084,23 @@ bool ProgramBinary::linkUniforms(InfoLog &infoLog, GLenum shader, ID3DXConstantT // Adds the description of a constant found in the binary shader to the list of uniforms // Returns true if succesful (uniform not already defined) -bool ProgramBinary::defineUniform(InfoLog &infoLog, GLenum shader, const D3DXHANDLE &constantHandle, const D3DXCONSTANT_DESC &constantDescription, std::string name) +bool ProgramBinary::defineUniform(InfoLog &infoLog, GLenum shader, const D3DConstant *constant, std::string name) { - if (constantDescription.RegisterSet == D3DXRS_SAMPLER) + if (constant->registerSet == D3DConstant::RS_SAMPLER) { - for (unsigned int i = 0; i < constantDescription.RegisterCount; i++) + for (unsigned int i = 0; i < constant->registerCount; i++) { - D3DXHANDLE psConstant = mConstantTablePS->GetConstantByName(NULL, constantDescription.Name); - D3DXHANDLE vsConstant = mConstantTableVS->GetConstantByName(NULL, constantDescription.Name); + const D3DConstant *psConstant = mConstantTablePS->getConstantByName(constant->name.c_str()); + const D3DConstant *vsConstant = mConstantTableVS->getConstantByName(constant->name.c_str()); if (psConstant) { - unsigned int samplerIndex = mConstantTablePS->GetSamplerIndex(psConstant) + i; + unsigned int samplerIndex = psConstant->registerIndex + i; if (samplerIndex < MAX_TEXTURE_IMAGE_UNITS) { mSamplersPS[samplerIndex].active = true; - mSamplersPS[samplerIndex].textureType = (constantDescription.Type == D3DXPT_SAMPLERCUBE) ? TEXTURE_CUBE : TEXTURE_2D; + mSamplersPS[samplerIndex].textureType = (constant->type == D3DConstant::PT_SAMPLERCUBE) ? TEXTURE_CUBE : TEXTURE_2D; mSamplersPS[samplerIndex].logicalTextureUnit = 0; mUsedPixelSamplerRange = std::max(samplerIndex + 1, mUsedPixelSamplerRange); } @@ -2085,12 +2113,12 @@ bool ProgramBinary::defineUniform(InfoLog &infoLog, GLenum shader, const D3DXHAN if (vsConstant) { - unsigned int samplerIndex = mConstantTableVS->GetSamplerIndex(vsConstant) + i; + unsigned int samplerIndex = vsConstant->registerIndex + i; if (samplerIndex < getContext()->getMaximumVertexTextureImageUnits()) { mSamplersVS[samplerIndex].active = true; - mSamplersVS[samplerIndex].textureType = (constantDescription.Type == D3DXPT_SAMPLERCUBE) ? TEXTURE_CUBE : TEXTURE_2D; + mSamplersVS[samplerIndex].textureType = (constant->type == D3DConstant::PT_SAMPLERCUBE) ? TEXTURE_CUBE : TEXTURE_2D; mSamplersVS[samplerIndex].logicalTextureUnit = 0; mUsedVertexSamplerRange = std::max(samplerIndex + 1, mUsedVertexSamplerRange); } @@ -2103,27 +2131,19 @@ bool ProgramBinary::defineUniform(InfoLog &infoLog, GLenum shader, const D3DXHAN } } - switch(constantDescription.Class) + switch(constant->typeClass) { - case D3DXPC_STRUCT: + case D3DConstant::CLASS_STRUCT: { - for (unsigned int arrayIndex = 0; arrayIndex < constantDescription.Elements; arrayIndex++) + for (unsigned int arrayIndex = 0; arrayIndex < constant->elements; arrayIndex++) { - D3DXHANDLE elementHandle = mConstantTablePS->GetConstantElement(constantHandle, arrayIndex); - - for (unsigned int field = 0; field < constantDescription.StructMembers; field++) + for (unsigned int field = 0; field < constant->structMembers[arrayIndex].size(); field++) { - D3DXHANDLE fieldHandle = mConstantTablePS->GetConstant(elementHandle, field); + const D3DConstant *fieldConstant = constant->structMembers[arrayIndex][field]; - D3DXCONSTANT_DESC fieldDescription; - UINT descriptionCount = 1; + std::string structIndex = (constant->elements > 1) ? ("[" + str(arrayIndex) + "]") : ""; - HRESULT result = mConstantTablePS->GetConstantDesc(fieldHandle, &fieldDescription, &descriptionCount); - ASSERT(SUCCEEDED(result)); - - std::string structIndex = (constantDescription.Elements > 1) ? ("[" + str(arrayIndex) + "]") : ""; - - if (!defineUniform(infoLog, shader, fieldHandle, fieldDescription, name + constantDescription.Name + structIndex + ".")) + if (!defineUniform(infoLog, shader, fieldConstant, name + constant->name + structIndex + ".")) { return false; } @@ -2132,20 +2152,20 @@ bool ProgramBinary::defineUniform(InfoLog &infoLog, GLenum shader, const D3DXHAN return true; } - case D3DXPC_SCALAR: - case D3DXPC_VECTOR: - case D3DXPC_MATRIX_COLUMNS: - case D3DXPC_OBJECT: - return defineUniform(shader, constantDescription, name + constantDescription.Name); + case D3DConstant::CLASS_SCALAR: + case D3DConstant::CLASS_VECTOR: + case D3DConstant::CLASS_MATRIX_COLUMNS: + case D3DConstant::CLASS_OBJECT: + return defineUniform(shader, constant, name + constant->name); default: UNREACHABLE(); return false; } } -bool ProgramBinary::defineUniform(GLenum shader, const D3DXCONSTANT_DESC &constantDescription, const std::string &_name) +bool ProgramBinary::defineUniform(GLenum shader, const D3DConstant *constant, const std::string &_name) { - Uniform *uniform = createUniform(constantDescription, _name); + Uniform *uniform = createUniform(constant, _name); if(!uniform) { @@ -2162,8 +2182,8 @@ bool ProgramBinary::defineUniform(GLenum shader, const D3DXCONSTANT_DESC &consta uniform = mUniforms[mUniformIndex[location].index]; } - if (shader == GL_FRAGMENT_SHADER) uniform->ps.set(constantDescription); - if (shader == GL_VERTEX_SHADER) uniform->vs.set(constantDescription); + if (shader == GL_FRAGMENT_SHADER) uniform->ps.set(constant); + if (shader == GL_VERTEX_SHADER) uniform->vs.set(constant); if (location >= 0) { @@ -2181,53 +2201,53 @@ bool ProgramBinary::defineUniform(GLenum shader, const D3DXCONSTANT_DESC &consta return true; } -Uniform *ProgramBinary::createUniform(const D3DXCONSTANT_DESC &constantDescription, const std::string &_name) +Uniform *ProgramBinary::createUniform(const D3DConstant *constant, const std::string &_name) { - if (constantDescription.Rows == 1) // Vectors and scalars + if (constant->rows == 1) // Vectors and scalars { - switch (constantDescription.Type) + switch (constant->type) { - case D3DXPT_SAMPLER2D: - switch (constantDescription.Columns) + case D3DConstant::PT_SAMPLER2D: + switch (constant->columns) { - case 1: return new Uniform(GL_SAMPLER_2D, _name, constantDescription.Elements); + case 1: return new Uniform(GL_SAMPLER_2D, _name, constant->elements); default: UNREACHABLE(); } break; - case D3DXPT_SAMPLERCUBE: - switch (constantDescription.Columns) + case D3DConstant::PT_SAMPLERCUBE: + switch (constant->columns) { - case 1: return new Uniform(GL_SAMPLER_CUBE, _name, constantDescription.Elements); + case 1: return new Uniform(GL_SAMPLER_CUBE, _name, constant->elements); default: UNREACHABLE(); } break; - case D3DXPT_BOOL: - switch (constantDescription.Columns) + case D3DConstant::PT_BOOL: + switch (constant->columns) { - case 1: return new Uniform(GL_BOOL, _name, constantDescription.Elements); - case 2: return new Uniform(GL_BOOL_VEC2, _name, constantDescription.Elements); - case 3: return new Uniform(GL_BOOL_VEC3, _name, constantDescription.Elements); - case 4: return new Uniform(GL_BOOL_VEC4, _name, constantDescription.Elements); + case 1: return new Uniform(GL_BOOL, _name, constant->elements); + case 2: return new Uniform(GL_BOOL_VEC2, _name, constant->elements); + case 3: return new Uniform(GL_BOOL_VEC3, _name, constant->elements); + case 4: return new Uniform(GL_BOOL_VEC4, _name, constant->elements); default: UNREACHABLE(); } break; - case D3DXPT_INT: - switch (constantDescription.Columns) + case D3DConstant::PT_INT: + switch (constant->columns) { - case 1: return new Uniform(GL_INT, _name, constantDescription.Elements); - case 2: return new Uniform(GL_INT_VEC2, _name, constantDescription.Elements); - case 3: return new Uniform(GL_INT_VEC3, _name, constantDescription.Elements); - case 4: return new Uniform(GL_INT_VEC4, _name, constantDescription.Elements); + case 1: return new Uniform(GL_INT, _name, constant->elements); + case 2: return new Uniform(GL_INT_VEC2, _name, constant->elements); + case 3: return new Uniform(GL_INT_VEC3, _name, constant->elements); + case 4: return new Uniform(GL_INT_VEC4, _name, constant->elements); default: UNREACHABLE(); } break; - case D3DXPT_FLOAT: - switch (constantDescription.Columns) + case D3DConstant::PT_FLOAT: + switch (constant->columns) { - case 1: return new Uniform(GL_FLOAT, _name, constantDescription.Elements); - case 2: return new Uniform(GL_FLOAT_VEC2, _name, constantDescription.Elements); - case 3: return new Uniform(GL_FLOAT_VEC3, _name, constantDescription.Elements); - case 4: return new Uniform(GL_FLOAT_VEC4, _name, constantDescription.Elements); + case 1: return new Uniform(GL_FLOAT, _name, constant->elements); + case 2: return new Uniform(GL_FLOAT_VEC2, _name, constant->elements); + case 3: return new Uniform(GL_FLOAT_VEC3, _name, constant->elements); + case 4: return new Uniform(GL_FLOAT_VEC4, _name, constant->elements); default: UNREACHABLE(); } break; @@ -2235,16 +2255,16 @@ Uniform *ProgramBinary::createUniform(const D3DXCONSTANT_DESC &constantDescripti UNREACHABLE(); } } - else if (constantDescription.Rows == constantDescription.Columns) // Square matrices + else if (constant->rows == constant->columns) // Square matrices { - switch (constantDescription.Type) + switch (constant->type) { - case D3DXPT_FLOAT: - switch (constantDescription.Rows) + case D3DConstant::PT_FLOAT: + switch (constant->rows) { - case 2: return new Uniform(GL_FLOAT_MAT2, _name, constantDescription.Elements); - case 3: return new Uniform(GL_FLOAT_MAT3, _name, constantDescription.Elements); - case 4: return new Uniform(GL_FLOAT_MAT4, _name, constantDescription.Elements); + case 2: return new Uniform(GL_FLOAT_MAT2, _name, constant->elements); + case 3: return new Uniform(GL_FLOAT_MAT3, _name, constant->elements); + case 4: return new Uniform(GL_FLOAT_MAT4, _name, constant->elements); default: UNREACHABLE(); } break; @@ -2366,11 +2386,11 @@ bool ProgramBinary::applyUniformnfv(Uniform *targetUniform, const GLfloat *v) bool ProgramBinary::applyUniform1iv(Uniform *targetUniform, GLsizei count, const GLint *v) { ASSERT(count <= D3D9_MAX_FLOAT_CONSTANTS); - D3DXVECTOR4 vector[D3D9_MAX_FLOAT_CONSTANTS]; + Vector4 vector[D3D9_MAX_FLOAT_CONSTANTS]; for (int i = 0; i < count; i++) { - vector[i] = D3DXVECTOR4((float)v[i], 0, 0, 0); + vector[i] = Vector4((float)v[i], 0, 0, 0); } if (targetUniform->ps.registerCount) @@ -2427,11 +2447,11 @@ bool ProgramBinary::applyUniform1iv(Uniform *targetUniform, GLsizei count, const bool ProgramBinary::applyUniform2iv(Uniform *targetUniform, GLsizei count, const GLint *v) { ASSERT(count <= D3D9_MAX_FLOAT_CONSTANTS); - D3DXVECTOR4 vector[D3D9_MAX_FLOAT_CONSTANTS]; + Vector4 vector[D3D9_MAX_FLOAT_CONSTANTS]; for (int i = 0; i < count; i++) { - vector[i] = D3DXVECTOR4((float)v[0], (float)v[1], 0, 0); + vector[i] = Vector4((float)v[0], (float)v[1], 0, 0); v += 2; } @@ -2444,11 +2464,11 @@ bool ProgramBinary::applyUniform2iv(Uniform *targetUniform, GLsizei count, const bool ProgramBinary::applyUniform3iv(Uniform *targetUniform, GLsizei count, const GLint *v) { ASSERT(count <= D3D9_MAX_FLOAT_CONSTANTS); - D3DXVECTOR4 vector[D3D9_MAX_FLOAT_CONSTANTS]; + Vector4 vector[D3D9_MAX_FLOAT_CONSTANTS]; for (int i = 0; i < count; i++) { - vector[i] = D3DXVECTOR4((float)v[0], (float)v[1], (float)v[2], 0); + vector[i] = Vector4((float)v[0], (float)v[1], (float)v[2], 0); v += 3; } @@ -2461,11 +2481,11 @@ bool ProgramBinary::applyUniform3iv(Uniform *targetUniform, GLsizei count, const bool ProgramBinary::applyUniform4iv(Uniform *targetUniform, GLsizei count, const GLint *v) { ASSERT(count <= D3D9_MAX_FLOAT_CONSTANTS); - D3DXVECTOR4 vector[D3D9_MAX_FLOAT_CONSTANTS]; + Vector4 vector[D3D9_MAX_FLOAT_CONSTANTS]; for (int i = 0; i < count; i++) { - vector[i] = D3DXVECTOR4((float)v[0], (float)v[1], (float)v[2], (float)v[3]); + vector[i] = Vector4((float)v[0], (float)v[1], (float)v[2], (float)v[3]); v += 4; } @@ -2475,7 +2495,7 @@ bool ProgramBinary::applyUniform4iv(Uniform *targetUniform, GLsizei count, const return true; } -void ProgramBinary::applyUniformniv(Uniform *targetUniform, GLsizei count, const D3DXVECTOR4 *vector) +void ProgramBinary::applyUniformniv(Uniform *targetUniform, GLsizei count, const Vector4 *vector) { if (targetUniform->ps.registerCount) { diff --git a/gfx/angle/src/libGLESv2/ProgramBinary.h b/gfx/angle/src/libGLESv2/ProgramBinary.h index 5443ccae8f4b..9ffe70b6177c 100644 --- a/gfx/angle/src/libGLESv2/ProgramBinary.h +++ b/gfx/angle/src/libGLESv2/ProgramBinary.h @@ -14,13 +14,14 @@ #include #include -#include #include #include #include -#include "libGLESv2/Shader.h" #include "libGLESv2/Context.h" +#include "libGLESv2/D3DConstantTable.h" +#include "libGLESv2/mathutil.h" +#include "libGLESv2/Shader.h" namespace gl { @@ -54,18 +55,18 @@ struct Uniform registerCount = 0; } - void set(const D3DXCONSTANT_DESC &constantDescription) + void set(const D3DConstant *constant) { - switch(constantDescription.RegisterSet) + switch(constant->registerSet) { - case D3DXRS_BOOL: boolIndex = constantDescription.RegisterIndex; break; - case D3DXRS_FLOAT4: float4Index = constantDescription.RegisterIndex; break; - case D3DXRS_SAMPLER: samplerIndex = constantDescription.RegisterIndex; break; + case D3DConstant::RS_BOOL: boolIndex = constant->registerIndex; break; + case D3DConstant::RS_FLOAT4: float4Index = constant->registerIndex; break; + case D3DConstant::RS_SAMPLER: samplerIndex = constant->registerIndex; break; default: UNREACHABLE(); } - ASSERT(registerCount == 0 || registerCount == (int)constantDescription.RegisterCount); - registerCount = constantDescription.RegisterCount; + ASSERT(registerCount == 0 || registerCount == (int)constant->registerCount); + registerCount = constant->registerCount; } int float4Index; @@ -109,6 +110,7 @@ class ProgramBinary : public RefCountObject GLint getSamplerMapping(SamplerType type, unsigned int samplerIndex); TextureType getSamplerTextureType(SamplerType type, unsigned int samplerIndex); GLint getUsedSamplerRange(SamplerType type); + bool usesPointSize() const; GLint getUniformLocation(std::string name); bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v); @@ -163,23 +165,23 @@ class ProgramBinary : public RefCountObject private: DISALLOW_COPY_AND_ASSIGN(ProgramBinary); - ID3D10Blob *compileToBinary(InfoLog &infoLog, const char *hlsl, const char *profile, ID3DXConstantTable **constantTable); + ID3D10Blob *compileToBinary(InfoLog &infoLog, const char *hlsl, const char *profile, D3DConstantTable **constantTable); int packVaryings(InfoLog &infoLog, const Varying *packing[][4], FragmentShader *fragmentShader); bool linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std::string& vertexHLSL, FragmentShader *fragmentShader, VertexShader *vertexShader); bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader); - bool linkUniforms(InfoLog &infoLog, GLenum shader, ID3DXConstantTable *constantTable); - bool defineUniform(InfoLog &infoLog, GLenum shader, const D3DXHANDLE &constantHandle, const D3DXCONSTANT_DESC &constantDescription, std::string name = ""); - bool defineUniform(GLenum shader, const D3DXCONSTANT_DESC &constantDescription, const std::string &name); - Uniform *createUniform(const D3DXCONSTANT_DESC &constantDescription, const std::string &name); + bool linkUniforms(InfoLog &infoLog, GLenum shader, D3DConstantTable *constantTable); + bool defineUniform(InfoLog &infoLog, GLenum shader, const D3DConstant *constant, std::string name = ""); + bool defineUniform(GLenum shader, const D3DConstant *constant, const std::string &name); + Uniform *createUniform( const D3DConstant *constant, const std::string &name); bool applyUniformnfv(Uniform *targetUniform, const GLfloat *v); bool applyUniform1iv(Uniform *targetUniform, GLsizei count, const GLint *v); bool applyUniform2iv(Uniform *targetUniform, GLsizei count, const GLint *v); bool applyUniform3iv(Uniform *targetUniform, GLsizei count, const GLint *v); bool applyUniform4iv(Uniform *targetUniform, GLsizei count, const GLint *v); - void applyUniformniv(Uniform *targetUniform, GLsizei count, const D3DXVECTOR4 *vector); + void applyUniformniv(Uniform *targetUniform, GLsizei count, const Vector4 *vector); void applyUniformnbv(Uniform *targetUniform, GLsizei count, int width, const GLboolean *v); IDirect3DDevice9 *mDevice; @@ -188,8 +190,8 @@ class ProgramBinary : public RefCountObject IDirect3DVertexShader9 *mVertexExecutable; // These are only used during linking. - ID3DXConstantTable *mConstantTablePS; - ID3DXConstantTable *mConstantTableVS; + D3DConstantTable *mConstantTablePS; + D3DConstantTable *mConstantTableVS; Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS]; int mSemanticIndex[MAX_VERTEX_ATTRIBS]; @@ -207,6 +209,7 @@ class ProgramBinary : public RefCountObject Sampler mSamplersVS[MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF]; GLuint mUsedVertexSamplerRange; GLuint mUsedPixelSamplerRange; + bool mUsesPointSize; typedef std::vector UniformArray; UniformArray mUniforms; diff --git a/gfx/angle/src/libGLESv2/Shader.cpp b/gfx/angle/src/libGLESv2/Shader.cpp index 1087f11b4af9..c734803fc2ad 100644 --- a/gfx/angle/src/libGLESv2/Shader.cpp +++ b/gfx/angle/src/libGLESv2/Shader.cpp @@ -315,7 +315,7 @@ void Shader::uncompile() void Shader::compileToHLSL(void *compiler) { // ensure we don't pass a NULL source to the compiler - char *source = "\0"; + const char *source = "\0"; if (mSource) { source = mSource; @@ -504,7 +504,7 @@ void VertexShader::uncompile() // set by ParseAttributes mAttributes.clear(); -}; +} void VertexShader::compile() { diff --git a/gfx/angle/src/libGLESv2/Shader.h b/gfx/angle/src/libGLESv2/Shader.h index 4e1ac4c77696..b73fc288a117 100644 --- a/gfx/angle/src/libGLESv2/Shader.h +++ b/gfx/angle/src/libGLESv2/Shader.h @@ -14,7 +14,6 @@ #define GL_APICALL #include -#include #include #include #include diff --git a/gfx/angle/src/libGLESv2/Texture.cpp b/gfx/angle/src/libGLESv2/Texture.cpp index 7a44b1d0e35e..e3e8941d69ca 100644 --- a/gfx/angle/src/libGLESv2/Texture.cpp +++ b/gfx/angle/src/libGLESv2/Texture.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -10,8 +10,6 @@ #include "libGLESv2/Texture.h" -#include - #include #include "common/debug.h" @@ -28,49 +26,48 @@ namespace gl { unsigned int TextureStorage::mCurrentTextureSerial = 1; -static D3DFORMAT ConvertTextureFormatType(GLenum format, GLenum type) +static D3DFORMAT ConvertTextureInternalFormat(GLint internalformat) { - if (IsDepthTexture(format)) + switch (internalformat) { + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT32_OES: + case GL_DEPTH24_STENCIL8_OES: return D3DFMT_INTZ; - } - else if (format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || - format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) - { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return D3DFMT_DXT1; - } - else if (format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE) - { + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: return D3DFMT_DXT3; - } - else if (format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE) - { + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: return D3DFMT_DXT5; - } - else if (type == GL_FLOAT) - { + case GL_RGBA32F_EXT: + case GL_RGB32F_EXT: + case GL_ALPHA32F_EXT: + case GL_LUMINANCE32F_EXT: + case GL_LUMINANCE_ALPHA32F_EXT: return D3DFMT_A32B32G32R32F; - } - else if (type == GL_HALF_FLOAT_OES) - { + case GL_RGBA16F_EXT: + case GL_RGB16F_EXT: + case GL_ALPHA16F_EXT: + case GL_LUMINANCE16F_EXT: + case GL_LUMINANCE_ALPHA16F_EXT: return D3DFMT_A16B16G16R16F; - } - else if (type == GL_UNSIGNED_BYTE) - { - if (format == GL_LUMINANCE && getContext()->supportsLuminanceTextures()) + case GL_LUMINANCE8_EXT: + if (getContext()->supportsLuminanceTextures()) { return D3DFMT_L8; } - else if (format == GL_LUMINANCE_ALPHA && getContext()->supportsLuminanceAlphaTextures()) + break; + case GL_LUMINANCE8_ALPHA8_EXT: + if (getContext()->supportsLuminanceAlphaTextures()) { return D3DFMT_A8L8; } - else if (format == GL_RGB) - { - return D3DFMT_X8R8G8B8; - } - - return D3DFMT_A8R8G8B8; + break; + case GL_RGB8_OES: + case GL_RGB565: + return D3DFMT_X8R8G8B8; } return D3DFMT_A8R8G8B8; @@ -117,7 +114,8 @@ static inline DWORD GetTextureUsage(D3DFORMAT d3dfmt, GLenum glusage, bool force return d3dusage; } -static void MakeValidSize(bool isImage, bool isCompressed, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset) { +static void MakeValidSize(bool isImage, bool isCompressed, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset) +{ int upsampleCount = 0; if (isCompressed) @@ -137,12 +135,39 @@ static void MakeValidSize(bool isImage, bool isCompressed, GLsizei *requestWidth *levelOffset = upsampleCount; } +static void CopyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source) +{ + D3DLOCKED_RECT sourceLock = {0}; + D3DLOCKED_RECT destLock = {0}; + + source->LockRect(&sourceLock, NULL, 0); + dest->LockRect(&destLock, NULL, 0); + + if (sourceLock.pBits && destLock.pBits) + { + D3DSURFACE_DESC desc; + source->GetDesc(&desc); + + int rows = dx::IsCompressedFormat(desc.Format) ? desc.Height / 4 : desc.Height; + int bytes = dx::ComputeRowSize(desc.Format, desc.Width); + ASSERT(bytes <= sourceLock.Pitch && bytes <= destLock.Pitch); + + for(int i = 0; i < rows; i++) + { + memcpy((char*)destLock.pBits + destLock.Pitch * i, (char*)sourceLock.pBits + sourceLock.Pitch * i, bytes); + } + + source->UnlockRect(); + dest->UnlockRect(); + } + else UNREACHABLE(); +} + Image::Image() { mWidth = 0; mHeight = 0; - mFormat = GL_NONE; - mType = GL_UNSIGNED_BYTE; + mInternalFormat = GL_NONE; mSurface = NULL; @@ -160,20 +185,18 @@ Image::~Image() } } -bool Image::redefine(GLenum format, GLsizei width, GLsizei height, GLenum type, bool forceRelease) +bool Image::redefine(GLint internalformat, GLsizei width, GLsizei height, bool forceRelease) { if (mWidth != width || mHeight != height || - mFormat != format || - mType != type || + mInternalFormat != internalformat || forceRelease) { mWidth = width; mHeight = height; - mFormat = format; - mType = type; + mInternalFormat = internalformat; // compute the d3d format that will be used - mD3DFormat = ConvertTextureFormatType(mFormat, mType); + mD3DFormat = ConvertTextureInternalFormat(internalformat); if (mSurface) { @@ -205,9 +228,9 @@ void Image::createSurface() int levelToFetch = 0; GLsizei requestWidth = mWidth; GLsizei requestHeight = mHeight; - MakeValidSize(true, IsCompressed(mFormat), &requestWidth, &requestHeight, &levelToFetch); + MakeValidSize(true, IsCompressed(mInternalFormat), &requestWidth, &requestHeight, &levelToFetch); - HRESULT result = getDevice()->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, d3dFormat, + HRESULT result = getDevice()->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, 0, d3dFormat, poolToUse, &newTexture, NULL); if (FAILED(result)) @@ -275,18 +298,21 @@ IDirect3DSurface9 *Image::getSurface() void Image::setManagedSurface(IDirect3DSurface9 *surface) { - if (mSurface) - { - D3DXLoadSurfaceFromSurface(surface, NULL, NULL, mSurface, NULL, NULL, D3DX_FILTER_BOX, 0); - mSurface->Release(); - } - D3DSURFACE_DESC desc; surface->GetDesc(&desc); ASSERT(desc.Pool == D3DPOOL_MANAGED); - mSurface = surface; - mD3DPool = desc.Pool; + if ((GLsizei)desc.Width == mWidth && (GLsizei)desc.Height == mHeight) + { + if (mSurface) + { + CopyLockableSurfaces(surface, mSurface); + mSurface->Release(); + } + + mSurface = surface; + mD3DPool = desc.Pool; + } } void Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) @@ -301,15 +327,27 @@ void Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint y rect.right = xoffset + width; rect.bottom = yoffset + height; + POINT point = {rect.left, rect.top}; + if (mD3DPool == D3DPOOL_MANAGED) { - HRESULT result = D3DXLoadSurfaceFromSurface(destSurface, NULL, &rect, sourceSurface, NULL, &rect, D3DX_FILTER_BOX, 0); - ASSERT(SUCCEEDED(result)); + D3DSURFACE_DESC desc; + sourceSurface->GetDesc(&desc); + + IDirect3DSurface9 *surf = 0; + HRESULT result = getDevice()->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surf, NULL); + + if (SUCCEEDED(result)) + { + CopyLockableSurfaces(surf, sourceSurface); + result = getDevice()->UpdateSurface(surf, &rect, destSurface, &point); + ASSERT(SUCCEEDED(result)); + surf->Release(); + } } else { - // UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools - POINT point = {rect.left, rect.top}; + // UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools HRESULT result = getDevice()->UpdateSurface(sourceSurface, &rect, destSurface, &point); ASSERT(SUCCEEDED(result)); } @@ -318,7 +356,7 @@ void Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint y // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input // into the target pixel rectangle. -void Image::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum type, +void Image::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLint unpackAlignment, const void *input) { RECT lockRect = @@ -334,120 +372,84 @@ void Image::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height return; } - GLsizei inputPitch = ComputePitch(width, mFormat, type, unpackAlignment); - switch (type) + GLsizei inputPitch = ComputePitch(width, mInternalFormat, unpackAlignment); + + switch (mInternalFormat) { - case GL_UNSIGNED_BYTE: - switch (mFormat) + case GL_ALPHA8_EXT: + if (supportsSSE2()) { - case GL_ALPHA: - if (supportsSSE2()) - { - loadAlphaDataSSE2(width, height, inputPitch, input, locked.Pitch, locked.pBits); - } - else - { - loadAlphaData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - } - break; - case GL_LUMINANCE: - loadLuminanceData(width, height, inputPitch, input, locked.Pitch, locked.pBits, getD3DFormat() == D3DFMT_L8); - break; - case GL_LUMINANCE_ALPHA: - loadLuminanceAlphaData(width, height, inputPitch, input, locked.Pitch, locked.pBits, getD3DFormat() == D3DFMT_A8L8); - break; - case GL_RGB: - loadRGBUByteData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - case GL_RGBA: - if (supportsSSE2()) - { - loadRGBAUByteDataSSE2(width, height, inputPitch, input, locked.Pitch, locked.pBits); - } - else - { - loadRGBAUByteData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - } - break; - case GL_BGRA_EXT: - loadBGRAData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - default: UNREACHABLE(); + loadAlphaDataSSE2(width, height, inputPitch, input, locked.Pitch, locked.pBits); + } + else + { + loadAlphaData(width, height, inputPitch, input, locked.Pitch, locked.pBits); } break; - case GL_UNSIGNED_SHORT_5_6_5: - switch (mFormat) + case GL_LUMINANCE8_EXT: + loadLuminanceData(width, height, inputPitch, input, locked.Pitch, locked.pBits, getD3DFormat() == D3DFMT_L8); + break; + case GL_ALPHA32F_EXT: + loadAlphaFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_LUMINANCE32F_EXT: + loadLuminanceFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_ALPHA16F_EXT: + loadAlphaHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_LUMINANCE16F_EXT: + loadLuminanceHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_LUMINANCE8_ALPHA8_EXT: + loadLuminanceAlphaData(width, height, inputPitch, input, locked.Pitch, locked.pBits, getD3DFormat() == D3DFMT_A8L8); + break; + case GL_LUMINANCE_ALPHA32F_EXT: + loadLuminanceAlphaFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_LUMINANCE_ALPHA16F_EXT: + loadLuminanceAlphaHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_RGB8_OES: + loadRGBUByteData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_RGB565: + loadRGB565Data(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_RGBA8_OES: + if (supportsSSE2()) { - case GL_RGB: - loadRGB565Data(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - default: UNREACHABLE(); + loadRGBAUByteDataSSE2(width, height, inputPitch, input, locked.Pitch, locked.pBits); + } + else + { + loadRGBAUByteData(width, height, inputPitch, input, locked.Pitch, locked.pBits); } break; - case GL_UNSIGNED_SHORT_4_4_4_4: - switch (mFormat) - { - case GL_RGBA: - loadRGBA4444Data(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - default: UNREACHABLE(); - } + case GL_RGBA4: + loadRGBA4444Data(width, height, inputPitch, input, locked.Pitch, locked.pBits); break; - case GL_UNSIGNED_SHORT_5_5_5_1: - switch (mFormat) - { - case GL_RGBA: - loadRGBA5551Data(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - default: UNREACHABLE(); - } + case GL_RGB5_A1: + loadRGBA5551Data(width, height, inputPitch, input, locked.Pitch, locked.pBits); break; - case GL_FLOAT: - switch (mFormat) - { - // float textures are converted to RGBA, not BGRA, as they're stored that way in D3D - case GL_ALPHA: - loadAlphaFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - case GL_LUMINANCE: - loadLuminanceFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - case GL_LUMINANCE_ALPHA: - loadLuminanceAlphaFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - case GL_RGB: - loadRGBFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - case GL_RGBA: - loadRGBAFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - default: UNREACHABLE(); - } + case GL_BGRA8_EXT: + loadBGRAData(width, height, inputPitch, input, locked.Pitch, locked.pBits); break; - case GL_HALF_FLOAT_OES: - switch (mFormat) - { - // float textures are converted to RGBA, not BGRA, as they're stored that way in D3D - case GL_ALPHA: - loadAlphaHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - case GL_LUMINANCE: - loadLuminanceHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - case GL_LUMINANCE_ALPHA: - loadLuminanceAlphaHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - case GL_RGB: - loadRGBHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - case GL_RGBA: - loadRGBAHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); - break; - default: UNREACHABLE(); - } + // float textures are converted to RGBA, not BGRA, as they're stored that way in D3D + case GL_RGB32F_EXT: + loadRGBFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); break; - default: UNREACHABLE(); + case GL_RGB16F_EXT: + loadRGBHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_RGBA32F_EXT: + loadRGBAFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + case GL_RGBA16F_EXT: + loadRGBAHalfFloatData(width, height, inputPitch, input, locked.Pitch, locked.pBits); + break; + default: UNREACHABLE(); } unlock(); @@ -849,8 +851,8 @@ void Image::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsi return; } - GLsizei inputSize = ComputeCompressedSize(width, height, mFormat); - GLsizei inputPitch = ComputeCompressedPitch(width, mFormat); + GLsizei inputSize = ComputeCompressedSize(width, height, mInternalFormat); + GLsizei inputPitch = ComputeCompressedPitch(width, mInternalFormat); int rows = inputSize / inputPitch; for (int i = 0; i < rows; ++i) { @@ -888,153 +890,385 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, RECT sourceRect = {x, y, x + width, y + height}; RECT destRect = {xoffset, yoffset, xoffset + width, yoffset + height}; - if (isRenderableFormat()) + D3DLOCKED_RECT sourceLock = {0}; + result = renderTargetData->LockRect(&sourceLock, &sourceRect, 0); + + if (FAILED(result)) { - result = D3DXLoadSurfaceFromSurface(getSurface(), NULL, &destRect, renderTargetData, NULL, &sourceRect, D3DX_FILTER_BOX, 0); - - if (FAILED(result)) - { - ERR("Copying surfaces unexpectedly failed."); - renderTargetData->Release(); - return error(GL_OUT_OF_MEMORY); - } + ERR("Failed to lock the source surface (rectangle might be invalid)."); + renderTargetData->Release(); + return error(GL_OUT_OF_MEMORY); } - else + + D3DLOCKED_RECT destLock = {0}; + result = lock(&destLock, &destRect); + + if (FAILED(result)) { - D3DLOCKED_RECT sourceLock = {0}; - result = renderTargetData->LockRect(&sourceLock, &sourceRect, 0); + ERR("Failed to lock the destination surface (rectangle might be invalid)."); + renderTargetData->UnlockRect(); + renderTargetData->Release(); + return error(GL_OUT_OF_MEMORY); + } - if (FAILED(result)) + if (destLock.pBits && sourceLock.pBits) + { + unsigned char *source = (unsigned char*)sourceLock.pBits; + unsigned char *dest = (unsigned char*)destLock.pBits; + + switch (description.Format) { - ERR("Failed to lock the source surface (rectangle might be invalid)."); - renderTargetData->Release(); - return error(GL_OUT_OF_MEMORY); - } - - D3DLOCKED_RECT destLock = {0}; - result = lock(&destLock, &destRect); - - if (FAILED(result)) - { - ERR("Failed to lock the destination surface (rectangle might be invalid)."); - renderTargetData->UnlockRect(); - renderTargetData->Release(); - return error(GL_OUT_OF_MEMORY); - } - - if (destLock.pBits && sourceLock.pBits) - { - unsigned char *source = (unsigned char*)sourceLock.pBits; - unsigned char *dest = (unsigned char*)destLock.pBits; - - switch (description.Format) + case D3DFMT_X8R8G8B8: + case D3DFMT_A8R8G8B8: + switch(getD3DFormat()) { case D3DFMT_X8R8G8B8: case D3DFMT_A8R8G8B8: - switch(getD3DFormat()) + for(int y = 0; y < height; y++) { - case D3DFMT_L8: - for(int y = 0; y < height; y++) - { - for(int x = 0; x < width; x++) - { - dest[x] = source[x * 4 + 2]; - } + memcpy(dest, source, 4 * width); - source += sourceLock.Pitch; - dest += destLock.Pitch; - } - break; - case D3DFMT_A8L8: - for(int y = 0; y < height; y++) - { - for(int x = 0; x < width; x++) - { - dest[x * 2 + 0] = source[x * 4 + 2]; - dest[x * 2 + 1] = source[x * 4 + 3]; - } - - source += sourceLock.Pitch; - dest += destLock.Pitch; - } - break; - default: - UNREACHABLE(); + source += sourceLock.Pitch; + dest += destLock.Pitch; } break; - case D3DFMT_R5G6B5: - switch(getD3DFormat()) + case D3DFMT_L8: + for(int y = 0; y < height; y++) { - case D3DFMT_L8: - for(int y = 0; y < height; y++) + for(int x = 0; x < width; x++) { - for(int x = 0; x < width; x++) - { - unsigned char red = source[x * 2 + 1] & 0xF8; - dest[x] = red | (red >> 5); - } - - source += sourceLock.Pitch; - dest += destLock.Pitch; + dest[x] = source[x * 4 + 2]; } - break; - default: - UNREACHABLE(); + + source += sourceLock.Pitch; + dest += destLock.Pitch; } break; - case D3DFMT_A1R5G5B5: - switch(getD3DFormat()) + case D3DFMT_A8L8: + for(int y = 0; y < height; y++) { - case D3DFMT_L8: - for(int y = 0; y < height; y++) + for(int x = 0; x < width; x++) { - for(int x = 0; x < width; x++) - { - unsigned char red = source[x * 2 + 1] & 0x7C; - dest[x] = (red << 1) | (red >> 4); - } - - source += sourceLock.Pitch; - dest += destLock.Pitch; + dest[x * 2 + 0] = source[x * 4 + 2]; + dest[x * 2 + 1] = source[x * 4 + 3]; } - break; - case D3DFMT_A8L8: - for(int y = 0; y < height; y++) - { - for(int x = 0; x < width; x++) - { - unsigned char red = source[x * 2 + 1] & 0x7C; - dest[x * 2 + 0] = (red << 1) | (red >> 4); - dest[x * 2 + 1] = (signed char)source[x * 2 + 1] >> 7; - } - source += sourceLock.Pitch; - dest += destLock.Pitch; - } - break; - default: - UNREACHABLE(); + source += sourceLock.Pitch; + dest += destLock.Pitch; } break; default: UNREACHABLE(); } - } + break; + case D3DFMT_R5G6B5: + switch(getD3DFormat()) + { + case D3DFMT_X8R8G8B8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + unsigned short rgb = ((unsigned short*)source)[x]; + unsigned char red = (rgb & 0xF800) >> 8; + unsigned char green = (rgb & 0x07E0) >> 3; + unsigned char blue = (rgb & 0x001F) << 3; + dest[x + 0] = blue | (blue >> 5); + dest[x + 1] = green | (green >> 6); + dest[x + 2] = red | (red >> 5); + dest[x + 3] = 0xFF; + } - unlock(); - renderTargetData->UnlockRect(); + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + case D3DFMT_L8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + unsigned char red = source[x * 2 + 1] & 0xF8; + dest[x] = red | (red >> 5); + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + default: + UNREACHABLE(); + } + break; + case D3DFMT_A1R5G5B5: + switch(getD3DFormat()) + { + case D3DFMT_X8R8G8B8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + unsigned short argb = ((unsigned short*)source)[x]; + unsigned char red = (argb & 0x7C00) >> 7; + unsigned char green = (argb & 0x03E0) >> 2; + unsigned char blue = (argb & 0x001F) << 3; + dest[x + 0] = blue | (blue >> 5); + dest[x + 1] = green | (green >> 5); + dest[x + 2] = red | (red >> 5); + dest[x + 3] = 0xFF; + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + case D3DFMT_A8R8G8B8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + unsigned short argb = ((unsigned short*)source)[x]; + unsigned char red = (argb & 0x7C00) >> 7; + unsigned char green = (argb & 0x03E0) >> 2; + unsigned char blue = (argb & 0x001F) << 3; + unsigned char alpha = (signed short)argb >> 15; + dest[x + 0] = blue | (blue >> 5); + dest[x + 1] = green | (green >> 5); + dest[x + 2] = red | (red >> 5); + dest[x + 3] = alpha; + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + case D3DFMT_L8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + unsigned char red = source[x * 2 + 1] & 0x7C; + dest[x] = (red << 1) | (red >> 4); + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + case D3DFMT_A8L8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + unsigned char red = source[x * 2 + 1] & 0x7C; + dest[x * 2 + 0] = (red << 1) | (red >> 4); + dest[x * 2 + 1] = (signed char)source[x * 2 + 1] >> 7; + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + default: + UNREACHABLE(); + } + break; + default: + UNREACHABLE(); + } } + unlock(); + renderTargetData->UnlockRect(); + renderTargetData->Release(); mDirty = true; } +namespace +{ +struct L8 +{ + unsigned char L; + + static void average(L8 *dst, const L8 *src1, const L8 *src2) + { + dst->L = ((src1->L ^ src2->L) >> 1) + (src1->L & src2->L); + } +}; + +struct A8L8 +{ + unsigned char L; + unsigned char A; + + static void average(A8L8 *dst, const A8L8 *src1, const A8L8 *src2) + { + *(unsigned short*)dst = (((*(unsigned short*)src1 ^ *(unsigned short*)src2) & 0xFEFE) >> 1) + (*(unsigned short*)src1 & *(unsigned short*)src2); + } +}; + +struct A8R8G8B8 +{ + unsigned char B; + unsigned char G; + unsigned char R; + unsigned char A; + + static void average(A8R8G8B8 *dst, const A8R8G8B8 *src1, const A8R8G8B8 *src2) + { + *(unsigned int*)dst = (((*(unsigned int*)src1 ^ *(unsigned int*)src2) & 0xFEFEFEFE) >> 1) + (*(unsigned int*)src1 & *(unsigned int*)src2); + } +}; + +struct A16B16G16R16F +{ + unsigned short R; + unsigned short G; + unsigned short B; + unsigned short A; + + static void average(A16B16G16R16F *dst, const A16B16G16R16F *src1, const A16B16G16R16F *src2) + { + dst->R = float32ToFloat16((float16ToFloat32(src1->R) + float16ToFloat32(src2->R)) * 0.5f); + dst->G = float32ToFloat16((float16ToFloat32(src1->G) + float16ToFloat32(src2->G)) * 0.5f); + dst->B = float32ToFloat16((float16ToFloat32(src1->B) + float16ToFloat32(src2->B)) * 0.5f); + dst->A = float32ToFloat16((float16ToFloat32(src1->A) + float16ToFloat32(src2->A)) * 0.5f); + } +}; + +struct A32B32G32R32F +{ + float R; + float G; + float B; + float A; + + static void average(A32B32G32R32F *dst, const A32B32G32R32F *src1, const A32B32G32R32F *src2) + { + dst->R = (src1->R + src2->R) * 0.5f; + dst->G = (src1->G + src2->G) * 0.5f; + dst->B = (src1->B + src2->B) * 0.5f; + dst->A = (src1->A + src2->A) * 0.5f; + } +}; + +template +void GenerateMip(unsigned int sourceWidth, unsigned int sourceHeight, + const unsigned char *sourceData, int sourcePitch, + unsigned char *destData, int destPitch) +{ + unsigned int mipWidth = std::max(1U, sourceWidth >> 1); + unsigned int mipHeight = std::max(1U, sourceHeight >> 1); + + if (sourceHeight == 1) + { + ASSERT(sourceWidth != 1); + + const T *src = (const T*)sourceData; + T *dst = (T*)destData; + + for (unsigned int x = 0; x < mipWidth; x++) + { + T::average(&dst[x], &src[x * 2], &src[x * 2 + 1]); + } + } + else if (sourceWidth == 1) + { + ASSERT(sourceHeight != 1); + + for (unsigned int y = 0; y < 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); + + T::average(dst, src0, src1); + } + } + else + { + for (unsigned int y = 0; y < 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); + + for (unsigned int x = 0; x < mipWidth; x++) + { + T tmp0; + T tmp1; + + T::average(&tmp0, &src0[x * 2], &src0[x * 2 + 1]); + T::average(&tmp1, &src1[x * 2], &src1[x * 2 + 1]); + T::average(&dst[x], &tmp0, &tmp1); + } + } + } +} + +void GenerateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface) +{ + D3DSURFACE_DESC destDesc; + HRESULT result = destSurface->GetDesc(&destDesc); + ASSERT(SUCCEEDED(result)); + + D3DSURFACE_DESC sourceDesc; + result = sourceSurface->GetDesc(&sourceDesc); + ASSERT(SUCCEEDED(result)); + + ASSERT(sourceDesc.Format == destDesc.Format); + ASSERT(sourceDesc.Width == 1 || sourceDesc.Width / 2 == destDesc.Width); + ASSERT(sourceDesc.Height == 1 || sourceDesc.Height / 2 == destDesc.Height); + + D3DLOCKED_RECT sourceLocked = {0}; + result = sourceSurface->LockRect(&sourceLocked, NULL, D3DLOCK_READONLY); + ASSERT(SUCCEEDED(result)); + + D3DLOCKED_RECT destLocked = {0}; + result = destSurface->LockRect(&destLocked, NULL, 0); + ASSERT(SUCCEEDED(result)); + + const unsigned char *sourceData = reinterpret_cast(sourceLocked.pBits); + unsigned char *destData = reinterpret_cast(destLocked.pBits); + + if (sourceData && destData) + { + switch (sourceDesc.Format) + { + case D3DFMT_L8: + GenerateMip(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch); + break; + case D3DFMT_A8L8: + GenerateMip(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch); + break; + case D3DFMT_A8R8G8B8: + case D3DFMT_X8R8G8B8: + GenerateMip(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch); + break; + case D3DFMT_A16B16G16R16F: + GenerateMip(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch); + break; + case D3DFMT_A32B32G32R32F: + GenerateMip(sourceDesc.Width, sourceDesc.Height, sourceData, sourceLocked.Pitch, destData, destLocked.Pitch); + break; + default: + UNREACHABLE(); + break; + } + + destSurface->UnlockRect(); + sourceSurface->UnlockRect(); + } +} +} + TextureStorage::TextureStorage(DWORD usage) - : mD3DUsage(usage), + : mLodOffset(0), + mD3DUsage(usage), mD3DPool(getDisplay()->getTexturePool(usage)), - mTextureSerial(issueTextureSerial()), - mLodOffset(0) + mTextureSerial(issueTextureSerial()) { } @@ -1242,11 +1476,28 @@ GLenum Texture::getUsage() const return mUsage; } +bool Texture::isMipmapFiltered() const +{ + switch (mMinFilter) + { + 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; + } +} + void Texture::setImage(GLint unpackAlignment, const void *pixels, Image *image) { if (pixels != NULL) { - image->loadData(0, 0, image->getWidth(), image->getHeight(), image->getType(), unpackAlignment, pixels); + image->loadData(0, 0, image->getWidth(), image->getHeight(), unpackAlignment, pixels); mDirtyImages = true; } } @@ -1264,7 +1515,7 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig { if (pixels != NULL) { - image->loadData(xoffset, yoffset, width, height, type, unpackAlignment, pixels); + image->loadData(xoffset, yoffset, width, height, unpackAlignment, pixels); mDirtyImages = true; } @@ -1357,9 +1608,9 @@ GLint Texture::creationLevels(GLsizei size) const return creationLevels(size, size); } -int Texture::levelCount() const +int Texture::levelCount() { - return getBaseTexture() ? getBaseTexture()->GetLevelCount() : 0; + return getBaseTexture() ? getBaseTexture()->GetLevelCount() - getLodOffset() : 0; } Blit *Texture::getBlitter() @@ -1372,11 +1623,22 @@ bool Texture::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *sou { if (source && dest) { - HRESULT result; + HRESULT result = D3DERR_OUTOFVIDEOMEMORY; if (fromManaged) { - result = D3DXLoadSurfaceFromSurface(dest, NULL, NULL, source, NULL, NULL, D3DX_FILTER_BOX, 0); + D3DSURFACE_DESC desc; + source->GetDesc(&desc); + + IDirect3DSurface9 *surf = 0; + result = getDevice()->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surf, NULL); + + if (SUCCEEDED(result)) + { + CopyLockableSurfaces(surf, source); + result = getDevice()->UpdateSurface(surf, NULL, dest, NULL); + surf->Release(); + } } else { @@ -1411,8 +1673,8 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, in if (width > 0 && height > 0) { IDirect3DDevice9 *device = getDevice(); - MakeValidSize(false, dx2es::IsCompressedD3DFormat(format), &width, &height, &mLodOffset); - HRESULT result = device->CreateTexture(width, height, levels + mLodOffset, getUsage(), format, getPool(), &mTexture, NULL); + MakeValidSize(false, dx::IsCompressedFormat(format), &width, &height, &mLodOffset); + HRESULT result = device->CreateTexture(width, height, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL); if (FAILED(result)) { @@ -1432,7 +1694,7 @@ TextureStorage2D::~TextureStorage2D() // Increments refcount on surface. // caller must Release() the returned surface -IDirect3DSurface9 *TextureStorage2D::getSurfaceLevel(int level) +IDirect3DSurface9 *TextureStorage2D::getSurfaceLevel(int level, bool dirty) { IDirect3DSurface9 *surface = NULL; @@ -1440,6 +1702,12 @@ IDirect3DSurface9 *TextureStorage2D::getSurfaceLevel(int level) { HRESULT result = mTexture->GetSurfaceLevel(level + mLodOffset, &surface); ASSERT(SUCCEEDED(result)); + + // With managed textures the driver needs to be informed of updates to the lower mipmap levels + if (level != 0 && isManaged() && dirty) + { + mTexture->AddDirtyRect(NULL); + } } return surface; @@ -1518,7 +1786,7 @@ GLsizei Texture2D::getHeight(GLint level) const GLenum Texture2D::getInternalFormat(GLint level) const { if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) - return mImageArray[level].getFormat(); + return mImageArray[level].getInternalFormat(); else return GL_NONE; } @@ -1531,11 +1799,11 @@ D3DFORMAT Texture2D::getD3DFormat(GLint level) const return D3DFMT_UNKNOWN; } -void Texture2D::redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type) +void Texture2D::redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height) { releaseTexImage(); - bool redefined = mImageArray[level].redefine(format, width, height, type, false); + bool redefined = mImageArray[level].redefine(internalformat, width, height, false); if (mTexStorage && redefined) { @@ -1552,7 +1820,8 @@ void Texture2D::redefineImage(GLint level, GLenum format, GLsizei width, GLsizei void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels) { - redefineImage(level, format, width, height, type); + GLint internalformat = ConvertSizedInternalFormat(format, type); + redefineImage(level, internalformat, width, height); Texture::setImage(unpackAlignment, pixels, &mImageArray[level]); } @@ -1561,22 +1830,22 @@ void Texture2D::bindTexImage(egl::Surface *surface) { releaseTexImage(); - GLenum format; + GLint internalformat; switch(surface->getFormat()) { case D3DFMT_A8R8G8B8: - format = GL_RGBA; + internalformat = GL_RGBA8_OES; break; case D3DFMT_X8R8G8B8: - format = GL_RGB; + internalformat = GL_RGB8_OES; break; default: UNIMPLEMENTED(); return; } - mImageArray[0].redefine(format, surface->getWidth(), surface->getHeight(), GL_UNSIGNED_BYTE, true); + mImageArray[0].redefine(internalformat, surface->getWidth(), surface->getHeight(), true); delete mTexStorage; mTexStorage = new TextureStorage2D(surface->getOffscreenTexture()); @@ -1601,14 +1870,15 @@ void Texture2D::releaseTexImage() for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) { - mImageArray[i].redefine(GL_RGBA, 0, 0, GL_UNSIGNED_BYTE, true); + mImageArray[i].redefine(GL_RGBA8_OES, 0, 0, true); } } } void Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels) { - redefineImage(level, format, width, height, GL_UNSIGNED_BYTE); + // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly + redefineImage(level, format, width, height); Texture::setCompressedImage(imageSize, pixels, &mImageArray[level]); } @@ -1619,7 +1889,7 @@ void Texture2D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei wi if (level < levelCount()) { - IDirect3DSurface9 *destLevel = mTexStorage->getSurfaceLevel(level); + IDirect3DSurface9 *destLevel = mTexStorage->getSurfaceLevel(level, true); if (destLevel) { @@ -1658,7 +1928,8 @@ void Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei return error(GL_OUT_OF_MEMORY); } - redefineImage(level, format, width, height, GL_UNSIGNED_BYTE); + GLint internalformat = ConvertSizedInternalFormat(format, GL_UNSIGNED_BYTE); + redefineImage(level, internalformat, width, height); if (!mImageArray[level].isRenderableFormat()) { @@ -1682,7 +1953,7 @@ void Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei sourceRect.top = y; sourceRect.bottom = y + height; - IDirect3DSurface9 *dest = mTexStorage->getSurfaceLevel(level); + IDirect3DSurface9 *dest = mTexStorage->getSurfaceLevel(level, true); if (dest) { @@ -1732,12 +2003,13 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo sourceRect.top = y; sourceRect.bottom = y + height; - - IDirect3DSurface9 *dest = mTexStorage->getSurfaceLevel(level); + IDirect3DSurface9 *dest = mTexStorage->getSurfaceLevel(level, true); if (dest) { - getBlitter()->copy(renderTarget, sourceRect, mImageArray[0].getFormat(), xoffset, yoffset, dest); + getBlitter()->copy(renderTarget, sourceRect, + gl::ExtractFormat(mImageArray[0].getInternalFormat()), + xoffset, yoffset, dest); dest->Release(); } } @@ -1748,9 +2020,7 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) { - GLenum format = gl::ExtractFormat(internalformat); - GLenum type = gl::ExtractType(internalformat); - D3DFORMAT d3dfmt = ConvertTextureFormatType(format, type); + D3DFORMAT d3dfmt = ConvertTextureInternalFormat(internalformat); DWORD d3dusage = GetTextureUsage(d3dfmt, mUsage, false); delete mTexStorage; @@ -1759,14 +2029,14 @@ void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GL for (int level = 0; level < levels; level++) { - mImageArray[level].redefine(format, width, height, type, true); + mImageArray[level].redefine(internalformat, width, height, true); width = std::max(1, width >> 1); height = std::max(1, height >> 1); } for (int level = levels; level < IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++) { - mImageArray[level].redefine(GL_NONE, 0, 0, GL_UNSIGNED_BYTE, true); + mImageArray[level].redefine(GL_NONE, 0, 0, true); } if (mTexStorage->isManaged()) @@ -1775,7 +2045,7 @@ void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GL for (int level = 0; level < levels; level++) { - IDirect3DSurface9 *surface = mTexStorage->getSurfaceLevel(level); + IDirect3DSurface9 *surface = mTexStorage->getSurfaceLevel(level, false); mImageArray[level].setManagedSurface(surface); } } @@ -1792,25 +2062,10 @@ bool Texture2D::isSamplerComplete() const return false; } - bool mipmapping = false; + bool mipmapping = isMipmapFiltered(); - switch (mMinFilter) - { - case GL_NEAREST: - case GL_LINEAR: - mipmapping = false; - break; - case GL_NEAREST_MIPMAP_NEAREST: - case GL_LINEAR_MIPMAP_NEAREST: - case GL_NEAREST_MIPMAP_LINEAR: - case GL_LINEAR_MIPMAP_LINEAR: - mipmapping = true; - break; - default: UNREACHABLE(); - } - - if ((getInternalFormat(0) == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) || - (getInternalFormat(0) == GL_HALF_FLOAT_OES && !getContext()->supportsFloat16LinearFilter())) + if ((IsFloat32Format(getInternalFormat(0)) && !getContext()->supportsFloat32LinearFilter()) || + (IsFloat16Format(getInternalFormat(0)) && !getContext()->supportsFloat16LinearFilter())) { if (mMagFilter != GL_NEAREST || (mMinFilter != GL_NEAREST && mMinFilter != GL_NEAREST_MIPMAP_NEAREST)) { @@ -1868,12 +2123,7 @@ bool Texture2D::isMipmapComplete() const for (int level = 1; level <= q; level++) { - if (mImageArray[level].getFormat() != mImageArray[0].getFormat()) - { - return false; - } - - if (mImageArray[level].getType() != mImageArray[0].getType()) + if (mImageArray[level].getInternalFormat() != mImageArray[0].getInternalFormat()) { return false; } @@ -1929,7 +2179,7 @@ void Texture2D::createTexture() for (int level = 0; level < levels; level++) { - IDirect3DSurface9 *surface = mTexStorage->getSurfaceLevel(level); + IDirect3DSurface9 *surface = mTexStorage->getSurfaceLevel(level, false); mImageArray[level].setManagedSurface(surface); } } @@ -1939,7 +2189,9 @@ void Texture2D::createTexture() void Texture2D::updateTexture() { - int levels = levelCount(); + bool mipmapping = (isMipmapFiltered() && isMipmapComplete()); + + int levels = (mipmapping ? levelCount() : 1); for (int level = 0; level < levels; level++) { @@ -1971,8 +2223,8 @@ void Texture2D::convertToRenderTarget() int levels = levelCount(); for (int i = 0; i < levels; i++) { - IDirect3DSurface9 *source = mTexStorage->getSurfaceLevel(i); - IDirect3DSurface9 *dest = newTexStorage->getSurfaceLevel(i); + IDirect3DSurface9 *source = mTexStorage->getSurfaceLevel(i, false); + IDirect3DSurface9 *dest = newTexStorage->getSurfaceLevel(i, true); if (!copyToRenderTarget(dest, source, mTexStorage->isManaged())) { @@ -2008,18 +2260,17 @@ void Texture2D::generateMipmaps() unsigned int q = log2(std::max(mImageArray[0].getWidth(), mImageArray[0].getHeight())); for (unsigned int i = 1; i <= q; i++) { - redefineImage(i, mImageArray[0].getFormat(), + redefineImage(i, mImageArray[0].getInternalFormat(), std::max(mImageArray[0].getWidth() >> i, 1), - std::max(mImageArray[0].getHeight() >> i, 1), - mImageArray[0].getType()); + std::max(mImageArray[0].getHeight() >> i, 1)); } if (mTexStorage && mTexStorage->isRenderTarget()) { for (unsigned int i = 1; i <= q; i++) { - IDirect3DSurface9 *upper = mTexStorage->getSurfaceLevel(i - 1); - IDirect3DSurface9 *lower = mTexStorage->getSurfaceLevel(i); + IDirect3DSurface9 *upper = mTexStorage->getSurfaceLevel(i - 1, false); + IDirect3DSurface9 *lower = mTexStorage->getSurfaceLevel(i, true); if (upper != NULL && lower != NULL) { @@ -2041,10 +2292,7 @@ void Texture2D::generateMipmaps() return error(GL_OUT_OF_MEMORY); } - if (FAILED(D3DXLoadSurfaceFromSurface(mImageArray[i].getSurface(), NULL, NULL, mImageArray[i - 1].getSurface(), NULL, NULL, D3DX_FILTER_BOX, 0))) - { - ERR(" failed to load filter %d to %d.", i - 1, i); - } + GenerateMip(mImageArray[i].getSurface(), mImageArray[i - 1].getSurface()); mImageArray[i].markDirty(); } @@ -2085,7 +2333,7 @@ IDirect3DSurface9 *Texture2D::getRenderTarget(GLenum target) { return NULL; } - return mTexStorage->getSurfaceLevel(0); + return mTexStorage->getSurfaceLevel(0, false); } // Increments refcount on surface. @@ -2107,7 +2355,7 @@ IDirect3DSurface9 *Texture2D::getDepthStencil(GLenum target) { return NULL; } - return mTexStorage->getSurfaceLevel(0); + return mTexStorage->getSurfaceLevel(0, false); } TextureStorage *Texture2D::getStorage(bool renderTarget) @@ -2137,8 +2385,8 @@ TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, DWORD { IDirect3DDevice9 *device = getDevice(); int height = size; - MakeValidSize(false, dx2es::IsCompressedD3DFormat(format), &size, &height, &mLodOffset); - HRESULT result = device->CreateCubeTexture(size, levels + mLodOffset, getUsage(), format, getPool(), &mTexture, NULL); + MakeValidSize(false, dx::IsCompressedFormat(format), &size, &height, &mLodOffset); + HRESULT result = device->CreateCubeTexture(size, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL); if (FAILED(result)) { @@ -2158,14 +2406,21 @@ TextureStorageCubeMap::~TextureStorageCubeMap() // Increments refcount on surface. // caller must Release() the returned surface -IDirect3DSurface9 *TextureStorageCubeMap::getCubeMapSurface(GLenum faceTarget, int level) +IDirect3DSurface9 *TextureStorageCubeMap::getCubeMapSurface(GLenum faceTarget, int level, bool dirty) { IDirect3DSurface9 *surface = NULL; if (mTexture) { - HRESULT result = mTexture->GetCubeMapSurface(es2dx::ConvertCubeFace(faceTarget), level + mLodOffset, &surface); + D3DCUBEMAP_FACES face = es2dx::ConvertCubeFace(faceTarget); + HRESULT result = mTexture->GetCubeMapSurface(face, level + mLodOffset, &surface); ASSERT(SUCCEEDED(result)); + + // With managed textures the driver needs to be informed of updates to the lower mipmap levels + if (level != 0 && isManaged() && dirty) + { + mTexture->AddDirtyRect(face, NULL); + } } return surface; @@ -2255,7 +2510,7 @@ GLsizei TextureCubeMap::getHeight(GLenum target, GLint level) const GLenum TextureCubeMap::getInternalFormat(GLenum target, GLint level) const { if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) - return mImageArray[faceIndex(target)][level].getFormat(); + return mImageArray[faceIndex(target)][level].getInternalFormat(); else return GL_NONE; } @@ -2300,7 +2555,8 @@ void TextureCubeMap::setImageNegZ(GLint level, GLsizei width, GLsizei height, GL void TextureCubeMap::setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels) { - redefineImage(faceIndex(face), level, format, width, height, GL_UNSIGNED_BYTE); + // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly + redefineImage(faceIndex(face), level, format, width, height); Texture::setCompressedImage(imageSize, pixels, &mImageArray[faceIndex(face)][level]); } @@ -2311,7 +2567,7 @@ void TextureCubeMap::commitRect(int face, GLint level, GLint xoffset, GLint yoff if (level < levelCount()) { - IDirect3DSurface9 *destLevel = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level); + IDirect3DSurface9 *destLevel = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, true); ASSERT(destLevel != NULL); if (destLevel != NULL) @@ -2346,27 +2602,10 @@ bool TextureCubeMap::isSamplerComplete() const { int size = mImageArray[0][0].getWidth(); - bool mipmapping; + bool mipmapping = isMipmapFiltered(); - switch (mMinFilter) - { - case GL_NEAREST: - case GL_LINEAR: - mipmapping = false; - break; - case GL_NEAREST_MIPMAP_NEAREST: - case GL_LINEAR_MIPMAP_NEAREST: - case GL_NEAREST_MIPMAP_LINEAR: - case GL_LINEAR_MIPMAP_LINEAR: - mipmapping = true; - break; - default: - UNREACHABLE(); - return false; - } - - if ((getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0) == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) || - (getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0) == GL_HALF_FLOAT_OES && !getContext()->supportsFloat16LinearFilter())) + if ((gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)) == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) || + (gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0) == GL_HALF_FLOAT_OES) && !getContext()->supportsFloat16LinearFilter())) { if (mMagFilter != GL_NEAREST || (mMinFilter != GL_NEAREST && mMinFilter != GL_NEAREST_MIPMAP_NEAREST)) { @@ -2412,8 +2651,7 @@ bool TextureCubeMap::isCubeComplete() const { if (mImageArray[face][0].getWidth() != mImageArray[0][0].getWidth() || mImageArray[face][0].getWidth() != mImageArray[0][0].getHeight() || - mImageArray[face][0].getFormat() != mImageArray[0][0].getFormat() || - mImageArray[face][0].getType() != mImageArray[0][0].getType()) + mImageArray[face][0].getInternalFormat() != mImageArray[0][0].getInternalFormat()) { return false; } @@ -2442,12 +2680,7 @@ bool TextureCubeMap::isMipmapCubeComplete() const { for (int level = 1; level <= q; level++) { - if (mImageArray[face][level].getFormat() != mImageArray[0][0].getFormat()) - { - return false; - } - - if (mImageArray[face][level].getType() != mImageArray[0][0].getType()) + if (mImageArray[face][level].getInternalFormat() != mImageArray[0][0].getInternalFormat()) { return false; } @@ -2480,7 +2713,7 @@ void TextureCubeMap::createTexture() if (!(size > 0)) return; // do not attempt to create d3d textures for nonexistant data - GLint levels = creationLevels(size, 0); + GLint levels = creationLevels(size); D3DFORMAT d3dfmt = mImageArray[0][0].getD3DFormat(); DWORD d3dusage = GetTextureUsage(d3dfmt, mUsage, false); @@ -2495,7 +2728,7 @@ void TextureCubeMap::createTexture() { for (int level = 0; level < levels; level++) { - IDirect3DSurface9 *surface = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level); + IDirect3DSurface9 *surface = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, false); mImageArray[face][level].setManagedSurface(surface); } } @@ -2506,9 +2739,12 @@ void TextureCubeMap::createTexture() void TextureCubeMap::updateTexture() { + bool mipmapping = isMipmapFiltered() && isMipmapCubeComplete(); + for (int face = 0; face < 6; face++) { - int levels = levelCount(); + int levels = (mipmapping ? levelCount() : 1); + for (int level = 0; level < levels; level++) { Image *image = &mImageArray[face][level]; @@ -2528,7 +2764,7 @@ void TextureCubeMap::convertToRenderTarget() if (mImageArray[0][0].getWidth() != 0) { GLsizei size = mImageArray[0][0].getWidth(); - GLint levels = creationLevels(size, 0); + GLint levels = creationLevels(size); D3DFORMAT d3dfmt = mImageArray[0][0].getD3DFormat(); DWORD d3dusage = GetTextureUsage(d3dfmt, GL_FRAMEBUFFER_ATTACHMENT_ANGLE, true); @@ -2541,8 +2777,8 @@ void TextureCubeMap::convertToRenderTarget() { for (int i = 0; i < levels; i++) { - IDirect3DSurface9 *source = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i); - IDirect3DSurface9 *dest = newTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i); + IDirect3DSurface9 *source = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i, false); + IDirect3DSurface9 *dest = newTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i, true); if (!copyToRenderTarget(dest, source, mTexStorage->isManaged())) { @@ -2567,7 +2803,8 @@ void TextureCubeMap::convertToRenderTarget() void TextureCubeMap::setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels) { - redefineImage(faceIndex, level, format, width, height, type); + GLint internalformat = ConvertSizedInternalFormat(format, type); + redefineImage(faceIndex, level, internalformat, width, height); Texture::setImage(unpackAlignment, pixels, &mImageArray[faceIndex][level]); } @@ -2583,9 +2820,9 @@ unsigned int TextureCubeMap::faceIndex(GLenum face) return face - GL_TEXTURE_CUBE_MAP_POSITIVE_X; } -void TextureCubeMap::redefineImage(int face, GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type) +void TextureCubeMap::redefineImage(int face, GLint level, GLint internalformat, GLsizei width, GLsizei height) { - bool redefined = mImageArray[face][level].redefine(format, width, height, type, false); + bool redefined = mImageArray[face][level].redefine(internalformat, width, height, false); if (mTexStorage && redefined) { @@ -2615,7 +2852,8 @@ void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint } unsigned int faceindex = faceIndex(target); - redefineImage(faceindex, level, format, width, height, GL_UNSIGNED_BYTE); + GLint internalformat = gl::ConvertSizedInternalFormat(format, GL_UNSIGNED_BYTE); + redefineImage(faceindex, level, internalformat, width, height); if (!mImageArray[faceindex][level].isRenderableFormat()) { @@ -2641,7 +2879,7 @@ void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint sourceRect.top = y; sourceRect.bottom = y + height; - IDirect3DSurface9 *dest = mTexStorage->getCubeMapSurface(target, level); + IDirect3DSurface9 *dest = mTexStorage->getCubeMapSurface(target, level, true); if (dest) { @@ -2695,11 +2933,11 @@ void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLi sourceRect.top = y; sourceRect.bottom = y + height; - IDirect3DSurface9 *dest = mTexStorage->getCubeMapSurface(target, level); + IDirect3DSurface9 *dest = mTexStorage->getCubeMapSurface(target, level, true); if (dest) { - getBlitter()->copy(renderTarget, sourceRect, mImageArray[0][0].getFormat(), xoffset, yoffset, dest); + getBlitter()->copy(renderTarget, sourceRect, gl::ExtractFormat(mImageArray[0][0].getInternalFormat()), xoffset, yoffset, dest); dest->Release(); } } @@ -2710,9 +2948,7 @@ void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLi void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size) { - GLenum format = gl::ExtractFormat(internalformat); - GLenum type = gl::ExtractType(internalformat); - D3DFORMAT d3dfmt = ConvertTextureFormatType(format, type); + D3DFORMAT d3dfmt = ConvertTextureInternalFormat(internalformat); DWORD d3dusage = GetTextureUsage(d3dfmt, mUsage, false); delete mTexStorage; @@ -2723,7 +2959,7 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size { for (int face = 0; face < 6; face++) { - mImageArray[face][level].redefine(format, size, size, type, true); + mImageArray[face][level].redefine(internalformat, size, size, true); size = std::max(1, size >> 1); } } @@ -2732,7 +2968,7 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size { for (int face = 0; face < 6; face++) { - mImageArray[face][level].redefine(GL_NONE, 0, 0, GL_UNSIGNED_BYTE, true); + mImageArray[face][level].redefine(GL_NONE, 0, 0, true); } } @@ -2744,7 +2980,7 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size { for (int level = 0; level < levels; level++) { - IDirect3DSurface9 *surface = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level); + IDirect3DSurface9 *surface = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, false); mImageArray[face][level].setManagedSurface(surface); } } @@ -2772,10 +3008,9 @@ void TextureCubeMap::generateMipmaps() { for (unsigned int i = 1; i <= q; i++) { - redefineImage(f, i, mImageArray[f][0].getFormat(), + redefineImage(f, i, mImageArray[f][0].getInternalFormat(), std::max(mImageArray[f][0].getWidth() >> i, 1), - std::max(mImageArray[f][0].getWidth() >> i, 1), - mImageArray[f][0].getType()); + std::max(mImageArray[f][0].getWidth() >> i, 1)); } } @@ -2785,8 +3020,8 @@ void TextureCubeMap::generateMipmaps() { for (unsigned int i = 1; i <= q; i++) { - IDirect3DSurface9 *upper = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i-1); - IDirect3DSurface9 *lower = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i); + IDirect3DSurface9 *upper = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i - 1, false); + IDirect3DSurface9 *lower = mTexStorage->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i, true); if (upper != NULL && lower != NULL) { @@ -2811,10 +3046,7 @@ void TextureCubeMap::generateMipmaps() return error(GL_OUT_OF_MEMORY); } - if (FAILED(D3DXLoadSurfaceFromSurface(mImageArray[f][i].getSurface(), NULL, NULL, mImageArray[f][i - 1].getSurface(), NULL, NULL, D3DX_FILTER_BOX, 0))) - { - ERR(" failed to load filter %d to %d.", i - 1, i); - } + GenerateMip(mImageArray[f][i].getSurface(), mImageArray[f][i - 1].getSurface()); mImageArray[f][i].markDirty(); } @@ -2853,7 +3085,7 @@ IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target) updateTexture(); - return mTexStorage->getCubeMapSurface(target, 0); + return mTexStorage->getCubeMapSurface(target, 0, false); } TextureStorage *TextureCubeMap::getStorage(bool renderTarget) diff --git a/gfx/angle/src/libGLESv2/Texture.h b/gfx/angle/src/libGLESv2/Texture.h index 6d67df7bc85d..deb2d050a5a9 100644 --- a/gfx/angle/src/libGLESv2/Texture.h +++ b/gfx/angle/src/libGLESv2/Texture.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -49,7 +49,7 @@ class Image Image(); ~Image(); - bool redefine(GLenum format, GLsizei width, GLsizei height, GLenum type, bool forceRelease); + bool redefine(GLint internalformat, GLsizei width, GLsizei height, bool forceRelease); void markDirty() {mDirty = true;} void markClean() {mDirty = false;} @@ -58,15 +58,14 @@ class Image GLsizei getWidth() const {return mWidth;} GLsizei getHeight() const {return mHeight;} - GLenum getFormat() const {return mFormat;} - GLenum getType() const {return mType;} + GLenum getInternalFormat() const {return mInternalFormat;} bool isDirty() const {return mSurface && mDirty;} IDirect3DSurface9 *getSurface(); void setManagedSurface(IDirect3DSurface9 *surface); void updateSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); - void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum type, + void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLint unpackAlignment, const void *input); void loadAlphaData(GLsizei width, GLsizei height, @@ -126,8 +125,7 @@ class Image GLsizei mWidth; GLsizei mHeight; - GLenum mFormat; - GLenum mType; + GLint mInternalFormat; bool mDirty; @@ -192,6 +190,7 @@ class Texture : public RefCountObject GLenum getWrapT() const; float getMaxAnisotropy() const; GLenum getUsage() const; + bool isMipmapFiltered() const; virtual bool isSamplerComplete() const = 0; @@ -227,7 +226,7 @@ class Texture : public RefCountObject virtual void convertToRenderTarget() = 0; virtual IDirect3DSurface9 *getRenderTarget(GLenum target) = 0; - int levelCount() const; + int levelCount(); static Blit *getBlitter(); static bool copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged); @@ -258,7 +257,7 @@ class TextureStorage2D : public TextureStorage virtual ~TextureStorage2D(); - IDirect3DSurface9 *getSurfaceLevel(int level); + IDirect3DSurface9 *getSurfaceLevel(int level, bool dirty); IDirect3DBaseTexture9 *getBaseTexture() const; virtual unsigned int getRenderTargetSerial(GLenum target) const; @@ -321,7 +320,7 @@ class Texture2D : public Texture bool isMipmapComplete() const; - void redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type); + void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height); void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); Image mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS]; @@ -345,7 +344,7 @@ class TextureStorageCubeMap : public TextureStorage virtual ~TextureStorageCubeMap(); - IDirect3DSurface9 *getCubeMapSurface(GLenum faceTarget, int level); + IDirect3DSurface9 *getCubeMapSurface(GLenum faceTarget, int level, bool dirty); IDirect3DBaseTexture9 *getBaseTexture() const; virtual unsigned int getRenderTargetSerial(GLenum target) const; @@ -416,7 +415,7 @@ class TextureCubeMap : public Texture void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); - void redefineImage(int faceIndex, GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type); + void redefineImage(int faceIndex, GLint level, GLint internalformat, GLsizei width, GLsizei height); Image mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS]; diff --git a/gfx/angle/src/libGLESv2/libGLESv2.cpp b/gfx/angle/src/libGLESv2/libGLESv2.cpp index 90df3c90080c..16d9c1775d73 100644 --- a/gfx/angle/src/libGLESv2/libGLESv2.cpp +++ b/gfx/angle/src/libGLESv2/libGLESv2.cpp @@ -148,8 +148,9 @@ bool checkTextureFormatType(GLenum format, GLenum type) return error(GL_INVALID_ENUM, false); } } + bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height, - GLint xoffset, GLint yoffset, GLint level, GLenum format, + GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type, gl::Texture2D *texture) { if (!texture) @@ -162,9 +163,13 @@ bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height, return error(GL_INVALID_OPERATION, false); } - if (format != GL_NONE && format != texture->getInternalFormat(level)) + if (format != GL_NONE) { - return error(GL_INVALID_OPERATION, false); + GLenum internalformat = gl::ConvertSizedInternalFormat(format, type); + if (internalformat != texture->getInternalFormat(level)) + { + return error(GL_INVALID_OPERATION, false); + } } if (compressed) @@ -186,7 +191,7 @@ bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height, } bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height, - GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, + GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type, gl::TextureCubeMap *texture) { if (!texture) @@ -199,9 +204,13 @@ bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height, return error(GL_INVALID_OPERATION, false); } - if (format != GL_NONE && format != texture->getInternalFormat(target, level)) + if (format != GL_NONE) { - return error(GL_INVALID_OPERATION, false); + GLenum internalformat = gl::ConvertSizedInternalFormat(format, type); + if (internalformat != texture->getInternalFormat(target, level)) + { + return error(GL_INVALID_OPERATION, false); + } } if (compressed) @@ -236,10 +245,12 @@ bool validReadFormatType(GLenum format, GLenum type) return false; } break; - case gl::IMPLEMENTATION_COLOR_READ_FORMAT: + case GL_BGRA_EXT: switch (type) { - case gl::IMPLEMENTATION_COLOR_READ_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; @@ -1216,7 +1227,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs if (target == GL_TEXTURE_2D) { gl::Texture2D *texture = context->getTexture2D(); - if (validateSubImageParams2D(true, width, height, xoffset, yoffset, level, format, texture)) + if (validateSubImageParams2D(true, width, height, xoffset, yoffset, level, format, GL_NONE, texture)) { texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); } @@ -1224,7 +1235,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs else if (gl::IsCubemapTextureTarget(target)) { gl::TextureCubeMap *texture = context->getTextureCubeMap(); - if (validateSubImageParamsCube(true, width, height, xoffset, yoffset, target, level, format, texture)) + if (validateSubImageParamsCube(true, width, height, xoffset, yoffset, target, level, format, GL_NONE, texture)) { texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); } @@ -1317,8 +1328,7 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma switch (internalformat) { case GL_ALPHA: - if (colorbufferFormat != GL_ALPHA && - colorbufferFormat != GL_RGBA && + if (colorbufferFormat != GL_ALPHA8_EXT && colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES) @@ -1328,10 +1338,8 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma break; case GL_LUMINANCE: case GL_RGB: - if (colorbufferFormat != GL_RGB && - colorbufferFormat != GL_RGB565 && + if (colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES && - colorbufferFormat != GL_RGBA && colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES) @@ -1341,8 +1349,7 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma break; case GL_LUMINANCE_ALPHA: case GL_RGBA: - if (colorbufferFormat != GL_RGBA && - colorbufferFormat != GL_RGBA4 && + if (colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES) { @@ -1496,22 +1503,22 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL { gl::Texture2D *tex2d = context->getTexture2D(); - if (!validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, tex2d)) + if (!validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d)) { return; // error already registered by validateSubImageParams } - textureFormat = tex2d->getInternalFormat(level); + textureFormat = gl::ExtractFormat(tex2d->getInternalFormat(level)); texture = tex2d; } else if (gl::IsCubemapTextureTarget(target)) { gl::TextureCubeMap *texcube = context->getTextureCubeMap(); - if (!validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, texcube)) + if (!validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube)) { return; // error already registered by validateSubImageParams } - textureFormat = texcube->getInternalFormat(target, level); + textureFormat = gl::ExtractFormat(texcube->getInternalFormat(target, level)); texture = texcube; } else UNREACHABLE(); @@ -1520,8 +1527,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL switch (textureFormat) { case GL_ALPHA: - if (colorbufferFormat != GL_ALPHA && - colorbufferFormat != GL_RGBA && + if (colorbufferFormat != GL_ALPHA8_EXT && colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES) @@ -1531,10 +1537,8 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL break; case GL_LUMINANCE: case GL_RGB: - if (colorbufferFormat != GL_RGB && - colorbufferFormat != GL_RGB565 && + if (colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES && - colorbufferFormat != GL_RGBA && colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES) @@ -1544,8 +1548,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL break; case GL_LUMINANCE_ALPHA: case GL_RGBA: - if (colorbufferFormat != GL_RGBA && - colorbufferFormat != GL_RGBA4 && + if (colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES) { @@ -4709,15 +4712,23 @@ void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, return error(GL_INVALID_VALUE); } - if (!validReadFormatType(format, type)) - { - return error(GL_INVALID_OPERATION); - } - gl::Context *context = gl::getNonLostContext(); if (context) { + 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->getCurrentReadFormatType(¤tFormat, ¤tType)) + return; + + if (!(currentFormat == format && currentType == type) && !validReadFormatType(format, type)) + { + return error(GL_INVALID_OPERATION); + } + context->readPixels(x, y, width, height, format, type, &bufSize, data); } } @@ -4741,15 +4752,23 @@ void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, return error(GL_INVALID_VALUE); } - if (!validReadFormatType(format, type)) - { - return error(GL_INVALID_OPERATION); - } - gl::Context *context = gl::getNonLostContext(); if (context) { + 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->getCurrentReadFormatType(¤tFormat, ¤tType)) + return; + + if (!(currentFormat == format && currentType == type) && !validReadFormatType(format, type)) + { + return error(GL_INVALID_OPERATION); + } + context->readPixels(x, y, width, height, format, type, NULL, pixels); } } @@ -5892,7 +5911,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint if (target == GL_TEXTURE_2D) { gl::Texture2D *texture = context->getTexture2D(); - if (validateSubImageParams2D(false, width, height, xoffset, yoffset, level, format, texture)) + if (validateSubImageParams2D(false, width, height, xoffset, yoffset, level, format, type, texture)) { texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels); } @@ -5900,7 +5919,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint else if (gl::IsCubemapTextureTarget(target)) { gl::TextureCubeMap *texture = context->getTextureCubeMap(); - if (validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, format, texture)) + if (validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, format, type, texture)) { texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels); } diff --git a/gfx/angle/src/libGLESv2/libGLESv2.def b/gfx/angle/src/libGLESv2/libGLESv2.def index 2324dcbaced4..30a32c9254a0 100644 --- a/gfx/angle/src/libGLESv2/libGLESv2.def +++ b/gfx/angle/src/libGLESv2/libGLESv2.def @@ -181,7 +181,7 @@ EXPORTS glGetProcAddress @148 NONAME glBindTexImage @158 NONAME - ; GCC has problems with linking to undecored stdcall functions, - ; so we explicitly add aliases for APIs used by EGL + ; GCC has problems with linking to undecorated stdcall functions, + ; so we explicitly add aliases for APIs used by EGL. glGetProcAddress@4=glGetProcAddress glBindTexImage@4=glBindTexImage diff --git a/gfx/angle/src/libGLESv2/libGLESv2.vcproj b/gfx/angle/src/libGLESv2/libGLESv2.vcproj deleted file mode 100644 index 3528e570ed1f..000000000000 --- a/gfx/angle/src/libGLESv2/libGLESv2.vcproj +++ /dev/null @@ -1,565 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gfx/angle/src/libGLESv2/libGLESv2.vcxproj b/gfx/angle/src/libGLESv2/libGLESv2.vcxproj new file mode 100644 index 000000000000..8352d2215ff0 --- /dev/null +++ b/gfx/angle/src/libGLESv2/libGLESv2.vcxproj @@ -0,0 +1,303 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {B5871A7A-968C-42E3-A33B-981E6F448E78} + libGLESv2 + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + $(IncludePath) + $(LibraryPath) + $(IncludePath) + $(LibraryPath) + $(IncludePath) + $(IncludePath) + $(LibraryPath) + $(LibraryPath) + + + + Disabled + $(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBGLESV2_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + true + EditAndContinue + 4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings) + + + d3d9.lib;%(AdditionalDependencies) + libGLESv2.def + true + Windows + false + + + MachineX86 + + + %40echo on +mkdir "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" +%40echo off + + + + + + MaxSpeed + AnySuitable + $(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + ANGLE_DISABLE_TRACE;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBGLESV2_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + + + Level4 + true + ProgramDatabase + 4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings) + + + d3d9.lib;%(AdditionalDependencies) + false + libGLESv2.def + true + Windows + true + true + false + + + MachineX86 + + + %40echo on +mkdir "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" +%40echo off + + + + + + X64 + + + Disabled + $(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBGLESV2_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level4 + 4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings) + ProgramDatabase + true + + + d3d9.lib;%(AdditionalDependencies) + libGLESv2.def + true + Windows + false + + + MachineX64 + + + %40echo on +mkdir "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" +%40echo off + + + + + + X64 + + + MaxSpeed + AnySuitable + $(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBGLESV2_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions) + MultiThreaded + + + Level4 + 4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings) + ProgramDatabase + true + + + d3d9.lib;%(AdditionalDependencies) + false + libGLESv2.def + true + Windows + true + true + false + + + MachineX64 + + + %40echo on +mkdir "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\lib\$(Configuration)\" +copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" +%40echo off + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {5620f0e4-6c43-49bc-a178-b804e1a0c3a7} + false + true + false + true + true + + + + + + \ No newline at end of file diff --git a/gfx/angle/src/libGLESv2/libGLESv2.vcxproj.filters b/gfx/angle/src/libGLESv2/libGLESv2.vcxproj.filters new file mode 100644 index 000000000000..dafea3b162eb --- /dev/null +++ b/gfx/angle/src/libGLESv2/libGLESv2.vcxproj.filters @@ -0,0 +1,184 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + + + + \ No newline at end of file diff --git a/gfx/angle/src/libGLESv2/main.cpp b/gfx/angle/src/libGLESv2/main.cpp index 154d277c27c9..6e678c2616ca 100644 --- a/gfx/angle/src/libGLESv2/main.cpp +++ b/gfx/angle/src/libGLESv2/main.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -16,7 +16,7 @@ static DWORD currentTLS = TLS_OUT_OF_INDEXES; -BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) +extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) { switch (reason) { diff --git a/gfx/angle/src/libGLESv2/mathutil.h b/gfx/angle/src/libGLESv2/mathutil.h index 7bb22500fa0d..790ecd89fa75 100644 --- a/gfx/angle/src/libGLESv2/mathutil.h +++ b/gfx/angle/src/libGLESv2/mathutil.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -15,6 +15,17 @@ namespace gl { +struct Vector4 +{ + Vector4() {} + Vector4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {} + + float x; + float y; + float z; + float w; +}; + inline bool isPow2(int x) { return (x & (x - 1)) == 0 && (x != 0); @@ -94,6 +105,41 @@ inline bool supportsSSE2() return supports; } + +inline unsigned short float32ToFloat16(float fp32) +{ + unsigned int fp32i = (unsigned int&)fp32; + unsigned int sign = (fp32i & 0x80000000) >> 16; + unsigned int abs = fp32i & 0x7FFFFFFF; + + if(abs > 0x47FFEFFF) // Infinity + { + return sign | 0x7FFF; + } + else if(abs < 0x38800000) // Denormal + { + unsigned int mantissa = (abs & 0x007FFFFF) | 0x00800000; + int e = 113 - (abs >> 23); + + if(e < 24) + { + abs = mantissa >> e; + } + else + { + abs = 0; + } + + return sign | (abs + 0x00000FFF + ((abs >> 13) & 1)) >> 13; + } + else + { + return sign | (abs + 0xC8000000 + 0x00000FFF + ((abs >> 13) & 1)) >> 13; + } +} + +float float16ToFloat32(unsigned short h); + } #endif // LIBGLESV2_MATHUTIL_H_ diff --git a/gfx/angle/src/libGLESv2/utilities.cpp b/gfx/angle/src/libGLESv2/utilities.cpp index e6f8993ad2d8..a3eb27d39221 100644 --- a/gfx/angle/src/libGLESv2/utilities.cpp +++ b/gfx/angle/src/libGLESv2/utilities.cpp @@ -229,34 +229,32 @@ int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsig return -1; } -GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment) +GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment) { ASSERT(alignment > 0 && isPow2(alignment)); - GLsizei rawPitch = ComputePixelSize(format, type) * width; + GLsizei rawPitch = ComputePixelSize(internalformat) * width; return (rawPitch + alignment - 1) & ~(alignment - 1); } -GLsizei ComputeCompressedPitch(GLsizei width, GLenum format) +GLsizei ComputeCompressedPitch(GLsizei width, GLenum internalformat) { - return ComputeCompressedSize(width, 1, format); + return ComputeCompressedSize(width, 1, internalformat); } -GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format) +GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum internalformat) { - switch (format) + switch (internalformat) { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return 8 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f); - break; + return 8 * ((width + 3) / 4) * ((height + 3) / 4); case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: - return 16 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f); + return 16 * ((width + 3) / 4) * ((height + 3) / 4); default: return 0; } - } bool IsCompressed(GLenum format) @@ -277,7 +275,21 @@ bool IsCompressed(GLenum format) bool IsDepthTexture(GLenum format) { if (format == GL_DEPTH_COMPONENT || - format == GL_DEPTH_STENCIL_OES) + format == GL_DEPTH_STENCIL_OES || + format == GL_DEPTH_COMPONENT16 || + format == GL_DEPTH_COMPONENT32_OES || + format == GL_DEPTH24_STENCIL8_OES) + { + return true; + } + + return false; +} + +bool IsStencilTexture(GLenum format) +{ + if (format == GL_DEPTH_STENCIL_OES || + format == GL_DEPTH24_STENCIL8_OES) { return true; } @@ -286,52 +298,31 @@ bool IsDepthTexture(GLenum format) } // Returns the size, in bytes, of a single texel in an Image -int ComputePixelSize(GLenum format, GLenum type) +int ComputePixelSize(GLint internalformat) { - switch (type) + switch (internalformat) { - case GL_UNSIGNED_BYTE: - switch (format) - { - case GL_ALPHA: return sizeof(unsigned char); - case GL_LUMINANCE: return sizeof(unsigned char); - case GL_LUMINANCE_ALPHA: return sizeof(unsigned char) * 2; - case GL_RGB: return sizeof(unsigned char) * 3; - case GL_RGBA: return sizeof(unsigned char) * 4; - case GL_BGRA_EXT: return sizeof(unsigned char) * 4; - default: UNREACHABLE(); - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT: - return sizeof(unsigned short); - case GL_UNSIGNED_INT: - case GL_UNSIGNED_INT_24_8_OES: - return sizeof(unsigned int); - case GL_FLOAT: - switch (format) - { - case GL_ALPHA: return sizeof(float); - case GL_LUMINANCE: return sizeof(float); - case GL_LUMINANCE_ALPHA: return sizeof(float) * 2; - case GL_RGB: return sizeof(float) * 3; - case GL_RGBA: return sizeof(float) * 4; - default: UNREACHABLE(); - } - break; - case GL_HALF_FLOAT_OES: - switch (format) - { - case GL_ALPHA: return sizeof(unsigned short); - case GL_LUMINANCE: return sizeof(unsigned short); - case GL_LUMINANCE_ALPHA: return sizeof(unsigned short) * 2; - case GL_RGB: return sizeof(unsigned short) * 3; - case GL_RGBA: return sizeof(unsigned short) * 4; - default: UNREACHABLE(); - } - break; + case GL_ALPHA8_EXT: return sizeof(unsigned char); + case GL_LUMINANCE8_EXT: return sizeof(unsigned char); + case GL_ALPHA32F_EXT: return sizeof(float); + case GL_LUMINANCE32F_EXT: return sizeof(float); + case GL_ALPHA16F_EXT: return sizeof(unsigned short); + case GL_LUMINANCE16F_EXT: return sizeof(unsigned short); + case GL_LUMINANCE8_ALPHA8_EXT: return sizeof(unsigned char) * 2; + case GL_LUMINANCE_ALPHA32F_EXT: return sizeof(float) * 2; + case GL_LUMINANCE_ALPHA16F_EXT: return sizeof(unsigned short) * 2; + case GL_RGB8_OES: return sizeof(unsigned char) * 3; + case GL_RGB565: return sizeof(unsigned short); + case GL_RGB32F_EXT: return sizeof(float) * 3; + case GL_RGB16F_EXT: return sizeof(unsigned short) * 3; + case GL_RGBA8_OES: return sizeof(unsigned char) * 4; + case GL_RGBA4: return sizeof(unsigned short); + case GL_RGB5_A1: return sizeof(unsigned short); + case GL_RGBA32F_EXT: return sizeof(float) * 4; + case GL_RGBA16F_EXT: return sizeof(unsigned short) * 4; + case GL_BGRA8_EXT: return sizeof(unsigned char) * 4; + case GL_BGRA4_ANGLEX: return sizeof(unsigned short); + case GL_BGR5_A1_ANGLEX: return sizeof(unsigned short); default: UNREACHABLE(); } @@ -348,6 +339,95 @@ bool IsInternalTextureTarget(GLenum target) return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target); } +GLint ConvertSizedInternalFormat(GLenum format, GLenum type) +{ + switch (format) + { + case GL_ALPHA: + switch (type) + { + case GL_UNSIGNED_BYTE: return GL_ALPHA8_EXT; + case GL_FLOAT: return GL_ALPHA32F_EXT; + case GL_HALF_FLOAT_OES: return GL_ALPHA16F_EXT; + default: UNIMPLEMENTED(); + } + break; + case GL_LUMINANCE: + switch (type) + { + case GL_UNSIGNED_BYTE: return GL_LUMINANCE8_EXT; + case GL_FLOAT: return GL_LUMINANCE32F_EXT; + case GL_HALF_FLOAT_OES: return GL_LUMINANCE16F_EXT; + default: UNIMPLEMENTED(); + } + break; + case GL_LUMINANCE_ALPHA: + switch (type) + { + case GL_UNSIGNED_BYTE: return GL_LUMINANCE8_ALPHA8_EXT; + case GL_FLOAT: return GL_LUMINANCE_ALPHA32F_EXT; + case GL_HALF_FLOAT_OES: return GL_LUMINANCE_ALPHA16F_EXT; + default: UNIMPLEMENTED(); + } + break; + case GL_RGB: + switch (type) + { + case GL_UNSIGNED_BYTE: return GL_RGB8_OES; + case GL_UNSIGNED_SHORT_5_6_5: return GL_RGB565; + case GL_FLOAT: return GL_RGB32F_EXT; + case GL_HALF_FLOAT_OES: return GL_RGB16F_EXT; + default: UNIMPLEMENTED(); + } + break; + case GL_RGBA: + switch (type) + { + case GL_UNSIGNED_BYTE: return GL_RGBA8_OES; + case GL_UNSIGNED_SHORT_4_4_4_4: return GL_RGBA4; + case GL_UNSIGNED_SHORT_5_5_5_1: return GL_RGB5_A1; + case GL_FLOAT: return GL_RGBA32F_EXT; + case GL_HALF_FLOAT_OES: return GL_RGBA16F_EXT; + break; + default: UNIMPLEMENTED(); + } + break; + case GL_BGRA_EXT: + switch (type) + { + case GL_UNSIGNED_BYTE: return GL_BGRA8_EXT; + case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: return GL_BGRA4_ANGLEX; + case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: return GL_BGR5_A1_ANGLEX; + default: UNIMPLEMENTED(); + } + 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 format; + case GL_DEPTH_COMPONENT: + switch (type) + { + case GL_UNSIGNED_SHORT: return GL_DEPTH_COMPONENT16; + case GL_UNSIGNED_INT: return GL_DEPTH_COMPONENT32_OES; + default: UNIMPLEMENTED(); + } + break; + case GL_DEPTH_STENCIL_OES: + switch (type) + { + case GL_UNSIGNED_INT_24_8_OES: return GL_DEPTH24_STENCIL8_OES; + default: UNIMPLEMENTED(); + } + break; + default: + UNIMPLEMENTED(); + } + + return GL_NONE; +} + GLenum ExtractFormat(GLenum internalformat) { switch (internalformat) @@ -479,6 +559,36 @@ bool IsStencilRenderable(GLenum internalformat) return false; } +bool IsFloat32Format(GLint internalformat) +{ + switch (internalformat) + { + case GL_RGBA32F_EXT: + case GL_RGB32F_EXT: + case GL_ALPHA32F_EXT: + case GL_LUMINANCE32F_EXT: + case GL_LUMINANCE_ALPHA32F_EXT: + return true; + default: + return false; + } +} + +bool IsFloat16Format(GLint internalformat) +{ + switch (internalformat) + { + case GL_RGBA16F_EXT: + case GL_RGB16F_EXT: + case GL_ALPHA16F_EXT: + case GL_LUMINANCE16F_EXT: + case GL_LUMINANCE_ALPHA16F_EXT: + return true; + default: + return false; + } +} + } namespace es2dx @@ -911,75 +1021,6 @@ unsigned int GetDepthSize(D3DFORMAT depthFormat) } } -bool IsFloat32Format(D3DFORMAT surfaceFormat) -{ - switch(surfaceFormat) - { - case D3DFMT_R16F: - case D3DFMT_G16R16F: - case D3DFMT_A16B16G16R16F: - return false; - case D3DFMT_R32F: - case D3DFMT_G32R32F: - case D3DFMT_A32B32G32R32F: - return true; - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - case D3DFMT_A1R5G5B5: - case D3DFMT_R5G6B5: - return false; - default: UNREACHABLE(); - } - return false; -} - -bool IsFloat16Format(D3DFORMAT surfaceFormat) -{ - switch(surfaceFormat) - { - case D3DFMT_R16F: - case D3DFMT_G16R16F: - case D3DFMT_A16B16G16R16F: - return true; - case D3DFMT_R32F: - case D3DFMT_G32R32F: - case D3DFMT_A32B32G32R32F: - return false; - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - case D3DFMT_A1R5G5B5: - case D3DFMT_R5G6B5: - return false; - default: UNREACHABLE(); - } - return false; -} - -bool IsDepthTextureFormat(D3DFORMAT surfaceFormat) -{ - return (surfaceFormat == D3DFMT_INTZ); -} - -bool IsStencilTextureFormat(D3DFORMAT surfaceFormat) -{ - return (surfaceFormat == D3DFMT_INTZ); -} - -bool IsCompressedD3DFormat(D3DFORMAT surfaceFormat) -{ - switch(surfaceFormat) - { - case D3DFMT_DXT1: - case D3DFMT_DXT2: - case D3DFMT_DXT3: - case D3DFMT_DXT4: - case D3DFMT_DXT5: - return true; - default: - return false; - } -} - GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type) { if (type == D3DMULTISAMPLE_NONMASKABLE) @@ -988,6 +1029,73 @@ GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type) 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 && gl::IsDepthTexture(format)) + return true; + return false; + } +} + +bool ConvertReadBufferFormat(D3DFORMAT d3dformat, GLenum *format, GLenum *type) +{ + switch (d3dformat) + { + case D3DFMT_A8R8G8B8: + *type = GL_UNSIGNED_BYTE; + *format = GL_BGRA_EXT; + break; + case D3DFMT_X8R8G8B8: + *type = GL_UNSIGNED_BYTE; + *format = GL_RGB; + break; + case D3DFMT_R5G6B5: + *type = GL_UNSIGNED_SHORT_5_6_5; + *format = GL_RGB; + break; + case D3DFMT_A16B16G16R16F: + *type = GL_HALF_FLOAT_OES; + *format = GL_RGBA; + break; + case D3DFMT_A32B32G32R32F: + *type = GL_FLOAT; + *format = GL_RGBA; + break; + case D3DFMT_A4R4G4B4: + *type = GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT; + *format = GL_BGRA_EXT; + break; + case D3DFMT_A1R5G5B5: + *type = GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT; + *format = GL_BGRA_EXT; + break; + default: + *type = GL_NONE; + *format = GL_NONE; + return false; + } + return true; +} + GLenum ConvertBackBufferFormat(D3DFORMAT format) { switch (format) @@ -1026,6 +1134,56 @@ GLenum ConvertDepthStencilFormat(D3DFORMAT format) } +namespace dx +{ + +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; + } +} + +} + std::string getTempPath() { char path[MAX_PATH]; diff --git a/gfx/angle/src/libGLESv2/utilities.h b/gfx/angle/src/libGLESv2/utilities.h index 3357eb092396..eb133de59b61 100644 --- a/gfx/angle/src/libGLESv2/utilities.h +++ b/gfx/angle/src/libGLESv2/utilities.h @@ -34,14 +34,16 @@ int VariableColumnCount(GLenum type); int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize); -int ComputePixelSize(GLenum format, GLenum type); -GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment); +int ComputePixelSize(GLint internalformat); +GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment); GLsizei ComputeCompressedPitch(GLsizei width, GLenum format); GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format); bool IsCompressed(GLenum format); bool IsDepthTexture(GLenum format); +bool IsStencilTexture(GLenum format); bool IsCubemapTextureTarget(GLenum target); bool IsInternalTextureTarget(GLenum target); +GLint ConvertSizedInternalFormat(GLenum format, GLenum type); GLenum ExtractFormat(GLenum internalformat); GLenum ExtractType(GLenum internalformat); @@ -49,6 +51,8 @@ bool IsColorRenderable(GLenum internalformat); bool IsDepthRenderable(GLenum internalformat); bool IsStencilRenderable(GLenum internalformat); +bool IsFloat32Format(GLint internalformat); +bool IsFloat16Format(GLint internalformat); } namespace es2dx @@ -74,25 +78,29 @@ D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples); namespace dx2es { + GLuint GetAlphaSize(D3DFORMAT colorFormat); GLuint GetRedSize(D3DFORMAT colorFormat); GLuint GetGreenSize(D3DFORMAT colorFormat); GLuint GetBlueSize(D3DFORMAT colorFormat); GLuint GetDepthSize(D3DFORMAT depthFormat); GLuint GetStencilSize(D3DFORMAT stencilFormat); -bool IsFloat32Format(D3DFORMAT surfaceFormat); -bool IsFloat16Format(D3DFORMAT surfaceFormat); -bool IsDepthTextureFormat(D3DFORMAT surfaceFormat); -bool IsStencilTextureFormat(D3DFORMAT surfaceFormat); -bool IsCompressedD3DFormat(D3DFORMAT format); GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type); +bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format); +bool ConvertReadBufferFormat(D3DFORMAT d3dformat, GLenum *format, GLenum *type); GLenum ConvertBackBufferFormat(D3DFORMAT format); GLenum ConvertDepthStencilFormat(D3DFORMAT format); } +namespace dx +{ +bool IsCompressedFormat(D3DFORMAT format); +size_t ComputeRowSize(D3DFORMAT format, unsigned int width); +} + std::string getTempPath(); void writeFile(const char* path, const void* data, size_t size); @@ -108,6 +116,6 @@ inline bool isDeviceLostError(HRESULT errorCode) default: return false; } -}; +} #endif // LIBGLESV2_UTILITIES_H diff --git a/gfx/angle/tests/build_tests.gyp b/gfx/angle/tests/build_tests.gyp deleted file mode 100644 index 32391ad55a5d..000000000000 --- a/gfx/angle/tests/build_tests.gyp +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'targets': [ - { - 'target_name': 'gtest', - 'type': 'static_library', - 'include_dirs': [ - '../third_party/googletest', - '../third_party/googletest/include', - ], - 'sources': [ - '../third_party/googletest/src/gtest-all.cc', - ], - }, - { - 'target_name': 'gmock', - 'type': 'static_library', - 'include_dirs': [ - '../third_party/googlemock', - '../third_party/googlemock/include', - '../third_party/googletest/include', - ], - 'sources': [ - '../third_party/googlemock/src/gmock-all.cc', - ], - }, - { - 'target_name': 'preprocessor_tests', - 'type': 'executable', - 'dependencies': [ - '../src/build_angle.gyp:preprocessor', - 'gtest', - 'gmock', - ], - 'include_dirs': [ - '../src/compiler/preprocessor/new', - '../third_party/googletest/include', - '../third_party/googlemock/include', - ], - 'sources': [ - '../third_party/googlemock/src/gmock_main.cc', - 'preprocessor_tests/char_test.cpp', - 'preprocessor_tests/comment_test.cpp', - 'preprocessor_tests/define_test.cpp', - 'preprocessor_tests/error_test.cpp', - 'preprocessor_tests/extension_test.cpp', - 'preprocessor_tests/identifier_test.cpp', - 'preprocessor_tests/if_test.cpp', - 'preprocessor_tests/input_test.cpp', - 'preprocessor_tests/location_test.cpp', - 'preprocessor_tests/MockDiagnostics.h', - 'preprocessor_tests/MockDirectiveHandler.h', - 'preprocessor_tests/number_test.cpp', - 'preprocessor_tests/operator_test.cpp', - 'preprocessor_tests/pragma_test.cpp', - 'preprocessor_tests/PreprocessorTest.cpp', - 'preprocessor_tests/PreprocessorTest.h', - 'preprocessor_tests/space_test.cpp', - 'preprocessor_tests/token_test.cpp', - 'preprocessor_tests/version_test.cpp', - ], - }, - { - 'target_name': 'compiler_tests', - 'type': 'executable', - 'dependencies': [ - '../src/build_angle.gyp:translator_common', - 'gtest', - 'gmock', - ], - 'include_dirs': [ - '../include', - '../src', - '../third_party/googletest/include', - '../third_party/googlemock/include', - ], - 'sources': [ - '../third_party/googlemock/src/gmock_main.cc', - 'compiler_tests/VariablePacker_test.cpp', - ], - }, - ], -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2: diff --git a/gfx/angle/tests/compiler_tests/VariablePacker_test.cpp b/gfx/angle/tests/compiler_tests/VariablePacker_test.cpp deleted file mode 100644 index 6405ea70f75f..000000000000 --- a/gfx/angle/tests/compiler_tests/VariablePacker_test.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// -// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -#include "compiler/VariablePacker.h" -#include "gtest/gtest.h" - -TEST(VariablePacking, Pack) { - VariablePacker packer; - TVariableInfoList vars; - const int kMaxRows = 16; - // test no vars. - EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); - - ShDataType types[] = { - SH_FLOAT_MAT4, // 0 - SH_FLOAT_MAT2, // 1 - SH_FLOAT_VEC4, // 2 - SH_INT_VEC4, // 3 - SH_BOOL_VEC4, // 4 - SH_FLOAT_MAT3, // 5 - SH_FLOAT_VEC3, // 6 - SH_INT_VEC3, // 7 - SH_BOOL_VEC3, // 8 - SH_FLOAT_VEC2, // 9 - SH_INT_VEC2, // 10 - SH_BOOL_VEC2, // 11 - SH_FLOAT, // 12 - SH_INT, // 13 - SH_BOOL, // 14 - SH_SAMPLER_2D, // 15 - SH_SAMPLER_CUBE, // 16 - SH_SAMPLER_EXTERNAL_OES, // 17 - SH_SAMPLER_2D_RECT_ARB, // 18 - }; - - for (size_t tt = 0; tt < sizeof(types) / sizeof(types[0]); ++tt) { - ShDataType type = types[tt]; - int num_rows = VariablePacker::GetNumRows(type); - int num_components_per_row = VariablePacker::GetNumComponentsPerRow(type); - // Check 1 of the type. - vars.clear(); - vars.push_back(TVariableInfo(type, 1)); - EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); - - // Check exactly the right amount of 1 type as an array. - int num_vars = kMaxRows / num_rows; - vars.clear(); - vars.push_back(TVariableInfo(type, num_vars)); - EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); - - // test too many - vars.clear(); - vars.push_back(TVariableInfo(type, num_vars + 1)); - EXPECT_FALSE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); - - // Check exactly the right amount of 1 type as individual vars. - num_vars = kMaxRows / num_rows * - ((num_components_per_row > 2) ? 1 : (4 / num_components_per_row)); - vars.clear(); - for (int ii = 0; ii < num_vars; ++ii) { - vars.push_back(TVariableInfo(type, 1)); - } - EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); - - // Check 1 too many. - vars.push_back(TVariableInfo( type, 1)); - EXPECT_FALSE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); - } - - // Test example from GLSL ES 3.0 spec chapter 11. - vars.clear(); - vars.push_back(TVariableInfo(SH_FLOAT_VEC4, 1)); - vars.push_back(TVariableInfo(SH_FLOAT_MAT3, 1)); - vars.push_back(TVariableInfo(SH_FLOAT_MAT3, 1)); - vars.push_back(TVariableInfo(SH_FLOAT_VEC2, 6)); - vars.push_back(TVariableInfo(SH_FLOAT_VEC2, 4)); - vars.push_back(TVariableInfo(SH_FLOAT_VEC2, 1)); - vars.push_back(TVariableInfo(SH_FLOAT, 3)); - vars.push_back(TVariableInfo(SH_FLOAT, 2)); - vars.push_back(TVariableInfo(SH_FLOAT, 1)); - EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars)); -} - diff --git a/gfx/angle/tests/preprocessor_tests/MockDiagnostics.h b/gfx/angle/tests/preprocessor_tests/MockDiagnostics.h deleted file mode 100644 index 459800317e37..000000000000 --- a/gfx/angle/tests/preprocessor_tests/MockDiagnostics.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#ifndef PREPROCESSOR_TESTS_MOCK_DIAGNOSTICS_H_ -#define PREPROCESSOR_TESTS_MOCK_DIAGNOSTICS_H_ - -#include "gmock/gmock.h" -#include "Diagnostics.h" - -class MockDiagnostics : public pp::Diagnostics -{ - public: - MOCK_METHOD3(print, - void(ID id, const pp::SourceLocation& loc, const std::string& text)); -}; - -#endif // PREPROCESSOR_TESTS_MOCK_DIAGNOSTICS_H_ diff --git a/gfx/angle/tests/preprocessor_tests/MockDirectiveHandler.h b/gfx/angle/tests/preprocessor_tests/MockDirectiveHandler.h deleted file mode 100644 index 68c05e226f7d..000000000000 --- a/gfx/angle/tests/preprocessor_tests/MockDirectiveHandler.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#ifndef PREPROCESSOR_TESTS_MOCK_DIRECTIVE_HANDLER_H_ -#define PREPROCESSOR_TESTS_MOCK_DIRECTIVE_HANDLER_H_ - -#include "gmock/gmock.h" -#include "DirectiveHandler.h" - -class MockDirectiveHandler : public pp::DirectiveHandler -{ - public: - MOCK_METHOD2(handleError, - void(const pp::SourceLocation& loc, const std::string& msg)); - - MOCK_METHOD3(handlePragma, - void(const pp::SourceLocation& loc, - const std::string& name, - const std::string& value)); - - MOCK_METHOD3(handleExtension, - void(const pp::SourceLocation& loc, - const std::string& name, - const std::string& behavior)); - - MOCK_METHOD2(handleVersion, - void(const pp::SourceLocation& loc, int version)); -}; - -#endif // PREPROCESSOR_TESTS_MOCK_DIRECTIVE_HANDLER_H_ diff --git a/gfx/angle/tests/preprocessor_tests/PreprocessorTest.cpp b/gfx/angle/tests/preprocessor_tests/PreprocessorTest.cpp deleted file mode 100644 index 9f90484f4eb3..000000000000 --- a/gfx/angle/tests/preprocessor_tests/PreprocessorTest.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -void PreprocessorTest::preprocess(const char* input, const char* expected) -{ - ASSERT_TRUE(mPreprocessor.init(1, &input, NULL)); - - int line = 1; - pp::Token token; - std::stringstream stream; - do - { - mPreprocessor.lex(&token); - for (; line < token.location.line; ++line) - { - stream << "\n"; - } - stream << token; - } while (token.type != pp::Token::LAST); - - std::string actual = stream.str(); - EXPECT_STREQ(expected, actual.c_str()); -} diff --git a/gfx/angle/tests/preprocessor_tests/PreprocessorTest.h b/gfx/angle/tests/preprocessor_tests/PreprocessorTest.h deleted file mode 100644 index e8184de06b82..000000000000 --- a/gfx/angle/tests/preprocessor_tests/PreprocessorTest.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "gtest/gtest.h" - -#include "MockDiagnostics.h" -#include "MockDirectiveHandler.h" -#include "Preprocessor.h" - -#ifndef PREPROCESSOR_TESTS_PREPROCESSOR_TEST_H_ -#define PREPROCESSOR_TESTS_PREPROCESSOR_TEST_H_ - -class PreprocessorTest : public testing::Test -{ - protected: - PreprocessorTest() : mPreprocessor(&mDiagnostics, &mDirectiveHandler) { } - - // Preprocesses the input string and verifies that it matches - // expected output. - void preprocess(const char* input, const char* expected); - - MockDiagnostics mDiagnostics; - MockDirectiveHandler mDirectiveHandler; - pp::Preprocessor mPreprocessor; -}; - -#endif // PREPROCESSOR_TESTS_PREPROCESSOR_TEST_H_ diff --git a/gfx/angle/tests/preprocessor_tests/char_test.cpp b/gfx/angle/tests/preprocessor_tests/char_test.cpp deleted file mode 100644 index e6576a0b13ae..000000000000 --- a/gfx/angle/tests/preprocessor_tests/char_test.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include -#include - -#include "PreprocessorTest.h" -#include "Token.h" - -class CharTest : public PreprocessorTest, - public testing::WithParamInterface -{ -}; - -static const char kPunctuators[] = { - '.', '+', '-', '/', '*', '%', '<', '>', '[', ']', '(', ')', '{', '}', - '^', '|', '&', '~', '=', '!', ':', ';', ',', '?'}; -static const int kNumPunctuators = - sizeof(kPunctuators) / sizeof(kPunctuators[0]); - -bool isPunctuator(char c) -{ - static const char* kPunctuatorBeg = kPunctuators; - static const char* kPunctuatorEnd = kPunctuators + kNumPunctuators; - return std::find(kPunctuatorBeg, kPunctuatorEnd, c) != kPunctuatorEnd; -} - -static const char kWhitespaces[] = {' ', '\t', '\v', '\f', '\n', '\r'}; -static const int kNumWhitespaces = - sizeof(kWhitespaces) / sizeof(kWhitespaces[0]); - -bool isWhitespace(char c) -{ - static const char* kWhitespaceBeg = kWhitespaces; - static const char* kWhitespaceEnd = kWhitespaces + kNumWhitespaces; - return std::find(kWhitespaceBeg, kWhitespaceEnd, c) != kWhitespaceEnd; -} - -TEST_P(CharTest, Identified) -{ - std::string str(1, GetParam()); - const char* cstr = str.c_str(); - int length = 1; - - // Note that we pass the length param as well because the invalid - // string may contain the null character. - ASSERT_TRUE(mPreprocessor.init(1, &cstr, &length)); - - int expectedType = pp::Token::LAST; - std::string expectedValue; - - if (str[0] == '#') - { - // Lone '#' is ignored. - } - else if ((str[0] == '_') || - ((str[0] >= 'a') && (str[0] <= 'z')) || - ((str[0] >= 'A') && (str[0] <= 'Z'))) - { - expectedType = pp::Token::IDENTIFIER; - expectedValue = str; - } - else if (str[0] >= '0' && str[0] <= '9') - { - expectedType = pp::Token::CONST_INT; - expectedValue = str; - } - else if (isPunctuator(str[0])) - { - expectedType = str[0]; - expectedValue = str; - } - else if (isWhitespace(str[0])) - { - // Whitespace is ignored. - } - else - { - // Everything else is invalid. - using testing::_; - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INVALID_CHARACTER, _, str)); - } - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(expectedType, token.type); - EXPECT_EQ(expectedValue, token.text); -}; - -// Note +1 for the max-value in range. It is there because the max-value -// not included in the range. -INSTANTIATE_TEST_CASE_P(All, CharTest, - testing::Range(CHAR_MIN, CHAR_MAX + 1)); - diff --git a/gfx/angle/tests/preprocessor_tests/comment_test.cpp b/gfx/angle/tests/preprocessor_tests/comment_test.cpp deleted file mode 100644 index 27f78cf17a73..000000000000 --- a/gfx/angle/tests/preprocessor_tests/comment_test.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -class CommentTest : public PreprocessorTest, - public testing::WithParamInterface -{ -}; - -TEST_P(CommentTest, CommentIgnored) -{ - const char* str = GetParam(); - - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::LAST, token.type); -} - -INSTANTIATE_TEST_CASE_P(LineComment, CommentTest, - testing::Values("//foo\n", // With newline. - "//foo", // Without newline. - "//**/", // Nested block comment. - "////", // Nested line comment. - "//\"")); // Invalid character. - -INSTANTIATE_TEST_CASE_P(BlockComment, CommentTest, - testing::Values("/*foo*/", - "/*foo\n*/", // With newline. - "/*//*/", // Nested line comment. - "/*/**/", // Nested block comment. - "/***/", // With lone '*'. - "/*\"*/")); // Invalid character. - -class BlockCommentTest : public PreprocessorTest -{ -}; - -TEST_F(BlockCommentTest, CommentReplacedWithSpace) -{ - const char* str = "/*foo*/bar"; - - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::IDENTIFIER, token.type); - EXPECT_EQ("bar", token.text); - EXPECT_TRUE(token.hasLeadingSpace()); -} - -TEST_F(BlockCommentTest, UnterminatedComment) -{ - const char* str = "/*foo"; - - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - using testing::_; - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_COMMENT, _, _)); - - pp::Token token; - mPreprocessor.lex(&token); -} diff --git a/gfx/angle/tests/preprocessor_tests/define_test.cpp b/gfx/angle/tests/preprocessor_tests/define_test.cpp deleted file mode 100644 index bb72016ba950..000000000000 --- a/gfx/angle/tests/preprocessor_tests/define_test.cpp +++ /dev/null @@ -1,893 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -class DefineTest : public PreprocessorTest -{ -}; - -TEST_F(DefineTest, NonIdentifier) -{ - const char* input = "#define 2 foo\n" - "2\n"; - const char* expected = "\n" - "2\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::UNEXPECTED_TOKEN, - pp::SourceLocation(0, 1), - "2")); - - preprocess(input, expected); -}; - -TEST_F(DefineTest, RedefinePredefined) -{ - const char* input = "#define __LINE__ 10\n" - "__LINE__\n" - "#define __FILE__ 20\n" - "__FILE__\n" - "#define __VERSION__ 200\n" - "__VERSION__\n" - "#define GL_ES 0\n" - "GL_ES\n"; - const char* expected = "\n" - "2\n" - "\n" - "0\n" - "\n" - "100\n" - "\n" - "1\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_REDEFINED, - pp::SourceLocation(0, 1), - "__LINE__")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_REDEFINED, - pp::SourceLocation(0, 3), - "__FILE__")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_REDEFINED, - pp::SourceLocation(0, 5), - "__VERSION__")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_REDEFINED, - pp::SourceLocation(0, 7), - "GL_ES")); - - preprocess(input, expected); -} - -TEST_F(DefineTest, ReservedUnderScore1) -{ - const char* input = "#define __foo bar\n" - "__foo\n"; - const char* expected = "\n" - "__foo\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_NAME_RESERVED, - pp::SourceLocation(0, 1), - "__foo")); - - preprocess(input, expected); -} - -TEST_F(DefineTest, ReservedUnderScore2) -{ - const char* input = "#define foo__bar baz\n" - "foo__bar\n"; - const char* expected = "\n" - "foo__bar\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_NAME_RESERVED, - pp::SourceLocation(0, 1), - "foo__bar")); - - preprocess(input, expected); -} - -TEST_F(DefineTest, ReservedGL) -{ - const char* input = "#define GL_foo bar\n" - "GL_foo\n"; - const char* expected = "\n" - "GL_foo\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_NAME_RESERVED, - pp::SourceLocation(0, 1), - "GL_foo")); - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjRedefineValid) -{ - const char* input = "#define foo (1-1)\n" - "#define foo /* whitespace */ (1-1) /* other */ \n" - "foo\n"; - const char* expected = "\n" - "\n" - "(1-1)\n"; - // No error or warning. - using testing::_; - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjRedefineInvalid) -{ - const char* input = "#define foo (0)\n" - "#define foo (1-1)\n" - "foo\n"; - const char* expected = "\n" - "\n" - "(0)\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_REDEFINED, - pp::SourceLocation(0, 2), - "foo")); - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncRedefineValid) -{ - const char* input = "#define foo(a) ( a )\n" - "#define foo( a )( /* whitespace */ a /* other */ )\n" - "foo(b)\n"; - const char* expected = "\n" - "\n" - "( b )\n"; - // No error or warning. - using testing::_; - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncRedefineInvalid) -{ - const char* input = "#define foo(b) ( a )\n" - "#define foo(b) ( b )\n" - "foo(1)\n"; - const char* expected = "\n" - "\n" - "( a )\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_REDEFINED, - pp::SourceLocation(0, 2), - "foo")); - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjBasic) -{ - const char* input = "#define foo 1\n" - "foo\n"; - const char* expected = "\n" - "1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjEmpty) -{ - const char* input = "#define foo\n" - "foo\n"; - const char* expected = "\n" - "\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjChain) -{ - const char* input = "#define foo 1\n" - "#define bar foo\n" - "bar\n"; - const char* expected = "\n" - "\n" - "1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjChainReverse) -{ - const char* input = "#define bar foo\n" - "#define foo 1\n" - "bar\n"; - const char* expected = "\n" - "\n" - "1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjRecursive) -{ - const char* input = "#define foo bar\n" - "#define bar baz\n" - "#define baz foo\n" - "foo\n" - "bar\n" - "baz\n"; - const char* expected = "\n" - "\n" - "\n" - "foo\n" - "bar\n" - "baz\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjCompositeChain) -{ - const char* input = "#define foo 1\n" - "#define bar a foo\n" - "bar\n"; - const char* expected = "\n" - "\n" - "a 1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjCompositeChainReverse) -{ - const char* input = "#define bar a foo\n" - "#define foo 1\n" - "bar\n"; - const char* expected = "\n" - "\n" - "a 1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjCompositeRecursive) -{ - const char* input = "#define foo a bar\n" - "#define bar b baz\n" - "#define baz c foo\n" - "foo\n" - "bar\n" - "baz\n"; - const char* expected = "\n" - "\n" - "\n" - "a b c foo\n" - "b c a bar\n" - "c a b baz\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjChainSelfRecursive) -{ - const char* input = "#define foo foo\n" - "#define bar foo\n" - "bar\n"; - const char* expected = "\n" - "\n" - "foo\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjectLikeWithParens) -{ - const char* input = "#define foo ()1\n" - "foo()\n" - "#define bar ()2\n" - "bar()\n"; - const char* expected = "\n" - "()1()\n" - "\n" - "()2()\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncEmpty) -{ - const char* input = "#define foo()\n" - "foo()\n"; - const char* expected = "\n" - "\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncNoArgs) -{ - const char* input = "#define foo() bar\n" - "foo()\n"; - const char* expected = "\n" - "bar\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncOneArgUnused) -{ - const char* input = "#define foo(x) 1\n" - "foo(bar)\n"; - const char* expected = "\n" - "1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncTwoArgsUnused) -{ - const char* input = "#define foo(x,y) 1\n" - "foo(bar,baz)\n"; - const char* expected = "\n" - "1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncOneArg) -{ - const char* input = "#define foo(x) ((x)+1)\n" - "foo(bar)\n"; - const char* expected = "\n" - "((bar)+1)\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncTwoArgs) -{ - const char* input = "#define foo(x,y) ((x)*(y))\n" - "foo(bar,baz)\n"; - const char* expected = "\n" - "((bar)*(baz))\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncEmptyArgs) -{ - const char* input = "#define zero() pass\n" - "#define one(x) pass\n" - "#define two(x,y) pass\n" - "zero()\n" - "one()\n" - "two(,)\n"; - const char* expected = "\n" - "\n" - "\n" - "pass\n" - "pass\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncMacroAsParam) -{ - const char* input = "#define x 0\n" - "#define foo(x) x\n" - "foo(1)\n"; - const char* expected = "\n" - "\n" - "1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncOneArgMulti) -{ - const char* input = "#define foo(x) (x)\n" - "foo(this is a multi-word argument)\n"; - const char* expected = "\n" - "(this is a multi-word argument)\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncTwoArgsMulti) -{ - const char* input = "#define foo(x,y) x,two fish,red fish,y\n" - "foo(one fish, blue fish)\n"; - const char* expected = "\n" - "one fish,two fish,red fish,blue fish\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncCompose) -{ - const char* input = "#define bar(x) (1+(x))\n" - "#define foo(y) (2*(y))\n" - "foo(bar(3))\n"; - const char* expected = "\n" - "\n" - "(2*((1+(3))))\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncArgWithParens) -{ - const char* input = "#define foo(x) (x)\n" - "foo(argument(with parens) FTW)\n"; - const char* expected = "\n" - "(argument(with parens) FTW)\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncMacroAsNonMacro) -{ - const char* input = "#define foo(bar) bar\n" - "foo bar\n"; - const char* expected = "\n" - "foo bar\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncExtraNewlines) -{ - const char* input = "#define foo(a) (a)\n" - "foo\n" - "(\n" - "1\n" - ")\n"; - const char* expected = "\n" - "(1)\n" - "\n" - "\n" - "\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ChainObjToFunc) -{ - const char* input = "#define foo() pass\n" - "#define bar foo()\n" - "bar\n"; - const char* expected = "\n" - "\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ChainObjToNonFunc) -{ - const char* input = "#define pass() fail\n" - "#define bar pass\n" - "bar\n"; - const char* expected = "\n" - "\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ChainObjToFuncWithArgs) -{ - const char* input = "#define foo(fail) fail\n" - "#define bar foo(pass)\n" - "bar\n"; - const char* expected = "\n" - "\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ChainObjToFuncCompose) -{ - const char* input = "#define baz(fail) fail\n" - "#define bar(fail) fail\n" - "#define foo bar(baz(pass))\n" - "foo\n"; - const char* expected = "\n" - "\n" - "\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ChainObjToFuncParensInText1) -{ - const char* input = "#define fail() pass\n" - "#define foo fail\n" - "foo()\n"; - const char* expected = "\n" - "\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ChainObjToFuncParensInText2) -{ - const char* input = "#define bar with,embedded,commas\n" - "#define func(x) pass\n" - "#define foo func\n" - "foo(bar)\n"; - const char* expected = "\n" - "\n" - "\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ChainObjToFuncMultiLevel) -{ - const char* input = "#define foo(x) pass\n" - "#define bar foo\n" - "#define baz bar\n" - "#define joe baz\n" - "joe (fail)\n"; - const char* expected = "\n" - "\n" - "\n" - "\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ObjToFuncRecursive) -{ - const char* input = "#define A(a,b) B(a,b)\n" - "#define C A(0,C)\n" - "C\n"; - const char* expected = "\n" - "\n" - "B(0,C)\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, ChainFuncToFuncCompose) -{ - const char* input = "#define baz(fail) fail\n" - "#define bar(fail) fail\n" - "#define foo() bar(baz(pass))\n" - "foo()\n"; - const char* expected = "\n" - "\n" - "\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncSelfRecursive) -{ - const char* input = "#define foo(a) foo(2*(a))\n" - "foo(3)\n"; - const char* expected = "\n" - "foo(2*(3))\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncSelfCompose) -{ - const char* input = "#define foo(a) foo(2*(a))\n" - "foo(foo(3))\n"; - const char* expected = "\n" - "foo(2*(foo(2*(3))))\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncSelfComposeNonFunc) -{ - const char* input = "#define foo(bar) bar\n" - "foo(foo)\n"; - const char* expected = "\n" - "foo\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncSelfComposeNonFuncMultiTokenArg) -{ - const char* input = "#define foo(bar) bar\n" - "foo(1+foo)\n"; - const char* expected = "\n" - "1+foo\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FinalizeUnexpandedMacro) -{ - const char* input = "#define expand(x) expand(x once)\n" - "#define foo(x) x\n" - "foo(expand(just))\n"; - const char* expected = "\n" - "\n" - "expand(just once)\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncArgWithCommas) -{ - const char* input = "#define foo(x) pass\n" - "foo(argument (with,embedded, commas) -- baz)\n"; - const char* expected = "\n" - "pass\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncArgObjMaroWithComma) -{ - const char* input = "#define foo(a) (a)\n" - "#define bar two,words\n" - "foo(bar)\n"; - const char* expected = "\n" - "\n" - "(two,words)\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncLeftParenInMacroRightParenInText) -{ - const char* input = "#define bar(a) a*2\n" - "#define foo bar(\n" - "foo b)\n"; - const char* expected = "\n" - "\n" - "b*2\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, RepeatedArg) -{ - const char* input = "#define double(x) x x\n" - "double(1)\n"; - const char* expected = "\n" - "1 1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncMissingRightParen) -{ - const char* input = "#define foo(x) (2*(x))\n" - "foo(3\n"; - const char* expected = "\n" - "\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_UNTERMINATED_INVOCATION, - pp::SourceLocation(0, 2), - "foo")); - - preprocess(input, expected); -} - -TEST_F(DefineTest, FuncIncorrectArgCount) -{ - const char* input = "#define foo(x,y) ((x)+(y))\n" - "foo()\n" - "foo(1)\n" - "foo(1,2,3)\n"; - const char* expected = "\n" - "\n" - "\n" - "\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_TOO_FEW_ARGS, - pp::SourceLocation(0, 2), - "foo")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_TOO_FEW_ARGS, - pp::SourceLocation(0, 3), - "foo")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_TOO_MANY_ARGS, - pp::SourceLocation(0, 4), - "foo")); - - preprocess(input, expected); -} - -TEST_F(DefineTest, Undef) -{ - const char* input = "#define foo 1\n" - "foo\n" - "#undef foo\n" - "foo\n"; - const char* expected = "\n" - "1\n" - "\n" - "foo\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, UndefPredefined) -{ - const char* input = "#undef __LINE__\n" - "__LINE__\n" - "#undef __FILE__\n" - "__FILE__\n" - "#undef __VERSION__\n" - "__VERSION__\n" - "#undef GL_ES\n" - "GL_ES\n"; - const char* expected = "\n" - "2\n" - "\n" - "0\n" - "\n" - "100\n" - "\n" - "1\n"; - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_UNDEFINED, - pp::SourceLocation(0, 1), - "__LINE__")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_UNDEFINED, - pp::SourceLocation(0, 3), - "__FILE__")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_UNDEFINED, - pp::SourceLocation(0, 5), - "__VERSION__")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_UNDEFINED, - pp::SourceLocation(0, 7), - "GL_ES")); - - preprocess(input, expected); -} - -TEST_F(DefineTest, UndefRedefine) -{ - const char* input = "#define foo 1\n" - "foo\n" - "#undef foo\n" - "foo\n" - "#define foo 2\n" - "foo\n"; - const char* expected = "\n" - "1\n" - "\n" - "foo\n" - "\n" - "2\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, C99Example) -{ - const char* input = - "#define x 3 \n" - "#define f(a) f(x * (a)) \n" - "#undef x \n" - "#define x 2 \n" - "#define g f \n" - "#define z z[0] \n" - "#define h g(~ \n" - "#define m(a) a(w) \n" - "#define w 0,1 \n" - "#define t(a) a \n" - "#define p() int \n" - "#define q(x) x \n" - " \n" - "f(y+1) + f(f(z)) % t(t(g)(0) + t)(1);\n" - "g(x+(3,4)-w) | h 5) & m\n" - " (f)^m(m);\n" - "p() i[q()] = { q(1), 23, 4, 5, };\n"; - const char* expected = - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);\n" - "f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))\n" - "^m(0,1);\n" - "int i[] = { 1, 23, 4, 5, };\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, Predefined_GL_ES) -{ - const char* input = "GL_ES\n"; - const char* expected = "1\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, Predefined_VERSION) -{ - const char* input = "__VERSION__\n"; - const char* expected = "100\n"; - - preprocess(input, expected); -} - -TEST_F(DefineTest, Predefined_LINE1) -{ - const char* str = "\n\n__LINE__"; - ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::CONST_INT, token.type); - EXPECT_EQ("3", token.text); -} - -TEST_F(DefineTest, Predefined_LINE2) -{ - const char* str = "#line 10\n" - "__LINE__\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::CONST_INT, token.type); - EXPECT_EQ("10", token.text); -} - -TEST_F(DefineTest, Predefined_FILE1) -{ - const char* const str[] = {"", "", "__FILE__"}; - ASSERT_TRUE(mPreprocessor.init(3, str, NULL)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::CONST_INT, token.type); - EXPECT_EQ("2", token.text); -} - -TEST_F(DefineTest, Predefined_FILE2) -{ - const char* const str[] = {"#line 10 20\n", "__FILE__"}; - ASSERT_TRUE(mPreprocessor.init(2, str, NULL)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::CONST_INT, token.type); - EXPECT_EQ("21", token.text); -} diff --git a/gfx/angle/tests/preprocessor_tests/error_test.cpp b/gfx/angle/tests/preprocessor_tests/error_test.cpp deleted file mode 100644 index c9e0c40fea76..000000000000 --- a/gfx/angle/tests/preprocessor_tests/error_test.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -class ErrorTest : public PreprocessorTest -{ -}; - -TEST_F(ErrorTest, Empty) -{ - const char* str = "#error\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, handleError(pp::SourceLocation(0, 1), "")); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(ErrorTest, OneTokenMessage) -{ - const char* str = "#error foo\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handleError(pp::SourceLocation(0, 1), " foo")); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(ErrorTest, TwoTokenMessage) -{ - const char* str = "#error foo bar\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handleError(pp::SourceLocation(0, 1), " foo bar")); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(ErrorTest, Comments) -{ - const char* str = "/*foo*/" - "#" - "/*foo*/" - "error" - "/*foo*/" - "foo" - "/*foo*/" - "bar" - "/*foo*/" - "//foo" - "\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handleError(pp::SourceLocation(0, 1), " foo bar")); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(ErrorTest, MissingNewline) -{ - const char* str = "#error foo"; - const char* expected = ""; - - using testing::_; - // Directive successfully parsed. - EXPECT_CALL(mDirectiveHandler, - handleError(pp::SourceLocation(0, 1), " foo")); - // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); - - preprocess(str, expected); -} diff --git a/gfx/angle/tests/preprocessor_tests/extension_test.cpp b/gfx/angle/tests/preprocessor_tests/extension_test.cpp deleted file mode 100644 index 94b7eb70dabe..000000000000 --- a/gfx/angle/tests/preprocessor_tests/extension_test.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -class ExtensionTest : public PreprocessorTest -{ -}; - -TEST_F(ExtensionTest, Valid) -{ - const char* str = "#extension foo : bar\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handleExtension(pp::SourceLocation(0, 1), "foo", "bar")); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(ExtensionTest, Comments) -{ - const char* str = "/*foo*/" - "#" - "/*foo*/" - "extension" - "/*foo*/" - "foo" - "/*foo*/" - ":" - "/*foo*/" - "bar" - "/*foo*/" - "//foo" - "\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handleExtension(pp::SourceLocation(0, 1), "foo", "bar")); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(ExtensionTest, MissingNewline) -{ - const char* str = "#extension foo : bar"; - const char* expected = ""; - - using testing::_; - // Directive successfully parsed. - EXPECT_CALL(mDirectiveHandler, - handleExtension(pp::SourceLocation(0, 1), "foo", "bar")); - // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); - - preprocess(str, expected); -} - -struct ExtensionTestParam -{ - const char* str; - pp::Diagnostics::ID id; -}; - -using testing::WithParamInterface; -class InvalidExtensionTest : public ExtensionTest, - public WithParamInterface -{ -}; - -TEST_P(InvalidExtensionTest, Identified) -{ - ExtensionTestParam param = GetParam(); - const char* expected = "\n"; - - using testing::_; - // No handleExtension call. - EXPECT_CALL(mDirectiveHandler, handleExtension(_, _, _)).Times(0); - // Invalid extension directive call. - EXPECT_CALL(mDiagnostics, print(param.id, pp::SourceLocation(0, 1), _)); - - preprocess(param.str, expected); -} - -static const ExtensionTestParam kParams[] = { - {"#extension\n", pp::Diagnostics::INVALID_EXTENSION_DIRECTIVE}, - {"#extension 1\n", pp::Diagnostics::INVALID_EXTENSION_NAME}, - {"#extension foo bar\n", pp::Diagnostics::UNEXPECTED_TOKEN}, - {"#extension foo : \n", pp::Diagnostics::INVALID_EXTENSION_DIRECTIVE}, - {"#extension foo : 1\n", pp::Diagnostics::INVALID_EXTENSION_BEHAVIOR}, - {"#extension foo : bar baz\n", pp::Diagnostics::UNEXPECTED_TOKEN} -}; -INSTANTIATE_TEST_CASE_P(All, InvalidExtensionTest, testing::ValuesIn(kParams)); diff --git a/gfx/angle/tests/preprocessor_tests/identifier_test.cpp b/gfx/angle/tests/preprocessor_tests/identifier_test.cpp deleted file mode 100644 index f2653b8cf408..000000000000 --- a/gfx/angle/tests/preprocessor_tests/identifier_test.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -#define CLOSED_RANGE(x, y) testing::Range(x, static_cast((y) + 1)) - -class IdentifierTest : public PreprocessorTest -{ -protected: - void expectIdentifier(const std::string& str) - { - const char* cstr = str.c_str(); - ASSERT_TRUE(mPreprocessor.init(1, &cstr, 0)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::IDENTIFIER, token.type); - EXPECT_EQ(str, token.text); - } -}; - -class SingleLetterIdentifierTest : public IdentifierTest, - public testing::WithParamInterface -{ -}; - -// This test covers identifier names of form [_a-zA-Z]. -TEST_P(SingleLetterIdentifierTest, Identified) -{ - std::string str(1, GetParam()); - expectIdentifier(str); -} - -// Test string: '_' -INSTANTIATE_TEST_CASE_P(Underscore, - SingleLetterIdentifierTest, - testing::Values('_')); - -// Test string: [a-z] -INSTANTIATE_TEST_CASE_P(a_z, - SingleLetterIdentifierTest, - CLOSED_RANGE('a', 'z')); - -// Test string: [A-Z] -INSTANTIATE_TEST_CASE_P(A_Z, - SingleLetterIdentifierTest, - CLOSED_RANGE('A', 'Z')); - -typedef std::tr1::tuple IdentifierParams; -class DoubleLetterIdentifierTest : - public IdentifierTest, - public testing::WithParamInterface -{ -}; - -// This test covers identifier names of form [_a-zA-Z][_a-zA-Z0-9]. -TEST_P(DoubleLetterIdentifierTest, Identified) -{ - std::string str; - str.push_back(std::tr1::get<0>(GetParam())); - str.push_back(std::tr1::get<1>(GetParam())); - - expectIdentifier(str); -} - -// Test string: "__" -INSTANTIATE_TEST_CASE_P(Underscore_Underscore, - DoubleLetterIdentifierTest, - testing::Combine(testing::Values('_'), - testing::Values('_'))); - -// Test string: "_"[a-z] -INSTANTIATE_TEST_CASE_P(Underscore_a_z, - DoubleLetterIdentifierTest, - testing::Combine(testing::Values('_'), - CLOSED_RANGE('a', 'z'))); - -// Test string: "_"[A-Z] -INSTANTIATE_TEST_CASE_P(Underscore_A_Z, - DoubleLetterIdentifierTest, - testing::Combine(testing::Values('_'), - CLOSED_RANGE('A', 'Z'))); - -// Test string: "_"[0-9] -INSTANTIATE_TEST_CASE_P(Underscore_0_9, - DoubleLetterIdentifierTest, - testing::Combine(testing::Values('_'), - CLOSED_RANGE('0', '9'))); - -// Test string: [a-z]"_" -INSTANTIATE_TEST_CASE_P(a_z_Underscore, - DoubleLetterIdentifierTest, - testing::Combine(CLOSED_RANGE('a', 'z'), - testing::Values('_'))); - -// Test string: [a-z][a-z] -INSTANTIATE_TEST_CASE_P(a_z_a_z, - DoubleLetterIdentifierTest, - testing::Combine(CLOSED_RANGE('a', 'z'), - CLOSED_RANGE('a', 'z'))); - -// Test string: [a-z][A-Z] -INSTANTIATE_TEST_CASE_P(a_z_A_Z, - DoubleLetterIdentifierTest, - testing::Combine(CLOSED_RANGE('a', 'z'), - CLOSED_RANGE('A', 'Z'))); - -// Test string: [a-z][0-9] -INSTANTIATE_TEST_CASE_P(a_z_0_9, - DoubleLetterIdentifierTest, - testing::Combine(CLOSED_RANGE('a', 'z'), - CLOSED_RANGE('0', '9'))); - -// Test string: [A-Z]"_" -INSTANTIATE_TEST_CASE_P(A_Z_Underscore, - DoubleLetterIdentifierTest, - testing::Combine(CLOSED_RANGE('A', 'Z'), - testing::Values('_'))); - -// Test string: [A-Z][a-z] -INSTANTIATE_TEST_CASE_P(A_Z_a_z, - DoubleLetterIdentifierTest, - testing::Combine(CLOSED_RANGE('A', 'Z'), - CLOSED_RANGE('a', 'z'))); - -// Test string: [A-Z][A-Z] -INSTANTIATE_TEST_CASE_P(A_Z_A_Z, - DoubleLetterIdentifierTest, - testing::Combine(CLOSED_RANGE('A', 'Z'), - CLOSED_RANGE('A', 'Z'))); - -// Test string: [A-Z][0-9] -INSTANTIATE_TEST_CASE_P(A_Z_0_9, - DoubleLetterIdentifierTest, - testing::Combine(CLOSED_RANGE('A', 'Z'), - CLOSED_RANGE('0', '9'))); - -// The tests above cover one-letter and various combinations of two-letter -// identifier names. This test covers all characters in a single string. -TEST_F(IdentifierTest, AllLetters) -{ - std::string str; - for (int c = 'a'; c <= 'z'; ++c) - str.push_back(c); - - str.push_back('_'); - - for (int c = 'A'; c <= 'Z'; ++c) - str.push_back(c); - - str.push_back('_'); - - for (int c = '0'; c <= '9'; ++c) - str.push_back(c); - - expectIdentifier(str); -} diff --git a/gfx/angle/tests/preprocessor_tests/if_test.cpp b/gfx/angle/tests/preprocessor_tests/if_test.cpp deleted file mode 100644 index 7a7548ffddb9..000000000000 --- a/gfx/angle/tests/preprocessor_tests/if_test.cpp +++ /dev/null @@ -1,835 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -class IfTest : public PreprocessorTest -{ -}; - -TEST_F(IfTest, If_0) -{ - const char* str = "pass_1\n" - "#if 0\n" - "fail\n" - "#endif\n" - "pass_2\n"; - const char* expected = "pass_1\n" - "\n" - "\n" - "\n" - "pass_2\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, If_1) -{ - const char* str = "pass_1\n" - "#if 1\n" - "pass_2\n" - "#endif\n" - "pass_3\n"; - const char* expected = "pass_1\n" - "\n" - "pass_2\n" - "\n" - "pass_3\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, If_0_Else) -{ - const char* str = "pass_1\n" - "#if 0\n" - "fail\n" - "#else\n" - "pass_2\n" - "#endif\n" - "pass_3\n"; - const char* expected = "pass_1\n" - "\n" - "\n" - "\n" - "pass_2\n" - "\n" - "pass_3\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, If_1_Else) -{ - const char* str = "pass_1\n" - "#if 1\n" - "pass_2\n" - "#else\n" - "fail\n" - "#endif\n" - "pass_3\n"; - const char* expected = "pass_1\n" - "\n" - "pass_2\n" - "\n" - "\n" - "\n" - "pass_3\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, If_0_Elif) -{ - const char* str = "pass_1\n" - "#if 0\n" - "fail_1\n" - "#elif 0\n" - "fail_2\n" - "#elif 1\n" - "pass_2\n" - "#elif 1\n" - "fail_3\n" - "#else\n" - "fail_4\n" - "#endif\n" - "pass_3\n"; - const char* expected = "pass_1\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "pass_2\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "pass_3\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, If_1_Elif) -{ - const char* str = "pass_1\n" - "#if 1\n" - "pass_2\n" - "#elif 0\n" - "fail_1\n" - "#elif 1\n" - "fail_2\n" - "#else\n" - "fail_4\n" - "#endif\n" - "pass_3\n"; - const char* expected = "pass_1\n" - "\n" - "pass_2\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "pass_3\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, If_Elif_Else) -{ - const char* str = "pass_1\n" - "#if 0\n" - "fail_1\n" - "#elif 0\n" - "fail_2\n" - "#elif 0\n" - "fail_3\n" - "#else\n" - "pass_2\n" - "#endif\n" - "pass_3\n"; - const char* expected = "pass_1\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "pass_2\n" - "\n" - "pass_3\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, If_0_Nested) -{ - const char* str = "pass_1\n" - "#if 0\n" - "fail_1\n" - "#if 1\n" - "fail_2\n" - "#else\n" - "fail_3\n" - "#endif\n" - "#else\n" - "pass_2\n" - "#endif\n" - "pass_3\n"; - const char* expected = "pass_1\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "pass_2\n" - "\n" - "pass_3\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, If_1_Nested) -{ - const char* str = "pass_1\n" - "#if 1\n" - "pass_2\n" - "#if 1\n" - "pass_3\n" - "#else\n" - "fail_1\n" - "#endif\n" - "#else\n" - "fail_2\n" - "#endif\n" - "pass_4\n"; - const char* expected = "pass_1\n" - "\n" - "pass_2\n" - "\n" - "pass_3\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "pass_4\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorPrecedence) -{ - const char* str = "#if 1 + 2 * 3 + - (26 % 17 - + 4 / 2)\n" - "fail_1\n" - "#else\n" - "pass_1\n" - "#endif\n"; - const char* expected = "\n" - "\n" - "\n" - "pass_1\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorDefined) -{ - const char* str = "#if defined foo\n" - "fail_1\n" - "#else\n" - "pass_1\n" - "#endif\n" - "#define foo\n" - "#if defined(foo)\n" - "pass_2\n" - "#else\n" - "fail_2\n" - "#endif\n" - "#undef foo\n" - "#if defined ( foo ) \n" - "fail_3\n" - "#else\n" - "pass_3\n" - "#endif\n"; - const char* expected = "\n" - "\n" - "\n" - "pass_1\n" - "\n" - "\n" - "\n" - "pass_2\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "pass_3\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorEQ) -{ - const char* str = "#if 4 - 1 == 2 + 1\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorNE) -{ - const char* str = "#if 1 != 2\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorLess) -{ - const char* str = "#if 1 < 2\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorGreater) -{ - const char* str = "#if 2 > 1\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorLE) -{ - const char* str = "#if 1 <= 2\n" - "pass_1\n" - "#else\n" - "fail_1\n" - "#endif\n" - "#if 2 <= 2\n" - "pass_2\n" - "#else\n" - "fail_2\n" - "#endif\n"; - const char* expected = "\n" - "pass_1\n" - "\n" - "\n" - "\n" - "\n" - "pass_2\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorGE) -{ - const char* str = "#if 2 >= 1\n" - "pass_1\n" - "#else\n" - "fail_1\n" - "#endif\n" - "#if 2 >= 2\n" - "pass_2\n" - "#else\n" - "fail_2\n" - "#endif\n"; - const char* expected = "\n" - "pass_1\n" - "\n" - "\n" - "\n" - "\n" - "pass_2\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorBitwiseOR) -{ - const char* str = "#if (0xaaaaaaaa | 0x55555555) == 0xffffffff\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorBitwiseAND) -{ - const char* str = "#if (0xaaaaaaa & 0x5555555) == 0\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorBitwiseXOR) -{ - const char* str = "#if (0xaaaaaaa ^ 0x5555555) == 0xfffffff\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorBitwiseComplement) -{ - const char* str = "#if (~ 0xdeadbeef) == -3735928560\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorLeft) -{ - const char* str = "#if (1 << 12) == 4096\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, OperatorRight) -{ - const char* str = "#if (31762 >> 8) == 124\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, ExpressionWithMacros) -{ - const char* str = "#define one 1\n" - "#define two 2\n" - "#define three 3\n" - "#if one + two == three\n" - "pass\n" - "#else\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "\n" - "\n" - "\n" - "pass\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, JunkInsideExcludedBlockIgnored) -{ - const char* str = "#if 0\n" - "foo !@#$%^&* .1bar\n" - "#foo\n" - "#if bar\n" - "fail\n" - "#endif\n" - "#else\n" - "pass\n" - "#endif\n"; - const char* expected = "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "pass\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, Ifdef) -{ - const char* str = "#define foo\n" - "#ifdef foo\n" - "pass_1\n" - "#else\n" - "fail_1\n" - "#endif\n" - "#undef foo\n" - "#ifdef foo\n" - "fail_2\n" - "#else\n" - "pass_2\n" - "#endif\n"; - const char* expected = "\n" - "\n" - "pass_1\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "pass_2\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, Ifndef) -{ - const char* str = "#define foo\n" - "#ifndef foo\n" - "fail_1\n" - "#else\n" - "pass_1\n" - "#endif\n" - "#undef foo\n" - "#ifndef foo\n" - "pass_2\n" - "#else\n" - "fail_2\n" - "#endif\n"; - const char* expected = "\n" - "\n" - "\n" - "\n" - "pass_1\n" - "\n" - "\n" - "\n" - "pass_2\n" - "\n" - "\n" - "\n"; - - preprocess(str, expected); -} - -TEST_F(IfTest, MissingExpression) -{ - const char* str = "#if\n" - "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INVALID_EXPRESSION, - pp::SourceLocation(0, 1), - "syntax error")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, DivisionByZero) -{ - const char* str = "#if 1 / (3 - (1 + 2))\n" - "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::DIVISION_BY_ZERO, - pp::SourceLocation(0, 1), "1 / 0")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, ModuloByZero) -{ - const char* str = "#if 1 % (3 - (1 + 2))\n" - "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::DIVISION_BY_ZERO, - pp::SourceLocation(0, 1), "1 % 0")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, DecIntegerOverflow) -{ - const char* str = "#if 4294967296\n" - "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INTEGER_OVERFLOW, - pp::SourceLocation(0, 1), "4294967296")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, OctIntegerOverflow) -{ - const char* str = "#if 077777777777\n" - "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INTEGER_OVERFLOW, - pp::SourceLocation(0, 1), "077777777777")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, HexIntegerOverflow) -{ - const char* str = "#if 0xfffffffff\n" - "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INTEGER_OVERFLOW, - pp::SourceLocation(0, 1), "0xfffffffff")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, UndefinedMacro) -{ - const char* str = "#if UNDEFINED\n" - "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INVALID_EXPRESSION, - pp::SourceLocation(0, 1), - "syntax error")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, - pp::SourceLocation(0, 1), - "UNDEFINED")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, InvalidExpressionIgnoredForExcludedElif) -{ - const char* str = "#if 1\n" - "pass\n" - "#elif UNDEFINED\n" - "fail\n" - "#endif\n"; - const char* expected = "\n" - "pass\n" - "\n" - "\n" - "\n"; - - // No error or warning. - using testing::_; - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(IfTest, ElseWithoutIf) -{ - const char* str = "#else\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ELSE_WITHOUT_IF, - pp::SourceLocation(0, 1), - "else")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, ElifWithoutIf) -{ - const char* str = "#elif 1\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ELIF_WITHOUT_IF, - pp::SourceLocation(0, 1), - "elif")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, EndifWithoutIf) -{ - const char* str = "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ENDIF_WITHOUT_IF, - pp::SourceLocation(0, 1), - "endif")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, ElseAfterElse) -{ - const char* str = "#if 1\n" - "#else\n" - "#else\n" - "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ELSE_AFTER_ELSE, - pp::SourceLocation(0, 3), - "else")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, ElifAfterElse) -{ - const char* str = "#if 1\n" - "#else\n" - "#elif 0\n" - "#endif\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ELIF_AFTER_ELSE, - pp::SourceLocation(0, 3), - "elif")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, UnterminatedIf) -{ - const char* str = "#if 1\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_UNTERMINATED, - pp::SourceLocation(0, 1), - "if")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -TEST_F(IfTest, UnterminatedIfdef) -{ - const char* str = "#ifdef foo\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_UNTERMINATED, - pp::SourceLocation(0, 1), - "ifdef")); - - pp::Token token; - mPreprocessor.lex(&token); -} - diff --git a/gfx/angle/tests/preprocessor_tests/input_test.cpp b/gfx/angle/tests/preprocessor_tests/input_test.cpp deleted file mode 100644 index b6a132af4719..000000000000 --- a/gfx/angle/tests/preprocessor_tests/input_test.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Input.h" -#include "Token.h" - -class InitTest : public PreprocessorTest -{ -}; - -TEST_F(InitTest, NegativeCount) -{ - EXPECT_FALSE(mPreprocessor.init(-1, NULL, NULL)); -} - -TEST_F(InitTest, ZeroCount) -{ - EXPECT_TRUE(mPreprocessor.init(0, NULL, NULL)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::LAST, token.type); -} - -TEST_F(InitTest, NullString) -{ - EXPECT_FALSE(mPreprocessor.init(1, NULL, NULL)); -} - -TEST(InputTest, DefaultConstructor) -{ - pp::Input input; - EXPECT_EQ(0, input.count()); - EXPECT_EQ(0, input.read(NULL, 1)); -} - -TEST(InputTest, NullLength) -{ - const char* str[] = {"foo"}; - pp::Input input(1, str, NULL); - EXPECT_EQ(3, input.length(0)); -} - -TEST(InputTest, NegativeLength) -{ - const char* str[] = {"foo"}; - int length[] = {-1}; - pp::Input input(1, str, length); - EXPECT_EQ(3, input.length(0)); -} - -TEST(InputTest, ActualLength) -{ - const char* str[] = {"foobar"}; - int length[] = {3}; - pp::Input input(1, str, length); - // Note that strlen(str[0]) != length[0]. - // Even then Input should just accept any non-negative number. - EXPECT_EQ(length[0], input.length(0)); -} - -TEST(InputTest, String) -{ - const char* str[] = {"foo"}; - pp::Input input(1, str, NULL); - EXPECT_STREQ(str[0], input.string(0)); -} - -TEST(InputTest, ReadSingleString) -{ - int count = 1; - const char* str[] = {"foo"}; - char buf[4] = {'\0', '\0', '\0', '\0'}; - - int maxSize = 1; - pp::Input input1(count, str, NULL); - EXPECT_EQ(1, input1.read(buf, maxSize)); - EXPECT_EQ('f', buf[0]); - EXPECT_EQ(1, input1.read(buf, maxSize)); - EXPECT_EQ('o', buf[0]); - EXPECT_EQ(1, input1.read(buf, maxSize)); - EXPECT_EQ('o', buf[0]); - EXPECT_EQ(0, input1.read(buf, maxSize)); - - maxSize = 2; - pp::Input input2(count, str, NULL); - EXPECT_EQ(2, input2.read(buf, maxSize)); - EXPECT_STREQ("fo", buf); - EXPECT_EQ(1, input2.read(buf, maxSize)); - EXPECT_EQ('o', buf[0]); - EXPECT_EQ(0, input2.read(buf, maxSize)); - - maxSize = 3; - pp::Input input3(count, str, NULL); - EXPECT_EQ(3, input3.read(buf, maxSize)); - EXPECT_STREQ("foo", buf); - EXPECT_EQ(0, input3.read(buf, maxSize)); - - maxSize = 4; - pp::Input input4(count, str, NULL); - EXPECT_EQ(3, input4.read(buf, maxSize)); - EXPECT_STREQ("foo", buf); - EXPECT_EQ(0, input4.read(buf, maxSize)); -} - -TEST(InputTest, ReadMultipleStrings) -{ - int count = 3; - const char* str[] = {"f", "o", "o"}; - char buf[4] = {'\0', '\0', '\0', '\0'}; - - int maxSize = 1; - pp::Input input1(count, str, NULL); - EXPECT_EQ(1, input1.read(buf, maxSize)); - EXPECT_EQ('f', buf[0]); - EXPECT_EQ(1, input1.read(buf, maxSize)); - EXPECT_EQ('o', buf[0]); - EXPECT_EQ(1, input1.read(buf, maxSize)); - EXPECT_EQ('o', buf[0]); - EXPECT_EQ(0, input1.read(buf, maxSize)); - - maxSize = 2; - pp::Input input2(count, str, NULL); - EXPECT_EQ(2, input2.read(buf, maxSize)); - EXPECT_STREQ("fo", buf); - EXPECT_EQ(1, input2.read(buf, maxSize)); - EXPECT_EQ('o', buf[0]); - EXPECT_EQ(0, input2.read(buf, maxSize)); - - maxSize = 3; - pp::Input input3(count, str, NULL); - EXPECT_EQ(3, input3.read(buf, maxSize)); - EXPECT_STREQ("foo", buf); - EXPECT_EQ(0, input3.read(buf, maxSize)); - - maxSize = 4; - pp::Input input4(count, str, NULL); - EXPECT_EQ(3, input4.read(buf, maxSize)); - EXPECT_STREQ("foo", buf); - EXPECT_EQ(0, input4.read(buf, maxSize)); -} - -TEST(InputTest, ReadStringsWithLength) -{ - int count = 2; - const char* str[] = {"foo", "bar"}; - // Note that the length for the first string is 2 which is less than - // strlen(str[0]. We want to make sure that the last character is ignored. - int length[] = {2, 3}; - char buf[6] = {'\0', '\0', '\0', '\0', '\0', '\0'}; - int maxSize = 5; - - pp::Input input(count, str, length); - EXPECT_EQ(maxSize, input.read(buf, maxSize)); - EXPECT_STREQ("fobar", buf); -} - diff --git a/gfx/angle/tests/preprocessor_tests/location_test.cpp b/gfx/angle/tests/preprocessor_tests/location_test.cpp deleted file mode 100644 index b615f99cd1a8..000000000000 --- a/gfx/angle/tests/preprocessor_tests/location_test.cpp +++ /dev/null @@ -1,303 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -class LocationTest : public PreprocessorTest -{ -protected: - void expectLocation(int count, - const char* const string[], - const int length[], - const pp::SourceLocation& location) - { - ASSERT_TRUE(mPreprocessor.init(count, string, length)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::IDENTIFIER, token.type); - EXPECT_EQ("foo", token.text); - - EXPECT_EQ(location.file, token.location.file); - EXPECT_EQ(location.line, token.location.line); - } -}; - -TEST_F(LocationTest, String0_Line1) -{ - const char* str = "foo"; - pp::SourceLocation loc(0, 1); - - SCOPED_TRACE("String0_Line1"); - expectLocation(1, &str, NULL, loc); -} - -TEST_F(LocationTest, String0_Line2) -{ - const char* str = "\nfoo"; - pp::SourceLocation loc(0, 2); - - SCOPED_TRACE("String0_Line2"); - expectLocation(1, &str, NULL, loc); -} - -TEST_F(LocationTest, String1_Line1) -{ - const char* const str[] = {"\n\n", "foo"}; - pp::SourceLocation loc(1, 1); - - SCOPED_TRACE("String1_Line1"); - expectLocation(2, str, NULL, loc); -} - -TEST_F(LocationTest, String1_Line2) -{ - const char* const str[] = {"\n\n", "\nfoo"}; - pp::SourceLocation loc(1, 2); - - SCOPED_TRACE("String1_Line2"); - expectLocation(2, str, NULL, loc); -} - -TEST_F(LocationTest, NewlineInsideCommentCounted) -{ - const char* str = "/*\n\n*/foo"; - pp::SourceLocation loc(0, 3); - - SCOPED_TRACE("NewlineInsideCommentCounted"); - expectLocation(1, &str, NULL, loc); -} - -TEST_F(LocationTest, ErrorLocationAfterComment) -{ - const char* str = "/*\n\n*/@"; - - ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::INVALID_CHARACTER, - pp::SourceLocation(0, 3), - "@")); - - pp::Token token; - mPreprocessor.lex(&token); -} - -// The location of a token straddling two or more strings is that of the -// first character of the token. - -TEST_F(LocationTest, TokenStraddlingTwoStrings) -{ - const char* const str[] = {"f", "oo"}; - pp::SourceLocation loc(0, 1); - - SCOPED_TRACE("TokenStraddlingTwoStrings"); - expectLocation(2, str, NULL, loc); -} - -TEST_F(LocationTest, TokenStraddlingThreeStrings) -{ - const char* const str[] = {"f", "o", "o"}; - pp::SourceLocation loc(0, 1); - - SCOPED_TRACE("TokenStraddlingThreeStrings"); - expectLocation(3, str, NULL, loc); -} - -TEST_F(LocationTest, EndOfFileWithoutNewline) -{ - const char* const str[] = {"foo"}; - ASSERT_TRUE(mPreprocessor.init(1, str, NULL)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::IDENTIFIER, token.type); - EXPECT_EQ("foo", token.text); - EXPECT_EQ(0, token.location.file); - EXPECT_EQ(1, token.location.line); - - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::LAST, token.type); - EXPECT_EQ(0, token.location.file); - EXPECT_EQ(1, token.location.line); -} - -TEST_F(LocationTest, EndOfFileAfterNewline) -{ - const char* const str[] = {"foo\n"}; - ASSERT_TRUE(mPreprocessor.init(1, str, NULL)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::IDENTIFIER, token.type); - EXPECT_EQ("foo", token.text); - EXPECT_EQ(0, token.location.file); - EXPECT_EQ(1, token.location.line); - - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::LAST, token.type); - EXPECT_EQ(0, token.location.file); - EXPECT_EQ(2, token.location.line); -} - -TEST_F(LocationTest, EndOfFileAfterEmptyString) -{ - const char* const str[] = {"foo\n", "\n", ""}; - ASSERT_TRUE(mPreprocessor.init(3, str, NULL)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::IDENTIFIER, token.type); - EXPECT_EQ("foo", token.text); - EXPECT_EQ(0, token.location.file); - EXPECT_EQ(1, token.location.line); - - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::LAST, token.type); - EXPECT_EQ(2, token.location.file); - EXPECT_EQ(1, token.location.line); -} - -TEST_F(LocationTest, ValidLineDirective1) -{ - const char* str = "#line 10\n" - "foo"; - pp::SourceLocation loc(0, 10); - - SCOPED_TRACE("ValidLineDirective1"); - expectLocation(1, &str, NULL, loc); -} - -TEST_F(LocationTest, ValidLineDirective2) -{ - const char* str = "#line 10 20\n" - "foo"; - pp::SourceLocation loc(20, 10); - - SCOPED_TRACE("ValidLineDirective2"); - expectLocation(1, &str, NULL, loc); -} - -TEST_F(LocationTest, LineDirectiveCommentsIgnored) -{ - const char* str = "/* bar */" - "#" - "/* bar */" - "line" - "/* bar */" - "10" - "/* bar */" - "20" - "/* bar */" - "// bar " - "\n" - "foo"; - pp::SourceLocation loc(20, 10); - - SCOPED_TRACE("LineDirectiveCommentsIgnored"); - expectLocation(1, &str, NULL, loc); -} - -TEST_F(LocationTest, LineDirectiveWithMacro1) -{ - const char* str = "#define L 10\n" - "#define F(x) x\n" - "#line L F(20)\n" - "foo"; - pp::SourceLocation loc(20, 10); - - SCOPED_TRACE("LineDirectiveWithMacro1"); - expectLocation(1, &str, NULL, loc); -} - -TEST_F(LocationTest, LineDirectiveWithMacro2) -{ - const char* str = "#define LOC 10 20\n" - "#line LOC\n" - "foo"; - pp::SourceLocation loc(20, 10); - - SCOPED_TRACE("LineDirectiveWithMacro2"); - expectLocation(1, &str, NULL, loc); -} - -TEST_F(LocationTest, LineDirectiveWithPredefinedMacro) -{ - const char* str = "#line __LINE__ __FILE__\n" - "foo"; - pp::SourceLocation loc(0, 1); - - SCOPED_TRACE("LineDirectiveWithMacro"); - expectLocation(1, &str, NULL, loc); -} - -TEST_F(LocationTest, LineDirectiveNewlineBeforeStringBreak) -{ - const char* const str[] = {"#line 10 20\n", "foo"}; - // String number is incremented after it is set by the line directive. - // Also notice that line number is reset after the string break. - pp::SourceLocation loc(21, 1); - - SCOPED_TRACE("LineDirectiveNewlineBeforeStringBreak"); - expectLocation(2, str, NULL, loc); -} - -TEST_F(LocationTest, LineDirectiveNewlineAfterStringBreak) -{ - const char* const str[] = {"#line 10 20", "\nfoo"}; - // String number is incremented before it is set by the line directive. - pp::SourceLocation loc(20, 10); - - SCOPED_TRACE("LineDirectiveNewlineAfterStringBreak"); - expectLocation(2, str, NULL, loc); -} - -TEST_F(LocationTest, LineDirectiveMissingNewline) -{ - const char* str = "#line 10"; - ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - - using testing::_; - // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); - - pp::Token token; - mPreprocessor.lex(&token); -} - -struct LineTestParam -{ - const char* str; - pp::Diagnostics::ID id; -}; - -class InvalidLineTest : public LocationTest, - public testing::WithParamInterface -{ -}; - -TEST_P(InvalidLineTest, Identified) -{ - LineTestParam param = GetParam(); - ASSERT_TRUE(mPreprocessor.init(1, ¶m.str, NULL)); - - using testing::_; - // Invalid line directive call. - EXPECT_CALL(mDiagnostics, print(param.id, pp::SourceLocation(0, 1), _)); - - pp::Token token; - mPreprocessor.lex(&token); -} - -static const LineTestParam kParams[] = { - {"#line\n", pp::Diagnostics::INVALID_LINE_DIRECTIVE}, - {"#line foo\n", pp::Diagnostics::INVALID_LINE_NUMBER}, - {"#line 10 foo\n", pp::Diagnostics::INVALID_FILE_NUMBER}, - {"#line 10 20 foo\n", pp::Diagnostics::UNEXPECTED_TOKEN}, - {"#line 0xffffffff\n", pp::Diagnostics::INTEGER_OVERFLOW}, - {"#line 10 0xffffffff\n", pp::Diagnostics::INTEGER_OVERFLOW} -}; - -INSTANTIATE_TEST_CASE_P(All, InvalidLineTest, testing::ValuesIn(kParams)); diff --git a/gfx/angle/tests/preprocessor_tests/number_test.cpp b/gfx/angle/tests/preprocessor_tests/number_test.cpp deleted file mode 100644 index 136732122f54..000000000000 --- a/gfx/angle/tests/preprocessor_tests/number_test.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -#define CLOSED_RANGE(x, y) testing::Range(x, static_cast((y) + 1)) - -class InvalidNumberTest : public PreprocessorTest, - public testing::WithParamInterface -{ -}; - -TEST_P(InvalidNumberTest, InvalidNumberIdentified) -{ - const char* str = GetParam(); - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - using testing::_; - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::INVALID_NUMBER, _, str)); - - pp::Token token; - mPreprocessor.lex(&token); -} - -INSTANTIATE_TEST_CASE_P(InvalidIntegers, InvalidNumberTest, - testing::Values("1a", "08", "0xG")); - - -INSTANTIATE_TEST_CASE_P(InvalidFloats, InvalidNumberTest, - testing::Values("1eg", "0.a", "0.1.2", ".0a", ".0.1")); - -typedef std::tr1::tuple IntegerParams; -class IntegerTest : public PreprocessorTest, - public testing::WithParamInterface -{ -}; - -TEST_P(IntegerTest, Identified) -{ - std::string str(std::tr1::get<0>(GetParam())); // prefix. - str.push_back(std::tr1::get<1>(GetParam())); // digit. - const char* cstr = str.c_str(); - - ASSERT_TRUE(mPreprocessor.init(1, &cstr, 0)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::CONST_INT, token.type); - EXPECT_EQ(str, token.text); -} - -INSTANTIATE_TEST_CASE_P(DecimalInteger, - IntegerTest, - testing::Combine(testing::Values(""), - CLOSED_RANGE('0', '9'))); - -INSTANTIATE_TEST_CASE_P(OctalInteger, - IntegerTest, - testing::Combine(testing::Values("0"), - CLOSED_RANGE('0', '7'))); - -INSTANTIATE_TEST_CASE_P(HexadecimalInteger_0_9, - IntegerTest, - testing::Combine(testing::Values("0x", "0X"), - CLOSED_RANGE('0', '9'))); - -INSTANTIATE_TEST_CASE_P(HexadecimalInteger_a_f, - IntegerTest, - testing::Combine(testing::Values("0x", "0X"), - CLOSED_RANGE('a', 'f'))); - -INSTANTIATE_TEST_CASE_P(HexadecimalInteger_A_F, - IntegerTest, - testing::Combine(testing::Values("0x", "0X"), - CLOSED_RANGE('A', 'F'))); - -class FloatTest : public PreprocessorTest -{ - protected: - void expectFloat(const std::string& str) - { - const char* cstr = str.c_str(); - ASSERT_TRUE(mPreprocessor.init(1, &cstr, 0)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::CONST_FLOAT, token.type); - EXPECT_EQ(str, token.text); - } -}; - -typedef std::tr1::tuple FloatScientificParams; -class FloatScientificTest : - public FloatTest, - public testing::WithParamInterface -{ -}; - -// This test covers floating point numbers of form [0-9][eE][+-]?[0-9]. -TEST_P(FloatScientificTest, FloatIdentified) -{ - std::string str; - str.push_back(std::tr1::get<0>(GetParam())); // significand [0-9]. - str.push_back(std::tr1::get<1>(GetParam())); // separator [eE]. - str.append(std::tr1::get<2>(GetParam())); // sign [" " "+" "-"]. - str.push_back(std::tr1::get<3>(GetParam())); // exponent [0-9]. - - SCOPED_TRACE("FloatScientificTest"); - expectFloat(str); -} - -INSTANTIATE_TEST_CASE_P(FloatScientific, - FloatScientificTest, - testing::Combine(CLOSED_RANGE('0', '9'), - testing::Values('e', 'E'), - testing::Values("", "+", "-"), - CLOSED_RANGE('0', '9'))); - -typedef std::tr1::tuple FloatFractionParams; -class FloatFractionTest : - public FloatTest, - public testing::WithParamInterface -{ -}; - -// This test covers floating point numbers of form [0-9]"." and [0-9]?"."[0-9]. -TEST_P(FloatFractionTest, FloatIdentified) -{ - std::string str; - - char significand = std::tr1::get<0>(GetParam()); - if (significand != '\0') - str.push_back(significand); - - str.push_back('.'); - - char fraction = std::tr1::get<1>(GetParam()); - if (fraction != '\0') - str.push_back(fraction); - - SCOPED_TRACE("FloatFractionTest"); - expectFloat(str); -} - -INSTANTIATE_TEST_CASE_P(FloatFraction_X_X, - FloatFractionTest, - testing::Combine(CLOSED_RANGE('0', '9'), - CLOSED_RANGE('0', '9'))); - -INSTANTIATE_TEST_CASE_P(FloatFraction_0_X, - FloatFractionTest, - testing::Combine(testing::Values('\0'), - CLOSED_RANGE('0', '9'))); - -INSTANTIATE_TEST_CASE_P(FloatFraction_X_0, - FloatFractionTest, - testing::Combine(CLOSED_RANGE('0', '9'), - testing::Values('\0'))); - -// In the tests above we have tested individual parts of a float separately. -// This test has all parts of a float. -TEST_F(FloatTest, FractionScientific) -{ - SCOPED_TRACE("FractionScientific"); - expectFloat("0.1e+2"); -} diff --git a/gfx/angle/tests/preprocessor_tests/operator_test.cpp b/gfx/angle/tests/preprocessor_tests/operator_test.cpp deleted file mode 100644 index d73bec633364..000000000000 --- a/gfx/angle/tests/preprocessor_tests/operator_test.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -struct OperatorTestParam -{ - const char* str; - int op; -}; - -class OperatorTest : public PreprocessorTest, - public testing::WithParamInterface -{ -}; - -TEST_P(OperatorTest, Identified) -{ - OperatorTestParam param = GetParam(); - - ASSERT_TRUE(mPreprocessor.init(1, ¶m.str, 0)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(param.op, token.type); - EXPECT_EQ(param.str, token.text); -} - -static const OperatorTestParam kOperators[] = { - {"(", '('}, - {")", ')'}, - {"[", '['}, - {"]", ']'}, - {".", '.'}, - {"+", '+'}, - {"-", '-'}, - {"~", '~'}, - {"!", '!'}, - {"*", '*'}, - {"/", '/'}, - {"%", '%'}, - {"<", '<'}, - {">", '>'}, - {"&", '&'}, - {"^", '^'}, - {"|", '|'}, - {"?", '?'}, - {":", ':'}, - {"=", '='}, - {",", ','}, - {"++", pp::Token::OP_INC}, - {"--", pp::Token::OP_DEC}, - {"<<", pp::Token::OP_LEFT}, - {">>", pp::Token::OP_RIGHT}, - {"<=", pp::Token::OP_LE}, - {">=", pp::Token::OP_GE}, - {"==", pp::Token::OP_EQ}, - {"!=", pp::Token::OP_NE}, - {"&&", pp::Token::OP_AND}, - {"^^", pp::Token::OP_XOR}, - {"||", pp::Token::OP_OR}, - {"+=", pp::Token::OP_ADD_ASSIGN}, - {"-=", pp::Token::OP_SUB_ASSIGN}, - {"*=", pp::Token::OP_MUL_ASSIGN}, - {"/=", pp::Token::OP_DIV_ASSIGN}, - {"%=", pp::Token::OP_MOD_ASSIGN}, - {"<<=", pp::Token::OP_LEFT_ASSIGN}, - {">>=", pp::Token::OP_RIGHT_ASSIGN}, - {"&=", pp::Token::OP_AND_ASSIGN}, - {"^=", pp::Token::OP_XOR_ASSIGN}, - {"|=", pp::Token::OP_OR_ASSIGN} -}; - -INSTANTIATE_TEST_CASE_P(All, OperatorTest, - testing::ValuesIn(kOperators)); - diff --git a/gfx/angle/tests/preprocessor_tests/pragma_test.cpp b/gfx/angle/tests/preprocessor_tests/pragma_test.cpp deleted file mode 100644 index a76fadae4830..000000000000 --- a/gfx/angle/tests/preprocessor_tests/pragma_test.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -class PragmaTest : public PreprocessorTest -{ -}; - -TEST_F(PragmaTest, EmptyName) -{ - const char* str = "#pragma\n"; - const char* expected = "\n"; - - using testing::_; - // No handlePragma calls. - EXPECT_CALL(mDirectiveHandler, handlePragma(_, _, _)).Times(0); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(PragmaTest, EmptyValue) -{ - const char* str = "#pragma foo\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handlePragma(pp::SourceLocation(0, 1), "foo", "")); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(PragmaTest, NameValue) -{ - const char* str = "#pragma foo(bar)\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handlePragma(pp::SourceLocation(0, 1), "foo", "bar")); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(PragmaTest, Comments) -{ - const char* str = "/*foo*/" - "#" - "/*foo*/" - "pragma" - "/*foo*/" - "foo" - "/*foo*/" - "(" - "/*foo*/" - "bar" - "/*foo*/" - ")" - "/*foo*/" - "//foo" - "\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handlePragma(pp::SourceLocation(0, 1), "foo", "bar")); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(PragmaTest, MissingNewline) -{ - const char* str = "#pragma foo(bar)"; - const char* expected = ""; - - using testing::_; - // Pragma successfully parsed. - EXPECT_CALL(mDirectiveHandler, - handlePragma(pp::SourceLocation(0, 1), "foo", "bar")); - // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); - - preprocess(str, expected); -} - -class InvalidPragmaTest : public PragmaTest, - public testing::WithParamInterface -{ -}; - -TEST_P(InvalidPragmaTest, Identified) -{ - const char* str = GetParam(); - const char* expected = "\n"; - - using testing::_; - // No handlePragma calls. - EXPECT_CALL(mDirectiveHandler, handlePragma(_, _, _)).Times(0); - // Unrecognized pragma warning. - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::UNRECOGNIZED_PRAGMA, - pp::SourceLocation(0, 1), _)); - - preprocess(str, expected); -} - -INSTANTIATE_TEST_CASE_P(All, InvalidPragmaTest, testing::Values( - "#pragma 1\n", // Invalid name. - "#pragma foo()\n", // Missing value. - "#pragma foo bar)\n", // Missing left paren, - "#pragma foo(bar\n", // Missing right paren. - "#pragma foo bar\n", // Missing parens. - "#pragma foo(bar) baz\n")); // Extra tokens. diff --git a/gfx/angle/tests/preprocessor_tests/space_test.cpp b/gfx/angle/tests/preprocessor_tests/space_test.cpp deleted file mode 100644 index c6b70c560c6b..000000000000 --- a/gfx/angle/tests/preprocessor_tests/space_test.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -class SpaceTest : public PreprocessorTest -{ - protected: - void expectSpace(const std::string& str) - { - const char* cstr = str.c_str(); - ASSERT_TRUE(mPreprocessor.init(1, &cstr, 0)); - - pp::Token token; - // "foo" is returned after ignoring the whitespace characters. - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::IDENTIFIER, token.type); - EXPECT_EQ("foo", token.text); - // The whitespace character is however recorded with the next token. - EXPECT_TRUE(token.hasLeadingSpace()); - } -}; - -// Whitespace characters allowed in GLSL. -// Note that newline characters (\n) will be tested separately. -static const char kSpaceChars[] = {' ', '\t', '\v', '\f'}; - -// This test fixture tests the processing of a single whitespace character. -// All tests in this fixture are ran with all possible whitespace character -// allowed in GLSL. -class SpaceCharTest : public SpaceTest, - public testing::WithParamInterface -{ -}; - -TEST_P(SpaceCharTest, SpaceIgnored) -{ - // Construct test string with the whitespace char before "foo". - std::string str(1, GetParam()); - str.append("foo"); - - expectSpace(str); -} - -INSTANTIATE_TEST_CASE_P(SingleSpaceChar, - SpaceCharTest, - testing::ValuesIn(kSpaceChars)); - -// This test fixture tests the processing of a string containing consecutive -// whitespace characters. All tests in this fixture are ran with all possible -// combinations of whitespace characters allowed in GLSL. -typedef std::tr1::tuple SpaceStringParams; -class SpaceStringTest : public SpaceTest, - public testing::WithParamInterface -{ -}; - -TEST_P(SpaceStringTest, SpaceIgnored) -{ - // Construct test string with the whitespace char before "foo". - std::string str; - str.push_back(std::tr1::get<0>(GetParam())); - str.push_back(std::tr1::get<1>(GetParam())); - str.push_back(std::tr1::get<2>(GetParam())); - str.append("foo"); - - expectSpace(str); -} - -INSTANTIATE_TEST_CASE_P(SpaceCharCombination, - SpaceStringTest, - testing::Combine(testing::ValuesIn(kSpaceChars), - testing::ValuesIn(kSpaceChars), - testing::ValuesIn(kSpaceChars))); - -// The tests above make sure that the space char is recorded in the -// next token. This test makes sure that a token is not incorrectly marked -// to have leading space. -TEST_F(SpaceTest, LeadingSpace) -{ - const char* str = " foo+ -bar"; - ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); - - pp::Token token; - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::IDENTIFIER, token.type); - EXPECT_EQ("foo", token.text); - EXPECT_TRUE(token.hasLeadingSpace()); - - mPreprocessor.lex(&token); - EXPECT_EQ('+', token.type); - EXPECT_FALSE(token.hasLeadingSpace()); - - mPreprocessor.lex(&token); - EXPECT_EQ('-', token.type); - EXPECT_TRUE(token.hasLeadingSpace()); - - mPreprocessor.lex(&token); - EXPECT_EQ(pp::Token::IDENTIFIER, token.type); - EXPECT_EQ("bar", token.text); - EXPECT_FALSE(token.hasLeadingSpace()); -} diff --git a/gfx/angle/tests/preprocessor_tests/token_test.cpp b/gfx/angle/tests/preprocessor_tests/token_test.cpp deleted file mode 100644 index 323d468340fe..000000000000 --- a/gfx/angle/tests/preprocessor_tests/token_test.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "gtest/gtest.h" - -#include "Token.h" - -TEST(TokenTest, DefaultConstructor) -{ - pp::Token token; - EXPECT_EQ(0, token.type); - EXPECT_EQ(0, token.flags); - EXPECT_EQ(0, token.location.line); - EXPECT_EQ(0, token.location.file); - EXPECT_EQ("", token.text); -} - -TEST(TokenTest, Assignment) -{ - pp::Token token; - token.type = 1; - token.flags = 1; - token.location.line = 1; - token.location.file = 1; - token.text.assign("foo"); - - token = pp::Token(); - EXPECT_EQ(0, token.type); - EXPECT_EQ(0, token.flags); - EXPECT_EQ(0, token.location.line); - EXPECT_EQ(0, token.location.file); - EXPECT_EQ("", token.text); -} - -TEST(TokenTest, Equals) -{ - pp::Token token; - EXPECT_TRUE(token.equals(pp::Token())); - - token.type = 1; - EXPECT_FALSE(token.equals(pp::Token())); - token.type = 0; - - token.flags = 1; - EXPECT_FALSE(token.equals(pp::Token())); - token.flags = 0; - - token.location.line = 1; - EXPECT_FALSE(token.equals(pp::Token())); - token.location.line = 0; - - token.location.file = 1; - EXPECT_FALSE(token.equals(pp::Token())); - token.location.file = 0; - - token.text.assign("foo"); - EXPECT_FALSE(token.equals(pp::Token())); - token.text.clear(); - - EXPECT_TRUE(token.equals(pp::Token())); -} - -TEST(TokenTest, HasLeadingSpace) -{ - pp::Token token; - EXPECT_FALSE(token.hasLeadingSpace()); - token.setHasLeadingSpace(true); - EXPECT_TRUE(token.hasLeadingSpace()); - token.setHasLeadingSpace(false); - EXPECT_FALSE(token.hasLeadingSpace()); -} - -TEST(TokenTest, Write) -{ - pp::Token token; - token.text.assign("foo"); - std::stringstream out1; - out1 << token; - EXPECT_TRUE(out1.good()); - EXPECT_EQ("foo", out1.str()); - - token.setHasLeadingSpace(true); - std::stringstream out2; - out2 << token; - EXPECT_TRUE(out2.good()); - EXPECT_EQ(" foo", out2.str()); -} diff --git a/gfx/angle/tests/preprocessor_tests/version_test.cpp b/gfx/angle/tests/preprocessor_tests/version_test.cpp deleted file mode 100644 index 0db2fad1d11b..000000000000 --- a/gfx/angle/tests/preprocessor_tests/version_test.cpp +++ /dev/null @@ -1,229 +0,0 @@ -// -// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -#include "PreprocessorTest.h" -#include "Token.h" - -class VersionTest : public PreprocessorTest -{ -}; - -TEST_F(VersionTest, Valid) -{ - const char* str = "#version 200\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handleVersion(pp::SourceLocation(0, 1), 200)); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(VersionTest, CommentsIgnored) -{ - const char* str = "/*foo*/" - "#" - "/*foo*/" - "version" - "/*foo*/" - "200" - "/*foo*/" - "//foo" - "\n"; - const char* expected = "\n"; - - using testing::_; - EXPECT_CALL(mDirectiveHandler, - handleVersion(pp::SourceLocation(0, 1), 200)); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(VersionTest, MissingNewline) -{ - const char* str = "#version 200"; - const char* expected = ""; - - using testing::_; - // Directive successfully parsed. - EXPECT_CALL(mDirectiveHandler, - handleVersion(pp::SourceLocation(0, 1), 200)); - // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); - - preprocess(str, expected); -} - -TEST_F(VersionTest, AfterComments) -{ - const char* str = "/* block comment acceptable */\n" - "// line comment acceptable\n" - "#version 200\n"; - const char* expected = "\n\n\n"; - - using testing::_; - // Directive successfully parsed. - EXPECT_CALL(mDirectiveHandler, - handleVersion(pp::SourceLocation(0, 3), 200)); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(VersionTest, AfterWhitespace) -{ - const char* str = "\n" - "\n" - "#version 200\n"; - const char* expected = "\n\n\n"; - - using testing::_; - // Directive successfully parsed. - EXPECT_CALL(mDirectiveHandler, - handleVersion(pp::SourceLocation(0, 3), 200)); - // No error or warning. - EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); - - preprocess(str, expected); -} - -TEST_F(VersionTest, AfterValidToken) -{ - const char* str = "foo\n" - "#version 200\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - - using testing::_; - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, - pp::SourceLocation(0, 2), _)); - - pp::Token token; - do - { - mPreprocessor.lex(&token); - } while (token.type != pp::Token::LAST); -} - -TEST_F(VersionTest, AfterInvalidToken) -{ - const char* str = "$\n" - "#version 200\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - - using testing::_; - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INVALID_CHARACTER, - pp::SourceLocation(0, 1), "$")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, - pp::SourceLocation(0, 2), _)); - - pp::Token token; - do - { - mPreprocessor.lex(&token); - } while (token.type != pp::Token::LAST); -} - -TEST_F(VersionTest, AfterValidDirective) -{ - const char* str = "#\n" - "#version 200\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - - using testing::_; - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, - pp::SourceLocation(0, 2), _)); - - pp::Token token; - do - { - mPreprocessor.lex(&token); - } while (token.type != pp::Token::LAST); -} - -TEST_F(VersionTest, AfterInvalidDirective) -{ - const char* str = "#foo\n" - "#version 200\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - - using testing::_; - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::DIRECTIVE_INVALID_NAME, - pp::SourceLocation(0, 1), "foo")); - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, - pp::SourceLocation(0, 2), _)); - - pp::Token token; - do - { - mPreprocessor.lex(&token); - } while (token.type != pp::Token::LAST); -} - -TEST_F(VersionTest, AfterExcludedBlock) -{ - const char* str = "#if 0\n" - "foo\n" - "#endif\n" - "#version 200\n"; - ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - - using testing::_; - EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, - pp::SourceLocation(0, 4), _)); - - pp::Token token; - do - { - mPreprocessor.lex(&token); - } while (token.type != pp::Token::LAST); -} - -struct VersionTestParam -{ - const char* str; - pp::Diagnostics::ID id; -}; - -class InvalidVersionTest : public VersionTest, - public testing::WithParamInterface -{ -}; - -TEST_P(InvalidVersionTest, Identified) -{ - VersionTestParam param = GetParam(); - const char* expected = "\n"; - - using testing::_; - // No handleVersion call. - EXPECT_CALL(mDirectiveHandler, handleVersion(_, _)).Times(0); - // Invalid version directive call. - EXPECT_CALL(mDiagnostics, print(param.id, pp::SourceLocation(0, 1), _)); - - preprocess(param.str, expected); -} - -static const VersionTestParam kParams[] = { - {"#version\n", pp::Diagnostics::INVALID_VERSION_DIRECTIVE}, - {"#version foo\n", pp::Diagnostics::INVALID_VERSION_NUMBER}, - {"#version 100 foo\n", pp::Diagnostics::UNEXPECTED_TOKEN}, - {"#version 0xffffffff\n", pp::Diagnostics::INTEGER_OVERFLOW} -}; - -INSTANTIATE_TEST_CASE_P(All, InvalidVersionTest, testing::ValuesIn(kParams));