Commit 4a667fe9 by Zhenyao Mo

Add an option to initialize varyings without static use in vertex shaders

ANGLEBUG=554 TEST=webgl conformance test on mac: shaders-with-varyings.html r=kbr@chromium.org,nicolascapens@chromium.org cc=alokp@chromium.org,shannonwoods@chromium.org Change-Id: I2e692d43fb15f1cf3ade3e398020d1fedb2b32f0 Reviewed-on: https://chromium-review.googlesource.com/185922Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Tested-by: 's avatarZhenyao Mo <zmo@chromium.org> Conflicts: src/common/version.h src/compiler/translator/Compiler.cpp Change-Id: If7db13ef345bd6199d4ea0d7786f0de20885f2f3 Reviewed-on: https://chromium-review.googlesource.com/186144Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Tested-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent 32d508e2
...@@ -212,8 +212,8 @@ typedef enum { ...@@ -212,8 +212,8 @@ typedef enum {
// This flag limits the depth of the call stack. // This flag limits the depth of the call stack.
SH_LIMIT_CALL_STACK_DEPTH = 0x4000, SH_LIMIT_CALL_STACK_DEPTH = 0x4000,
// This flag initializes gl_Position to vec4(0.0, 0.0, 0.0, 1.0) at // This flag initializes gl_Position to vec4(0,0,0,0) at the
// the beginning of the vertex shader, and has no effect in the // beginning of the vertex shader's main(), and has no effect in the
// fragment shader. It is intended as a workaround for drivers which // fragment shader. It is intended as a workaround for drivers which
// incorrectly fail to link programs if gl_Position is not written. // incorrectly fail to link programs if gl_Position is not written.
SH_INIT_GL_POSITION = 0x8000, SH_INIT_GL_POSITION = 0x8000,
...@@ -224,6 +224,12 @@ typedef enum { ...@@ -224,6 +224,12 @@ typedef enum {
// This is to work around a MacOSX driver bug that |b| is executed // This is to work around a MacOSX driver bug that |b| is executed
// independent of |a|'s value. // independent of |a|'s value.
SH_UNFOLD_SHORT_CIRCUIT = 0x10000, SH_UNFOLD_SHORT_CIRCUIT = 0x10000,
// This flag initializes varyings without static use in vertex shader
// at the beginning of main(), and has no effects in the fragment shader.
// It is intended as a workaround for drivers which incorrectly optimize
// out such varyings and cause a link failure.
SH_INIT_VARYINGS_WITHOUT_STATIC_USE = 0x20000,
} ShCompileOptions; } ShCompileOptions;
// Defines alternate strategies for implementing array index clamping. // Defines alternate strategies for implementing array index clamping.
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "compiler/translator/DetectCallDepth.h" #include "compiler/translator/DetectCallDepth.h"
#include "compiler/translator/ForLoopUnroll.h" #include "compiler/translator/ForLoopUnroll.h"
#include "compiler/translator/Initialize.h" #include "compiler/translator/Initialize.h"
#include "compiler/translator/InitializeGLPosition.h"
#include "compiler/translator/InitializeParseContext.h" #include "compiler/translator/InitializeParseContext.h"
#include "compiler/translator/InitializeVariables.h"
#include "compiler/translator/MapLongVariableNames.h" #include "compiler/translator/MapLongVariableNames.h"
#include "compiler/translator/ParseContext.h" #include "compiler/translator/ParseContext.h"
#include "compiler/translator/RenameFunction.h" #include "compiler/translator/RenameFunction.h"
...@@ -30,43 +30,51 @@ bool isWebGLBasedSpec(ShShaderSpec spec) ...@@ -30,43 +30,51 @@ bool isWebGLBasedSpec(ShShaderSpec spec)
} }
namespace { namespace {
class TScopedPoolAllocator { class TScopedPoolAllocator
public: {
TScopedPoolAllocator(TPoolAllocator* allocator) : mAllocator(allocator) { public:
TScopedPoolAllocator(TPoolAllocator* allocator) : mAllocator(allocator)
{
mAllocator->push(); mAllocator->push();
SetGlobalPoolAllocator(mAllocator); SetGlobalPoolAllocator(mAllocator);
} }
~TScopedPoolAllocator() { ~TScopedPoolAllocator()
{
SetGlobalPoolAllocator(NULL); SetGlobalPoolAllocator(NULL);
mAllocator->pop(); mAllocator->pop();
} }
private: private:
TPoolAllocator* mAllocator; TPoolAllocator* mAllocator;
}; };
class TScopedSymbolTableLevel { class TScopedSymbolTableLevel
public: {
TScopedSymbolTableLevel(TSymbolTable* table) : mTable(table) { public:
TScopedSymbolTableLevel(TSymbolTable* table) : mTable(table)
{
ASSERT(mTable->atBuiltInLevel()); ASSERT(mTable->atBuiltInLevel());
mTable->push(); mTable->push();
} }
~TScopedSymbolTableLevel() { ~TScopedSymbolTableLevel()
{
while (!mTable->atBuiltInLevel()) while (!mTable->atBuiltInLevel())
mTable->pop(); mTable->pop();
} }
private: private:
TSymbolTable* mTable; TSymbolTable* mTable;
}; };
} // namespace } // namespace
TShHandleBase::TShHandleBase() { TShHandleBase::TShHandleBase()
{
allocator.push(); allocator.push();
SetGlobalPoolAllocator(&allocator); SetGlobalPoolAllocator(&allocator);
} }
TShHandleBase::~TShHandleBase() { TShHandleBase::~TShHandleBase()
{
SetGlobalPoolAllocator(NULL); SetGlobalPoolAllocator(NULL);
allocator.popAll(); allocator.popAll();
} }
...@@ -156,7 +164,8 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -156,7 +164,8 @@ bool TCompiler::compile(const char* const shaderStrings[],
shaderVersion = parseContext.getShaderVersion(); shaderVersion = parseContext.getShaderVersion();
if (success) { if (success)
{
TIntermNode* root = parseContext.treeRoot; TIntermNode* root = parseContext.treeRoot;
success = intermediate.postProcess(root); success = intermediate.postProcess(root);
...@@ -198,26 +207,31 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -198,26 +207,31 @@ bool TCompiler::compile(const char* const shaderStrings[],
if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) && hashFunction == NULL) if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) && hashFunction == NULL)
mapLongVariableNames(root); mapLongVariableNames(root);
if (success && shaderType == SH_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION)) { if (success && shaderType == SH_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION))
InitializeGLPosition initGLPosition; initializeGLPosition(root);
root->traverse(&initGLPosition);
}
if (success && (compileOptions & SH_UNFOLD_SHORT_CIRCUIT)) { if (success && (compileOptions & SH_UNFOLD_SHORT_CIRCUIT))
{
UnfoldShortCircuitAST unfoldShortCircuit; UnfoldShortCircuitAST unfoldShortCircuit;
root->traverse(&unfoldShortCircuit); root->traverse(&unfoldShortCircuit);
unfoldShortCircuit.updateTree(); unfoldShortCircuit.updateTree();
} }
if (success && (compileOptions & SH_VARIABLES)) { if (success && (compileOptions & SH_VARIABLES))
{
collectVariables(root); collectVariables(root);
if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS) { if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
{
success = enforcePackingRestrictions(); success = enforcePackingRestrictions();
if (!success) { if (!success)
{
infoSink.info.prefix(EPrefixError); infoSink.info.prefix(EPrefixError);
infoSink.info << "too many uniforms"; infoSink.info << "too many uniforms";
} }
} }
if (success && shaderType == SH_VERTEX_SHADER &&
(compileOptions & SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
initializeVaryingsWithoutStaticUse(root);
} }
if (success && (compileOptions & SH_INTERMEDIATE_TREE)) if (success && (compileOptions & SH_INTERMEDIATE_TREE))
...@@ -268,12 +282,14 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources) ...@@ -268,12 +282,14 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
symbolTable.setDefaultPrecision(integer, EbpHigh); symbolTable.setDefaultPrecision(integer, EbpHigh);
symbolTable.setDefaultPrecision(floatingPoint, EbpHigh); symbolTable.setDefaultPrecision(floatingPoint, EbpHigh);
break; break;
default: assert(false && "Language not supported"); default:
assert(false && "Language not supported");
} }
// We set defaults for all the sampler types, even those that are // We set defaults for all the sampler types, even those that are
// only available if an extension exists. // only available if an extension exists.
for (int samplerType = EbtGuardSamplerBegin + 1; for (int samplerType = EbtGuardSamplerBegin + 1;
samplerType < EbtGuardSamplerEnd; ++samplerType) { samplerType < EbtGuardSamplerEnd; ++samplerType)
{
sampler.type = static_cast<TBasicType>(samplerType); sampler.type = static_cast<TBasicType>(samplerType);
symbolTable.setDefaultPrecision(sampler, EbpLow); symbolTable.setDefaultPrecision(sampler, EbpLow);
} }
...@@ -305,7 +321,8 @@ bool TCompiler::detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool lim ...@@ -305,7 +321,8 @@ bool TCompiler::detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool lim
{ {
DetectCallDepth detect(infoSink, limitCallStackDepth, maxCallStackDepth); DetectCallDepth detect(infoSink, limitCallStackDepth, maxCallStackDepth);
root->traverse(&detect); root->traverse(&detect);
switch (detect.detectCallDepth()) { switch (detect.detectCallDepth())
{
case DetectCallDepth::kErrorNone: case DetectCallDepth::kErrorNone:
return true; return true;
case DetectCallDepth::kErrorMissingMain: case DetectCallDepth::kErrorMissingMain:
...@@ -339,7 +356,8 @@ void TCompiler::rewriteCSSShader(TIntermNode* root) ...@@ -339,7 +356,8 @@ void TCompiler::rewriteCSSShader(TIntermNode* root)
root->traverse(&renamer); root->traverse(&renamer);
} }
bool TCompiler::validateLimitations(TIntermNode* root) { bool TCompiler::validateLimitations(TIntermNode* root)
{
ValidateLimitations validate(shaderType, infoSink.info); ValidateLimitations validate(shaderType, infoSink.info);
root->traverse(&validate); root->traverse(&validate);
return validate.numErrors() == 0; return validate.numErrors() == 0;
...@@ -347,26 +365,30 @@ bool TCompiler::validateLimitations(TIntermNode* root) { ...@@ -347,26 +365,30 @@ bool TCompiler::validateLimitations(TIntermNode* root) {
bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph) bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph)
{ {
if (shaderSpec != SH_WEBGL_SPEC) { if (shaderSpec != SH_WEBGL_SPEC)
{
infoSink.info << "Timing restrictions must be enforced under the WebGL spec."; infoSink.info << "Timing restrictions must be enforced under the WebGL spec.";
return false; return false;
} }
if (shaderType == SH_FRAGMENT_SHADER) { if (shaderType == SH_FRAGMENT_SHADER)
{
TDependencyGraph graph(root); TDependencyGraph graph(root);
// Output any errors first. // Output any errors first.
bool success = enforceFragmentShaderTimingRestrictions(graph); bool success = enforceFragmentShaderTimingRestrictions(graph);
// Then, output the dependency graph. // Then, output the dependency graph.
if (outputGraph) { if (outputGraph)
{
TDependencyGraphOutput output(infoSink.info); TDependencyGraphOutput output(infoSink.info);
output.outputAllSpanningTrees(graph); output.outputAllSpanningTrees(graph);
} }
return success; return success;
} }
else { else
{
return enforceVertexShaderTimingRestrictions(root); return enforceVertexShaderTimingRestrictions(root);
} }
} }
...@@ -386,7 +408,8 @@ bool TCompiler::limitExpressionComplexity(TIntermNode* root) ...@@ -386,7 +408,8 @@ bool TCompiler::limitExpressionComplexity(TIntermNode* root)
samplerSymbol->traverse(&graphTraverser); samplerSymbol->traverse(&graphTraverser);
} }
if (traverser.getMaxDepth() > maxExpressionComplexity) { if (traverser.getMaxDepth() > maxExpressionComplexity)
{
infoSink.info << "Expression too complex."; infoSink.info << "Expression too complex.";
return false; return false;
} }
...@@ -419,6 +442,70 @@ bool TCompiler::enforcePackingRestrictions() ...@@ -419,6 +442,70 @@ bool TCompiler::enforcePackingRestrictions()
return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms); return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
} }
void TCompiler::initializeGLPosition(TIntermNode* root)
{
InitializeVariables::InitVariableInfoList variables;
InitializeVariables::InitVariableInfo var(
"gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4));
variables.push_back(var);
InitializeVariables initializer(variables);
root->traverse(&initializer);
}
void TCompiler::initializeVaryingsWithoutStaticUse(TIntermNode* root)
{
InitializeVariables::InitVariableInfoList variables;
for (size_t ii = 0; ii < varyings.size(); ++ii)
{
const TVariableInfo& varying = varyings[ii];
if (varying.staticUse)
continue;
unsigned char size = 0;
bool matrix = false;
switch (varying.type)
{
case SH_FLOAT:
size = 1;
break;
case SH_FLOAT_VEC2:
size = 2;
break;
case SH_FLOAT_VEC3:
size = 3;
break;
case SH_FLOAT_VEC4:
size = 4;
break;
case SH_FLOAT_MAT2:
size = 2;
matrix = true;
break;
case SH_FLOAT_MAT3:
size = 3;
matrix = true;
break;
case SH_FLOAT_MAT4:
size = 4;
matrix = true;
break;
default:
ASSERT(false);
}
TType type(EbtFloat, EbpUndefined, EvqVaryingOut, size, matrix, varying.isArray);
TString name = varying.name.c_str();
if (varying.isArray)
{
type.setArraySize(varying.size);
name = name.substr(0, name.find_first_of('['));
}
InitializeVariables::InitVariableInfo var(name, type);
variables.push_back(var);
}
InitializeVariables initializer(variables);
root->traverse(&initializer);
}
void TCompiler::mapLongVariableNames(TIntermNode* root) void TCompiler::mapLongVariableNames(TIntermNode* root)
{ {
ASSERT(longNameMap); ASSERT(longNameMap);
......
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "compiler/translator/InitializeGLPosition.h"
#include "compiler/translator/compilerdebug.h"
bool InitializeGLPosition::visitAggregate(Visit visit, TIntermAggregate* node)
{
bool visitChildren = !mCodeInserted;
switch (node->getOp())
{
case EOpSequence: break;
case EOpFunction:
{
// Function definition.
ASSERT(visit == PreVisit);
if (node->getName() == "main(")
{
TIntermSequence &sequence = node->getSequence();
ASSERT((sequence.size() == 1) || (sequence.size() == 2));
TIntermAggregate *body = NULL;
if (sequence.size() == 1)
{
body = new TIntermAggregate(EOpSequence);
sequence.push_back(body);
}
else
{
body = sequence[1]->getAsAggregate();
}
ASSERT(body);
insertCode(body->getSequence());
mCodeInserted = true;
}
break;
}
default: visitChildren = false; break;
}
return visitChildren;
}
void InitializeGLPosition::insertCode(TIntermSequence& sequence)
{
TIntermBinary *binary = new TIntermBinary(EOpAssign);
sequence.insert(sequence.begin(), binary);
TIntermSymbol *left = new TIntermSymbol(
0, "gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4));
binary->setLeft(left);
ConstantUnion *u = new ConstantUnion[4];
for (int ii = 0; ii < 3; ++ii)
u[ii].setFConst(0.0f);
u[3].setFConst(1.0f);
TIntermConstantUnion *right = new TIntermConstantUnion(
u, TType(EbtFloat, EbpUndefined, EvqConst, 4));
binary->setRight(right);
}
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "compiler/translator/InitializeVariables.h"
#include "compiler/translator/compilerdebug.h"
namespace
{
TIntermConstantUnion* constructFloatConstUnionNode(const TType& type)
{
TType myType = type;
unsigned char size = myType.getNominalSize();
if (myType.isMatrix())
size *= size;
ConstantUnion *u = new ConstantUnion[size];
for (int ii = 0; ii < size; ++ii)
u[ii].setFConst(0.0f);
myType.clearArrayness();
myType.setQualifier(EvqConst);
TIntermConstantUnion *node = new TIntermConstantUnion(u, myType);
return node;
}
TIntermConstantUnion* constructIndexNode(int index)
{
ConstantUnion *u = new ConstantUnion[1];
u[0].setIConst(index);
TType type(EbtInt, EbpUndefined, EvqConst, 1);
TIntermConstantUnion *node = new TIntermConstantUnion(u, type);
return node;
}
} // namespace anonymous
bool InitializeVariables::visitAggregate(Visit visit, TIntermAggregate* node)
{
bool visitChildren = !mCodeInserted;
switch (node->getOp())
{
case EOpSequence:
break;
case EOpFunction:
{
// Function definition.
ASSERT(visit == PreVisit);
if (node->getName() == "main(")
{
TIntermSequence &sequence = node->getSequence();
ASSERT((sequence.size() == 1) || (sequence.size() == 2));
TIntermAggregate *body = NULL;
if (sequence.size() == 1)
{
body = new TIntermAggregate(EOpSequence);
sequence.push_back(body);
}
else
{
body = sequence[1]->getAsAggregate();
}
ASSERT(body);
insertInitCode(body->getSequence());
mCodeInserted = true;
}
break;
}
default:
visitChildren = false;
break;
}
return visitChildren;
}
void InitializeVariables::insertInitCode(TIntermSequence& sequence)
{
for (size_t ii = 0; ii < mVariables.size(); ++ii)
{
const InitVariableInfo& varInfo = mVariables[ii];
if (varInfo.type.isArray())
{
for (int index = varInfo.type.getArraySize() - 1; index >= 0; --index)
{
TIntermBinary *assign = new TIntermBinary(EOpAssign);
sequence.insert(sequence.begin(), assign);
TIntermBinary *indexDirect = new TIntermBinary(EOpIndexDirect);
TIntermSymbol *symbol = new TIntermSymbol(0, varInfo.name, varInfo.type);
indexDirect->setLeft(symbol);
TIntermConstantUnion *indexNode = constructIndexNode(index);
indexDirect->setRight(indexNode);
assign->setLeft(indexDirect);
TIntermConstantUnion *zeroConst = constructFloatConstUnionNode(varInfo.type);
assign->setRight(zeroConst);
}
}
else
{
TIntermBinary *assign = new TIntermBinary(EOpAssign);
sequence.insert(sequence.begin(), assign);
TIntermSymbol *symbol = new TIntermSymbol(0, varInfo.name, varInfo.type);
assign->setLeft(symbol);
TIntermConstantUnion *zeroConst = constructFloatConstUnionNode(varInfo.type);
assign->setRight(zeroConst);
}
}
}
...@@ -4,17 +4,34 @@ ...@@ -4,17 +4,34 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
#ifndef COMPILER_INITIALIZE_GL_POSITION_H_ #ifndef COMPILER_INITIALIZE_VARIABLES_H_
#define COMPILER_INITIALIZE_GL_POSITION_H_ #define COMPILER_INITIALIZE_VARIABLES_H_
#include "compiler/translator/intermediate.h" #include "compiler/translator/intermediate.h"
class InitializeGLPosition : public TIntermTraverser class InitializeVariables : public TIntermTraverser
{ {
public: public:
InitializeGLPosition() : mCodeInserted(false) { } struct InitVariableInfo
{
protected: TString name;
TType type;
InitVariableInfo(const TString& _name, const TType& _type)
: name(_name),
type(_type)
{
}
};
typedef TVector<InitVariableInfo> InitVariableInfoList;
InitializeVariables(const InitVariableInfoList& vars)
: mCodeInserted(false),
mVariables(vars)
{
}
protected:
virtual bool visitBinary(Visit visit, TIntermBinary* node) { return false; } virtual bool visitBinary(Visit visit, TIntermBinary* node) { return false; }
virtual bool visitUnary(Visit visit, TIntermUnary* node) { return false; } virtual bool visitUnary(Visit visit, TIntermUnary* node) { return false; }
virtual bool visitSelection(Visit visit, TIntermSelection* node) { return false; } virtual bool visitSelection(Visit visit, TIntermSelection* node) { return false; }
...@@ -23,11 +40,11 @@ protected: ...@@ -23,11 +40,11 @@ protected:
virtual bool visitAggregate(Visit visit, TIntermAggregate* node); virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
private: private:
// Insert AST node in the beginning of main() for "gl_Position = vec4(0.0, 0.0, 0.0, 1.0);". void insertInitCode(TIntermSequence& sequence);
void insertCode(TIntermSequence& sequence);
InitVariableInfoList mVariables;
bool mCodeInserted; bool mCodeInserted;
}; };
#endif // COMPILER_INITIALIZE_GL_POSITION_H_ #endif // COMPILER_INITIALIZE_VARIABLES_H_
...@@ -103,6 +103,16 @@ protected: ...@@ -103,6 +103,16 @@ protected:
// Returns true if, after applying the packing rules in the GLSL 1.017 spec // Returns true if, after applying the packing rules in the GLSL 1.017 spec
// Appendix A, section 7, the shader does not use too many uniforms. // Appendix A, section 7, the shader does not use too many uniforms.
bool enforcePackingRestrictions(); bool enforcePackingRestrictions();
// Insert statements to initialize varyings without static use in the beginning
// of main(). It is to work around a Mac driver where such varyings in a vertex
// shader may be optimized out incorrectly at compile time, causing a link failure.
// This function should only be applied to vertex shaders.
void initializeVaryingsWithoutStaticUse(TIntermNode* root);
// Insert gl_Position = vec4(0,0,0,0) to the beginning of main().
// It is to work around a Linux driver bug where missing this causes compile failure
// while spec says it is allowed.
// This function should only be applied to vertex shaders.
void initializeGLPosition(TIntermNode* root);
// Returns true if the shader passes the restrictions that aim to prevent timing attacks. // Returns true if the shader passes the restrictions that aim to prevent timing attacks.
bool enforceTimingRestrictions(TIntermNode* root, bool outputGraph); bool enforceTimingRestrictions(TIntermNode* root, bool outputGraph);
// Returns true if the shader does not use samplers. // Returns true if the shader does not use samplers.
......
...@@ -163,10 +163,12 @@ void getBuiltInVariableInfo(const TType& type, ...@@ -163,10 +163,12 @@ void getBuiltInVariableInfo(const TType& type,
varInfo.name = (name + "[0]").c_str(); varInfo.name = (name + "[0]").c_str();
varInfo.mappedName = (mappedName + "[0]").c_str(); varInfo.mappedName = (mappedName + "[0]").c_str();
varInfo.size = type.getArraySize(); varInfo.size = type.getArraySize();
varInfo.isArray = true;
} else { } else {
varInfo.name = name.c_str(); varInfo.name = name.c_str();
varInfo.mappedName = mappedName.c_str(); varInfo.mappedName = mappedName.c_str();
varInfo.size = 1; varInfo.size = 1;
varInfo.isArray = false;
} }
varInfo.precision = type.getPrecision(); varInfo.precision = type.getPrecision();
varInfo.type = getVariableDataType(type); varInfo.type = getVariableDataType(type);
...@@ -214,6 +216,7 @@ TVariableInfo* findVariable(const TType& type, ...@@ -214,6 +216,7 @@ TVariableInfo* findVariable(const TType& type,
TVariableInfo::TVariableInfo() TVariableInfo::TVariableInfo()
: type(SH_NONE), : type(SH_NONE),
size(0), size(0),
isArray(false),
precision(EbpUndefined), precision(EbpUndefined),
staticUse(false) staticUse(false)
{ {
...@@ -222,6 +225,7 @@ TVariableInfo::TVariableInfo() ...@@ -222,6 +225,7 @@ TVariableInfo::TVariableInfo()
TVariableInfo::TVariableInfo(ShDataType type, int size) TVariableInfo::TVariableInfo(ShDataType type, int size)
: type(type), : type(type),
size(size), size(size),
isArray(false),
precision(EbpUndefined), precision(EbpUndefined),
staticUse(false) staticUse(false)
{ {
......
...@@ -20,6 +20,7 @@ struct TVariableInfo { ...@@ -20,6 +20,7 @@ struct TVariableInfo {
TPersistString mappedName; TPersistString mappedName;
ShDataType type; ShDataType type;
int size; int size;
bool isArray;
TPrecision precision; TPrecision precision;
bool staticUse; bool staticUse;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment