1 /* 2 * Mesa 3-D graphics library 3 * 4 * Copyright (C) 2004-2007 Brian Paul All Rights Reserved. 5 * Copyright (C) 2010 VMware, Inc. All Rights Reserved. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * and/or sell copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included 15 * in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 * OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 26 27 #ifndef SHADERAPI_H 28 #define SHADERAPI_H 29 30 31 #include "glheader.h" 32 #include "main/mtypes.h" 33 #include "compiler/shader_enums.h" 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 40 struct _glapi_table; 41 struct gl_context; 42 struct gl_linked_shader; 43 struct gl_pipeline_object; 44 struct gl_program; 45 struct gl_program_resource; 46 struct gl_shader; 47 struct gl_shader_program; 48 49 extern GLbitfield 50 _mesa_get_shader_flags(void); 51 52 extern const char * 53 _mesa_get_shader_capture_path(void); 54 55 extern void 56 _mesa_copy_string(GLchar *dst, GLsizei maxLength, 57 GLsizei *length, const GLchar *src); 58 59 extern void 60 _mesa_use_shader_program(struct gl_context *ctx, 61 struct gl_shader_program *shProg); 62 63 extern void 64 _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, 65 const char *caller); 66 67 extern void 68 _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh); 69 70 extern void 71 _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *sh_prog); 72 73 extern unsigned 74 _mesa_count_active_attribs(struct gl_shader_program *shProg); 75 76 extern size_t 77 _mesa_longest_attribute_name_length(struct gl_shader_program *shProg); 78 79 extern void 80 _mesa_shader_write_subroutine_indices(struct gl_context *ctx, 81 gl_shader_stage stage); 82 83 void GLAPIENTRY 84 _mesa_AttachObjectARB_no_error(GLhandleARB, GLhandleARB); 85 86 extern void GLAPIENTRY 87 _mesa_AttachObjectARB(GLhandleARB, GLhandleARB); 88 89 extern void GLAPIENTRY 90 _mesa_CompileShader(GLuint); 91 92 extern GLhandleARB GLAPIENTRY 93 _mesa_CreateProgramObjectARB(void); 94 95 GLhandleARB GLAPIENTRY 96 _mesa_CreateShaderObjectARB_no_error(GLenum type); 97 98 extern GLhandleARB GLAPIENTRY 99 _mesa_CreateShaderObjectARB(GLenum type); 100 101 extern void GLAPIENTRY 102 _mesa_DeleteObjectARB(GLhandleARB obj); 103 104 void GLAPIENTRY 105 _mesa_DetachObjectARB_no_error(GLhandleARB, GLhandleARB); 106 107 extern void GLAPIENTRY 108 _mesa_DetachObjectARB(GLhandleARB, GLhandleARB); 109 110 extern void GLAPIENTRY 111 _mesa_GetAttachedObjectsARB(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); 112 113 extern GLint GLAPIENTRY 114 _mesa_GetFragDataLocation(GLuint program, const GLchar *name); 115 116 extern GLint GLAPIENTRY 117 _mesa_GetFragDataIndex(GLuint program, const GLchar *name); 118 119 extern GLhandleARB GLAPIENTRY 120 _mesa_GetHandleARB(GLenum pname); 121 122 extern void GLAPIENTRY 123 _mesa_GetInfoLogARB(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); 124 125 extern void GLAPIENTRY 126 _mesa_GetObjectParameterfvARB(GLhandleARB, GLenum, GLfloat *); 127 128 extern void GLAPIENTRY 129 _mesa_GetObjectParameterivARB(GLhandleARB, GLenum, GLint *); 130 131 extern void GLAPIENTRY 132 _mesa_GetShaderSource(GLuint, GLsizei, GLsizei *, GLchar *); 133 134 extern GLboolean GLAPIENTRY 135 _mesa_IsProgram(GLuint name); 136 137 extern GLboolean GLAPIENTRY 138 _mesa_IsShader(GLuint name); 139 140 void GLAPIENTRY 141 _mesa_LinkProgram_no_error(GLuint programObj); 142 143 extern void GLAPIENTRY 144 _mesa_LinkProgram(GLuint programObj); 145 146 void GLAPIENTRY 147 _mesa_ShaderSource_no_error(GLuint, GLsizei, const GLchar* const *, 148 const GLint *); 149 150 extern void GLAPIENTRY 151 _mesa_ShaderSource(GLuint, GLsizei, const GLchar* const *, const GLint *); 152 153 void GLAPIENTRY 154 _mesa_UseProgram_no_error(GLuint); 155 extern void GLAPIENTRY 156 _mesa_UseProgram(GLuint); 157 158 extern void GLAPIENTRY 159 _mesa_ValidateProgram(GLuint); 160 161 162 void GLAPIENTRY 163 _mesa_BindAttribLocation_no_error(GLuint program, GLuint, const GLchar *); 164 165 extern void GLAPIENTRY 166 _mesa_BindAttribLocation(GLuint program, GLuint, const GLchar *); 167 168 extern void GLAPIENTRY 169 _mesa_BindFragDataLocation(GLuint program, GLuint colorNumber, 170 const GLchar *name); 171 172 extern void GLAPIENTRY 173 _mesa_BindFragDataLocationIndexed(GLuint program, GLuint colorNumber, 174 GLuint index, const GLchar *name); 175 176 extern void GLAPIENTRY 177 _mesa_BindFragDataLocation_no_error(GLuint program, GLuint colorNumber, 178 const GLchar *name); 179 180 extern void GLAPIENTRY 181 _mesa_BindFragDataLocationIndexed_no_error(GLuint program, GLuint colorNumber, 182 GLuint index, const GLchar *name); 183 184 extern void GLAPIENTRY 185 _mesa_GetActiveAttrib(GLuint, GLuint, GLsizei, GLsizei *, GLint *, 186 GLenum *, GLchar *); 187 188 extern GLint GLAPIENTRY 189 _mesa_GetAttribLocation(GLuint, const GLchar *); 190 191 void GLAPIENTRY 192 _mesa_AttachShader_no_error(GLuint program, GLuint shader); 193 194 extern void GLAPIENTRY 195 _mesa_AttachShader(GLuint program, GLuint shader); 196 197 GLuint GLAPIENTRY 198 _mesa_CreateShader_no_error(GLenum); 199 200 extern GLuint GLAPIENTRY 201 _mesa_CreateShader(GLenum); 202 203 extern GLuint GLAPIENTRY 204 _mesa_CreateProgram(void); 205 206 extern void GLAPIENTRY 207 _mesa_DeleteProgram(GLuint program); 208 209 extern void GLAPIENTRY 210 _mesa_DeleteShader(GLuint shader); 211 212 void GLAPIENTRY 213 _mesa_DetachShader_no_error(GLuint program, GLuint shader); 214 215 extern void GLAPIENTRY 216 _mesa_DetachShader(GLuint program, GLuint shader); 217 218 extern void GLAPIENTRY 219 _mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, 220 GLsizei *count, GLuint *obj); 221 222 extern void GLAPIENTRY 223 _mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params); 224 225 extern void GLAPIENTRY 226 _mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, 227 GLsizei *length, GLchar *infoLog); 228 229 extern void GLAPIENTRY 230 _mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params); 231 232 extern void GLAPIENTRY 233 _mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, 234 GLsizei *length, GLchar *infoLog); 235 236 237 extern void GLAPIENTRY 238 _mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, 239 GLint *range, GLint *precision); 240 241 extern void GLAPIENTRY 242 _mesa_ReleaseShaderCompiler(void); 243 244 extern void GLAPIENTRY 245 _mesa_ShaderBinary(GLint n, const GLuint *shaders, GLenum binaryformat, 246 const void* binary, GLint length); 247 248 extern void GLAPIENTRY 249 _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, 250 GLenum *binaryFormat, GLvoid *binary); 251 252 extern void GLAPIENTRY 253 _mesa_ProgramBinary(GLuint program, GLenum binaryFormat, 254 const GLvoid *binary, GLsizei length); 255 256 void GLAPIENTRY 257 _mesa_ProgramParameteri_no_error(GLuint program, GLenum pname, GLint value); 258 259 extern void GLAPIENTRY 260 _mesa_ProgramParameteri(GLuint program, GLenum pname, GLint value); 261 262 void 263 _mesa_use_program(struct gl_context *ctx, gl_shader_stage stage, 264 struct gl_shader_program *shProg, struct gl_program *prog, 265 struct gl_pipeline_object *shTarget); 266 267 extern void 268 _mesa_copy_linked_program_data(const struct gl_shader_program *src, 269 struct gl_linked_shader *dst_sh); 270 271 extern bool 272 _mesa_validate_shader_target(const struct gl_context *ctx, GLenum type); 273 274 275 /* GL_ARB_separate_shader_objects */ 276 extern GLuint GLAPIENTRY 277 _mesa_CreateShaderProgramv(GLenum type, GLsizei count, 278 const GLchar* const *strings); 279 280 /* GL_ARB_program_resource_query */ 281 extern const char* 282 _mesa_program_resource_name(struct gl_program_resource *res); 283 284 extern unsigned 285 _mesa_program_resource_array_size(struct gl_program_resource *res); 286 287 extern GLuint 288 _mesa_program_resource_index(struct gl_shader_program *shProg, 289 struct gl_program_resource *res); 290 291 extern struct gl_program_resource * 292 _mesa_program_resource_find_name(struct gl_shader_program *shProg, 293 GLenum programInterface, const char *name, 294 unsigned *array_index); 295 296 extern struct gl_program_resource * 297 _mesa_program_resource_find_index(struct gl_shader_program *shProg, 298 GLenum programInterface, GLuint index); 299 300 extern struct gl_program_resource * 301 _mesa_program_resource_find_active_variable(struct gl_shader_program *shProg, 302 GLenum programInterface, 303 const struct gl_uniform_block *block, 304 unsigned index); 305 306 extern bool 307 _mesa_get_program_resource_name(struct gl_shader_program *shProg, 308 GLenum programInterface, GLuint index, 309 GLsizei bufSize, GLsizei *length, 310 GLchar *name, const char *caller); 311 312 extern unsigned 313 _mesa_program_resource_name_len(struct gl_program_resource *res); 314 315 extern GLint 316 _mesa_program_resource_location(struct gl_shader_program *shProg, 317 GLenum programInterface, const char *name); 318 319 extern GLint 320 _mesa_program_resource_location_index(struct gl_shader_program *shProg, 321 GLenum programInterface, const char *name); 322 323 extern unsigned 324 _mesa_program_resource_prop(struct gl_shader_program *shProg, 325 struct gl_program_resource *res, GLuint index, 326 const GLenum prop, GLint *val, const char *caller); 327 328 extern void 329 _mesa_get_program_resourceiv(struct gl_shader_program *shProg, 330 GLenum programInterface, GLuint index, 331 GLsizei propCount, const GLenum *props, 332 GLsizei bufSize, GLsizei *length, 333 GLint *params); 334 335 extern void 336 _mesa_create_program_resource_hash(struct gl_shader_program *shProg); 337 338 /* GL_ARB_tessellation_shader */ 339 void GLAPIENTRY 340 _mesa_PatchParameteri_no_error(GLenum pname, GLint value); 341 342 extern void GLAPIENTRY 343 _mesa_PatchParameteri(GLenum pname, GLint value); 344 345 extern void GLAPIENTRY 346 _mesa_PatchParameterfv(GLenum pname, const GLfloat *values); 347 348 /* GL_ARB_shader_subroutine */ 349 void 350 _mesa_program_init_subroutine_defaults(struct gl_context *ctx, 351 struct gl_program *prog); 352 353 extern GLint GLAPIENTRY 354 _mesa_GetSubroutineUniformLocation(GLuint program, GLenum shadertype, 355 const GLchar *name); 356 357 extern GLuint GLAPIENTRY 358 _mesa_GetSubroutineIndex(GLuint program, GLenum shadertype, 359 const GLchar *name); 360 361 extern GLvoid GLAPIENTRY 362 _mesa_GetActiveSubroutineUniformiv(GLuint program, GLenum shadertype, 363 GLuint index, GLenum pname, GLint *values); 364 365 extern GLvoid GLAPIENTRY 366 _mesa_GetActiveSubroutineUniformName(GLuint program, GLenum shadertype, 367 GLuint index, GLsizei bufsize, 368 GLsizei *length, GLchar *name); 369 370 extern GLvoid GLAPIENTRY 371 _mesa_GetActiveSubroutineName(GLuint program, GLenum shadertype, 372 GLuint index, GLsizei bufsize, 373 GLsizei *length, GLchar *name); 374 375 extern GLvoid GLAPIENTRY 376 _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count, 377 const GLuint *indices); 378 379 extern GLvoid GLAPIENTRY 380 _mesa_GetUniformSubroutineuiv(GLenum shadertype, GLint location, 381 GLuint *params); 382 383 extern GLvoid GLAPIENTRY 384 _mesa_GetProgramStageiv(GLuint program, GLenum shadertype, 385 GLenum pname, GLint *values); 386 387 extern GLvoid GLAPIENTRY 388 _mesa_NamedStringARB(GLenum type, GLint namelen, const GLchar *name, 389 GLint stringlen, const GLchar *string); 390 391 extern GLvoid GLAPIENTRY 392 _mesa_DeleteNamedStringARB(GLint namelen, const GLchar *name); 393 394 extern GLvoid GLAPIENTRY 395 _mesa_CompileShaderIncludeARB(GLuint shader, GLsizei count, 396 const GLchar* const *path, const GLint *length); 397 398 extern GLboolean GLAPIENTRY 399 _mesa_IsNamedStringARB(GLint namelen, const GLchar *name); 400 401 extern GLvoid GLAPIENTRY 402 _mesa_GetNamedStringARB(GLint namelen, const GLchar *name, GLsizei bufSize, 403 GLint *stringlen, GLchar *string); 404 405 extern GLvoid GLAPIENTRY 406 _mesa_GetNamedStringivARB(GLint namelen, const GLchar *name, 407 GLenum pname, GLint *params); 408 409 GLcharARB * 410 _mesa_read_shader_source(const gl_shader_stage stage, const char *source); 411 412 void 413 _mesa_dump_shader_source(const gl_shader_stage stage, const char *source); 414 415 void 416 _mesa_init_shader_includes(struct gl_shared_state *shared); 417 418 size_t 419 _mesa_get_shader_include_cursor(struct gl_shared_state *shared); 420 421 void 422 _mesa_set_shader_include_cursor(struct gl_shared_state *shared, size_t cusor); 423 424 void 425 _mesa_destroy_shader_includes(struct gl_shared_state *shared); 426 427 const char * 428 _mesa_lookup_shader_include(struct gl_context *ctx, char *path, 429 bool error_check); 430 431 #ifdef __cplusplus 432 } 433 #endif 434 435 #endif /* SHADERAPI_H */ 436