From: Eric Anholt Date: Mon, 6 Jan 2020 21:19:30 +0000 (-0800) Subject: mesa/prog: Reuse count_vec4_slots() from ir_to_mesa. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4cabd4812a6b2a15d15cd889778a36956574c9a3;p=mesa.git mesa/prog: Reuse count_vec4_slots() from ir_to_mesa. Reviewed-by: Kristian H. Kristensen Part-of: --- diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index bcf50c505e1..dfc52e718d1 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -499,84 +499,10 @@ ir_to_mesa_visitor::src_reg_for_float(float val) return src; } -static int -storage_type_size(const struct glsl_type *type, bool bindless) -{ - unsigned int i; - int size; - - switch (type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_UINT8: - case GLSL_TYPE_INT8: - case GLSL_TYPE_UINT16: - case GLSL_TYPE_INT16: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_FLOAT16: - case GLSL_TYPE_BOOL: - if (type->is_matrix()) { - return type->matrix_columns; - } else { - /* Regardless of size of vector, it gets a vec4. This is bad - * packing for things like floats, but otherwise arrays become a - * mess. Hopefully a later pass over the code can pack scalars - * down if appropriate. - */ - return 1; - } - break; - case GLSL_TYPE_DOUBLE: - if (type->is_matrix()) { - if (type->vector_elements > 2) - return type->matrix_columns * 2; - else - return type->matrix_columns; - } else { - if (type->vector_elements > 2) - return 2; - else - return 1; - } - break; - case GLSL_TYPE_UINT64: - case GLSL_TYPE_INT64: - if (type->vector_elements > 2) - return 2; - else - return 1; - case GLSL_TYPE_ARRAY: - assert(type->length > 0); - return storage_type_size(type->fields.array, bindless) * type->length; - case GLSL_TYPE_STRUCT: - size = 0; - for (i = 0; i < type->length; i++) { - size += storage_type_size(type->fields.structure[i].type, bindless); - } - return size; - case GLSL_TYPE_SAMPLER: - case GLSL_TYPE_IMAGE: - if (!bindless) - return 0; - /* fall through */ - case GLSL_TYPE_SUBROUTINE: - return 1; - case GLSL_TYPE_ATOMIC_UINT: - case GLSL_TYPE_VOID: - case GLSL_TYPE_ERROR: - case GLSL_TYPE_INTERFACE: - case GLSL_TYPE_FUNCTION: - assert(!"Invalid type in type_size"); - break; - } - - return 0; -} - static int type_size(const struct glsl_type *type) { - return storage_type_size(type, false); + return type->count_vec4_slots(false, false); } /**