VirtualBox

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

Last change on this file since 78376 was 78375, checked in by vboxsync, 6 years ago

Additions/common/crOpengl,GuestHost/OpenGL,HostServices/SharedOpenGL: Eliminate all global variables from the state tracker library (state_tracker) in preparation of the SPU DLL merging, bugref:9435

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.5 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(&pack_spu.StateTracker);
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 crPackBegin( mode );
51 if ( thread->netServer.conn->Barf ) {
52 thread->BeginEndMode = mode;
53 thread->BeginEndState = -1;
54 if ( mode == GL_LINES || mode == GL_TRIANGLES || mode == GL_QUADS || mode == GL_POLYGON )
55 {
56 CRASSERT(!buf->pack);
57
58 crPackReleaseBuffer( thread->packer );
59 buf->pack = crNetAlloc( thread->netServer.conn );
60 crPackInitBuffer( buf, buf->pack, thread->netServer.conn->buffer_size, thread->netServer.conn->mtu );
61 buf->holds_BeginEnd = 1;
62 buf->in_BeginEnd = 1;
63 crPackSetBuffer( thread->packer, buf );
64
65 thread->BeginEndState = 0;
66 }
67 }
68}
69
70void PACKSPU_APIENTRY packspu_End( void )
71{
72 GET_THREAD(thread);
73 CRPackBuffer *buf = &thread->BeginEndBuffer;
74
75 if ( thread->netServer.conn->Barf &&
76 (thread->BeginEndMode == GL_LINES
77 || thread->BeginEndMode == GL_TRIANGLES
78 || thread->BeginEndMode == GL_QUADS
79 || thread->BeginEndMode == GL_POLYGON ) )
80 {
81 CRASSERT(buf->pack);
82
83 crPackReleaseBuffer( thread->packer );
84 crPackSetBuffer( thread->packer, &thread->normBuffer );
85 if ( !crPackCanHoldBuffer( buf ) )
86 packspuFlush( (void *) thread );
87
88 crPackAppendBuffer( buf );
89 crNetFree( thread->netServer.conn, buf->pack );
90 buf->pack = NULL;
91 }
92
93 crPackEnd();
94}
95
96static void DoVertex( void )
97{
98 GET_THREAD(thread);
99 CRPackBuffer *buf = &thread->BeginEndBuffer;
100 CRPackBuffer *gbuf = &thread->normBuffer;
101 int num_data;
102 int num_opcode;
103
104 /*crDebug( "really doing Vertex" );*/
105 crPackReleaseBuffer( thread->packer );
106 num_data = buf->data_current - buf->data_start;
107 num_opcode = buf->opcode_start - buf->opcode_current;
108 crPackSetBuffer( thread->packer, gbuf );
109 if ( !crPackCanHoldBuffer( buf ) )
110 /* doesn't hold, first flush gbuf*/
111 packspuFlush( (void *) thread );
112
113 crPackAppendBuffer( buf );
114 crPackReleaseBuffer( thread->packer );
115 crPackSetBuffer( thread->packer, buf );
116 crPackResetPointers(thread->packer);
117}
118
119static void RunState( void )
120{
121 GET_THREAD(thread);
122 if (! thread->netServer.conn->Barf ) return;
123 if (thread->BeginEndState == -1) return;
124 switch(thread->BeginEndMode) {
125 case GL_POLYGON:
126 return;
127 case GL_LINES:
128 thread->BeginEndState = (thread->BeginEndState + 1) % 2;
129 if (thread->BeginEndState)
130 return;
131 break;
132 case GL_TRIANGLES:
133 thread->BeginEndState = (thread->BeginEndState + 1) % 3;
134 if (thread->BeginEndState)
135 return;
136 break;
137 case GL_QUADS:
138 thread->BeginEndState = (thread->BeginEndState + 1) % 4;
139 if (thread->BeginEndState)
140 return;
141 break;
142 }
143 DoVertex();
144}
145""")
146
147keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
148
149for func_name in apiutil.AllSpecials( "packspu_vertex" ):
150 params = apiutil.Parameters(func_name)
151 print('void PACKSPU_APIENTRY packspu_%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params) ))
152 print('{')
153 print('\tcrPack%s(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
154 print('\tRunState();')
155 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