aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2020-05-18 15:14:35 +1000
committerMarge Bot <[email protected]>2020-05-18 21:56:29 +0000
commitff9c95421a64a349ca70a61b1a6c9cd22198cd67 (patch)
tree4c4986add20266d7e99582e0f432d61fc21df3f3 /src/gallium/drivers/r600
parent164aed6c8142a995c6ac1c36ee7a16896f675163 (diff)
r600/sfn: plumb the chip class into the instruction emission
In order to emit the correct instruction sequences for cayman we need this info. Reviewed-by: Gert Wollny <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5084>
Diffstat (limited to 'src/gallium/drivers/r600')
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_defines.h2
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_emitinstruction.cpp5
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_emitinstruction.h3
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_nir.cpp20
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_nir.h3
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_base.cpp9
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_base.h5
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_compute.cpp5
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_compute.h3
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp5
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_fragment.h3
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp5
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_geometry.h2
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_tcs.cpp5
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_tcs.h2
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.cpp5
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.h3
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_vertex.cpp5
-rw-r--r--src/gallium/drivers/r600/sfn/sfn_shader_vertex.h3
19 files changed, 59 insertions, 34 deletions
diff --git a/src/gallium/drivers/r600/sfn/sfn_defines.h b/src/gallium/drivers/r600/sfn/sfn_defines.h
index e114979e4c5..e3f52b3179b 100644
--- a/src/gallium/drivers/r600/sfn/sfn_defines.h
+++ b/src/gallium/drivers/r600/sfn/sfn_defines.h
@@ -28,7 +28,7 @@
#define sfn_defines_h
#include "../r600_isa.h"
-
+#include "amd_family.h"
namespace r600 {
diff --git a/src/gallium/drivers/r600/sfn/sfn_emitinstruction.cpp b/src/gallium/drivers/r600/sfn/sfn_emitinstruction.cpp
index e433cd1255e..c9c8662a669 100644
--- a/src/gallium/drivers/r600/sfn/sfn_emitinstruction.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_emitinstruction.cpp
@@ -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};
diff --git a/src/gallium/drivers/r600/sfn/sfn_emitinstruction.h b/src/gallium/drivers/r600/sfn/sfn_emitinstruction.h
index cfec84a959d..961c0612994 100644
--- a/src/gallium/drivers/r600/sfn/sfn_emitinstruction.h
+++ b/src/gallium/drivers/r600/sfn/sfn_emitinstruction.h
@@ -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:
diff --git a/src/gallium/drivers/r600/sfn/sfn_nir.cpp b/src/gallium/drivers/r600/sfn/sfn_nir.cpp
index 01e5617d0f8..3f8badf6fc3 100644
--- a/src/gallium/drivers/r600/sfn/sfn_nir.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_nir.cpp
@@ -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);
diff --git a/src/gallium/drivers/r600/sfn/sfn_nir.h b/src/gallium/drivers/r600/sfn/sfn_nir.h
index 162b2e47b9d..2b6f19fe58d 100644
--- a/src/gallium/drivers/r600/sfn/sfn_nir.h
+++ b/src/gallium/drivers/r600/sfn/sfn_nir.h
@@ -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;
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp
index b7f126c4def..2e9abfb6136 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp
@@ -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)
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_base.h b/src/gallium/drivers/r600/sfn/sfn_shader_base.h
index 44376471819..dd0cd58dba5 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_base.h
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_base.h
@@ -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;
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_compute.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_compute.cpp
index e7499bfe465..e832b8a2b06 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_compute.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_compute.cpp
@@ -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)
{
}
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_compute.h b/src/gallium/drivers/r600/sfn/sfn_shader_compute.h
index 8c7a022c2a8..bd6e792635f 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_compute.h
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_compute.h
@@ -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;
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp
index c3521f19362..54c45143b1b 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp
@@ -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),
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_fragment.h b/src/gallium/drivers/r600/sfn/sfn_shader_fragment.h
index 91811671814..fbf91708a4b 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_fragment.h
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_fragment.h
@@ -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:
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp
index 878e54e0630..6bdbb827497 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp
@@ -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),
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_geometry.h b/src/gallium/drivers/r600/sfn/sfn_shader_geometry.h
index cacbdaf50b7..cbecc1b20c8 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_geometry.h
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_geometry.h
@@ -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;
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_tcs.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_tcs.cpp
index 11e657e67a3..8e959cf27d2 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_tcs.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_tcs.cpp
@@ -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;
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_tcs.h b/src/gallium/drivers/r600/sfn/sfn_shader_tcs.h
index 8e6d4f1b15f..06267d7a1b2 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_tcs.h
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_tcs.h
@@ -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:
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.cpp
index 0c114194bf6..351c32ffda5 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.cpp
@@ -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)
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.h b/src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.h
index ce715e2d727..a9086a3268f 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.h
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_tess_eval.h
@@ -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:
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_vertex.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_vertex.cpp
index 8337553aec2..f6cdc648318 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_vertex.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_vertex.cpp
@@ -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),
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_vertex.h b/src/gallium/drivers/r600/sfn/sfn_shader_vertex.h
index f1c38452374..4135cf1e3cd 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_vertex.h
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_vertex.h
@@ -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;