mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 02:28:10 +02:00
Add queries to get the glsl_type of a row or column of a matrix
This commit is contained in:
parent
664da2510a
commit
252127c379
1 changed files with 34 additions and 6 deletions
40
glsl_types.h
40
glsl_types.h
|
|
@ -39,6 +39,12 @@
|
|||
#define GLSL_TYPE_VOID 8
|
||||
#define GLSL_TYPE_ERROR 9
|
||||
|
||||
extern const struct glsl_type *const glsl_error_type;
|
||||
extern const struct glsl_type *const glsl_int_type;
|
||||
extern const struct glsl_type *const glsl_uint_type;
|
||||
extern const struct glsl_type *const glsl_float_type;
|
||||
extern const struct glsl_type *const glsl_bool_type;
|
||||
|
||||
#define is_numeric_base_type(b) \
|
||||
(((b) >= GLSL_TYPE_UINT) && ((b) <= GLSL_TYPE_FLOAT))
|
||||
|
||||
|
|
@ -223,6 +229,34 @@ struct glsl_type {
|
|||
return base_type == GLSL_TYPE_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the full type of a matrix row
|
||||
*
|
||||
* \return
|
||||
* If the type is not a matrix, \c glsl_error_type is returned. Otherwise
|
||||
* a type matching the rows of the matrix is returned.
|
||||
*/
|
||||
const glsl_type *row_type() const
|
||||
{
|
||||
return is_matrix()
|
||||
? get_instance(base_type, matrix_rows, 1)
|
||||
: glsl_error_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the full type of a matrix column
|
||||
*
|
||||
* \return
|
||||
* If the type is not a matrix, \c glsl_error_type is returned. Otherwise
|
||||
* a type matching the columns of the matrix is returned.
|
||||
*/
|
||||
const glsl_type *column_type() const
|
||||
{
|
||||
return is_matrix()
|
||||
? get_instance(base_type, vector_elements, 1)
|
||||
: glsl_error_type;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* \name Pointers to various type singletons
|
||||
|
|
@ -254,12 +288,6 @@ extern "C" {
|
|||
extern void
|
||||
_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
|
||||
|
||||
extern const struct glsl_type *const glsl_error_type;
|
||||
extern const struct glsl_type *const glsl_int_type;
|
||||
extern const struct glsl_type *const glsl_uint_type;
|
||||
extern const struct glsl_type *const glsl_float_type;
|
||||
extern const struct glsl_type *const glsl_bool_type;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue