mesa/prog: Reuse count_vec4_slots() from ir_to_mesa.
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3297>
This commit is contained in:
parent
74ee3f76de
commit
4cabd4812a
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue