mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
brw: Replace type_size_xvec4 with glsl_count_attribute_slots
This is nearly identical, except for bindless sampler/texture/image handling. But we only use it for inputs/outputs, not uniforms, where there are no bindless handles to worry about. Deletes a lot of mostly-duplicated code. Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37784>
This commit is contained in:
parent
a12f117cef
commit
b3c511592a
1 changed files with 1 additions and 74 deletions
|
|
@ -28,79 +28,6 @@
|
|||
#include "compiler/nir/nir_builder.h"
|
||||
#include "dev/intel_debug.h"
|
||||
|
||||
/*
|
||||
* Returns the minimum number of vec4 (as_vec4 == true) or dvec4 (as_vec4 ==
|
||||
* false) elements needed to pack a type.
|
||||
*/
|
||||
static int
|
||||
type_size_xvec4(const struct glsl_type *type, bool as_vec4, bool bindless)
|
||||
{
|
||||
unsigned int i;
|
||||
int size;
|
||||
|
||||
switch (type->base_type) {
|
||||
case GLSL_TYPE_UINT:
|
||||
case GLSL_TYPE_INT:
|
||||
case GLSL_TYPE_FLOAT:
|
||||
case GLSL_TYPE_FLOAT16:
|
||||
case GLSL_TYPE_BFLOAT16:
|
||||
case GLSL_TYPE_FLOAT_E4M3FN:
|
||||
case GLSL_TYPE_FLOAT_E5M2:
|
||||
case GLSL_TYPE_BOOL:
|
||||
case GLSL_TYPE_DOUBLE:
|
||||
case GLSL_TYPE_UINT16:
|
||||
case GLSL_TYPE_INT16:
|
||||
case GLSL_TYPE_UINT8:
|
||||
case GLSL_TYPE_INT8:
|
||||
case GLSL_TYPE_UINT64:
|
||||
case GLSL_TYPE_INT64:
|
||||
if (glsl_type_is_matrix(type)) {
|
||||
const glsl_type *col_type = glsl_get_column_type(type);
|
||||
unsigned col_slots =
|
||||
(as_vec4 && glsl_type_is_dual_slot(col_type)) ? 2 : 1;
|
||||
return type->matrix_columns * col_slots;
|
||||
} 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 (as_vec4 && glsl_type_is_dual_slot(type)) ? 2 : 1;
|
||||
}
|
||||
case GLSL_TYPE_ARRAY:
|
||||
assert(type->length > 0);
|
||||
return type_size_xvec4(type->fields.array, as_vec4, bindless) *
|
||||
type->length;
|
||||
case GLSL_TYPE_STRUCT:
|
||||
case GLSL_TYPE_INTERFACE:
|
||||
size = 0;
|
||||
for (i = 0; i < type->length; i++) {
|
||||
size += type_size_xvec4(type->fields.structure[i].type, as_vec4,
|
||||
bindless);
|
||||
}
|
||||
return size;
|
||||
case GLSL_TYPE_SUBROUTINE:
|
||||
return 1;
|
||||
|
||||
case GLSL_TYPE_SAMPLER:
|
||||
case GLSL_TYPE_TEXTURE:
|
||||
/* Samplers and textures take up no register space, since they're baked
|
||||
* in at link time.
|
||||
*/
|
||||
return bindless ? 1 : 0;
|
||||
case GLSL_TYPE_ATOMIC_UINT:
|
||||
return 0;
|
||||
case GLSL_TYPE_IMAGE:
|
||||
return bindless ? 1 : 0;
|
||||
case GLSL_TYPE_VOID:
|
||||
case GLSL_TYPE_ERROR:
|
||||
case GLSL_TYPE_COOPERATIVE_MATRIX:
|
||||
UNREACHABLE("not reached");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum number of vec4 elements needed to pack a type.
|
||||
*
|
||||
|
|
@ -114,7 +41,7 @@ type_size_xvec4(const struct glsl_type *type, bool as_vec4, bool bindless)
|
|||
int
|
||||
type_size_vec4(const struct glsl_type *type, bool bindless)
|
||||
{
|
||||
return type_size_xvec4(type, true, bindless);
|
||||
return glsl_count_attribute_slots(type, false);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue