diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 48707df224d..c476358b660 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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; } } diff --git a/src/panfrost/lib/pan_shader.c b/src/panfrost/lib/pan_shader.c index c49d6f40217..c2104175702 100644 --- a/src/panfrost/lib/pan_shader.c +++ b/src/panfrost/lib/pan_shader.c @@ -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); + } + } } diff --git a/src/panfrost/util/pan_ir.h b/src/panfrost/util/pan_ir.h index dc8bb95ea90..3f20e3f4e62 100644 --- a/src/panfrost/util/pan_ir.h +++ b/src/panfrost/util/pan_ir.h @@ -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 {