#define sfn_defines_h
#include "../r600_isa.h"
-
+#include "amd_family.h"
namespace r600 {
return m_proc.create_register_from_nir_src(src, swizzle);
}
+enum chip_class EmitInstruction::get_chip_class(void) const
+{
+ return m_proc.get_chip_class();
+}
+
const std::set<AluModifiers> EmitInstruction::empty = {};
const std::set<AluModifiers> EmitInstruction::write = {alu_write};
const std::set<AluModifiers> EmitInstruction::last_write = {alu_write, alu_last_instr};
#define EMITINSTRUCTION_H
#include "compiler/nir/nir.h"
+#include "sfn_defines.h"
#include "sfn_value.h"
#include "sfn_instruction_alu.h"
void load_uniform(const nir_alu_src& src);
const nir_variable *get_deref_location(const nir_src& v) const;
-
+ enum chip_class get_chip_class(void) const;
private:
bool ShaderFromNir::lower(const nir_shader *shader, r600_pipe_shader *pipe_shader,
r600_pipe_shader_selector *sel, r600_shader_key& key,
- struct r600_shader* gs_shader)
+ struct r600_shader* gs_shader, enum chip_class _chip_class)
{
sh = shader;
+ chip_class = _chip_class;
assert(sh);
switch (shader->info.stage) {
case MESA_SHADER_VERTEX:
- impl.reset(new VertexShaderFromNir(pipe_shader, *sel, key, gs_shader));
+ impl.reset(new VertexShaderFromNir(pipe_shader, *sel, key, gs_shader, chip_class));
break;
case MESA_SHADER_TESS_CTRL:
sfn_log << SfnLog::trans << "Start TCS\n";
- impl.reset(new TcsShaderFromNir(pipe_shader, *sel, key));
+ impl.reset(new TcsShaderFromNir(pipe_shader, *sel, key, chip_class));
break;
case MESA_SHADER_TESS_EVAL:
sfn_log << SfnLog::trans << "Start TESS_EVAL\n";
- impl.reset(new TEvalShaderFromNir(pipe_shader, *sel, key, gs_shader));
+ impl.reset(new TEvalShaderFromNir(pipe_shader, *sel, key, gs_shader, chip_class));
break;
case MESA_SHADER_GEOMETRY:
sfn_log << SfnLog::trans << "Start GS\n";
- impl.reset(new GeometryShaderFromNir(pipe_shader, *sel, key));
+ impl.reset(new GeometryShaderFromNir(pipe_shader, *sel, key, chip_class));
break;
case MESA_SHADER_FRAGMENT:
sfn_log << SfnLog::trans << "Start FS\n";
- impl.reset(new FragmentShaderFromNir(*shader, pipe_shader->shader, *sel, key));
+ impl.reset(new FragmentShaderFromNir(*shader, pipe_shader->shader, *sel, key, chip_class));
break;
case MESA_SHADER_COMPUTE:
sfn_log << SfnLog::trans << "Start CS\n";
- impl.reset(new ComputeShaderFromNir(pipe_shader, *sel, key));
+ impl.reset(new ComputeShaderFromNir(pipe_shader, *sel, key, chip_class));
break;
default:
return false;
struct r600_shader* gs_shader = nullptr;
if (rctx->gs_shader)
gs_shader = &rctx->gs_shader->current->shader;
+ r600_screen *rscreen = rctx->screen;
- bool r = convert.lower(sel->nir, pipeshader, sel, *key, gs_shader);
-
+ bool r = convert.lower(sel->nir, pipeshader, sel, *key, gs_shader, rscreen->b.chip_class);
if (!r || rctx->screen->b.debug_flags & DBG_ALL_SHADERS) {
static int shnr = 0;
auto shader = convert.shader();
- r600_screen *rscreen = rctx->screen;
r600_bytecode_init(&pipeshader->shader.bc, rscreen->b.chip_class, rscreen->b.family,
rscreen->has_compressed_msaa_texturing);
bool lower(const nir_shader *shader, r600_pipe_shader *sh,
r600_pipe_shader_selector *sel, r600_shader_key &key,
- r600_shader *gs_shader);
+ r600_shader *gs_shader, enum chip_class chip_class);
bool process_declaration();
std::unique_ptr<ShaderFromNirProcessor> impl;
const nir_shader *sh;
+ enum chip_class chip_class;
int m_current_if_id;
int m_current_loop_id;
std::stack<int> m_if_stack;
ShaderFromNirProcessor::ShaderFromNirProcessor(pipe_shader_type ptype,
r600_pipe_shader_selector& sel,
- r600_shader &sh_info, int scratch_size):
+ r600_shader &sh_info, int scratch_size,
+ enum chip_class chip_class):
m_processor_type(ptype),
m_nesting_depth(0),
m_block_number(0),
m_export_output(0, -1),
m_sh_info(sh_info),
+ m_chip_class(chip_class),
m_tex_instr(*this),
m_alu_instr(*this),
m_ssbo_instr(*this),
return scan_sysvalue_access(instr);
}
+enum chip_class ShaderFromNirProcessor::get_chip_class(void) const
+{
+ return m_chip_class;
+}
+
static void remap_shader_info(r600_shader& sh_info,
std::vector<rename_reg_pair>& map,
UNUSED ValueMap& values)
class ShaderFromNirProcessor : public ValuePool {
public:
ShaderFromNirProcessor(pipe_shader_type ptype, r600_pipe_shader_selector& sel,
- r600_shader& sh_info, int scratch_size);
+ r600_shader& sh_info, int scratch_size, enum chip_class _chip_class);
virtual ~ShaderFromNirProcessor();
void emit_instruction(Instruction *ir);
const GPRVector *output_register(unsigned location) const;
void evaluate_spi_sid(r600_shader_io &io);
+ enum chip_class get_chip_class() const;
protected:
void set_var_address(nir_deref_instr *instr);
unsigned m_block_number;
InstructionBlock m_export_output;
r600_shader& m_sh_info;
-
+ enum chip_class m_chip_class;
EmitTexInstruction m_tex_instr;
EmitAluInstruction m_alu_instr;
EmitSSBOInstruction m_ssbo_instr;
ComputeShaderFromNir::ComputeShaderFromNir(r600_pipe_shader *sh,
r600_pipe_shader_selector& sel,
- UNUSED const r600_shader_key& key):
+ UNUSED const r600_shader_key& key,
+ enum chip_class chip_class):
ShaderFromNirProcessor (PIPE_SHADER_COMPUTE, sel, sh->shader,
- sh->scratch_space_needed),
+ sh->scratch_space_needed, chip_class),
m_reserved_registers(0)
{
}
public:
ComputeShaderFromNir(r600_pipe_shader *sh,
r600_pipe_shader_selector& sel,
- const r600_shader_key &key);
+ const r600_shader_key &key,
+ enum chip_class chip_class);
bool scan_sysvalue_access(nir_instr *instr) override;
FragmentShaderFromNir::FragmentShaderFromNir(const nir_shader& nir,
r600_shader& sh,
r600_pipe_shader_selector &sel,
- const r600_shader_key &key):
- ShaderFromNirProcessor(PIPE_SHADER_FRAGMENT, sel, sh, nir.scratch_size),
+ const r600_shader_key &key,
+ enum chip_class chip_class):
+ ShaderFromNirProcessor(PIPE_SHADER_FRAGMENT, sel, sh, nir.scratch_size, chip_class),
m_max_color_exports(MAX2(key.ps.nr_cbufs,1)),
m_max_counted_color_exports(0),
m_two_sided_color(key.ps.color_two_side),
class FragmentShaderFromNir : public ShaderFromNirProcessor {
public:
FragmentShaderFromNir(const nir_shader& nir, r600_shader& sh_info,
- r600_pipe_shader_selector &sel, const r600_shader_key &key);
+ r600_pipe_shader_selector &sel, const r600_shader_key &key,
+ enum chip_class chip_class);
bool scan_sysvalue_access(nir_instr *instr) override;
private:
GeometryShaderFromNir::GeometryShaderFromNir(r600_pipe_shader *sh,
r600_pipe_shader_selector &sel,
- const r600_shader_key &key):
+ const r600_shader_key &key,
+ enum chip_class chip_class):
VertexStage(PIPE_SHADER_GEOMETRY, sel, sh->shader,
- sh->scratch_space_needed),
+ sh->scratch_space_needed, chip_class),
m_pipe_shader(sh),
m_so_info(&sel.so),
m_first_vertex_emitted(false),
class GeometryShaderFromNir : public VertexStage
{
public:
- GeometryShaderFromNir(r600_pipe_shader *sh, r600_pipe_shader_selector& sel, const r600_shader_key& key);
+ GeometryShaderFromNir(r600_pipe_shader *sh, r600_pipe_shader_selector& sel, const r600_shader_key& key, enum chip_class chip_class);
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override;
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
bool scan_sysvalue_access(nir_instr *instr) override;
TcsShaderFromNir::TcsShaderFromNir(r600_pipe_shader *sh,
r600_pipe_shader_selector& sel,
- const r600_shader_key& key):
+ const r600_shader_key& key,
+ enum chip_class chip_class):
ShaderFromNirProcessor (PIPE_SHADER_TESS_CTRL, sel, sh->shader,
- sh->scratch_space_needed),
+ sh->scratch_space_needed, chip_class),
m_reserved_registers(0)
{
sh_info().tcs_prim_mode = key.tcs.prim_mode;
class TcsShaderFromNir : public ShaderFromNirProcessor
{
public:
- TcsShaderFromNir(r600_pipe_shader *sh, r600_pipe_shader_selector& sel, const r600_shader_key& key);
+ TcsShaderFromNir(r600_pipe_shader *sh, r600_pipe_shader_selector& sel, const r600_shader_key& key, enum chip_class chip_class);
bool scan_sysvalue_access(nir_instr *instr) override;
private:
namespace r600 {
TEvalShaderFromNir::TEvalShaderFromNir(r600_pipe_shader *sh, r600_pipe_shader_selector& sel,
- const r600_shader_key& key, r600_shader *gs_shader):
+ const r600_shader_key& key, r600_shader *gs_shader,
+ enum chip_class chip_class):
VertexStage(PIPE_SHADER_TESS_EVAL, sel, sh->shader,
- sh->scratch_space_needed),
+ sh->scratch_space_needed, chip_class),
m_reserved_registers(0),
m_key(key)
{
public:
TEvalShaderFromNir(r600_pipe_shader *sh, r600_pipe_shader_selector& sel,
- const r600_shader_key& key, r600_shader *gs_shader);
+ const r600_shader_key& key, r600_shader *gs_shader,
+ enum chip_class chip_class);
bool scan_sysvalue_access(nir_instr *instr) override;
PValue primitive_id() override {return m_primitive_id;}
private:
VertexShaderFromNir::VertexShaderFromNir(r600_pipe_shader *sh,
r600_pipe_shader_selector& sel,
const r600_shader_key& key,
- struct r600_shader* gs_shader):
+ struct r600_shader* gs_shader,
+ enum chip_class chip_class):
VertexStage(PIPE_SHADER_VERTEX, sel, sh->shader,
- sh->scratch_space_needed),
+ sh->scratch_space_needed, chip_class),
m_num_clip_dist(0),
m_last_param_export(nullptr),
m_last_pos_export(nullptr),
public:
VertexShaderFromNir(r600_pipe_shader *sh,
r600_pipe_shader_selector &sel,
- const r600_shader_key &key, r600_shader *gs_shader);
+ const r600_shader_key &key, r600_shader *gs_shader,
+ enum chip_class chip_class);
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override;
bool scan_sysvalue_access(nir_instr *instr) override;