mesa: Add OES_EGL_image to extension list.
[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 struct pipe_shader_state tgsi;
56 void *driver_shader;
57
58 /** Program prefixed with glBitmap prologue */
59 struct st_fragment_program *bitmap_program;
60 uint bitmap_sampler;
61 };
62
63
64
65 struct st_vp_varient_key
66 {
67 boolean passthrough_edgeflags;
68 };
69
70
71 /**
72 * This represents a vertex program, especially translated to match
73 * the inputs of a particular fragment shader.
74 */
75 struct st_vp_varient
76 {
77 /* Parameters which generated this translated version of a vertex
78 * shader:
79 */
80 struct st_vp_varient_key key;
81
82 /**
83 * TGSI tokens (to later generate a 'draw' module shader for
84 * selection/feedback/rasterpos)
85 */
86 struct pipe_shader_state tgsi;
87
88 /** Driver's compiled shader */
89 void *driver_shader;
90
91 /** For using our private draw module (glRasterPos) */
92 struct draw_vertex_shader *draw_shader;
93
94 /** Next in linked list */
95 struct st_vp_varient *next;
96
97 /** similar to that in st_vertex_program, but with information about edgeflags too */
98 GLuint num_inputs;
99 };
100
101
102
103
104 /**
105 * Derived from Mesa gl_fragment_program:
106 */
107 struct st_vertex_program
108 {
109 struct gl_vertex_program Base; /**< The Mesa vertex program */
110 GLuint serialNo, lastSerialNo;
111
112 /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */
113 GLuint input_to_index[VERT_ATTRIB_MAX];
114 /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
115 GLuint index_to_input[PIPE_MAX_SHADER_INPUTS];
116 GLuint num_inputs;
117
118 /** Maps VERT_RESULT_x to slot */
119 GLuint result_to_output[VERT_RESULT_MAX];
120 ubyte output_semantic_name[VERT_RESULT_MAX];
121 ubyte output_semantic_index[VERT_RESULT_MAX];
122 GLuint num_outputs;
123
124 /** List of translated varients of this vertex program.
125 */
126 struct st_vp_varient *varients;
127 };
128
129
130 static INLINE struct st_fragment_program *
131 st_fragment_program( struct gl_fragment_program *fp )
132 {
133 return (struct st_fragment_program *)fp;
134 }
135
136
137 static INLINE struct st_vertex_program *
138 st_vertex_program( struct gl_vertex_program *vp )
139 {
140 return (struct st_vertex_program *)vp;
141 }
142
143
144 static INLINE void
145 st_reference_vertprog(struct st_context *st,
146 struct st_vertex_program **ptr,
147 struct st_vertex_program *prog)
148 {
149 _mesa_reference_program(st->ctx,
150 (struct gl_program **) ptr,
151 (struct gl_program *) prog);
152 }
153
154 static INLINE void
155 st_reference_fragprog(struct st_context *st,
156 struct st_fragment_program **ptr,
157 struct st_fragment_program *prog)
158 {
159 _mesa_reference_program(st->ctx,
160 (struct gl_program **) ptr,
161 (struct gl_program *) prog);
162 }
163
164
165 extern void
166 st_translate_fragment_program(struct st_context *st,
167 struct st_fragment_program *fp);
168
169
170 /* Called after program string change, discard all previous
171 * compilation results.
172 */
173 extern void
174 st_prepare_vertex_program(struct st_context *st,
175 struct st_vertex_program *stvp);
176
177 extern struct st_vp_varient *
178 st_translate_vertex_program(struct st_context *st,
179 struct st_vertex_program *stvp,
180 const struct st_vp_varient_key *key);
181
182 void
183 st_vp_release_varients( struct st_context *st,
184 struct st_vertex_program *stvp );
185
186 extern void
187 st_print_shaders(GLcontext *ctx);
188
189
190 #endif