VirtualBox

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

Last change on this file since 46368 was 46368, checked in by vboxsync, 12 years ago

crOpenGL: more debugging

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

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