st/mesa: remove dead stfp input_map array
[mesa.git] / src / mesa / state_tracker / st_program.h
1 /**************************************************************************
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * 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, sub license, 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 portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Keith Whitwell <keith@tungstengraphics.com>
31 */
32
33
34 #ifndef ST_PROGRAM_H
35 #define ST_PROGRAM_H
36
37 #include "main/mtypes.h"
38 #include "shader/program.h"
39 #include "pipe/p_shader_tokens.h"
40
41
42 struct cso_fragment_shader;
43 struct cso_vertex_shader;
44 struct translated_vertex_program;
45
46
47 /**
48 * Derived from Mesa gl_fragment_program:
49 */
50 struct st_fragment_program
51 {
52 struct gl_fragment_program Base;
53 GLuint serialNo;
54
55 GLuint input_to_slot[FRAG_ATTRIB_MAX]; /**< Maps FRAG_ATTRIB_x to slot */
56 GLuint num_input_slots;
57
58 ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
59 ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
60
61 struct pipe_shader_state state;
62 void *driver_shader;
63
64 /** Program prefixed with glBitmap prologue */
65 struct st_fragment_program *bitmap_program;
66 uint bitmap_sampler;
67 };
68
69
70
71 struct st_vp_varient_key
72 {
73 boolean passthrough_edgeflags;
74 };
75
76
77 /**
78 * This represents a vertex program, especially translated to match
79 * the inputs of a particular fragment shader.
80 */
81 struct st_vp_varient
82 {
83 /* Parameters which generated this translated version of a vertex
84 * shader:
85 */
86 struct st_vp_varient_key key;
87
88 /** TGSI tokens -- why?
89 */
90 struct pipe_shader_state state;
91
92 /** Driver's compiled shader */
93 void *driver_shader;
94
95 /** For using our private draw module (glRasterPos) */
96 struct draw_vertex_shader *draw_shader;
97
98 /** Next in linked list */
99 struct st_vp_varient *next;
100
101 /** similar to that in st_vertex_program, but with information about edgeflags too */
102 GLuint num_inputs;
103 };
104
105
106
107
108 /**
109 * Derived from Mesa gl_fragment_program:
110 */
111 struct st_vertex_program
112 {
113 struct gl_vertex_program Base; /**< The Mesa vertex program */
114 GLuint serialNo, lastSerialNo;
115
116 /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */
117 GLuint input_to_index[VERT_ATTRIB_MAX];
118 /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
119 GLuint index_to_input[PIPE_MAX_SHADER_INPUTS];
120 GLuint num_inputs;
121
122 /** Maps VERT_RESULT_x to slot */
123 GLuint result_to_output[VERT_RESULT_MAX];
124 ubyte output_semantic_name[VERT_RESULT_MAX];
125 ubyte output_semantic_index[VERT_RESULT_MAX];
126 GLuint num_outputs;
127
128 /** List of translated varients of this vertex program.
129 */
130 struct st_vp_varient *varients;
131 };
132
133
134 static INLINE struct st_fragment_program *
135 st_fragment_program( struct gl_fragment_program *fp )
136 {
137 return (struct st_fragment_program *)fp;
138 }
139
140
141 static INLINE struct st_vertex_program *
142 st_vertex_program( struct gl_vertex_program *vp )
143 {
144 return (struct st_vertex_program *)vp;
145 }
146
147
148 static INLINE void
149 st_reference_vertprog(struct st_context *st,
150 struct st_vertex_program **ptr,
151 struct st_vertex_program *prog)
152 {
153 _mesa_reference_program(st->ctx,
154 (struct gl_program **) ptr,
155 (struct gl_program *) prog);
156 }
157
158 static INLINE void
159 st_reference_fragprog(struct st_context *st,
160 struct st_fragment_program **ptr,
161 struct st_fragment_program *prog)
162 {
163 _mesa_reference_program(st->ctx,
164 (struct gl_program **) ptr,
165 (struct gl_program *) prog);
166 }
167
168
169 extern void
170 st_translate_fragment_program(struct st_context *st,
171 struct st_fragment_program *fp,
172 const GLuint inputMapping[]);
173
174
175 /* Called after program string change, discard all previous
176 * compilation results.
177 */
178 extern void
179 st_prepare_vertex_program(struct st_context *st,
180 struct st_vertex_program *stvp);
181
182 extern struct st_vp_varient *
183 st_translate_vertex_program(struct st_context *st,
184 struct st_vertex_program *stvp,
185 const struct st_vp_varient_key *key);
186
187 void
188 st_vp_release_varients( struct st_context *st,
189 struct st_vertex_program *stvp );
190
191 extern void
192 st_print_shaders(GLcontext *ctx);
193
194
195 #endif