VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py@ 69498

Last change on this file since 69498 was 69310, checked in by vboxsync, 7 years ago

common/crOpenGL: scm updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.9 KB
Line 
1# Copyright (c) 2001, Stanford University
2# All rights reserved.
3#
4# See the file LICENSE.txt for information on redistributing this software.
5
6from __future__ import print_function
7import sys
8
9import apiutil
10
11
12apiutil.CopyrightC()
13
14print("""/* DO NOT EDIT - AUTOMATICALLY GENERATED BY packspu_beginend.py */
15#include "packspu.h"
16#include "assert.h"
17#include "cr_packfunctions.h"
18#include "packspu_proto.h"
19
20void PACKSPU_APIENTRY packspu_Begin( GLenum mode )
21{
22 CRPackBuffer *buf;
23#if CR_ARB_vertex_buffer_object
24 GET_CONTEXT(ctx);
25#else
26 GET_THREAD(thread);
27#endif
28
29 buf = &thread->BeginEndBuffer;
30
31 /* XXX comparing mode >= 0 here is not needed since mode is unsigned */
32 CRASSERT( /*mode >= GL_POINTS && */mode <= GL_POLYGON );
33
34#if CR_ARB_vertex_buffer_object
35 {
36 GLboolean serverArrays = GL_FALSE;
37 if (ctx->clientState->extensions.ARB_vertex_buffer_object)
38 serverArrays = crStateUseServerArrays();
39 if (serverArrays) {
40 CRClientState *clientState = &(ctx->clientState->client);
41 if (clientState->array.locked && !clientState->array.synced)
42 {
43 crPackLockArraysEXT(clientState->array.lockFirst, clientState->array.lockCount);
44 clientState->array.synced = GL_TRUE;
45 }
46 }
47 }
48#endif
49
50 if (pack_spu.swap)
51 {
52 crPackBeginSWAP( mode );
53 }
54 else
55 {
56 crPackBegin( mode );
57 }
58
59 if ( thread->netServer.conn->Barf ) {
60 thread->BeginEndMode = mode;
61 thread->BeginEndState = -1;
62 if ( mode == GL_LINES || mode == GL_TRIANGLES || mode == GL_QUADS || mode == GL_POLYGON )
63 {
64 CRASSERT(!buf->pack);
65
66 crPackReleaseBuffer( thread->packer );
67 buf->pack = crNetAlloc( thread->netServer.conn );
68 crPackInitBuffer( buf, buf->pack, thread->netServer.conn->buffer_size, thread->netServer.conn->mtu );
69 buf->holds_BeginEnd = 1;
70 buf->in_BeginEnd = 1;
71 crPackSetBuffer( thread->packer, buf );
72
73 thread->BeginEndState = 0;
74 }
75 }
76}
77
78void PACKSPU_APIENTRY packspu_End( void )
79{
80 GET_THREAD(thread);
81 CRPackBuffer *buf = &thread->BeginEndBuffer;
82
83 if ( thread->netServer.conn->Barf &&
84 (thread->BeginEndMode == GL_LINES
85 || thread->BeginEndMode == GL_TRIANGLES
86 || thread->BeginEndMode == GL_QUADS
87 || thread->BeginEndMode == GL_POLYGON ) )
88 {
89 CRASSERT(buf->pack);
90
91 crPackReleaseBuffer( thread->packer );
92 crPackSetBuffer( thread->packer, &thread->normBuffer );
93 if ( !crPackCanHoldBuffer( buf ) )
94 packspuFlush( (void *) thread );
95
96 crPackAppendBuffer( buf );
97 crNetFree( thread->netServer.conn, buf->pack );
98 buf->pack = NULL;
99 }
100
101 if (pack_spu.swap)
102 {
103 crPackEndSWAP();
104 }
105 else
106 {
107 crPackEnd();
108 }
109}
110
111static void DoVertex( void )
112{
113 GET_THREAD(thread);
114 CRPackBuffer *buf = &thread->BeginEndBuffer;
115 CRPackBuffer *gbuf = &thread->normBuffer;
116 int num_data;
117 int num_opcode;
118
119 /*crDebug( "really doing Vertex" );*/
120 crPackReleaseBuffer( thread->packer );
121 num_data = buf->data_current - buf->data_start;
122 num_opcode = buf->opcode_start - buf->opcode_current;
123 crPackSetBuffer( thread->packer, gbuf );
124 if ( !crPackCanHoldBuffer( buf ) )
125 /* doesn't hold, first flush gbuf*/
126 packspuFlush( (void *) thread );
127
128 crPackAppendBuffer( buf );
129 crPackReleaseBuffer( thread->packer );
130 crPackSetBuffer( thread->packer, buf );
131 crPackResetPointers(thread->packer);
132}
133
134static void RunState( void )
135{
136 GET_THREAD(thread);
137 if (! thread->netServer.conn->Barf ) return;
138 if (thread->BeginEndState == -1) return;
139 switch(thread->BeginEndMode) {
140 case GL_POLYGON:
141 return;
142 case GL_LINES:
143 thread->BeginEndState = (thread->BeginEndState + 1) % 2;
144 if (thread->BeginEndState)
145 return;
146 break;
147 case GL_TRIANGLES:
148 thread->BeginEndState = (thread->BeginEndState + 1) % 3;
149 if (thread->BeginEndState)
150 return;
151 break;
152 case GL_QUADS:
153 thread->BeginEndState = (thread->BeginEndState + 1) % 4;
154 if (thread->BeginEndState)
155 return;
156 break;
157 }
158 DoVertex();
159}
160""")
161
162keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
163
164for func_name in apiutil.AllSpecials( "packspu_vertex" ):
165 params = apiutil.Parameters(func_name)
166 print('void PACKSPU_APIENTRY packspu_%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params) ))
167 print('{')
168 print('\tif (pack_spu.swap)')
169 print('\t{')
170 print('\t\tcrPack%sSWAP(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
171 print('\t}')
172 print('\telse')
173 print('\t{')
174 print('\t\tcrPack%s(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
175 print('\t}')
176 print('\tRunState();')
177 print('}')
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette