1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
30 * Keith Whitwell <keith@tungstengraphics.com>
37 #include "main/mtypes.h"
38 #include "shader/program.h"
39 #include "pipe/p_shader_tokens.h"
42 struct cso_fragment_shader
;
43 struct cso_vertex_shader
;
44 struct translated_vertex_program
;
48 * Derived from Mesa gl_fragment_program:
50 struct st_fragment_program
52 struct gl_fragment_program Base
;
55 struct pipe_shader_state tgsi
;
58 /** Program prefixed with glBitmap prologue */
59 struct st_fragment_program
*bitmap_program
;
65 struct st_vp_varient_key
67 boolean passthrough_edgeflags
;
72 * This represents a vertex program, especially translated to match
73 * the inputs of a particular fragment shader.
77 /* Parameters which generated this translated version of a vertex
80 struct st_vp_varient_key key
;
83 * TGSI tokens (to later generate a 'draw' module shader for
84 * selection/feedback/rasterpos)
86 struct pipe_shader_state tgsi
;
88 /** Driver's compiled shader */
91 /** For using our private draw module (glRasterPos) */
92 struct draw_vertex_shader
*draw_shader
;
94 /** Next in linked list */
95 struct st_vp_varient
*next
;
97 /** similar to that in st_vertex_program, but with information about edgeflags too */
105 * Derived from Mesa gl_fragment_program:
107 struct st_vertex_program
109 struct gl_vertex_program Base
; /**< The Mesa vertex program */
110 GLuint serialNo
, lastSerialNo
;
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
];
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
];
124 /** List of translated varients of this vertex program.
126 struct st_vp_varient
*varients
;
130 static INLINE
struct st_fragment_program
*
131 st_fragment_program( struct gl_fragment_program
*fp
)
133 return (struct st_fragment_program
*)fp
;
137 static INLINE
struct st_vertex_program
*
138 st_vertex_program( struct gl_vertex_program
*vp
)
140 return (struct st_vertex_program
*)vp
;
145 st_reference_vertprog(struct st_context
*st
,
146 struct st_vertex_program
**ptr
,
147 struct st_vertex_program
*prog
)
149 _mesa_reference_program(st
->ctx
,
150 (struct gl_program
**) ptr
,
151 (struct gl_program
*) prog
);
155 st_reference_fragprog(struct st_context
*st
,
156 struct st_fragment_program
**ptr
,
157 struct st_fragment_program
*prog
)
159 _mesa_reference_program(st
->ctx
,
160 (struct gl_program
**) ptr
,
161 (struct gl_program
*) prog
);
166 st_translate_fragment_program(struct st_context
*st
,
167 struct st_fragment_program
*fp
);
170 /* Called after program string change, discard all previous
171 * compilation results.
174 st_prepare_vertex_program(struct st_context
*st
,
175 struct st_vertex_program
*stvp
);
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
);
183 st_vp_release_varients( struct st_context
*st
,
184 struct st_vertex_program
*stvp
);
187 st_print_shaders(GLcontext
*ctx
);