summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-08-05 12:59:44 +0300
committerAndrew Knight <andrew.knight@digia.com>2014-08-05 16:43:22 +0200
commita6a12d8c0fc918972c15268f749ecc7c90b95d6c (patch)
treecb6d986d30ef97e932ab51768854d5d9b46729d3 /src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp
parent14f9c09542bd6cc19430473da9ce4c68f239ec7d (diff)
ANGLE: upgrade to 2.1~07d49ef5350a
This version of ANGLE provides partial ES3 support, numerous bug fixes, and several potentially useful vendor extensions. All patches have been rebased. The following changes are noted: 0000-General-fixes-for-ANGLE-2.1.patch contains compile fixes for the new ANGLE 0004-Make-it-possible-to-link-ANGLE-statically-for-single.patch has incorporated patch 0015. 0007-Make-DX9-DX11-mutually-exclusive.patch has been removed as it was fixed upstream. 0007-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch has been moved up to fill the patch number gap. 0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch now contains patch 0014 and 0017. 0013-ANGLE-Allow-for-universal-program-binaries.patch has been removed as it is no longer relevant. 0014-ANGLE-D3D11-Fix-internal-index-buffer-for-level-9-ha.patch has been merged with patch 0010. 0015-ANGLE-Don-t-export-DLLMain-functions-for-static-buil.patch has been merged with patch 0004. 0016-ANGLE-WinRT-Call-Trim-when-application-suspends.patch has been removed and will be replaced by a follow-up patch using a different technique. 0017-ANGLE-D3D11-Don-t-use-mipmaps-in-level-9-textures.patch has been merged with patch 0010. 0018-ANGLE-WinRT-Create-swap-chain-using-physical-resolut.patch has been removed and will be replaced by a follow-up patch extending the EGL_ANGLE_window_fixed_size extension. 0019-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch is now patch 0007. [ChangeLog][Third-party libraries] ANGLE has been upgraded to version 2.1, bringing partial support for OpenGL ES3 over Direct3D 11, numerous bug fixes, and several new vendor extensions. Change-Id: I6d95ce1480462d67228d83c1e5c74a1706b5b21c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp')
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp190
1 files changed, 80 insertions, 110 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp b/src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp
index 5634d86337..faaf0115fc 100644
--- a/src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp
@@ -4,121 +4,78 @@
// found in the LICENSE file.
//
#include "compiler/translator/VariablePacker.h"
+#include "angle_gl.h"
+#include "common/utilities.h"
#include <algorithm>
-#include "compiler/translator/ShHandle.h"
-namespace {
-int GetSortOrder(ShDataType type)
+int VariablePacker::GetNumComponentsPerRow(sh::GLenum type)
{
- switch (type) {
- case SH_FLOAT_MAT4:
- return 0;
- case SH_FLOAT_MAT2:
- return 1;
- case SH_FLOAT_VEC4:
- case SH_INT_VEC4:
- case SH_BOOL_VEC4:
- return 2;
- case SH_FLOAT_MAT3:
- return 3;
- case SH_FLOAT_VEC3:
- case SH_INT_VEC3:
- case SH_BOOL_VEC3:
- return 4;
- case SH_FLOAT_VEC2:
- case SH_INT_VEC2:
- case SH_BOOL_VEC2:
- return 5;
- case SH_FLOAT:
- case SH_INT:
- case SH_BOOL:
- case SH_SAMPLER_2D:
- case SH_SAMPLER_CUBE:
- case SH_SAMPLER_EXTERNAL_OES:
- case SH_SAMPLER_2D_RECT_ARB:
- return 6;
- default:
- ASSERT(false);
- return 7;
+ switch (type)
+ {
+ case GL_FLOAT_MAT4:
+ case GL_FLOAT_MAT2:
+ case GL_FLOAT_MAT2x4:
+ case GL_FLOAT_MAT3x4:
+ case GL_FLOAT_MAT4x2:
+ case GL_FLOAT_MAT4x3:
+ case GL_FLOAT_VEC4:
+ case GL_INT_VEC4:
+ case GL_BOOL_VEC4:
+ case GL_UNSIGNED_INT_VEC4:
+ return 4;
+ case GL_FLOAT_MAT3:
+ case GL_FLOAT_MAT2x3:
+ case GL_FLOAT_MAT3x2:
+ case GL_FLOAT_VEC3:
+ case GL_INT_VEC3:
+ case GL_BOOL_VEC3:
+ case GL_UNSIGNED_INT_VEC3:
+ return 3;
+ case GL_FLOAT_VEC2:
+ case GL_INT_VEC2:
+ case GL_BOOL_VEC2:
+ case GL_UNSIGNED_INT_VEC2:
+ return 2;
+ default:
+ ASSERT(gl::VariableComponentCount(type) == 1);
+ return 1;
}
}
-} // namespace
-int VariablePacker::GetNumComponentsPerRow(ShDataType type)
+int VariablePacker::GetNumRows(sh::GLenum type)
{
- switch (type) {
- case SH_FLOAT_MAT4:
- case SH_FLOAT_MAT2:
- case SH_FLOAT_VEC4:
- case SH_INT_VEC4:
- case SH_BOOL_VEC4:
- return 4;
- case SH_FLOAT_MAT3:
- case SH_FLOAT_VEC3:
- case SH_INT_VEC3:
- case SH_BOOL_VEC3:
- return 3;
- case SH_FLOAT_VEC2:
- case SH_INT_VEC2:
- case SH_BOOL_VEC2:
- return 2;
- case SH_FLOAT:
- case SH_INT:
- case SH_BOOL:
- case SH_SAMPLER_2D:
- case SH_SAMPLER_CUBE:
- case SH_SAMPLER_EXTERNAL_OES:
- case SH_SAMPLER_2D_RECT_ARB:
- return 1;
- default:
- ASSERT(false);
- return 5;
+ switch (type)
+ {
+ case GL_FLOAT_MAT4:
+ case GL_FLOAT_MAT2x4:
+ case GL_FLOAT_MAT3x4:
+ case GL_FLOAT_MAT4x3:
+ case GL_FLOAT_MAT4x2:
+ return 4;
+ case GL_FLOAT_MAT3:
+ case GL_FLOAT_MAT2x3:
+ case GL_FLOAT_MAT3x2:
+ return 3;
+ case GL_FLOAT_MAT2:
+ return 2;
+ default:
+ ASSERT(gl::VariableRowCount(type) == 1);
+ return 1;
}
}
-int VariablePacker::GetNumRows(ShDataType type)
+struct TVariableInfoComparer
{
- switch (type) {
- case SH_FLOAT_MAT4:
- return 4;
- case SH_FLOAT_MAT3:
- return 3;
- case SH_FLOAT_MAT2:
- return 2;
- case SH_FLOAT_VEC4:
- case SH_INT_VEC4:
- case SH_BOOL_VEC4:
- case SH_FLOAT_VEC3:
- case SH_INT_VEC3:
- case SH_BOOL_VEC3:
- case SH_FLOAT_VEC2:
- case SH_INT_VEC2:
- case SH_BOOL_VEC2:
- case SH_FLOAT:
- case SH_INT:
- case SH_BOOL:
- case SH_SAMPLER_2D:
- case SH_SAMPLER_CUBE:
- case SH_SAMPLER_EXTERNAL_OES:
- case SH_SAMPLER_2D_RECT_ARB:
- return 1;
- default:
- ASSERT(false);
- return 100000;
- }
-}
-
-struct TVariableInfoComparer {
- bool operator()(const TVariableInfo& lhs, const TVariableInfo& rhs) const
+ bool operator()(const sh::ShaderVariable &lhs, const sh::ShaderVariable &rhs) const
{
- int lhsSortOrder = GetSortOrder(lhs.type);
- int rhsSortOrder = GetSortOrder(rhs.type);
+ int lhsSortOrder = gl::VariableSortOrder(lhs.type);
+ int rhsSortOrder = gl::VariableSortOrder(rhs.type);
if (lhsSortOrder != rhsSortOrder) {
return lhsSortOrder < rhsSortOrder;
}
// Sort by largest first.
- return lhs.size > rhs.size;
+ return lhs.arraySize > rhs.arraySize;
}
};
@@ -189,13 +146,23 @@ bool VariablePacker::searchColumn(int column, int numRows, int* destRow, int* de
return true;
}
-bool VariablePacker::CheckVariablesWithinPackingLimits(int maxVectors, const TVariableInfoList& in_variables)
+template <typename VarT>
+bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int maxVectors,
+ const std::vector<VarT> &in_variables)
{
ASSERT(maxVectors > 0);
maxRows_ = maxVectors;
topNonFullRow_ = 0;
bottomNonFullRow_ = maxRows_ - 1;
- TVariableInfoList variables(in_variables);
+ std::vector<VarT> variables(in_variables);
+
+ // Check whether each variable fits in the available vectors.
+ for (size_t i = 0; i < variables.size(); i++) {
+ const sh::ShaderVariable &variable = variables[i];
+ if (variable.elementCount() > maxVectors / GetNumRows(variable.type)) {
+ return false;
+ }
+ }
// As per GLSL 1.017 Appendix A, Section 7 variables are packed in specific
// order by type, then by size of array, largest first.
@@ -206,11 +173,11 @@ bool VariablePacker::CheckVariablesWithinPackingLimits(int maxVectors, const TVa
// Packs the 4 column variables.
size_t ii = 0;
for (; ii < variables.size(); ++ii) {
- const TVariableInfo& variable = variables[ii];
+ const sh::ShaderVariable &variable = variables[ii];
if (GetNumComponentsPerRow(variable.type) != 4) {
break;
}
- topNonFullRow_ += GetNumRows(variable.type) * variable.size;
+ topNonFullRow_ += GetNumRows(variable.type) * variable.elementCount();
}
if (topNonFullRow_ > maxRows_) {
@@ -220,11 +187,11 @@ bool VariablePacker::CheckVariablesWithinPackingLimits(int maxVectors, const TVa
// Packs the 3 column variables.
int num3ColumnRows = 0;
for (; ii < variables.size(); ++ii) {
- const TVariableInfo& variable = variables[ii];
+ const sh::ShaderVariable &variable = variables[ii];
if (GetNumComponentsPerRow(variable.type) != 3) {
break;
}
- num3ColumnRows += GetNumRows(variable.type) * variable.size;
+ num3ColumnRows += GetNumRows(variable.type) * variable.elementCount();
}
if (topNonFullRow_ + num3ColumnRows > maxRows_) {
@@ -239,11 +206,11 @@ bool VariablePacker::CheckVariablesWithinPackingLimits(int maxVectors, const TVa
int rowsAvailableInColumns01 = twoColumnRowsAvailable;
int rowsAvailableInColumns23 = twoColumnRowsAvailable;
for (; ii < variables.size(); ++ii) {
- const TVariableInfo& variable = variables[ii];
+ const sh::ShaderVariable &variable = variables[ii];
if (GetNumComponentsPerRow(variable.type) != 2) {
break;
}
- int numRows = GetNumRows(variable.type) * variable.size;
+ int numRows = GetNumRows(variable.type) * variable.elementCount();
if (numRows <= rowsAvailableInColumns01) {
rowsAvailableInColumns01 -= numRows;
} else if (numRows <= rowsAvailableInColumns23) {
@@ -263,9 +230,9 @@ bool VariablePacker::CheckVariablesWithinPackingLimits(int maxVectors, const TVa
// Packs the 1 column variables.
for (; ii < variables.size(); ++ii) {
- const TVariableInfo& variable = variables[ii];
+ const sh::ShaderVariable &variable = variables[ii];
ASSERT(1 == GetNumComponentsPerRow(variable.type));
- int numRows = GetNumRows(variable.type) * variable.size;
+ int numRows = GetNumRows(variable.type) * variable.elementCount();
int smallestColumn = -1;
int smallestSize = maxRows_ + 1;
int topRow = -1;
@@ -293,5 +260,8 @@ bool VariablePacker::CheckVariablesWithinPackingLimits(int maxVectors, const TVa
return true;
}
-
-
+// Instantiate all possible variable packings
+template bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int, const std::vector<sh::ShaderVariable> &);
+template bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int, const std::vector<sh::Attribute> &);
+template bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int, const std::vector<sh::Uniform> &);
+template bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int, const std::vector<sh::Varying> &);