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
33 #include "shaderobjects.h"
34 #include "shaderobjects_3dlabs.h"
41 _mesa_DeleteObjectARB (GLhandleARB obj
)
43 GET_CURRENT_CONTEXT(ctx
);
44 struct gl2_unknown_intf
**unk
;
45 struct gl2_generic_intf
**gen
;
47 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
48 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, obj
);
49 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
53 _mesa_error (ctx
, GL_INVALID_VALUE
, "glDeleteObjectARB");
57 gen
= (struct gl2_generic_intf
**) (**unk
).QueryInterface (unk
, UIID_GENERIC
);
60 _mesa_error (ctx
, GL_INVALID_VALUE
, "glDeleteObjectARB");
65 (**gen
)._unknown
.Release ((struct gl2_unknown_intf
**) gen
);
68 GLhandleARB GLAPIENTRY
69 _mesa_GetHandleARB (GLenum pname
)
71 GET_CURRENT_CONTEXT(ctx
);
75 case GL_PROGRAM_OBJECT_ARB
:
76 if (ctx
->ShaderObjects
.current_program
!= NULL
)
77 return (**ctx
->ShaderObjects
.current_program
)._container
._generic
.GetName (
78 (struct gl2_generic_intf
**) ctx
->ShaderObjects
.current_program
);
86 _mesa_DetachObjectARB (GLhandleARB containerObj
, GLhandleARB attachedObj
)
88 GET_CURRENT_CONTEXT(ctx
);
89 struct gl2_unknown_intf
**unkc
, **unka
;
90 struct gl2_container_intf
**con
;
91 struct gl2_generic_intf
**att
;
93 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
94 unkc
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, containerObj
);
95 unka
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, attachedObj
);
96 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
98 if (unkc
== NULL
|| unka
== NULL
)
100 _mesa_error (ctx
, GL_INVALID_VALUE
, "glDetachObjectARB");
104 con
= (struct gl2_container_intf
**) (**unkc
).QueryInterface (unkc
, UIID_CONTAINER
);
107 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glDetachObjectARB");
111 att
= (struct gl2_generic_intf
**) (**unka
).QueryInterface (unka
, UIID_GENERIC
);
114 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
115 _mesa_error (ctx
, GL_INVALID_VALUE
, "glDetachObjectARB");
119 if ((**con
).Detach (con
, att
) == GL_FALSE
)
121 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
122 (**att
)._unknown
.Release ((struct gl2_unknown_intf
**) att
);
126 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
127 (**att
)._unknown
.Release ((struct gl2_unknown_intf
**) att
);
130 GLhandleARB GLAPIENTRY
131 _mesa_CreateShaderObjectARB (GLenum shaderType
)
134 return _mesa_3dlabs_create_shader_object (shaderType
);
139 _mesa_ShaderSourceARB (GLhandleARB shaderObj
, GLsizei count
, const GLcharARB
**string
,
142 GET_CURRENT_CONTEXT(ctx
);
143 struct gl2_unknown_intf
**unk
;
144 struct gl2_shader_intf
**sha
;
149 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
150 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, shaderObj
);
151 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
155 _mesa_error (ctx
, GL_INVALID_VALUE
, "glShaderSourceARB");
159 sha
= (struct gl2_shader_intf
**) (**unk
).QueryInterface (unk
, UIID_SHADER
);
162 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glShaderSourceARB");
166 /* this array holds offsets of where the appropriate string ends, thus the last
167 element will be set to the total length of the source code */
168 offsets
= (GLint
*) _mesa_malloc (count
* sizeof (GLint
));
171 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
172 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
176 for (i
= 0; i
< count
; i
++)
178 if (length
== NULL
|| length
[i
] < 0)
179 offsets
[i
] = _mesa_strlen (string
[i
]);
181 offsets
[i
] = length
[i
];
182 /* accumulate string lengths */
184 offsets
[i
] += offsets
[i
- 1];
187 source
= (GLcharARB
*) _mesa_malloc ((offsets
[count
- 1] + 1) * sizeof (GLcharARB
));
190 _mesa_free ((void *) offsets
);
191 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
192 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
196 for (i
= 0; i
< count
; i
++)
198 GLint start
= (i
> 0) ? offsets
[i
- 1] : 0;
199 _mesa_memcpy (source
+ start
, string
[i
], (offsets
[i
] - start
) * sizeof (GLcharARB
));
201 source
[offsets
[count
- 1]] = '\0';
203 (**sha
).SetSource (sha
, source
, offsets
, count
);
204 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
208 _mesa_CompileShaderARB (GLhandleARB shaderObj
)
210 GET_CURRENT_CONTEXT(ctx
);
211 struct gl2_unknown_intf
**unk
;
212 struct gl2_shader_intf
**sha
;
214 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
215 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, shaderObj
);
216 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
220 _mesa_error (ctx
, GL_INVALID_VALUE
, "glCompileShaderARB");
224 sha
= (struct gl2_shader_intf
**) (**unk
).QueryInterface (unk
, UIID_SHADER
);
227 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glCompileShaderARB");
231 (**sha
).Compile (sha
);
232 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
235 GLhandleARB GLAPIENTRY
236 _mesa_CreateProgramObjectARB (void)
239 return _mesa_3dlabs_create_program_object ();
244 _mesa_AttachObjectARB (GLhandleARB containerObj
, GLhandleARB obj
)
246 GET_CURRENT_CONTEXT(ctx
);
247 struct gl2_unknown_intf
**unkc
, **unka
;
248 struct gl2_container_intf
**con
;
249 struct gl2_generic_intf
**att
;
251 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
252 unkc
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, containerObj
);
253 unka
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, obj
);
254 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
256 if (unkc
== NULL
|| unka
== NULL
)
258 _mesa_error (ctx
, GL_INVALID_VALUE
, "glAttachObjectARB");
262 con
= (struct gl2_container_intf
**) (**unkc
).QueryInterface (unkc
, UIID_CONTAINER
);
265 _mesa_error (ctx
, GL_INVALID_VALUE
, "glAttachObjectARB");
269 att
= (struct gl2_generic_intf
**) (**unka
).QueryInterface (unka
, UIID_GENERIC
);
272 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
273 _mesa_error (ctx
, GL_INVALID_VALUE
, "glAttachObjectARB");
277 if (!(**con
).Attach (con
, att
))
279 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
280 (**att
)._unknown
.Release ((struct gl2_unknown_intf
**) att
);
284 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
285 (**att
)._unknown
.Release ((struct gl2_unknown_intf
**) att
);
289 _mesa_LinkProgramARB (GLhandleARB programObj
)
291 GET_CURRENT_CONTEXT(ctx
);
292 struct gl2_unknown_intf
**unk
;
293 struct gl2_program_intf
**pro
;
295 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
296 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
297 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
301 _mesa_error (ctx
, GL_INVALID_VALUE
, "glLinkProgramARB");
305 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
308 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glLinkProgramARB");
312 if (pro
== ctx
->ShaderObjects
.current_program
)
314 /* TODO re-install executable program */
318 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
322 _mesa_UseProgramObjectARB (GLhandleARB programObj
)
324 GET_CURRENT_CONTEXT(ctx
);
325 struct gl2_program_intf
**pro
;
333 struct gl2_unknown_intf
**unk
;
335 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
336 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
337 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
341 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUseProgramObjectARB");
345 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
348 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUseProgramObjectARB");
352 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
354 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
355 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUseProgramObjectARB");
360 if (ctx
->ShaderObjects
.current_program
!= NULL
)
362 (**ctx
->ShaderObjects
.current_program
)._container
._generic
._unknown
.Release (
363 (struct gl2_unknown_intf
**) ctx
->ShaderObjects
.current_program
);
366 ctx
->ShaderObjects
.current_program
= pro
;
370 _mesa_ValidateProgramARB (GLhandleARB programObj
)
372 GET_CURRENT_CONTEXT(ctx
);
373 struct gl2_unknown_intf
**unk
;
374 struct gl2_program_intf
**pro
;
376 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
377 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
378 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
382 _mesa_error (ctx
, GL_INVALID_VALUE
, "glValidateProgramARB");
386 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
389 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glValidateProgramARB");
393 (**pro
).Validate (pro
);
394 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
400 The error INVALID_OPERATION is generated by the Uniform*ARB if the
401 number of values loaded results in exceeding the declared extent of a
404 The error INVALID_OPERATION is generated by the Uniform*ARB commands if
405 the size does not match the size of the uniform declared in the shader.
407 The error INVALID_OPERATION is generated by the Uniform*ARB commands if
408 the type does not match the type of the uniform declared in the shader,
409 if the uniform is not of type Boolean.
411 The error INVALID_OPERATION is generated by the Uniform*ARB commands if
412 <location> does not exist for the program object currently in use.
414 The error INVALID_OPERATION is generated if a uniform command other than
415 Uniform1i{v}ARB is used to load a sampler value.
421 _mesa_Uniform1fARB (GLint location
, GLfloat v0
)
423 GET_CURRENT_CONTEXT(ctx
);
425 if (ctx
->ShaderObjects
.current_program
== NULL
)
427 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1fARB");
433 _mesa_Uniform2fARB (GLint location
, GLfloat v0
, GLfloat v1
)
435 GET_CURRENT_CONTEXT(ctx
);
437 if (ctx
->ShaderObjects
.current_program
== NULL
)
439 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2fARB");
445 _mesa_Uniform3fARB (GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
)
447 GET_CURRENT_CONTEXT(ctx
);
449 if (ctx
->ShaderObjects
.current_program
== NULL
)
451 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3fARB");
457 _mesa_Uniform4fARB (GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
, GLfloat v3
)
459 GET_CURRENT_CONTEXT(ctx
);
461 if (ctx
->ShaderObjects
.current_program
== NULL
)
463 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4fARB");
469 _mesa_Uniform1iARB (GLint location
, GLint v0
)
471 GET_CURRENT_CONTEXT(ctx
);
473 if (ctx
->ShaderObjects
.current_program
== NULL
)
475 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1iARB");
481 _mesa_Uniform2iARB (GLint location
, GLint v0
, GLint v1
)
483 GET_CURRENT_CONTEXT(ctx
);
485 if (ctx
->ShaderObjects
.current_program
== NULL
)
487 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2iARB");
493 _mesa_Uniform3iARB (GLint location
, GLint v0
, GLint v1
, GLint v2
)
495 GET_CURRENT_CONTEXT(ctx
);
497 if (ctx
->ShaderObjects
.current_program
== NULL
)
499 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3iARB");
505 _mesa_Uniform4iARB (GLint location
, GLint v0
, GLint v1
, GLint v2
, GLint v3
)
507 GET_CURRENT_CONTEXT(ctx
);
509 if (ctx
->ShaderObjects
.current_program
== NULL
)
511 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4iARB");
517 _mesa_Uniform1fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
519 GET_CURRENT_CONTEXT(ctx
);
521 if (ctx
->ShaderObjects
.current_program
== NULL
)
523 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1fvARB");
529 _mesa_Uniform2fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
531 GET_CURRENT_CONTEXT(ctx
);
533 if (ctx
->ShaderObjects
.current_program
== NULL
)
535 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2fvARB");
541 _mesa_Uniform3fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
543 GET_CURRENT_CONTEXT(ctx
);
545 if (ctx
->ShaderObjects
.current_program
== NULL
)
547 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3fvARB");
553 _mesa_Uniform4fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
555 GET_CURRENT_CONTEXT(ctx
);
557 if (ctx
->ShaderObjects
.current_program
== NULL
)
559 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4fvARB");
565 _mesa_Uniform1ivARB (GLint location
, GLsizei count
, const GLint
*value
)
567 GET_CURRENT_CONTEXT(ctx
);
569 if (ctx
->ShaderObjects
.current_program
== NULL
)
571 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1ivARB");
577 _mesa_Uniform2ivARB (GLint location
, GLsizei count
, const GLint
*value
)
579 GET_CURRENT_CONTEXT(ctx
);
581 if (ctx
->ShaderObjects
.current_program
== NULL
)
583 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2ivARB");
589 _mesa_Uniform3ivARB (GLint location
, GLsizei count
, const GLint
*value
)
591 GET_CURRENT_CONTEXT(ctx
);
593 if (ctx
->ShaderObjects
.current_program
== NULL
)
595 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3ivARB");
601 _mesa_Uniform4ivARB (GLint location
, GLsizei count
, const GLint
*value
)
603 GET_CURRENT_CONTEXT(ctx
);
605 if (ctx
->ShaderObjects
.current_program
== NULL
)
607 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4ivARB");
613 _mesa_UniformMatrix2fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
615 GET_CURRENT_CONTEXT(ctx
);
617 if (ctx
->ShaderObjects
.current_program
== NULL
)
619 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix2fvARB");
625 _mesa_UniformMatrix3fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
627 GET_CURRENT_CONTEXT(ctx
);
629 if (ctx
->ShaderObjects
.current_program
== NULL
)
631 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix3fvARB");
637 _mesa_UniformMatrix4fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
639 GET_CURRENT_CONTEXT(ctx
);
641 if (ctx
->ShaderObjects
.current_program
== NULL
)
643 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix4fvARB");
649 _mesa_get_object_parameter (GLhandleARB obj
, GLenum pname
, GLvoid
*params
, GLboolean
*integral
,
652 GET_CURRENT_CONTEXT(ctx
);
653 struct gl2_unknown_intf
**unk
;
654 struct gl2_generic_intf
**gen
;
655 struct gl2_shader_intf
**sha
;
656 struct gl2_program_intf
**pro
;
657 GLint
*ipar
= (GLint
*) params
;
658 /*GLfloat *fpar = (GLfloat *) params;*/
659 GLboolean success
= GL_TRUE
;
661 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
662 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, obj
);
663 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
667 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetObjectParameterivARB");
671 gen
= (struct gl2_generic_intf
**) (**unk
).QueryInterface (unk
, UIID_GENERIC
);
674 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
678 sha
= (struct gl2_shader_intf
**) (**unk
).QueryInterface (unk
, UIID_SHADER
);
679 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
681 /* set default values */
682 *integral
= GL_TRUE
; /* indicates param type, TRUE: GLint, FALSE: GLfloat */
683 *size
= 1; /* param array size */
687 case GL_OBJECT_TYPE_ARB
:
688 *ipar
= (**gen
).GetType (gen
);
690 case GL_OBJECT_SUBTYPE_ARB
:
692 *ipar
= (**sha
).GetSubType (sha
);
694 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
698 case GL_OBJECT_DELETE_STATUS_ARB
:
699 *ipar
= (**gen
).GetDeleteStatus (gen
);
701 case GL_OBJECT_COMPILE_STATUS_ARB
:
703 *ipar
= (**sha
).GetCompileStatus (sha
);
705 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
709 case GL_OBJECT_LINK_STATUS_ARB
:
711 *ipar
= (**pro
).GetLinkStatus (pro
);
713 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
717 case GL_OBJECT_VALIDATE_STATUS_ARB
:
719 *ipar
= (**pro
).GetValidateStatus (pro
);
721 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
725 case GL_OBJECT_INFO_LOG_LENGTH_ARB
:
727 const GLcharARB
*info
= (**gen
).GetInfoLog (gen
);
731 *ipar
= _mesa_strlen (info
) + 1;
734 case GL_OBJECT_ATTACHED_OBJECTS_ARB
:
736 *ipar
= (**pro
)._container
.GetAttachedCount ((struct gl2_container_intf
**) pro
);
738 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
742 case GL_OBJECT_ACTIVE_UNIFORMS_ARB
:
744 *ipar
= 0; /* TODO */
746 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
750 case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB
:
752 *ipar
= 0; /* TODO */
754 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
758 case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB
:
760 const GLcharARB
*src
= (**sha
).GetSource (sha
);
764 *ipar
= _mesa_strlen (src
) + 1;
766 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
771 _mesa_error (ctx
, GL_INVALID_ENUM
, "glGetObjectParameterivARB");
776 (**gen
)._unknown
.Release ((struct gl2_unknown_intf
**) gen
);
778 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
780 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
786 _mesa_GetObjectParameterfvARB (GLhandleARB obj
, GLenum pname
, GLfloat
*params
)
791 assert (sizeof (GLfloat
) == sizeof (GLint
));
793 if (_mesa_get_object_parameter (obj
, pname
, (GLvoid
*) params
, &integral
, &size
) != GL_FALSE
)
794 if (integral
!= GL_FALSE
)
795 for (i
= 0; i
< size
; i
++)
796 params
[i
] = (GLfloat
) ((GLint
*) params
)[i
];
800 _mesa_GetObjectParameterivARB (GLhandleARB obj
, GLenum pname
, GLint
*params
)
805 assert (sizeof (GLfloat
) == sizeof (GLint
));
807 if (_mesa_get_object_parameter (obj
, pname
, (GLvoid
*) params
, &integral
, &size
) != GL_FALSE
)
808 if (integral
== GL_FALSE
)
809 for (i
= 0; i
< size
; i
++)
810 params
[i
] = (GLint
) ((GLfloat
*) params
)[i
];
814 _mesa_get_string (const GLcharARB
*src
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*str
)
821 len
= _mesa_strlen (src
);
825 /* allocate space for null termination */
830 _mesa_memcpy (str
, src
, len
* sizeof (GLcharARB
));
839 _mesa_GetInfoLogARB (GLhandleARB obj
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*infoLog
)
841 GET_CURRENT_CONTEXT(ctx
);
842 struct gl2_unknown_intf
**unk
;
843 struct gl2_generic_intf
**gen
;
845 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
846 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, obj
);
847 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
851 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetInfoLogARB");
855 gen
= (struct gl2_generic_intf
**) (**unk
).QueryInterface (unk
, UIID_GENERIC
);
858 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetInfoLogARB");
862 _mesa_get_string ((**gen
).GetInfoLog (gen
), maxLength
, length
, infoLog
);
864 (**gen
)._unknown
.Release ((struct gl2_unknown_intf
**) gen
);
868 _mesa_GetAttachedObjectsARB (GLhandleARB containerObj
, GLsizei maxCount
, GLsizei
*count
, GLhandleARB
*obj
)
870 GET_CURRENT_CONTEXT(ctx
);
871 struct gl2_unknown_intf
**unk
;
872 struct gl2_container_intf
**con
;
875 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
876 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, containerObj
);
877 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
881 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetAttachedObjectsARB");
885 con
= (struct gl2_container_intf
**) (**unk
).QueryInterface (unk
, UIID_CONTAINER
);
888 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetAttachedObjectsARB");
892 cnt
= (**con
).GetAttachedCount (con
);
896 for (i
= 0; i
< cnt
; i
++)
898 struct gl2_generic_intf
**x
= (**con
).GetAttached (con
, i
);
899 obj
[i
] = (**x
).GetName (x
);
900 (**x
)._unknown
.Release ((struct gl2_unknown_intf
**) x
);
903 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
910 _mesa_GetUniformLocationARB (GLhandleARB programObj
, const GLcharARB
*name
)
912 GET_CURRENT_CONTEXT(ctx
);
913 struct gl2_unknown_intf
**unk
;
914 struct gl2_program_intf
**pro
;
917 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
918 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
919 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
923 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetUniformLocationARB");
927 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
930 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformLocationARB");
934 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
936 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformLocationARB");
937 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
943 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
948 _mesa_GetActiveUniformARB (GLhandleARB programObj
, GLuint index
, GLsizei maxLength
, GLsizei
*length
, GLint
*size
, GLenum
*type
, GLcharARB
*name
)
950 GET_CURRENT_CONTEXT(ctx
);
951 struct gl2_unknown_intf
**unk
;
952 struct gl2_program_intf
**pro
;
954 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
955 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
956 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
960 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveUniformARB");
964 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
967 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetActiveUniformARB");
971 /* if (index >= val (OBJECT_ACTIVE_ATTRIBUTES_ARB))
973 _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveUniformARB");
974 (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
980 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
984 _mesa_GetUniformfvARB (GLhandleARB programObj
, GLint location
, GLfloat
*params
)
986 GET_CURRENT_CONTEXT(ctx
);
987 struct gl2_unknown_intf
**unk
;
988 struct gl2_program_intf
**pro
;
990 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
991 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
992 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
996 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetUniformfvARB");
1000 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
1003 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformfvARB");
1007 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
1009 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformfvARB");
1010 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1014 /* TODO validate location (OPERATION) */
1018 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1022 _mesa_GetUniformivARB (GLhandleARB programObj
, GLint location
, GLint
*params
)
1024 GET_CURRENT_CONTEXT(ctx
);
1025 struct gl2_unknown_intf
**unk
;
1026 struct gl2_program_intf
**pro
;
1028 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1029 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
1030 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1034 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetUniformivARB");
1038 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
1041 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformivARB");
1045 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
1047 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformivARB");
1048 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1052 /* TODO validate location (GL_INVALID_OPERATION) */
1056 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1060 _mesa_GetShaderSourceARB (GLhandleARB obj
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*source
)
1062 GET_CURRENT_CONTEXT(ctx
);
1063 struct gl2_unknown_intf
**unk
;
1064 struct gl2_shader_intf
**sha
;
1066 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1067 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, obj
);
1068 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1072 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetShaderSourceARB");
1076 sha
= (struct gl2_shader_intf
**) (**unk
).QueryInterface (unk
, UIID_SHADER
);
1079 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetShaderSourceARB");
1083 _mesa_get_string ((**sha
).GetSource (sha
), maxLength
, length
, source
);
1085 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
1088 /* GL_ARB_vertex_shader */
1091 _mesa_BindAttribLocationARB (GLhandleARB programObj
, GLuint index
, const GLcharARB
*name
)
1093 GET_CURRENT_CONTEXT(ctx
);
1094 struct gl2_unknown_intf
**unk
;
1095 struct gl2_program_intf
**pro
;
1097 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1098 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
1099 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1103 _mesa_error (ctx
, GL_INVALID_VALUE
, "glBindAttribLocationARB");
1107 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
1110 _mesa_error (ctx
, GL_INVALID_VALUE
, "glBindAttribLocationARB");
1116 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1120 _mesa_GetActiveAttribARB (GLhandleARB programObj
, GLuint index
, GLsizei maxLength
, GLsizei
*length
, GLint
*size
, GLenum
*type
, GLcharARB
*name
)
1122 GET_CURRENT_CONTEXT(ctx
);
1123 struct gl2_unknown_intf
**unk
;
1124 struct gl2_program_intf
**pro
;
1126 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1127 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
1128 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1132 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveAttribARB");
1136 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
1139 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveAttribARB");
1145 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1149 _mesa_GetAttribLocationARB (GLhandleARB programObj
, const GLcharARB
*name
)
1151 GET_CURRENT_CONTEXT(ctx
);
1152 struct gl2_unknown_intf
**unk
;
1153 struct gl2_program_intf
**pro
;
1156 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1157 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
1158 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1162 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetAttribLocationARB");
1166 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
1169 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetAttribLocationARB");
1175 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1180 _mesa_init_shaderobjects (GLcontext
*ctx
)
1182 ctx
->ShaderObjects
.current_program
= NULL
;
1184 #if 0 /* disable for now */
1185 _mesa_init_shaderobjects_3dlabs (ctx
);