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
)
133 return _mesa_3dlabs_create_shader_object (shaderType
);
137 _mesa_ShaderSourceARB (GLhandleARB shaderObj
, GLsizei count
, const GLcharARB
**string
,
140 GET_CURRENT_CONTEXT(ctx
);
141 struct gl2_unknown_intf
**unk
;
142 struct gl2_shader_intf
**sha
;
147 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
148 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, shaderObj
);
149 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
153 _mesa_error (ctx
, GL_INVALID_VALUE
, "glShaderSourceARB");
157 sha
= (struct gl2_shader_intf
**) (**unk
).QueryInterface (unk
, UIID_SHADER
);
160 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glShaderSourceARB");
164 /* this array holds offsets of where the appropriate string ends, thus the last
165 element will be set to the total length of the source code */
166 offsets
= (GLint
*) _mesa_malloc (count
* sizeof (GLint
));
169 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
170 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
174 for (i
= 0; i
< count
; i
++)
176 if (length
== NULL
|| length
[i
] < 0)
177 offsets
[i
] = _mesa_strlen (string
[i
]);
179 offsets
[i
] = length
[i
];
180 /* accumulate string lengths */
182 offsets
[i
] += offsets
[i
- 1];
185 source
= (GLcharARB
*) _mesa_malloc ((offsets
[count
- 1] + 1) * sizeof (GLcharARB
));
188 _mesa_free ((void *) offsets
);
189 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
190 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
194 for (i
= 0; i
< count
; i
++)
196 GLint start
= (i
> 0) ? offsets
[i
- 1] : 0;
197 _mesa_memcpy (source
+ start
, string
[i
], (offsets
[i
] - start
) * sizeof (GLcharARB
));
199 source
[offsets
[count
- 1]] = '\0';
201 (**sha
).SetSource (sha
, source
, offsets
, count
);
202 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
206 _mesa_CompileShaderARB (GLhandleARB shaderObj
)
208 GET_CURRENT_CONTEXT(ctx
);
209 struct gl2_unknown_intf
**unk
;
210 struct gl2_shader_intf
**sha
;
212 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
213 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, shaderObj
);
214 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
218 _mesa_error (ctx
, GL_INVALID_VALUE
, "glCompileShaderARB");
222 sha
= (struct gl2_shader_intf
**) (**unk
).QueryInterface (unk
, UIID_SHADER
);
225 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glCompileShaderARB");
229 (**sha
).Compile (sha
);
230 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
233 GLhandleARB GLAPIENTRY
234 _mesa_CreateProgramObjectARB (void)
236 return _mesa_3dlabs_create_program_object ();
240 _mesa_AttachObjectARB (GLhandleARB containerObj
, GLhandleARB obj
)
242 GET_CURRENT_CONTEXT(ctx
);
243 struct gl2_unknown_intf
**unkc
, **unka
;
244 struct gl2_container_intf
**con
;
245 struct gl2_generic_intf
**att
;
247 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
248 unkc
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, containerObj
);
249 unka
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, obj
);
250 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
252 if (unkc
== NULL
|| unka
== NULL
)
254 _mesa_error (ctx
, GL_INVALID_VALUE
, "glAttachObjectARB");
258 con
= (struct gl2_container_intf
**) (**unkc
).QueryInterface (unkc
, UIID_CONTAINER
);
261 _mesa_error (ctx
, GL_INVALID_VALUE
, "glAttachObjectARB");
265 att
= (struct gl2_generic_intf
**) (**unka
).QueryInterface (unka
, UIID_GENERIC
);
268 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
269 _mesa_error (ctx
, GL_INVALID_VALUE
, "glAttachObjectARB");
273 if (!(**con
).Attach (con
, att
))
275 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
276 (**att
)._unknown
.Release ((struct gl2_unknown_intf
**) att
);
280 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
281 (**att
)._unknown
.Release ((struct gl2_unknown_intf
**) att
);
285 _mesa_LinkProgramARB (GLhandleARB programObj
)
287 GET_CURRENT_CONTEXT(ctx
);
288 struct gl2_unknown_intf
**unk
;
289 struct gl2_program_intf
**pro
;
291 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
292 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
293 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
297 _mesa_error (ctx
, GL_INVALID_VALUE
, "glLinkProgramARB");
301 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
304 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glLinkProgramARB");
308 if (pro
== ctx
->ShaderObjects
.current_program
)
310 /* TODO re-install executable program */
314 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
318 _mesa_UseProgramObjectARB (GLhandleARB programObj
)
320 GET_CURRENT_CONTEXT(ctx
);
321 struct gl2_program_intf
**pro
;
329 struct gl2_unknown_intf
**unk
;
331 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
332 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
333 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
337 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUseProgramObjectARB");
341 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
344 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUseProgramObjectARB");
348 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
350 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
351 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUseProgramObjectARB");
356 if (ctx
->ShaderObjects
.current_program
!= NULL
)
358 (**ctx
->ShaderObjects
.current_program
)._container
._generic
._unknown
.Release (
359 (struct gl2_unknown_intf
**) ctx
->ShaderObjects
.current_program
);
362 ctx
->ShaderObjects
.current_program
= pro
;
366 _mesa_ValidateProgramARB (GLhandleARB programObj
)
368 GET_CURRENT_CONTEXT(ctx
);
369 struct gl2_unknown_intf
**unk
;
370 struct gl2_program_intf
**pro
;
372 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
373 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
374 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
378 _mesa_error (ctx
, GL_INVALID_VALUE
, "glValidateProgramARB");
382 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
385 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glValidateProgramARB");
389 (**pro
).Validate (pro
);
390 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
396 The error INVALID_OPERATION is generated by the Uniform*ARB if the
397 number of values loaded results in exceeding the declared extent of a
400 The error INVALID_OPERATION is generated by the Uniform*ARB commands if
401 the size does not match the size of the uniform declared in the shader.
403 The error INVALID_OPERATION is generated by the Uniform*ARB commands if
404 the type does not match the type of the uniform declared in the shader,
405 if the uniform is not of type Boolean.
407 The error INVALID_OPERATION is generated by the Uniform*ARB commands if
408 <location> does not exist for the program object currently in use.
410 The error INVALID_OPERATION is generated if a uniform command other than
411 Uniform1i{v}ARB is used to load a sampler value.
417 _mesa_Uniform1fARB (GLint location
, GLfloat v0
)
419 GET_CURRENT_CONTEXT(ctx
);
421 if (ctx
->ShaderObjects
.current_program
== NULL
)
423 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1fARB");
429 _mesa_Uniform2fARB (GLint location
, GLfloat v0
, GLfloat v1
)
431 GET_CURRENT_CONTEXT(ctx
);
433 if (ctx
->ShaderObjects
.current_program
== NULL
)
435 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2fARB");
441 _mesa_Uniform3fARB (GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
)
443 GET_CURRENT_CONTEXT(ctx
);
445 if (ctx
->ShaderObjects
.current_program
== NULL
)
447 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3fARB");
453 _mesa_Uniform4fARB (GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
, GLfloat v3
)
455 GET_CURRENT_CONTEXT(ctx
);
457 if (ctx
->ShaderObjects
.current_program
== NULL
)
459 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4fARB");
465 _mesa_Uniform1iARB (GLint location
, GLint v0
)
467 GET_CURRENT_CONTEXT(ctx
);
469 if (ctx
->ShaderObjects
.current_program
== NULL
)
471 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1iARB");
477 _mesa_Uniform2iARB (GLint location
, GLint v0
, GLint v1
)
479 GET_CURRENT_CONTEXT(ctx
);
481 if (ctx
->ShaderObjects
.current_program
== NULL
)
483 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2iARB");
489 _mesa_Uniform3iARB (GLint location
, GLint v0
, GLint v1
, GLint v2
)
491 GET_CURRENT_CONTEXT(ctx
);
493 if (ctx
->ShaderObjects
.current_program
== NULL
)
495 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3iARB");
501 _mesa_Uniform4iARB (GLint location
, GLint v0
, GLint v1
, GLint v2
, GLint v3
)
503 GET_CURRENT_CONTEXT(ctx
);
505 if (ctx
->ShaderObjects
.current_program
== NULL
)
507 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4iARB");
513 _mesa_Uniform1fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
515 GET_CURRENT_CONTEXT(ctx
);
517 if (ctx
->ShaderObjects
.current_program
== NULL
)
519 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1fvARB");
525 _mesa_Uniform2fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
527 GET_CURRENT_CONTEXT(ctx
);
529 if (ctx
->ShaderObjects
.current_program
== NULL
)
531 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2fvARB");
537 _mesa_Uniform3fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
539 GET_CURRENT_CONTEXT(ctx
);
541 if (ctx
->ShaderObjects
.current_program
== NULL
)
543 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3fvARB");
549 _mesa_Uniform4fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
551 GET_CURRENT_CONTEXT(ctx
);
553 if (ctx
->ShaderObjects
.current_program
== NULL
)
555 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4fvARB");
561 _mesa_Uniform1ivARB (GLint location
, GLsizei count
, const GLint
*value
)
563 GET_CURRENT_CONTEXT(ctx
);
565 if (ctx
->ShaderObjects
.current_program
== NULL
)
567 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1ivARB");
573 _mesa_Uniform2ivARB (GLint location
, GLsizei count
, const GLint
*value
)
575 GET_CURRENT_CONTEXT(ctx
);
577 if (ctx
->ShaderObjects
.current_program
== NULL
)
579 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2ivARB");
585 _mesa_Uniform3ivARB (GLint location
, GLsizei count
, const GLint
*value
)
587 GET_CURRENT_CONTEXT(ctx
);
589 if (ctx
->ShaderObjects
.current_program
== NULL
)
591 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3ivARB");
597 _mesa_Uniform4ivARB (GLint location
, GLsizei count
, const GLint
*value
)
599 GET_CURRENT_CONTEXT(ctx
);
601 if (ctx
->ShaderObjects
.current_program
== NULL
)
603 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4ivARB");
609 _mesa_UniformMatrix2fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
611 GET_CURRENT_CONTEXT(ctx
);
613 if (ctx
->ShaderObjects
.current_program
== NULL
)
615 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix2fvARB");
621 _mesa_UniformMatrix3fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
623 GET_CURRENT_CONTEXT(ctx
);
625 if (ctx
->ShaderObjects
.current_program
== NULL
)
627 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix3fvARB");
633 _mesa_UniformMatrix4fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
635 GET_CURRENT_CONTEXT(ctx
);
637 if (ctx
->ShaderObjects
.current_program
== NULL
)
639 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix4fvARB");
645 _mesa_get_object_parameter (GLhandleARB obj
, GLenum pname
, GLvoid
*params
, GLboolean
*integral
,
648 GET_CURRENT_CONTEXT(ctx
);
649 struct gl2_unknown_intf
**unk
;
650 struct gl2_generic_intf
**gen
;
651 struct gl2_shader_intf
**sha
;
652 struct gl2_program_intf
**pro
;
653 GLint
*ipar
= (GLint
*) params
;
654 /*GLfloat *fpar = (GLfloat *) params;*/
655 GLboolean success
= GL_TRUE
;
657 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
658 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, obj
);
659 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
663 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetObjectParameterivARB");
667 gen
= (struct gl2_generic_intf
**) (**unk
).QueryInterface (unk
, UIID_GENERIC
);
670 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
674 sha
= (struct gl2_shader_intf
**) (**unk
).QueryInterface (unk
, UIID_SHADER
);
675 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
677 /* set default values */
678 *integral
= GL_TRUE
; /* indicates param type, TRUE: GLint, FALSE: GLfloat */
679 *size
= 1; /* param array size */
683 case GL_OBJECT_TYPE_ARB
:
684 *ipar
= (**gen
).GetType (gen
);
686 case GL_OBJECT_SUBTYPE_ARB
:
688 *ipar
= (**sha
).GetSubType (sha
);
690 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
694 case GL_OBJECT_DELETE_STATUS_ARB
:
695 *ipar
= (**gen
).GetDeleteStatus (gen
);
697 case GL_OBJECT_COMPILE_STATUS_ARB
:
699 *ipar
= (**sha
).GetCompileStatus (sha
);
701 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
705 case GL_OBJECT_LINK_STATUS_ARB
:
707 *ipar
= (**pro
).GetLinkStatus (pro
);
709 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
713 case GL_OBJECT_VALIDATE_STATUS_ARB
:
715 *ipar
= (**pro
).GetValidateStatus (pro
);
717 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
721 case GL_OBJECT_INFO_LOG_LENGTH_ARB
:
723 const GLcharARB
*info
= (**gen
).GetInfoLog (gen
);
727 *ipar
= _mesa_strlen (info
) + 1;
730 case GL_OBJECT_ATTACHED_OBJECTS_ARB
:
732 *ipar
= (**pro
)._container
.GetAttachedCount ((struct gl2_container_intf
**) pro
);
734 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
738 case GL_OBJECT_ACTIVE_UNIFORMS_ARB
:
740 *ipar
= 0; /* TODO */
742 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
746 case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB
:
748 *ipar
= 0; /* TODO */
750 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
754 case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB
:
756 const GLcharARB
*src
= (**sha
).GetSource (sha
);
760 *ipar
= _mesa_strlen (src
) + 1;
762 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetObjectParameterivARB");
767 _mesa_error (ctx
, GL_INVALID_ENUM
, "glGetObjectParameterivARB");
772 (**gen
)._unknown
.Release ((struct gl2_unknown_intf
**) gen
);
774 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
776 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
782 _mesa_GetObjectParameterfvARB (GLhandleARB obj
, GLenum pname
, GLfloat
*params
)
787 assert (sizeof (GLfloat
) == sizeof (GLint
));
789 if (_mesa_get_object_parameter (obj
, pname
, (GLvoid
*) params
, &integral
, &size
) != GL_FALSE
)
790 if (integral
!= GL_FALSE
)
791 for (i
= 0; i
< size
; i
++)
792 params
[i
] = (GLfloat
) ((GLint
*) params
)[i
];
796 _mesa_GetObjectParameterivARB (GLhandleARB obj
, GLenum pname
, GLint
*params
)
801 assert (sizeof (GLfloat
) == sizeof (GLint
));
803 if (_mesa_get_object_parameter (obj
, pname
, (GLvoid
*) params
, &integral
, &size
) != GL_FALSE
)
804 if (integral
== GL_FALSE
)
805 for (i
= 0; i
< size
; i
++)
806 params
[i
] = (GLint
) ((GLfloat
*) params
)[i
];
810 _mesa_get_string (const GLcharARB
*src
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*str
)
817 len
= _mesa_strlen (src
);
821 /* allocate space for null termination */
826 _mesa_memcpy (str
, src
, len
* sizeof (GLcharARB
));
835 _mesa_GetInfoLogARB (GLhandleARB obj
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*infoLog
)
837 GET_CURRENT_CONTEXT(ctx
);
838 struct gl2_unknown_intf
**unk
;
839 struct gl2_generic_intf
**gen
;
841 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
842 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, obj
);
843 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
847 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetInfoLogARB");
851 gen
= (struct gl2_generic_intf
**) (**unk
).QueryInterface (unk
, UIID_GENERIC
);
854 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetInfoLogARB");
858 _mesa_get_string ((**gen
).GetInfoLog (gen
), maxLength
, length
, infoLog
);
860 (**gen
)._unknown
.Release ((struct gl2_unknown_intf
**) gen
);
864 _mesa_GetAttachedObjectsARB (GLhandleARB containerObj
, GLsizei maxCount
, GLsizei
*count
, GLhandleARB
*obj
)
866 GET_CURRENT_CONTEXT(ctx
);
867 struct gl2_unknown_intf
**unk
;
868 struct gl2_container_intf
**con
;
871 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
872 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, containerObj
);
873 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
877 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetAttachedObjectsARB");
881 con
= (struct gl2_container_intf
**) (**unk
).QueryInterface (unk
, UIID_CONTAINER
);
884 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetAttachedObjectsARB");
888 cnt
= (**con
).GetAttachedCount (con
);
892 for (i
= 0; i
< cnt
; i
++)
894 struct gl2_generic_intf
**x
= (**con
).GetAttached (con
, i
);
895 obj
[i
] = (**x
).GetName (x
);
896 (**x
)._unknown
.Release ((struct gl2_unknown_intf
**) x
);
899 (**con
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) con
);
906 _mesa_GetUniformLocationARB (GLhandleARB programObj
, const GLcharARB
*name
)
908 GET_CURRENT_CONTEXT(ctx
);
909 struct gl2_unknown_intf
**unk
;
910 struct gl2_program_intf
**pro
;
913 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
914 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
915 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
919 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetUniformLocationARB");
923 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
926 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformLocationARB");
930 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
932 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformLocationARB");
933 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
939 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
944 _mesa_GetActiveUniformARB (GLhandleARB programObj
, GLuint index
, GLsizei maxLength
, GLsizei
*length
, GLint
*size
, GLenum
*type
, GLcharARB
*name
)
946 GET_CURRENT_CONTEXT(ctx
);
947 struct gl2_unknown_intf
**unk
;
948 struct gl2_program_intf
**pro
;
950 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
951 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
952 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
956 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveUniformARB");
960 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
963 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetActiveUniformARB");
967 /* if (index >= val (OBJECT_ACTIVE_ATTRIBUTES_ARB))
969 _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveUniformARB");
970 (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
976 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
980 _mesa_GetUniformfvARB (GLhandleARB programObj
, GLint location
, GLfloat
*params
)
982 GET_CURRENT_CONTEXT(ctx
);
983 struct gl2_unknown_intf
**unk
;
984 struct gl2_program_intf
**pro
;
986 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
987 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
988 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
992 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetUniformfvARB");
996 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
999 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformfvARB");
1003 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
1005 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformfvARB");
1006 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1010 /* TODO validate location (OPERATION) */
1014 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1018 _mesa_GetUniformivARB (GLhandleARB programObj
, GLint location
, GLint
*params
)
1020 GET_CURRENT_CONTEXT(ctx
);
1021 struct gl2_unknown_intf
**unk
;
1022 struct gl2_program_intf
**pro
;
1024 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1025 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
1026 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1030 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetUniformivARB");
1034 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
1037 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformivARB");
1041 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
1043 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetUniformivARB");
1044 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1048 /* TODO validate location (GL_INVALID_OPERATION) */
1052 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1056 _mesa_GetShaderSourceARB (GLhandleARB obj
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*source
)
1058 GET_CURRENT_CONTEXT(ctx
);
1059 struct gl2_unknown_intf
**unk
;
1060 struct gl2_shader_intf
**sha
;
1062 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1063 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, obj
);
1064 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1068 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetShaderSourceARB");
1072 sha
= (struct gl2_shader_intf
**) (**unk
).QueryInterface (unk
, UIID_SHADER
);
1075 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glGetShaderSourceARB");
1079 _mesa_get_string ((**sha
).GetSource (sha
), maxLength
, length
, source
);
1081 (**sha
)._generic
._unknown
.Release ((struct gl2_unknown_intf
**) sha
);
1084 /* GL_ARB_vertex_shader */
1087 _mesa_BindAttribLocationARB (GLhandleARB programObj
, GLuint index
, const GLcharARB
*name
)
1089 GET_CURRENT_CONTEXT(ctx
);
1090 struct gl2_unknown_intf
**unk
;
1091 struct gl2_program_intf
**pro
;
1093 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1094 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
1095 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1099 _mesa_error (ctx
, GL_INVALID_VALUE
, "glBindAttribLocationARB");
1103 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
1106 _mesa_error (ctx
, GL_INVALID_VALUE
, "glBindAttribLocationARB");
1112 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1116 _mesa_GetActiveAttribARB (GLhandleARB programObj
, GLuint index
, GLsizei maxLength
, GLsizei
*length
, GLint
*size
, GLenum
*type
, GLcharARB
*name
)
1118 GET_CURRENT_CONTEXT(ctx
);
1119 struct gl2_unknown_intf
**unk
;
1120 struct gl2_program_intf
**pro
;
1122 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1123 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
1124 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1128 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveAttribARB");
1132 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
1135 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveAttribARB");
1141 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1145 _mesa_GetAttribLocationARB (GLhandleARB programObj
, const GLcharARB
*name
)
1147 GET_CURRENT_CONTEXT(ctx
);
1148 struct gl2_unknown_intf
**unk
;
1149 struct gl2_program_intf
**pro
;
1152 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
1153 unk
= (struct gl2_unknown_intf
**) _mesa_HashLookup (ctx
->Shared
->GL2Objects
, programObj
);
1154 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
1158 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetAttribLocationARB");
1162 pro
= (struct gl2_program_intf
**) (**unk
).QueryInterface (unk
, UIID_PROGRAM
);
1165 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetAttribLocationARB");
1171 (**pro
)._container
._generic
._unknown
.Release ((struct gl2_unknown_intf
**) pro
);
1176 _mesa_init_shaderobjects (GLcontext
*ctx
)
1178 ctx
->ShaderObjects
.current_program
= NULL
;
1180 _mesa_init_shaderobjects_3dlabs (ctx
);