VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py@ 78375

Last change on this file since 78375 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.7 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, string, re
8
9import apiutil
10
11
12
13apiutil.CopyrightC()
14
15print("""
16/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY server_dispatch.py SCRIPT */
17#include "cr_spu.h"
18#include "chromium.h"
19#include "cr_error.h"
20#include "server_dispatch.h"
21#include "server.h"
22#include "cr_unpack.h"
23
24CRCurrentStatePointers crServerCurrent;
25""")
26
27
28for func_name in apiutil.AllSpecials( sys.argv[1]+"/../state_tracker/state" ):
29 params = apiutil.Parameters(func_name)
30 if (apiutil.FindSpecial( "server", func_name ) or
31 "get" in apiutil.Properties(func_name)):
32 continue
33
34 wrap = apiutil.GetCategoryWrapper(func_name)
35 if wrap:
36 print('#if defined(CR_%s)' % wrap)
37 print('void SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( func_name, apiutil.MakeDeclarationStringForDispatcher( params ) ))
38 print('{')
39 if len(params) == 0:
40 print('\tcrState%s(&cr_server.StateTracker);' % (func_name))
41 else:
42 print('\tcrState%s(&cr_server.StateTracker, %s);' % (func_name, apiutil.MakeCallStringForDispatcher( params ) ))
43 print('\tcr_server.head_spu->dispatch_table.%s(%s);' % (func_name, apiutil.MakeCallStringForDispatcher( params ) ))
44 print('}')
45 if wrap:
46 print('#endif')
47
48
49keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
50for func_name in keys:
51 current = 0
52 array = ""
53 condition = ""
54 m = re.search( r"^(Color|Normal)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
55 if m :
56 current = 1
57 name = m.group(1)[:1].lower() + m.group(1)[1:]
58 type = m.group(3) + m.group(2)
59 m = re.search( r"^(SecondaryColor)(3)(ub|b|us|s|ui|i|f|d)(EXT)$", func_name )
60 if m :
61 current = 1
62 name = m.group(1)[:1].lower() + m.group(1)[1:]
63 type = m.group(3) + m.group(2)
64 m = re.search( r"^(TexCoord)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
65 if m :
66 current = 1
67 name = m.group(1)[:1].lower() + m.group(1)[1:]
68 type = m.group(3) + m.group(2)
69 array = "[0]"
70 m = re.search( r"^(MultiTexCoord)([1234])(ub|b|us|s|ui|i|f|d)ARB$", func_name )
71 if m :
72 current = 1
73 name = "texCoord"
74 type = m.group(3) + m.group(2)
75 array = "[texture-GL_TEXTURE0_ARB]"
76 condition = "if (texture >= GL_TEXTURE0_ARB && texture < GL_TEXTURE0_ARB + CR_MAX_TEXTURE_UNITS)"
77 m = re.match( r"^(Index)(ub|b|us|s|ui|i|f|d)$", func_name )
78 if m :
79 current = 1
80 name = m.group(1)[:1].lower() + m.group(1)[1:]
81 type = m.group(2) + "1"
82 m = re.match( r"^(EdgeFlag)$", func_name )
83 if m :
84 current = 1
85 name = m.group(1)[:1].lower() + m.group(1)[1:]
86 type = "l1"
87 m = re.match( r"^(FogCoord)(f|d)(EXT)$", func_name)
88 if m :
89 current = 1
90 name = m.group(1)[:1].lower() + m.group(1)[1:]
91 type = m.group(2) + "1"
92
93 # Vertex attribute commands w/ some special cases
94 m = re.search( r"^(VertexAttrib)([1234])(s|i|f|d)ARB$", func_name )
95 if m :
96 current = 1
97 name = m.group(1)[:1].lower() + m.group(1)[1:]
98 type = m.group(3) + m.group(2)
99 array = "[index]"
100 condition = "if (index < CR_MAX_VERTEX_ATTRIBS)"
101 if func_name == "VertexAttrib4NubARB":
102 current = 1
103 name = "vertexAttrib"
104 type = "ub4"
105 array = "[index]"
106 condition = "if (index < CR_MAX_VERTEX_ATTRIBS)"
107
108 if current:
109 params = apiutil.Parameters(func_name)
110 print('void SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params) ))
111 print('{')
112 print('\t%s' % (condition))
113 print('\t{')
114 print('\t\tcr_server.head_spu->dispatch_table.%s(%s);' % (func_name, apiutil.MakeCallStringForDispatcher(params) ))
115 print("\t\tcr_server.current.c.%s.%s%s = cr_server.pUnpackerState->pbUnpackData;" % (name,type,array))
116 print('\t}')
117 print('}\n')
118
119print("""
120void crServerInitDispatch(void)
121{
122 crSPUInitDispatchTable( &(cr_server.dispatch) );
123 crSPUCopyDispatchTable( &(cr_server.dispatch), &(cr_server.head_spu->dispatch_table ) );
124""")
125
126for func_name in keys:
127 if ("get" in apiutil.Properties(func_name) or
128 apiutil.FindSpecial( "server", func_name ) or
129 apiutil.FindSpecial( sys.argv[1]+"/../state_tracker/state", func_name )):
130
131 wrap = apiutil.GetCategoryWrapper(func_name)
132 if wrap:
133 print('#if defined(CR_%s)' % wrap)
134
135 print('\tcr_server.dispatch.%s = crServerDispatch%s;' % (func_name, func_name))
136 if wrap:
137 print('#endif')
138
139print('}')
140
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