Add Variable Packing checks to ANGLE
BUG=373
TEST=unit tests
git-svn-id: https://angleproject.googlecode.com/svn/trunk@1317 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/Compiler.cpp b/src/compiler/Compiler.cpp
index cab8056..9e7f75c 100644
--- a/src/compiler/Compiler.cpp
+++ b/src/compiler/Compiler.cpp
@@ -14,6 +14,7 @@
#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"
@@ -113,6 +114,9 @@
bool TCompiler::Init(const ShBuiltInResources& resources)
{
+ maxUniformVectors = (shaderType == SH_VERTEX_SHADER) ?
+ resources.MaxVertexUniformVectors :
+ resources.MaxFragmentUniformVectors;
TScopedPoolAllocator scopedAlloc(&allocator, false);
// Generate built-in symbol table.
@@ -192,8 +196,15 @@
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);
@@ -310,6 +321,12 @@
root->traverse(&collect);
}
+bool TCompiler::enforcePackingRestrictions()
+{
+ VariablePacker packer;
+ return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
+}
+
void TCompiler::mapLongVariableNames(TIntermNode* root)
{
ASSERT(longNameMap);