mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 13:20:14 +01:00
pan/lower_framebuffer: Operate on lowered I/O
This turns the early pass into a late pass, which is important because it depends on the shader key and therefore should be called by the driver instead of the compiler preprocessing. It's also simpler this way. The shader key work is waiting for review in another merge request. In the mean time, this patch will let us run blend lowering early for blend shaders on Midgard. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20836>
This commit is contained in:
parent
1b6607fa13
commit
63f30802eb
2 changed files with 14 additions and 23 deletions
|
|
@ -3154,10 +3154,6 @@ midgard_compile_shader_nir(nir_shader *nir,
|
|||
NIR_PASS_V(nir, nir_lower_var_copies);
|
||||
NIR_PASS_V(nir, nir_lower_vars_to_ssa);
|
||||
|
||||
NIR_PASS_V(nir, pan_lower_framebuffer, inputs->rt_formats,
|
||||
inputs->raw_fmt_mask, inputs->is_blend,
|
||||
ctx->quirks & MIDGARD_BROKEN_BLEND_LOADS);
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
|
||||
glsl_type_size, 0);
|
||||
|
||||
|
|
@ -3177,6 +3173,10 @@ midgard_compile_shader_nir(nir_shader *nir,
|
|||
|
||||
NIR_PASS_V(nir, midgard_nir_lower_global_load);
|
||||
|
||||
NIR_PASS_V(nir, pan_lower_framebuffer, inputs->rt_formats,
|
||||
inputs->raw_fmt_mask, inputs->is_blend,
|
||||
ctx->quirks & MIDGARD_BROKEN_BLEND_LOADS);
|
||||
|
||||
/* Collect varyings after lowering I/O */
|
||||
pan_nir_collect_varyings(nir, info);
|
||||
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ pan_lower_fb_store(nir_shader *shader, nir_builder *b,
|
|||
{
|
||||
/* For stores, add conversion before */
|
||||
nir_ssa_def *unpacked =
|
||||
nir_ssa_for_src(b, intr->src[1], intr->num_components);
|
||||
nir_ssa_for_src(b, intr->src[0], intr->num_components);
|
||||
unpacked = nir_pad_vec4(b, unpacked);
|
||||
|
||||
/* Re-order the components */
|
||||
|
|
@ -518,10 +518,9 @@ pan_lower_fb_store(nir_shader *shader, nir_builder *b,
|
|||
unpacked = pan_pack_reorder(b, desc, unpacked);
|
||||
|
||||
nir_ssa_def *packed = pan_pack(b, desc, unpacked);
|
||||
nir_variable *var = nir_intrinsic_get_var(intr, 0);
|
||||
|
||||
nir_store_raw_output_pan(b, packed,
|
||||
.io_semantics.location = var->data.location);
|
||||
.io_semantics = nir_intrinsic_io_semantics(intr));
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
|
|
@ -535,12 +534,9 @@ pan_lower_fb_load(nir_shader *shader, nir_builder *b, nir_intrinsic_instr *intr,
|
|||
const struct util_format_description *desc,
|
||||
bool reorder_comps, int sample)
|
||||
{
|
||||
nir_io_semantics sem = {
|
||||
.location = nir_intrinsic_get_var(intr, 0)->data.location,
|
||||
};
|
||||
|
||||
nir_ssa_def *packed = nir_load_raw_output_pan(
|
||||
b, 4, 32, pan_sample_id(b, sample), .io_semantics = sem);
|
||||
nir_ssa_def *packed =
|
||||
nir_load_raw_output_pan(b, 4, 32, pan_sample_id(b, sample),
|
||||
.io_semantics = nir_intrinsic_io_semantics(intr));
|
||||
|
||||
/* Convert the raw value */
|
||||
nir_ssa_def *unpacked = pan_unpack(b, desc, packed);
|
||||
|
|
@ -590,22 +586,17 @@ pan_lower_framebuffer(nir_shader *shader, const enum pipe_format *rt_fmts,
|
|||
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
|
||||
bool is_load = intr->intrinsic == nir_intrinsic_load_deref;
|
||||
bool is_store = intr->intrinsic == nir_intrinsic_store_deref;
|
||||
bool is_load = intr->intrinsic == nir_intrinsic_load_output;
|
||||
bool is_store = intr->intrinsic == nir_intrinsic_store_output;
|
||||
|
||||
if (!(is_load || (is_store && is_blend)))
|
||||
continue;
|
||||
|
||||
nir_variable *var = nir_intrinsic_get_var(intr, 0);
|
||||
|
||||
if (var->data.mode != nir_var_shader_out)
|
||||
nir_io_semantics sem = nir_intrinsic_io_semantics(intr);
|
||||
if (sem.location < FRAG_RESULT_DATA0)
|
||||
continue;
|
||||
|
||||
if (var->data.location < FRAG_RESULT_DATA0)
|
||||
continue;
|
||||
|
||||
unsigned rt = var->data.location - FRAG_RESULT_DATA0;
|
||||
|
||||
unsigned rt = sem.location - FRAG_RESULT_DATA0;
|
||||
if (rt_fmts[rt] == PIPE_FORMAT_NONE)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue