r600/sfn: plumb the chip class into the instruction emission
authorDave Airlie <airlied@redhat.com>
Mon, 18 May 2020 05:14:35 +0000 (15:14 +1000)
committerMarge Bot <eric+marge@anholt.net>
Mon, 18 May 2020 21:56:29 +0000 (21:56 +0000)
In order to emit the correct instruction sequences for cayman
we need this info.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5084>

19 files changed:
src/gallium/drivers/r600/sfn/sfn_defines.h
src/gallium/drivers/r600/sfn/sfn_emitinstruction.cpp
src/gallium/drivers/r600/sfn/sfn_emitinstruction.h
src/gallium/drivers/r600/sfn/sfn_nir.cpp
src/gallium/drivers/r600/sfn/sfn_nir.h
src/gallium/drivers/r600/sfn/sfn_shader_base.cpp
src/gallium/drivers/r600/sfn/sfn_shader_base.h
src/gallium/drivers/r600/sfn/sfn_shader_compute.cpp
src/gallium/drivers/r600/sfn/sfn_shader_compute.h
src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp
src/gallium/drivers/r600/sfn/sfn_shader_fragment.h
src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp
src/gallium/drivers/r600/sfn/sfn_shader_geometry.h
src/gallium/drivers/r600/sfn/sfn_shader_tcs.cpp
src/gallium/drivers/r600/sfn/sfn_shader_tcs.h
src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.cpp
src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.h
src/gallium/drivers/r600/sfn/sfn_shader_vertex.cpp
src/gallium/drivers/r600/sfn/sfn_shader_vertex.h

index e114979e4c525f33777961b6339f81e1b5f6fabb..e3f52b3179bf49866858554b6a99defcf9db4b89 100644 (file)
@@ -28,7 +28,7 @@
 #define sfn_defines_h
 
 #include "../r600_isa.h"
-
+#include "amd_family.h"
 namespace r600 {
 
 
index e433cd1255e70346bdb02cb783c30d6b70c10e6e..c9c8662a669c7d28c5bfdbcc049b39d46edddeb3 100644 (file)
@@ -148,6 +148,11 @@ PValue EmitInstruction::create_register_from_nir_src(const nir_src& src, unsigne
    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};
index cfec84a959d21c6e3de4a65cbbb7b6efa9c31e27..961c0612994c45b69d2c49e4cd4e14b8b546bd9e 100644 (file)
@@ -28,6 +28,7 @@
 #define EMITINSTRUCTION_H
 
 #include "compiler/nir/nir.h"
+#include "sfn_defines.h"
 #include "sfn_value.h"
 #include "sfn_instruction_alu.h"
 
@@ -82,7 +83,7 @@ protected:
    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:
 
index 01e5617d0f8319f2cb4a767b0b5be6ad09560694..3f8badf6fc330e58ce5aa5ab502e8b2b5b156dfd 100644 (file)
@@ -55,34 +55,35 @@ ShaderFromNir::ShaderFromNir():sh(nullptr),
 
 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;
@@ -677,9 +678,9 @@ int r600_shader_from_nir(struct r600_context *rctx,
    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;
 
@@ -701,7 +702,6 @@ int r600_shader_from_nir(struct r600_context *rctx,
 
    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);
 
index 162b2e47b9df6b2848138c58f3d96fd521f19306..2b6f19fe58d078baf8de6c530ab9ea22e5c11cdd 100644 (file)
@@ -57,7 +57,7 @@ public:
 
    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();
 
@@ -79,6 +79,7 @@ private:
    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;
index b7f126c4def0d78c2f936ae9582114d80de522e9..2e9abfb613626aa3b289ca9acf6f47b44a1b1b4e 100644 (file)
@@ -58,12 +58,14 @@ using namespace std;
 
 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),
@@ -95,6 +97,11 @@ bool ShaderFromNirProcessor::scan_instruction(nir_instr *instr)
    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)
index 44376471819df40b0c52d880f3f323dbab1ac76c..dd0cd58dba5f54f40f51942968168cdc9e16ea89 100644 (file)
@@ -56,7 +56,7 @@ extern SfnLog sfn_log;
 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);
@@ -83,6 +83,7 @@ public:
    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);
@@ -191,7 +192,7 @@ private:
    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;
index e7499bfe4652d8d4d0328bd0052191aef422673a..e832b8a2b06ad4cfabf42feea397625bb4bac5b3 100644 (file)
@@ -31,9 +31,10 @@ namespace r600 {
 
 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)
 {
 }
index 8c7a022c2a82835d84beefc15c748882b2348111..bd6e792635f84a8b7f78d3962459ca928acd9510 100644 (file)
@@ -38,7 +38,8 @@ class ComputeShaderFromNir : public ShaderFromNirProcessor
 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;
 
index c3521f193629dd908b1d1d9d46124355b974895e..54c45143b1b5c2388ee0953a0e01d227f4add876 100644 (file)
@@ -34,8 +34,9 @@ namespace r600 {
 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),
index 918116718146c2cb7d1c47343a95b51ffcdfa292..fbf91708a4b957a57d9fe2e4f374ffe31ca87f69 100644 (file)
@@ -36,7 +36,8 @@ namespace r600 {
 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:
 
index 878e54e0630eebda89395da15f822d785851f280..6bdbb827497ee1e9aee18d3bbf942ef6ed9cfe82 100644 (file)
@@ -33,9 +33,10 @@ namespace r600 {
 
 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),
index cacbdaf50b70bf291cee6d4add282a98235b21b0..cbecc1b20c814bb54bf7b7dc216e7d4a5916a3a1 100644 (file)
@@ -35,7 +35,7 @@ namespace r600 {
 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;
index 11e657e67a30793589af698846f9cb1c216b1101..8e959cf27d2ecdb8286e02d314b14f8b3421bc4b 100644 (file)
@@ -6,9 +6,10 @@ namespace r600 {
 
 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;
index 8e6d4f1b15f734aceb337a8da6484d68ddb79e9c..06267d7a1b2c6ccbc9f9f0132458d55c6bde3fdb 100644 (file)
@@ -8,7 +8,7 @@ namespace r600 {
 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:
index 0c114194bf63d065d1cc953bb86efed9434f337b..351c32ffda5c0a075c90f100428d8e8f5cc6db33 100644 (file)
@@ -4,9 +4,10 @@
 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)
 
index ce715e2d7274bfaaa8ed955e1c89485c722f16ba..a9086a3268faa5423fbf25d9caa0abe47b7ae32f 100644 (file)
@@ -10,7 +10,8 @@ class TEvalShaderFromNir : public VertexStage
 {
 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:
index 8337553aec2c2068c0f92271d440dffb8586b15a..f6cdc648318c59104395cad74d6bf12b70870eef 100644 (file)
@@ -40,9 +40,10 @@ using std::priority_queue;
 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),
index f1c384523741f913c2f3ac5a31bee3bfa58efac3..4135cf1e3cd0dc4dcc40c3b5558d4614b8657603 100644 (file)
@@ -36,7 +36,8 @@ class VertexShaderFromNir : public VertexStage {
 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;