i915: Remove most of the code under gen >= 4 checks.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vs.h
1 /*
2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) 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 <keith@tungstengraphics.com>
30 */
31
32
33 #ifndef BRW_VS_H
34 #define BRW_VS_H
35
36
37 #include "brw_context.h"
38 #include "brw_eu.h"
39 #include "brw_program.h"
40 #include "program/program.h"
41
42 /**
43 * The VF can't natively handle certain types of attributes, such as GL_FIXED
44 * or most 10_10_10_2 types. These flags enable various VS workarounds to
45 * "fix" attributes at the beginning of shaders.
46 */
47 #define BRW_ATTRIB_WA_COMPONENT_MASK 7 /* mask for GL_FIXED scale channel count */
48 #define BRW_ATTRIB_WA_NORMALIZE 8 /* normalize in shader */
49 #define BRW_ATTRIB_WA_BGRA 16 /* swap r/b channels in shader */
50 #define BRW_ATTRIB_WA_SIGN 32 /* interpret as signed in shader */
51 #define BRW_ATTRIB_WA_SCALE 64 /* interpret as scaled in shader */
52
53 struct brw_vec4_prog_key {
54 GLuint program_string_id;
55
56 /**
57 * True if at least one clip flag is enabled, regardless of whether the
58 * shader uses clip planes or gl_ClipDistance.
59 */
60 GLuint userclip_active:1;
61
62 /**
63 * How many user clipping planes are being uploaded to the vertex shader as
64 * push constants.
65 */
66 GLuint nr_userclip_plane_consts:4;
67
68 /**
69 * True if the shader uses gl_ClipDistance, regardless of whether any clip
70 * flags are enabled.
71 */
72 GLuint uses_clip_distance:1;
73
74 /**
75 * For pre-Gen6 hardware, a bitfield indicating which clipping planes are
76 * enabled. This is used to compact clip planes.
77 *
78 * For Gen6 and later hardware, clip planes are not compacted, so this
79 * value is zero to avoid provoking unnecessary shader recompiles.
80 */
81 GLuint userclip_planes_enabled_gen_4_5:MAX_CLIP_PLANES;
82
83 GLuint clamp_vertex_color:1;
84
85 struct brw_sampler_prog_key_data tex;
86 };
87
88
89 struct brw_vs_prog_key {
90 struct brw_vec4_prog_key base;
91
92 /*
93 * Per-attribute workaround flags
94 */
95 uint8_t gl_attrib_wa_flags[VERT_ATTRIB_MAX];
96
97 GLuint copy_edgeflag:1;
98
99 /**
100 * For pre-Gen6 hardware, a bitfield indicating which texture coordinates
101 * are going to be replaced with point coordinates (as a consequence of a
102 * call to glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)). Because
103 * our SF thread requires exact matching between VS outputs and FS inputs,
104 * these texture coordinates will need to be unconditionally included in
105 * the VUE, even if they aren't written by the vertex shader.
106 */
107 GLuint point_coord_replace:8;
108 };
109
110
111 struct brw_vec4_compile {
112 GLuint last_scratch; /**< measured in 32-byte (register size) units */
113 };
114
115
116 struct brw_vs_compile {
117 struct brw_vec4_compile base;
118 struct brw_vs_prog_key key;
119
120 struct brw_vertex_program *vp;
121 };
122
123 const unsigned *brw_vs_emit(struct brw_context *brw,
124 struct gl_shader_program *prog,
125 struct brw_vs_compile *c,
126 struct brw_vs_prog_data *prog_data,
127 void *mem_ctx,
128 unsigned *program_size);
129 bool brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
130 void brw_vs_debug_recompile(struct brw_context *brw,
131 struct gl_shader_program *prog,
132 const struct brw_vs_prog_key *key);
133 bool brw_vec4_prog_data_compare(const struct brw_vec4_prog_data *a,
134 const struct brw_vec4_prog_data *b);
135 bool brw_vs_prog_data_compare(const void *a, const void *b,
136 int aux_size, const void *key);
137 void brw_vec4_prog_data_free(const struct brw_vec4_prog_data *prog_data);
138 void brw_vs_prog_data_free(const void *in_prog_data);
139
140 #endif