panfrost: Add a bitset of render targets read by shaders

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5755>
This commit is contained in:
Icecream95 2020-07-06 19:41:28 +12:00 committed by Marge Bot
parent 75018f6495
commit e603248e07
4 changed files with 24 additions and 1 deletions

View file

@ -226,6 +226,12 @@ panfrost_shader_compile(struct panfrost_context *ctx,
if (s->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_STENCIL))
state->writes_stencil = true;
uint64_t outputs_read = s->info.outputs_read;
if (outputs_read & BITFIELD64_BIT(FRAG_RESULT_COLOR))
outputs_read |= BITFIELD64_BIT(FRAG_RESULT_DATA0);
state->outputs_read = outputs_read >> FRAG_RESULT_DATA0;
/* List of reasons we need to execute frag shaders when things
* are masked off */

View file

@ -878,7 +878,8 @@ panfrost_frag_shader_meta_init(struct panfrost_context *ctx,
bool depth_enabled = fs->writes_depth ||
(zsa && zsa->depth.enabled && zsa->depth.func != PIPE_FUNC_ALWAYS);
SET_BIT(fragmeta->midgard1.flags_lo, MALI_READS_TILEBUFFER, !depth_enabled && fs->can_discard);
SET_BIT(fragmeta->midgard1.flags_lo, MALI_READS_TILEBUFFER,
fs->outputs_read || (!depth_enabled && fs->can_discard));
SET_BIT(fragmeta->midgard1.flags_lo, MALI_READS_ZS, depth_enabled && fs->can_discard);
}

View file

@ -664,6 +664,21 @@ panfrost_variant_matches(
}
}
if (variant->outputs_read) {
struct pipe_framebuffer_state *fb = &ctx->pipe_framebuffer;
unsigned i;
BITSET_FOREACH_SET(i, &variant->outputs_read, 8) {
enum pipe_format fmt = PIPE_FORMAT_R8G8B8A8_UNORM;
if ((fb->nr_cbufs > i) && fb->cbufs[i])
fmt = fb->cbufs[i]->format;
if (variant->rt_formats[i] != fmt)
return false;
}
}
/* Point sprites TODO on bifrost, always pass */
if (is_fragment && rasterizer && (rasterizer->sprite_coord_enable |
variant->point_sprite_mask)

View file

@ -225,6 +225,7 @@ struct panfrost_shader_state {
unsigned first_tag;
struct panfrost_bo *bo;
BITSET_WORD outputs_read;
enum pipe_format rt_formats[8];
};