Hash :
d57e0db3
Author :
Date :
2015-04-24T15:05:08
Remove separate compilerdebug.h in favor of debug.h
This unifies the behavior across the compiler and rest of ANGLE - for
example, one can use #define ANGLE_TEST_CONFIG to disable UNIMPLEMENTED
asserts in both the compiler and the rest of ANGLE. Compiler traces from
asserts also go to the same TRACE_OUTPUT_FILE as other traces instead of
being directed through ParseContext.
The compiler build already includes the common sources, so no changes to
build config are needed.
The original version of this change was reverted due to release mode
build issues. This version adds UNUSED_ASSERTION_VARIABLE where needed.
TEST=angle_unittests, angle_end2end_tests,
dEQP-GLES3.functional.shaders.*
BUG=angleproject:983
Change-Id: I36929020a04251b8bc834fbb3c069e10128c3082
Reviewed-on: https://chromium-review.googlesource.com/267411
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "common/debug.h"
#include "compiler/translator/RegenerateStructNames.h"
void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol)
{
ASSERT(symbol);
TType *type = symbol->getTypePointer();
ASSERT(type);
TStructure *userType = type->getStruct();
if (!userType)
return;
if (mSymbolTable.findBuiltIn(userType->name(), mShaderVersion))
{
// Built-in struct, do not touch it.
return;
}
int uniqueId = userType->uniqueId();
ASSERT(mScopeDepth > 0);
if (mScopeDepth == 1)
{
// If a struct is defined at global scope, we don't map its name.
// This is because at global level, the struct might be used to
// declare a uniform, so the same name needs to stay the same for
// vertex/fragment shaders. However, our mapping uses internal ID,
// which will be different for the same struct in vertex/fragment
// shaders.
// This is OK because names for any structs defined in other scopes
// will begin with "_webgl", which is reserved. So there will be
// no conflicts among unmapped struct names from global scope and
// mapped struct names from other scopes.
// However, we need to keep track of these global structs, so if a
// variable is used in a local scope, we don't try to modify the
// struct name through that variable.
mDeclaredGlobalStructs.insert(uniqueId);
return;
}
if (mDeclaredGlobalStructs.count(uniqueId) > 0)
return;
// Map {name} to _webgl_struct_{uniqueId}_{name}.
const char kPrefix[] = "_webgl_struct_";
if (userType->name().find(kPrefix) == 0)
{
// The name has already been regenerated.
return;
}
std::string id = Str(uniqueId);
TString tmp = kPrefix + TString(id.c_str());
tmp += "_" + userType->name();
userType->setName(tmp);
}
bool RegenerateStructNames::visitAggregate(Visit, TIntermAggregate *aggregate)
{
ASSERT(aggregate);
switch (aggregate->getOp())
{
case EOpSequence:
++mScopeDepth;
{
TIntermSequence &sequence = *(aggregate->getSequence());
for (size_t ii = 0; ii < sequence.size(); ++ii)
{
TIntermNode *node = sequence[ii];
ASSERT(node != NULL);
node->traverse(this);
}
}
--mScopeDepth;
return false;
default:
return true;
}
}