Changeset 16074 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Jan 20, 2009 10:00:38 AM (16 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/crOpenGL/array
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/crOpenGL/array/arrayspu.c
r16036 r16074 13 13 ArraySPU array_spu; 14 14 15 #ifdef CHROMIUM_THREADSAFE 16 CRmutex _ArrayMutex; 17 #endif 18 15 19 static void ARRAYSPU_APIENTRY arrayspu_ArrayElement( GLint index ) 16 20 { 17 const CRClientState *c = &( array_spu.ctx->client);21 const CRClientState *c = &(crStateGetCurrent()->client); 18 22 const CRVertexArrays *array = &(c->array); 19 const GLboolean vpEnabled = array_spu.ctx->program.vpEnabled;23 const GLboolean vpEnabled = crStateGetCurrent()->program.vpEnabled; 20 24 unsigned char *p; 21 25 unsigned int unit, attr; … … 103 107 104 108 /* Now do conventional arrays, unless overriden by generic arrays above */ 105 for (unit = 0 ; unit < array_spu.ctx->limits.maxTextureUnits ; unit++)109 for (unit = 0 ; unit < crStateGetCurrent()->limits.maxTextureUnits ; unit++) 106 110 { 107 111 if (array->t[unit].enabled && !(vpEnabled && array->a[VERT_ATTRIB_TEX0+unit].enabled)) … … 450 454 GLubyte *p = (GLubyte *)indices; 451 455 #ifdef CR_ARB_vertex_buffer_object 452 CRBufferObject *elementsBuffer = array_spu.ctx->bufferobject.elementsBuffer;456 CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer; 453 457 #endif 454 458 … … 622 626 { 623 627 if (cap == GL_VERTEX_PROGRAM_NV) { 624 array_spu.ctx->program.vpEnabled = GL_TRUE;628 crStateGetCurrent()->program.vpEnabled = GL_TRUE; 625 629 } 626 630 array_spu.child.Enable(cap); … … 631 635 { 632 636 if (cap == GL_VERTEX_PROGRAM_NV) { 633 array_spu.ctx->program.vpEnabled = GL_FALSE;637 crStateGetCurrent()->program.vpEnabled = GL_FALSE; 634 638 } 635 639 array_spu.child.Disable(cap); … … 754 758 } 755 759 760 static GLint ARRAYSPU_APIENTRY 761 arrayspu_CreateContext( const char *dpyName, GLint visual, GLint shareCtx ) 762 { 763 GLint ctx, slot; 764 765 #ifdef CHROMIUM_THREADSAFE 766 crLockMutex(&_ArrayMutex); 767 #endif 768 769 ctx = array_spu.child.CreateContext(dpyName, visual, shareCtx); 770 771 /* find an empty context slot */ 772 for (slot = 0; slot < array_spu.numContexts; slot++) { 773 if (!array_spu.context[slot].clientState) { 774 /* found empty slot */ 775 break; 776 } 777 } 778 if (slot == array_spu.numContexts) { 779 array_spu.numContexts++; 780 } 781 782 array_spu.context[slot].clientState = crStateCreateContext(NULL, visual, NULL); 783 array_spu.context[slot].clientCtx = ctx; 784 #ifdef CR_ARB_vertex_buffer_object 785 array_spu.context[slot].clientState->bufferobject.retainBufferData = GL_TRUE; 786 #endif 787 788 #ifdef CHROMIUM_THREADSAFE 789 crUnlockMutex(&_ArrayMutex); 790 #endif 791 792 return ctx; 793 } 794 795 static void ARRAYSPU_APIENTRY 796 arrayspu_MakeCurrent( GLint window, GLint nativeWindow, GLint ctx ) 797 { 798 #ifdef CHROMIUM_THREADSAFE 799 crLockMutex(&_ArrayMutex); 800 #endif 801 array_spu.child.MakeCurrent(window, nativeWindow, ctx); 802 803 if (ctx) { 804 int slot; 805 806 for (slot=0; slot<array_spu.numContexts; ++slot) 807 if (array_spu.context[slot].clientCtx == ctx) break; 808 CRASSERT(slot < array_spu.numContexts); 809 810 crStateMakeCurrent(array_spu.context[slot].clientState); 811 } 812 else 813 { 814 crStateMakeCurrent(NULL); 815 } 816 817 #ifdef CHROMIUM_THREADSAFE 818 crUnlockMutex(&_ArrayMutex); 819 #endif 820 } 821 822 static void ARRAYSPU_APIENTRY 823 arrayspu_DestroyContext( GLint ctx ) 824 { 825 #ifdef CHROMIUM_THREADSAFE 826 crLockMutex(&_ArrayMutex); 827 #endif 828 array_spu.child.DestroyContext(ctx); 829 830 if (ctx) { 831 int slot; 832 833 for (slot=0; slot<array_spu.numContexts; ++slot) 834 if (array_spu.context[slot].clientCtx == ctx) break; 835 CRASSERT(slot < array_spu.numContexts); 836 837 crStateDestroyContext(array_spu.context[slot].clientState); 838 839 array_spu.context[slot].clientState = NULL; 840 array_spu.context[slot].clientCtx = 0; 841 } 842 843 #ifdef CHROMIUM_THREADSAFE 844 crUnlockMutex(&_ArrayMutex); 845 #endif 846 } 756 847 757 848 SPUNamedFunctionTable _cr_array_table[] = { … … 793 884 { "GetBufferPointervARB", (SPUGenericFunction) arrayspu_GetBufferPointervARB}, 794 885 { "InterleavedArrays", (SPUGenericFunction) arrayspu_InterleavedArrays}, 886 { "CreateContext", (SPUGenericFunction) arrayspu_CreateContext}, 887 { "MakeCurrent", (SPUGenericFunction) arrayspu_MakeCurrent}, 888 { "DestroyContext", (SPUGenericFunction) arrayspu_DestroyContext}, 795 889 { NULL, NULL } 796 890 }; -
trunk/src/VBox/Additions/WINNT/Graphics/crOpenGL/array/arrayspu.h
r15532 r16074 19 19 void arrayspuSetVBoxConfiguration( void ); 20 20 21 typedef struct context_info_t ContextInfo; 22 23 struct context_info_t { 24 CRContext *clientState; /* used to store client-side GL state */ 25 GLint clientCtx; /* client context ID */ 26 }; 27 21 28 typedef struct { 22 29 int id; 23 30 int has_child; 24 CRContext * ctx;31 CRContext *defaultctx; 25 32 SPUDispatchTable self, child, super; 33 int numContexts; 34 ContextInfo context[CR_MAX_CONTEXTS]; 26 35 } ArraySPU; 27 36 28 37 extern ArraySPU array_spu; 29 38 39 #ifdef CHROMIUM_THREADSAFE 40 extern CRmutex _ArrayMutex; 41 #endif 42 30 43 #endif /* ARRAY_SPU_H */ -
trunk/src/VBox/Additions/WINNT/Graphics/crOpenGL/array/arrayspu_init.c
r16073 r16074 7 7 #include "cr_spu.h" 8 8 #include "arrayspu.h" 9 #include "cr_mem.h" 9 10 #include <stdio.h> 10 11 … … 27 28 (void) num_contexts; 28 29 30 #ifdef CHROMIUM_THREADSAFE 31 crInitMutex(&_ArrayMutex); 32 #endif 33 29 34 array_spu.id = id; 30 35 array_spu.has_child = 0; … … 40 45 41 46 crStateInit(); 42 array_spu.ctx = crStateCreateContext( NULL, 0, NULL ); 47 /*@todo seems default context ain't needed at all*/ 48 array_spu.defaultctx = crStateCreateContext( NULL, 0, NULL ); 43 49 #ifdef CR_ARB_vertex_buffer_object 44 array_spu. ctx->bufferobject.retainBufferData = GL_TRUE;50 array_spu.defaultctx->bufferobject.retainBufferData = GL_TRUE; 45 51 #endif 46 52 /* we call SetCurrent instead of MakeCurrent as the differencer 47 53 * isn't setup yet anyway */ 48 crStateSetCurrent( array_spu.ctx ); 54 crStateSetCurrent( array_spu.defaultctx ); 55 56 array_spu.numContexts = 0; 57 crMemZero(array_spu.context, CR_MAX_CONTEXTS * sizeof(ContextInfo)); 49 58 50 59 return &array_functions;
Note:
See TracChangeset
for help on using the changeset viewer.