mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
nir: lower smooth lines conditionally using the new intrinsic
RADV will enable/disable this based on a dynamic state. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21587>
This commit is contained in:
parent
759a57d902
commit
3626c23e85
1 changed files with 24 additions and 15 deletions
|
|
@ -51,20 +51,31 @@ lower_polylinesmooth(nir_builder *b, nir_instr *instr, void *data)
|
|||
assert(intr->num_components == 4);
|
||||
|
||||
b->cursor = nir_before_instr(&intr->instr);
|
||||
|
||||
nir_ssa_def *coverage = nir_load_sample_mask_in(b);
|
||||
|
||||
/* coverage = (coverage) / SI_NUM_SMOOTH_AA_SAMPLES */
|
||||
coverage = nir_bit_count(b, coverage);
|
||||
coverage = nir_u2f32(b, coverage);
|
||||
coverage = nir_fmul_imm(b, coverage, 1.0 / *num_smooth_aa_sample);
|
||||
nir_ssa_def *res1, *res2;
|
||||
|
||||
/* Write out the fragment color*vec4(1, 1, 1, alpha) */
|
||||
nir_ssa_def *one = nir_imm_float(b, 1.0f);
|
||||
nir_ssa_def *new_val = nir_fmul(b, nir_vec4(b, one, one, one, coverage),
|
||||
intr->src[0].ssa);
|
||||
nir_instr_rewrite_src(instr, &intr->src[0], nir_src_for_ssa(new_val));
|
||||
nir_if *if_enabled = nir_push_if(b, nir_load_poly_line_smooth_enabled(b));
|
||||
{
|
||||
nir_ssa_def *coverage = nir_load_sample_mask_in(b);
|
||||
|
||||
/* coverage = (coverage) / SI_NUM_SMOOTH_AA_SAMPLES */
|
||||
coverage = nir_bit_count(b, coverage);
|
||||
coverage = nir_u2f32(b, coverage);
|
||||
coverage = nir_fmul_imm(b, coverage, 1.0 / *num_smooth_aa_sample);
|
||||
|
||||
/* Write out the fragment color*vec4(1, 1, 1, alpha) */
|
||||
nir_ssa_def *one = nir_imm_float(b, 1.0f);
|
||||
res1 = nir_fmul(b, nir_vec4(b, one, one, one, coverage), intr->src[0].ssa);
|
||||
}
|
||||
nir_push_else(b, if_enabled);
|
||||
{
|
||||
res2 = intr->src[0].ssa;
|
||||
}
|
||||
nir_pop_if(b, if_enabled);
|
||||
|
||||
nir_ssa_def *new_dest = nir_if_phi(b, res1, res2);
|
||||
|
||||
nir_instr_rewrite_src(instr, &intr->src[0], nir_src_for_ssa(new_dest));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -72,8 +83,6 @@ bool
|
|||
nir_lower_poly_line_smooth(nir_shader *shader, unsigned num_smooth_aa_sample)
|
||||
{
|
||||
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
|
||||
return nir_shader_instructions_pass(shader, lower_polylinesmooth,
|
||||
nir_metadata_loop_analysis |
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance, &num_smooth_aa_sample);
|
||||
return nir_shader_instructions_pass(shader, lower_polylinesmooth, 0,
|
||||
&num_smooth_aa_sample);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue