Commit 865d1451 by Jamie Madill

Consolidate varying packing sort order methods.

We were using the same list in the shader varying sorting as well as in the varying packing validation in the translator. BUG=angle:466 Change-Id: Ic11758288e7a522d7c18a293de9e137e487e3978 Reviewed-on: https://chromium-review.googlesource.com/205595Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent aa72d782
...@@ -360,6 +360,83 @@ bool IsTriangleMode(GLenum drawMode) ...@@ -360,6 +360,83 @@ bool IsTriangleMode(GLenum drawMode)
return false; return false;
} }
// [OpenGL ES SL 3.00.4] Section 11 p. 120
// Vertex Outs/Fragment Ins packing priorities
int VariableSortOrder(GLenum type)
{
switch (type)
{
// 1. Arrays of mat4 and mat4
// Non-square matrices of type matCxR consume the same space as a square
// matrix of type matN where N is the greater of C and R
case GL_FLOAT_MAT4:
case GL_FLOAT_MAT2x4:
case GL_FLOAT_MAT3x4:
case GL_FLOAT_MAT4x2:
case GL_FLOAT_MAT4x3:
return 0;
// 2. Arrays of mat2 and mat2 (since they occupy full rows)
case GL_FLOAT_MAT2:
return 1;
// 3. Arrays of vec4 and vec4
case GL_FLOAT_VEC4:
case GL_INT_VEC4:
case GL_BOOL_VEC4:
case GL_UNSIGNED_INT_VEC4:
return 2;
// 4. Arrays of mat3 and mat3
case GL_FLOAT_MAT3:
case GL_FLOAT_MAT2x3:
case GL_FLOAT_MAT3x2:
return 3;
// 5. Arrays of vec3 and vec3
case GL_FLOAT_VEC3:
case GL_INT_VEC3:
case GL_BOOL_VEC3:
case GL_UNSIGNED_INT_VEC3:
return 4;
// 6. Arrays of vec2 and vec2
case GL_FLOAT_VEC2:
case GL_INT_VEC2:
case GL_BOOL_VEC2:
case GL_UNSIGNED_INT_VEC2:
return 5;
// 7. Single component types
case GL_FLOAT:
case GL_INT:
case GL_BOOL:
case GL_UNSIGNED_INT:
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
case GL_SAMPLER_EXTERNAL_OES:
case GL_SAMPLER_2D_RECT_ARB:
case GL_SAMPLER_2D_ARRAY:
case GL_SAMPLER_3D:
case GL_INT_SAMPLER_2D:
case GL_INT_SAMPLER_3D:
case GL_INT_SAMPLER_CUBE:
case GL_INT_SAMPLER_2D_ARRAY:
case GL_UNSIGNED_INT_SAMPLER_2D:
case GL_UNSIGNED_INT_SAMPLER_3D:
case GL_UNSIGNED_INT_SAMPLER_CUBE:
case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
case GL_SAMPLER_2D_SHADOW:
case GL_SAMPLER_2D_ARRAY_SHADOW:
case GL_SAMPLER_CUBE_SHADOW:
return 6;
default:
UNREACHABLE();
return 0;
}
}
} }
std::string getTempPath() std::string getTempPath()
......
...@@ -30,6 +30,7 @@ GLenum TransposeMatrixType(GLenum type); ...@@ -30,6 +30,7 @@ GLenum TransposeMatrixType(GLenum type);
int VariableRegisterCount(GLenum type); int VariableRegisterCount(GLenum type);
int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix); int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix);
int MatrixComponentCount(GLenum type, bool isRowMajorMatrix); int MatrixComponentCount(GLenum type, bool isRowMajorMatrix);
int VariableSortOrder(GLenum type);
int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize); int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
......
...@@ -9,52 +9,6 @@ ...@@ -9,52 +9,6 @@
#include <algorithm> #include <algorithm>
namespace
{
int GetSortOrder(sh::GLenum type)
{
switch (type) {
case GL_FLOAT_MAT4:
case GL_FLOAT_MAT2x4:
case GL_FLOAT_MAT3x4:
case GL_FLOAT_MAT4x2:
case GL_FLOAT_MAT4x3:
return 0;
case GL_FLOAT_MAT2:
return 1;
case GL_FLOAT_VEC4:
case GL_INT_VEC4:
case GL_BOOL_VEC4:
return 2;
case GL_FLOAT_MAT3:
case GL_FLOAT_MAT2x3:
case GL_FLOAT_MAT3x2:
return 3;
case GL_FLOAT_VEC3:
case GL_INT_VEC3:
case GL_BOOL_VEC3:
return 4;
case GL_FLOAT_VEC2:
case GL_INT_VEC2:
case GL_BOOL_VEC2:
return 5;
case GL_FLOAT:
case GL_INT:
case GL_BOOL:
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
case GL_SAMPLER_EXTERNAL_OES:
case GL_SAMPLER_2D_RECT_ARB:
return 6;
default:
ASSERT(false);
return 7;
}
}
} // namespace
int VariablePacker::GetNumComponentsPerRow(sh::GLenum type) int VariablePacker::GetNumComponentsPerRow(sh::GLenum type)
{ {
switch (type) switch (type)
...@@ -111,11 +65,12 @@ int VariablePacker::GetNumRows(sh::GLenum type) ...@@ -111,11 +65,12 @@ int VariablePacker::GetNumRows(sh::GLenum type)
} }
} }
struct TVariableInfoComparer { struct TVariableInfoComparer
{
bool operator()(const TVariableInfo& lhs, const TVariableInfo& rhs) const bool operator()(const TVariableInfo& lhs, const TVariableInfo& rhs) const
{ {
int lhsSortOrder = GetSortOrder(lhs.type); int lhsSortOrder = gl::VariableSortOrder(lhs.type);
int rhsSortOrder = GetSortOrder(rhs.type); int rhsSortOrder = gl::VariableSortOrder(rhs.type);
if (lhsSortOrder != rhsSortOrder) { if (lhsSortOrder != rhsSortOrder) {
return lhsSortOrder < rhsSortOrder; return lhsSortOrder < rhsSortOrder;
} }
......
...@@ -402,49 +402,6 @@ rx::D3DWorkaroundType Shader::getD3DWorkarounds() const ...@@ -402,49 +402,6 @@ rx::D3DWorkaroundType Shader::getD3DWorkarounds() const
return rx::ANGLE_D3D_WORKAROUND_NONE; return rx::ANGLE_D3D_WORKAROUND_NONE;
} }
// [OpenGL ES SL 3.00.4] Section 11 p. 120
// Vertex Outs/Fragment Ins packing priorities
static const GLenum varyingPriorityList[] =
{
// 1. Arrays of mat4 and mat4
GL_FLOAT_MAT4,
// Non-square matrices of type matCxR consume the same space as a square
// matrix of type matN where N is the greater of C and R
GL_FLOAT_MAT3x4,
GL_FLOAT_MAT4x3,
GL_FLOAT_MAT2x4,
GL_FLOAT_MAT4x2,
// 2. Arrays of mat2 and mat2 (since they occupy full rows)
GL_FLOAT_MAT2,
// 3. Arrays of vec4 and vec4
GL_FLOAT_VEC4,
GL_INT_VEC4,
GL_UNSIGNED_INT_VEC4,
// 4. Arrays of mat3 and mat3
GL_FLOAT_MAT3,
GL_FLOAT_MAT2x3,
GL_FLOAT_MAT3x2,
// 5. Arrays of vec3 and vec3
GL_FLOAT_VEC3,
GL_INT_VEC3,
GL_UNSIGNED_INT_VEC3,
// 6. Arrays of vec2 and vec2
GL_FLOAT_VEC2,
GL_INT_VEC2,
GL_UNSIGNED_INT_VEC2,
// 7. Arrays of float and float
GL_FLOAT,
GL_INT,
GL_UNSIGNED_INT,
};
// true if varying x has a higher priority in packing than y // true if varying x has a higher priority in packing than y
bool Shader::compareVarying(const PackedVarying &x, const PackedVarying &y) bool Shader::compareVarying(const PackedVarying &x, const PackedVarying &y)
{ {
...@@ -459,19 +416,12 @@ bool Shader::compareVarying(const PackedVarying &x, const PackedVarying &y) ...@@ -459,19 +416,12 @@ bool Shader::compareVarying(const PackedVarying &x, const PackedVarying &y)
return false; return false;
} }
unsigned int xPriority = GL_INVALID_INDEX; if (y.type == GL_STRUCT_ANGLEX)
unsigned int yPriority = GL_INVALID_INDEX;
for (unsigned int priorityIndex = 0; priorityIndex < ArraySize(varyingPriorityList); priorityIndex++)
{ {
if (varyingPriorityList[priorityIndex] == x.type) xPriority = priorityIndex; return true;
if (varyingPriorityList[priorityIndex] == y.type) yPriority = priorityIndex;
if (xPriority != GL_INVALID_INDEX && yPriority != GL_INVALID_INDEX) break;
} }
ASSERT(xPriority != GL_INVALID_INDEX && yPriority != GL_INVALID_INDEX); return gl::VariableSortOrder(x.type) <= gl::VariableSortOrder(y.type);
return xPriority <= yPriority;
} }
int Shader::getShaderVersion() const int Shader::getShaderVersion() const
......
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