2 * Mesa 3-D graphics library
5 * Copyright (C) 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_3dlabs.c
27 * shader objects definitions for 3dlabs compiler
31 /* Set this to 1 when we are ready to use 3dlabs' front-end */
32 #define USE_3DLABS_FRONTEND 0
35 #include "shaderobjects.h"
36 #include "shaderobjects_3dlabs.h"
41 #if USE_3DLABS_FRONTEND
42 #include "slang_mesa.h"
43 #include "Public/ShaderLang.h"
45 #include "slang_compile.h"
48 struct gl2_unknown_obj
50 GLuint reference_count
;
51 void (* _destructor
) (struct gl2_unknown_intf
**);
54 struct gl2_unknown_impl
56 struct gl2_unknown_intf
*_vftbl
;
57 struct gl2_unknown_obj _obj
;
61 _unknown_destructor (struct gl2_unknown_intf
**intf
)
66 _unknown_AddRef (struct gl2_unknown_intf
**intf
)
68 struct gl2_unknown_impl
*impl
= (struct gl2_unknown_impl
*) intf
;
70 impl
->_obj
.reference_count
++;
74 _unknown_Release (struct gl2_unknown_intf
**intf
)
76 struct gl2_unknown_impl
*impl
= (struct gl2_unknown_impl
*) intf
;
78 impl
->_obj
.reference_count
--;
79 if (impl
->_obj
.reference_count
== 0)
81 impl
->_obj
._destructor (intf
);
82 _mesa_free ((void *) intf
);
86 static struct gl2_unknown_intf
**
87 _unknown_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
89 if (uiid
== UIID_UNKNOWN
)
91 (**intf
).AddRef (intf
);
97 static struct gl2_unknown_intf _unknown_vftbl
= {
100 _unknown_QueryInterface
104 _unknown_constructor (struct gl2_unknown_impl
*impl
)
106 impl
->_vftbl
= &_unknown_vftbl
;
107 impl
->_obj
.reference_count
= 1;
108 impl
->_obj
._destructor
= _unknown_destructor
;
111 struct gl2_unkinner_obj
113 struct gl2_unknown_intf
**unkouter
;
116 struct gl2_unkinner_impl
118 struct gl2_unknown_intf
*_vftbl
;
119 struct gl2_unkinner_obj _obj
;
123 _unkinner_destructor (struct gl2_unknown_intf
**intf
)
128 _unkinner_AddRef (struct gl2_unknown_intf
**intf
)
130 struct gl2_unkinner_impl
*impl
= (struct gl2_unkinner_impl
*) intf
;
132 (**impl
->_obj
.unkouter
).AddRef (impl
->_obj
.unkouter
);
136 _unkinner_Release (struct gl2_unknown_intf
**intf
)
138 struct gl2_unkinner_impl
*impl
= (struct gl2_unkinner_impl
*) intf
;
140 (**impl
->_obj
.unkouter
).Release (impl
->_obj
.unkouter
);
143 static struct gl2_unknown_intf
**
144 _unkinner_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
146 struct gl2_unkinner_impl
*impl
= (struct gl2_unkinner_impl
*) intf
;
148 return (**impl
->_obj
.unkouter
).QueryInterface (impl
->_obj
.unkouter
, uiid
);
151 static struct gl2_unknown_intf _unkinner_vftbl
= {
154 _unkinner_QueryInterface
158 _unkinner_constructor (struct gl2_unkinner_impl
*impl
, struct gl2_unknown_intf
**outer
)
160 impl
->_vftbl
= &_unkinner_vftbl
;
161 impl
->_obj
.unkouter
= outer
;
164 struct gl2_generic_obj
166 struct gl2_unknown_obj _unknown
;
168 GLboolean delete_status
;
172 struct gl2_generic_impl
174 struct gl2_generic_intf
*_vftbl
;
175 struct gl2_generic_obj _obj
;
179 _generic_destructor (struct gl2_unknown_intf
**intf
)
181 GET_CURRENT_CONTEXT(ctx
);
182 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
184 _mesa_free ((void *) impl
->_obj
.info_log
);
186 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
187 _mesa_HashRemove (ctx
->Shared
->GL2Objects
, impl
->_obj
.name
);
188 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
190 _unknown_destructor (intf
);
193 static struct gl2_unknown_intf
**
194 _generic_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
196 if (uiid
== UIID_GENERIC
)
198 (**intf
).AddRef (intf
);
201 return _unknown_QueryInterface (intf
, uiid
);
205 _generic_Delete (struct gl2_generic_intf
**intf
)
207 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
209 if (impl
->_obj
.delete_status
== GL_FALSE
)
211 impl
->_obj
.delete_status
= GL_TRUE
;
212 (**intf
)._unknown
.Release ((struct gl2_unknown_intf
**) intf
);
217 _generic_GetName (struct gl2_generic_intf
**intf
)
219 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
221 return impl
->_obj
.name
;
225 _generic_GetDeleteStatus (struct gl2_generic_intf
**intf
)
227 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
229 return impl
->_obj
.delete_status
;
232 static const GLcharARB
*
233 _generic_GetInfoLog (struct gl2_generic_intf
**intf
)
235 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
237 return impl
->_obj
.info_log
;
240 static struct gl2_generic_intf _generic_vftbl
= {
244 _generic_QueryInterface
247 NULL
, /* abstract GetType */
249 _generic_GetDeleteStatus
,
254 _generic_constructor (struct gl2_generic_impl
*impl
)
256 GET_CURRENT_CONTEXT(ctx
);
258 _unknown_constructor ((struct gl2_unknown_impl
*) impl
);
259 impl
->_vftbl
= &_generic_vftbl
;
260 impl
->_obj
._unknown
._destructor
= _generic_destructor
;
261 impl
->_obj
.delete_status
= GL_FALSE
;
262 impl
->_obj
.info_log
= NULL
;
264 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
265 impl
->_obj
.name
= _mesa_HashFindFreeKeyBlock (ctx
->Shared
->GL2Objects
, 1);
266 _mesa_HashInsert (ctx
->Shared
->GL2Objects
, impl
->_obj
.name
, (void *) impl
);
267 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
270 struct gl2_container_obj
272 struct gl2_generic_obj _generic
;
273 struct gl2_generic_intf
***attached
;
274 GLuint attached_count
;
277 struct gl2_container_impl
279 struct gl2_container_intf
*_vftbl
;
280 struct gl2_container_obj _obj
;
284 _container_destructor (struct gl2_unknown_intf
**intf
)
286 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
289 for (i
= 0; i
< impl
->_obj
.attached_count
; i
++)
291 struct gl2_generic_intf
**x
= impl
->_obj
.attached
[i
];
292 (**x
)._unknown
.Release ((struct gl2_unknown_intf
**) x
);
295 _generic_destructor (intf
);
298 static struct gl2_unknown_intf
**
299 _container_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
301 if (uiid
== UIID_CONTAINER
)
303 (**intf
).AddRef (intf
);
306 return _generic_QueryInterface (intf
, uiid
);
310 _container_Attach (struct gl2_container_intf
**intf
, struct gl2_generic_intf
**att
)
312 GET_CURRENT_CONTEXT(ctx
);
313 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
316 for (i
= 0; i
< impl
->_obj
.attached_count
; i
++)
317 if (impl
->_obj
.attached
[i
] == att
)
319 _mesa_error (ctx
, GL_INVALID_OPERATION
, "_container_Attach");
323 impl
->_obj
.attached
= (struct gl2_generic_intf
***) _mesa_realloc (impl
->_obj
.attached
,
324 impl
->_obj
.attached_count
* sizeof (*impl
->_obj
.attached
), (impl
->_obj
.attached_count
+ 1) *
325 sizeof (*impl
->_obj
.attached
));
326 if (impl
->_obj
.attached
== NULL
)
329 impl
->_obj
.attached
[impl
->_obj
.attached_count
] = att
;
330 impl
->_obj
.attached_count
++;
331 (**att
)._unknown
.AddRef ((struct gl2_unknown_intf
**) att
);
336 _container_Detach (struct gl2_container_intf
**intf
, struct gl2_generic_intf
**att
)
338 GET_CURRENT_CONTEXT(ctx
);
339 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
342 for (i
= 0; i
< impl
->_obj
.attached_count
; i
++)
343 if (impl
->_obj
.attached
[i
] == att
)
345 for (j
= i
; j
< impl
->_obj
.attached_count
- 1; j
++)
346 impl
->_obj
.attached
[j
] = impl
->_obj
.attached
[j
+ 1];
347 impl
->_obj
.attached
= (struct gl2_generic_intf
***) _mesa_realloc (impl
->_obj
.attached
,
348 impl
->_obj
.attached_count
* sizeof (*impl
->_obj
.attached
),
349 (impl
->_obj
.attached_count
- 1) * sizeof (*impl
->_obj
.attached
));
350 impl
->_obj
.attached_count
--;
351 (**att
)._unknown
.Release ((struct gl2_unknown_intf
**) att
);
355 _mesa_error (ctx
, GL_INVALID_OPERATION
, "_container_Detach");
360 _container_GetAttachedCount (struct gl2_container_intf
**intf
)
362 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
364 return impl
->_obj
.attached_count
;
367 static struct gl2_generic_intf
**
368 _container_GetAttached (struct gl2_container_intf
**intf
, GLuint index
)
370 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
372 (**impl
->_obj
.attached
[index
])._unknown
.AddRef (
373 (struct gl2_unknown_intf
**)impl
->_obj
.attached
[index
]);
374 return impl
->_obj
.attached
[index
];
377 static struct gl2_container_intf _container_vftbl
= {
382 _container_QueryInterface
385 NULL
, /* abstract GetType */
387 _generic_GetDeleteStatus
,
392 _container_GetAttachedCount
,
393 _container_GetAttached
397 _container_constructor (struct gl2_container_impl
*impl
)
399 _generic_constructor ((struct gl2_generic_impl
*) impl
);
400 impl
->_vftbl
= &_container_vftbl
;
401 impl
->_obj
._generic
._unknown
._destructor
= _container_destructor
;
402 impl
->_obj
.attached
= NULL
;
403 impl
->_obj
.attached_count
= 0;
406 struct gl2_3dlabs_shhandle_obj
408 struct gl2_unkinner_obj _unknown
;
409 #if USE_3DLABS_FRONTEND
414 struct gl2_3dlabs_shhandle_impl
416 struct gl2_3dlabs_shhandle_intf
*_vftbl
;
417 struct gl2_3dlabs_shhandle_obj _obj
;
421 _3dlabs_shhandle_destructor (struct gl2_unknown_intf
**intf
)
423 #if USE_3DLABS_FRONTEND
424 struct gl2_3dlabs_shhandle_impl
*impl
= (struct gl2_3dlabs_shhandle_impl
*) intf
;
425 ShDestruct (impl
->_obj
.handle
);
427 _unkinner_destructor (intf
);
431 _3dlabs_shhandle_GetShHandle (struct gl2_3dlabs_shhandle_intf
**intf
)
433 #if USE_3DLABS_FRONTEND
434 struct gl2_3dlabs_shhandle_impl
*impl
= (struct gl2_3dlabs_shhandle_impl
*) intf
;
435 return impl
->_obj
.handle
;
441 static struct gl2_3dlabs_shhandle_intf _3dlabs_shhandle_vftbl
= {
445 _unkinner_QueryInterface
447 _3dlabs_shhandle_GetShHandle
451 _3dlabs_shhandle_constructor (struct gl2_3dlabs_shhandle_impl
*impl
, struct gl2_unknown_intf
**outer
)
453 _unkinner_constructor ((struct gl2_unkinner_impl
*) impl
, outer
);
454 impl
->_vftbl
= &_3dlabs_shhandle_vftbl
;
455 #if USE_3DLABS_FRONTEND
456 impl
->_obj
.handle
= NULL
;
460 struct gl2_shader_obj
462 struct gl2_generic_obj _generic
;
463 struct gl2_3dlabs_shhandle_impl _3dlabs_shhandle
;
464 GLboolean compile_status
;
467 GLsizei offset_count
;
470 struct gl2_shader_impl
472 struct gl2_shader_intf
*_vftbl
;
473 struct gl2_shader_obj _obj
;
477 _shader_destructor (struct gl2_unknown_intf
**intf
)
479 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
481 _mesa_free ((void *) impl
->_obj
.source
);
482 _mesa_free ((void *) impl
->_obj
.offsets
);
483 _3dlabs_shhandle_destructor ((struct gl2_unknown_intf
**) &impl
->_obj
._3dlabs_shhandle
._vftbl
);
484 _generic_destructor (intf
);
487 static struct gl2_unknown_intf
**
488 _shader_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
490 #if USE_3DLABS_FRONTEND
491 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
494 if (uiid
== UIID_SHADER
)
496 (**intf
).AddRef (intf
);
499 #if USE_3DLABS_FRONTEND
500 if (uiid
== UIID_3DLABS_SHHANDLE
)
502 (**intf
).AddRef (intf
);
503 return (struct gl2_unknown_intf
**) &impl
->_obj
._3dlabs_shhandle
._vftbl
;
506 return _generic_QueryInterface (intf
, uiid
);
510 _shader_GetType (struct gl2_generic_intf
**intf
)
512 return GL_SHADER_OBJECT_ARB
;
516 _shader_GetCompileStatus (struct gl2_shader_intf
**intf
)
518 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
520 return impl
->_obj
.compile_status
;
524 _shader_SetSource (struct gl2_shader_intf
**intf
, GLcharARB
*src
, GLint
*off
, GLsizei cnt
)
526 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
528 _mesa_free ((void *) impl
->_obj
.source
);
529 impl
->_obj
.source
= src
;
530 _mesa_free ((void *) impl
->_obj
.offsets
);
531 impl
->_obj
.offsets
= off
;
532 impl
->_obj
.offset_count
= cnt
;
535 static const GLcharARB
*
536 _shader_GetSource (struct gl2_shader_intf
**intf
)
538 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
540 return impl
->_obj
.source
;
544 _shader_Compile (struct gl2_shader_intf
**intf
)
546 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
547 #if USE_3DLABS_FRONTEND
549 TBuiltInResource res
;
551 slang_translation_unit unit
;
552 slang_unit_type type
;
553 slang_info_log info_log
;
556 impl
->_obj
.compile_status
= GL_FALSE
;
557 _mesa_free ((void *) impl
->_obj
._generic
.info_log
);
558 impl
->_obj
._generic
.info_log
= NULL
;
560 #if USE_3DLABS_FRONTEND
561 /* 3dlabs compiler expects us to feed it with null-terminated string array,
562 we've got only one big string with offsets, so we must split it; but when
563 there's only one string to deal with, we pass its address directly */
565 if (impl
->_obj
.offset_count
<= 1)
566 strings
= &impl
->_obj
.source
;
569 GLsizei i
, offset
= 0;
571 strings
= (char **) _mesa_malloc (impl
->_obj
.offset_count
* sizeof (char *));
575 for (i
= 0; i
< impl
->_obj
.offset_count
; i
++)
577 GLsizei size
= impl
->_obj
.offsets
[i
] - offset
;
579 strings
[i
] = (char *) _mesa_malloc ((size
+ 1) * sizeof (char));
580 if (strings
[i
] == NULL
)
584 for (j
= 0; j
< i
; j
++)
585 _mesa_free (strings
[j
]);
586 _mesa_free (strings
);
590 _mesa_memcpy (strings
[i
], impl
->_obj
.source
+ offset
, size
* sizeof (char));
591 strings
[i
][size
] = '\0';
592 offset
= impl
->_obj
.offsets
[i
];
596 /* TODO set these fields to some REAL numbers */
598 res
.maxClipPlanes
= 6;
599 res
.maxTextureUnits
= 2;
600 res
.maxTextureCoords
= 2;
601 res
.maxVertexAttribs
= 8;
602 res
.maxVertexUniformComponents
= 64;
603 res
.maxVaryingFloats
= 8;
604 res
.maxVertexTextureImageUnits
= 2;
605 res
.maxCombinedTextureImageUnits
= 2;
606 res
.maxTextureImageUnits
= 2;
607 res
.maxFragmentUniformComponents
= 64;
608 res
.maxDrawBuffers
= 1;
610 if (ShCompile (impl
->_obj
._3dlabs_shhandle
._obj
.handle
, strings
, impl
->_obj
.offset_count
,
611 EShOptFull
, &res
, 0))
612 impl
->_obj
.compile_status
= GL_TRUE
;
613 if (impl
->_obj
.offset_count
> 1)
617 for (i
= 0; i
< impl
->_obj
.offset_count
; i
++)
618 _mesa_free (strings
[i
]);
619 _mesa_free (strings
);
622 impl
->_obj
._generic
.info_log
= _mesa_strdup (ShGetInfoLog (
623 impl
->_obj
._3dlabs_shhandle
._obj
.handle
));
625 if (impl
->_vftbl
->GetSubType (intf
) == GL_FRAGMENT_SHADER
)
626 type
= slang_unit_fragment_shader
;
628 type
= slang_unit_vertex_shader
;
629 slang_info_log_construct (&info_log
);
630 if (_slang_compile (impl
->_obj
.source
, &unit
, type
, &info_log
))
632 impl
->_obj
.compile_status
= GL_TRUE
;
634 if (info_log
.text
!= NULL
)
635 impl
->_obj
._generic
.info_log
= _mesa_strdup (info_log
.text
);
637 impl
->_obj
._generic
.info_log
= _mesa_strdup ("");
638 slang_info_log_destruct (&info_log
);
642 static struct gl2_shader_intf _shader_vftbl
= {
647 _shader_QueryInterface
652 _generic_GetDeleteStatus
,
655 NULL
, /* abstract GetSubType */
656 _shader_GetCompileStatus
,
663 _shader_constructor (struct gl2_shader_impl
*impl
)
665 _generic_constructor ((struct gl2_generic_impl
*) impl
);
666 _3dlabs_shhandle_constructor (&impl
->_obj
._3dlabs_shhandle
, (struct gl2_unknown_intf
**)
668 impl
->_vftbl
= &_shader_vftbl
;
669 impl
->_obj
._generic
._unknown
._destructor
= _shader_destructor
;
670 impl
->_obj
.compile_status
= GL_FALSE
;
671 impl
->_obj
.source
= NULL
;
672 impl
->_obj
.offsets
= NULL
;
673 impl
->_obj
.offset_count
= 0;
676 struct gl2_program_obj
678 struct gl2_container_obj _container
;
679 GLboolean link_status
;
680 GLboolean validate_status
;
681 #if USE_3DLABS_FRONTEND
687 struct gl2_program_impl
689 struct gl2_program_intf
*_vftbl
;
690 struct gl2_program_obj _obj
;
694 _program_destructor (struct gl2_unknown_intf
**intf
)
696 #if USE_3DLABS_FRONTEND
697 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
699 ShDestruct (impl
->_obj
.linker
);
700 ShDestruct (impl
->_obj
.uniforms
);
702 _container_destructor (intf
);
705 static struct gl2_unknown_intf
**
706 _program_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
708 if (uiid
== UIID_PROGRAM
)
710 (**intf
).AddRef (intf
);
713 return _container_QueryInterface (intf
, uiid
);
717 _program_GetType (struct gl2_generic_intf
**intf
)
719 return GL_PROGRAM_OBJECT_ARB
;
723 _program_Attach (struct gl2_container_intf
**intf
, struct gl2_generic_intf
**att
)
725 GET_CURRENT_CONTEXT(ctx
);
726 struct gl2_unknown_intf
**sha
;
728 sha
= (**att
)._unknown
.QueryInterface ((struct gl2_unknown_intf
**) att
, UIID_SHADER
);
731 _mesa_error (ctx
, GL_INVALID_OPERATION
, "_program_Attach");
735 (**sha
).Release (sha
);
736 return _container_Attach (intf
, att
);
740 _program_GetLinkStatus (struct gl2_program_intf
**intf
)
742 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
744 return impl
->_obj
.link_status
;
748 _program_GetValidateStatus (struct gl2_program_intf
**intf
)
750 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
752 return impl
->_obj
.validate_status
;
756 _program_Link (struct gl2_program_intf
**intf
)
758 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
759 #if USE_3DLABS_FRONTEND
764 impl
->_obj
.link_status
= GL_FALSE
;
765 _mesa_free ((void *) impl
->_obj
._container
._generic
.info_log
);
766 impl
->_obj
._container
._generic
.info_log
= NULL
;
768 #if USE_3DLABS_FRONTEND
769 handles
= (ShHandle
*) _mesa_malloc (impl
->_obj
._container
.attached_count
* sizeof (ShHandle
));
773 for (i
= 0; i
< impl
->_obj
._container
.attached_count
; i
++)
775 struct gl2_generic_intf
**gen
= impl
->_obj
._container
.attached
[i
];
776 struct gl2_3dlabs_shhandle_intf
**sh
;
778 sh
= (struct gl2_3dlabs_shhandle_intf
**) (**gen
)._unknown
.QueryInterface (
779 (struct gl2_unknown_intf
**) gen
, UIID_3DLABS_SHHANDLE
);
782 handles
[i
] = (**sh
).GetShHandle (sh
);
783 (**sh
)._unknown
.Release ((struct gl2_unknown_intf
**) sh
);
787 _mesa_free (handles
);
792 if (ShLink (impl
->_obj
.linker
, handles
, impl
->_obj
._container
.attached_count
,
793 impl
->_obj
.uniforms
, NULL
, NULL
))
794 impl
->_obj
.link_status
= GL_TRUE
;
796 impl
->_obj
._container
._generic
.info_log
= _mesa_strdup (ShGetInfoLog (impl
->_obj
.linker
));
801 _program_Validate (struct gl2_program_intf
**intf
)
803 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
805 impl
->_obj
.validate_status
= GL_FALSE
;
806 _mesa_free ((void *) impl
->_obj
._container
._generic
.info_log
);
807 impl
->_obj
._container
._generic
.info_log
= NULL
;
812 static struct gl2_program_intf _program_vftbl
= {
818 _program_QueryInterface
823 _generic_GetDeleteStatus
,
828 _container_GetAttachedCount
,
829 _container_GetAttached
831 _program_GetLinkStatus
,
832 _program_GetValidateStatus
,
838 _program_constructor (struct gl2_program_impl
*impl
)
840 _container_constructor ((struct gl2_container_impl
*) impl
);
841 impl
->_vftbl
= &_program_vftbl
;
842 impl
->_obj
._container
._generic
._unknown
._destructor
= _program_destructor
;
843 impl
->_obj
.link_status
= GL_FALSE
;
844 impl
->_obj
.validate_status
= GL_FALSE
;
845 #if USE_3DLABS_FRONTEND
846 impl
->_obj
.linker
= ShConstructLinker (EShExVertexFragment
, 0);
847 impl
->_obj
.uniforms
= ShConstructUniformMap ();
851 struct gl2_fragment_shader_obj
853 struct gl2_shader_obj _shader
;
856 struct gl2_fragment_shader_impl
858 struct gl2_fragment_shader_intf
*_vftbl
;
859 struct gl2_fragment_shader_obj _obj
;
863 _fragment_shader_destructor (struct gl2_unknown_intf
**intf
)
865 struct gl2_fragment_shader_impl
*impl
= (struct gl2_fragment_shader_impl
*) intf
;
868 /* TODO free fragment shader data */
870 _shader_destructor (intf
);
873 static struct gl2_unknown_intf
**
874 _fragment_shader_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
876 if (uiid
== UIID_FRAGMENT_SHADER
)
878 (**intf
).AddRef (intf
);
881 return _shader_QueryInterface (intf
, uiid
);
885 _fragment_shader_GetSubType (struct gl2_shader_intf
**intf
)
887 return GL_FRAGMENT_SHADER_ARB
;
890 static struct gl2_fragment_shader_intf _fragment_shader_vftbl
= {
896 _fragment_shader_QueryInterface
901 _generic_GetDeleteStatus
,
904 _fragment_shader_GetSubType
,
905 _shader_GetCompileStatus
,
913 _fragment_shader_constructor (struct gl2_fragment_shader_impl
*impl
)
915 _shader_constructor ((struct gl2_shader_impl
*) impl
);
916 impl
->_vftbl
= &_fragment_shader_vftbl
;
917 impl
->_obj
._shader
._generic
._unknown
._destructor
= _fragment_shader_destructor
;
918 #if USE_3DLABS_FRONTEND
919 impl
->_obj
._shader
._3dlabs_shhandle
._obj
.handle
= ShConstructCompiler (EShLangFragment
, 0);
923 struct gl2_vertex_shader_obj
925 struct gl2_shader_obj _shader
;
928 struct gl2_vertex_shader_impl
930 struct gl2_vertex_shader_intf
*_vftbl
;
931 struct gl2_vertex_shader_obj _obj
;
935 _vertex_shader_destructor (struct gl2_unknown_intf
**intf
)
937 struct gl2_vertex_shader_impl
*impl
= (struct gl2_vertex_shader_impl
*) intf
;
940 /* TODO free vertex shader data */
942 _shader_destructor (intf
);
945 static struct gl2_unknown_intf
**
946 _vertex_shader_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
948 if (uiid
== UIID_VERTEX_SHADER
)
950 (**intf
).AddRef (intf
);
953 return _shader_QueryInterface (intf
, uiid
);
957 _vertex_shader_GetSubType (struct gl2_shader_intf
**intf
)
959 return GL_VERTEX_SHADER_ARB
;
962 static struct gl2_vertex_shader_intf _vertex_shader_vftbl
= {
968 _vertex_shader_QueryInterface
973 _generic_GetDeleteStatus
,
976 _vertex_shader_GetSubType
,
977 _shader_GetCompileStatus
,
985 _vertex_shader_constructor (struct gl2_vertex_shader_impl
*impl
)
987 _shader_constructor ((struct gl2_shader_impl
*) impl
);
988 impl
->_vftbl
= &_vertex_shader_vftbl
;
989 impl
->_obj
._shader
._generic
._unknown
._destructor
= _vertex_shader_destructor
;
990 #if USE_3DLABS_FRONTEND
991 impl
->_obj
._shader
._3dlabs_shhandle
._obj
.handle
= ShConstructCompiler (EShLangVertex
, 0);
996 _mesa_3dlabs_create_shader_object (GLenum shaderType
)
1000 case GL_FRAGMENT_SHADER_ARB
:
1002 struct gl2_fragment_shader_impl
*x
= (struct gl2_fragment_shader_impl
*)
1003 _mesa_malloc (sizeof (struct gl2_fragment_shader_impl
));
1007 _fragment_shader_constructor (x
);
1008 return x
->_obj
._shader
._generic
.name
;
1012 case GL_VERTEX_SHADER_ARB
:
1014 struct gl2_vertex_shader_impl
*x
= (struct gl2_vertex_shader_impl
*)
1015 _mesa_malloc (sizeof (struct gl2_vertex_shader_impl
));
1019 _vertex_shader_constructor (x
);
1020 return x
->_obj
._shader
._generic
.name
;
1030 _mesa_3dlabs_create_program_object (void)
1032 struct gl2_program_impl
*x
= (struct gl2_program_impl
*)
1033 _mesa_malloc (sizeof (struct gl2_program_impl
));
1037 _program_constructor (x
);
1038 return x
->_obj
._container
._generic
.name
;
1045 _mesa_init_shaderobjects_3dlabs (GLcontext
*ctx
)
1047 #if USE_3DLABS_FRONTEND
1048 _glslang_3dlabs_InitProcess ();
1049 _glslang_3dlabs_ShInitialize ();