mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 04:20:18 +01:00
intel/brw: Move type_size_* functions out of vec4-specific file
Will make easier later to delete vec4 files. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27691>
This commit is contained in:
parent
9bfccc1935
commit
303fd4e935
2 changed files with 112 additions and 111 deletions
|
|
@ -30,6 +30,117 @@
|
|||
#include "compiler/nir/nir_builder.h"
|
||||
#include "util/u_math.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_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 : DIV_ROUND_UP(ISL_IMAGE_PARAM_SIZE, 4);
|
||||
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.
|
||||
*
|
||||
* For simple types, it will return 1 (a single vec4); for matrices, the
|
||||
* number of columns; for array and struct, the sum of the vec4_size of
|
||||
* each of its elements; and for sampler and atomic, zero.
|
||||
*
|
||||
* This method is useful to calculate how much register space is needed to
|
||||
* store a particular type.
|
||||
*/
|
||||
int
|
||||
type_size_vec4(const struct glsl_type *type, bool bindless)
|
||||
{
|
||||
return type_size_xvec4(type, true, bindless);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum number of dvec4 elements needed to pack a type.
|
||||
*
|
||||
* For simple types, it will return 1 (a single dvec4); for matrices, the
|
||||
* number of columns; for array and struct, the sum of the dvec4_size of
|
||||
* each of its elements; and for sampler and atomic, zero.
|
||||
*
|
||||
* This method is useful to calculate how much register space is needed to
|
||||
* store a particular type.
|
||||
*
|
||||
* Measuring double-precision vertex inputs as dvec4 is required because
|
||||
* ARB_vertex_attrib_64bit states that these uses the same number of locations
|
||||
* than the single-precision version. That is, two consecutives dvec4 would be
|
||||
* located in location "x" and location "x+1", not "x+2".
|
||||
*
|
||||
* In order to map vec4/dvec4 vertex inputs in the proper ATTRs,
|
||||
* remap_vs_attrs() will take in account both the location and also if the
|
||||
* type fits in one or two vec4 slots.
|
||||
*/
|
||||
int
|
||||
type_size_dvec4(const struct glsl_type *type, bool bindless)
|
||||
{
|
||||
return type_size_xvec4(type, false, bindless);
|
||||
}
|
||||
|
||||
static bool
|
||||
remap_tess_levels(nir_builder *b, nir_intrinsic_instr *intr,
|
||||
enum tess_primitive_mode _primitive_mode)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "brw_nir.h"
|
||||
#include "brw_vec4.h"
|
||||
#include "brw_cfg.h"
|
||||
#include "brw_eu.h"
|
||||
|
|
@ -559,117 +560,6 @@ vec4_visitor::emit_pack_snorm_4x8(const dst_reg &dst, const src_reg &src0)
|
|||
emit(VEC4_OPCODE_PACK_BYTES, dst, bytes);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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_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 : DIV_ROUND_UP(ISL_IMAGE_PARAM_SIZE, 4);
|
||||
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.
|
||||
*
|
||||
* For simple types, it will return 1 (a single vec4); for matrices, the
|
||||
* number of columns; for array and struct, the sum of the vec4_size of
|
||||
* each of its elements; and for sampler and atomic, zero.
|
||||
*
|
||||
* This method is useful to calculate how much register space is needed to
|
||||
* store a particular type.
|
||||
*/
|
||||
extern "C" int
|
||||
type_size_vec4(const struct glsl_type *type, bool bindless)
|
||||
{
|
||||
return type_size_xvec4(type, true, bindless);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum number of dvec4 elements needed to pack a type.
|
||||
*
|
||||
* For simple types, it will return 1 (a single dvec4); for matrices, the
|
||||
* number of columns; for array and struct, the sum of the dvec4_size of
|
||||
* each of its elements; and for sampler and atomic, zero.
|
||||
*
|
||||
* This method is useful to calculate how much register space is needed to
|
||||
* store a particular type.
|
||||
*
|
||||
* Measuring double-precision vertex inputs as dvec4 is required because
|
||||
* ARB_vertex_attrib_64bit states that these uses the same number of locations
|
||||
* than the single-precision version. That is, two consecutives dvec4 would be
|
||||
* located in location "x" and location "x+1", not "x+2".
|
||||
*
|
||||
* In order to map vec4/dvec4 vertex inputs in the proper ATTRs,
|
||||
* remap_vs_attrs() will take in account both the location and also if the
|
||||
* type fits in one or two vec4 slots.
|
||||
*/
|
||||
extern "C" int
|
||||
type_size_dvec4(const struct glsl_type *type, bool bindless)
|
||||
{
|
||||
return type_size_xvec4(type, false, bindless);
|
||||
}
|
||||
|
||||
src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type)
|
||||
{
|
||||
init();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue