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 ubyte input_semantic_name
[PIPE_MAX_SHADER_INPUTS
];
56 ubyte input_semantic_index
[PIPE_MAX_SHADER_INPUTS
];
58 struct pipe_shader_state state
;
61 /** Program prefixed with glBitmap prologue */
62 struct st_fragment_program
*bitmap_program
;
68 struct st_vp_varient_key
70 boolean passthrough_edgeflags
;
75 * This represents a vertex program, especially translated to match
76 * the inputs of a particular fragment shader.
80 /* Parameters which generated this translated version of a vertex
83 struct st_vp_varient_key key
;
85 /** TGSI tokens -- why?
87 struct pipe_shader_state state
;
89 /** Driver's compiled shader */
92 /** For using our private draw module (glRasterPos) */
93 struct draw_vertex_shader
*draw_shader
;
95 /** Next in linked list */
96 struct st_vp_varient
*next
;
98 /** similar to that in st_vertex_program, but with information about edgeflags too */
106 * Derived from Mesa gl_fragment_program:
108 struct st_vertex_program
110 struct gl_vertex_program Base
; /**< The Mesa vertex program */
111 GLuint serialNo
, lastSerialNo
;
113 /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */
114 GLuint input_to_index
[VERT_ATTRIB_MAX
];
115 /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
116 GLuint index_to_input
[PIPE_MAX_SHADER_INPUTS
];
119 /** Maps VERT_RESULT_x to slot */
120 GLuint result_to_output
[VERT_RESULT_MAX
];
121 ubyte output_semantic_name
[VERT_RESULT_MAX
];
122 ubyte output_semantic_index
[VERT_RESULT_MAX
];
125 /** List of translated varients of this vertex program.
127 struct st_vp_varient
*varients
;
131 static INLINE
struct st_fragment_program
*
132 st_fragment_program( struct gl_fragment_program
*fp
)
134 return (struct st_fragment_program
*)fp
;
138 static INLINE
struct st_vertex_program
*
139 st_vertex_program( struct gl_vertex_program
*vp
)
141 return (struct st_vertex_program
*)vp
;
146 st_reference_vertprog(struct st_context
*st
,
147 struct st_vertex_program
**ptr
,
148 struct st_vertex_program
*prog
)
150 _mesa_reference_program(st
->ctx
,
151 (struct gl_program
**) ptr
,
152 (struct gl_program
*) prog
);
156 st_reference_fragprog(struct st_context
*st
,
157 struct st_fragment_program
**ptr
,
158 struct st_fragment_program
*prog
)
160 _mesa_reference_program(st
->ctx
,
161 (struct gl_program
**) ptr
,
162 (struct gl_program
*) prog
);
167 st_translate_fragment_program(struct st_context
*st
,
168 struct st_fragment_program
*fp
);
171 /* Called after program string change, discard all previous
172 * compilation results.
175 st_prepare_vertex_program(struct st_context
*st
,
176 struct st_vertex_program
*stvp
);
178 extern struct st_vp_varient
*
179 st_translate_vertex_program(struct st_context
*st
,
180 struct st_vertex_program
*stvp
,
181 const struct st_vp_varient_key
*key
);
184 st_vp_release_varients( struct st_context
*st
,
185 struct st_vertex_program
*stvp
);
188 st_print_shaders(GLcontext
*ctx
);