2 * Mesa 3-D graphics library
5 * Copyright (C) 2004-2006 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 RELEASE_GENERIC(x)\
40 (**x)._unknown.Release ((struct gl2_unknown_intf **) (x))
42 #define RELEASE_CONTAINER(x)\
43 (**x)._generic._unknown.Release ((struct gl2_unknown_intf **) (x))
45 #define RELEASE_PROGRAM(x)\
46 (**x)._container._generic._unknown.Release ((struct gl2_unknown_intf **) (x))
48 #define RELEASE_SHADER(x)\
49 (**x)._generic._unknown.Release ((struct gl2_unknown_intf **) (x))
51 static struct gl2_unknown_intf
**
52 lookup_handle (GLcontext
*ctx
, GLhandleARB handle
, enum gl2_uuid uuid
, const char *function
)
54 struct gl2_unknown_intf
**unk
;
57 * Note: _mesa_HashLookup() requires non-zero input values, so the passed-in handle value
58 * must be checked beforehand.
61 _mesa_error (ctx
, GL_INVALID_VALUE
, function
);
64 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
65 unk
= (struct gl2_unknown_intf
**) (_mesa_HashLookup (ctx
->Shared
->GL2Objects
, handle
));
66 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
68 _mesa_error (ctx
, GL_INVALID_VALUE
, function
);
70 unk
= (**unk
).QueryInterface (unk
, uuid
);
72 _mesa_error (ctx
, GL_INVALID_OPERATION
, function
);
77 #define GET_GENERIC(x, handle, function)\
78 struct gl2_generic_intf **x = (struct gl2_generic_intf **)\
79 lookup_handle (ctx, handle, UIID_GENERIC, function);
81 #define GET_CONTAINER(x, handle, function)\
82 struct gl2_container_intf **x = (struct gl2_container_intf **)\
83 lookup_handle (ctx, handle, UIID_CONTAINER, function);
85 #define GET_PROGRAM(x, handle, function)\
86 struct gl2_program_intf **x = (struct gl2_program_intf **)\
87 lookup_handle (ctx, handle, UIID_PROGRAM, function);
89 #define GET_SHADER(x, handle, function)\
90 struct gl2_shader_intf **x = (struct gl2_shader_intf **)\
91 lookup_handle (ctx, handle, UIID_SHADER, function);
93 #define GET_LINKED_PROGRAM(x, handle, function)\
94 GET_PROGRAM(x, handle, function);\
95 if (x != NULL && (**x).GetLinkStatus (x) == GL_FALSE) {\
98 _mesa_error (ctx, GL_INVALID_OPERATION, function);\
101 #define GET_CURRENT_LINKED_PROGRAM(x, function)\
102 struct gl2_program_intf **x = NULL;\
103 if (ctx->ShaderObjects.CurrentProgram == NULL)\
104 _mesa_error (ctx, GL_INVALID_OPERATION, function);\
106 x = ctx->ShaderObjects.CurrentProgram;\
107 if (x != NULL && (**x).GetLinkStatus (x) == GL_FALSE) {\
109 _mesa_error (ctx, GL_INVALID_OPERATION, function);\
113 #define IS_NAME_WITH_GL_PREFIX(x) ((x)[0] == 'g' && (x)[1] == 'l' && (x)[2] == '_')
117 _mesa_DeleteObjectARB (GLhandleARB obj
)
121 GET_CURRENT_CONTEXT(ctx
);
122 GET_GENERIC(gen
, obj
, "glDeleteObjectARB");
126 (**gen
).Delete (gen
);
127 RELEASE_GENERIC(gen
);
132 GLhandleARB GLAPIENTRY
133 _mesa_GetHandleARB (GLenum pname
)
135 GET_CURRENT_CONTEXT(ctx
);
139 case GL_PROGRAM_OBJECT_ARB
:
141 struct gl2_program_intf
**pro
= ctx
->ShaderObjects
.CurrentProgram
;
144 return (**pro
)._container
._generic
.GetName ((struct gl2_generic_intf
**) (pro
));
148 _mesa_error (ctx
, GL_INVALID_ENUM
, "glGetHandleARB");
155 _mesa_DetachObjectARB (GLhandleARB containerObj
, GLhandleARB attachedObj
)
157 GET_CURRENT_CONTEXT(ctx
);
158 GET_CONTAINER(con
, containerObj
, "glDetachObjectARB");
162 GET_GENERIC(att
, attachedObj
, "glDetachObjectARB");
166 (**con
).Detach (con
, att
);
167 RELEASE_GENERIC(att
);
169 RELEASE_CONTAINER(con
);
173 GLhandleARB GLAPIENTRY
174 _mesa_CreateShaderObjectARB (GLenum shaderType
)
176 return _mesa_3dlabs_create_shader_object (shaderType
);
180 _mesa_ShaderSourceARB (GLhandleARB shaderObj
, GLsizei count
, const GLcharARB
**string
,
183 GET_CURRENT_CONTEXT(ctx
);
187 GET_SHADER(sha
, shaderObj
, "glShaderSourceARB");
195 _mesa_error (ctx
, GL_INVALID_VALUE
, "glShaderSourceARB");
200 * This array holds offsets of where the appropriate string ends, thus the last
201 * element will be set to the total length of the source code.
203 offsets
= (GLint
*) _mesa_malloc (count
* sizeof (GLint
));
207 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
211 for (i
= 0; i
< count
; i
++)
213 if (string
[i
] == NULL
)
215 _mesa_free ((GLvoid
*) offsets
);
217 _mesa_error (ctx
, GL_INVALID_VALUE
, "glShaderSourceARB");
220 if (length
== NULL
|| length
[i
] < 0)
221 offsets
[i
] = _mesa_strlen (string
[i
]);
223 offsets
[i
] = length
[i
];
224 /* accumulate string lengths */
226 offsets
[i
] += offsets
[i
- 1];
229 source
= (GLcharARB
*) _mesa_malloc ((offsets
[count
- 1] + 1) * sizeof (GLcharARB
));
232 _mesa_free ((GLvoid
*) offsets
);
234 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glShaderSourceARB");
238 for (i
= 0; i
< count
; i
++)
240 GLint start
= (i
> 0) ? offsets
[i
- 1] : 0;
241 _mesa_memcpy (source
+ start
, string
[i
], (offsets
[i
] - start
) * sizeof (GLcharARB
));
243 source
[offsets
[count
- 1]] = '\0';
245 (**sha
).SetSource (sha
, source
, offsets
, count
);
250 _mesa_CompileShaderARB (GLhandleARB shaderObj
)
252 GET_CURRENT_CONTEXT(ctx
);
253 GET_SHADER(sha
, shaderObj
, "glCompileShaderARB");
257 (**sha
).Compile (sha
);
262 GLhandleARB GLAPIENTRY
263 _mesa_CreateProgramObjectARB (GLvoid
)
265 return _mesa_3dlabs_create_program_object ();
269 _mesa_AttachObjectARB (GLhandleARB containerObj
, GLhandleARB obj
)
271 GET_CURRENT_CONTEXT(ctx
);
272 GET_CONTAINER(con
, containerObj
, "glAttachObjectARB");
276 GET_GENERIC(att
, obj
, "glAttachObjectARB");
280 (**con
).Attach (con
, att
);
281 RELEASE_GENERIC(att
);
283 RELEASE_CONTAINER(con
);
288 _mesa_LinkProgramARB (GLhandleARB programObj
)
290 GET_CURRENT_CONTEXT(ctx
);
291 GET_PROGRAM(pro
, programObj
, "glLinkProgramARB");
296 if (pro
== ctx
->ShaderObjects
.CurrentProgram
)
298 if ((**pro
).GetLinkStatus (pro
))
299 _mesa_UseProgramObjectARB (programObj
);
301 _mesa_UseProgramObjectARB (0);
303 RELEASE_PROGRAM(pro
);
308 _mesa_UseProgramObjectARB (GLhandleARB programObj
)
310 GET_CURRENT_CONTEXT(ctx
);
311 struct gl2_program_intf
**program
= NULL
;
313 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
317 GET_PROGRAM(pro
, programObj
, "glUseProgramObjectARB");
322 if ((**pro
).GetLinkStatus (pro
) == GL_FALSE
)
324 RELEASE_PROGRAM(pro
);
325 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUseProgramObjectARB");
331 ctx
->ShaderObjects
._VertexShaderPresent
= (**pro
).IsShaderPresent (pro
, GL_VERTEX_SHADER_ARB
);
332 ctx
->ShaderObjects
._FragmentShaderPresent
= (**pro
).IsShaderPresent (pro
,
333 GL_FRAGMENT_SHADER_ARB
);
337 ctx
->ShaderObjects
._VertexShaderPresent
= GL_FALSE
;
338 ctx
->ShaderObjects
._FragmentShaderPresent
= GL_FALSE
;
341 if (ctx
->ShaderObjects
.CurrentProgram
!= NULL
)
342 RELEASE_PROGRAM(ctx
->ShaderObjects
.CurrentProgram
);
343 ctx
->ShaderObjects
.CurrentProgram
= program
;
347 _mesa_ValidateProgramARB (GLhandleARB programObj
)
349 GET_CURRENT_CONTEXT(ctx
);
350 GET_PROGRAM(pro
, programObj
, "glValidateProgramARB");
354 (**pro
).Validate (pro
);
355 RELEASE_PROGRAM(pro
);
360 _mesa_Uniform1fARB (GLint location
, GLfloat v0
)
362 GET_CURRENT_CONTEXT(ctx
);
363 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform1fARB");
365 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
369 if (!(**pro
).WriteUniform (pro
, location
, 1, &v0
, GL_FLOAT
))
370 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1fARB");
375 _mesa_Uniform2fARB (GLint location
, GLfloat v0
, GLfloat v1
)
377 GET_CURRENT_CONTEXT(ctx
);
378 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform2fARB");
380 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
388 if (!(**pro
).WriteUniform (pro
, location
, 1, v
, GL_FLOAT_VEC2
))
389 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2fARB");
394 _mesa_Uniform3fARB (GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
)
396 GET_CURRENT_CONTEXT(ctx
);
397 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform3fARB");
399 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
408 if (!(**pro
).WriteUniform (pro
, location
, 1, v
, GL_FLOAT_VEC3
))
409 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3fARB");
414 _mesa_Uniform4fARB (GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
, GLfloat v3
)
416 GET_CURRENT_CONTEXT(ctx
);
417 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform4fARB");
419 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
429 if (!(**pro
).WriteUniform (pro
, location
, 1, v
, GL_FLOAT_VEC4
))
430 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4fARB");
435 _mesa_Uniform1iARB (GLint location
, GLint v0
)
437 GET_CURRENT_CONTEXT(ctx
);
438 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform1iARB");
440 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
444 if (!(**pro
).WriteUniform (pro
, location
, 1, &v0
, GL_INT
))
445 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1iARB");
450 _mesa_Uniform2iARB (GLint location
, GLint v0
, GLint v1
)
452 GET_CURRENT_CONTEXT(ctx
);
453 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform2iARB");
455 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
463 if (!(**pro
).WriteUniform (pro
, location
, 1, v
, GL_INT_VEC2
))
464 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2iARB");
469 _mesa_Uniform3iARB (GLint location
, GLint v0
, GLint v1
, GLint v2
)
471 GET_CURRENT_CONTEXT(ctx
);
472 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform3iARB");
474 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
483 if (!(**pro
).WriteUniform (pro
, location
, 1, v
, GL_INT_VEC3
))
484 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3iARB");
489 _mesa_Uniform4iARB (GLint location
, GLint v0
, GLint v1
, GLint v2
, GLint v3
)
491 GET_CURRENT_CONTEXT(ctx
);
492 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform4iARB");
494 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
504 if (!(**pro
).WriteUniform (pro
, location
, 1, v
, GL_INT_VEC4
))
505 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4iARB");
510 _mesa_Uniform1fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
512 GET_CURRENT_CONTEXT(ctx
);
513 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform1fvARB");
517 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniform1fvARB");
521 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
525 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_FLOAT
))
526 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1fvARB");
531 _mesa_Uniform2fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
533 GET_CURRENT_CONTEXT(ctx
);
534 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform2fvARB");
538 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniform2fvARB");
542 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
546 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_FLOAT_VEC2
))
547 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2fvARB");
552 _mesa_Uniform3fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
554 GET_CURRENT_CONTEXT(ctx
);
555 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform3fvARB");
559 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniform3fvARB");
563 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
567 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_FLOAT_VEC3
))
568 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3fvARB");
573 _mesa_Uniform4fvARB (GLint location
, GLsizei count
, const GLfloat
*value
)
575 GET_CURRENT_CONTEXT(ctx
);
576 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform4fvARB");
580 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniform4fvARB");
584 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
588 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_FLOAT_VEC4
))
589 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4fvARB");
594 _mesa_Uniform1ivARB (GLint location
, GLsizei count
, const GLint
*value
)
596 GET_CURRENT_CONTEXT(ctx
);
597 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform1ivARB");
601 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniform1ivARB");
605 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
609 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_INT
))
610 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform1ivARB");
615 _mesa_Uniform2ivARB (GLint location
, GLsizei count
, const GLint
*value
)
617 GET_CURRENT_CONTEXT(ctx
);
618 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform2ivARB");
622 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniform2ivARB");
626 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
630 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_INT_VEC2
))
631 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform2ivARB");
636 _mesa_Uniform3ivARB (GLint location
, GLsizei count
, const GLint
*value
)
638 GET_CURRENT_CONTEXT(ctx
);
639 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform3ivARB");
643 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniform3ivARB");
647 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
651 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_INT_VEC3
))
652 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform3ivARB");
657 _mesa_Uniform4ivARB (GLint location
, GLsizei count
, const GLint
*value
)
659 GET_CURRENT_CONTEXT(ctx
);
660 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniform4ivARB");
664 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniform4ivARB");
668 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
672 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_INT_VEC4
))
673 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniform4ivARB");
678 _mesa_UniformMatrix2fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
680 GET_CURRENT_CONTEXT(ctx
);
681 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniformMatrix2fvARB");
685 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniformMatrix2fvARB");
689 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
698 trans
= (GLfloat
*) _mesa_malloc (count
* 4 * sizeof (GLfloat
));
701 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glUniformMatrix2fvARB");
704 for (pt
= trans
, pv
= value
; pt
!= trans
+ count
* 4; pt
+= 4, pv
+= 4)
711 if (!(**pro
).WriteUniform (pro
, location
, count
, trans
, GL_FLOAT_MAT2
))
712 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix2fvARB");
717 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_FLOAT_MAT2
))
718 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix2fvARB");
724 _mesa_UniformMatrix3fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
726 GET_CURRENT_CONTEXT(ctx
);
727 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniformMatrix3fvARB");
731 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniformMatrix3fvARB");
735 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
744 trans
= (GLfloat
*) _mesa_malloc (count
* 9 * sizeof (GLfloat
));
747 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glUniformMatrix3fvARB");
750 for (pt
= trans
, pv
= value
; pt
!= trans
+ count
* 9; pt
+= 9, pv
+= 9)
762 if (!(**pro
).WriteUniform (pro
, location
, count
, trans
, GL_FLOAT_MAT3
))
763 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix3fvARB");
768 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_FLOAT_MAT3
))
769 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix3fvARB");
775 _mesa_UniformMatrix4fvARB (GLint location
, GLsizei count
, GLboolean transpose
, const GLfloat
*value
)
777 GET_CURRENT_CONTEXT(ctx
);
778 GET_CURRENT_LINKED_PROGRAM(pro
, "glUniformMatrix4fvARB");
782 _mesa_error (ctx
, GL_INVALID_VALUE
, "glUniformMatrix4fvARB");
786 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
795 trans
= (GLfloat
*) _mesa_malloc (count
* 16 * sizeof (GLfloat
));
798 _mesa_error (ctx
, GL_OUT_OF_MEMORY
, "glUniformMatrix4fvARB");
801 for (pt
= trans
, pv
= value
; pt
!= trans
+ count
* 16; pt
+= 16, pv
+= 16)
803 _math_transposef (pt
, pv
);
805 if (!(**pro
).WriteUniform (pro
, location
, count
, trans
, GL_FLOAT_MAT4
))
806 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix4fvARB");
811 if (!(**pro
).WriteUniform (pro
, location
, count
, value
, GL_FLOAT_MAT4
))
812 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glUniformMatrix4fvARB");
818 _mesa_get_object_parameter (GLhandleARB obj
, GLenum pname
, GLvoid
*params
, GLboolean
*integral
,
821 GET_CURRENT_CONTEXT(ctx
);
822 GLint
*ipar
= (GLint
*) params
;
824 /* set default values */
825 *integral
= GL_TRUE
; /* indicates param type, TRUE: GLint, FALSE: GLfloat */
826 *size
= 1; /* param array size */
830 case GL_OBJECT_TYPE_ARB
:
831 case GL_OBJECT_DELETE_STATUS_ARB
:
832 case GL_OBJECT_INFO_LOG_LENGTH_ARB
:
834 GET_GENERIC(gen
, obj
, "glGetObjectParameterivARB");
841 case GL_OBJECT_TYPE_ARB
:
842 *ipar
= (**gen
).GetType (gen
);
844 case GL_OBJECT_DELETE_STATUS_ARB
:
845 *ipar
= (**gen
).GetDeleteStatus (gen
);
847 case GL_OBJECT_INFO_LOG_LENGTH_ARB
:
848 *ipar
= (**gen
).GetInfoLogLength (gen
);
852 RELEASE_GENERIC(gen
);
855 case GL_OBJECT_SUBTYPE_ARB
:
856 case GL_OBJECT_COMPILE_STATUS_ARB
:
857 case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB
:
859 GET_SHADER(sha
, obj
, "glGetObjectParameterivARB");
866 case GL_OBJECT_SUBTYPE_ARB
:
867 *ipar
= (**sha
).GetSubType (sha
);
869 case GL_OBJECT_COMPILE_STATUS_ARB
:
870 *ipar
= (**sha
).GetCompileStatus (sha
);
872 case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB
:
874 const GLcharARB
*src
= (**sha
).GetSource (sha
);
879 *ipar
= _mesa_strlen (src
) + 1;
887 case GL_OBJECT_LINK_STATUS_ARB
:
888 case GL_OBJECT_VALIDATE_STATUS_ARB
:
889 case GL_OBJECT_ATTACHED_OBJECTS_ARB
:
890 case GL_OBJECT_ACTIVE_UNIFORMS_ARB
:
891 case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB
:
893 GET_PROGRAM(pro
, obj
, "glGetObjectParameterivARB");
900 case GL_OBJECT_LINK_STATUS_ARB
:
901 *ipar
= (**pro
).GetLinkStatus (pro
);
903 case GL_OBJECT_VALIDATE_STATUS_ARB
:
904 *ipar
= (**pro
).GetValidateStatus (pro
);
906 case GL_OBJECT_ATTACHED_OBJECTS_ARB
:
907 *ipar
= (**pro
)._container
.GetAttachedCount ((struct gl2_container_intf
**) (pro
));
909 case GL_OBJECT_ACTIVE_UNIFORMS_ARB
:
910 *ipar
= (**pro
).GetActiveUniformCount (pro
);
912 case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB
:
913 *ipar
= (**pro
).GetActiveUniformMaxLength (pro
);
915 case GL_OBJECT_ACTIVE_ATTRIBUTES_ARB
:
916 *ipar
= (**pro
).GetActiveAttribCount (pro
);
918 case GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB
:
919 *ipar
= (**pro
).GetActiveAttribMaxLength (pro
);
923 RELEASE_PROGRAM(pro
);
927 _mesa_error (ctx
, GL_INVALID_ENUM
, "glGetObjectParameterivARB");
935 _mesa_GetObjectParameterfvARB (GLhandleARB obj
, GLenum pname
, GLfloat
*params
)
937 GET_CURRENT_CONTEXT(ctx
);
943 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetObjectParameterfvARB");
947 assert (sizeof (GLfloat
) == sizeof (GLint
));
949 if (_mesa_get_object_parameter (obj
, pname
, (GLvoid
*) params
, &integral
, &size
))
954 for (i
= 0; i
< size
; i
++)
955 params
[i
] = (GLfloat
) ((GLint
*) params
)[i
];
960 _mesa_GetObjectParameterivARB (GLhandleARB obj
, GLenum pname
, GLint
*params
)
962 GET_CURRENT_CONTEXT(ctx
);
968 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetObjectParameterivARB");
972 assert (sizeof (GLfloat
) == sizeof (GLint
));
974 if (_mesa_get_object_parameter (obj
, pname
, (GLvoid
*) params
, &integral
, &size
))
979 for (i
= 0; i
< size
; i
++)
980 params
[i
] = (GLint
) ((GLfloat
*) params
)[i
];
986 * Copy string from <src> to <dst>, up to maxLength characters, returning
987 * length of <dst> in <length>.
988 * \param src the strings source
989 * \param maxLength max chars to copy
990 * \param length returns numberof chars copied
991 * \param dst the string destination
994 copy_string(const GLcharARB
*src
, GLsizei maxLength
, GLsizei
*length
,
998 for (len
= 0; len
< maxLength
- 1 && src
&& src
[len
]; len
++)
1008 _mesa_GetInfoLogARB (GLhandleARB obj
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*infoLog
)
1010 GET_CURRENT_CONTEXT(ctx
);
1011 GET_GENERIC(gen
, obj
, "glGetInfoLogARB");
1016 if (infoLog
== NULL
)
1017 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetInfoLogARB");
1019 GLsizei actualsize
= (**gen
).GetInfoLogLength (gen
);
1020 if (actualsize
> maxLength
)
1021 actualsize
= maxLength
;
1022 (**gen
).GetInfoLog (gen
, actualsize
, infoLog
);
1024 *length
= (actualsize
> 0) ? actualsize
- 1 : 0;
1026 RELEASE_GENERIC(gen
);
1030 _mesa_GetAttachedObjectsARB (GLhandleARB containerObj
, GLsizei maxCount
, GLsizei
*count
,
1033 GET_CURRENT_CONTEXT(ctx
);
1034 GET_CONTAINER(con
, containerObj
, "glGetAttachedObjectsARB");
1040 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetAttachedObjectsARB");
1045 cnt
= (**con
).GetAttachedCount (con
);
1051 for (i
= 0; i
< cnt
; i
++)
1053 struct gl2_generic_intf
**x
= (**con
).GetAttached (con
, i
);
1054 obj
[i
] = (**x
).GetName (x
);
1058 RELEASE_CONTAINER(con
);
1062 _mesa_GetUniformLocationARB (GLhandleARB programObj
, const GLcharARB
*name
)
1064 GET_CURRENT_CONTEXT(ctx
);
1066 GET_LINKED_PROGRAM(pro
, programObj
, "glGetUniformLocationARB");
1072 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetUniformLocationARB");
1075 if (!IS_NAME_WITH_GL_PREFIX(name
))
1076 loc
= (**pro
).GetUniformLocation (pro
, name
);
1078 RELEASE_PROGRAM(pro
);
1083 _mesa_GetActiveUniformARB (GLhandleARB programObj
, GLuint index
, GLsizei maxLength
, GLsizei
*length
,
1084 GLint
*size
, GLenum
*type
, GLcharARB
*name
)
1086 GET_CURRENT_CONTEXT(ctx
);
1087 GET_PROGRAM(pro
, programObj
, "glGetActiveUniformARB");
1092 if (size
== NULL
|| type
== NULL
|| name
== NULL
)
1093 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveUniformARB");
1096 if (index
< (**pro
).GetActiveUniformCount (pro
))
1097 (**pro
).GetActiveUniform (pro
, index
, maxLength
, length
, size
, type
, name
);
1099 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveUniformARB");
1101 RELEASE_PROGRAM(pro
);
1105 _mesa_GetUniformfvARB (GLhandleARB programObj
, GLint location
, GLfloat
*params
)
1107 GET_CURRENT_CONTEXT(ctx
);
1108 GET_LINKED_PROGRAM(pro
, programObj
, "glGetUniformfvARB");
1113 RELEASE_PROGRAM(pro
);
1118 _mesa_GetUniformivARB (GLhandleARB programObj
, GLint location
, GLint
*params
)
1120 GET_CURRENT_CONTEXT(ctx
);
1121 GET_LINKED_PROGRAM(pro
, programObj
, "glGetUniformivARB");
1126 RELEASE_PROGRAM(pro
);
1131 _mesa_GetShaderSourceARB (GLhandleARB obj
, GLsizei maxLength
, GLsizei
*length
, GLcharARB
*source
)
1133 GET_CURRENT_CONTEXT(ctx
);
1134 GET_SHADER(sha
, obj
, "glGetShaderSourceARB");
1140 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetShaderSourceARB");
1142 copy_string ((**sha
).GetSource (sha
), maxLength
, length
, source
);
1143 RELEASE_SHADER(sha
);
1146 /* GL_ARB_vertex_shader */
1149 _mesa_BindAttribLocationARB (GLhandleARB programObj
, GLuint index
, const GLcharARB
*name
)
1151 GET_CURRENT_CONTEXT(ctx
);
1152 GET_PROGRAM(pro
, programObj
, "glBindAttribLocationARB");
1157 if (name
== NULL
|| index
>= MAX_VERTEX_ATTRIBS
)
1158 _mesa_error (ctx
, GL_INVALID_VALUE
, "glBindAttribLocationARB");
1159 else if (IS_NAME_WITH_GL_PREFIX(name
))
1160 _mesa_error (ctx
, GL_INVALID_OPERATION
, "glBindAttribLocationARB");
1162 (**pro
).OverrideAttribBinding (pro
, index
, name
);
1163 RELEASE_PROGRAM(pro
);
1167 _mesa_GetActiveAttribARB (GLhandleARB programObj
, GLuint index
, GLsizei maxLength
, GLsizei
*length
,
1168 GLint
*size
, GLenum
*type
, GLcharARB
*name
)
1170 GET_CURRENT_CONTEXT(ctx
);
1171 GET_PROGRAM(pro
, programObj
, "glGetActiveAttribARB");
1176 if (name
== NULL
|| index
>= (**pro
).GetActiveAttribCount (pro
))
1177 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetActiveAttribARB");
1179 (**pro
).GetActiveAttrib (pro
, index
, maxLength
, length
, size
, type
, name
);
1180 RELEASE_PROGRAM(pro
);
1184 _mesa_GetAttribLocationARB (GLhandleARB programObj
, const GLcharARB
*name
)
1186 GET_CURRENT_CONTEXT(ctx
);
1188 GET_LINKED_PROGRAM(pro
, programObj
, "glGetAttribLocationARB");
1194 _mesa_error (ctx
, GL_INVALID_VALUE
, "glGetAttribLocationARB");
1195 else if (!IS_NAME_WITH_GL_PREFIX(name
))
1196 loc
= (**pro
).GetAttribLocation (pro
, name
);
1197 RELEASE_PROGRAM(pro
);
1202 _mesa_init_shaderobjects (GLcontext
*ctx
)
1204 ctx
->ShaderObjects
.CurrentProgram
= NULL
;
1205 ctx
->ShaderObjects
._FragmentShaderPresent
= GL_FALSE
;
1206 ctx
->ShaderObjects
._VertexShaderPresent
= GL_FALSE
;
1208 _mesa_init_shaderobjects_3dlabs (ctx
);