From 0456c5d58031aa1d9627ab6935a67c2b603c2e48 Mon Sep 17 00:00:00 2001 From: Nicolas Capens Date: Fri, 17 Oct 2014 14:36:08 -0400 Subject: [PATCH] Remove unused shader compiler code. BUG=14600811 Change-Id: I09f18c61e94b46592e2c0bd1905a668c94ed1c16 Reviewed-on: https://swiftshader-review.googlesource.com/1080 Reviewed-by: Nicolas Capens Tested-by: Nicolas Capens --- src/GLES2/compiler/Compiler.cpp | 12 -- src/GLES2/compiler/Compiler.vcxproj | 4 - src/GLES2/compiler/Compiler.vcxproj.filters | 12 -- src/GLES2/compiler/Intermediate.cpp | 1 - src/GLES2/compiler/QualifierAlive.cpp | 58 -------- src/GLES2/compiler/QualifierAlive.h | 7 - src/GLES2/compiler/ShHandle.h | 7 - src/GLES2/compiler/ShaderLang.cpp | 80 ----------- src/GLES2/compiler/VariableInfo.cpp | 211 ---------------------------- src/GLES2/compiler/VariableInfo.h | 42 ------ src/GLES2/include/GLSLANG/ShaderLang.h | 78 ---------- src/GLES2/libGLESv2/libGLESv2.cbp | 4 - 12 files changed, 516 deletions(-) delete mode 100644 src/GLES2/compiler/QualifierAlive.cpp delete mode 100644 src/GLES2/compiler/QualifierAlive.h delete mode 100644 src/GLES2/compiler/VariableInfo.cpp delete mode 100644 src/GLES2/compiler/VariableInfo.h diff --git a/src/GLES2/compiler/Compiler.cpp b/src/GLES2/compiler/Compiler.cpp index d1b36c050..694586968 100644 --- a/src/GLES2/compiler/Compiler.cpp +++ b/src/GLES2/compiler/Compiler.cpp @@ -114,9 +114,6 @@ bool TCompiler::compile(const char* const shaderStrings[], if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING)) success = validateLimitations(root); - if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) - collectAttribsUniforms(root); - if (success && (compileOptions & SH_INTERMEDIATE_TREE)) intermediate.outputTree(root); @@ -181,9 +178,6 @@ void TCompiler::clearResults() infoSink.info.erase(); infoSink.obj.erase(); infoSink.debug.erase(); - - attribs.clear(); - uniforms.clear(); } bool TCompiler::validateCallDepth(TIntermNode *root, TInfoSink &infoSink) @@ -220,12 +214,6 @@ bool TCompiler::validateLimitations(TIntermNode* root) { return validate.numErrors() == 0; } -void TCompiler::collectAttribsUniforms(TIntermNode* root) -{ - CollectAttribsUniforms collect(attribs, uniforms); - root->traverse(&collect); -} - const TExtensionBehavior& TCompiler::getExtensionBehavior() const { return extensionBehavior; diff --git a/src/GLES2/compiler/Compiler.vcxproj b/src/GLES2/compiler/Compiler.vcxproj index 60aee6459..3416a227b 100644 --- a/src/GLES2/compiler/Compiler.vcxproj +++ b/src/GLES2/compiler/Compiler.vcxproj @@ -123,14 +123,12 @@ - - @@ -194,7 +192,6 @@ - @@ -202,7 +199,6 @@ - diff --git a/src/GLES2/compiler/Compiler.vcxproj.filters b/src/GLES2/compiler/Compiler.vcxproj.filters index 369f97aa3..d4118f070 100644 --- a/src/GLES2/compiler/Compiler.vcxproj.filters +++ b/src/GLES2/compiler/Compiler.vcxproj.filters @@ -50,9 +50,6 @@ Source Files - - Source Files - Source Files @@ -68,9 +65,6 @@ Source Files - - Source Files - Source Files\generated @@ -142,9 +136,6 @@ Header Files - - Header Files - Header Files @@ -163,9 +154,6 @@ Header Files - - Header Files - Header Files\generated diff --git a/src/GLES2/compiler/Intermediate.cpp b/src/GLES2/compiler/Intermediate.cpp index 56c3ee23d..6910deb4f 100644 --- a/src/GLES2/compiler/Intermediate.cpp +++ b/src/GLES2/compiler/Intermediate.cpp @@ -13,7 +13,6 @@ #include #include "compiler/localintermediate.h" -#include "compiler/QualifierAlive.h" #include "compiler/RemoveTree.h" #include "compiler/SymbolTable.h" diff --git a/src/GLES2/compiler/QualifierAlive.cpp b/src/GLES2/compiler/QualifierAlive.cpp deleted file mode 100644 index 92a6874eb..000000000 --- a/src/GLES2/compiler/QualifierAlive.cpp +++ /dev/null @@ -1,58 +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 "compiler/intermediate.h" - -class TAliveTraverser : public TIntermTraverser { -public: - TAliveTraverser(TQualifier q) : TIntermTraverser(true, false, false, true), found(false), qualifier(q) - { - } - - bool wasFound() { return found; } - -protected: - bool found; - TQualifier qualifier; - - void visitSymbol(TIntermSymbol*); - bool visitSelection(Visit, TIntermSelection*); -}; - -// -// Report whether or not a variable of the given qualifier type -// is guaranteed written. Not always possible to determine if -// it is written conditionally. -// -// ?? It does not do this well yet, this is just a place holder -// that simply determines if it was reference at all, anywhere. -// -bool QualifierWritten(TIntermNode* node, TQualifier qualifier) -{ - TAliveTraverser it(qualifier); - - if (node) - node->traverse(&it); - - return it.wasFound(); -} - -void TAliveTraverser::visitSymbol(TIntermSymbol* node) -{ - // - // If it's what we're looking for, record it. - // - if (node->getQualifier() == qualifier) - found = true; -} - -bool TAliveTraverser::visitSelection(Visit preVisit, TIntermSelection* node) -{ - if (wasFound()) - return false; - - return true; -} diff --git a/src/GLES2/compiler/QualifierAlive.h b/src/GLES2/compiler/QualifierAlive.h deleted file mode 100644 index 872a06f72..000000000 --- a/src/GLES2/compiler/QualifierAlive.h +++ /dev/null @@ -1,7 +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. -// - -bool QualifierWritten(TIntermNode* root, TQualifier); diff --git a/src/GLES2/compiler/ShHandle.h b/src/GLES2/compiler/ShHandle.h index c77258209..685970643 100644 --- a/src/GLES2/compiler/ShHandle.h +++ b/src/GLES2/compiler/ShHandle.h @@ -19,7 +19,6 @@ #include "compiler/ExtensionBehavior.h" #include "compiler/InfoSink.h" #include "compiler/SymbolTable.h" -#include "compiler/VariableInfo.h" class TCompiler; @@ -55,8 +54,6 @@ public: // Get results of the last compilation. TInfoSink& getInfoSink() { return infoSink; } - const TVariableInfoList& getAttribs() const { return attribs; } - const TVariableInfoList& getUniforms() const { return uniforms; } protected: ShShaderType getShaderType() const { return shaderType; } @@ -70,8 +67,6 @@ protected: // Returns true if the given shader does not exceed the minimum // functionality mandated in GLSL 1.0 spec Appendix A. bool validateLimitations(TIntermNode *root); - // Collect info for all attribs and uniforms. - void collectAttribsUniforms(TIntermNode *root); // Translate to object code. virtual bool translate(TIntermNode *root) = 0; // Get built-in extensions with default behavior. @@ -91,8 +86,6 @@ private: // Results of compilation. TInfoSink infoSink; // Output sink. - TVariableInfoList attribs; // Active attributes in the compiled shader. - TVariableInfoList uniforms; // Active uniforms in the compiled shader. }; // diff --git a/src/GLES2/compiler/ShaderLang.cpp b/src/GLES2/compiler/ShaderLang.cpp index 7c5e07017..368c0683d 100644 --- a/src/GLES2/compiler/ShaderLang.cpp +++ b/src/GLES2/compiler/ShaderLang.cpp @@ -18,58 +18,6 @@ #include // -// This is the platform independent interface between an OGL driver -// and the shading language compiler. -// - -static bool checkActiveUniformAndAttribMaxLengths(const ShHandle handle, - int expectedValue) -{ - int activeUniformLimit = 0; - ShGetInfo(handle, SH_ACTIVE_UNIFORM_MAX_LENGTH, &activeUniformLimit); - int activeAttribLimit = 0; - ShGetInfo(handle, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &activeAttribLimit); - return (expectedValue == activeUniformLimit && expectedValue == activeAttribLimit); -} - -static void getVariableInfo(ShShaderInfo varType, - const ShHandle handle, - int index, - int* length, - int* size, - ShDataType* type, - char* name) -{ - if (!handle || !size || !type || !name) - return; - ASSERT((varType == SH_ACTIVE_ATTRIBUTES) || - (varType == SH_ACTIVE_UNIFORMS)); - - TShHandleBase* base = reinterpret_cast(handle); - TCompiler* compiler = base->getAsCompiler(); - if (compiler == 0) - return; - - const TVariableInfoList& varList = varType == SH_ACTIVE_ATTRIBUTES ? - compiler->getAttribs() : compiler->getUniforms(); - if (index < 0 || index >= static_cast(varList.size())) - return; - - const TVariableInfo& varInfo = varList[index]; - if (length) *length = varInfo.name.size(); - *size = varInfo.size; - *type = varInfo.type; - - // This size must match that queried by - // SH_ACTIVE_UNIFORM_MAX_LENGTH and SH_ACTIVE_ATTRIBUTE_MAX_LENGTH - // in ShGetInfo, below. - int activeUniformAndAttribLength = 1 + MAX_SYMBOL_NAME_LEN; - ASSERT(checkActiveUniformAndAttribMaxLengths(handle, activeUniformAndAttribLength)); - strncpy(name, varInfo.name.c_str(), activeUniformAndAttribLength); - name[activeUniformAndAttribLength - 1] = 0; -} - -// // Driver must call this first, once, before doing any other // compiler operations. // @@ -194,15 +142,9 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params) case SH_OBJECT_CODE_LENGTH: *params = compiler->getInfoSink().obj.size() + 1; break; - case SH_ACTIVE_UNIFORMS: - *params = compiler->getUniforms().size(); - break; case SH_ACTIVE_UNIFORM_MAX_LENGTH: *params = 1 + MAX_SYMBOL_NAME_LEN; break; - case SH_ACTIVE_ATTRIBUTES: - *params = compiler->getAttribs().size(); - break; case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH: *params = 1 + MAX_SYMBOL_NAME_LEN; break; @@ -241,25 +183,3 @@ void ShGetObjectCode(const ShHandle handle, char* objCode) TInfoSink& infoSink = compiler->getInfoSink(); strcpy(objCode, infoSink.obj.c_str()); } - -void ShGetActiveAttrib(const ShHandle handle, - int index, - int* length, - int* size, - ShDataType* type, - char* name) -{ - getVariableInfo(SH_ACTIVE_ATTRIBUTES, - handle, index, length, size, type, name); -} - -void ShGetActiveUniform(const ShHandle handle, - int index, - int* length, - int* size, - ShDataType* type, - char* name) -{ - getVariableInfo(SH_ACTIVE_UNIFORMS, - handle, index, length, size, type, name); -} diff --git a/src/GLES2/compiler/VariableInfo.cpp b/src/GLES2/compiler/VariableInfo.cpp deleted file mode 100644 index ea41dceab..000000000 --- a/src/GLES2/compiler/VariableInfo.cpp +++ /dev/null @@ -1,211 +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/VariableInfo.h" - -static TString arrayBrackets(int index) -{ - TStringStream stream; - stream << "[" << index << "]"; - return stream.str(); -} - -// Returns the data type for an attribute or uniform. -static ShDataType getVariableDataType(const TType& type) -{ - switch (type.getBasicType()) { - case EbtFloat: - if (type.isMatrix()) { - switch (type.getNominalSize()) { - case 2: return SH_FLOAT_MAT2; - case 3: return SH_FLOAT_MAT3; - case 4: return SH_FLOAT_MAT4; - default: UNREACHABLE(); - } - } else if (type.isVector()) { - switch (type.getNominalSize()) { - case 2: return SH_FLOAT_VEC2; - case 3: return SH_FLOAT_VEC3; - case 4: return SH_FLOAT_VEC4; - default: UNREACHABLE(); - } - } else { - return SH_FLOAT; - } - case EbtInt: - if (type.isMatrix()) { - UNREACHABLE(); - } else if (type.isVector()) { - switch (type.getNominalSize()) { - case 2: return SH_INT_VEC2; - case 3: return SH_INT_VEC3; - case 4: return SH_INT_VEC4; - default: UNREACHABLE(); - } - } else { - return SH_INT; - } - case EbtBool: - if (type.isMatrix()) { - UNREACHABLE(); - } else if (type.isVector()) { - switch (type.getNominalSize()) { - case 2: return SH_BOOL_VEC2; - case 3: return SH_BOOL_VEC3; - case 4: return SH_BOOL_VEC4; - default: UNREACHABLE(); - } - } else { - return SH_BOOL; - } - case EbtSampler2D: return SH_SAMPLER_2D; - case EbtSamplerCube: return SH_SAMPLER_CUBE; - case EbtSamplerExternalOES: return SH_SAMPLER_EXTERNAL_OES; - default: UNREACHABLE(); - } - return SH_NONE; -} - -static void getBuiltInVariableInfo(const TType& type, - const TString& name, - TVariableInfoList& infoList); -static void getUserDefinedVariableInfo(const TType& type, - const TString& name, - TVariableInfoList& infoList); - -// Returns info for an attribute or uniform. -static void getVariableInfo(const TType& type, - const TString& name, - TVariableInfoList& infoList) -{ - if (type.getBasicType() == EbtStruct) { - if (type.isArray()) { - for (int i = 0; i < type.getArraySize(); ++i) { - TString lname = name + arrayBrackets(i); - getUserDefinedVariableInfo(type, lname, infoList); - } - } else { - getUserDefinedVariableInfo(type, name, infoList); - } - } else { - getBuiltInVariableInfo(type, name, infoList); - } -} - -void getBuiltInVariableInfo(const TType& type, - const TString& name, - TVariableInfoList& infoList) -{ - ASSERT(type.getBasicType() != EbtStruct); - - TVariableInfo varInfo; - if (type.isArray()) { - varInfo.name = (name + "[0]").c_str(); - varInfo.size = type.getArraySize(); - } else { - varInfo.name = name.c_str(); - varInfo.size = 1; - } - varInfo.type = getVariableDataType(type); - infoList.push_back(varInfo); -} - -void getUserDefinedVariableInfo(const TType& type, - const TString& name, - TVariableInfoList& infoList) -{ - ASSERT(type.getBasicType() == EbtStruct); - - const TTypeList* structure = type.getStruct(); - for (size_t i = 0; i < structure->size(); ++i) { - const TType* fieldType = (*structure)[i].type; - getVariableInfo(*fieldType, - name + "." + fieldType->getFieldName(), - infoList); - } -} - -CollectAttribsUniforms::CollectAttribsUniforms(TVariableInfoList& attribs, - TVariableInfoList& uniforms) - : mAttribs(attribs), - mUniforms(uniforms) -{ -} - -// We are only interested in attribute and uniform variable declaration. -void CollectAttribsUniforms::visitSymbol(TIntermSymbol*) -{ -} - -void CollectAttribsUniforms::visitConstantUnion(TIntermConstantUnion*) -{ -} - -bool CollectAttribsUniforms::visitBinary(Visit, TIntermBinary*) -{ - return false; -} - -bool CollectAttribsUniforms::visitUnary(Visit, TIntermUnary*) -{ - return false; -} - -bool CollectAttribsUniforms::visitSelection(Visit, TIntermSelection*) -{ - return false; -} - -bool CollectAttribsUniforms::visitAggregate(Visit, TIntermAggregate* node) -{ - bool visitChildren = false; - - switch (node->getOp()) - { - case EOpSequence: - // We need to visit sequence children to get to variable declarations. - visitChildren = true; - break; - case EOpDeclaration: { - const TIntermSequence& sequence = node->getSequence(); - TQualifier qualifier = sequence.front()->getAsTyped()->getQualifier(); - if (qualifier == EvqAttribute || qualifier == EvqUniform) - { - TVariableInfoList& infoList = qualifier == EvqAttribute ? - mAttribs : mUniforms; - for (TIntermSequence::const_iterator i = sequence.begin(); - i != sequence.end(); ++i) - { - const TIntermSymbol* variable = (*i)->getAsSymbolNode(); - // The only case in which the sequence will not contain a - // TIntermSymbol node is initialization. It will contain a - // TInterBinary node in that case. Since attributes and unifroms - // cannot be initialized in a shader, we must have only - // TIntermSymbol nodes in the sequence. - ASSERT(variable != NULL); - getVariableInfo(variable->getType(), - variable->getSymbol(), - infoList); - } - } - break; - } - default: break; - } - - return visitChildren; -} - -bool CollectAttribsUniforms::visitLoop(Visit, TIntermLoop*) -{ - return false; -} - -bool CollectAttribsUniforms::visitBranch(Visit, TIntermBranch*) -{ - return false; -} - diff --git a/src/GLES2/compiler/VariableInfo.h b/src/GLES2/compiler/VariableInfo.h deleted file mode 100644 index 77902d984..000000000 --- a/src/GLES2/compiler/VariableInfo.h +++ /dev/null @@ -1,42 +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. -// - -#ifndef COMPILER_VARIABLE_INFO_H_ -#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 { - TPersistString name; - ShDataType type; - int size; -}; -typedef std::vector TVariableInfoList; - -// Traverses intermediate tree to collect all attributes and uniforms. -class CollectAttribsUniforms : public TIntermTraverser { -public: - CollectAttribsUniforms(TVariableInfoList& attribs, - TVariableInfoList& uniforms); - - virtual void visitSymbol(TIntermSymbol*); - virtual void visitConstantUnion(TIntermConstantUnion*); - virtual bool visitBinary(Visit, TIntermBinary*); - virtual bool visitUnary(Visit, TIntermUnary*); - virtual bool visitSelection(Visit, TIntermSelection*); - virtual bool visitAggregate(Visit, TIntermAggregate*); - virtual bool visitLoop(Visit, TIntermLoop*); - virtual bool visitBranch(Visit, TIntermBranch*); - -private: - TVariableInfoList& mAttribs; - TVariableInfoList& mUniforms; -}; - -#endif // COMPILER_VARIABLE_INFO_H_ diff --git a/src/GLES2/include/GLSLANG/ShaderLang.h b/src/GLES2/include/GLSLANG/ShaderLang.h index 256309246..f4b42722b 100644 --- a/src/GLES2/include/GLSLANG/ShaderLang.h +++ b/src/GLES2/include/GLSLANG/ShaderLang.h @@ -36,33 +36,9 @@ typedef enum { } ShShaderSpec; typedef enum { - SH_NONE = 0, - SH_INT = 0x1404, - SH_FLOAT = 0x1406, - SH_FLOAT_VEC2 = 0x8B50, - SH_FLOAT_VEC3 = 0x8B51, - SH_FLOAT_VEC4 = 0x8B52, - SH_INT_VEC2 = 0x8B53, - SH_INT_VEC3 = 0x8B54, - SH_INT_VEC4 = 0x8B55, - SH_BOOL = 0x8B56, - SH_BOOL_VEC2 = 0x8B57, - SH_BOOL_VEC3 = 0x8B58, - SH_BOOL_VEC4 = 0x8B59, - SH_FLOAT_MAT2 = 0x8B5A, - SH_FLOAT_MAT3 = 0x8B5B, - SH_FLOAT_MAT4 = 0x8B5C, - SH_SAMPLER_2D = 0x8B5E, - SH_SAMPLER_CUBE = 0x8B60, - SH_SAMPLER_EXTERNAL_OES = 0x8D66 -} ShDataType; - -typedef enum { SH_INFO_LOG_LENGTH = 0x8B84, SH_OBJECT_CODE_LENGTH = 0x8B88, // GL_SHADER_SOURCE_LENGTH - SH_ACTIVE_UNIFORMS = 0x8B86, SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87, - SH_ACTIVE_ATTRIBUTES = 0x8B89, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A } ShShaderInfo; @@ -216,60 +192,6 @@ void ShGetInfoLog(const ShHandle handle, char* infoLog); // ShGetInfo with SH_OBJECT_CODE_LENGTH. void ShGetObjectCode(const ShHandle handle, char* objCode); -// Returns information about an active attribute variable. -// Parameters: -// handle: Specifies the compiler -// index: Specifies the index of the attribute variable to be queried. -// length: Returns the number of characters actually written in the string -// indicated by name (excluding the null terminator) if a value other -// than NULL is passed. -// size: Returns the size of the attribute variable. -// type: Returns the data type of the attribute variable. -// name: Returns a null terminated string containing the name of the -// attribute variable. It is assumed that name has enough memory to -// accomodate the attribute variable name. The size of the buffer -// required to store the attribute variable name can be obtained by -// calling ShGetInfo with SH_ACTIVE_ATTRIBUTE_MAX_LENGTH. -// mappedName: Returns a null terminated string containing the mapped name of -// the attribute variable, It is assumed that mappedName has enough -// memory (SH_MAPPED_NAME_MAX_LENGTH), or NULL if don't care -// about the mapped name. If the name is not mapped, then name and -// mappedName are the same. -void ShGetActiveAttrib(const ShHandle handle, - int index, - int* length, - int* size, - ShDataType* type, - char* name, - char* mappedName); - -// Returns information about an active uniform variable. -// Parameters: -// handle: Specifies the compiler -// index: Specifies the index of the uniform variable to be queried. -// length: Returns the number of characters actually written in the string -// indicated by name (excluding the null terminator) if a value -// other than NULL is passed. -// size: Returns the size of the uniform variable. -// type: Returns the data type of the uniform variable. -// name: Returns a null terminated string containing the name of the -// uniform variable. It is assumed that name has enough memory to -// accomodate the uniform variable name. The size of the buffer required -// to store the uniform variable name can be obtained by calling -// ShGetInfo with SH_ACTIVE_UNIFORMS_MAX_LENGTH. -// mappedName: Returns a null terminated string containing the mapped name of -// the uniform variable, It is assumed that mappedName has enough -// memory (SH_MAPPED_NAME_MAX_LENGTH), or NULL if don't care -// about the mapped name. If the name is not mapped, then name and -// mappedName are the same. -void ShGetActiveUniform(const ShHandle handle, - int index, - int* length, - int* size, - ShDataType* type, - char* name, - char* mappedName); - #ifdef __cplusplus } #endif diff --git a/src/GLES2/libGLESv2/libGLESv2.cbp b/src/GLES2/libGLESv2/libGLESv2.cbp index 65008eddd..a045a3ae8 100644 --- a/src/GLES2/libGLESv2/libGLESv2.cbp +++ b/src/GLES2/libGLESv2/libGLESv2.cbp @@ -171,8 +171,6 @@ - - @@ -184,8 +182,6 @@ - - -- 2.11.0