2 * Mesa 3-D graphics library
4 * Copyright (C) 2004-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * Implementation of GLSL-related API functions.
30 * The glUniform* functions are in uniforms.c
34 * 1. Check that the right error code is generated for all _mesa_error() calls.
35 * 2. Insert FLUSH_VERTICES calls in various places
39 #include "main/glheader.h"
40 #include "main/context.h"
41 #include "main/dispatch.h"
42 #include "main/enums.h"
43 #include "main/hash.h"
44 #include "main/mfeatures.h"
45 #include "main/mtypes.h"
46 #include "main/shaderapi.h"
47 #include "main/shaderobj.h"
48 #include "program/program.h"
49 #include "program/prog_parameter.h"
50 #include "program/prog_uniform.h"
53 #include "../glsl/glsl_parser_extras.h"
55 /** Define this to enable shader substitution (see below) */
56 #define SHADER_SUBST 0
60 * Return mask of GLSL_x flags by examining the MESA_GLSL env var.
63 get_shader_flags(void)
65 GLbitfield flags
= 0x0;
66 const char *env
= _mesa_getenv("MESA_GLSL");
69 if (strstr(env
, "dump"))
71 if (strstr(env
, "log"))
73 if (strstr(env
, "nopvert"))
74 flags
|= GLSL_NOP_VERT
;
75 if (strstr(env
, "nopfrag"))
76 flags
|= GLSL_NOP_FRAG
;
77 if (strstr(env
, "nopt"))
79 else if (strstr(env
, "opt"))
81 if (strstr(env
, "uniform"))
82 flags
|= GLSL_UNIFORMS
;
83 if (strstr(env
, "useprog"))
84 flags
|= GLSL_USE_PROG
;
92 * Initialize context's shader state.
95 _mesa_init_shader_state(struct gl_context
*ctx
)
97 /* Device drivers may override these to control what kind of instructions
98 * are generated by the GLSL compiler.
100 struct gl_shader_compiler_options options
;
103 memset(&options
, 0, sizeof(options
));
104 options
.MaxUnrollIterations
= 32;
106 /* Default pragma settings */
107 options
.DefaultPragmas
.Optimize
= GL_TRUE
;
109 for (sh
= 0; sh
< MESA_SHADER_TYPES
; ++sh
)
110 memcpy(&ctx
->ShaderCompilerOptions
[sh
], &options
, sizeof(options
));
112 ctx
->Shader
.Flags
= get_shader_flags();
117 * Free the per-context shader-related state.
120 _mesa_free_shader_state(struct gl_context
*ctx
)
122 _mesa_reference_shader_program(ctx
, &ctx
->Shader
.CurrentVertexProgram
, NULL
);
123 _mesa_reference_shader_program(ctx
, &ctx
->Shader
.CurrentGeometryProgram
,
125 _mesa_reference_shader_program(ctx
, &ctx
->Shader
.CurrentFragmentProgram
,
127 _mesa_reference_shader_program(ctx
, &ctx
->Shader
.ActiveProgram
, NULL
);
132 * Return the size of the given GLSL datatype, in floats (components).
135 _mesa_sizeof_glsl_type(GLenum type
)
140 case GL_UNSIGNED_INT
:
145 case GL_SAMPLER_CUBE
:
146 case GL_SAMPLER_1D_SHADOW
:
147 case GL_SAMPLER_2D_SHADOW
:
148 case GL_SAMPLER_2D_RECT_ARB
:
149 case GL_SAMPLER_2D_RECT_SHADOW_ARB
:
150 case GL_SAMPLER_1D_ARRAY_EXT
:
151 case GL_SAMPLER_2D_ARRAY_EXT
:
152 case GL_SAMPLER_1D_ARRAY_SHADOW_EXT
:
153 case GL_SAMPLER_2D_ARRAY_SHADOW_EXT
:
154 case GL_SAMPLER_CUBE_SHADOW_EXT
:
158 case GL_UNSIGNED_INT_VEC2
:
163 case GL_UNSIGNED_INT_VEC3
:
168 case GL_UNSIGNED_INT_VEC4
:
172 case GL_FLOAT_MAT2x3
:
173 case GL_FLOAT_MAT2x4
:
174 return 8; /* two float[4] vectors */
176 case GL_FLOAT_MAT3x2
:
177 case GL_FLOAT_MAT3x4
:
178 return 12; /* three float[4] vectors */
180 case GL_FLOAT_MAT4x2
:
181 case GL_FLOAT_MAT4x3
:
182 return 16; /* four float[4] vectors */
184 _mesa_problem(NULL
, "Invalid type in _mesa_sizeof_glsl_type()");
191 * Copy string from <src> to <dst>, up to maxLength characters, returning
192 * length of <dst> in <length>.
193 * \param src the strings source
194 * \param maxLength max chars to copy
195 * \param length returns number of chars copied
196 * \param dst the string destination
199 _mesa_copy_string(GLchar
*dst
, GLsizei maxLength
,
200 GLsizei
*length
, const GLchar
*src
)
203 for (len
= 0; len
< maxLength
- 1 && src
&& src
[len
]; len
++)
214 * Confirm that the a shader type is valid and supported by the implementation
216 * \param ctx Current GL context
217 * \param type Shader target
221 validate_shader_target(const struct gl_context
*ctx
, GLenum type
)
224 #if FEATURE_ARB_fragment_shader
225 case GL_FRAGMENT_SHADER
:
226 return ctx
->Extensions
.ARB_fragment_shader
;
228 #if FEATURE_ARB_vertex_shader
229 case GL_VERTEX_SHADER
:
230 return ctx
->Extensions
.ARB_vertex_shader
;
232 #if FEATURE_ARB_geometry_shader4
233 case GL_GEOMETRY_SHADER_ARB
:
234 return ctx
->Extensions
.ARB_geometry_shader4
;
243 * Find the length of the longest transform feedback varying name
244 * which was specified with glTransformFeedbackVaryings().
247 longest_feedback_varying_name(const struct gl_shader_program
*shProg
)
251 for (i
= 0; i
< shProg
->TransformFeedback
.NumVarying
; i
++) {
252 GLint len
= strlen(shProg
->TransformFeedback
.VaryingNames
[i
]);
262 is_program(struct gl_context
*ctx
, GLuint name
)
264 struct gl_shader_program
*shProg
= _mesa_lookup_shader_program(ctx
, name
);
265 return shProg
? GL_TRUE
: GL_FALSE
;
270 is_shader(struct gl_context
*ctx
, GLuint name
)
272 struct gl_shader
*shader
= _mesa_lookup_shader(ctx
, name
);
273 return shader
? GL_TRUE
: GL_FALSE
;
278 * Attach shader to a shader program.
281 attach_shader(struct gl_context
*ctx
, GLuint program
, GLuint shader
)
283 struct gl_shader_program
*shProg
;
284 struct gl_shader
*sh
;
287 shProg
= _mesa_lookup_shader_program_err(ctx
, program
, "glAttachShader");
291 sh
= _mesa_lookup_shader_err(ctx
, shader
, "glAttachShader");
296 n
= shProg
->NumShaders
;
297 for (i
= 0; i
< n
; i
++) {
298 if (shProg
->Shaders
[i
] == sh
) {
299 /* The shader is already attched to this program. The
300 * GL_ARB_shader_objects spec says:
302 * "The error INVALID_OPERATION is generated by AttachObjectARB
303 * if <obj> is already attached to <containerObj>."
305 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glAttachShader");
311 shProg
->Shaders
= (struct gl_shader
**)
312 _mesa_realloc(shProg
->Shaders
,
313 n
* sizeof(struct gl_shader
*),
314 (n
+ 1) * sizeof(struct gl_shader
*));
315 if (!shProg
->Shaders
) {
316 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glAttachShader");
321 shProg
->Shaders
[n
] = NULL
; /* since realloc() didn't zero the new space */
322 _mesa_reference_shader(ctx
, &shProg
->Shaders
[n
], sh
);
323 shProg
->NumShaders
++;
328 bind_frag_data_location(struct gl_context
*ctx
, GLuint program
,
329 GLuint colorNumber
, const GLchar
*name
)
331 _mesa_problem(ctx
, "bind_frag_data_location() not implemented yet");
336 create_shader(struct gl_context
*ctx
, GLenum type
)
338 struct gl_shader
*sh
;
341 if (!validate_shader_target(ctx
, type
)) {
342 _mesa_error(ctx
, GL_INVALID_ENUM
, "CreateShader(type)");
346 name
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->ShaderObjects
, 1);
347 sh
= ctx
->Driver
.NewShader(ctx
, name
, type
);
348 _mesa_HashInsert(ctx
->Shared
->ShaderObjects
, name
, sh
);
355 create_shader_program(struct gl_context
*ctx
)
358 struct gl_shader_program
*shProg
;
360 name
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->ShaderObjects
, 1);
362 shProg
= ctx
->Driver
.NewShaderProgram(ctx
, name
);
364 _mesa_HashInsert(ctx
->Shared
->ShaderObjects
, name
, shProg
);
366 assert(shProg
->RefCount
== 1);
373 * Named w/ "2" to indicate OpenGL 2.x vs GL_ARB_fragment_programs's
377 delete_shader_program(struct gl_context
*ctx
, GLuint name
)
380 * NOTE: deleting shaders/programs works a bit differently than
381 * texture objects (and buffer objects, etc). Shader/program
382 * handles/IDs exist in the hash table until the object is really
383 * deleted (refcount==0). With texture objects, the handle/ID is
384 * removed from the hash table in glDeleteTextures() while the tex
385 * object itself might linger until its refcount goes to zero.
387 struct gl_shader_program
*shProg
;
389 shProg
= _mesa_lookup_shader_program_err(ctx
, name
, "glDeleteProgram");
393 shProg
->DeletePending
= GL_TRUE
;
395 /* effectively, decr shProg's refcount */
396 _mesa_reference_shader_program(ctx
, &shProg
, NULL
);
401 delete_shader(struct gl_context
*ctx
, GLuint shader
)
403 struct gl_shader
*sh
;
405 sh
= _mesa_lookup_shader_err(ctx
, shader
, "glDeleteShader");
409 sh
->DeletePending
= GL_TRUE
;
411 /* effectively, decr sh's refcount */
412 _mesa_reference_shader(ctx
, &sh
, NULL
);
417 detach_shader(struct gl_context
*ctx
, GLuint program
, GLuint shader
)
419 struct gl_shader_program
*shProg
;
423 shProg
= _mesa_lookup_shader_program_err(ctx
, program
, "glDetachShader");
427 n
= shProg
->NumShaders
;
429 for (i
= 0; i
< n
; i
++) {
430 if (shProg
->Shaders
[i
]->Name
== shader
) {
432 struct gl_shader
**newList
;
435 _mesa_reference_shader(ctx
, &shProg
->Shaders
[i
], NULL
);
437 /* alloc new, smaller array */
438 newList
= (struct gl_shader
**)
439 malloc((n
- 1) * sizeof(struct gl_shader
*));
441 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDetachShader");
444 for (j
= 0; j
< i
; j
++) {
445 newList
[j
] = shProg
->Shaders
[j
];
448 newList
[j
++] = shProg
->Shaders
[i
];
449 free(shProg
->Shaders
);
451 shProg
->Shaders
= newList
;
452 shProg
->NumShaders
= n
- 1;
457 for (j
= 0; j
< shProg
->NumShaders
; j
++) {
458 assert(shProg
->Shaders
[j
]->Type
== GL_VERTEX_SHADER
||
459 shProg
->Shaders
[j
]->Type
== GL_FRAGMENT_SHADER
);
460 assert(shProg
->Shaders
[j
]->RefCount
> 0);
472 if (is_shader(ctx
, shader
))
473 err
= GL_INVALID_OPERATION
;
474 else if (is_program(ctx
, shader
))
475 err
= GL_INVALID_OPERATION
;
477 err
= GL_INVALID_VALUE
;
478 _mesa_error(ctx
, err
, "glDetachProgram(shader)");
485 * Return list of shaders attached to shader program.
488 get_attached_shaders(struct gl_context
*ctx
, GLuint program
, GLsizei maxCount
,
489 GLsizei
*count
, GLuint
*obj
)
491 struct gl_shader_program
*shProg
=
492 _mesa_lookup_shader_program_err(ctx
, program
, "glGetAttachedShaders");
495 for (i
= 0; i
< (GLuint
) maxCount
&& i
< shProg
->NumShaders
; i
++) {
496 obj
[i
] = shProg
->Shaders
[i
]->Name
;
505 get_frag_data_location(struct gl_context
*ctx
, GLuint program
,
508 _mesa_problem(ctx
, "get_frag_data_location() not implemented yet");
515 * glGetHandleARB() - return ID/name of currently bound shader program.
518 get_handle(struct gl_context
*ctx
, GLenum pname
)
520 if (pname
== GL_PROGRAM_OBJECT_ARB
) {
521 if (ctx
->Shader
.ActiveProgram
)
522 return ctx
->Shader
.ActiveProgram
->Name
;
527 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetHandleARB");
534 * glGetProgramiv() - get shader program state.
535 * Note that this is for GLSL shader programs, not ARB vertex/fragment
536 * programs (see glGetProgramivARB).
539 get_programiv(struct gl_context
*ctx
, GLuint program
, GLenum pname
, GLint
*params
)
541 struct gl_shader_program
*shProg
542 = _mesa_lookup_shader_program(ctx
, program
);
545 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramiv(program)");
550 case GL_DELETE_STATUS
:
551 *params
= shProg
->DeletePending
;
554 *params
= shProg
->LinkStatus
;
556 case GL_VALIDATE_STATUS
:
557 *params
= shProg
->Validated
;
559 case GL_INFO_LOG_LENGTH
:
560 *params
= shProg
->InfoLog
? strlen(shProg
->InfoLog
) + 1 : 0;
562 case GL_ATTACHED_SHADERS
:
563 *params
= shProg
->NumShaders
;
565 case GL_ACTIVE_ATTRIBUTES
:
566 *params
= _mesa_count_active_attribs(shProg
);
568 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
:
569 *params
= _mesa_longest_attribute_name_length(shProg
);
571 case GL_ACTIVE_UNIFORMS
:
572 *params
= shProg
->Uniforms
? shProg
->Uniforms
->NumUniforms
: 0;
574 case GL_ACTIVE_UNIFORM_MAX_LENGTH
:
575 *params
= _mesa_longest_uniform_name(shProg
->Uniforms
);
577 (*params
)++; /* add one for terminating zero */
579 case GL_PROGRAM_BINARY_LENGTH_OES
:
582 #if FEATURE_EXT_transform_feedback
583 case GL_TRANSFORM_FEEDBACK_VARYINGS
:
584 *params
= shProg
->TransformFeedback
.NumVarying
;
586 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH
:
587 *params
= longest_feedback_varying_name(shProg
) + 1;
589 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE
:
590 *params
= shProg
->TransformFeedback
.BufferMode
;
593 #if FEATURE_ARB_geometry_shader4
594 case GL_GEOMETRY_VERTICES_OUT_ARB
:
595 *params
= shProg
->Geom
.VerticesOut
;
597 case GL_GEOMETRY_INPUT_TYPE_ARB
:
598 *params
= shProg
->Geom
.InputType
;
600 case GL_GEOMETRY_OUTPUT_TYPE_ARB
:
601 *params
= shProg
->Geom
.OutputType
;
605 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramiv(pname)");
612 * glGetShaderiv() - get GLSL shader state
615 get_shaderiv(struct gl_context
*ctx
, GLuint name
, GLenum pname
, GLint
*params
)
617 struct gl_shader
*shader
=
618 _mesa_lookup_shader_err(ctx
, name
, "glGetShaderiv");
626 *params
= shader
->Type
;
628 case GL_DELETE_STATUS
:
629 *params
= shader
->DeletePending
;
631 case GL_COMPILE_STATUS
:
632 *params
= shader
->CompileStatus
;
634 case GL_INFO_LOG_LENGTH
:
635 *params
= shader
->InfoLog
? strlen(shader
->InfoLog
) + 1 : 0;
637 case GL_SHADER_SOURCE_LENGTH
:
638 *params
= shader
->Source
? strlen((char *) shader
->Source
) + 1 : 0;
641 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetShaderiv(pname)");
648 get_program_info_log(struct gl_context
*ctx
, GLuint program
, GLsizei bufSize
,
649 GLsizei
*length
, GLchar
*infoLog
)
651 struct gl_shader_program
*shProg
652 = _mesa_lookup_shader_program(ctx
, program
);
654 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramInfoLog(program)");
657 _mesa_copy_string(infoLog
, bufSize
, length
, shProg
->InfoLog
);
662 get_shader_info_log(struct gl_context
*ctx
, GLuint shader
, GLsizei bufSize
,
663 GLsizei
*length
, GLchar
*infoLog
)
665 struct gl_shader
*sh
= _mesa_lookup_shader(ctx
, shader
);
667 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetShaderInfoLog(shader)");
670 _mesa_copy_string(infoLog
, bufSize
, length
, sh
->InfoLog
);
675 * Return shader source code.
678 get_shader_source(struct gl_context
*ctx
, GLuint shader
, GLsizei maxLength
,
679 GLsizei
*length
, GLchar
*sourceOut
)
681 struct gl_shader
*sh
;
682 sh
= _mesa_lookup_shader_err(ctx
, shader
, "glGetShaderSource");
686 _mesa_copy_string(sourceOut
, maxLength
, length
, sh
->Source
);
691 * Set/replace shader source code.
694 shader_source(struct gl_context
*ctx
, GLuint shader
, const GLchar
*source
)
696 struct gl_shader
*sh
;
698 sh
= _mesa_lookup_shader_err(ctx
, shader
, "glShaderSource");
702 /* free old shader source string and install new one */
704 free((void *) sh
->Source
);
707 sh
->CompileStatus
= GL_FALSE
;
709 sh
->SourceChecksum
= _mesa_str_checksum(sh
->Source
);
718 compile_shader(struct gl_context
*ctx
, GLuint shaderObj
)
720 struct gl_shader
*sh
;
721 struct gl_shader_compiler_options
*options
;
723 sh
= _mesa_lookup_shader_err(ctx
, shaderObj
, "glCompileShader");
727 options
= &ctx
->ShaderCompilerOptions
[_mesa_shader_type_to_index(sh
->Type
)];
729 /* set default pragma state for shader */
730 sh
->Pragmas
= options
->DefaultPragmas
;
732 /* this call will set the sh->CompileStatus field to indicate if
733 * compilation was successful.
735 _mesa_glsl_compile_shader(ctx
, sh
);
740 * Link a program's shaders.
743 link_program(struct gl_context
*ctx
, GLuint program
)
745 struct gl_shader_program
*shProg
;
746 struct gl_transform_feedback_object
*obj
=
747 ctx
->TransformFeedback
.CurrentObject
;
749 shProg
= _mesa_lookup_shader_program_err(ctx
, program
, "glLinkProgram");
754 && (shProg
== ctx
->Shader
.CurrentVertexProgram
755 || shProg
== ctx
->Shader
.CurrentGeometryProgram
756 || shProg
== ctx
->Shader
.CurrentFragmentProgram
)) {
757 _mesa_error(ctx
, GL_INVALID_OPERATION
,
758 "glLinkProgram(transform feedback active");
762 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
764 _mesa_glsl_link_shader(ctx
, shProg
);
770 printf("Link %u shaders in program %u: %s\n",
771 shProg
->NumShaders
, shProg
->Name
,
772 shProg
->LinkStatus
? "Success" : "Failed");
774 for (i
= 0; i
< shProg
->NumShaders
; i
++) {
775 printf(" shader %u, type 0x%x\n",
776 shProg
->Shaders
[i
]->Name
,
777 shProg
->Shaders
[i
]->Type
);
784 * Print basic shader info (for debug).
787 print_shader_info(const struct gl_shader_program
*shProg
)
791 printf("Mesa: glUseProgram(%u)\n", shProg
->Name
);
792 for (i
= 0; i
< shProg
->NumShaders
; i
++) {
794 switch (shProg
->Shaders
[i
]->Type
) {
795 case GL_VERTEX_SHADER
:
798 case GL_FRAGMENT_SHADER
:
801 case GL_GEOMETRY_SHADER
:
807 printf(" %s shader %u, checksum %u\n", s
,
808 shProg
->Shaders
[i
]->Name
,
809 shProg
->Shaders
[i
]->SourceChecksum
);
811 if (shProg
->_LinkedShaders
[MESA_SHADER_VERTEX
])
812 printf(" vert prog %u\n",
813 shProg
->_LinkedShaders
[MESA_SHADER_VERTEX
]->Program
->Id
);
814 if (shProg
->FragmentProgram
)
815 printf(" frag prog %u\n", shProg
->FragmentProgram
->Base
.Id
);
816 if (shProg
->_LinkedShaders
[MESA_SHADER_GEOMETRY
])
817 printf(" geom prog %u\n",
818 shProg
->_LinkedShaders
[MESA_SHADER_GEOMETRY
]->Program
->Id
);
823 * Use the named shader program for subsequent glUniform calls
826 _mesa_active_program(struct gl_context
*ctx
, struct gl_shader_program
*shProg
,
829 if ((shProg
!= NULL
) && !shProg
->LinkStatus
) {
830 _mesa_error(ctx
, GL_INVALID_OPERATION
,
831 "%s(program %u not linked)", caller
, shProg
->Name
);
835 if (ctx
->Shader
.ActiveProgram
!= shProg
) {
836 _mesa_reference_shader_program(ctx
, &ctx
->Shader
.ActiveProgram
, shProg
);
843 use_shader_program(struct gl_context
*ctx
, GLenum type
,
844 struct gl_shader_program
*shProg
)
846 struct gl_shader_program
**target
;
849 #if FEATURE_ARB_vertex_shader
850 case GL_VERTEX_SHADER
:
851 target
= &ctx
->Shader
.CurrentVertexProgram
;
853 || (shProg
->_LinkedShaders
[MESA_SHADER_VERTEX
] == NULL
)) {
858 #if FEATURE_ARB_geometry_shader4
859 case GL_GEOMETRY_SHADER_ARB
:
860 target
= &ctx
->Shader
.CurrentGeometryProgram
;
862 || (shProg
->_LinkedShaders
[MESA_SHADER_GEOMETRY
] == NULL
)) {
867 #if FEATURE_ARB_fragment_shader
868 case GL_FRAGMENT_SHADER
:
869 target
= &ctx
->Shader
.CurrentFragmentProgram
;
871 || (shProg
->_LinkedShaders
[MESA_SHADER_FRAGMENT
] == NULL
)) {
880 if (*target
!= shProg
) {
881 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
| _NEW_PROGRAM_CONSTANTS
);
882 _mesa_reference_shader_program(ctx
, target
, shProg
);
890 * Use the named shader program for subsequent rendering.
893 _mesa_use_program(struct gl_context
*ctx
, struct gl_shader_program
*shProg
)
895 use_shader_program(ctx
, GL_VERTEX_SHADER
, shProg
);
896 use_shader_program(ctx
, GL_GEOMETRY_SHADER_ARB
, shProg
);
897 use_shader_program(ctx
, GL_FRAGMENT_SHADER
, shProg
);
898 _mesa_active_program(ctx
, shProg
, "glUseProgram");
900 if (ctx
->Driver
.UseProgram
)
901 ctx
->Driver
.UseProgram(ctx
, shProg
);
906 * Validate a program's samplers.
907 * Specifically, check that there aren't two samplers of different types
908 * pointing to the same texture unit.
909 * \return GL_TRUE if valid, GL_FALSE if invalid
912 validate_samplers(const struct gl_program
*prog
, char *errMsg
)
914 static const char *targetName
[] = {
924 GLint targetUsed
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
925 GLbitfield samplersUsed
= prog
->SamplersUsed
;
928 assert(Elements(targetName
) == NUM_TEXTURE_TARGETS
);
930 if (samplersUsed
== 0x0)
933 for (i
= 0; i
< Elements(targetUsed
); i
++)
936 /* walk over bits which are set in 'samplers' */
937 while (samplersUsed
) {
939 gl_texture_index target
;
940 GLint sampler
= _mesa_ffs(samplersUsed
) - 1;
941 assert(sampler
>= 0);
942 assert(sampler
< Elements(prog
->SamplerUnits
));
943 unit
= prog
->SamplerUnits
[sampler
];
944 target
= prog
->SamplerTargets
[sampler
];
945 if (targetUsed
[unit
] != -1 && targetUsed
[unit
] != (int) target
) {
946 _mesa_snprintf(errMsg
, 100,
947 "Texture unit %d is accessed both as %s and %s",
948 unit
, targetName
[targetUsed
[unit
]], targetName
[target
]);
951 targetUsed
[unit
] = target
;
952 samplersUsed
^= (1 << sampler
);
960 * Do validation of the given shader program.
961 * \param errMsg returns error message if validation fails.
962 * \return GL_TRUE if valid, GL_FALSE if invalid (and set errMsg)
965 validate_shader_program(const struct gl_shader_program
*shProg
,
968 const struct gl_shader
*vs
= shProg
->_LinkedShaders
[MESA_SHADER_VERTEX
];
969 const struct gl_shader
*gs
= shProg
->_LinkedShaders
[MESA_SHADER_GEOMETRY
];
970 const struct gl_fragment_program
*fp
= shProg
->FragmentProgram
;
972 if (!shProg
->LinkStatus
) {
976 /* From the GL spec, a program is invalid if any of these are true:
978 any two active samplers in the current program object are of
979 different types, but refer to the same texture image unit,
981 any active sampler in the current program object refers to a texture
982 image unit where fixed-function fragment processing accesses a
983 texture target that does not match the sampler type, or
985 the sum of the number of active samplers in the program and the
986 number of texture image units enabled for fixed-function fragment
987 processing exceeds the combined limit on the total number of texture
993 * Check: any two active samplers in the current program object are of
994 * different types, but refer to the same texture image unit,
996 if (vs
&& !validate_samplers(vs
->Program
, errMsg
)) {
999 if (gs
&& !validate_samplers(gs
->Program
, errMsg
)) {
1002 if (fp
&& !validate_samplers(&fp
->Base
, errMsg
)) {
1011 * Called via glValidateProgram()
1014 validate_program(struct gl_context
*ctx
, GLuint program
)
1016 struct gl_shader_program
*shProg
;
1017 char errMsg
[100] = "";
1019 shProg
= _mesa_lookup_shader_program_err(ctx
, program
, "glValidateProgram");
1024 shProg
->Validated
= validate_shader_program(shProg
, errMsg
);
1025 if (!shProg
->Validated
) {
1026 /* update info log */
1027 if (shProg
->InfoLog
) {
1028 ralloc_free(shProg
->InfoLog
);
1030 shProg
->InfoLog
= ralloc_strdup(shProg
, errMsg
);
1037 _mesa_AttachObjectARB(GLhandleARB program
, GLhandleARB shader
)
1039 GET_CURRENT_CONTEXT(ctx
);
1040 attach_shader(ctx
, program
, shader
);
1045 _mesa_AttachShader(GLuint program
, GLuint shader
)
1047 GET_CURRENT_CONTEXT(ctx
);
1048 attach_shader(ctx
, program
, shader
);
1052 /* GL_EXT_gpu_shader4, GL3 */
1054 _mesa_BindFragDataLocation(GLuint program
, GLuint colorNumber
,
1057 GET_CURRENT_CONTEXT(ctx
);
1058 bind_frag_data_location(ctx
, program
, colorNumber
, name
);
1063 _mesa_CompileShaderARB(GLhandleARB shaderObj
)
1065 GET_CURRENT_CONTEXT(ctx
);
1066 if (MESA_VERBOSE
& VERBOSE_API
)
1067 _mesa_debug(ctx
, "glCompileShader %u\n", shaderObj
);
1068 compile_shader(ctx
, shaderObj
);
1073 _mesa_CreateShader(GLenum type
)
1075 GET_CURRENT_CONTEXT(ctx
);
1076 if (MESA_VERBOSE
& VERBOSE_API
)
1077 _mesa_debug(ctx
, "glCreateShader %s\n", _mesa_lookup_enum_by_nr(type
));
1078 return create_shader(ctx
, type
);
1082 GLhandleARB GLAPIENTRY
1083 _mesa_CreateShaderObjectARB(GLenum type
)
1085 GET_CURRENT_CONTEXT(ctx
);
1086 return create_shader(ctx
, type
);
1091 _mesa_CreateProgram(void)
1093 GET_CURRENT_CONTEXT(ctx
);
1094 if (MESA_VERBOSE
& VERBOSE_API
)
1095 _mesa_debug(ctx
, "glCreateProgram\n");
1096 return create_shader_program(ctx
);
1100 GLhandleARB GLAPIENTRY
1101 _mesa_CreateProgramObjectARB(void)
1103 GET_CURRENT_CONTEXT(ctx
);
1104 return create_shader_program(ctx
);
1109 _mesa_DeleteObjectARB(GLhandleARB obj
)
1111 if (MESA_VERBOSE
& VERBOSE_API
) {
1112 GET_CURRENT_CONTEXT(ctx
);
1113 _mesa_debug(ctx
, "glDeleteObjectARB(%u)\n", obj
);
1117 GET_CURRENT_CONTEXT(ctx
);
1118 FLUSH_VERTICES(ctx
, 0);
1119 if (is_program(ctx
, obj
)) {
1120 delete_shader_program(ctx
, obj
);
1122 else if (is_shader(ctx
, obj
)) {
1123 delete_shader(ctx
, obj
);
1133 _mesa_DeleteProgram(GLuint name
)
1136 GET_CURRENT_CONTEXT(ctx
);
1137 FLUSH_VERTICES(ctx
, 0);
1138 delete_shader_program(ctx
, name
);
1144 _mesa_DeleteShader(GLuint name
)
1147 GET_CURRENT_CONTEXT(ctx
);
1148 FLUSH_VERTICES(ctx
, 0);
1149 delete_shader(ctx
, name
);
1155 _mesa_DetachObjectARB(GLhandleARB program
, GLhandleARB shader
)
1157 GET_CURRENT_CONTEXT(ctx
);
1158 detach_shader(ctx
, program
, shader
);
1163 _mesa_DetachShader(GLuint program
, GLuint shader
)
1165 GET_CURRENT_CONTEXT(ctx
);
1166 detach_shader(ctx
, program
, shader
);
1171 _mesa_GetAttachedObjectsARB(GLhandleARB container
, GLsizei maxCount
,
1172 GLsizei
* count
, GLhandleARB
* obj
)
1174 GET_CURRENT_CONTEXT(ctx
);
1175 get_attached_shaders(ctx
, container
, maxCount
, count
, obj
);
1180 _mesa_GetAttachedShaders(GLuint program
, GLsizei maxCount
,
1181 GLsizei
*count
, GLuint
*obj
)
1183 GET_CURRENT_CONTEXT(ctx
);
1184 get_attached_shaders(ctx
, program
, maxCount
, count
, obj
);
1188 /* GL_EXT_gpu_shader4, GL3 */
1190 _mesa_GetFragDataLocation(GLuint program
, const GLchar
*name
)
1192 GET_CURRENT_CONTEXT(ctx
);
1193 return get_frag_data_location(ctx
, program
, name
);
1199 _mesa_GetInfoLogARB(GLhandleARB object
, GLsizei maxLength
, GLsizei
* length
,
1200 GLcharARB
* infoLog
)
1202 GET_CURRENT_CONTEXT(ctx
);
1203 if (is_program(ctx
, object
)) {
1204 get_program_info_log(ctx
, object
, maxLength
, length
, infoLog
);
1206 else if (is_shader(ctx
, object
)) {
1207 get_shader_info_log(ctx
, object
, maxLength
, length
, infoLog
);
1210 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetInfoLogARB");
1216 _mesa_GetObjectParameterivARB(GLhandleARB object
, GLenum pname
, GLint
*params
)
1218 GET_CURRENT_CONTEXT(ctx
);
1219 /* Implement in terms of GetProgramiv, GetShaderiv */
1220 if (is_program(ctx
, object
)) {
1221 if (pname
== GL_OBJECT_TYPE_ARB
) {
1222 *params
= GL_PROGRAM_OBJECT_ARB
;
1225 get_programiv(ctx
, object
, pname
, params
);
1228 else if (is_shader(ctx
, object
)) {
1229 if (pname
== GL_OBJECT_TYPE_ARB
) {
1230 *params
= GL_SHADER_OBJECT_ARB
;
1233 get_shaderiv(ctx
, object
, pname
, params
);
1237 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetObjectParameterivARB");
1243 _mesa_GetObjectParameterfvARB(GLhandleARB object
, GLenum pname
,
1246 GLint iparams
[1]; /* XXX is one element enough? */
1247 _mesa_GetObjectParameterivARB(object
, pname
, iparams
);
1248 params
[0] = (GLfloat
) iparams
[0];
1253 _mesa_GetProgramiv(GLuint program
, GLenum pname
, GLint
*params
)
1255 GET_CURRENT_CONTEXT(ctx
);
1256 get_programiv(ctx
, program
, pname
, params
);
1261 _mesa_GetShaderiv(GLuint shader
, GLenum pname
, GLint
*params
)
1263 GET_CURRENT_CONTEXT(ctx
);
1264 get_shaderiv(ctx
, shader
, pname
, params
);
1269 _mesa_GetProgramInfoLog(GLuint program
, GLsizei bufSize
,
1270 GLsizei
*length
, GLchar
*infoLog
)
1272 GET_CURRENT_CONTEXT(ctx
);
1273 get_program_info_log(ctx
, program
, bufSize
, length
, infoLog
);
1278 _mesa_GetShaderInfoLog(GLuint shader
, GLsizei bufSize
,
1279 GLsizei
*length
, GLchar
*infoLog
)
1281 GET_CURRENT_CONTEXT(ctx
);
1282 get_shader_info_log(ctx
, shader
, bufSize
, length
, infoLog
);
1287 _mesa_GetShaderSourceARB(GLhandleARB shader
, GLsizei maxLength
,
1288 GLsizei
*length
, GLcharARB
*sourceOut
)
1290 GET_CURRENT_CONTEXT(ctx
);
1291 get_shader_source(ctx
, shader
, maxLength
, length
, sourceOut
);
1295 GLhandleARB GLAPIENTRY
1296 _mesa_GetHandleARB(GLenum pname
)
1298 GET_CURRENT_CONTEXT(ctx
);
1299 return get_handle(ctx
, pname
);
1303 GLboolean GLAPIENTRY
1304 _mesa_IsProgram(GLuint name
)
1306 GET_CURRENT_CONTEXT(ctx
);
1307 return is_program(ctx
, name
);
1311 GLboolean GLAPIENTRY
1312 _mesa_IsShader(GLuint name
)
1314 GET_CURRENT_CONTEXT(ctx
);
1315 return is_shader(ctx
, name
);
1320 _mesa_LinkProgramARB(GLhandleARB programObj
)
1322 GET_CURRENT_CONTEXT(ctx
);
1323 link_program(ctx
, programObj
);
1329 * Read shader source code from a file.
1330 * Useful for debugging to override an app's shader.
1333 read_shader(const char *fname
)
1335 const int max
= 50*1000;
1336 FILE *f
= fopen(fname
, "r");
1337 GLcharARB
*buffer
, *shader
;
1344 buffer
= (char *) malloc(max
);
1345 len
= fread(buffer
, 1, max
, f
);
1350 shader
= _mesa_strdup(buffer
);
1358 * Called via glShaderSource() and glShaderSourceARB() API functions.
1359 * Basically, concatenate the source code strings into one long string
1360 * and pass it to _mesa_shader_source().
1363 _mesa_ShaderSourceARB(GLhandleARB shaderObj
, GLsizei count
,
1364 const GLcharARB
** string
, const GLint
* length
)
1366 GET_CURRENT_CONTEXT(ctx
);
1368 GLsizei i
, totalLength
;
1372 if (!shaderObj
|| string
== NULL
) {
1373 _mesa_error(ctx
, GL_INVALID_VALUE
, "glShaderSourceARB");
1378 * This array holds offsets of where the appropriate string ends, thus the
1379 * last element will be set to the total length of the source code.
1381 offsets
= (GLint
*) malloc(count
* sizeof(GLint
));
1382 if (offsets
== NULL
) {
1383 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
1387 for (i
= 0; i
< count
; i
++) {
1388 if (string
[i
] == NULL
) {
1389 free((GLvoid
*) offsets
);
1390 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1391 "glShaderSourceARB(null string)");
1394 if (length
== NULL
|| length
[i
] < 0)
1395 offsets
[i
] = strlen(string
[i
]);
1397 offsets
[i
] = length
[i
];
1398 /* accumulate string lengths */
1400 offsets
[i
] += offsets
[i
- 1];
1403 /* Total length of source string is sum off all strings plus two.
1404 * One extra byte for terminating zero, another extra byte to silence
1405 * valgrind warnings in the parser/grammer code.
1407 totalLength
= offsets
[count
- 1] + 2;
1408 source
= (GLcharARB
*) malloc(totalLength
* sizeof(GLcharARB
));
1409 if (source
== NULL
) {
1410 free((GLvoid
*) offsets
);
1411 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
1415 for (i
= 0; i
< count
; i
++) {
1416 GLint start
= (i
> 0) ? offsets
[i
- 1] : 0;
1417 memcpy(source
+ start
, string
[i
],
1418 (offsets
[i
] - start
) * sizeof(GLcharARB
));
1420 source
[totalLength
- 1] = '\0';
1421 source
[totalLength
- 2] = '\0';
1424 /* Compute the shader's source code checksum then try to open a file
1425 * named newshader_<CHECKSUM>. If it exists, use it in place of the
1426 * original shader source code. For debugging.
1429 GLcharARB
*newSource
;
1431 checksum
= _mesa_str_checksum(source
);
1433 _mesa_snprintf(filename
, sizeof(filename
), "newshader_%d", checksum
);
1435 newSource
= read_shader(filename
);
1437 fprintf(stderr
, "Mesa: Replacing shader %u chksum=%d with %s\n",
1438 shaderObj
, checksum
, filename
);
1444 shader_source(ctx
, shaderObj
, source
);
1447 struct gl_shader
*sh
= _mesa_lookup_shader(ctx
, shaderObj
);
1449 sh
->SourceChecksum
= checksum
; /* save original checksum */
1457 _mesa_UseProgramObjectARB(GLhandleARB program
)
1459 GET_CURRENT_CONTEXT(ctx
);
1460 struct gl_shader_program
*shProg
;
1461 struct gl_transform_feedback_object
*obj
=
1462 ctx
->TransformFeedback
.CurrentObject
;
1464 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1467 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1468 "glUseProgram(transform feedback active)");
1473 shProg
= _mesa_lookup_shader_program_err(ctx
, program
, "glUseProgram");
1477 if (!shProg
->LinkStatus
) {
1478 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1479 "glUseProgram(program %u not linked)", program
);
1484 if (ctx
->Shader
.Flags
& GLSL_USE_PROG
) {
1485 print_shader_info(shProg
);
1492 _mesa_use_program(ctx
, shProg
);
1497 _mesa_ValidateProgramARB(GLhandleARB program
)
1499 GET_CURRENT_CONTEXT(ctx
);
1500 validate_program(ctx
, program
);
1506 _mesa_GetShaderPrecisionFormat(GLenum shadertype
, GLenum precisiontype
,
1507 GLint
* range
, GLint
* precision
)
1509 const struct gl_program_constants
*limits
;
1510 const struct gl_precision
*p
;
1511 GET_CURRENT_CONTEXT(ctx
);
1513 switch (shadertype
) {
1514 case GL_VERTEX_SHADER
:
1515 limits
= &ctx
->Const
.VertexProgram
;
1517 case GL_FRAGMENT_SHADER
:
1518 limits
= &ctx
->Const
.FragmentProgram
;
1521 _mesa_error(ctx
, GL_INVALID_ENUM
,
1522 "glGetShaderPrecisionFormat(shadertype)");
1526 switch (precisiontype
) {
1528 p
= &limits
->LowFloat
;
1530 case GL_MEDIUM_FLOAT
:
1531 p
= &limits
->MediumFloat
;
1534 p
= &limits
->HighFloat
;
1537 p
= &limits
->LowInt
;
1540 p
= &limits
->MediumInt
;
1543 p
= &limits
->HighInt
;
1546 _mesa_error(ctx
, GL_INVALID_ENUM
,
1547 "glGetShaderPrecisionFormat(precisiontype)");
1551 range
[0] = p
->RangeMin
;
1552 range
[1] = p
->RangeMax
;
1553 precision
[0] = p
->Precision
;
1558 _mesa_ReleaseShaderCompiler(void)
1560 _mesa_destroy_shader_compiler_caches();
1565 _mesa_ShaderBinary(GLint n
, const GLuint
* shaders
, GLenum binaryformat
,
1566 const void* binary
, GLint length
)
1568 GET_CURRENT_CONTEXT(ctx
);
1571 (void) binaryformat
;
1574 _mesa_error(ctx
, GL_INVALID_OPERATION
, __FUNCTION__
);
1577 #endif /* FEATURE_ES2 */
1580 #if FEATURE_ARB_geometry_shader4
1583 _mesa_ProgramParameteriARB(GLuint program
, GLenum pname
, GLint value
)
1585 struct gl_shader_program
*shProg
;
1586 GET_CURRENT_CONTEXT(ctx
);
1588 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1590 shProg
= _mesa_lookup_shader_program_err(ctx
, program
,
1591 "glProgramParameteri");
1596 case GL_GEOMETRY_VERTICES_OUT_ARB
:
1598 (unsigned) value
> ctx
->Const
.MaxGeometryOutputVertices
) {
1599 _mesa_error(ctx
, GL_INVALID_VALUE
,
1600 "glProgramParameteri(GL_GEOMETRY_VERTICES_OUT_ARB=%d",
1604 shProg
->Geom
.VerticesOut
= value
;
1606 case GL_GEOMETRY_INPUT_TYPE_ARB
:
1610 case GL_LINES_ADJACENCY_ARB
:
1612 case GL_TRIANGLES_ADJACENCY_ARB
:
1613 shProg
->Geom
.InputType
= value
;
1616 _mesa_error(ctx
, GL_INVALID_VALUE
,
1617 "glProgramParameteri(geometry input type = %s",
1618 _mesa_lookup_enum_by_nr(value
));
1622 case GL_GEOMETRY_OUTPUT_TYPE_ARB
:
1626 case GL_TRIANGLE_STRIP
:
1627 shProg
->Geom
.OutputType
= value
;
1630 _mesa_error(ctx
, GL_INVALID_VALUE
,
1631 "glProgramParameteri(geometry output type = %s",
1632 _mesa_lookup_enum_by_nr(value
));
1637 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameteriARB(pname=%s)",
1638 _mesa_lookup_enum_by_nr(pname
));
1646 _mesa_use_shader_program(struct gl_context
*ctx
, GLenum type
,
1647 struct gl_shader_program
*shProg
)
1649 use_shader_program(ctx
, type
, shProg
);
1651 if (ctx
->Driver
.UseProgram
)
1652 ctx
->Driver
.UseProgram(ctx
, shProg
);
1656 _mesa_UseShaderProgramEXT(GLenum type
, GLuint program
)
1658 GET_CURRENT_CONTEXT(ctx
);
1659 struct gl_shader_program
*shProg
= NULL
;
1661 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1663 if (!validate_shader_target(ctx
, type
)) {
1664 _mesa_error(ctx
, GL_INVALID_ENUM
, "glUseShaderProgramEXT(type)");
1668 if (ctx
->TransformFeedback
.CurrentObject
->Active
) {
1669 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1670 "glUseShaderProgramEXT(transform feedback is active)");
1675 shProg
= _mesa_lookup_shader_program_err(ctx
, program
,
1676 "glUseShaderProgramEXT");
1680 if (!shProg
->LinkStatus
) {
1681 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1682 "glUseShaderProgramEXT(program not linked)");
1687 _mesa_use_shader_program(ctx
, type
, shProg
);
1691 _mesa_ActiveProgramEXT(GLuint program
)
1693 GET_CURRENT_CONTEXT(ctx
);
1694 struct gl_shader_program
*shProg
= (program
!= 0)
1695 ? _mesa_lookup_shader_program_err(ctx
, program
, "glActiveProgramEXT")
1698 _mesa_active_program(ctx
, shProg
, "glActiveProgramEXT");
1703 _mesa_CreateShaderProgramEXT(GLenum type
, const GLchar
*string
)
1705 GET_CURRENT_CONTEXT(ctx
);
1706 const GLuint shader
= create_shader(ctx
, type
);
1710 shader_source(ctx
, shader
, _mesa_strdup(string
));
1711 compile_shader(ctx
, shader
);
1713 program
= create_shader_program(ctx
);
1715 struct gl_shader_program
*shProg
;
1716 struct gl_shader
*sh
;
1717 GLint compiled
= GL_FALSE
;
1719 shProg
= _mesa_lookup_shader_program(ctx
, program
);
1720 sh
= _mesa_lookup_shader(ctx
, shader
);
1722 get_shaderiv(ctx
, shader
, GL_COMPILE_STATUS
, &compiled
);
1724 attach_shader(ctx
, program
, shader
);
1725 link_program(ctx
, program
);
1726 detach_shader(ctx
, program
, shader
);
1730 if (active
-user
-defined
-varyings
-in
-linked
-program
) {
1731 append
-error
-to
-info
-log
;
1732 shProg
->LinkStatus
= GL_FALSE
;
1737 ralloc_strcat(&shProg
->InfoLog
, sh
->InfoLog
);
1740 delete_shader(ctx
, shader
);
1747 * Plug in shader-related functions into API dispatch table.
1750 _mesa_init_shader_dispatch(struct _glapi_table
*exec
)
1753 /* GL_ARB_vertex/fragment_shader */
1754 SET_DeleteObjectARB(exec
, _mesa_DeleteObjectARB
);
1755 SET_GetHandleARB(exec
, _mesa_GetHandleARB
);
1756 SET_DetachObjectARB(exec
, _mesa_DetachObjectARB
);
1757 SET_CreateShaderObjectARB(exec
, _mesa_CreateShaderObjectARB
);
1758 SET_ShaderSourceARB(exec
, _mesa_ShaderSourceARB
);
1759 SET_CompileShaderARB(exec
, _mesa_CompileShaderARB
);
1760 SET_CreateProgramObjectARB(exec
, _mesa_CreateProgramObjectARB
);
1761 SET_AttachObjectARB(exec
, _mesa_AttachObjectARB
);
1762 SET_LinkProgramARB(exec
, _mesa_LinkProgramARB
);
1763 SET_UseProgramObjectARB(exec
, _mesa_UseProgramObjectARB
);
1764 SET_ValidateProgramARB(exec
, _mesa_ValidateProgramARB
);
1765 SET_GetObjectParameterfvARB(exec
, _mesa_GetObjectParameterfvARB
);
1766 SET_GetObjectParameterivARB(exec
, _mesa_GetObjectParameterivARB
);
1767 SET_GetInfoLogARB(exec
, _mesa_GetInfoLogARB
);
1768 SET_GetAttachedObjectsARB(exec
, _mesa_GetAttachedObjectsARB
);
1769 SET_GetShaderSourceARB(exec
, _mesa_GetShaderSourceARB
);
1772 SET_AttachShader(exec
, _mesa_AttachShader
);
1773 SET_CreateProgram(exec
, _mesa_CreateProgram
);
1774 SET_CreateShader(exec
, _mesa_CreateShader
);
1775 SET_DeleteProgram(exec
, _mesa_DeleteProgram
);
1776 SET_DeleteShader(exec
, _mesa_DeleteShader
);
1777 SET_DetachShader(exec
, _mesa_DetachShader
);
1778 SET_GetAttachedShaders(exec
, _mesa_GetAttachedShaders
);
1779 SET_GetProgramiv(exec
, _mesa_GetProgramiv
);
1780 SET_GetProgramInfoLog(exec
, _mesa_GetProgramInfoLog
);
1781 SET_GetShaderiv(exec
, _mesa_GetShaderiv
);
1782 SET_GetShaderInfoLog(exec
, _mesa_GetShaderInfoLog
);
1783 SET_IsProgram(exec
, _mesa_IsProgram
);
1784 SET_IsShader(exec
, _mesa_IsShader
);
1786 #if FEATURE_ARB_vertex_shader
1787 SET_BindAttribLocationARB(exec
, _mesa_BindAttribLocationARB
);
1788 SET_GetActiveAttribARB(exec
, _mesa_GetActiveAttribARB
);
1789 SET_GetAttribLocationARB(exec
, _mesa_GetAttribLocationARB
);
1792 #if FEATURE_ARB_geometry_shader4
1793 SET_ProgramParameteriARB(exec
, _mesa_ProgramParameteriARB
);
1796 SET_UseShaderProgramEXT(exec
, _mesa_UseShaderProgramEXT
);
1797 SET_ActiveProgramEXT(exec
, _mesa_ActiveProgramEXT
);
1798 SET_CreateShaderProgramEXT(exec
, _mesa_CreateShaderProgramEXT
);
1800 /* GL_EXT_gpu_shader4 / GL 3.0 */
1801 SET_BindFragDataLocationEXT(exec
, _mesa_BindFragDataLocation
);
1802 SET_GetFragDataLocationEXT(exec
, _mesa_GetFragDataLocation
);
1804 /* GL_ARB_ES2_compatibility */
1805 SET_ReleaseShaderCompiler(exec
, _mesa_ReleaseShaderCompiler
);
1806 SET_GetShaderPrecisionFormat(exec
, _mesa_GetShaderPrecisionFormat
);
1808 #endif /* FEATURE_GL */