Fix matrix dimensioning
Newb GL mistake: matrices in GL are column-major. This means that vector_elements is the number of rows. Making these changes causes matrix-08.glsl to pass.
This commit is contained in:
@@ -275,7 +275,7 @@ gen_header "120"
|
|||||||
for c in 2 3 4; do
|
for c in 2 3 4; do
|
||||||
for r in 2 3 4; do
|
for r in 2 3 4; do
|
||||||
if [ $c -ne $r ]; then
|
if [ $c -ne $r ]; then
|
||||||
gen_integral_type "mat${c}x${r}" "GLSL_TYPE_FLOAT" $c $r
|
gen_integral_type "mat${c}x${r}" "GLSL_TYPE_FLOAT" $r $c
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
16
glsl_types.h
16
glsl_types.h
@@ -75,7 +75,7 @@ struct glsl_type {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned vector_elements:3; /**< 0, 2, 3, or 4 vector elements. */
|
unsigned vector_elements:3; /**< 0, 2, 3, or 4 vector elements. */
|
||||||
unsigned matrix_rows:3; /**< 0, 2, 3, or 4 matrix rows. */
|
unsigned matrix_columns:3; /**< 0, 2, 3, or 4 matrix columns. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the data type
|
* Name of the data type
|
||||||
@@ -108,11 +108,11 @@ struct glsl_type {
|
|||||||
|
|
||||||
|
|
||||||
glsl_type(unsigned base_type, unsigned vector_elements,
|
glsl_type(unsigned base_type, unsigned vector_elements,
|
||||||
unsigned matrix_rows, const char *name) :
|
unsigned matrix_columns, const char *name) :
|
||||||
base_type(base_type),
|
base_type(base_type),
|
||||||
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
|
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
|
||||||
sampler_type(0),
|
sampler_type(0),
|
||||||
vector_elements(vector_elements), matrix_rows(matrix_rows),
|
vector_elements(vector_elements), matrix_columns(matrix_columns),
|
||||||
name(name),
|
name(name),
|
||||||
length(0)
|
length(0)
|
||||||
{
|
{
|
||||||
@@ -124,7 +124,7 @@ struct glsl_type {
|
|||||||
base_type(GLSL_TYPE_SAMPLER),
|
base_type(GLSL_TYPE_SAMPLER),
|
||||||
sampler_dimensionality(dim), sampler_shadow(shadow),
|
sampler_dimensionality(dim), sampler_shadow(shadow),
|
||||||
sampler_array(array), sampler_type(type),
|
sampler_array(array), sampler_type(type),
|
||||||
vector_elements(0), matrix_rows(0),
|
vector_elements(0), matrix_columns(0),
|
||||||
name(name),
|
name(name),
|
||||||
length(0)
|
length(0)
|
||||||
{
|
{
|
||||||
@@ -136,7 +136,7 @@ struct glsl_type {
|
|||||||
base_type(GLSL_TYPE_STRUCT),
|
base_type(GLSL_TYPE_STRUCT),
|
||||||
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
|
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
|
||||||
sampler_type(0),
|
sampler_type(0),
|
||||||
vector_elements(0), matrix_rows(0),
|
vector_elements(0), matrix_columns(0),
|
||||||
name(name),
|
name(name),
|
||||||
length(num_fields)
|
length(num_fields)
|
||||||
{
|
{
|
||||||
@@ -175,7 +175,7 @@ struct glsl_type {
|
|||||||
bool is_vector() const
|
bool is_vector() const
|
||||||
{
|
{
|
||||||
return (vector_elements > 0)
|
return (vector_elements > 0)
|
||||||
&& (matrix_rows == 0)
|
&& (matrix_columns == 0)
|
||||||
&& (base_type >= GLSL_TYPE_UINT)
|
&& (base_type >= GLSL_TYPE_UINT)
|
||||||
&& (base_type <= GLSL_TYPE_BOOL);
|
&& (base_type <= GLSL_TYPE_BOOL);
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ struct glsl_type {
|
|||||||
bool is_matrix() const
|
bool is_matrix() const
|
||||||
{
|
{
|
||||||
/* GLSL only has float matrices. */
|
/* GLSL only has float matrices. */
|
||||||
return (matrix_rows > 0) && (base_type == GLSL_TYPE_FLOAT);
|
return (matrix_columns > 0) && (base_type == GLSL_TYPE_FLOAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -239,7 +239,7 @@ struct glsl_type {
|
|||||||
const glsl_type *row_type() const
|
const glsl_type *row_type() const
|
||||||
{
|
{
|
||||||
return is_matrix()
|
return is_matrix()
|
||||||
? get_instance(base_type, matrix_rows, 1)
|
? get_instance(base_type, matrix_columns, 1)
|
||||||
: glsl_error_type;
|
: glsl_error_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
ir.cpp
2
ir.cpp
@@ -59,7 +59,7 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data)
|
|||||||
{
|
{
|
||||||
const unsigned elements =
|
const unsigned elements =
|
||||||
((type->vector_elements == 0) ? 1 : type->vector_elements)
|
((type->vector_elements == 0) ? 1 : type->vector_elements)
|
||||||
* ((type->matrix_rows == 0) ? 1 : type->matrix_rows);
|
* ((type->matrix_columns == 0) ? 1 : type->matrix_columns);
|
||||||
unsigned size = 0;
|
unsigned size = 0;
|
||||||
|
|
||||||
this->type = type;
|
this->type = type;
|
||||||
|
@@ -38,7 +38,7 @@ type_compare(const glsl_type *a, const glsl_type *b)
|
|||||||
case GLSL_TYPE_FLOAT:
|
case GLSL_TYPE_FLOAT:
|
||||||
case GLSL_TYPE_BOOL:
|
case GLSL_TYPE_BOOL:
|
||||||
if ((a->vector_elements != b->vector_elements)
|
if ((a->vector_elements != b->vector_elements)
|
||||||
|| (a->matrix_rows != b->matrix_rows))
|
|| (a->matrix_columns != b->matrix_columns))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* There is no implicit conversion to or from bool.
|
/* There is no implicit conversion to or from bool.
|
||||||
|
Reference in New Issue
Block a user