xref: /aosp_15_r20/external/mesa3d/src/intel/compiler/elk/elk_vec4_vs_visitor.cpp (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2013 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
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 
25 #include "elk_vec4_vs.h"
26 #include "dev/intel_debug.h"
27 
28 namespace elk {
29 
30 void
emit_prolog()31 vec4_vs_visitor::emit_prolog()
32 {
33 }
34 
35 
36 void
emit_urb_write_header(int mrf)37 vec4_vs_visitor::emit_urb_write_header(int mrf)
38 {
39    /* No need to do anything for VS; an implied write to this MRF will be
40     * performed by ELK_VEC4_VS_OPCODE_URB_WRITE.
41     */
42    (void) mrf;
43 }
44 
45 
46 vec4_instruction *
emit_urb_write_opcode(bool complete)47 vec4_vs_visitor::emit_urb_write_opcode(bool complete)
48 {
49    vec4_instruction *inst = emit(ELK_VEC4_VS_OPCODE_URB_WRITE);
50    inst->urb_write_flags = complete ?
51       ELK_URB_WRITE_EOT_COMPLETE : ELK_URB_WRITE_NO_FLAGS;
52 
53    return inst;
54 }
55 
56 
57 void
emit_urb_slot(dst_reg reg,int varying)58 vec4_vs_visitor::emit_urb_slot(dst_reg reg, int varying)
59 {
60    reg.type = ELK_REGISTER_TYPE_F;
61    output_reg[varying][0].type = reg.type;
62 
63    switch (varying) {
64    case VARYING_SLOT_COL0:
65    case VARYING_SLOT_COL1:
66    case VARYING_SLOT_BFC0:
67    case VARYING_SLOT_BFC1: {
68       /* These built-in varyings are only supported in compatibility mode,
69        * and we only support GS in core profile.  So, this must be a vertex
70        * shader.
71        */
72       vec4_instruction *inst = emit_generic_urb_slot(reg, varying, 0);
73       if (inst && key->clamp_vertex_color)
74          inst->saturate = true;
75       break;
76    }
77    default:
78       return vec4_visitor::emit_urb_slot(reg, varying);
79    }
80 }
81 
82 
83 void
emit_thread_end()84 vec4_vs_visitor::emit_thread_end()
85 {
86    /* For VS, we always end the thread by emitting a single vertex.
87     * emit_urb_write_opcode() will take care of setting the eot flag on the
88     * SEND instruction.
89     */
90    emit_vertex();
91 }
92 
93 
vec4_vs_visitor(const struct elk_compiler * compiler,const struct elk_compile_params * params,const struct elk_vs_prog_key * key,struct elk_vs_prog_data * vs_prog_data,const nir_shader * shader,bool debug_enabled)94 vec4_vs_visitor::vec4_vs_visitor(const struct elk_compiler *compiler,
95                                  const struct elk_compile_params *params,
96                                  const struct elk_vs_prog_key *key,
97                                  struct elk_vs_prog_data *vs_prog_data,
98                                  const nir_shader *shader,
99                                  bool debug_enabled)
100    : vec4_visitor(compiler, params, &key->base.tex, &vs_prog_data->base,
101                   shader, false /* no_spills */, debug_enabled),
102      key(key),
103      vs_prog_data(vs_prog_data)
104 {
105 }
106 
107 
108 } /* namespace elk */
109