mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
st: add st_glsl_type_dword_size() helper
This will be used to support uniform packing. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
5488166730
commit
a80cf442d9
2 changed files with 44 additions and 0 deletions
|
|
@ -108,3 +108,46 @@ st_glsl_storage_type_size(const struct glsl_type *type, bool is_bindless)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
st_glsl_type_dword_size(const struct glsl_type *type)
|
||||
{
|
||||
unsigned int size, i;
|
||||
|
||||
switch (type->base_type) {
|
||||
case GLSL_TYPE_UINT:
|
||||
case GLSL_TYPE_INT:
|
||||
case GLSL_TYPE_FLOAT:
|
||||
case GLSL_TYPE_BOOL:
|
||||
return type->components();
|
||||
case GLSL_TYPE_UINT16:
|
||||
case GLSL_TYPE_INT16:
|
||||
case GLSL_TYPE_FLOAT16:
|
||||
return DIV_ROUND_UP(type->components(), 2);
|
||||
case GLSL_TYPE_DOUBLE:
|
||||
case GLSL_TYPE_UINT64:
|
||||
case GLSL_TYPE_INT64:
|
||||
return type->components() * 2;
|
||||
case GLSL_TYPE_ARRAY:
|
||||
return st_glsl_type_dword_size(type->fields.array) * type->length;
|
||||
case GLSL_TYPE_STRUCT:
|
||||
size = 0;
|
||||
for (i = 0; i < type->length; i++) {
|
||||
size += st_glsl_type_dword_size(type->fields.structure[i].type);
|
||||
}
|
||||
return size;
|
||||
case GLSL_TYPE_IMAGE:
|
||||
case GLSL_TYPE_SAMPLER:
|
||||
case GLSL_TYPE_ATOMIC_UINT:
|
||||
return 0;
|
||||
case GLSL_TYPE_SUBROUTINE:
|
||||
return 1;
|
||||
case GLSL_TYPE_VOID:
|
||||
case GLSL_TYPE_ERROR:
|
||||
case GLSL_TYPE_INTERFACE:
|
||||
case GLSL_TYPE_FUNCTION:
|
||||
unreachable("not reached");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ extern "C" {
|
|||
int st_glsl_storage_type_size(const struct glsl_type *type,
|
||||
bool is_bindless);
|
||||
|
||||
int st_glsl_type_dword_size(const struct glsl_type *type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue