Add non-square mat support to the shader language interface.

TRAC #23081 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2397 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 50733334
......@@ -37,7 +37,7 @@ extern "C" {
// Version number for shader translation API.
// It is incremented everytime the API changes.
#define ANGLE_SH_VERSION 112
#define ANGLE_SH_VERSION 113
//
// The names of the following enums have been derived by replacing GL prefix
......@@ -102,6 +102,12 @@ typedef enum {
SH_FLOAT_MAT2 = 0x8B5A,
SH_FLOAT_MAT3 = 0x8B5B,
SH_FLOAT_MAT4 = 0x8B5C,
SH_FLOAT_MAT2x3 = 0x8B65,
SH_FLOAT_MAT2x4 = 0x8B66,
SH_FLOAT_MAT3x2 = 0x8B67,
SH_FLOAT_MAT3x4 = 0x8B68,
SH_FLOAT_MAT4x2 = 0x8B69,
SH_FLOAT_MAT4x3 = 0x8B6A,
SH_SAMPLER_2D = 0x8B5E,
SH_SAMPLER_CUBE = 0x8B60,
SH_SAMPLER_2D_RECT_ARB = 0x8B63,
......
......@@ -333,6 +333,12 @@ void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType, bool mapLongV
case SH_FLOAT_MAT2: typeName = "GL_FLOAT_MAT2"; break;
case SH_FLOAT_MAT3: typeName = "GL_FLOAT_MAT3"; break;
case SH_FLOAT_MAT4: typeName = "GL_FLOAT_MAT4"; break;
case SH_FLOAT_MAT2x3: typeName = "GL_FLOAT_MAT2x3"; break;
case SH_FLOAT_MAT3x2: typeName = "GL_FLOAT_MAT3x2"; break;
case SH_FLOAT_MAT4x2: typeName = "GL_FLOAT_MAT4x2"; break;
case SH_FLOAT_MAT2x4: typeName = "GL_FLOAT_MAT2x4"; break;
case SH_FLOAT_MAT3x4: typeName = "GL_FLOAT_MAT3x4"; break;
case SH_FLOAT_MAT4x3: typeName = "GL_FLOAT_MAT4x3"; break;
case SH_SAMPLER_2D: typeName = "GL_SAMPLER_2D"; break;
case SH_SAMPLER_CUBE: typeName = "GL_SAMPLER_CUBE"; break;
case SH_SAMPLER_EXTERNAL_OES: typeName = "GL_SAMPLER_EXTERNAL_OES"; break;
......
......@@ -19,11 +19,32 @@ static ShDataType getVariableDataType(const TType& type)
switch (type.getBasicType()) {
case EbtFloat:
if (type.isMatrix()) {
switch (type.getRows()) {
case 2: return SH_FLOAT_MAT2;
case 3: return SH_FLOAT_MAT3;
case 4: return SH_FLOAT_MAT4;
default: UNREACHABLE();
switch (type.getCols())
{
case 2:
switch (type.getRows())
{
case 2: return SH_FLOAT_MAT2;
case 3: return SH_FLOAT_MAT2x3;
case 4: return SH_FLOAT_MAT2x4;
default: UNREACHABLE();
}
case 3:
switch (type.getRows())
{
case 2: return SH_FLOAT_MAT3x2;
case 3: return SH_FLOAT_MAT3;
case 4: return SH_FLOAT_MAT3x4;
default: UNREACHABLE();
}
case 4:
switch (type.getRows())
{
case 2: return SH_FLOAT_MAT4x2;
case 3: return SH_FLOAT_MAT4x3;
case 4: return SH_FLOAT_MAT4;
default: UNREACHABLE();
}
}
} else if (type.isVector()) {
switch (type.getNominalSize()) {
......
......@@ -13,6 +13,10 @@ int GetSortOrder(ShDataType type)
{
switch (type) {
case SH_FLOAT_MAT4:
case SH_FLOAT_MAT2x4:
case SH_FLOAT_MAT3x4:
case SH_FLOAT_MAT4x2:
case SH_FLOAT_MAT4x3:
return 0;
case SH_FLOAT_MAT2:
return 1;
......@@ -21,6 +25,8 @@ int GetSortOrder(ShDataType type)
case SH_BOOL_VEC4:
return 2;
case SH_FLOAT_MAT3:
case SH_FLOAT_MAT2x3:
case SH_FLOAT_MAT3x2:
return 3;
case SH_FLOAT_VEC3:
case SH_INT_VEC3:
......@@ -50,11 +56,17 @@ int VariablePacker::GetNumComponentsPerRow(ShDataType type)
switch (type) {
case SH_FLOAT_MAT4:
case SH_FLOAT_MAT2:
case SH_FLOAT_MAT2x4:
case SH_FLOAT_MAT3x4:
case SH_FLOAT_MAT4x2:
case SH_FLOAT_MAT4x3:
case SH_FLOAT_VEC4:
case SH_INT_VEC4:
case SH_BOOL_VEC4:
return 4;
case SH_FLOAT_MAT3:
case SH_FLOAT_MAT2x3:
case SH_FLOAT_MAT3x2:
case SH_FLOAT_VEC3:
case SH_INT_VEC3:
case SH_BOOL_VEC3:
......@@ -81,8 +93,14 @@ int VariablePacker::GetNumRows(ShDataType type)
{
switch (type) {
case SH_FLOAT_MAT4:
case SH_FLOAT_MAT2x4:
case SH_FLOAT_MAT3x4:
case SH_FLOAT_MAT4x3:
case SH_FLOAT_MAT4x2:
return 4;
case SH_FLOAT_MAT3:
case SH_FLOAT_MAT2x3:
case SH_FLOAT_MAT3x2:
return 3;
case SH_FLOAT_MAT2:
return 2;
......
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