1 #ifndef VERTEXSTAGEEXPORT_H 2 #define VERTEXSTAGEEXPORT_H 3 4 #include "sfn_shader_base.h" 5 6 namespace r600 { 7 8 class VertexStage : public ShaderFromNirProcessor { 9 public: 10 using ShaderFromNirProcessor::ShaderFromNirProcessor; 11 12 virtual PValue primitive_id() = 0; 13 }; 14 15 class VertexStageExportBase 16 { 17 public: 18 VertexStageExportBase(VertexStage& proc); 19 virtual ~VertexStageExportBase(); 20 virtual bool store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) = 0; 21 virtual void finalize_exports() = 0; 22 virtual bool do_process_outputs(nir_variable *output); cur_param()23 int cur_param() const {return m_cur_param;} 24 protected: 25 VertexStage& m_proc; 26 std::map<unsigned, unsigned> m_param_map; 27 int m_cur_clip_pos; 28 int m_cur_param; 29 GPRVector m_clip_vertex; 30 }; 31 32 class VertexStageExportForFS : public VertexStageExportBase 33 { 34 public: 35 VertexStageExportForFS(VertexStage& proc, 36 const pipe_stream_output_info *so_info, 37 r600_pipe_shader *pipe_shader, 38 const r600_shader_key& key); 39 40 bool store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override; 41 void finalize_exports() override; 42 43 private: 44 bool emit_varying_param(const nir_variable *out_var, nir_intrinsic_instr* instr); 45 bool emit_varying_pos(const nir_variable *out_var, nir_intrinsic_instr* instr, 46 std::array<uint32_t, 4> *swizzle_override = nullptr); 47 bool emit_clip_vertices(const nir_variable *out_var, nir_intrinsic_instr* instr); 48 bool emit_stream(int stream); 49 50 ExportInstruction *m_last_param_export; 51 ExportInstruction *m_last_pos_export; 52 53 int m_num_clip_dist; 54 int m_enabled_stream_buffers_mask; 55 const pipe_stream_output_info *m_so_info; 56 r600_pipe_shader *m_pipe_shader; 57 const r600_shader_key& m_key; 58 59 }; 60 61 class VertexStageExportForGS : public VertexStageExportBase 62 { 63 public: 64 VertexStageExportForGS(VertexStage& proc, 65 const r600_shader *gs_shader); 66 bool store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override; 67 void finalize_exports() override; 68 69 private: 70 unsigned m_num_clip_dist; 71 const r600_shader *m_gs_shader; 72 }; 73 74 class VertexStageExportForES : public VertexStageExportBase 75 { 76 public: 77 VertexStageExportForES(VertexStage& proc); 78 bool store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override; 79 void finalize_exports() override; 80 }; 81 82 83 } 84 85 #endif // VERTEXSTAGEEXPORT_H 86