2 * Mesa 3-D graphics library
4 * Copyright (C) 2004-2007 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
30 #include "main/compiler.h"
31 #include "main/glheader.h"
32 #include "main/mtypes.h"
33 #include "program/ir_to_mesa.h"
46 _mesa_init_shader_state(struct gl_context
* ctx
);
49 _mesa_free_shader_state(struct gl_context
*ctx
);
53 _mesa_reference_shader(struct gl_context
*ctx
, struct gl_shader
**ptr
,
54 struct gl_shader
*sh
);
56 extern struct gl_shader
*
57 _mesa_lookup_shader(struct gl_context
*ctx
, GLuint name
);
59 extern struct gl_shader
*
60 _mesa_lookup_shader_err(struct gl_context
*ctx
, GLuint name
, const char *caller
);
65 _mesa_reference_shader_program_(struct gl_context
*ctx
,
66 struct gl_shader_program
**ptr
,
67 struct gl_shader_program
*shProg
);
70 _mesa_reference_shader_program_data(struct gl_context
*ctx
,
71 struct gl_shader_program_data
**ptr
,
72 struct gl_shader_program_data
*data
);
75 _mesa_reference_shader_program(struct gl_context
*ctx
,
76 struct gl_shader_program
**ptr
,
77 struct gl_shader_program
*shProg
)
80 _mesa_reference_shader_program_(ctx
, ptr
, shProg
);
83 extern struct gl_shader
*
84 _mesa_new_shader(GLuint name
, gl_shader_stage type
);
87 _mesa_delete_shader(struct gl_context
*ctx
, struct gl_shader
*sh
);
90 _mesa_delete_linked_shader(struct gl_context
*ctx
,
91 struct gl_linked_shader
*sh
);
93 extern struct gl_shader_program
*
94 _mesa_lookup_shader_program(struct gl_context
*ctx
, GLuint name
);
96 extern struct gl_shader_program
*
97 _mesa_lookup_shader_program_err(struct gl_context
*ctx
, GLuint name
,
100 extern struct gl_shader_program
*
101 _mesa_new_shader_program(GLuint name
);
103 extern struct gl_shader_program_data
*
104 _mesa_create_shader_program_data(void);
107 _mesa_clear_shader_program_data(struct gl_context
*ctx
,
108 struct gl_shader_program
*shProg
);
111 _mesa_free_shader_program_data(struct gl_context
*ctx
,
112 struct gl_shader_program
*shProg
);
115 _mesa_delete_shader_program(struct gl_context
*ctx
,
116 struct gl_shader_program
*shProg
);
120 _mesa_init_shader_object_functions(struct dd_function_table
*driver
);
122 static inline gl_shader_stage
123 _mesa_shader_enum_to_shader_stage(GLenum v
)
126 case GL_VERTEX_SHADER
:
127 return MESA_SHADER_VERTEX
;
128 case GL_FRAGMENT_SHADER
:
129 return MESA_SHADER_FRAGMENT
;
130 case GL_GEOMETRY_SHADER
:
131 return MESA_SHADER_GEOMETRY
;
132 case GL_TESS_CONTROL_SHADER
:
133 return MESA_SHADER_TESS_CTRL
;
134 case GL_TESS_EVALUATION_SHADER
:
135 return MESA_SHADER_TESS_EVAL
;
136 case GL_COMPUTE_SHADER
:
137 return MESA_SHADER_COMPUTE
;
139 unreachable("bad value in _mesa_shader_enum_to_shader_stage()");
143 /* 8 bytes + another underscore */
144 #define MESA_SUBROUTINE_PREFIX_LEN 9
145 static inline const char *
146 _mesa_shader_stage_to_subroutine_prefix(gl_shader_stage stage
)
149 case MESA_SHADER_VERTEX
:
151 case MESA_SHADER_GEOMETRY
:
153 case MESA_SHADER_FRAGMENT
:
155 case MESA_SHADER_COMPUTE
:
157 case MESA_SHADER_TESS_CTRL
:
159 case MESA_SHADER_TESS_EVAL
:
166 static inline gl_shader_stage
167 _mesa_shader_stage_from_subroutine_uniform(GLenum subuniform
)
169 switch (subuniform
) {
170 case GL_VERTEX_SUBROUTINE_UNIFORM
:
171 return MESA_SHADER_VERTEX
;
172 case GL_GEOMETRY_SUBROUTINE_UNIFORM
:
173 return MESA_SHADER_GEOMETRY
;
174 case GL_FRAGMENT_SUBROUTINE_UNIFORM
:
175 return MESA_SHADER_FRAGMENT
;
176 case GL_COMPUTE_SUBROUTINE_UNIFORM
:
177 return MESA_SHADER_COMPUTE
;
178 case GL_TESS_CONTROL_SUBROUTINE_UNIFORM
:
179 return MESA_SHADER_TESS_CTRL
;
180 case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM
:
181 return MESA_SHADER_TESS_EVAL
;
183 unreachable("not reached");
186 static inline gl_shader_stage
187 _mesa_shader_stage_from_subroutine(GLenum subroutine
)
189 switch (subroutine
) {
190 case GL_VERTEX_SUBROUTINE
:
191 return MESA_SHADER_VERTEX
;
192 case GL_GEOMETRY_SUBROUTINE
:
193 return MESA_SHADER_GEOMETRY
;
194 case GL_FRAGMENT_SUBROUTINE
:
195 return MESA_SHADER_FRAGMENT
;
196 case GL_COMPUTE_SUBROUTINE
:
197 return MESA_SHADER_COMPUTE
;
198 case GL_TESS_CONTROL_SUBROUTINE
:
199 return MESA_SHADER_TESS_CTRL
;
200 case GL_TESS_EVALUATION_SUBROUTINE
:
201 return MESA_SHADER_TESS_EVAL
;
203 unreachable("not reached");
207 _mesa_shader_stage_to_subroutine(gl_shader_stage stage
)
210 case MESA_SHADER_VERTEX
:
211 return GL_VERTEX_SUBROUTINE
;
212 case MESA_SHADER_GEOMETRY
:
213 return GL_GEOMETRY_SUBROUTINE
;
214 case MESA_SHADER_FRAGMENT
:
215 return GL_FRAGMENT_SUBROUTINE
;
216 case MESA_SHADER_COMPUTE
:
217 return GL_COMPUTE_SUBROUTINE
;
218 case MESA_SHADER_TESS_CTRL
:
219 return GL_TESS_CONTROL_SUBROUTINE
;
220 case MESA_SHADER_TESS_EVAL
:
221 return GL_TESS_EVALUATION_SUBROUTINE
;
222 case MESA_SHADER_NONE
:
225 unreachable("not reached");
229 _mesa_shader_stage_to_subroutine_uniform(gl_shader_stage stage
)
232 case MESA_SHADER_VERTEX
:
233 return GL_VERTEX_SUBROUTINE_UNIFORM
;
234 case MESA_SHADER_GEOMETRY
:
235 return GL_GEOMETRY_SUBROUTINE_UNIFORM
;
236 case MESA_SHADER_FRAGMENT
:
237 return GL_FRAGMENT_SUBROUTINE_UNIFORM
;
238 case MESA_SHADER_COMPUTE
:
239 return GL_COMPUTE_SUBROUTINE_UNIFORM
;
240 case MESA_SHADER_TESS_CTRL
:
241 return GL_TESS_CONTROL_SUBROUTINE_UNIFORM
;
242 case MESA_SHADER_TESS_EVAL
:
243 return GL_TESS_EVALUATION_SUBROUTINE_UNIFORM
;
244 case MESA_SHADER_NONE
:
247 unreachable("not reached");
251 _mesa_validate_pipeline_io(struct gl_pipeline_object
*);
257 #endif /* SHADEROBJ_H */