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
->VertexProgram
)
812 printf(" vert prog %u\n", shProg
->VertexProgram
->Base
.Id
);
813 if (shProg
->FragmentProgram
)
814 printf(" frag prog %u\n", shProg
->FragmentProgram
->Base
.Id
);
815 if (shProg
->GeometryProgram
)
816 printf(" geom prog %u\n", shProg
->GeometryProgram
->Base
.Id
);
821 * Use the named shader program for subsequent glUniform calls
824 _mesa_active_program(struct gl_context
*ctx
, struct gl_shader_program
*shProg
,
827 if ((shProg
!= NULL
) && !shProg
->LinkStatus
) {
828 _mesa_error(ctx
, GL_INVALID_OPERATION
,
829 "%s(program %u not linked)", caller
, shProg
->Name
);
833 if (ctx
->Shader
.ActiveProgram
!= shProg
) {
834 _mesa_reference_shader_program(ctx
, &ctx
->Shader
.ActiveProgram
, shProg
);
841 use_shader_program(struct gl_context
*ctx
, GLenum type
,
842 struct gl_shader_program
*shProg
)
844 struct gl_shader_program
**target
;
847 #if FEATURE_ARB_vertex_shader
848 case GL_VERTEX_SHADER
:
849 target
= &ctx
->Shader
.CurrentVertexProgram
;
851 || (shProg
->_LinkedShaders
[MESA_SHADER_VERTEX
] == NULL
)) {
856 #if FEATURE_ARB_geometry_shader4
857 case GL_GEOMETRY_SHADER_ARB
:
858 target
= &ctx
->Shader
.CurrentGeometryProgram
;
860 || (shProg
->_LinkedShaders
[MESA_SHADER_GEOMETRY
] == NULL
)) {
865 #if FEATURE_ARB_fragment_shader
866 case GL_FRAGMENT_SHADER
:
867 target
= &ctx
->Shader
.CurrentFragmentProgram
;
869 || (shProg
->_LinkedShaders
[MESA_SHADER_FRAGMENT
] == NULL
)) {
878 if (*target
!= shProg
) {
879 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
| _NEW_PROGRAM_CONSTANTS
);
880 _mesa_reference_shader_program(ctx
, target
, shProg
);
888 * Use the named shader program for subsequent rendering.
891 _mesa_use_program(struct gl_context
*ctx
, struct gl_shader_program
*shProg
)
893 use_shader_program(ctx
, GL_VERTEX_SHADER
, shProg
);
894 use_shader_program(ctx
, GL_GEOMETRY_SHADER_ARB
, shProg
);
895 use_shader_program(ctx
, GL_FRAGMENT_SHADER
, shProg
);
896 _mesa_active_program(ctx
, shProg
, "glUseProgram");
898 if (ctx
->Driver
.UseProgram
)
899 ctx
->Driver
.UseProgram(ctx
, shProg
);
904 * Validate a program's samplers.
905 * Specifically, check that there aren't two samplers of different types
906 * pointing to the same texture unit.
907 * \return GL_TRUE if valid, GL_FALSE if invalid
910 validate_samplers(const struct gl_program
*prog
, char *errMsg
)
912 static const char *targetName
[] = {
922 GLint targetUsed
[MAX_COMBINED_TEXTURE_IMAGE_UNITS
];
923 GLbitfield samplersUsed
= prog
->SamplersUsed
;
926 assert(Elements(targetName
) == NUM_TEXTURE_TARGETS
);
928 if (samplersUsed
== 0x0)
931 for (i
= 0; i
< Elements(targetUsed
); i
++)
934 /* walk over bits which are set in 'samplers' */
935 while (samplersUsed
) {
937 gl_texture_index target
;
938 GLint sampler
= _mesa_ffs(samplersUsed
) - 1;
939 assert(sampler
>= 0);
940 assert(sampler
< Elements(prog
->SamplerUnits
));
941 unit
= prog
->SamplerUnits
[sampler
];
942 target
= prog
->SamplerTargets
[sampler
];
943 if (targetUsed
[unit
] != -1 && targetUsed
[unit
] != (int) target
) {
944 _mesa_snprintf(errMsg
, 100,
945 "Texture unit %d is accessed both as %s and %s",
946 unit
, targetName
[targetUsed
[unit
]], targetName
[target
]);
949 targetUsed
[unit
] = target
;
950 samplersUsed
^= (1 << sampler
);
958 * Do validation of the given shader program.
959 * \param errMsg returns error message if validation fails.
960 * \return GL_TRUE if valid, GL_FALSE if invalid (and set errMsg)
963 validate_shader_program(const struct gl_shader_program
*shProg
,
966 const struct gl_vertex_program
*vp
= shProg
->VertexProgram
;
967 const struct gl_geometry_program
*gp
= shProg
->GeometryProgram
;
968 const struct gl_fragment_program
*fp
= shProg
->FragmentProgram
;
970 if (!shProg
->LinkStatus
) {
974 /* From the GL spec, a program is invalid if any of these are true:
976 any two active samplers in the current program object are of
977 different types, but refer to the same texture image unit,
979 any active sampler in the current program object refers to a texture
980 image unit where fixed-function fragment processing accesses a
981 texture target that does not match the sampler type, or
983 the sum of the number of active samplers in the program and the
984 number of texture image units enabled for fixed-function fragment
985 processing exceeds the combined limit on the total number of texture
991 * Check: any two active samplers in the current program object are of
992 * different types, but refer to the same texture image unit,
994 if (vp
&& !validate_samplers(&vp
->Base
, errMsg
)) {
997 if (gp
&& !validate_samplers(&gp
->Base
, errMsg
)) {
1000 if (fp
&& !validate_samplers(&fp
->Base
, errMsg
)) {
1009 * Called via glValidateProgram()
1012 validate_program(struct gl_context
*ctx
, GLuint program
)
1014 struct gl_shader_program
*shProg
;
1015 char errMsg
[100] = "";
1017 shProg
= _mesa_lookup_shader_program_err(ctx
, program
, "glValidateProgram");
1022 shProg
->Validated
= validate_shader_program(shProg
, errMsg
);
1023 if (!shProg
->Validated
) {
1024 /* update info log */
1025 if (shProg
->InfoLog
) {
1026 ralloc_free(shProg
->InfoLog
);
1028 shProg
->InfoLog
= ralloc_strdup(shProg
, errMsg
);
1035 _mesa_AttachObjectARB(GLhandleARB program
, GLhandleARB shader
)
1037 GET_CURRENT_CONTEXT(ctx
);
1038 attach_shader(ctx
, program
, shader
);
1043 _mesa_AttachShader(GLuint program
, GLuint shader
)
1045 GET_CURRENT_CONTEXT(ctx
);
1046 attach_shader(ctx
, program
, shader
);
1050 /* GL_EXT_gpu_shader4, GL3 */
1052 _mesa_BindFragDataLocation(GLuint program
, GLuint colorNumber
,
1055 GET_CURRENT_CONTEXT(ctx
);
1056 bind_frag_data_location(ctx
, program
, colorNumber
, name
);
1061 _mesa_CompileShaderARB(GLhandleARB shaderObj
)
1063 GET_CURRENT_CONTEXT(ctx
);
1064 if (MESA_VERBOSE
& VERBOSE_API
)
1065 _mesa_debug(ctx
, "glCompileShader %u\n", shaderObj
);
1066 compile_shader(ctx
, shaderObj
);
1071 _mesa_CreateShader(GLenum type
)
1073 GET_CURRENT_CONTEXT(ctx
);
1074 if (MESA_VERBOSE
& VERBOSE_API
)
1075 _mesa_debug(ctx
, "glCreateShader %s\n", _mesa_lookup_enum_by_nr(type
));
1076 return create_shader(ctx
, type
);
1080 GLhandleARB GLAPIENTRY
1081 _mesa_CreateShaderObjectARB(GLenum type
)
1083 GET_CURRENT_CONTEXT(ctx
);
1084 return create_shader(ctx
, type
);
1089 _mesa_CreateProgram(void)
1091 GET_CURRENT_CONTEXT(ctx
);
1092 if (MESA_VERBOSE
& VERBOSE_API
)
1093 _mesa_debug(ctx
, "glCreateProgram\n");
1094 return create_shader_program(ctx
);
1098 GLhandleARB GLAPIENTRY
1099 _mesa_CreateProgramObjectARB(void)
1101 GET_CURRENT_CONTEXT(ctx
);
1102 return create_shader_program(ctx
);
1107 _mesa_DeleteObjectARB(GLhandleARB obj
)
1109 if (MESA_VERBOSE
& VERBOSE_API
) {
1110 GET_CURRENT_CONTEXT(ctx
);
1111 _mesa_debug(ctx
, "glDeleteObjectARB(%u)\n", obj
);
1115 GET_CURRENT_CONTEXT(ctx
);
1116 FLUSH_VERTICES(ctx
, 0);
1117 if (is_program(ctx
, obj
)) {
1118 delete_shader_program(ctx
, obj
);
1120 else if (is_shader(ctx
, obj
)) {
1121 delete_shader(ctx
, obj
);
1131 _mesa_DeleteProgram(GLuint name
)
1134 GET_CURRENT_CONTEXT(ctx
);
1135 FLUSH_VERTICES(ctx
, 0);
1136 delete_shader_program(ctx
, name
);
1142 _mesa_DeleteShader(GLuint name
)
1145 GET_CURRENT_CONTEXT(ctx
);
1146 FLUSH_VERTICES(ctx
, 0);
1147 delete_shader(ctx
, name
);
1153 _mesa_DetachObjectARB(GLhandleARB program
, GLhandleARB shader
)
1155 GET_CURRENT_CONTEXT(ctx
);
1156 detach_shader(ctx
, program
, shader
);
1161 _mesa_DetachShader(GLuint program
, GLuint shader
)
1163 GET_CURRENT_CONTEXT(ctx
);
1164 detach_shader(ctx
, program
, shader
);
1169 _mesa_GetAttachedObjectsARB(GLhandleARB container
, GLsizei maxCount
,
1170 GLsizei
* count
, GLhandleARB
* obj
)
1172 GET_CURRENT_CONTEXT(ctx
);
1173 get_attached_shaders(ctx
, container
, maxCount
, count
, obj
);
1178 _mesa_GetAttachedShaders(GLuint program
, GLsizei maxCount
,
1179 GLsizei
*count
, GLuint
*obj
)
1181 GET_CURRENT_CONTEXT(ctx
);
1182 get_attached_shaders(ctx
, program
, maxCount
, count
, obj
);
1186 /* GL_EXT_gpu_shader4, GL3 */
1188 _mesa_GetFragDataLocation(GLuint program
, const GLchar
*name
)
1190 GET_CURRENT_CONTEXT(ctx
);
1191 return get_frag_data_location(ctx
, program
, name
);
1197 _mesa_GetInfoLogARB(GLhandleARB object
, GLsizei maxLength
, GLsizei
* length
,
1198 GLcharARB
* infoLog
)
1200 GET_CURRENT_CONTEXT(ctx
);
1201 if (is_program(ctx
, object
)) {
1202 get_program_info_log(ctx
, object
, maxLength
, length
, infoLog
);
1204 else if (is_shader(ctx
, object
)) {
1205 get_shader_info_log(ctx
, object
, maxLength
, length
, infoLog
);
1208 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetInfoLogARB");
1214 _mesa_GetObjectParameterivARB(GLhandleARB object
, GLenum pname
, GLint
*params
)
1216 GET_CURRENT_CONTEXT(ctx
);
1217 /* Implement in terms of GetProgramiv, GetShaderiv */
1218 if (is_program(ctx
, object
)) {
1219 if (pname
== GL_OBJECT_TYPE_ARB
) {
1220 *params
= GL_PROGRAM_OBJECT_ARB
;
1223 get_programiv(ctx
, object
, pname
, params
);
1226 else if (is_shader(ctx
, object
)) {
1227 if (pname
== GL_OBJECT_TYPE_ARB
) {
1228 *params
= GL_SHADER_OBJECT_ARB
;
1231 get_shaderiv(ctx
, object
, pname
, params
);
1235 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetObjectParameterivARB");
1241 _mesa_GetObjectParameterfvARB(GLhandleARB object
, GLenum pname
,
1244 GLint iparams
[1]; /* XXX is one element enough? */
1245 _mesa_GetObjectParameterivARB(object
, pname
, iparams
);
1246 params
[0] = (GLfloat
) iparams
[0];
1251 _mesa_GetProgramiv(GLuint program
, GLenum pname
, GLint
*params
)
1253 GET_CURRENT_CONTEXT(ctx
);
1254 get_programiv(ctx
, program
, pname
, params
);
1259 _mesa_GetShaderiv(GLuint shader
, GLenum pname
, GLint
*params
)
1261 GET_CURRENT_CONTEXT(ctx
);
1262 get_shaderiv(ctx
, shader
, pname
, params
);
1267 _mesa_GetProgramInfoLog(GLuint program
, GLsizei bufSize
,
1268 GLsizei
*length
, GLchar
*infoLog
)
1270 GET_CURRENT_CONTEXT(ctx
);
1271 get_program_info_log(ctx
, program
, bufSize
, length
, infoLog
);
1276 _mesa_GetShaderInfoLog(GLuint shader
, GLsizei bufSize
,
1277 GLsizei
*length
, GLchar
*infoLog
)
1279 GET_CURRENT_CONTEXT(ctx
);
1280 get_shader_info_log(ctx
, shader
, bufSize
, length
, infoLog
);
1285 _mesa_GetShaderSourceARB(GLhandleARB shader
, GLsizei maxLength
,
1286 GLsizei
*length
, GLcharARB
*sourceOut
)
1288 GET_CURRENT_CONTEXT(ctx
);
1289 get_shader_source(ctx
, shader
, maxLength
, length
, sourceOut
);
1293 GLhandleARB GLAPIENTRY
1294 _mesa_GetHandleARB(GLenum pname
)
1296 GET_CURRENT_CONTEXT(ctx
);
1297 return get_handle(ctx
, pname
);
1301 GLboolean GLAPIENTRY
1302 _mesa_IsProgram(GLuint name
)
1304 GET_CURRENT_CONTEXT(ctx
);
1305 return is_program(ctx
, name
);
1309 GLboolean GLAPIENTRY
1310 _mesa_IsShader(GLuint name
)
1312 GET_CURRENT_CONTEXT(ctx
);
1313 return is_shader(ctx
, name
);
1318 _mesa_LinkProgramARB(GLhandleARB programObj
)
1320 GET_CURRENT_CONTEXT(ctx
);
1321 link_program(ctx
, programObj
);
1327 * Read shader source code from a file.
1328 * Useful for debugging to override an app's shader.
1331 read_shader(const char *fname
)
1333 const int max
= 50*1000;
1334 FILE *f
= fopen(fname
, "r");
1335 GLcharARB
*buffer
, *shader
;
1342 buffer
= (char *) malloc(max
);
1343 len
= fread(buffer
, 1, max
, f
);
1348 shader
= _mesa_strdup(buffer
);
1356 * Called via glShaderSource() and glShaderSourceARB() API functions.
1357 * Basically, concatenate the source code strings into one long string
1358 * and pass it to _mesa_shader_source().
1361 _mesa_ShaderSourceARB(GLhandleARB shaderObj
, GLsizei count
,
1362 const GLcharARB
** string
, const GLint
* length
)
1364 GET_CURRENT_CONTEXT(ctx
);
1366 GLsizei i
, totalLength
;
1370 if (!shaderObj
|| string
== NULL
) {
1371 _mesa_error(ctx
, GL_INVALID_VALUE
, "glShaderSourceARB");
1376 * This array holds offsets of where the appropriate string ends, thus the
1377 * last element will be set to the total length of the source code.
1379 offsets
= (GLint
*) malloc(count
* sizeof(GLint
));
1380 if (offsets
== NULL
) {
1381 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
1385 for (i
= 0; i
< count
; i
++) {
1386 if (string
[i
] == NULL
) {
1387 free((GLvoid
*) offsets
);
1388 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1389 "glShaderSourceARB(null string)");
1392 if (length
== NULL
|| length
[i
] < 0)
1393 offsets
[i
] = strlen(string
[i
]);
1395 offsets
[i
] = length
[i
];
1396 /* accumulate string lengths */
1398 offsets
[i
] += offsets
[i
- 1];
1401 /* Total length of source string is sum off all strings plus two.
1402 * One extra byte for terminating zero, another extra byte to silence
1403 * valgrind warnings in the parser/grammer code.
1405 totalLength
= offsets
[count
- 1] + 2;
1406 source
= (GLcharARB
*) malloc(totalLength
* sizeof(GLcharARB
));
1407 if (source
== NULL
) {
1408 free((GLvoid
*) offsets
);
1409 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
1413 for (i
= 0; i
< count
; i
++) {
1414 GLint start
= (i
> 0) ? offsets
[i
- 1] : 0;
1415 memcpy(source
+ start
, string
[i
],
1416 (offsets
[i
] - start
) * sizeof(GLcharARB
));
1418 source
[totalLength
- 1] = '\0';
1419 source
[totalLength
- 2] = '\0';
1422 /* Compute the shader's source code checksum then try to open a file
1423 * named newshader_<CHECKSUM>. If it exists, use it in place of the
1424 * original shader source code. For debugging.
1427 GLcharARB
*newSource
;
1429 checksum
= _mesa_str_checksum(source
);
1431 _mesa_snprintf(filename
, sizeof(filename
), "newshader_%d", checksum
);
1433 newSource
= read_shader(filename
);
1435 fprintf(stderr
, "Mesa: Replacing shader %u chksum=%d with %s\n",
1436 shaderObj
, checksum
, filename
);
1442 shader_source(ctx
, shaderObj
, source
);
1445 struct gl_shader
*sh
= _mesa_lookup_shader(ctx
, shaderObj
);
1447 sh
->SourceChecksum
= checksum
; /* save original checksum */
1455 _mesa_UseProgramObjectARB(GLhandleARB program
)
1457 GET_CURRENT_CONTEXT(ctx
);
1458 struct gl_shader_program
*shProg
;
1459 struct gl_transform_feedback_object
*obj
=
1460 ctx
->TransformFeedback
.CurrentObject
;
1462 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1465 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1466 "glUseProgram(transform feedback active)");
1471 shProg
= _mesa_lookup_shader_program_err(ctx
, program
, "glUseProgram");
1475 if (!shProg
->LinkStatus
) {
1476 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1477 "glUseProgram(program %u not linked)", program
);
1482 if (ctx
->Shader
.Flags
& GLSL_USE_PROG
) {
1483 print_shader_info(shProg
);
1490 _mesa_use_program(ctx
, shProg
);
1495 _mesa_ValidateProgramARB(GLhandleARB program
)
1497 GET_CURRENT_CONTEXT(ctx
);
1498 validate_program(ctx
, program
);
1504 _mesa_GetShaderPrecisionFormat(GLenum shadertype
, GLenum precisiontype
,
1505 GLint
* range
, GLint
* precision
)
1507 const struct gl_program_constants
*limits
;
1508 const struct gl_precision
*p
;
1509 GET_CURRENT_CONTEXT(ctx
);
1511 switch (shadertype
) {
1512 case GL_VERTEX_SHADER
:
1513 limits
= &ctx
->Const
.VertexProgram
;
1515 case GL_FRAGMENT_SHADER
:
1516 limits
= &ctx
->Const
.FragmentProgram
;
1519 _mesa_error(ctx
, GL_INVALID_ENUM
,
1520 "glGetShaderPrecisionFormat(shadertype)");
1524 switch (precisiontype
) {
1526 p
= &limits
->LowFloat
;
1528 case GL_MEDIUM_FLOAT
:
1529 p
= &limits
->MediumFloat
;
1532 p
= &limits
->HighFloat
;
1535 p
= &limits
->LowInt
;
1538 p
= &limits
->MediumInt
;
1541 p
= &limits
->HighInt
;
1544 _mesa_error(ctx
, GL_INVALID_ENUM
,
1545 "glGetShaderPrecisionFormat(precisiontype)");
1549 range
[0] = p
->RangeMin
;
1550 range
[1] = p
->RangeMax
;
1551 precision
[0] = p
->Precision
;
1556 _mesa_ReleaseShaderCompiler(void)
1558 _mesa_destroy_shader_compiler_caches();
1563 _mesa_ShaderBinary(GLint n
, const GLuint
* shaders
, GLenum binaryformat
,
1564 const void* binary
, GLint length
)
1566 GET_CURRENT_CONTEXT(ctx
);
1569 (void) binaryformat
;
1572 _mesa_error(ctx
, GL_INVALID_OPERATION
, __FUNCTION__
);
1575 #endif /* FEATURE_ES2 */
1578 #if FEATURE_ARB_geometry_shader4
1581 _mesa_ProgramParameteriARB(GLuint program
, GLenum pname
, GLint value
)
1583 struct gl_shader_program
*shProg
;
1584 GET_CURRENT_CONTEXT(ctx
);
1586 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1588 shProg
= _mesa_lookup_shader_program_err(ctx
, program
,
1589 "glProgramParameteri");
1594 case GL_GEOMETRY_VERTICES_OUT_ARB
:
1596 (unsigned) value
> ctx
->Const
.MaxGeometryOutputVertices
) {
1597 _mesa_error(ctx
, GL_INVALID_VALUE
,
1598 "glProgramParameteri(GL_GEOMETRY_VERTICES_OUT_ARB=%d",
1602 shProg
->Geom
.VerticesOut
= value
;
1604 case GL_GEOMETRY_INPUT_TYPE_ARB
:
1608 case GL_LINES_ADJACENCY_ARB
:
1610 case GL_TRIANGLES_ADJACENCY_ARB
:
1611 shProg
->Geom
.InputType
= value
;
1614 _mesa_error(ctx
, GL_INVALID_VALUE
,
1615 "glProgramParameteri(geometry input type = %s",
1616 _mesa_lookup_enum_by_nr(value
));
1620 case GL_GEOMETRY_OUTPUT_TYPE_ARB
:
1624 case GL_TRIANGLE_STRIP
:
1625 shProg
->Geom
.OutputType
= value
;
1628 _mesa_error(ctx
, GL_INVALID_VALUE
,
1629 "glProgramParameteri(geometry output type = %s",
1630 _mesa_lookup_enum_by_nr(value
));
1635 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameteriARB(pname=%s)",
1636 _mesa_lookup_enum_by_nr(pname
));
1644 _mesa_use_shader_program(struct gl_context
*ctx
, GLenum type
,
1645 struct gl_shader_program
*shProg
)
1647 use_shader_program(ctx
, type
, shProg
);
1649 if (ctx
->Driver
.UseProgram
)
1650 ctx
->Driver
.UseProgram(ctx
, shProg
);
1654 _mesa_UseShaderProgramEXT(GLenum type
, GLuint program
)
1656 GET_CURRENT_CONTEXT(ctx
);
1657 struct gl_shader_program
*shProg
= NULL
;
1659 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1661 if (!validate_shader_target(ctx
, type
)) {
1662 _mesa_error(ctx
, GL_INVALID_ENUM
, "glUseShaderProgramEXT(type)");
1666 if (ctx
->TransformFeedback
.CurrentObject
->Active
) {
1667 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1668 "glUseShaderProgramEXT(transform feedback is active)");
1673 shProg
= _mesa_lookup_shader_program_err(ctx
, program
,
1674 "glUseShaderProgramEXT");
1678 if (!shProg
->LinkStatus
) {
1679 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1680 "glUseShaderProgramEXT(program not linked)");
1685 _mesa_use_shader_program(ctx
, type
, shProg
);
1689 _mesa_ActiveProgramEXT(GLuint program
)
1691 GET_CURRENT_CONTEXT(ctx
);
1692 struct gl_shader_program
*shProg
= (program
!= 0)
1693 ? _mesa_lookup_shader_program_err(ctx
, program
, "glActiveProgramEXT")
1696 _mesa_active_program(ctx
, shProg
, "glActiveProgramEXT");
1701 _mesa_CreateShaderProgramEXT(GLenum type
, const GLchar
*string
)
1703 GET_CURRENT_CONTEXT(ctx
);
1704 const GLuint shader
= create_shader(ctx
, type
);
1708 shader_source(ctx
, shader
, _mesa_strdup(string
));
1709 compile_shader(ctx
, shader
);
1711 program
= create_shader_program(ctx
);
1713 struct gl_shader_program
*shProg
;
1714 struct gl_shader
*sh
;
1715 GLint compiled
= GL_FALSE
;
1717 shProg
= _mesa_lookup_shader_program(ctx
, program
);
1718 sh
= _mesa_lookup_shader(ctx
, shader
);
1720 get_shaderiv(ctx
, shader
, GL_COMPILE_STATUS
, &compiled
);
1722 attach_shader(ctx
, program
, shader
);
1723 link_program(ctx
, program
);
1724 detach_shader(ctx
, program
, shader
);
1728 if (active
-user
-defined
-varyings
-in
-linked
-program
) {
1729 append
-error
-to
-info
-log
;
1730 shProg
->LinkStatus
= GL_FALSE
;
1735 ralloc_strcat(&shProg
->InfoLog
, sh
->InfoLog
);
1738 delete_shader(ctx
, shader
);
1745 * Plug in shader-related functions into API dispatch table.
1748 _mesa_init_shader_dispatch(struct _glapi_table
*exec
)
1751 /* GL_ARB_vertex/fragment_shader */
1752 SET_DeleteObjectARB(exec
, _mesa_DeleteObjectARB
);
1753 SET_GetHandleARB(exec
, _mesa_GetHandleARB
);
1754 SET_DetachObjectARB(exec
, _mesa_DetachObjectARB
);
1755 SET_CreateShaderObjectARB(exec
, _mesa_CreateShaderObjectARB
);
1756 SET_ShaderSourceARB(exec
, _mesa_ShaderSourceARB
);
1757 SET_CompileShaderARB(exec
, _mesa_CompileShaderARB
);
1758 SET_CreateProgramObjectARB(exec
, _mesa_CreateProgramObjectARB
);
1759 SET_AttachObjectARB(exec
, _mesa_AttachObjectARB
);
1760 SET_LinkProgramARB(exec
, _mesa_LinkProgramARB
);
1761 SET_UseProgramObjectARB(exec
, _mesa_UseProgramObjectARB
);
1762 SET_ValidateProgramARB(exec
, _mesa_ValidateProgramARB
);
1763 SET_GetObjectParameterfvARB(exec
, _mesa_GetObjectParameterfvARB
);
1764 SET_GetObjectParameterivARB(exec
, _mesa_GetObjectParameterivARB
);
1765 SET_GetInfoLogARB(exec
, _mesa_GetInfoLogARB
);
1766 SET_GetAttachedObjectsARB(exec
, _mesa_GetAttachedObjectsARB
);
1767 SET_GetShaderSourceARB(exec
, _mesa_GetShaderSourceARB
);
1770 SET_AttachShader(exec
, _mesa_AttachShader
);
1771 SET_CreateProgram(exec
, _mesa_CreateProgram
);
1772 SET_CreateShader(exec
, _mesa_CreateShader
);
1773 SET_DeleteProgram(exec
, _mesa_DeleteProgram
);
1774 SET_DeleteShader(exec
, _mesa_DeleteShader
);
1775 SET_DetachShader(exec
, _mesa_DetachShader
);
1776 SET_GetAttachedShaders(exec
, _mesa_GetAttachedShaders
);
1777 SET_GetProgramiv(exec
, _mesa_GetProgramiv
);
1778 SET_GetProgramInfoLog(exec
, _mesa_GetProgramInfoLog
);
1779 SET_GetShaderiv(exec
, _mesa_GetShaderiv
);
1780 SET_GetShaderInfoLog(exec
, _mesa_GetShaderInfoLog
);
1781 SET_IsProgram(exec
, _mesa_IsProgram
);
1782 SET_IsShader(exec
, _mesa_IsShader
);
1784 #if FEATURE_ARB_vertex_shader
1785 SET_BindAttribLocationARB(exec
, _mesa_BindAttribLocationARB
);
1786 SET_GetActiveAttribARB(exec
, _mesa_GetActiveAttribARB
);
1787 SET_GetAttribLocationARB(exec
, _mesa_GetAttribLocationARB
);
1790 #if FEATURE_ARB_geometry_shader4
1791 SET_ProgramParameteriARB(exec
, _mesa_ProgramParameteriARB
);
1794 SET_UseShaderProgramEXT(exec
, _mesa_UseShaderProgramEXT
);
1795 SET_ActiveProgramEXT(exec
, _mesa_ActiveProgramEXT
);
1796 SET_CreateShaderProgramEXT(exec
, _mesa_CreateShaderProgramEXT
);
1798 /* GL_EXT_gpu_shader4 / GL 3.0 */
1799 SET_BindFragDataLocationEXT(exec
, _mesa_BindFragDataLocation
);
1800 SET_GetFragDataLocationEXT(exec
, _mesa_GetFragDataLocation
);
1802 /* GL_ARB_ES2_compatibility */
1803 SET_ReleaseShaderCompiler(exec
, _mesa_ReleaseShaderCompiler
);
1804 SET_GetShaderPrecisionFormat(exec
, _mesa_GetShaderPrecisionFormat
);
1806 #endif /* FEATURE_GL */