xref: /aosp_15_r20/external/mesa3d/src/intel/compiler/elk/elk_gfx6_gs_visitor.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2014 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  */
24 
25 #ifndef ELK_GFX6_GS_VISITOR_H
26 #define ELK_GFX6_GS_VISITOR_H
27 
28 #include "elk_vec4.h"
29 #include "elk_vec4_gs_visitor.h"
30 
31 #ifdef __cplusplus
32 
33 namespace elk {
34 
35 class gfx6_gs_visitor : public vec4_gs_visitor
36 {
37 public:
gfx6_gs_visitor(const struct elk_compiler * comp,const struct elk_compile_params * params,struct elk_gs_compile * c,struct elk_gs_prog_data * prog_data,const nir_shader * shader,bool no_spills,bool debug_enabled)38    gfx6_gs_visitor(const struct elk_compiler *comp,
39                    const struct elk_compile_params *params,
40                    struct elk_gs_compile *c,
41                    struct elk_gs_prog_data *prog_data,
42                    const nir_shader *shader,
43                    bool no_spills,
44                    bool debug_enabled) :
45       vec4_gs_visitor(comp, params, c, prog_data, shader, no_spills, debug_enabled)
46       {
47       }
48 
49 protected:
50    virtual void emit_prolog();
51    virtual void emit_thread_end();
52    virtual void gs_emit_vertex(int stream_id);
53    virtual void gs_end_primitive();
54    virtual void emit_urb_write_header(int mrf);
55    virtual void setup_payload();
56 
57 private:
58    void xfb_write();
59    void xfb_program(unsigned vertex, unsigned num_verts);
60    int get_vertex_output_offset_for_varying(int vertex, int varying);
61    void emit_snb_gs_urb_write_opcode(bool complete,
62                                      int base_mrf,
63                                      int last_mrf,
64                                      int urb_offset);
65 
66    src_reg vertex_output;
67    src_reg vertex_output_offset;
68    src_reg temp;
69    src_reg first_vertex;
70    src_reg prim_count;
71    src_reg primitive_id;
72 
73    /* Transform Feedback members */
74    src_reg sol_prim_written;
75    src_reg svbi;
76    src_reg max_svbi;
77    src_reg destination_indices;
78 };
79 
80 } /* namespace elk */
81 
82 #endif /* __cplusplus */
83 
84 #endif /* ELK_GFX6_GS_VISITOR_H */
85