mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
panvk: Prepare the blend logic for Valhall
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30736>
This commit is contained in:
parent
c1b3db966a
commit
5b1cddf35f
4 changed files with 24 additions and 14 deletions
|
|
@ -357,14 +357,13 @@ panvk_draw_prepare_fs_rsd(struct panvk_cmd_buffer *cmdbuf,
|
|||
bool writes_z = writes_depth(cmdbuf);
|
||||
bool writes_s = writes_stencil(cmdbuf);
|
||||
bool needs_fs = fs_required(cmdbuf);
|
||||
bool blend_shader_loads_blend_const = false;
|
||||
bool blend_reads_dest = false;
|
||||
|
||||
struct panfrost_ptr ptr = pan_pool_alloc_desc_aggregate(
|
||||
&cmdbuf->desc_pool.base, PAN_DESC(RENDERER_STATE),
|
||||
PAN_DESC_ARRAY(bd_count, BLEND));
|
||||
struct mali_renderer_state_packed *rsd = ptr.cpu;
|
||||
struct mali_blend_packed *bds = ptr.cpu + pan_size(RENDERER_STATE);
|
||||
struct panvk_blend_info binfo = {0};
|
||||
|
||||
mali_ptr fs_code = panvk_shader_get_dev_addr(fs);
|
||||
|
||||
|
|
@ -372,7 +371,7 @@ panvk_draw_prepare_fs_rsd(struct panvk_cmd_buffer *cmdbuf,
|
|||
panvk_per_arch(blend_emit_descs)(
|
||||
dev, cb, cmdbuf->state.gfx.render.color_attachments.fmts,
|
||||
cmdbuf->state.gfx.render.color_attachments.samples, fs_info, fs_code,
|
||||
bds, &blend_reads_dest, &blend_shader_loads_blend_const);
|
||||
bds, &binfo);
|
||||
} else {
|
||||
for (unsigned i = 0; i < bd_count; i++) {
|
||||
pan_pack(&bds[i], BLEND, cfg) {
|
||||
|
|
@ -388,7 +387,7 @@ panvk_draw_prepare_fs_rsd(struct panvk_cmd_buffer *cmdbuf,
|
|||
if (needs_fs) {
|
||||
pan_shader_prepare_rsd(fs_info, fs_code, &cfg);
|
||||
|
||||
if (blend_shader_loads_blend_const) {
|
||||
if (binfo.shader_loads_blend_const) {
|
||||
/* Preload the blend constant if the blend shader depends on it. */
|
||||
cfg.preload.uniform_count = MAX2(
|
||||
cfg.preload.uniform_count,
|
||||
|
|
@ -400,7 +399,7 @@ panvk_draw_prepare_fs_rsd(struct panvk_cmd_buffer *cmdbuf,
|
|||
MESA_VK_RP_ATTACHMENT_ANY_COLOR_BITS;
|
||||
cfg.properties.allow_forward_pixel_to_kill =
|
||||
fs_info->fs.can_fpk && !(rt_mask & ~rt_written) &&
|
||||
!alpha_to_coverage && !blend_reads_dest;
|
||||
!alpha_to_coverage && !binfo.any_dest_read;
|
||||
|
||||
bool writes_zs = writes_z || writes_s;
|
||||
bool zs_always_passes = ds_test_always_passes(cmdbuf);
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ foreach arch : [6, 7, 9, 10]
|
|||
# Just add the v9/v10 entrypoints for now.
|
||||
per_arch_files = [
|
||||
panvk_entrypoints[0],
|
||||
'panvk_vX_blend.c',
|
||||
'panvk_vX_descriptor_set.c',
|
||||
'panvk_vX_descriptor_set_layout.c',
|
||||
'panvk_vX_nir_lower_descriptors.c',
|
||||
|
|
|
|||
|
|
@ -35,12 +35,17 @@ VkResult panvk_per_arch(blend_shader_cache_init)(struct panvk_device *dev);
|
|||
|
||||
void panvk_per_arch(blend_shader_cache_cleanup)(struct panvk_device *dev);
|
||||
|
||||
struct panvk_blend_info {
|
||||
bool any_dest_read;
|
||||
bool needs_shader;
|
||||
bool shader_loads_blend_const;
|
||||
};
|
||||
|
||||
VkResult panvk_per_arch(blend_emit_descs)(
|
||||
struct panvk_device *dev, const struct vk_color_blend_state *cb,
|
||||
const VkFormat *color_attachment_formats, uint8_t *color_attachment_samples,
|
||||
const struct pan_shader_info *fs_info, mali_ptr fs_code,
|
||||
struct mali_blend_packed *bds, bool *any_dest_read,
|
||||
bool *any_blend_const_load);
|
||||
struct mali_blend_packed *bds, struct panvk_blend_info *blend_info);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -204,8 +204,6 @@ emit_blend_desc(const struct pan_shader_info *fs_info, mali_ptr fs_code,
|
|||
cfg.constant = constant;
|
||||
|
||||
if (blend_shader) {
|
||||
uint32_t ret_offset = fs_info->bifrost.blend[rt_idx].return_offset;
|
||||
|
||||
/* Blend and fragment shaders must be in the same 4G region. */
|
||||
assert((blend_shader >> 32) == (fs_code >> 32));
|
||||
/* Blend shader must be 16-byte aligned. */
|
||||
|
|
@ -216,6 +214,9 @@ emit_blend_desc(const struct pan_shader_info *fs_info, mali_ptr fs_code,
|
|||
cfg.internal.mode = MALI_BLEND_MODE_SHADER;
|
||||
cfg.internal.shader.pc = (uint32_t)blend_shader;
|
||||
|
||||
#if PAN_ARCH <= 7
|
||||
uint32_t ret_offset = fs_info->bifrost.blend[rt_idx].return_offset;
|
||||
|
||||
/* If ret_offset is zero, we assume the BLEND is a terminal
|
||||
* instruction and set return_value to zero, to let the
|
||||
* blend shader jump to address zero, which terminates the
|
||||
|
|
@ -223,6 +224,7 @@ emit_blend_desc(const struct pan_shader_info *fs_info, mali_ptr fs_code,
|
|||
*/
|
||||
cfg.internal.shader.return_value =
|
||||
ret_offset ? fs_code + ret_offset : 0;
|
||||
#endif
|
||||
} else {
|
||||
bool opaque = pan_blend_is_opaque(rt->equation);
|
||||
|
||||
|
|
@ -252,6 +254,7 @@ emit_blend_desc(const struct pan_shader_info *fs_info, mali_ptr fs_code,
|
|||
|
||||
cfg.internal.fixed_function.rt = rt_idx;
|
||||
|
||||
#if PAN_ARCH <= 7
|
||||
if (fs_info->fs.untyped_color_outputs) {
|
||||
nir_alu_type type = fs_info->bifrost.blend[rt_idx].type;
|
||||
|
||||
|
|
@ -268,6 +271,7 @@ emit_blend_desc(const struct pan_shader_info *fs_info, mali_ptr fs_code,
|
|||
cfg.internal.fixed_function.alpha_one_store =
|
||||
pan_blend_alpha_one_store(rt->equation);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -352,8 +356,7 @@ panvk_per_arch(blend_emit_descs)(
|
|||
struct panvk_device *dev, const struct vk_color_blend_state *cb,
|
||||
const VkFormat *color_attachment_formats, uint8_t *color_attachment_samples,
|
||||
const struct pan_shader_info *fs_info, mali_ptr fs_code,
|
||||
struct mali_blend_packed *bds, bool *any_dest_read,
|
||||
bool *any_blend_const_load)
|
||||
struct mali_blend_packed *bds, struct panvk_blend_info *blend_info)
|
||||
{
|
||||
struct pan_blend_state bs = {
|
||||
.logicop_enable = cb->logic_op_enable,
|
||||
|
|
@ -371,7 +374,7 @@ panvk_per_arch(blend_emit_descs)(
|
|||
/* All bits set to one encodes unused fixed-function blend constant. */
|
||||
unsigned ff_blend_constant = ~0;
|
||||
|
||||
*any_dest_read = false;
|
||||
memset(blend_info, 0, sizeof(*blend_info));
|
||||
for (uint8_t i = 0; i < cb->attachment_count; i++) {
|
||||
struct pan_blend_rt_state *rt = &bs.rts[i];
|
||||
|
||||
|
|
@ -426,7 +429,7 @@ panvk_per_arch(blend_emit_descs)(
|
|||
util_blend_dst_alpha_to_one(rt->equation.alpha_dst_factor);
|
||||
}
|
||||
|
||||
*any_dest_read |= pan_blend_reads_dest(rt->equation);
|
||||
blend_info->any_dest_read |= pan_blend_reads_dest(rt->equation);
|
||||
|
||||
if (blend_needs_shader(&bs, i, &ff_blend_constant)) {
|
||||
nir_alu_type src0_type = fs_info->bifrost.blend[i].type;
|
||||
|
|
@ -437,7 +440,9 @@ panvk_per_arch(blend_emit_descs)(
|
|||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
*any_blend_const_load |= pan_blend_constant_mask(rt->equation) != 0;
|
||||
blend_info->shader_loads_blend_const |=
|
||||
pan_blend_constant_mask(rt->equation) != 0;
|
||||
blend_info->needs_shader = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue