Commit f7df2c57 authored by Gert Wollny's avatar Gert Wollny Committed by Marge Bot

r600/sfn: extract class to handle the VS export to different stages

This code can be shared with the TESS_EVAL shader
Signed-off-by: Gert Wollny's avatarGert Wollny <gert.wollny@collabora.com>
Part-of: <mesa/mesa!4714>
parent 38038b36
......@@ -152,7 +152,9 @@ CXX_SOURCES = \
sfn/sfn_value_gpr.cpp \
sfn/sfn_value_gpr.h \
sfn/sfn_valuepool.cpp \
sfn/sfn_valuepool.h
sfn/sfn_valuepool.h \
sfn/sfn_vertexstageexport.cpp \
sfn/sfn_vertexstageexport.h
R600_GENERATED_FILES = \
egd_tables.h
......@@ -170,6 +170,8 @@ files_r600 = files(
'sfn/sfn_value_gpr.h',
'sfn/sfn_valuepool.cpp',
'sfn/sfn_valuepool.h',
'sfn/sfn_vertexstageexport.cpp',
'sfn/sfn_vertexstageexport.h',
)
egd_tables_h = custom_target(
......
......@@ -60,16 +60,8 @@ bool ShaderFromNir::lower(const nir_shader *shader, r600_pipe_shader *pipe_shade
switch (shader->info.stage) {
case MESA_SHADER_VERTEX:
if (key.vs.as_es) {
sfn_log << SfnLog::trans << "Start VS for GS\n";
impl.reset(new VertexShaderFromNirForGS(pipe_shader, *sel, key, gs_shader));
} else if (key.vs.as_ls) {
sfn_log << "VS: next type TCS and TES not yet supported\n";
return false;
} else {
sfn_log << SfnLog::trans << "Start VS for FS\n";
impl.reset(new VertexShaderFromNirForFS(pipe_shader, *sel, key));
}
impl.reset(new VertexShaderFromNir(pipe_shader, *sel, key, gs_shader));
break;
break;
case MESA_SHADER_GEOMETRY:
sfn_log << SfnLog::trans << "Start GS\n";
......
......@@ -105,11 +105,10 @@ protected:
bool emit_store_local_shared(nir_intrinsic_instr* instr);
bool emit_barrier(nir_intrinsic_instr* instr);
const GPRVector *output_register(unsigned location) const;
bool load_preloaded_value(const nir_dest& dest, int chan, PValue value,
bool as_last = true);
void add_param_output_reg(int loc, const GPRVector *gpr);
void inc_atomic_file_count();
std::bitset<8> m_sv_values;
......
......@@ -28,23 +28,21 @@
#define sfn_vertex_shader_from_nir_h
#include "sfn_shader_base.h"
#include "sfn_vertexstageexport.h"
namespace r600 {
class VertexShaderFromNir : public ShaderFromNirProcessor {
class VertexShaderFromNir : public VertexStage {
public:
VertexShaderFromNir(r600_pipe_shader *sh,
r600_pipe_shader_selector &sel,
const r600_shader_key &key);
const r600_shader_key &key, r600_shader *gs_shader);
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override;
bool scan_sysvalue_access(nir_instr *instr) override;
PValue primitive_id() override {return m_primitive_id;}
protected:
bool emit_varying_pos(const nir_variable *out_var, nir_intrinsic_instr* instr,
std::array<uint32_t, 4> *swizzle_override = nullptr);
bool emit_varying_param(const nir_variable *out_var, nir_intrinsic_instr* instr);
bool emit_clip_vertices(const nir_variable *out_var, nir_intrinsic_instr* instr);
bool emit_stream(int stream);
// todo: encapsulate
unsigned m_num_clip_dist;
......@@ -54,49 +52,26 @@ protected:
unsigned m_enabled_stream_buffers_mask;
const pipe_stream_output_info *m_so_info;
void do_finalize() override;
std::map<unsigned, unsigned> m_param_map;
private:
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
void finalize_exports();
void emit_shader_start() override;
bool do_process_inputs(nir_variable *input) override;
bool allocate_reserved_registers() override;
bool do_process_outputs(nir_variable *output) override;
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
virtual void finalize_exports() = 0;
unsigned m_cur_param;
std::map<unsigned, unsigned> m_param_map;
unsigned m_cur_clip_pos;
bool emit_store_local_shared(nir_intrinsic_instr* instr);
PValue m_vertex_id;
PValue m_instance_id;
PValue m_rel_vertex_id;
PValue m_primitive_id;
r600_shader_key m_key;
};
class VertexShaderFromNirForFS : public VertexShaderFromNir {
public:
using VertexShaderFromNir::VertexShaderFromNir;
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
private:
void finalize_exports() override;
};
class VertexShaderFromNirForGS : public VertexShaderFromNir {
public:
VertexShaderFromNirForGS(r600_pipe_shader *sh, r600_pipe_shader_selector &sel,
const r600_shader_key &key, const r600_shader *gs_shader);
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
void finalize_exports() override;
const r600_shader *m_gs_shader;
};
class VertexShaderFromNirForES : public VertexShaderFromNir {
public:
VertexShaderFromNirForES(r600_pipe_shader *sh, const pipe_stream_output_info *so_info, r600_pipe_shader_selector &sel,
const r600_shader_key &key);
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
void finalize_exports() override;
std::unique_ptr<VertexStageExportBase> m_export_processor;
};
}
......
This diff is collapsed.
#ifndef VERTEXSTAGEEXPORT_H
#define VERTEXSTAGEEXPORT_H
#include "sfn_shader_base.h"
namespace r600 {
class VertexStage : public ShaderFromNirProcessor {
public:
using ShaderFromNirProcessor::ShaderFromNirProcessor;
virtual PValue primitive_id() = 0;
};
class VertexStageExportBase
{
public:
VertexStageExportBase(VertexStage& proc);
virtual ~VertexStageExportBase();
void setup_paramn_map();
virtual bool store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) = 0;
virtual void finalize_exports() = 0;
virtual bool do_process_outputs(nir_variable *output);
int cur_param() const {return m_cur_param;}
protected:
VertexStage& m_proc;
std::map<unsigned, unsigned> m_param_map;
int m_cur_clip_pos;
int m_cur_param;
};
class VertexStageExportForFS : public VertexStageExportBase
{
public:
VertexStageExportForFS(VertexStage& proc,
const pipe_stream_output_info *so_info,
r600_pipe_shader *pipe_shader,
const r600_shader_key& key);
bool store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
void finalize_exports() override;
private:
bool emit_varying_param(const nir_variable *out_var, nir_intrinsic_instr* instr);
bool emit_varying_pos(const nir_variable *out_var, nir_intrinsic_instr* instr,
std::array<uint32_t, 4> *swizzle_override = nullptr);
bool emit_clip_vertices(const nir_variable *out_var, nir_intrinsic_instr* instr);
bool emit_stream(int stream);
ExportInstruction *m_last_param_export;
ExportInstruction *m_last_pos_export;
int m_num_clip_dist;
int m_enabled_stream_buffers_mask;
const pipe_stream_output_info *m_so_info;
r600_pipe_shader *m_pipe_shader;
const r600_shader_key& m_key;
};
class VertexStageExportForGS : public VertexStageExportBase
{
public:
VertexStageExportForGS(VertexStage& proc,
const r600_shader *gs_shader);
bool store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
void finalize_exports() override;
private:
unsigned m_num_clip_dist;
const r600_shader *m_gs_shader;
};
class VertexStageExportForES : public VertexStageExportBase
{
public:
VertexStageExportForES(VertexStage& proc);
bool store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
void finalize_exports() override;
};
}
#endif // VERTEXSTAGEEXPORT_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment