#include "brw_shader.h"
#include "brw_ir_fs.h"
#include "brw_fs_builder.h"
+#include "brw_fs_live_variables.h"
#include "compiler/nir/nir.h"
struct bblock_t;
struct acp_entry;
}
+class fs_visitor;
+
namespace brw {
- class fs_live_variables;
+ /**
+ * Register pressure analysis of a shader. Estimates how many registers
+ * are live at any point of the program in GRF units.
+ */
+ struct register_pressure {
+ register_pressure(const fs_visitor *v);
+ ~register_pressure();
+
+ analysis_dependency_class
+ dependency_class() const
+ {
+ return (DEPENDENCY_INSTRUCTION_IDENTITY |
+ DEPENDENCY_INSTRUCTION_DATA_FLOW |
+ DEPENDENCY_VARIABLES);
+ }
+
+ bool
+ validate(const fs_visitor *) const
+ {
+ /* FINISHME */
+ return true;
+ }
+
+ unsigned *regs_live_at_ip;
+ };
}
struct brw_gs_compile;
bool assign_regs(bool allow_spilling, bool spill_all);
void assign_regs_trivial();
void calculate_payload_ranges(int payload_node_count,
- int *payload_last_use_ip);
+ int *payload_last_use_ip) const;
void split_virtual_grfs();
bool compact_virtual_grfs();
void assign_constant_locations();
bool get_pull_locs(const fs_reg &src, unsigned *out_surf_index,
unsigned *out_pull_index);
void lower_constant_loads();
- void invalidate_live_intervals();
- void calculate_live_intervals();
- void calculate_register_pressure();
+ virtual void invalidate_analysis(brw::analysis_dependency_class c);
void validate();
bool opt_algebraic();
bool opt_redundant_discard_jumps();
bool opt_cse();
- bool opt_cse_local(bblock_t *block, int &ip);
+ bool opt_cse_local(const brw::fs_live_variables &live, bblock_t *block, int &ip);
+
bool opt_copy_propagation();
bool try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry);
bool try_constant_propagate(fs_inst *inst, acp_entry *entry);
bool remove_extra_rounding_modes();
bool opt_sampler_eot();
- bool virtual_grf_interferes(int a, int b);
void schedule_instructions(instruction_scheduler_mode mode);
void insert_gen4_send_dependency_workarounds();
void insert_gen4_pre_send_dependency_workarounds(bblock_t *block,
fs_reg interp_reg(int location, int channel);
- virtual void dump_instructions();
- virtual void dump_instructions(const char *name);
- void dump_instruction(backend_instruction *inst);
- void dump_instruction(backend_instruction *inst, FILE *file);
+ virtual void dump_instructions() const;
+ virtual void dump_instructions(const char *name) const;
+ void dump_instruction(const backend_instruction *inst) const;
+ void dump_instruction(const backend_instruction *inst, FILE *file) const;
const brw_base_prog_key *const key;
const struct brw_sampler_prog_key_data *key_tex;
const struct brw_vue_map *input_vue_map;
- int *virtual_grf_start;
- int *virtual_grf_end;
- brw::fs_live_variables *live_intervals;
+ int *param_size;
- int *regs_live_at_ip;
+ BRW_ANALYSIS(live_analysis, brw::fs_live_variables,
+ backend_shader *) live_analysis;
+ BRW_ANALYSIS(regpressure_analysis, brw::register_pressure,
+ fs_visitor *) regpressure_analysis;
/** Number of uniform variable components visited. */
unsigned uniforms;
int *push_constant_loc;
fs_reg subgroup_id;
+ fs_reg group_size[3];
fs_reg scratch_base;
fs_reg frag_depth;
fs_reg frag_stencil;
/**
* Return the flag register used in fragment shaders to keep track of live
- * samples.
+ * samples. On Gen7+ we use f1.0-f1.1 to allow discard jumps in SIMD32
+ * dispatch mode, while earlier generations are constrained to f0.1, which
+ * limits the dispatch width to SIMD16 for fragment shaders that use discard.
*/
static inline unsigned
sample_mask_flag_subreg(const fs_visitor *shader)
{
assert(shader->stage == MESA_SHADER_FRAGMENT);
- return 1;
+ return shader->devinfo->gen >= 7 ? 2 : 1;
}
/**
fs_generator(const struct brw_compiler *compiler, void *log_data,
void *mem_ctx,
struct brw_stage_prog_data *prog_data,
- struct shader_stats shader_stats,
bool runtime_check_aads_emit,
gl_shader_stage stage);
~fs_generator();
void enable_debug(const char *shader_name);
int generate_code(const cfg_t *cfg, int dispatch_width,
+ struct shader_stats shader_stats,
struct brw_compile_stats *stats);
const unsigned *get_assembly();
unsigned dispatch_width; /**< 8, 16 or 32 */
exec_list discard_halt_patches;
- struct shader_stats shader_stats;
bool runtime_check_aads_emit;
bool debug_flag;
const char *shader_name;
uint32_t brw_fb_write_msg_control(const fs_inst *inst,
const struct brw_wm_prog_data *prog_data);
+void brw_compute_urb_setup_index(struct brw_wm_prog_data *wm_prog_data);
#endif /* BRW_FS_H */