[gtk+/wip/otte/shader: 3/151] gsksltype: Add matrix type
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/shader: 3/151] gsksltype: Add matrix type
- Date: Mon, 23 Oct 2017 01:19:30 +0000 (UTC)
commit b831968e0639ce183a8c96ec2b5df7a57fb900fb
Author: Benjamin Otte <otte redhat com>
Date: Sun Sep 17 15:09:06 2017 +0200
gsksltype: Add matrix type
gsk/gskslnode.c | 248 ++++++++++++++++++++++++++++++++++++++++++++++--
gsk/gsksltype.c | 239 ++++++++++++++++++++++++++++++++++++++++++++++-
gsk/gsksltypeprivate.h | 8 ++
3 files changed, 485 insertions(+), 10 deletions(-)
---
diff --git a/gsk/gskslnode.c b/gsk/gskslnode.c
index bea5a6f..27461ef 100644
--- a/gsk/gskslnode.c
+++ b/gsk/gskslnode.c
@@ -350,18 +350,89 @@ gsk_sl_node_operation_print (GskSlNode *node,
}
static GskSlType *
-gsk_sl_node_operation_get_return_type (GskSlNode *node)
+gsk_sl_node_bitwise_type_check (GskSlPreprocessor *stream,
+ GskSlType *ltype,
+ GskSlType *rtype)
{
- GskSlNodeOperation *operation = (GskSlNodeOperation *) node;
- GskSlType *ltype, *rtype;
+ GskSlScalarType lscalar, rscalar;
- ltype = gsk_sl_node_get_return_type (operation->left);
- rtype = gsk_sl_node_get_return_type (operation->right);
+ lscalar = gsk_sl_type_get_scalar_type (ltype);
+ if (lscalar != GSK_SL_INT && lscalar != GSK_SL_UINT)
+ {
+ if (stream)
+ gsk_sl_preprocessor_error (stream, "Left operand is not an integer type.");
+ return NULL;
+ }
+ rscalar = gsk_sl_type_get_scalar_type (ltype);
+ if (rscalar != GSK_SL_INT && rscalar != GSK_SL_UINT)
+ {
+ if (stream)
+ gsk_sl_preprocessor_error (stream, "Right operand is not an integer type.");
+ return NULL;
+ }
+ if (!gsk_sl_type_is_scalar (ltype) && !gsk_sl_type_is_vector (ltype))
+ {
+ if (stream)
+ gsk_sl_preprocessor_error (stream, "Left operand is neither a scalar nor a vector.");
+ return NULL;
+ }
+ if (!gsk_sl_type_is_scalar (rtype) && !gsk_sl_type_is_vector (rtype))
+ {
+ if (stream)
+ gsk_sl_preprocessor_error (stream, "Right operand is neither a scalar nor a vector.");
+ return NULL;
+ }
+ if (gsk_sl_type_is_vector (ltype) && gsk_sl_type_is_vector (rtype) &&
+ gsk_sl_type_get_length (ltype) != gsk_sl_type_get_length (rtype))
+ {
+ if (stream)
+ gsk_sl_preprocessor_error (stream, "Vector operands do not have the same length.");
+ return NULL;
+ }
- if (gsk_sl_type_can_convert (ltype, rtype))
- return ltype;
+ rscalar = lscalar == GSK_SL_UINT ? GSK_SL_UINT : rscalar;
+ if (gsk_sl_type_is_scalar (ltype) && gsk_sl_type_is_scalar (rtype))
+ return gsk_sl_type_get_scalar (rscalar);
else
- return rtype;
+ return gsk_sl_type_get_vector (rscalar, gsk_sl_type_get_length (ltype));
+}
+
+static GskSlType *
+gsk_sl_node_operation_get_return_type (GskSlNode *node)
+{
+ GskSlNodeOperation *operation = (GskSlNodeOperation *) node;
+
+ switch (operation->op)
+ {
+ case GSK_SL_OPERATION_MUL:
+ case GSK_SL_OPERATION_DIV:
+ case GSK_SL_OPERATION_MOD:
+ case GSK_SL_OPERATION_ADD:
+ case GSK_SL_OPERATION_SUB:
+ case GSK_SL_OPERATION_LSHIFT:
+ case GSK_SL_OPERATION_RSHIFT:
+ case GSK_SL_OPERATION_LESS:
+ case GSK_SL_OPERATION_GREATER:
+ case GSK_SL_OPERATION_LESS_EQUAL:
+ case GSK_SL_OPERATION_GREATER_EQUAL:
+ case GSK_SL_OPERATION_EQUAL:
+ case GSK_SL_OPERATION_NOT_EQUAL:
+ g_assert_not_reached ();
+ return NULL;
+ case GSK_SL_OPERATION_AND:
+ case GSK_SL_OPERATION_XOR:
+ case GSK_SL_OPERATION_OR:
+ return gsk_sl_node_bitwise_type_check (NULL,
+ gsk_sl_node_get_return_type (operation->left),
+ gsk_sl_node_get_return_type (operation->right));
+ case GSK_SL_OPERATION_LOGICAL_AND:
+ case GSK_SL_OPERATION_LOGICAL_XOR:
+ case GSK_SL_OPERATION_LOGICAL_OR:
+ return gsk_sl_type_get_scalar (GSK_SL_BOOL);
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
}
static gboolean
@@ -713,11 +784,146 @@ gsk_sl_node_parse_primary_expression (GskSlNodeProgram *program,
}
static GskSlNode *
+gsk_sl_node_parse_equality_expression (GskSlNodeProgram *program,
+ GskSlScope *scope,
+ GskSlPreprocessor *stream)
+{
+ return gsk_sl_node_parse_primary_expression (program, scope, stream);
+}
+
+static GskSlNode *
+gsk_sl_node_parse_and_expression (GskSlNodeProgram *program,
+ GskSlScope *scope,
+ GskSlPreprocessor *stream)
+{
+ const GskSlToken *token;
+ GskSlNode *node;
+ GskSlNodeOperation *operation;
+
+ node = gsk_sl_node_parse_equality_expression (program, scope, stream);
+ if (node == NULL)
+ return NULL;
+
+ while (TRUE)
+ {
+ token = gsk_sl_preprocessor_get (stream);
+ if (!gsk_sl_token_is (token, GSK_SL_TOKEN_AMPERSAND))
+ return node;
+
+ operation = gsk_sl_node_new (GskSlNodeOperation, &GSK_SL_NODE_OPERATION);
+ operation->left = node;
+ operation->op = GSK_SL_OPERATION_AND;
+ gsk_sl_preprocessor_consume (stream, (GskSlNode *) operation);
+ operation->right = gsk_sl_node_parse_equality_expression (program, scope, stream);
+ if (operation->right == NULL)
+ {
+ gsk_sl_node_ref (node);
+ gsk_sl_node_unref ((GskSlNode *) operation);
+ }
+ else if (!gsk_sl_node_bitwise_type_check (stream,
+ gsk_sl_node_get_return_type (operation->left),
+ gsk_sl_node_get_return_type (operation->right)))
+ {
+ gsk_sl_node_ref (node);
+ gsk_sl_node_unref ((GskSlNode *) operation);
+ }
+ else
+ {
+ node = (GskSlNode *) operation;
+ }
+ }
+
+ return node;
+}
+
+static GskSlNode *
+gsk_sl_node_parse_xor_expression (GskSlNodeProgram *program,
+ GskSlScope *scope,
+ GskSlPreprocessor *stream)
+{
+ const GskSlToken *token;
+ GskSlNode *node;
+ GskSlNodeOperation *operation;
+
+ node = gsk_sl_node_parse_and_expression (program, scope, stream);
+ if (node == NULL)
+ return NULL;
+
+ while (TRUE)
+ {
+ token = gsk_sl_preprocessor_get (stream);
+ if (!gsk_sl_token_is (token, GSK_SL_TOKEN_CARET))
+ return node;
+
+ operation = gsk_sl_node_new (GskSlNodeOperation, &GSK_SL_NODE_OPERATION);
+ operation->left = node;
+ operation->op = GSK_SL_OPERATION_XOR;
+ gsk_sl_preprocessor_consume (stream, (GskSlNode *) operation);
+ operation->right = gsk_sl_node_parse_and_expression (program, scope, stream);
+ if (operation->right == NULL)
+ {
+ gsk_sl_node_ref (node);
+ gsk_sl_node_unref ((GskSlNode *) operation);
+ }
+ else if (!gsk_sl_node_bitwise_type_check (stream,
+ gsk_sl_node_get_return_type (operation->left),
+ gsk_sl_node_get_return_type (operation->right)))
+ {
+ gsk_sl_node_ref (node);
+ gsk_sl_node_unref ((GskSlNode *) operation);
+ }
+ else
+ {
+ node = (GskSlNode *) operation;
+ }
+ }
+
+ return node;
+}
+
+static GskSlNode *
gsk_sl_node_parse_or_expression (GskSlNodeProgram *program,
GskSlScope *scope,
GskSlPreprocessor *stream)
{
- return gsk_sl_node_parse_primary_expression (program, scope, stream);
+ const GskSlToken *token;
+ GskSlNode *node;
+ GskSlNodeOperation *operation;
+
+ node = gsk_sl_node_parse_xor_expression (program, scope, stream);
+ if (node == NULL)
+ return NULL;
+
+ while (TRUE)
+ {
+ token = gsk_sl_preprocessor_get (stream);
+ if (!gsk_sl_token_is (token, GSK_SL_TOKEN_VERTICAL_BAR))
+ return node;
+
+ operation = gsk_sl_node_new (GskSlNodeOperation, &GSK_SL_NODE_OPERATION);
+ operation->left = node;
+ operation->op = GSK_SL_OPERATION_OR;
+ gsk_sl_preprocessor_consume (stream, (GskSlNode *) operation);
+ operation->right = gsk_sl_node_parse_xor_expression (program, scope, stream);
+ if (operation->right == NULL)
+ {
+ gsk_sl_node_ref (node);
+ gsk_sl_node_unref ((GskSlNode *) operation);
+ }
+ else if (!gsk_sl_node_bitwise_type_check (stream,
+ gsk_sl_node_get_return_type (operation->left),
+ gsk_sl_node_get_return_type (operation->right)))
+ {
+ gsk_sl_node_ref (node);
+ gsk_sl_node_unref ((GskSlNode *) operation);
+ }
+ else
+ {
+ node = (GskSlNode *) operation;
+ }
+ }
+
+ return node;
}
static GskSlNode *
@@ -1072,6 +1278,30 @@ gsk_sl_node_parse_function_definition (GskSlNodeProgram *program,
case GSK_SL_TOKEN_DVEC2:
case GSK_SL_TOKEN_DVEC3:
case GSK_SL_TOKEN_DVEC4:
+ case GSK_SL_TOKEN_MAT2:
+ case GSK_SL_TOKEN_MAT3:
+ case GSK_SL_TOKEN_MAT4:
+ case GSK_SL_TOKEN_DMAT2:
+ case GSK_SL_TOKEN_DMAT3:
+ case GSK_SL_TOKEN_DMAT4:
+ case GSK_SL_TOKEN_MAT2X2:
+ case GSK_SL_TOKEN_MAT2X3:
+ case GSK_SL_TOKEN_MAT2X4:
+ case GSK_SL_TOKEN_MAT3X2:
+ case GSK_SL_TOKEN_MAT3X3:
+ case GSK_SL_TOKEN_MAT3X4:
+ case GSK_SL_TOKEN_MAT4X2:
+ case GSK_SL_TOKEN_MAT4X3:
+ case GSK_SL_TOKEN_MAT4X4:
+ case GSK_SL_TOKEN_DMAT2X2:
+ case GSK_SL_TOKEN_DMAT2X3:
+ case GSK_SL_TOKEN_DMAT2X4:
+ case GSK_SL_TOKEN_DMAT3X2:
+ case GSK_SL_TOKEN_DMAT3X3:
+ case GSK_SL_TOKEN_DMAT3X4:
+ case GSK_SL_TOKEN_DMAT4X2:
+ case GSK_SL_TOKEN_DMAT4X3:
+ case GSK_SL_TOKEN_DMAT4X4:
node = gsk_sl_node_parse_declaration (program, function->scope, stream);
if (node)
{
diff --git a/gsk/gsksltype.c b/gsk/gsksltype.c
index 6c2a084..5045b2e 100644
--- a/gsk/gsksltype.c
+++ b/gsk/gsksltype.c
@@ -42,6 +42,7 @@ struct _GskSlTypeClass {
void (* print) (const GskSlType *type,
GString *string);
GskSlScalarType (* get_scalar_type) (const GskSlType *type);
+ guint (* get_length) (const GskSlType *type);
gboolean (* can_convert) (const GskSlType *target,
const GskSlType *source);
};
@@ -128,6 +129,12 @@ gsk_sl_type_scalar_get_scalar_type (const GskSlType *type)
return scalar->scalar;
}
+static guint
+gsk_sl_type_scalar_get_length (const GskSlType *type)
+{
+ return 0;
+}
+
static gboolean
gsk_sl_type_scalar_can_convert (const GskSlType *target,
const GskSlType *source)
@@ -145,6 +152,7 @@ static const GskSlTypeClass GSK_SL_TYPE_SCALAR = {
gsk_sl_type_scalar_free,
gsk_sl_type_scalar_print,
gsk_sl_type_scalar_get_scalar_type,
+ gsk_sl_type_scalar_get_length,
gsk_sl_type_scalar_can_convert
};
@@ -205,6 +213,14 @@ gsk_sl_type_vector_get_scalar_type (const GskSlType *type)
return vector->scalar;
}
+static guint
+gsk_sl_type_vector_get_length (const GskSlType *type)
+{
+ GskSlTypeVector *vector = (GskSlTypeVector *) type;
+
+ return vector->length;
+}
+
static gboolean
gsk_sl_type_vector_can_convert (const GskSlType *target,
const GskSlType *source)
@@ -225,9 +241,83 @@ static const GskSlTypeClass GSK_SL_TYPE_VECTOR = {
gsk_sl_type_vector_free,
gsk_sl_type_vector_print,
gsk_sl_type_vector_get_scalar_type,
+ gsk_sl_type_vector_get_length,
gsk_sl_type_vector_can_convert
};
+/* MATRIX */
+
+typedef struct _GskSlTypeMatrix GskSlTypeMatrix;
+
+struct _GskSlTypeMatrix {
+ GskSlType parent;
+
+ GskSlScalarType scalar;
+ guint columns;
+ guint rows;
+};
+
+static void
+gsk_sl_type_matrix_free (GskSlType *type)
+{
+ g_assert_not_reached ();
+}
+
+static void
+gsk_sl_type_matrix_print (const GskSlType *type,
+ GString *string)
+{
+ const GskSlTypeMatrix *matrix = (const GskSlTypeMatrix *) type;
+
+ g_string_append (string, matrix->scalar == GSK_SL_DOUBLE ? "dmat" : "mat");
+ g_string_append_printf (string, "%u", matrix->columns);
+ if (matrix->columns != matrix->rows)
+ {
+ g_string_append_printf (string, "x%u", matrix->rows);
+ }
+}
+
+static GskSlScalarType
+gsk_sl_type_matrix_get_scalar_type (const GskSlType *type)
+{
+ const GskSlTypeMatrix *matrix = (const GskSlTypeMatrix *) type;
+
+ return matrix->scalar;
+}
+
+static guint
+gsk_sl_type_matrix_get_length (const GskSlType *type)
+{
+ GskSlTypeMatrix *matrix = (GskSlTypeMatrix *) type;
+
+ return matrix->columns;
+}
+
+static gboolean
+gsk_sl_type_matrix_can_convert (const GskSlType *target,
+ const GskSlType *source)
+{
+ const GskSlTypeMatrix *target_matrix = (const GskSlTypeMatrix *) target;
+ const GskSlTypeMatrix *source_matrix = (const GskSlTypeMatrix *) source;
+
+ if (target->class != source->class)
+ return FALSE;
+
+ if (target_matrix->rows != source_matrix->rows ||
+ target_matrix->columns != source_matrix->columns)
+ return FALSE;
+
+ return gsk_sl_scalar_type_can_convert (target_matrix->scalar, source_matrix->scalar);
+}
+
+static const GskSlTypeClass GSK_SL_TYPE_MATRIX = {
+ gsk_sl_type_matrix_free,
+ gsk_sl_type_matrix_print,
+ gsk_sl_type_matrix_get_scalar_type,
+ gsk_sl_type_matrix_get_length,
+ gsk_sl_type_matrix_can_convert
+};
+
GskSlType *
gsk_sl_type_new_parse (GskSlPreprocessor *stream)
{
@@ -301,6 +391,66 @@ gsk_sl_type_new_parse (GskSlPreprocessor *stream)
case GSK_SL_TOKEN_DVEC4:
type = gsk_sl_type_ref (gsk_sl_type_get_vector (GSK_SL_DOUBLE, 4));
break;
+ case GSK_SL_TOKEN_MAT2:
+ case GSK_SL_TOKEN_MAT2X2:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_FLOAT, 2, 2));
+ break;
+ case GSK_SL_TOKEN_MAT2X3:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_FLOAT, 2, 3));
+ break;
+ case GSK_SL_TOKEN_MAT2X4:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_FLOAT, 2, 4));
+ break;
+ case GSK_SL_TOKEN_MAT3X2:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_FLOAT, 3, 2));
+ break;
+ case GSK_SL_TOKEN_MAT3:
+ case GSK_SL_TOKEN_MAT3X3:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_FLOAT, 3, 3));
+ break;
+ case GSK_SL_TOKEN_MAT3X4:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_FLOAT, 3, 4));
+ break;
+ case GSK_SL_TOKEN_MAT4X2:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_FLOAT, 4, 2));
+ break;
+ case GSK_SL_TOKEN_MAT4X3:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_FLOAT, 4, 3));
+ break;
+ case GSK_SL_TOKEN_MAT4:
+ case GSK_SL_TOKEN_MAT4X4:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_FLOAT, 4, 4));
+ break;
+ case GSK_SL_TOKEN_DMAT2:
+ case GSK_SL_TOKEN_DMAT2X2:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_DOUBLE, 2, 2));
+ break;
+ case GSK_SL_TOKEN_DMAT2X3:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_DOUBLE, 2, 3));
+ break;
+ case GSK_SL_TOKEN_DMAT2X4:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_DOUBLE, 2, 4));
+ break;
+ case GSK_SL_TOKEN_DMAT3X2:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_DOUBLE, 3, 2));
+ break;
+ case GSK_SL_TOKEN_DMAT3:
+ case GSK_SL_TOKEN_DMAT3X3:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_DOUBLE, 3, 3));
+ break;
+ case GSK_SL_TOKEN_DMAT3X4:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_DOUBLE, 3, 4));
+ break;
+ case GSK_SL_TOKEN_DMAT4X2:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_DOUBLE, 4, 2));
+ break;
+ case GSK_SL_TOKEN_DMAT4X3:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_DOUBLE, 4, 3));
+ break;
+ case GSK_SL_TOKEN_DMAT4:
+ case GSK_SL_TOKEN_DMAT4X4:
+ type = gsk_sl_type_ref (gsk_sl_type_get_matrix (GSK_SL_DOUBLE, 4, 4));
+ break;
default:
gsk_sl_preprocessor_error (stream, "Expected type specifier");
return NULL;
@@ -365,6 +515,64 @@ gsk_sl_type_get_vector (GskSlScalarType scalar,
return &builtin_vector_types[length - 2][scalar].parent;
}
+static GskSlTypeMatrix
+builtin_matrix_types[3][3][2] = {
+ {
+ {
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_FLOAT, 2, 2 },
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_DOUBLE, 2, 2 }
+ },
+ {
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_FLOAT, 2, 3 },
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_DOUBLE, 2, 3 }
+ },
+ {
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_FLOAT, 2, 4 },
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_DOUBLE, 2, 4 }
+ },
+ },
+ {
+ {
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_FLOAT, 3, 2 },
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_DOUBLE, 3, 2 }
+ },
+ {
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_FLOAT, 3, 3 },
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_DOUBLE, 3, 3 }
+ },
+ {
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_FLOAT, 3, 4 },
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_DOUBLE, 3, 4 }
+ },
+ },
+ {
+ {
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_FLOAT, 4, 2 },
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_DOUBLE, 4, 2 }
+ },
+ {
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_FLOAT, 4, 3 },
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_DOUBLE, 4, 3 }
+ },
+ {
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_FLOAT, 4, 4 },
+ { { &GSK_SL_TYPE_MATRIX, 1 }, GSK_SL_DOUBLE, 4, 4 }
+ },
+ },
+};
+
+GskSlType *
+gsk_sl_type_get_matrix (GskSlScalarType scalar,
+ guint columns,
+ guint rows)
+{
+ g_assert (scalar == GSK_SL_FLOAT || scalar == GSK_SL_DOUBLE);
+ g_assert (columns >= 2 && columns <= 4);
+ g_assert (rows >= 2 && rows <= 4);
+
+ return &builtin_matrix_types[columns - 2][rows - 2][scalar == GSK_SL_FLOAT ? 0 : 1].parent;
+}
+
GskSlType *
gsk_sl_type_ref (GskSlType *type)
{
@@ -406,9 +614,38 @@ gsk_sl_type_to_string (const GskSlType *type)
}
gboolean
+gsk_sl_type_is_scalar (const GskSlType *type)
+{
+ return type->class == &GSK_SL_TYPE_SCALAR;
+}
+
+gboolean
+gsk_sl_type_is_vector (const GskSlType *type)
+{
+ return type->class == &GSK_SL_TYPE_VECTOR;
+}
+
+gboolean
+gsk_sl_type_is_matrix (const GskSlType *type)
+{
+ return type->class == &GSK_SL_TYPE_MATRIX;
+}
+
+GskSlScalarType
+gsk_sl_type_get_scalar_type (const GskSlType *type)
+{
+ return type->class->get_scalar_type (type);
+}
+
+GskSlScalarType
+gsk_sl_type_get_length (const GskSlType *type)
+{
+ return type->class->get_length (type);
+}
+
+gboolean
gsk_sl_type_can_convert (const GskSlType *target,
const GskSlType *source)
{
return target->class->can_convert (target, source);
}
-
diff --git a/gsk/gsksltypeprivate.h b/gsk/gsksltypeprivate.h
index 5f66763..b7166ac 100644
--- a/gsk/gsksltypeprivate.h
+++ b/gsk/gsksltypeprivate.h
@@ -38,6 +38,9 @@ GskSlType * gsk_sl_type_new_parse (GskSlPreprocess
GskSlType * gsk_sl_type_get_scalar (GskSlScalarType scalar);
GskSlType * gsk_sl_type_get_vector (GskSlScalarType scalar,
guint length);
+GskSlType * gsk_sl_type_get_matrix (GskSlScalarType scalar,
+ guint columns,
+ guint rows);
GskSlType * gsk_sl_type_ref (GskSlType *type);
void gsk_sl_type_unref (GskSlType *type);
@@ -46,6 +49,11 @@ void gsk_sl_type_print (const GskSlType
GString *string);
char * gsk_sl_type_to_string (const GskSlType *type);
+gboolean gsk_sl_type_is_scalar (const GskSlType *type);
+gboolean gsk_sl_type_is_vector (const GskSlType *type);
+gboolean gsk_sl_type_is_matrix (const GskSlType *type);
+GskSlScalarType gsk_sl_type_get_scalar_type (const GskSlType *type);
+guint gsk_sl_type_get_length (const GskSlType *type);
gboolean gsk_sl_type_can_convert (const GskSlType *target,
const GskSlType *source);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]