.emtcode TYPE_SPECIFIER_STRUCT 24
.emtcode TYPE_SPECIFIER_TYPENAME 25
+/* OpenGL 2.1 */
+.emtcode TYPE_SPECIFIER_MAT23 26
+.emtcode TYPE_SPECIFIER_MAT32 27
+.emtcode TYPE_SPECIFIER_MAT24 28
+.emtcode TYPE_SPECIFIER_MAT42 29
+.emtcode TYPE_SPECIFIER_MAT34 30
+.emtcode TYPE_SPECIFIER_MAT43 31
+
+
/* structure field */
.emtcode FIELD_NONE 0
.emtcode FIELD_NEXT 1
| "mat2"
| "mat3"
| "mat4"
+ | "mat2x3"
+ | "mat3x2"
+ | "mat2x4"
+ | "mat4x2"
+ | "mat3x4"
+ | "mat4x3"
| "sampler1D"
| "sampler2D"
| "sampler3D"
"mat2" .emit TYPE_SPECIFIER_MAT2 .or
"mat3" .emit TYPE_SPECIFIER_MAT3 .or
"mat4" .emit TYPE_SPECIFIER_MAT4 .or
+ "mat2x3" .emit TYPE_SPECIFIER_MAT23 .or
+ "mat3x2" .emit TYPE_SPECIFIER_MAT32 .or
+ "mat2x4" .emit TYPE_SPECIFIER_MAT24 .or
+ "mat4x2" .emit TYPE_SPECIFIER_MAT42 .or
+ "mat3x4" .emit TYPE_SPECIFIER_MAT34 .or
+ "mat4x3" .emit TYPE_SPECIFIER_MAT43 .or
"sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
"sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
"sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
".emtcode TYPE_SPECIFIER_SAMPLER2DRECTSHADOW 23\n"
".emtcode TYPE_SPECIFIER_STRUCT 24\n"
".emtcode TYPE_SPECIFIER_TYPENAME 25\n"
+".emtcode TYPE_SPECIFIER_MAT23 26\n"
+".emtcode TYPE_SPECIFIER_MAT32 27\n"
+".emtcode TYPE_SPECIFIER_MAT24 28\n"
+".emtcode TYPE_SPECIFIER_MAT42 29\n"
+".emtcode TYPE_SPECIFIER_MAT34 30\n"
+".emtcode TYPE_SPECIFIER_MAT43 31\n"
".emtcode FIELD_NONE 0\n"
".emtcode FIELD_NEXT 1\n"
".emtcode FIELD_ARRAY 2\n"
" \"mat2\" .emit TYPE_SPECIFIER_MAT2 .or\n"
" \"mat3\" .emit TYPE_SPECIFIER_MAT3 .or\n"
" \"mat4\" .emit TYPE_SPECIFIER_MAT4 .or\n"
+" \"mat2x3\" .emit TYPE_SPECIFIER_MAT23 .or\n"
+" \"mat3x2\" .emit TYPE_SPECIFIER_MAT32 .or\n"
+" \"mat2x4\" .emit TYPE_SPECIFIER_MAT24 .or\n"
+" \"mat4x2\" .emit TYPE_SPECIFIER_MAT42 .or\n"
+" \"mat3x4\" .emit TYPE_SPECIFIER_MAT34 .or\n"
+" \"mat4x3\" .emit TYPE_SPECIFIER_MAT43 .or\n"
" \"sampler1D\" .emit TYPE_SPECIFIER_SAMPLER1D .or\n"
" \"sampler2D\" .emit TYPE_SPECIFIER_SAMPLER2D .or\n"
" \"sampler3D\" .emit TYPE_SPECIFIER_SAMPLER3D .or\n"
return 3 * 3;
case SLANG_SPEC_MAT4:
return 4 * 4;
+ case SLANG_SPEC_MAT23:
+ case SLANG_SPEC_MAT32:
+ return 2 * 3;
+ case SLANG_SPEC_MAT24:
+ case SLANG_SPEC_MAT42:
+ return 2 * 4;
+ case SLANG_SPEC_MAT34:
+ case SLANG_SPEC_MAT43:
+ return 3 * 4;
case SLANG_SPEC_SAMPLER1D:
case SLANG_SPEC_SAMPLER2D:
case SLANG_SPEC_SAMPLER3D:
#define TYPE_SPECIFIER_SAMPLER2DRECTSHADOW 23
#define TYPE_SPECIFIER_STRUCT 24
#define TYPE_SPECIFIER_TYPENAME 25
+#define TYPE_SPECIFIER_MAT23 26
+#define TYPE_SPECIFIER_MAT32 27
+#define TYPE_SPECIFIER_MAT24 28
+#define TYPE_SPECIFIER_MAT42 29
+#define TYPE_SPECIFIER_MAT34 30
+#define TYPE_SPECIFIER_MAT43 31
+
static int
parse_type_specifier(slang_parse_ctx * C, slang_output_ctx * O,
case TYPE_SPECIFIER_MAT4:
spec->type = SLANG_SPEC_MAT4;
break;
+ case TYPE_SPECIFIER_MAT23:
+ spec->type = SLANG_SPEC_MAT23;
+ break;
+ case TYPE_SPECIFIER_MAT32:
+ spec->type = SLANG_SPEC_MAT32;
+ break;
+ case TYPE_SPECIFIER_MAT24:
+ spec->type = SLANG_SPEC_MAT24;
+ break;
+ case TYPE_SPECIFIER_MAT42:
+ spec->type = SLANG_SPEC_MAT42;
+ break;
+ case TYPE_SPECIFIER_MAT34:
+ spec->type = SLANG_SPEC_MAT34;
+ break;
+ case TYPE_SPECIFIER_MAT43:
+ spec->type = SLANG_SPEC_MAT43;
+ break;
case TYPE_SPECIFIER_SAMPLER1D:
spec->type = SLANG_SPEC_SAMPLER1D;
break;
{"mat2", SLANG_SPEC_MAT2},
{"mat3", SLANG_SPEC_MAT3},
{"mat4", SLANG_SPEC_MAT4},
+ {"mat2x3", SLANG_SPEC_MAT23},
+ {"mat3x2", SLANG_SPEC_MAT32},
+ {"mat2x4", SLANG_SPEC_MAT24},
+ {"mat4x2", SLANG_SPEC_MAT42},
+ {"mat3x4", SLANG_SPEC_MAT34},
+ {"mat4x3", SLANG_SPEC_MAT43},
{"sampler1D", SLANG_SPEC_SAMPLER1D},
{"sampler2D", SLANG_SPEC_SAMPLER2D},
{"sampler3D", SLANG_SPEC_SAMPLER3D},
return GL_FLOAT_MAT3_ARB;
case SLANG_SPEC_MAT4:
return GL_FLOAT_MAT4_ARB;
+ case SLANG_SPEC_MAT23:
+ return GL_FLOAT_MAT2x3_ARB;
+ case SLANG_SPEC_MAT32:
+ return GL_FLOAT_MAT3x2_ARB;
+ case SLANG_SPEC_MAT24:
+ return GL_FLOAT_MAT2x4_ARB;
+ case SLANG_SPEC_MAT42:
+ return GL_FLOAT_MAT4x2_ARB;
+ case SLANG_SPEC_MAT34:
+ return GL_FLOAT_MAT3x4_ARB;
+ case SLANG_SPEC_MAT43:
+ return GL_FLOAT_MAT4x3_ARB;
case SLANG_SPEC_SAMPLER1D:
return GL_SAMPLER_1D_ARB;
case SLANG_SPEC_SAMPLER2D:
case SLANG_SPEC_MAT4:
printf("mat4");
break;
+ case SLANG_SPEC_MAT23:
+ printf("mat2x3");
+ break;
+ case SLANG_SPEC_MAT32:
+ printf("mat3x2");
+ break;
+ case SLANG_SPEC_MAT24:
+ printf("mat2x4");
+ break;
+ case SLANG_SPEC_MAT42:
+ printf("mat4x2");
+ break;
+ case SLANG_SPEC_MAT34:
+ printf("mat3x4");
+ break;
+ case SLANG_SPEC_MAT43:
+ printf("mat4x3");
+ break;
case SLANG_SPEC_SAMPLER1D:
printf("sampler1D");
break;
static GLboolean
aggregate_matrix(slang_storage_aggregate * agg, slang_storage_type basic_type,
- GLuint dimension)
+ GLuint columns, GLuint rows)
{
slang_storage_array *arr = slang_storage_aggregate_push_new(agg);
if (arr == NULL)
return GL_FALSE;
arr->type = SLANG_STORE_AGGREGATE;
- arr->length = dimension;
+ arr->length = columns;
arr->aggregate =
(slang_storage_aggregate *)
slang_alloc_malloc(sizeof(slang_storage_aggregate));
arr->aggregate = NULL;
return GL_FALSE;
}
- if (!aggregate_vector(arr->aggregate, basic_type, dimension))
+ if (!aggregate_vector(arr->aggregate, basic_type, rows))
return GL_FALSE;
return GL_TRUE;
}
case SLANG_SPEC_VEC4:
return aggregate_vector(agg, SLANG_STORE_FLOAT, 4);
case SLANG_SPEC_MAT2:
- return aggregate_matrix(agg, SLANG_STORE_FLOAT, 2);
+ return aggregate_matrix(agg, SLANG_STORE_FLOAT, 2, 2);
case SLANG_SPEC_MAT3:
- return aggregate_matrix(agg, SLANG_STORE_FLOAT, 3);
+ return aggregate_matrix(agg, SLANG_STORE_FLOAT, 3, 3);
case SLANG_SPEC_MAT4:
- return aggregate_matrix(agg, SLANG_STORE_FLOAT, 4);
+ return aggregate_matrix(agg, SLANG_STORE_FLOAT, 4, 4);
+
+ case SLANG_SPEC_MAT23:
+ return aggregate_matrix(agg, SLANG_STORE_FLOAT, 2, 3);
+ case SLANG_SPEC_MAT32:
+ return aggregate_matrix(agg, SLANG_STORE_FLOAT, 3, 2);
+ case SLANG_SPEC_MAT24:
+ return aggregate_matrix(agg, SLANG_STORE_FLOAT, 2, 4);
+ case SLANG_SPEC_MAT42:
+ return aggregate_matrix(agg, SLANG_STORE_FLOAT, 4, 2);
+ case SLANG_SPEC_MAT34:
+ return aggregate_matrix(agg, SLANG_STORE_FLOAT, 3, 4);
+ case SLANG_SPEC_MAT43:
+ return aggregate_matrix(agg, SLANG_STORE_FLOAT, 4, 3);
+
case SLANG_SPEC_SAMPLER1D:
case SLANG_SPEC_SAMPLER2D:
case SLANG_SPEC_SAMPLER3D:
case SLANG_SPEC_MAT2:
case SLANG_SPEC_MAT3:
case SLANG_SPEC_MAT4:
+ case SLANG_SPEC_MAT23:
+ case SLANG_SPEC_MAT32:
+ case SLANG_SPEC_MAT24:
+ case SLANG_SPEC_MAT42:
+ case SLANG_SPEC_MAT34:
+ case SLANG_SPEC_MAT43:
return GL_TRUE;
default:
return GL_FALSE;
/**
- * Given a vector type, return the type of the vector's elements
+ * Given a vector type, return the type of the vector's elements.
+ * For a matrix, return the type of the columns.
*/
slang_type_specifier_type
_slang_type_base(slang_type_specifier_type ty)
return SLANG_SPEC_VEC3;
case SLANG_SPEC_MAT4:
return SLANG_SPEC_VEC4;
+ case SLANG_SPEC_MAT23:
+ return SLANG_SPEC_VEC3;
+ case SLANG_SPEC_MAT32:
+ return SLANG_SPEC_VEC2;
+ case SLANG_SPEC_MAT24:
+ return SLANG_SPEC_VEC4;
+ case SLANG_SPEC_MAT42:
+ return SLANG_SPEC_VEC2;
+ case SLANG_SPEC_MAT34:
+ return SLANG_SPEC_VEC4;
+ case SLANG_SPEC_MAT43:
+ return SLANG_SPEC_VEC3;
default:
return SLANG_SPEC_VOID;
}
/**
- * Return the dimensionality of a vector or matrix type.
+ * Return the dimensionality of a vector, or for a matrix, return number
+ * of columns.
*/
GLuint
_slang_type_dim(slang_type_specifier_type ty)
case SLANG_SPEC_BVEC4:
case SLANG_SPEC_MAT4:
return 4;
+
+ case SLANG_SPEC_MAT23:
+ return 2;
+ case SLANG_SPEC_MAT32:
+ return 3;
+ case SLANG_SPEC_MAT24:
+ return 2;
+ case SLANG_SPEC_MAT42:
+ return 4;
+ case SLANG_SPEC_MAT34:
+ return 3;
+ case SLANG_SPEC_MAT43:
+ return 4;
+
default:
return 0;
}
SLANG_SPEC_MAT2,
SLANG_SPEC_MAT3,
SLANG_SPEC_MAT4,
+ SLANG_SPEC_MAT23,
+ SLANG_SPEC_MAT32,
+ SLANG_SPEC_MAT24,
+ SLANG_SPEC_MAT42,
+ SLANG_SPEC_MAT34,
+ SLANG_SPEC_MAT43,
SLANG_SPEC_SAMPLER1D,
SLANG_SPEC_SAMPLER2D,
SLANG_SPEC_SAMPLER3D,