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
33 #include "shaderobjects.h"
34 #include "shaderobjects_3dlabs.h"
38 #include "slang_mesa.h"
39 #include "Public/ShaderLang.h"
41 struct gl2_unknown_obj
43 GLuint reference_count
;
44 void (* _destructor
) (struct gl2_unknown_intf
**);
47 struct gl2_unknown_impl
49 struct gl2_unknown_intf
*_vftbl
;
50 struct gl2_unknown_obj _obj
;
54 _unknown_destructor (struct gl2_unknown_intf
**intf
)
59 _unknown_AddRef (struct gl2_unknown_intf
**intf
)
61 struct gl2_unknown_impl
*impl
= (struct gl2_unknown_impl
*) intf
;
63 impl
->_obj
.reference_count
++;
67 _unknown_Release (struct gl2_unknown_intf
**intf
)
69 struct gl2_unknown_impl
*impl
= (struct gl2_unknown_impl
*) intf
;
71 impl
->_obj
.reference_count
--;
72 if (impl
->_obj
.reference_count
== 0)
74 impl
->_obj
._destructor (intf
);
75 _mesa_free ((void *) intf
);
79 static struct gl2_unknown_intf
**
80 _unknown_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
82 if (uiid
== UIID_UNKNOWN
)
84 (**intf
).AddRef (intf
);
90 static struct gl2_unknown_intf _unknown_vftbl
= {
93 _unknown_QueryInterface
97 _unknown_constructor (struct gl2_unknown_impl
*impl
)
99 impl
->_vftbl
= &_unknown_vftbl
;
100 impl
->_obj
.reference_count
= 1;
101 impl
->_obj
._destructor
= _unknown_destructor
;
104 struct gl2_unkinner_obj
106 struct gl2_unknown_intf
**unkouter
;
109 struct gl2_unkinner_impl
111 struct gl2_unknown_intf
*_vftbl
;
112 struct gl2_unkinner_obj _obj
;
116 _unkinner_destructor (struct gl2_unknown_intf
**intf
)
121 _unkinner_AddRef (struct gl2_unknown_intf
**intf
)
123 struct gl2_unkinner_impl
*impl
= (struct gl2_unkinner_impl
*) intf
;
125 (**impl
->_obj
.unkouter
).AddRef (impl
->_obj
.unkouter
);
129 _unkinner_Release (struct gl2_unknown_intf
**intf
)
131 struct gl2_unkinner_impl
*impl
= (struct gl2_unkinner_impl
*) intf
;
133 (**impl
->_obj
.unkouter
).Release (impl
->_obj
.unkouter
);
136 static struct gl2_unknown_intf
**
137 _unkinner_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
139 struct gl2_unkinner_impl
*impl
= (struct gl2_unkinner_impl
*) intf
;
141 return (**impl
->_obj
.unkouter
).QueryInterface (impl
->_obj
.unkouter
, uiid
);
144 static struct gl2_unknown_intf _unkinner_vftbl
= {
147 _unkinner_QueryInterface
151 _unkinner_constructor (struct gl2_unkinner_impl
*impl
, struct gl2_unknown_intf
**outer
)
153 impl
->_vftbl
= &_unkinner_vftbl
;
154 impl
->_obj
.unkouter
= outer
;
157 struct gl2_generic_obj
159 struct gl2_unknown_obj _unknown
;
161 GLboolean delete_status
;
165 struct gl2_generic_impl
167 struct gl2_generic_intf
*_vftbl
;
168 struct gl2_generic_obj _obj
;
172 _generic_destructor (struct gl2_unknown_intf
**intf
)
174 GET_CURRENT_CONTEXT(ctx
);
175 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
177 _mesa_free ((void *) impl
->_obj
.info_log
);
179 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
180 _mesa_HashRemove (ctx
->Shared
->GL2Objects
, impl
->_obj
.name
);
181 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
183 _unknown_destructor (intf
);
186 static struct gl2_unknown_intf
**
187 _generic_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
189 if (uiid
== UIID_GENERIC
)
191 (**intf
).AddRef (intf
);
194 return _unknown_QueryInterface (intf
, uiid
);
198 _generic_Delete (struct gl2_generic_intf
**intf
)
200 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
202 if (impl
->_obj
.delete_status
== GL_FALSE
)
204 impl
->_obj
.delete_status
= GL_TRUE
;
205 (**intf
)._unknown
.Release ((struct gl2_unknown_intf
**) intf
);
210 _generic_GetName (struct gl2_generic_intf
**intf
)
212 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
214 return impl
->_obj
.name
;
218 _generic_GetDeleteStatus (struct gl2_generic_intf
**intf
)
220 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
222 return impl
->_obj
.delete_status
;
225 static const GLcharARB
*
226 _generic_GetInfoLog (struct gl2_generic_intf
**intf
)
228 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
230 return impl
->_obj
.info_log
;
233 static struct gl2_generic_intf _generic_vftbl
= {
237 _generic_QueryInterface
240 NULL
, /* abstract GetType */
242 _generic_GetDeleteStatus
,
247 _generic_constructor (struct gl2_generic_impl
*impl
)
249 GET_CURRENT_CONTEXT(ctx
);
251 _unknown_constructor ((struct gl2_unknown_impl
*) impl
);
252 impl
->_vftbl
= &_generic_vftbl
;
253 impl
->_obj
._unknown
._destructor
= _generic_destructor
;
254 impl
->_obj
.delete_status
= GL_FALSE
;
255 impl
->_obj
.info_log
= NULL
;
257 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
258 impl
->_obj
.name
= _mesa_HashFindFreeKeyBlock (ctx
->Shared
->GL2Objects
, 1);
259 _mesa_HashInsert (ctx
->Shared
->GL2Objects
, impl
->_obj
.name
, (void *) impl
);
260 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
263 struct gl2_container_obj
265 struct gl2_generic_obj _generic
;
266 struct gl2_generic_intf
***attached
;
267 GLuint attached_count
;
270 struct gl2_container_impl
272 struct gl2_container_intf
*_vftbl
;
273 struct gl2_container_obj _obj
;
277 _container_destructor (struct gl2_unknown_intf
**intf
)
279 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
282 for (i
= 0; i
< impl
->_obj
.attached_count
; i
++)
284 struct gl2_generic_intf
**x
= impl
->_obj
.attached
[i
];
285 (**x
)._unknown
.Release ((struct gl2_unknown_intf
**) x
);
288 _generic_destructor (intf
);
291 static struct gl2_unknown_intf
**
292 _container_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
294 if (uiid
== UIID_CONTAINER
)
296 (**intf
).AddRef (intf
);
299 return _generic_QueryInterface (intf
, uiid
);
303 _container_Attach (struct gl2_container_intf
**intf
, struct gl2_generic_intf
**att
)
305 GET_CURRENT_CONTEXT(ctx
);
306 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
309 for (i
= 0; i
< impl
->_obj
.attached_count
; i
++)
310 if (impl
->_obj
.attached
[i
] == att
)
312 _mesa_error (ctx
, GL_INVALID_OPERATION
, "_container_Attach");
316 impl
->_obj
.attached
= (struct gl2_generic_intf
***) _mesa_realloc (impl
->_obj
.attached
,
317 impl
->_obj
.attached_count
* sizeof (*impl
->_obj
.attached
), (impl
->_obj
.attached_count
+ 1) *
318 sizeof (*impl
->_obj
.attached
));
319 if (impl
->_obj
.attached
== NULL
)
322 impl
->_obj
.attached
[impl
->_obj
.attached_count
] = att
;
323 impl
->_obj
.attached_count
++;
324 (**att
)._unknown
.AddRef ((struct gl2_unknown_intf
**) att
);
329 _container_Detach (struct gl2_container_intf
**intf
, struct gl2_generic_intf
**att
)
331 GET_CURRENT_CONTEXT(ctx
);
332 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
335 for (i
= 0; i
< impl
->_obj
.attached_count
; i
++)
336 if (impl
->_obj
.attached
[i
] == att
)
338 for (j
= i
; j
< impl
->_obj
.attached_count
- 1; j
++)
339 impl
->_obj
.attached
[j
] = impl
->_obj
.attached
[j
+ 1];
340 impl
->_obj
.attached
= (struct gl2_generic_intf
***) _mesa_realloc (impl
->_obj
.attached
,
341 impl
->_obj
.attached_count
* sizeof (*impl
->_obj
.attached
),
342 (impl
->_obj
.attached_count
- 1) * sizeof (*impl
->_obj
.attached
));
343 impl
->_obj
.attached_count
--;
344 (**att
)._unknown
.Release ((struct gl2_unknown_intf
**) att
);
348 _mesa_error (ctx
, GL_INVALID_OPERATION
, "_container_Detach");
353 _container_GetAttachedCount (struct gl2_container_intf
**intf
)
355 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
357 return impl
->_obj
.attached_count
;
360 static struct gl2_generic_intf
**
361 _container_GetAttached (struct gl2_container_intf
**intf
, GLuint index
)
363 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
365 (**impl
->_obj
.attached
[index
])._unknown
.AddRef (
366 (struct gl2_unknown_intf
**)impl
->_obj
.attached
[index
]);
367 return impl
->_obj
.attached
[index
];
370 static struct gl2_container_intf _container_vftbl
= {
375 _container_QueryInterface
378 NULL
, /* abstract GetType */
380 _generic_GetDeleteStatus
,
385 _container_GetAttachedCount
,
386 _container_GetAttached
390 _container_constructor (struct gl2_container_impl
*impl
)
392 _generic_constructor ((struct gl2_generic_impl
*) impl
);
393 impl
->_vftbl
= &_container_vftbl
;
394 impl
->_obj
._generic
._unknown
._destructor
= _container_destructor
;
395 impl
->_obj
.attached
= NULL
;
396 impl
->_obj
.attached_count
= 0;
399 struct gl2_3dlabs_shhandle_obj
401 struct gl2_unkinner_obj _unknown
;
405 struct gl2_3dlabs_shhandle_impl
407 struct gl2_3dlabs_shhandle_intf
*_vftbl
;
408 struct gl2_3dlabs_shhandle_obj _obj
;
412 _3dlabs_shhandle_destructor (struct gl2_unknown_intf
**intf
)
414 struct gl2_3dlabs_shhandle_impl
*impl
= (struct gl2_3dlabs_shhandle_impl
*) intf
;
416 ShDestruct (impl
->_obj
.handle
);
417 _unkinner_destructor (intf
);
421 _3dlabs_shhandle_GetShHandle (struct gl2_3dlabs_shhandle_intf
**intf
)
423 struct gl2_3dlabs_shhandle_impl
*impl
= (struct gl2_3dlabs_shhandle_impl
*) intf
;
425 return impl
->_obj
.handle
;
428 static struct gl2_3dlabs_shhandle_intf _3dlabs_shhandle_vftbl
= {
432 _unkinner_QueryInterface
434 _3dlabs_shhandle_GetShHandle
438 _3dlabs_shhandle_constructor (struct gl2_3dlabs_shhandle_impl
*impl
, struct gl2_unknown_intf
**outer
)
440 _unkinner_constructor ((struct gl2_unkinner_impl
*) impl
, outer
);
441 impl
->_vftbl
= &_3dlabs_shhandle_vftbl
;
442 impl
->_obj
.handle
= NULL
;
445 struct gl2_shader_obj
447 struct gl2_generic_obj _generic
;
448 struct gl2_3dlabs_shhandle_impl _3dlabs_shhandle
;
449 GLboolean compile_status
;
452 GLsizei offset_count
;
455 struct gl2_shader_impl
457 struct gl2_shader_intf
*_vftbl
;
458 struct gl2_shader_obj _obj
;
462 _shader_destructor (struct gl2_unknown_intf
**intf
)
464 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
466 _mesa_free ((void *) impl
->_obj
.source
);
467 _mesa_free ((void *) impl
->_obj
.offsets
);
468 _3dlabs_shhandle_destructor ((struct gl2_unknown_intf
**) &impl
->_obj
._3dlabs_shhandle
._vftbl
);
469 _generic_destructor (intf
);
472 static struct gl2_unknown_intf
**
473 _shader_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
475 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
477 if (uiid
== UIID_SHADER
)
479 (**intf
).AddRef (intf
);
482 if (uiid
== UIID_3DLABS_SHHANDLE
)
484 (**intf
).AddRef (intf
);
485 return (struct gl2_unknown_intf
**) &impl
->_obj
._3dlabs_shhandle
._vftbl
;
487 return _generic_QueryInterface (intf
, uiid
);
491 _shader_GetType (struct gl2_generic_intf
**intf
)
493 return GL_SHADER_OBJECT_ARB
;
497 _shader_GetCompileStatus (struct gl2_shader_intf
**intf
)
499 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
501 return impl
->_obj
.compile_status
;
505 _shader_SetSource (struct gl2_shader_intf
**intf
, GLcharARB
*src
, GLint
*off
, GLsizei cnt
)
507 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
509 _mesa_free ((void *) impl
->_obj
.source
);
510 impl
->_obj
.source
= src
;
511 _mesa_free ((void *) impl
->_obj
.offsets
);
512 impl
->_obj
.offsets
= off
;
513 impl
->_obj
.offset_count
= cnt
;
516 static const GLcharARB
*
517 _shader_GetSource (struct gl2_shader_intf
**intf
)
519 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
521 return impl
->_obj
.source
;
525 _shader_Compile (struct gl2_shader_intf
**intf
)
527 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
529 TBuiltInResource res
;
531 impl
->_obj
.compile_status
= GL_FALSE
;
532 _mesa_free ((void *) impl
->_obj
._generic
.info_log
);
533 impl
->_obj
._generic
.info_log
= NULL
;
535 /* 3dlabs compiler expects us to feed it with null-terminated string array,
536 we've got only one big string with offsets, so we must split it; but when
537 there's only one string to deal with, we pass its address directly */
539 if (impl
->_obj
.offset_count
<= 1)
540 strings
= &impl
->_obj
.source
;
543 GLsizei i
, offset
= 0;
545 strings
= (char **) _mesa_malloc (impl
->_obj
.offset_count
* sizeof (char *));
549 for (i
= 0; i
< impl
->_obj
.offset_count
; i
++)
551 GLsizei size
= impl
->_obj
.offsets
[i
] - offset
;
553 strings
[i
] = (char *) _mesa_malloc ((size
+ 1) * sizeof (char));
554 if (strings
[i
] == NULL
)
558 for (j
= 0; j
< i
; j
++)
559 _mesa_free (strings
[j
]);
560 _mesa_free (strings
);
564 _mesa_memcpy (strings
[i
], impl
->_obj
.source
+ offset
, size
* sizeof (char));
565 strings
[i
][size
] = '\0';
566 offset
= impl
->_obj
.offsets
[i
];
570 /* TODO set these fields to some REAL numbers */
572 res
.maxClipPlanes
= 6;
573 res
.maxTextureUnits
= 2;
574 res
.maxTextureCoords
= 2;
575 res
.maxVertexAttribs
= 8;
576 res
.maxVertexUniformComponents
= 64;
577 res
.maxVaryingFloats
= 8;
578 res
.maxVertexTextureImageUnits
= 2;
579 res
.maxCombinedTextureImageUnits
= 2;
580 res
.maxTextureImageUnits
= 2;
581 res
.maxFragmentUniformComponents
= 64;
582 res
.maxDrawBuffers
= 1;
584 if (ShCompile (impl
->_obj
._3dlabs_shhandle
._obj
.handle
, strings
, impl
->_obj
.offset_count
,
585 EShOptFull
, &res
, 0))
586 impl
->_obj
.compile_status
= GL_TRUE
;
588 if (impl
->_obj
.offset_count
> 1)
592 for (i
= 0; i
< impl
->_obj
.offset_count
; i
++)
593 _mesa_free (strings
[i
]);
594 _mesa_free (strings
);
597 impl
->_obj
._generic
.info_log
= _mesa_strdup (ShGetInfoLog (
598 impl
->_obj
._3dlabs_shhandle
._obj
.handle
));
601 static struct gl2_shader_intf _shader_vftbl
= {
606 _shader_QueryInterface
611 _generic_GetDeleteStatus
,
614 NULL
, /* abstract GetSubType */
615 _shader_GetCompileStatus
,
622 _shader_constructor (struct gl2_shader_impl
*impl
)
624 _generic_constructor ((struct gl2_generic_impl
*) impl
);
625 _3dlabs_shhandle_constructor (&impl
->_obj
._3dlabs_shhandle
, (struct gl2_unknown_intf
**)
627 impl
->_vftbl
= &_shader_vftbl
;
628 impl
->_obj
._generic
._unknown
._destructor
= _shader_destructor
;
629 impl
->_obj
.compile_status
= GL_FALSE
;
630 impl
->_obj
.source
= NULL
;
631 impl
->_obj
.offsets
= NULL
;
632 impl
->_obj
.offset_count
= 0;
635 struct gl2_program_obj
637 struct gl2_container_obj _container
;
638 GLboolean link_status
;
639 GLboolean validate_status
;
644 struct gl2_program_impl
646 struct gl2_program_intf
*_vftbl
;
647 struct gl2_program_obj _obj
;
651 _program_destructor (struct gl2_unknown_intf
**intf
)
653 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
655 ShDestruct (impl
->_obj
.linker
);
656 ShDestruct (impl
->_obj
.uniforms
);
657 _container_destructor (intf
);
660 static struct gl2_unknown_intf
**
661 _program_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
663 if (uiid
== UIID_PROGRAM
)
665 (**intf
).AddRef (intf
);
668 return _container_QueryInterface (intf
, uiid
);
672 _program_GetType (struct gl2_generic_intf
**intf
)
674 return GL_PROGRAM_OBJECT_ARB
;
678 _program_Attach (struct gl2_container_intf
**intf
, struct gl2_generic_intf
**att
)
680 GET_CURRENT_CONTEXT(ctx
);
681 struct gl2_unknown_intf
**sha
;
683 sha
= (**att
)._unknown
.QueryInterface ((struct gl2_unknown_intf
**) att
, UIID_SHADER
);
686 _mesa_error (ctx
, GL_INVALID_OPERATION
, "_program_Attach");
690 (**sha
).Release (sha
);
691 return _container_Attach (intf
, att
);
695 _program_GetLinkStatus (struct gl2_program_intf
**intf
)
697 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
699 return impl
->_obj
.link_status
;
703 _program_GetValidateStatus (struct gl2_program_intf
**intf
)
705 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
707 return impl
->_obj
.validate_status
;
711 _program_Link (struct gl2_program_intf
**intf
)
713 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
717 impl
->_obj
.link_status
= GL_FALSE
;
718 _mesa_free ((void *) impl
->_obj
._container
._generic
.info_log
);
719 impl
->_obj
._container
._generic
.info_log
= NULL
;
721 handles
= (ShHandle
*) _mesa_malloc (impl
->_obj
._container
.attached_count
* sizeof (ShHandle
));
725 for (i
= 0; i
< impl
->_obj
._container
.attached_count
; i
++)
727 struct gl2_generic_intf
**gen
= impl
->_obj
._container
.attached
[i
];
728 struct gl2_3dlabs_shhandle_intf
**sh
;
730 sh
= (struct gl2_3dlabs_shhandle_intf
**) (**gen
)._unknown
.QueryInterface (
731 (struct gl2_unknown_intf
**) gen
, UIID_3DLABS_SHHANDLE
);
734 handles
[i
] = (**sh
).GetShHandle (sh
);
735 (**sh
)._unknown
.Release ((struct gl2_unknown_intf
**) sh
);
739 _mesa_free (handles
);
744 if (ShLink (impl
->_obj
.linker
, handles
, impl
->_obj
._container
.attached_count
,
745 impl
->_obj
.uniforms
, NULL
, NULL
))
746 impl
->_obj
.link_status
= GL_TRUE
;
748 impl
->_obj
._container
._generic
.info_log
= _mesa_strdup (ShGetInfoLog (impl
->_obj
.linker
));
752 _program_Validate (struct gl2_program_intf
**intf
)
754 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
756 impl
->_obj
.validate_status
= GL_FALSE
;
757 _mesa_free ((void *) impl
->_obj
._container
._generic
.info_log
);
758 impl
->_obj
._container
._generic
.info_log
= NULL
;
763 static struct gl2_program_intf _program_vftbl
= {
769 _program_QueryInterface
774 _generic_GetDeleteStatus
,
779 _container_GetAttachedCount
,
780 _container_GetAttached
782 _program_GetLinkStatus
,
783 _program_GetValidateStatus
,
789 _program_constructor (struct gl2_program_impl
*impl
)
791 _container_constructor ((struct gl2_container_impl
*) impl
);
792 impl
->_vftbl
= &_program_vftbl
;
793 impl
->_obj
._container
._generic
._unknown
._destructor
= _program_destructor
;
794 impl
->_obj
.link_status
= GL_FALSE
;
795 impl
->_obj
.validate_status
= GL_FALSE
;
796 impl
->_obj
.linker
= ShConstructLinker (EShExVertexFragment
, 0);
797 impl
->_obj
.uniforms
= ShConstructUniformMap ();
800 struct gl2_fragment_shader_obj
802 struct gl2_shader_obj _shader
;
805 struct gl2_fragment_shader_impl
807 struct gl2_fragment_shader_intf
*_vftbl
;
808 struct gl2_fragment_shader_obj _obj
;
812 _fragment_shader_destructor (struct gl2_unknown_intf
**intf
)
814 struct gl2_fragment_shader_impl
*impl
= (struct gl2_fragment_shader_impl
*) intf
;
817 /* TODO free fragment shader data */
819 _shader_destructor (intf
);
822 static struct gl2_unknown_intf
**
823 _fragment_shader_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
825 if (uiid
== UIID_FRAGMENT_SHADER
)
827 (**intf
).AddRef (intf
);
830 return _shader_QueryInterface (intf
, uiid
);
834 _fragment_shader_GetSubType (struct gl2_shader_intf
**intf
)
836 return GL_FRAGMENT_SHADER_ARB
;
839 static struct gl2_fragment_shader_intf _fragment_shader_vftbl
= {
845 _fragment_shader_QueryInterface
850 _generic_GetDeleteStatus
,
853 _fragment_shader_GetSubType
,
854 _shader_GetCompileStatus
,
862 _fragment_shader_constructor (struct gl2_fragment_shader_impl
*impl
)
864 _shader_constructor ((struct gl2_shader_impl
*) impl
);
865 impl
->_vftbl
= &_fragment_shader_vftbl
;
866 impl
->_obj
._shader
._generic
._unknown
._destructor
= _fragment_shader_destructor
;
867 impl
->_obj
._shader
._3dlabs_shhandle
._obj
.handle
= ShConstructCompiler (EShLangFragment
, 0);
870 struct gl2_vertex_shader_obj
872 struct gl2_shader_obj _shader
;
875 struct gl2_vertex_shader_impl
877 struct gl2_vertex_shader_intf
*_vftbl
;
878 struct gl2_vertex_shader_obj _obj
;
882 _vertex_shader_destructor (struct gl2_unknown_intf
**intf
)
884 struct gl2_vertex_shader_impl
*impl
= (struct gl2_vertex_shader_impl
*) intf
;
887 /* TODO free vertex shader data */
889 _shader_destructor (intf
);
892 static struct gl2_unknown_intf
**
893 _vertex_shader_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
895 if (uiid
== UIID_VERTEX_SHADER
)
897 (**intf
).AddRef (intf
);
900 return _shader_QueryInterface (intf
, uiid
);
904 _vertex_shader_GetSubType (struct gl2_shader_intf
**intf
)
906 return GL_VERTEX_SHADER_ARB
;
909 static struct gl2_vertex_shader_intf _vertex_shader_vftbl
= {
915 _vertex_shader_QueryInterface
920 _generic_GetDeleteStatus
,
923 _vertex_shader_GetSubType
,
924 _shader_GetCompileStatus
,
932 _vertex_shader_constructor (struct gl2_vertex_shader_impl
*impl
)
934 _shader_constructor ((struct gl2_shader_impl
*) impl
);
935 impl
->_vftbl
= &_vertex_shader_vftbl
;
936 impl
->_obj
._shader
._generic
._unknown
._destructor
= _vertex_shader_destructor
;
937 impl
->_obj
._shader
._3dlabs_shhandle
._obj
.handle
= ShConstructCompiler (EShLangVertex
, 0);
941 _mesa_3dlabs_create_shader_object (GLenum shaderType
)
945 case GL_FRAGMENT_SHADER_ARB
:
947 struct gl2_fragment_shader_impl
*x
= (struct gl2_fragment_shader_impl
*)
948 _mesa_malloc (sizeof (struct gl2_fragment_shader_impl
));
952 _fragment_shader_constructor (x
);
953 return x
->_obj
._shader
._generic
.name
;
957 case GL_VERTEX_SHADER_ARB
:
959 struct gl2_vertex_shader_impl
*x
= (struct gl2_vertex_shader_impl
*)
960 _mesa_malloc (sizeof (struct gl2_vertex_shader_impl
));
964 _vertex_shader_constructor (x
);
965 return x
->_obj
._shader
._generic
.name
;
975 _mesa_3dlabs_create_program_object (void)
977 struct gl2_program_impl
*x
= (struct gl2_program_impl
*)
978 _mesa_malloc (sizeof (struct gl2_program_impl
));
982 _program_constructor (x
);
983 return x
->_obj
._container
._generic
.name
;
990 _mesa_init_shaderobjects_3dlabs (GLcontext
*ctx
)
992 _glslang_3dlabs_InitProcess ();
993 _glslang_3dlabs_ShInitialize ();