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 GLuint input_to_slot
[FRAG_ATTRIB_MAX
]; /**< Maps FRAG_ATTRIB_x to slot */
56 GLuint num_input_slots
;
58 /** map FP input back to VP output */
59 GLuint input_map
[PIPE_MAX_SHADER_INPUTS
];
61 ubyte input_semantic_name
[PIPE_MAX_SHADER_INPUTS
];
62 ubyte input_semantic_index
[PIPE_MAX_SHADER_INPUTS
];
64 struct pipe_shader_state state
;
67 /** Program prefixed with glBitmap prologue */
68 struct st_fragment_program
*bitmap_program
;
74 struct st_vp_varient_key
76 char dummy
; /* currently unused */
81 * This represents a vertex program, especially translated to match
82 * the inputs of a particular fragment shader.
86 /* Parameters which generated this translated version of a vertex
89 struct st_vp_varient_key key
;
91 /** TGSI tokens -- why?
93 struct pipe_shader_state state
;
95 /** Driver's compiled shader */
98 /** For using our private draw module (glRasterPos) */
99 struct draw_vertex_shader
*draw_shader
;
101 /** Next in linked list */
102 struct st_vp_varient
*next
;
109 * Derived from Mesa gl_fragment_program:
111 struct st_vertex_program
113 struct gl_vertex_program Base
; /**< The Mesa vertex program */
114 GLuint serialNo
, lastSerialNo
;
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
];
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
];
128 /** List of translated varients of this vertex program.
130 struct st_vp_varient
*varients
;
134 static INLINE
struct st_fragment_program
*
135 st_fragment_program( struct gl_fragment_program
*fp
)
137 return (struct st_fragment_program
*)fp
;
141 static INLINE
struct st_vertex_program
*
142 st_vertex_program( struct gl_vertex_program
*vp
)
144 return (struct st_vertex_program
*)vp
;
149 st_reference_vertprog(struct st_context
*st
,
150 struct st_vertex_program
**ptr
,
151 struct st_vertex_program
*prog
)
153 _mesa_reference_program(st
->ctx
,
154 (struct gl_program
**) ptr
,
155 (struct gl_program
*) prog
);
159 st_reference_fragprog(struct st_context
*st
,
160 struct st_fragment_program
**ptr
,
161 struct st_fragment_program
*prog
)
163 _mesa_reference_program(st
->ctx
,
164 (struct gl_program
**) ptr
,
165 (struct gl_program
*) prog
);
170 st_translate_fragment_program(struct st_context
*st
,
171 struct st_fragment_program
*fp
,
172 const GLuint inputMapping
[]);
175 /* Called after program string change, discard all previous
176 * compilation results.
179 st_prepare_vertex_program(struct st_context
*st
,
180 struct st_vertex_program
*stvp
);
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
);
188 st_vp_release_varients( struct st_context
*st
,
189 struct st_vertex_program
*stvp
);
192 st_print_shaders(GLcontext
*ctx
);