panfrost: Precompute bifrost_blend_type_from_nir

Needed in the draw call hot path. Do it at compile time.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10869>
This commit is contained in:
Alyssa Rosenzweig
2021-05-14 17:43:35 -04:00
committed by Marge Bot
parent 87256d335b
commit 5a8e1dfaf3
3 changed files with 36 additions and 25 deletions
+1 -25
View File
@@ -278,30 +278,6 @@ panfrost_fs_required(
return (fs->info.fs.writes_depth || fs->info.fs.writes_stencil);
}
static enum mali_bifrost_register_file_format
bifrost_blend_type_from_nir(nir_alu_type nir_type)
{
switch(nir_type) {
case 0: /* Render target not in use */
return 0;
case nir_type_float16:
return MALI_BIFROST_REGISTER_FILE_FORMAT_F16;
case nir_type_float32:
return MALI_BIFROST_REGISTER_FILE_FORMAT_F32;
case nir_type_int32:
return MALI_BIFROST_REGISTER_FILE_FORMAT_I32;
case nir_type_uint32:
return MALI_BIFROST_REGISTER_FILE_FORMAT_U32;
case nir_type_int16:
return MALI_BIFROST_REGISTER_FILE_FORMAT_I16;
case nir_type_uint16:
return MALI_BIFROST_REGISTER_FILE_FORMAT_U16;
default:
unreachable("Unsupported blend shader type for NIR alu type");
return 0;
}
}
static void
panfrost_emit_bifrost_blend(struct panfrost_batch *batch,
mali_ptr *blend_shaders, void *rts)
@@ -397,7 +373,7 @@ panfrost_emit_bifrost_blend(struct panfrost_batch *batch,
cfg.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(dev, format);
cfg.fixed_function.conversion.register_format =
bifrost_blend_type_from_nir(fs->info.bifrost.blend[i].type);
fs->info.bifrost.blend[i].format;
cfg.fixed_function.rt = i;
}
}
+32
View File
@@ -132,6 +132,30 @@ collect_varyings(nir_shader *s, nir_variable_mode varying_mode,
}
}
static enum mali_bifrost_register_file_format
bifrost_blend_type_from_nir(nir_alu_type nir_type)
{
switch(nir_type) {
case 0: /* Render target not in use */
return 0;
case nir_type_float16:
return MALI_BIFROST_REGISTER_FILE_FORMAT_F16;
case nir_type_float32:
return MALI_BIFROST_REGISTER_FILE_FORMAT_F32;
case nir_type_int32:
return MALI_BIFROST_REGISTER_FILE_FORMAT_I32;
case nir_type_uint32:
return MALI_BIFROST_REGISTER_FILE_FORMAT_U32;
case nir_type_int16:
return MALI_BIFROST_REGISTER_FILE_FORMAT_I16;
case nir_type_uint16:
return MALI_BIFROST_REGISTER_FILE_FORMAT_U16;
default:
unreachable("Unsupported blend shader type for NIR alu type");
return 0;
}
}
void
pan_shader_compile(const struct panfrost_device *dev,
nir_shader *s,
@@ -232,4 +256,12 @@ pan_shader_compile(const struct panfrost_device *dev,
info->writes_global = s->info.writes_memory;
info->sampler_count = info->texture_count = BITSET_LAST_BIT(s->info.textures_used);
/* This is "redundant" information, but is needed in a draw-time hot path */
if (pan_is_bifrost(dev)) {
for (unsigned i = 0; i < ARRAY_SIZE(info->bifrost.blend); ++i) {
info->bifrost.blend[i].format =
bifrost_blend_type_from_nir(info->bifrost.blend[i].type);
}
}
}
+3
View File
@@ -142,6 +142,9 @@ struct pan_shader_varying {
struct bifrost_shader_blend_info {
nir_alu_type type;
uint32_t return_offset;
/* mali_bifrost_register_file_format corresponding to nir_alu_type */
unsigned format;
};
struct bifrost_shader_info {