2 * Mesa 3-D graphics library
5 * Copyright (C) 2004-2005 Brian Paul 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.
26 * \file shaderobjects.c
27 * ARB_shader_objects state management functions
35 #include "shaderobjects.h"
36 #include "shaderobjects_3dlabs.h"
39 #define I_UNKNOWN struct gl2_unknown_intf **
40 #define I_GENERIC struct gl2_generic_intf **
41 #define I_CONTAINER struct gl2_container_intf **
42 #define I_PROGRAM struct gl2_program_intf **
43 #define I_SHADER struct gl2_shader_intf **
45 #define RELEASE_GENERIC(x)\
46 (**x)._unknown.Release ((I_UNKNOWN) x)
48 #define RELEASE_CONTAINER(x)\
49 (**x)._generic._unknown.Release ((I_UNKNOWN) x)
51 #define RELEASE_PROGRAM(x)\
52 (**x)._container._generic._unknown.Release ((I_UNKNOWN) x)
54 #define RELEASE_SHADER(x)\
55 (**x)._generic._unknown.Release ((I_UNKNOWN) x);
57 #define _LOOKUP_HANDLE(handle, function)\
59 _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\
60 unk = (I_UNKNOWN) _mesa_HashLookup (ctx->Shared->GL2Objects, handle);\
61 _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\
63 _mesa_error (ctx, GL_INVALID_VALUE, function);\
67 #define _QUERY_INTERFACE(x, type, uuid, function)\
68 x = (type) (**unk).QueryInterface (unk, uuid);\
70 _mesa_error (ctx, GL_INVALID_OPERATION, function);\
74 #define GET_GENERIC(x, handle, function)\
77 _LOOKUP_HANDLE(handle, function);\
78 _QUERY_INTERFACE(x, I_GENERIC, UIID_GENERIC, function);\
81 #define GET_CONTAINER(x, handle, function)\
82 I_CONTAINER x = NULL;\
84 _LOOKUP_HANDLE(handle, function);\
85 _QUERY_INTERFACE(x, I_CONTAINER, UIID_CONTAINER, function);\
88 #define GET_PROGRAM(x, handle, function)\
91 _LOOKUP_HANDLE(handle, function);\
92 _QUERY_INTERFACE(x, I_PROGRAM, UIID_PROGRAM, function);\
95 #define GET_SHADER(x, handle, function)\
98 _LOOKUP_HANDLE(handle, function);\
99 _QUERY_INTERFACE(x, I_SHADER, UIID_SHADER, function);\
102 #define _LINKED_PROGRAM(x, function)\
103 if ((**x).GetLinkStatus (x) == GL_FALSE) {\
105 _mesa_error (ctx, GL_INVALID_OPERATION, function);\
109 #define GET_LINKED_PROGRAM(x, handle, function)\
112 _LOOKUP_HANDLE(handle, function);\
113 _QUERY_INTERFACE(x, I_PROGRAM, UIID_PROGRAM, function);\
114 _LINKED_PROGRAM(x, function);\
117 #define _CURRENT_PROGRAM(x, function)\
118 if (ctx->ShaderObjects.CurrentProgram == NULL) {\
119 _mesa_error (ctx, GL_INVALID_OPERATION, function);\
122 x = ctx->ShaderObjects.CurrentProgram;
124 #define GET_CURRENT_LINKED_PROGRAM(x, function)\
127 _CURRENT_PROGRAM(x, function);\
128 _LINKED_PROGRAM(x, function);\
133 _mesa_DeleteObjectARB (GLhandleARB obj
)
135 GET_CURRENT_CONTEXT(ctx
);
136 GET_GENERIC(gen
, obj
, "glDeleteObjectARB");
140 (**gen
).Delete (gen
);
141 RELEASE_GENERIC(gen
);
145 GLhandleARB GLAPIENTRY
146 _mesa_GetHandleARB (GLenum pname
)
148 GET_CURRENT_CONTEXT(ctx
);
152 case GL_PROGRAM_OBJECT_ARB
:
154 I_PROGRAM pro
= ctx
->ShaderObjects
.CurrentProgram
;
157 return (**pro
)._container
._generic
.GetName ((I_GENERIC
) pro
);
161 _mesa_error (ctx
, GL_INVALID_ENUM
, "glGetHandleARB");
168 _mesa_DetachObjectARB (GLhandleARB containerObj
, GLhandleARB attachedObj
)
170 GET_CURRENT_CONTEXT(ctx
);
171 GET_CONTAINER(con
, containerObj
, "glDetachObjectARB");
175 GET_GENERIC(att
, attachedObj
, "glDetachObjectARB");
179 (**con
).Detach (con
, att
);
180 RELEASE_GENERIC(att
);
182 RELEASE_CONTAINER(con
);
186 GLhandleARB GLAPIENTRY
187 _mesa_CreateShaderObjectARB (GLenum shaderType
)
189 return _mesa_3dlabs_create_shader_object (shaderType
);
193 _mesa_ShaderSourceARB (GLhandleARB shaderObj
, GLsizei count
, const GLcharARB
**string
,
196 GET_CURRENT_CONTEXT(ctx
);
200 GET_SHADER(sha
, shaderObj
, "glShaderSourceARB");
206 * This array holds offsets of where the appropriate string ends, thus the last
207 * element will be set to the total length of the source code.
209 offsets
= (GLint
*) _mesa_malloc (count
* sizeof (GLint
));
213 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
217 for (i
= 0; i
< count
; i
++)
219 if (length
== NULL
|| length
[i
] < 0)
220 offsets
[i
] = _mesa_strlen (string
[i
]);
222 offsets
[i
] = length
[i
];
223 /* accumulate string lengths */
225 offsets
[i
] += offsets
[i
- 1];
228 source
= (GLcharARB
*) _mesa_malloc ((offsets
[count
- 1] + 1) * sizeof (GLcharARB
));
231 _mesa_free ((GLvoid
*) offsets
);
233 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
237 for (i
= 0; i
< count
; i
++)
239 GLint start
= (i
> 0) ? offsets
[i
- 1] : 0;
240 _mesa_memcpy (source
+ start
, string
[i
], (offsets
[i
] - start
) * sizeof (GLcharARB
));
242 source
[offsets
[count
- 1]] = '\0';
244 (**sha
).SetSource (sha
, source
, offsets
, count
);
249 _mesa_CompileShaderARB (GLhandleARB shaderObj
)
251 GET_CURRENT_CONTEXT(ctx
);
252 GET_SHADER(sha
, shaderObj
, "glCompileShaderARB");
256 (**sha
).Compile (sha
);
261 GLhandleARB GLAPIENTRY
262 _mesa_CreateProgramObjectARB (GLvoid
)
264 return _mesa_3dlabs_create_program_object ();
268 _mesa_AttachObjectARB (GLhandleARB containerObj
, GLhandleARB obj
)
270 GET_CURRENT_CONTEXT(ctx
);
271 GET_CONTAINER(con
, containerObj
, "glAttachObjectARB");
275 GET_GENERIC(att
, obj
, "glAttachObjectARB");
279 (**con
).Attach (con
, att
);
280 RELEASE_GENERIC(att
);
282 RELEASE_CONTAINER(con
);
287 _mesa_LinkProgramARB (GLhandleARB programObj
)
289 GET_CURRENT_CONTEXT(ctx
);
290 GET_PROGRAM(pro
, programObj
, "glLinkProgramARB");
294 if (pro
== ctx
->ShaderObjects
.CurrentProgram
)
296 /* TODO re-install executable program */
299 RELEASE_PROGRAM(pro
);
304 _mesa_UseProgramObjectARB (GLhandleARB programObj
)
306 GET_CURRENT_CONTEXT(ctx
);
307 I_PROGRAM program
= NULL
;
309 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
313 GET_PROGRAM(pro
, programObj
, "glUseProgramObjectARB");
318 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
320 RELEASE_PROGRAM(pro
);
321 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUseProgramObjectARB");
328 if (ctx
->ShaderObjects
.CurrentProgram
!= NULL
)
329 RELEASE_PROGRAM(ctx
->ShaderObjects
.CurrentProgram
);
330 ctx
->ShaderObjects
.CurrentProgram
= program
;
334 _mesa_ValidateProgramARB (GLhandleARB programObj
)
336 GET_CURRENT_CONTEXT(ctx
);
337 GET_PROGRAM(pro
, programObj
, "glValidateProgramARB");
341 (**pro
).Validate (pro
);
342 RELEASE_PROGRAM(pro
);
347 _mesa_Uniform1fARB (GLint location
, GLfloat v0
)
349 GET_CURRENT_CONTEXT(ctx
);
350 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform1fARB");
352 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
356 if (!_slang_write_uniform (pro
, location
, 1, &v0
, GL_FLOAT
))
357 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1fARB");
362 _mesa_Uniform2fARB (GLint location
, GLfloat v0
, GLfloat v1
)
364 GET_CURRENT_CONTEXT(ctx
);
365 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform2fARB");
367 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
371 GLfloat v
[2] = { v0
, v1
};
373 if (!_slang_write_uniform (pro
, location
, 1, v
, GL_FLOAT_VEC2
))
374 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2fARB");
379 _mesa_Uniform3fARB (GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
)
381 GET_CURRENT_CONTEXT(ctx
);
382 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform3fARB");
384 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
388 GLfloat v
[3] = { v0
, v1
, v2
};
390 if (!_slang_write_uniform (pro
, location
, 1, v
, GL_FLOAT_VEC3
))
391 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3fARB");
396 _mesa_Uniform4fARB (GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
, GLfloat v3
)
398 GET_CURRENT_CONTEXT(ctx
);
399 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform4fARB");
401 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
405 GLfloat v
[4] = { v0
, v1
, v2
, v3
};
407 if (!_slang_write_uniform (pro
, location
, 1, v
, GL_FLOAT_VEC4
))
408 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4fARB");
413 _mesa_Uniform1iARB (GLint location
, GLint v0
)
415 GET_CURRENT_CONTEXT(ctx
);
416 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform1iARB");
418 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
422 if (!_slang_write_uniform (pro
, location
, 1, &v0
, GL_INT
))
423 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1iARB");
428 _mesa_Uniform2iARB (GLint location
, GLint v0
, GLint v1
)
430 GET_CURRENT_CONTEXT(ctx
);
431 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform2iARB");
433 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
437 GLint v
[2] = { v0
, v1
};
439 if (!_slang_write_uniform (pro
, location
, 1, v
, GL_INT_VEC2
))
440 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2iARB");
445 _mesa_Uniform3iARB (GLint location
, GLint v0
, GLint v1
, GLint v2
)
447 GET_CURRENT_CONTEXT(ctx
);
448 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform3iARB");
450 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
454 GLint v
[3] = { v0
, v1
, v2
};
456 if (!_slang_write_uniform (pro
, location
, 1, v
, GL_INT_VEC3
))
457 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3iARB");
462 _mesa_Uniform4iARB (GLint location
, GLint v0
, GLint v1
, GLint v2
, GLint v3
)
464 GET_CURRENT_CONTEXT(ctx
);
465 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform4iARB");
467 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
471 GLint v
[4] = { v0
, v1
, v2
, v3
};
473 if (!_slang_write_uniform (pro
, location
, 1, v
, GL_INT_VEC4
))
474 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4iARB");
479 _mesa_Uniform1fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
481 GET_CURRENT_CONTEXT(ctx
);
482 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform1fvARB");
484 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
488 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_FLOAT
))
489 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1fvARB");
494 _mesa_Uniform2fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
496 GET_CURRENT_CONTEXT(ctx
);
497 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform2fvARB");
499 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
503 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_FLOAT_VEC2
))
504 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2fvARB");
509 _mesa_Uniform3fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
511 GET_CURRENT_CONTEXT(ctx
);
512 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform3fvARB");
514 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
518 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_FLOAT_VEC3
))
519 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3fvARB");
524 _mesa_Uniform4fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
526 GET_CURRENT_CONTEXT(ctx
);
527 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform4fvARB");
529 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
533 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_FLOAT_VEC4
))
534 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4fvARB");
539 _mesa_Uniform1ivARB (GLint location
, GLsizei count
, const GLint
*value
)
541 GET_CURRENT_CONTEXT(ctx
);
542 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform1ivARB");
544 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
548 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_INT
))
549 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1ivARB");
554 _mesa_Uniform2ivARB (GLint location
, GLsizei count
, const GLint
*value
)
556 GET_CURRENT_CONTEXT(ctx
);
557 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform2ivARB");
559 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
563 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_INT_VEC2
))
564 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2ivARB");
569 _mesa_Uniform3ivARB (GLint location
, GLsizei count
, const GLint
*value
)
571 GET_CURRENT_CONTEXT(ctx
);
572 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform3ivARB");
574 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
578 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_INT_VEC3
))
579 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3ivARB");
584 _mesa_Uniform4ivARB (GLint location
, GLsizei count
, const GLint
*value
)
586 GET_CURRENT_CONTEXT(ctx
);
587 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform4ivARB");
589 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
593 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_INT_VEC4
))
594 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4ivARB");
599 _mesa_UniformMatrix2fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
601 GET_CURRENT_CONTEXT(ctx
);
602 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniformMatrix2fvARB");
604 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
613 trans
= (GLfloat
*) _mesa_malloc (count
* 4 * sizeof (GLfloat
));
616 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glUniformMatrix2fvARB");
619 for (pt
= trans
, pv
= value
; pt
!= trans
+ count
* 4; pt
+= 4, pv
+= 4)
626 if (!_slang_write_uniform (pro
, location
, count
, trans
, GL_FLOAT_MAT2
))
627 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix2fvARB");
632 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_FLOAT_MAT2
))
633 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix2fvARB");
639 _mesa_UniformMatrix3fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
641 GET_CURRENT_CONTEXT(ctx
);
642 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniformMatrix3fvARB");
644 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
653 trans
= (GLfloat
*) _mesa_malloc (count
* 9 * sizeof (GLfloat
));
656 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glUniformMatrix3fvARB");
659 for (pt
= trans
, pv
= value
; pt
!= trans
+ count
* 9; pt
+= 9, pv
+= 9)
671 if (!_slang_write_uniform (pro
, location
, count
, trans
, GL_FLOAT_MAT3
))
672 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix3fvARB");
677 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_FLOAT_MAT3
))
678 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix3fvARB");
684 _mesa_UniformMatrix4fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
686 GET_CURRENT_CONTEXT(ctx
);
687 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniformMatrix4fvARB");
689 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
698 trans
= (GLfloat
*) _mesa_malloc (count
* 16 * sizeof (GLfloat
));
701 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glUniformMatrix4fvARB");
704 for (pt
= trans
, pv
= value
; pt
!= trans
+ count
* 16; pt
+= 16, pv
+= 16)
706 _math_transposef (pt
, pv
);
708 if (!_slang_write_uniform (pro
, location
, count
, trans
, GL_FLOAT_MAT4
))
709 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix4fvARB");
714 if (!_slang_write_uniform (pro
, location
, count
, value
, GL_FLOAT_MAT4
))
715 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix4fvARB");
721 _mesa_get_object_parameter (GLhandleARB obj
, GLenum pname
, GLvoid
*params
, GLboolean
*integral
,
724 GET_CURRENT_CONTEXT(ctx
);
725 GLint
*ipar
= (GLint
*) params
;
727 /* set default values */
728 *integral
= GL_TRUE
; /* indicates param type, TRUE: GLint, FALSE: GLfloat */
729 *size
= 1; /* param array size */
733 case GL_OBJECT_TYPE_ARB
:
734 case GL_OBJECT_DELETE_STATUS_ARB
:
735 case GL_OBJECT_INFO_LOG_LENGTH_ARB
:
737 GET_GENERIC(gen
, obj
, "glGetObjectParameterivARB");
744 case GL_OBJECT_TYPE_ARB
:
745 *ipar
= (**gen
).GetType (gen
);
747 case GL_OBJECT_DELETE_STATUS_ARB
:
748 *ipar
= (**gen
).GetDeleteStatus (gen
);
750 case GL_OBJECT_INFO_LOG_LENGTH_ARB
:
752 const GLcharARB
*info
= (**gen
).GetInfoLog (gen
);
757 *ipar
= _mesa_strlen (info
) + 1;
762 RELEASE_GENERIC(gen
);
765 case GL_OBJECT_SUBTYPE_ARB
:
766 case GL_OBJECT_COMPILE_STATUS_ARB
:
767 case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB
:
769 GET_SHADER(sha
, obj
, "glGetObjectParameterivARB");
776 case GL_OBJECT_SUBTYPE_ARB
:
777 *ipar
= (**sha
).GetSubType (sha
);
779 case GL_OBJECT_COMPILE_STATUS_ARB
:
780 *ipar
= (**sha
).GetCompileStatus (sha
);
782 case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB
:
784 const GLcharARB
*src
= (**sha
).GetSource (sha
);
789 *ipar
= _mesa_strlen (src
) + 1;
797 case GL_OBJECT_LINK_STATUS_ARB
:
798 case GL_OBJECT_VALIDATE_STATUS_ARB
:
799 case GL_OBJECT_ATTACHED_OBJECTS_ARB
:
800 case GL_OBJECT_ACTIVE_UNIFORMS_ARB
:
801 case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB
:
803 GET_PROGRAM(pro
, obj
, "glGetObjectParameterivARB");
810 case GL_OBJECT_LINK_STATUS_ARB
:
811 *ipar
= (**pro
).GetLinkStatus (pro
);
813 case GL_OBJECT_VALIDATE_STATUS_ARB
:
814 *ipar
= (**pro
).GetValidateStatus (pro
);
816 case GL_OBJECT_ATTACHED_OBJECTS_ARB
:
817 *ipar
= (**pro
)._container
.GetAttachedCount ((I_CONTAINER
) pro
);
819 case GL_OBJECT_ACTIVE_UNIFORMS_ARB
:
820 *ipar
= _slang_get_active_uniform_count (pro
);
822 case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB
:
823 *ipar
= _slang_get_active_uniform_max_length (pro
);
827 RELEASE_PROGRAM(pro
);
831 _mesa_error (ctx
, GL_INVALID_ENUM
, "glGetObjectParameterivARB");
839 _mesa_GetObjectParameterfvARB (GLhandleARB obj
, GLenum pname
, GLfloat
*params
)
844 assert (sizeof (GLfloat
) == sizeof (GLint
));
846 if (_mesa_get_object_parameter (obj
, pname
, (GLvoid
*) params
, &integral
, &size
))
851 for (i
= 0; i
< size
; i
++)
852 params
[i
] = (GLfloat
) ((GLint
*) params
)[i
];
857 _mesa_GetObjectParameterivARB (GLhandleARB obj
, GLenum pname
, GLint
*params
)
862 assert (sizeof (GLfloat
) == sizeof (GLint
));
864 if (_mesa_get_object_parameter (obj
, pname
, (GLvoid
*) params
, &integral
, &size
))
869 for (i
= 0; i
< size
; i
++)
870 params
[i
] = (GLint
) ((GLfloat
*) params
)[i
];
875 _mesa_get_string (const GLcharARB
*src
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*str
)
889 len
= _mesa_strlen (src
);
890 if (len
>= maxLength
)
893 _mesa_memcpy (str
, src
, len
* sizeof (GLcharARB
));
900 _mesa_GetInfoLogARB (GLhandleARB obj
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*infoLog
)
902 GET_CURRENT_CONTEXT(ctx
);
903 GET_GENERIC(gen
, obj
, "glGetInfoLogARB");
907 _mesa_get_string ((**gen
).GetInfoLog (gen
), maxLength
, length
, infoLog
);
908 RELEASE_GENERIC(gen
);
913 _mesa_GetAttachedObjectsARB (GLhandleARB containerObj
, GLsizei maxCount
, GLsizei
*count
,
916 GET_CURRENT_CONTEXT(ctx
);
918 GET_CONTAINER(con
, containerObj
, "glGetAttachedObjectsARB");
922 cnt
= (**con
).GetAttachedCount (con
);
928 for (i
= 0; i
< cnt
; i
++)
930 I_GENERIC x
= (**con
).GetAttached (con
, i
);
931 obj
[i
] = (**x
).GetName (x
);
934 RELEASE_CONTAINER(con
);
939 _mesa_GetUniformLocationARB (GLhandleARB programObj
, const GLcharARB
*name
)
941 GET_CURRENT_CONTEXT(ctx
);
943 GET_LINKED_PROGRAM(pro
, programObj
, "glGetUniformLocationARB");
947 if (name
!= NULL
&& (name
[0] != 'g' || name
[1] != 'l' || name
[2] != '_'))
948 loc
= _slang_get_uniform_location (pro
, name
);
949 RELEASE_PROGRAM(pro
);
955 _mesa_GetActiveUniformARB (GLhandleARB programObj
, GLuint index
, GLsizei maxLength
, GLsizei
*length
,
956 GLint
*size
, GLenum
*type
, GLcharARB
*name
)
958 GET_CURRENT_CONTEXT(ctx
);
959 GET_PROGRAM(pro
, programObj
, "glGetActiveUniformARB");
963 if (index
< _slang_get_active_uniform_count (pro
))
964 _slang_get_active_uniform (pro
, index
, maxLength
, length
, size
, type
, name
);
966 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveUniformARB");
967 RELEASE_PROGRAM(pro
);
972 _mesa_GetUniformfvARB (GLhandleARB programObj
, GLint location
, GLfloat
*params
)
974 GET_CURRENT_CONTEXT(ctx
);
975 GET_LINKED_PROGRAM(pro
, programObj
, "glGetUniformfvARB");
980 RELEASE_PROGRAM(pro
);
985 _mesa_GetUniformivARB (GLhandleARB programObj
, GLint location
, GLint
*params
)
987 GET_CURRENT_CONTEXT(ctx
);
988 GET_LINKED_PROGRAM(pro
, programObj
, "glGetUniformivARB");
993 RELEASE_PROGRAM(pro
);
998 _mesa_GetShaderSourceARB (GLhandleARB obj
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*source
)
1000 GET_CURRENT_CONTEXT(ctx
);
1001 GET_SHADER(sha
, obj
, "glGetShaderSourceARB");
1005 _mesa_get_string ((**sha
).GetSource (sha
), maxLength
, length
, source
);
1006 RELEASE_SHADER(sha
);
1010 /* GL_ARB_vertex_shader */
1013 _mesa_BindAttribLocationARB (GLhandleARB programObj
, GLuint index
, const GLcharARB
*name
)
1015 GET_CURRENT_CONTEXT(ctx
);
1016 GET_PROGRAM(pro
, programObj
, "glBindAttribLocationARB");
1020 if (name
!= NULL
&& (name
[0] != 'g' || name
[1] != 'l' || name
[2] != '_'))
1024 RELEASE_PROGRAM(pro
);
1029 _mesa_GetActiveAttribARB (GLhandleARB programObj
, GLuint index
, GLsizei maxLength
, GLsizei
*length
,
1030 GLint
*size
, GLenum
*type
, GLcharARB
*name
)
1032 GET_CURRENT_CONTEXT(ctx
);
1033 GET_PROGRAM(pro
, programObj
, "glGetActiveAttribARB");
1038 RELEASE_PROGRAM(pro
);
1043 _mesa_GetAttribLocationARB (GLhandleARB programObj
, const GLcharARB
*name
)
1045 GET_CURRENT_CONTEXT(ctx
);
1047 GET_PROGRAM(pro
, programObj
, "glGetAttribLocationARB");
1051 if (name
!= NULL
&& (name
[0] != 'g' || name
[1] != 'l' || name
[2] != '_'))
1055 RELEASE_PROGRAM(pro
);
1061 _mesa_init_shaderobjects (GLcontext
*ctx
)
1063 ctx
->ShaderObjects
.CurrentProgram
= NULL
;
1065 _mesa_init_shaderobjects_3dlabs (ctx
);