@@ -1772,6 +1772,70 @@ mitigate_hazards(Program* program)
1772
1772
}
1773
1773
}
1774
1774
1775
+ /* FeatureRequiredExportPriority in LLVM */
1776
+ void
1777
+ required_export_priority (Program* program)
1778
+ {
1779
+ /* Skip callees, assuming that the caller has already increased the priority. */
1780
+ bool increase_priority = !program->is_epilog && !program->info .vs .has_prolog &&
1781
+ (!program->info .merged_shader_compiled_separately ||
1782
+ program->stage .sw == SWStage::VS || program->stage .sw == SWStage::TES);
1783
+ increase_priority |= program->is_prolog ;
1784
+
1785
+ for (Block& block : program->blocks ) {
1786
+ std::vector<aco_ptr<Instruction>> new_instructions;
1787
+ new_instructions.reserve (block.instructions .size () + 6 );
1788
+
1789
+ Builder bld (program, &new_instructions);
1790
+
1791
+ if (increase_priority && block.index == 0 ) {
1792
+ if (!block.instructions .empty () && block.instructions [0 ]->opcode == aco_opcode::s_setprio)
1793
+ block.instructions [0 ]->salu ().imm = MAX2 (block.instructions [0 ]->salu ().imm , 2 );
1794
+ else
1795
+ bld.sopp (aco_opcode::s_setprio, 2 );
1796
+ }
1797
+
1798
+ for (unsigned i = 0 ; i < block.instructions .size (); i++) {
1799
+ Instruction* instr = block.instructions [i].get ();
1800
+ new_instructions.push_back (std::move (block.instructions [i]));
1801
+
1802
+ if (instr->opcode == aco_opcode::s_setprio) {
1803
+ instr->salu ().imm = MAX2 (instr->salu ().imm , 2 );
1804
+ continue ;
1805
+ }
1806
+
1807
+ bool end_of_export_sequence = instr->isEXP () && (i == block.instructions .size () - 1 ||
1808
+ !block.instructions [i + 1 ]->isEXP ());
1809
+ if (!end_of_export_sequence)
1810
+ continue ;
1811
+
1812
+ bool before_endpgm = false ;
1813
+ if (i != block.instructions .size () - 1 ) {
1814
+ before_endpgm = block.instructions [i + 1 ]->opcode == aco_opcode::s_endpgm;
1815
+ } else {
1816
+ /* Does this fallthrough to a s_endpgm? */
1817
+ for (unsigned j = block.index + 1 ; j < program->blocks .size (); j++) {
1818
+ if (program->blocks [j].instructions .size () == 1 &&
1819
+ program->blocks [j].instructions [0 ]->opcode == aco_opcode::s_endpgm)
1820
+ before_endpgm = true ;
1821
+ if (!program->blocks [j].instructions .empty ())
1822
+ break ;
1823
+ }
1824
+ }
1825
+
1826
+ bld.sopp (aco_opcode::s_setprio, 0 );
1827
+ if (!before_endpgm)
1828
+ bld.sopk (aco_opcode::s_waitcnt_expcnt, Operand (sgpr_null, s1), 0 );
1829
+ bld.sopp (aco_opcode::s_nop, 0 );
1830
+ bld.sopp (aco_opcode::s_nop, 0 );
1831
+ if (!before_endpgm)
1832
+ bld.sopp (aco_opcode::s_setprio, 2 );
1833
+ }
1834
+
1835
+ block.instructions = std::move (new_instructions);
1836
+ }
1837
+ }
1838
+
1775
1839
} /* end namespace */
1776
1840
1777
1841
void
@@ -1785,6 +1849,10 @@ insert_NOPs(Program* program)
1785
1849
mitigate_hazards<NOP_ctx_gfx10, handle_instruction_gfx10, resolve_all_gfx10>(program);
1786
1850
else
1787
1851
mitigate_hazards<NOP_ctx_gfx6, handle_instruction_gfx6, resolve_all_gfx6>(program);
1852
+
1853
+ if (program->gfx_level == GFX11_5 && (program->stage .hw == AC_HW_NEXT_GEN_GEOMETRY_SHADER ||
1854
+ program->stage .hw == AC_HW_PIXEL_SHADER))
1855
+ required_export_priority (program);
1788
1856
}
1789
1857
1790
1858
} // namespace aco
0 commit comments