• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  Copyright (C) Intel Corp.  2006.  All Rights Reserved.
3  Intel funded Tungsten Graphics to
4  develop this 3D driver.
5 
6  Permission is hereby granted, free of charge, to any person obtaining
7  a copy of this software and associated documentation files (the
8  "Software"), to deal in the Software without restriction, including
9  without limitation the rights to use, copy, modify, merge, publish,
10  distribute, sublicense, and/or sell copies of the Software, and to
11  permit persons to whom the Software is furnished to do so, subject to
12  the following conditions:
13 
14  The above copyright notice and this permission notice (including the
15  next paragraph) shall be included in all copies or substantial
16  portions of the Software.
17 
18  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 
26  **********************************************************************/
27  /*
28   * Authors:
29   *   Keith Whitwell <keithw@vmware.com>
30   */
31 
32 
33 #ifndef BRW_VS_H
34 #define BRW_VS_H
35 
36 
37 #include "brw_vec4.h"
38 
39 /**
40  * The VF can't natively handle certain types of attributes, such as GL_FIXED
41  * or most 10_10_10_2 types.  These flags enable various VS workarounds to
42  * "fix" attributes at the beginning of shaders.
43  */
44 #define BRW_ATTRIB_WA_COMPONENT_MASK    7  /* mask for GL_FIXED scale channel count */
45 #define BRW_ATTRIB_WA_NORMALIZE     8   /* normalize in shader */
46 #define BRW_ATTRIB_WA_BGRA          16  /* swap r/b channels in shader */
47 #define BRW_ATTRIB_WA_SIGN          32  /* interpret as signed in shader */
48 #define BRW_ATTRIB_WA_SCALE         64  /* interpret as scaled in shader */
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 GLbitfield64
55 brw_vs_outputs_written(struct brw_context *brw, struct brw_vs_prog_key *key,
56                        GLbitfield64 outputs_written);
57 
58 void
59 brw_upload_vs_prog(struct brw_context *brw);
60 
61 void
62 brw_vs_populate_key(struct brw_context *brw,
63                     struct brw_vs_prog_key *key);
64 
65 #ifdef __cplusplus
66 } /* extern "C" */
67 
68 
69 namespace brw {
70 
71 class vec4_vs_visitor : public vec4_visitor
72 {
73 public:
74    vec4_vs_visitor(const struct brw_compiler *compiler,
75                    void *log_data,
76                    const struct brw_vs_prog_key *key,
77                    struct brw_vs_prog_data *vs_prog_data,
78                    const nir_shader *shader,
79                    gl_clip_plane *clip_planes,
80                    void *mem_ctx,
81                    int shader_time_index,
82                    bool use_legacy_snorm_formula);
83 
84 protected:
85    virtual dst_reg *make_reg_for_system_value(int location);
86    virtual void setup_payload();
87    virtual void emit_prolog();
88    virtual void emit_thread_end();
89    virtual void emit_urb_write_header(int mrf);
90    virtual void emit_urb_slot(dst_reg reg, int varying);
91    virtual vec4_instruction *emit_urb_write_opcode(bool complete);
92 
93 private:
94    int setup_attributes(int payload_reg);
95    void setup_uniform_clipplane_values();
96    void emit_clip_distances(dst_reg reg, int offset);
97 
98    const struct brw_vs_prog_key *const key;
99    struct brw_vs_prog_data * const vs_prog_data;
100 
101    gl_clip_plane *clip_planes;
102 
103    bool use_legacy_snorm_formula;
104 };
105 
106 } /* namespace brw */
107 
108 
109 #endif
110 
111 #endif
112