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"
46 struct gl2_unknown_obj
48 GLuint reference_count
;
49 void (* _destructor
) (struct gl2_unknown_intf
**);
52 struct gl2_unknown_impl
54 struct gl2_unknown_intf
*_vftbl
;
55 struct gl2_unknown_obj _obj
;
59 _unknown_destructor (struct gl2_unknown_intf
**intf
)
64 _unknown_AddRef (struct gl2_unknown_intf
**intf
)
66 struct gl2_unknown_impl
*impl
= (struct gl2_unknown_impl
*) intf
;
68 impl
->_obj
.reference_count
++;
72 _unknown_Release (struct gl2_unknown_intf
**intf
)
74 struct gl2_unknown_impl
*impl
= (struct gl2_unknown_impl
*) intf
;
76 impl
->_obj
.reference_count
--;
77 if (impl
->_obj
.reference_count
== 0)
79 impl
->_obj
._destructor (intf
);
80 _mesa_free ((void *) intf
);
84 static struct gl2_unknown_intf
**
85 _unknown_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
87 if (uiid
== UIID_UNKNOWN
)
89 (**intf
).AddRef (intf
);
95 static struct gl2_unknown_intf _unknown_vftbl
= {
98 _unknown_QueryInterface
102 _unknown_constructor (struct gl2_unknown_impl
*impl
)
104 impl
->_vftbl
= &_unknown_vftbl
;
105 impl
->_obj
.reference_count
= 1;
106 impl
->_obj
._destructor
= _unknown_destructor
;
109 struct gl2_unkinner_obj
111 struct gl2_unknown_intf
**unkouter
;
114 struct gl2_unkinner_impl
116 struct gl2_unknown_intf
*_vftbl
;
117 struct gl2_unkinner_obj _obj
;
121 _unkinner_destructor (struct gl2_unknown_intf
**intf
)
126 _unkinner_AddRef (struct gl2_unknown_intf
**intf
)
128 struct gl2_unkinner_impl
*impl
= (struct gl2_unkinner_impl
*) intf
;
130 (**impl
->_obj
.unkouter
).AddRef (impl
->_obj
.unkouter
);
134 _unkinner_Release (struct gl2_unknown_intf
**intf
)
136 struct gl2_unkinner_impl
*impl
= (struct gl2_unkinner_impl
*) intf
;
138 (**impl
->_obj
.unkouter
).Release (impl
->_obj
.unkouter
);
141 static struct gl2_unknown_intf
**
142 _unkinner_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
144 struct gl2_unkinner_impl
*impl
= (struct gl2_unkinner_impl
*) intf
;
146 return (**impl
->_obj
.unkouter
).QueryInterface (impl
->_obj
.unkouter
, uiid
);
149 static struct gl2_unknown_intf _unkinner_vftbl
= {
152 _unkinner_QueryInterface
156 _unkinner_constructor (struct gl2_unkinner_impl
*impl
, struct gl2_unknown_intf
**outer
)
158 impl
->_vftbl
= &_unkinner_vftbl
;
159 impl
->_obj
.unkouter
= outer
;
162 struct gl2_generic_obj
164 struct gl2_unknown_obj _unknown
;
166 GLboolean delete_status
;
170 struct gl2_generic_impl
172 struct gl2_generic_intf
*_vftbl
;
173 struct gl2_generic_obj _obj
;
177 _generic_destructor (struct gl2_unknown_intf
**intf
)
179 GET_CURRENT_CONTEXT(ctx
);
180 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
182 _mesa_free ((void *) impl
->_obj
.info_log
);
184 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
185 _mesa_HashRemove (ctx
->Shared
->GL2Objects
, impl
->_obj
.name
);
186 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
188 _unknown_destructor (intf
);
191 static struct gl2_unknown_intf
**
192 _generic_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
194 if (uiid
== UIID_GENERIC
)
196 (**intf
).AddRef (intf
);
199 return _unknown_QueryInterface (intf
, uiid
);
203 _generic_Delete (struct gl2_generic_intf
**intf
)
205 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
207 if (impl
->_obj
.delete_status
== GL_FALSE
)
209 impl
->_obj
.delete_status
= GL_TRUE
;
210 (**intf
)._unknown
.Release ((struct gl2_unknown_intf
**) intf
);
215 _generic_GetName (struct gl2_generic_intf
**intf
)
217 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
219 return impl
->_obj
.name
;
223 _generic_GetDeleteStatus (struct gl2_generic_intf
**intf
)
225 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
227 return impl
->_obj
.delete_status
;
230 static const GLcharARB
*
231 _generic_GetInfoLog (struct gl2_generic_intf
**intf
)
233 struct gl2_generic_impl
*impl
= (struct gl2_generic_impl
*) intf
;
235 return impl
->_obj
.info_log
;
238 static struct gl2_generic_intf _generic_vftbl
= {
242 _generic_QueryInterface
245 NULL
, /* abstract GetType */
247 _generic_GetDeleteStatus
,
252 _generic_constructor (struct gl2_generic_impl
*impl
)
254 GET_CURRENT_CONTEXT(ctx
);
256 _unknown_constructor ((struct gl2_unknown_impl
*) impl
);
257 impl
->_vftbl
= &_generic_vftbl
;
258 impl
->_obj
._unknown
._destructor
= _generic_destructor
;
259 impl
->_obj
.delete_status
= GL_FALSE
;
260 impl
->_obj
.info_log
= NULL
;
262 _glthread_LOCK_MUTEX (ctx
->Shared
->Mutex
);
263 impl
->_obj
.name
= _mesa_HashFindFreeKeyBlock (ctx
->Shared
->GL2Objects
, 1);
264 _mesa_HashInsert (ctx
->Shared
->GL2Objects
, impl
->_obj
.name
, (void *) impl
);
265 _glthread_UNLOCK_MUTEX (ctx
->Shared
->Mutex
);
268 struct gl2_container_obj
270 struct gl2_generic_obj _generic
;
271 struct gl2_generic_intf
***attached
;
272 GLuint attached_count
;
275 struct gl2_container_impl
277 struct gl2_container_intf
*_vftbl
;
278 struct gl2_container_obj _obj
;
282 _container_destructor (struct gl2_unknown_intf
**intf
)
284 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
287 for (i
= 0; i
< impl
->_obj
.attached_count
; i
++)
289 struct gl2_generic_intf
**x
= impl
->_obj
.attached
[i
];
290 (**x
)._unknown
.Release ((struct gl2_unknown_intf
**) x
);
293 _generic_destructor (intf
);
296 static struct gl2_unknown_intf
**
297 _container_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
299 if (uiid
== UIID_CONTAINER
)
301 (**intf
).AddRef (intf
);
304 return _generic_QueryInterface (intf
, uiid
);
308 _container_Attach (struct gl2_container_intf
**intf
, struct gl2_generic_intf
**att
)
310 GET_CURRENT_CONTEXT(ctx
);
311 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
314 for (i
= 0; i
< impl
->_obj
.attached_count
; i
++)
315 if (impl
->_obj
.attached
[i
] == att
)
317 _mesa_error (ctx
, GL_INVALID_OPERATION
, "_container_Attach");
321 impl
->_obj
.attached
= (struct gl2_generic_intf
***) _mesa_realloc (impl
->_obj
.attached
,
322 impl
->_obj
.attached_count
* sizeof (*impl
->_obj
.attached
), (impl
->_obj
.attached_count
+ 1) *
323 sizeof (*impl
->_obj
.attached
));
324 if (impl
->_obj
.attached
== NULL
)
327 impl
->_obj
.attached
[impl
->_obj
.attached_count
] = att
;
328 impl
->_obj
.attached_count
++;
329 (**att
)._unknown
.AddRef ((struct gl2_unknown_intf
**) att
);
334 _container_Detach (struct gl2_container_intf
**intf
, struct gl2_generic_intf
**att
)
336 GET_CURRENT_CONTEXT(ctx
);
337 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
340 for (i
= 0; i
< impl
->_obj
.attached_count
; i
++)
341 if (impl
->_obj
.attached
[i
] == att
)
343 for (j
= i
; j
< impl
->_obj
.attached_count
- 1; j
++)
344 impl
->_obj
.attached
[j
] = impl
->_obj
.attached
[j
+ 1];
345 impl
->_obj
.attached
= (struct gl2_generic_intf
***) _mesa_realloc (impl
->_obj
.attached
,
346 impl
->_obj
.attached_count
* sizeof (*impl
->_obj
.attached
),
347 (impl
->_obj
.attached_count
- 1) * sizeof (*impl
->_obj
.attached
));
348 impl
->_obj
.attached_count
--;
349 (**att
)._unknown
.Release ((struct gl2_unknown_intf
**) att
);
353 _mesa_error (ctx
, GL_INVALID_OPERATION
, "_container_Detach");
358 _container_GetAttachedCount (struct gl2_container_intf
**intf
)
360 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
362 return impl
->_obj
.attached_count
;
365 static struct gl2_generic_intf
**
366 _container_GetAttached (struct gl2_container_intf
**intf
, GLuint index
)
368 struct gl2_container_impl
*impl
= (struct gl2_container_impl
*) intf
;
370 (**impl
->_obj
.attached
[index
])._unknown
.AddRef (
371 (struct gl2_unknown_intf
**)impl
->_obj
.attached
[index
]);
372 return impl
->_obj
.attached
[index
];
375 static struct gl2_container_intf _container_vftbl
= {
380 _container_QueryInterface
383 NULL
, /* abstract GetType */
385 _generic_GetDeleteStatus
,
390 _container_GetAttachedCount
,
391 _container_GetAttached
395 _container_constructor (struct gl2_container_impl
*impl
)
397 _generic_constructor ((struct gl2_generic_impl
*) impl
);
398 impl
->_vftbl
= &_container_vftbl
;
399 impl
->_obj
._generic
._unknown
._destructor
= _container_destructor
;
400 impl
->_obj
.attached
= NULL
;
401 impl
->_obj
.attached_count
= 0;
404 struct gl2_3dlabs_shhandle_obj
406 struct gl2_unkinner_obj _unknown
;
407 #if USE_3DLABS_FRONTEND
412 struct gl2_3dlabs_shhandle_impl
414 struct gl2_3dlabs_shhandle_intf
*_vftbl
;
415 struct gl2_3dlabs_shhandle_obj _obj
;
419 _3dlabs_shhandle_destructor (struct gl2_unknown_intf
**intf
)
421 #if USE_3DLABS_FRONTEND
422 struct gl2_3dlabs_shhandle_impl
*impl
= (struct gl2_3dlabs_shhandle_impl
*) intf
;
423 ShDestruct (impl
->_obj
.handle
);
425 _unkinner_destructor (intf
);
429 _3dlabs_shhandle_GetShHandle (struct gl2_3dlabs_shhandle_intf
**intf
)
431 #if USE_3DLABS_FRONTEND
432 struct gl2_3dlabs_shhandle_impl
*impl
= (struct gl2_3dlabs_shhandle_impl
*) intf
;
433 return impl
->_obj
.handle
;
439 static struct gl2_3dlabs_shhandle_intf _3dlabs_shhandle_vftbl
= {
443 _unkinner_QueryInterface
445 _3dlabs_shhandle_GetShHandle
449 _3dlabs_shhandle_constructor (struct gl2_3dlabs_shhandle_impl
*impl
, struct gl2_unknown_intf
**outer
)
451 _unkinner_constructor ((struct gl2_unkinner_impl
*) impl
, outer
);
452 impl
->_vftbl
= &_3dlabs_shhandle_vftbl
;
453 #if USE_3DLABS_FRONTEND
454 impl
->_obj
.handle
= NULL
;
458 struct gl2_shader_obj
460 struct gl2_generic_obj _generic
;
461 struct gl2_3dlabs_shhandle_impl _3dlabs_shhandle
;
462 GLboolean compile_status
;
465 GLsizei offset_count
;
468 struct gl2_shader_impl
470 struct gl2_shader_intf
*_vftbl
;
471 struct gl2_shader_obj _obj
;
475 _shader_destructor (struct gl2_unknown_intf
**intf
)
477 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
479 _mesa_free ((void *) impl
->_obj
.source
);
480 _mesa_free ((void *) impl
->_obj
.offsets
);
481 _3dlabs_shhandle_destructor ((struct gl2_unknown_intf
**) &impl
->_obj
._3dlabs_shhandle
._vftbl
);
482 _generic_destructor (intf
);
485 static struct gl2_unknown_intf
**
486 _shader_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
488 #if USE_3DLABS_FRONTEND
489 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
492 if (uiid
== UIID_SHADER
)
494 (**intf
).AddRef (intf
);
497 #if USE_3DLABS_FRONTEND
498 if (uiid
== UIID_3DLABS_SHHANDLE
)
500 (**intf
).AddRef (intf
);
501 return (struct gl2_unknown_intf
**) &impl
->_obj
._3dlabs_shhandle
._vftbl
;
504 return _generic_QueryInterface (intf
, uiid
);
508 _shader_GetType (struct gl2_generic_intf
**intf
)
510 return GL_SHADER_OBJECT_ARB
;
514 _shader_GetCompileStatus (struct gl2_shader_intf
**intf
)
516 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
518 return impl
->_obj
.compile_status
;
522 _shader_SetSource (struct gl2_shader_intf
**intf
, GLcharARB
*src
, GLint
*off
, GLsizei cnt
)
524 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
526 _mesa_free ((void *) impl
->_obj
.source
);
527 impl
->_obj
.source
= src
;
528 _mesa_free ((void *) impl
->_obj
.offsets
);
529 impl
->_obj
.offsets
= off
;
530 impl
->_obj
.offset_count
= cnt
;
533 static const GLcharARB
*
534 _shader_GetSource (struct gl2_shader_intf
**intf
)
536 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
538 return impl
->_obj
.source
;
542 _shader_Compile (struct gl2_shader_intf
**intf
)
544 struct gl2_shader_impl
*impl
= (struct gl2_shader_impl
*) intf
;
545 #if USE_3DLABS_FRONTEND
547 TBuiltInResource res
;
550 impl
->_obj
.compile_status
= GL_FALSE
;
551 _mesa_free ((void *) impl
->_obj
._generic
.info_log
);
552 impl
->_obj
._generic
.info_log
= NULL
;
554 #if USE_3DLABS_FRONTEND
555 /* 3dlabs compiler expects us to feed it with null-terminated string array,
556 we've got only one big string with offsets, so we must split it; but when
557 there's only one string to deal with, we pass its address directly */
559 if (impl
->_obj
.offset_count
<= 1)
560 strings
= &impl
->_obj
.source
;
563 GLsizei i
, offset
= 0;
565 strings
= (char **) _mesa_malloc (impl
->_obj
.offset_count
* sizeof (char *));
569 for (i
= 0; i
< impl
->_obj
.offset_count
; i
++)
571 GLsizei size
= impl
->_obj
.offsets
[i
] - offset
;
573 strings
[i
] = (char *) _mesa_malloc ((size
+ 1) * sizeof (char));
574 if (strings
[i
] == NULL
)
578 for (j
= 0; j
< i
; j
++)
579 _mesa_free (strings
[j
]);
580 _mesa_free (strings
);
584 _mesa_memcpy (strings
[i
], impl
->_obj
.source
+ offset
, size
* sizeof (char));
585 strings
[i
][size
] = '\0';
586 offset
= impl
->_obj
.offsets
[i
];
590 /* TODO set these fields to some REAL numbers */
592 res
.maxClipPlanes
= 6;
593 res
.maxTextureUnits
= 2;
594 res
.maxTextureCoords
= 2;
595 res
.maxVertexAttribs
= 8;
596 res
.maxVertexUniformComponents
= 64;
597 res
.maxVaryingFloats
= 8;
598 res
.maxVertexTextureImageUnits
= 2;
599 res
.maxCombinedTextureImageUnits
= 2;
600 res
.maxTextureImageUnits
= 2;
601 res
.maxFragmentUniformComponents
= 64;
602 res
.maxDrawBuffers
= 1;
604 if (ShCompile (impl
->_obj
._3dlabs_shhandle
._obj
.handle
, strings
, impl
->_obj
.offset_count
,
605 EShOptFull
, &res
, 0))
606 impl
->_obj
.compile_status
= GL_TRUE
;
607 if (impl
->_obj
.offset_count
> 1)
611 for (i
= 0; i
< impl
->_obj
.offset_count
; i
++)
612 _mesa_free (strings
[i
]);
613 _mesa_free (strings
);
616 impl
->_obj
._generic
.info_log
= _mesa_strdup (ShGetInfoLog (
617 impl
->_obj
._3dlabs_shhandle
._obj
.handle
));
621 static struct gl2_shader_intf _shader_vftbl
= {
626 _shader_QueryInterface
631 _generic_GetDeleteStatus
,
634 NULL
, /* abstract GetSubType */
635 _shader_GetCompileStatus
,
642 _shader_constructor (struct gl2_shader_impl
*impl
)
644 _generic_constructor ((struct gl2_generic_impl
*) impl
);
645 _3dlabs_shhandle_constructor (&impl
->_obj
._3dlabs_shhandle
, (struct gl2_unknown_intf
**)
647 impl
->_vftbl
= &_shader_vftbl
;
648 impl
->_obj
._generic
._unknown
._destructor
= _shader_destructor
;
649 impl
->_obj
.compile_status
= GL_FALSE
;
650 impl
->_obj
.source
= NULL
;
651 impl
->_obj
.offsets
= NULL
;
652 impl
->_obj
.offset_count
= 0;
655 struct gl2_program_obj
657 struct gl2_container_obj _container
;
658 GLboolean link_status
;
659 GLboolean validate_status
;
660 #if USE_3DLABS_FRONTEND
666 struct gl2_program_impl
668 struct gl2_program_intf
*_vftbl
;
669 struct gl2_program_obj _obj
;
673 _program_destructor (struct gl2_unknown_intf
**intf
)
675 #if USE_3DLABS_FRONTEND
676 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
678 ShDestruct (impl
->_obj
.linker
);
679 ShDestruct (impl
->_obj
.uniforms
);
681 _container_destructor (intf
);
684 static struct gl2_unknown_intf
**
685 _program_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
687 if (uiid
== UIID_PROGRAM
)
689 (**intf
).AddRef (intf
);
692 return _container_QueryInterface (intf
, uiid
);
696 _program_GetType (struct gl2_generic_intf
**intf
)
698 return GL_PROGRAM_OBJECT_ARB
;
702 _program_Attach (struct gl2_container_intf
**intf
, struct gl2_generic_intf
**att
)
704 GET_CURRENT_CONTEXT(ctx
);
705 struct gl2_unknown_intf
**sha
;
707 sha
= (**att
)._unknown
.QueryInterface ((struct gl2_unknown_intf
**) att
, UIID_SHADER
);
710 _mesa_error (ctx
, GL_INVALID_OPERATION
, "_program_Attach");
714 (**sha
).Release (sha
);
715 return _container_Attach (intf
, att
);
719 _program_GetLinkStatus (struct gl2_program_intf
**intf
)
721 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
723 return impl
->_obj
.link_status
;
727 _program_GetValidateStatus (struct gl2_program_intf
**intf
)
729 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
731 return impl
->_obj
.validate_status
;
735 _program_Link (struct gl2_program_intf
**intf
)
737 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
738 #if USE_3DLABS_FRONTEND
743 impl
->_obj
.link_status
= GL_FALSE
;
744 _mesa_free ((void *) impl
->_obj
._container
._generic
.info_log
);
745 impl
->_obj
._container
._generic
.info_log
= NULL
;
747 #if USE_3DLABS_FRONTEND
748 handles
= (ShHandle
*) _mesa_malloc (impl
->_obj
._container
.attached_count
* sizeof (ShHandle
));
752 for (i
= 0; i
< impl
->_obj
._container
.attached_count
; i
++)
754 struct gl2_generic_intf
**gen
= impl
->_obj
._container
.attached
[i
];
755 struct gl2_3dlabs_shhandle_intf
**sh
;
757 sh
= (struct gl2_3dlabs_shhandle_intf
**) (**gen
)._unknown
.QueryInterface (
758 (struct gl2_unknown_intf
**) gen
, UIID_3DLABS_SHHANDLE
);
761 handles
[i
] = (**sh
).GetShHandle (sh
);
762 (**sh
)._unknown
.Release ((struct gl2_unknown_intf
**) sh
);
766 _mesa_free (handles
);
771 if (ShLink (impl
->_obj
.linker
, handles
, impl
->_obj
._container
.attached_count
,
772 impl
->_obj
.uniforms
, NULL
, NULL
))
773 impl
->_obj
.link_status
= GL_TRUE
;
775 impl
->_obj
._container
._generic
.info_log
= _mesa_strdup (ShGetInfoLog (impl
->_obj
.linker
));
780 _program_Validate (struct gl2_program_intf
**intf
)
782 struct gl2_program_impl
*impl
= (struct gl2_program_impl
*) intf
;
784 impl
->_obj
.validate_status
= GL_FALSE
;
785 _mesa_free ((void *) impl
->_obj
._container
._generic
.info_log
);
786 impl
->_obj
._container
._generic
.info_log
= NULL
;
791 static struct gl2_program_intf _program_vftbl
= {
797 _program_QueryInterface
802 _generic_GetDeleteStatus
,
807 _container_GetAttachedCount
,
808 _container_GetAttached
810 _program_GetLinkStatus
,
811 _program_GetValidateStatus
,
817 _program_constructor (struct gl2_program_impl
*impl
)
819 _container_constructor ((struct gl2_container_impl
*) impl
);
820 impl
->_vftbl
= &_program_vftbl
;
821 impl
->_obj
._container
._generic
._unknown
._destructor
= _program_destructor
;
822 impl
->_obj
.link_status
= GL_FALSE
;
823 impl
->_obj
.validate_status
= GL_FALSE
;
824 #if USE_3DLABS_FRONTEND
825 impl
->_obj
.linker
= ShConstructLinker (EShExVertexFragment
, 0);
826 impl
->_obj
.uniforms
= ShConstructUniformMap ();
830 struct gl2_fragment_shader_obj
832 struct gl2_shader_obj _shader
;
835 struct gl2_fragment_shader_impl
837 struct gl2_fragment_shader_intf
*_vftbl
;
838 struct gl2_fragment_shader_obj _obj
;
842 _fragment_shader_destructor (struct gl2_unknown_intf
**intf
)
844 struct gl2_fragment_shader_impl
*impl
= (struct gl2_fragment_shader_impl
*) intf
;
847 /* TODO free fragment shader data */
849 _shader_destructor (intf
);
852 static struct gl2_unknown_intf
**
853 _fragment_shader_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
855 if (uiid
== UIID_FRAGMENT_SHADER
)
857 (**intf
).AddRef (intf
);
860 return _shader_QueryInterface (intf
, uiid
);
864 _fragment_shader_GetSubType (struct gl2_shader_intf
**intf
)
866 return GL_FRAGMENT_SHADER_ARB
;
869 static struct gl2_fragment_shader_intf _fragment_shader_vftbl
= {
875 _fragment_shader_QueryInterface
880 _generic_GetDeleteStatus
,
883 _fragment_shader_GetSubType
,
884 _shader_GetCompileStatus
,
892 _fragment_shader_constructor (struct gl2_fragment_shader_impl
*impl
)
894 _shader_constructor ((struct gl2_shader_impl
*) impl
);
895 impl
->_vftbl
= &_fragment_shader_vftbl
;
896 impl
->_obj
._shader
._generic
._unknown
._destructor
= _fragment_shader_destructor
;
897 #if USE_3DLABS_FRONTEND
898 impl
->_obj
._shader
._3dlabs_shhandle
._obj
.handle
= ShConstructCompiler (EShLangFragment
, 0);
902 struct gl2_vertex_shader_obj
904 struct gl2_shader_obj _shader
;
907 struct gl2_vertex_shader_impl
909 struct gl2_vertex_shader_intf
*_vftbl
;
910 struct gl2_vertex_shader_obj _obj
;
914 _vertex_shader_destructor (struct gl2_unknown_intf
**intf
)
916 struct gl2_vertex_shader_impl
*impl
= (struct gl2_vertex_shader_impl
*) intf
;
919 /* TODO free vertex shader data */
921 _shader_destructor (intf
);
924 static struct gl2_unknown_intf
**
925 _vertex_shader_QueryInterface (struct gl2_unknown_intf
**intf
, enum gl2_uiid uiid
)
927 if (uiid
== UIID_VERTEX_SHADER
)
929 (**intf
).AddRef (intf
);
932 return _shader_QueryInterface (intf
, uiid
);
936 _vertex_shader_GetSubType (struct gl2_shader_intf
**intf
)
938 return GL_VERTEX_SHADER_ARB
;
941 static struct gl2_vertex_shader_intf _vertex_shader_vftbl
= {
947 _vertex_shader_QueryInterface
952 _generic_GetDeleteStatus
,
955 _vertex_shader_GetSubType
,
956 _shader_GetCompileStatus
,
964 _vertex_shader_constructor (struct gl2_vertex_shader_impl
*impl
)
966 _shader_constructor ((struct gl2_shader_impl
*) impl
);
967 impl
->_vftbl
= &_vertex_shader_vftbl
;
968 impl
->_obj
._shader
._generic
._unknown
._destructor
= _vertex_shader_destructor
;
969 #if USE_3DLABS_FRONTEND
970 impl
->_obj
._shader
._3dlabs_shhandle
._obj
.handle
= ShConstructCompiler (EShLangVertex
, 0);
975 _mesa_3dlabs_create_shader_object (GLenum shaderType
)
979 case GL_FRAGMENT_SHADER_ARB
:
981 struct gl2_fragment_shader_impl
*x
= (struct gl2_fragment_shader_impl
*)
982 _mesa_malloc (sizeof (struct gl2_fragment_shader_impl
));
986 _fragment_shader_constructor (x
);
987 return x
->_obj
._shader
._generic
.name
;
991 case GL_VERTEX_SHADER_ARB
:
993 struct gl2_vertex_shader_impl
*x
= (struct gl2_vertex_shader_impl
*)
994 _mesa_malloc (sizeof (struct gl2_vertex_shader_impl
));
998 _vertex_shader_constructor (x
);
999 return x
->_obj
._shader
._generic
.name
;
1009 _mesa_3dlabs_create_program_object (void)
1011 struct gl2_program_impl
*x
= (struct gl2_program_impl
*)
1012 _mesa_malloc (sizeof (struct gl2_program_impl
));
1016 _program_constructor (x
);
1017 return x
->_obj
._container
._generic
.name
;
1024 _mesa_init_shaderobjects_3dlabs (GLcontext
*ctx
)
1026 #if USE_3DLABS_FRONTEND
1027 _glslang_3dlabs_InitProcess ();
1028 _glslang_3dlabs_ShInitialize ();