mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 06:20:09 +01:00
Add glsl_type::get_base_type query
Retreives the glsl_type that corresponds to the base type of a numeric scalar / vector / matrix type. So vec4 returns float, etc.
This commit is contained in:
parent
7aeb6abda7
commit
bb7e00a1cd
2 changed files with 27 additions and 0 deletions
|
|
@ -142,3 +142,20 @@ _mesa_glsl_get_vector_type(unsigned base_type, unsigned vector_length)
|
|||
return glsl_error_type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const glsl_type *glsl_type::get_base_type() const
|
||||
{
|
||||
switch (base_type) {
|
||||
case GLSL_TYPE_UINT:
|
||||
return glsl_uint_type;
|
||||
case GLSL_TYPE_INT:
|
||||
return glsl_int_type;
|
||||
case GLSL_TYPE_FLOAT:
|
||||
return glsl_float_type;
|
||||
case GLSL_TYPE_BOOL:
|
||||
return glsl_bool_type;
|
||||
default:
|
||||
return glsl_error_type;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
glsl_types.h
10
glsl_types.h
|
|
@ -137,6 +137,16 @@ struct glsl_type {
|
|||
this->fields.structure = fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* For numeric and boolean derrived types returns the basic scalar type
|
||||
*
|
||||
* If the type is a numeric or boolean scalar, vector, or matrix type,
|
||||
* this function gets the scalar type of the individual components. For
|
||||
* all other types, including arrays of numeric or boolean types, the
|
||||
* error type is returned.
|
||||
*/
|
||||
const glsl_type *get_base_type() const;
|
||||
|
||||
/**
|
||||
* Query whether or not a type is a scalar (non-vector and non-matrix).
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue