Add utility methods for determining register count.
TRAC #22293
Signed-off-by: Daniel Koch
Signed-off-by: Shannon Woods
Author: Nicolas Capens
git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1621 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/Types.h b/src/compiler/Types.h
index d457667..854bb44 100644
--- a/src/compiler/Types.h
+++ b/src/compiler/Types.h
@@ -136,6 +136,43 @@
return totalSize;
}
+ int elementRegisterCount() const
+ {
+ TTypeList *structure = getStruct();
+
+ if (structure)
+ {
+ int registerCount = 0;
+
+ for (size_t i = 0; i < structure->size(); i++)
+ {
+ registerCount += (*structure)[i].type->totalRegisterCount();
+ }
+
+ return registerCount;
+ }
+ else if (isMatrix())
+ {
+ return getNominalSize();
+ }
+ else
+ {
+ return 1;
+ }
+ }
+
+ int totalRegisterCount() const
+ {
+ if (array)
+ {
+ return arraySize * elementRegisterCount();
+ }
+ else
+ {
+ return elementRegisterCount();
+ }
+ }
+
bool isMatrix() const { return matrix ? true : false; }
void setMatrix(bool m) { matrix = m; }
diff --git a/src/compiler/intermediate.h b/src/compiler/intermediate.h
index 293db94..1dbeef0 100644
--- a/src/compiler/intermediate.h
+++ b/src/compiler/intermediate.h
@@ -259,6 +259,10 @@
const char* getQualifierString() const { return type.getQualifierString(); }
TString getCompleteString() const { return type.getCompleteString(); }
+ int totalRegisterCount() const { return type.totalRegisterCount(); }
+ int elementRegisterCount() const { return type.elementRegisterCount(); }
+ int getArraySize() const { return type.getArraySize(); }
+
protected:
TType type;
};