nir/i965/freedreno/vc4: add a bindless bool to type size functions

This required to calculate sizes correctly when we have bindless
samplers/images.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Timothy Arceri
2019-03-29 12:39:48 +11:00
committed by Karol Herbst
parent 3b2a9ffd60
commit 035759b61b
16 changed files with 76 additions and 59 deletions
+8 -5
View File
@@ -518,7 +518,7 @@ fs_reg::component_size(unsigned width) const
}
extern "C" int
type_size_scalar(const struct glsl_type *type)
type_size_scalar(const struct glsl_type *type, bool bindless)
{
unsigned int size, i;
@@ -540,17 +540,19 @@ type_size_scalar(const struct glsl_type *type)
case GLSL_TYPE_INT64:
return type->components() * 2;
case GLSL_TYPE_ARRAY:
return type_size_scalar(type->fields.array) * type->length;
return type_size_scalar(type->fields.array, bindless) * type->length;
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_INTERFACE:
size = 0;
for (i = 0; i < type->length; i++) {
size += type_size_scalar(type->fields.structure[i].type);
size += type_size_scalar(type->fields.structure[i].type, bindless);
}
return size;
case GLSL_TYPE_SAMPLER:
case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_IMAGE:
if (bindless)
return type->components() * 2;
case GLSL_TYPE_ATOMIC_UINT:
/* Samplers, atomics, and images take up no register space, since
* they're baked in at link time.
*/
@@ -1135,7 +1137,8 @@ fs_reg
fs_visitor::vgrf(const glsl_type *const type)
{
int reg_width = dispatch_width / 8;
return fs_reg(VGRF, alloc.allocate(type_size_scalar(type) * reg_width),
return fs_reg(VGRF,
alloc.allocate(type_size_scalar(type, false) * reg_width),
brw_type_for_base_type(type));
}
+1 -1
View File
@@ -58,7 +58,7 @@ fs_visitor::nir_setup_outputs()
const int loc = var->data.driver_location;
const unsigned var_vec4s =
var->data.compact ? DIV_ROUND_UP(glsl_get_length(var->type), 4)
: type_size_vec4(var->type);
: type_size_vec4(var->type, true);
vec4s[loc] = MAX2(vec4s[loc], var_vec4s);
}
+7 -7
View File
@@ -32,20 +32,20 @@
extern "C" {
#endif
int type_size_scalar(const struct glsl_type *type);
int type_size_vec4(const struct glsl_type *type);
int type_size_dvec4(const struct glsl_type *type);
int type_size_scalar(const struct glsl_type *type, bool bindless);
int type_size_vec4(const struct glsl_type *type, bool bindless);
int type_size_dvec4(const struct glsl_type *type, bool bindless);
static inline int
type_size_scalar_bytes(const struct glsl_type *type)
type_size_scalar_bytes(const struct glsl_type *type, bool bindless)
{
return type_size_scalar(type) * 4;
return type_size_scalar(type, bindless) * 4;
}
static inline int
type_size_vec4_bytes(const struct glsl_type *type)
type_size_vec4_bytes(const struct glsl_type *type, bool bindless)
{
return type_size_vec4(type) * 16;
return type_size_vec4(type, bindless) * 16;
}
/* Flags set in the instr->pass_flags field by i965 analysis passes */
+14 -12
View File
@@ -576,7 +576,7 @@ vec4_visitor::emit_pack_snorm_4x8(const dst_reg &dst, const src_reg &src0)
* false) elements needed to pack a type.
*/
static int
type_size_xvec4(const struct glsl_type *type, bool as_vec4)
type_size_xvec4(const struct glsl_type *type, bool as_vec4, bool bindless)
{
unsigned int i;
int size;
@@ -609,12 +609,14 @@ type_size_xvec4(const struct glsl_type *type, bool as_vec4)
}
case GLSL_TYPE_ARRAY:
assert(type->length > 0);
return type_size_xvec4(type->fields.array, as_vec4) * type->length;
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);
size += type_size_xvec4(type->fields.structure[i].type, as_vec4,
bindless);
}
return size;
case GLSL_TYPE_SUBROUTINE:
@@ -624,11 +626,11 @@ type_size_xvec4(const struct glsl_type *type, bool as_vec4)
/* Samplers take up no register space, since they're baked in at
* link time.
*/
return 0;
return bindless ? 1 : 0;
case GLSL_TYPE_ATOMIC_UINT:
return 0;
case GLSL_TYPE_IMAGE:
return DIV_ROUND_UP(BRW_IMAGE_PARAM_SIZE, 4);
return bindless ? 1 : DIV_ROUND_UP(BRW_IMAGE_PARAM_SIZE, 4);
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
case GLSL_TYPE_FUNCTION:
@@ -649,9 +651,9 @@ type_size_xvec4(const struct glsl_type *type, bool as_vec4)
* store a particular type.
*/
extern "C" int
type_size_vec4(const struct glsl_type *type)
type_size_vec4(const struct glsl_type *type, bool bindless)
{
return type_size_xvec4(type, true);
return type_size_xvec4(type, true, bindless);
}
/**
@@ -674,9 +676,9 @@ type_size_vec4(const struct glsl_type *type)
* type fits in one or two vec4 slots.
*/
extern "C" int
type_size_dvec4(const struct glsl_type *type)
type_size_dvec4(const struct glsl_type *type, bool bindless)
{
return type_size_xvec4(type, false);
return type_size_xvec4(type, false, bindless);
}
src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type)
@@ -684,7 +686,7 @@ src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type)
init();
this->file = VGRF;
this->nr = v->alloc.allocate(type_size_vec4(type));
this->nr = v->alloc.allocate(type_size_vec4(type, false));
if (type->is_array() || type->is_struct()) {
this->swizzle = BRW_SWIZZLE_NOOP;
@@ -702,7 +704,7 @@ src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type, int size)
init();
this->file = VGRF;
this->nr = v->alloc.allocate(type_size_vec4(type) * size);
this->nr = v->alloc.allocate(type_size_vec4(type, false) * size);
this->swizzle = BRW_SWIZZLE_NOOP;
@@ -714,7 +716,7 @@ dst_reg::dst_reg(class vec4_visitor *v, const struct glsl_type *type)
init();
this->file = VGRF;
this->nr = v->alloc.allocate(type_size_vec4(type));
this->nr = v->alloc.allocate(type_size_vec4(type, false));
if (type->is_array() || type->is_struct()) {
this->writemask = WRITEMASK_XYZW;