1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.
import sys
import apiutil
apiutil.CopyrightC()
print """
#include "cr_spu.h"
#include "chromium.h"
#include "cr_error.h"
#include "cr_mem.h"
#include "cr_net.h"
#include "server_dispatch.h"
#include "server.h"
"""
max_components = {
'GetClipPlane': 4,
'GetCombinerStageParameterfvNV': 4,
'GetCombinerStageParameterivNV': 4,
'GetCombinerOutputParameterfvNV': 4,
'GetCombinerOutputParameterivNV': 4,
'GetCombinerInputParameterfvNV': 4,
'GetCombinerInputParameterivNV': 4,
'GetFinalCombinerInputParameterfvNV': 4,
'GetFinalCombinerInputParameterivNV': 4,
'GetLightfv': 4,
'GetLightiv': 4,
'GetMaterialfv': 4,
'GetMaterialiv': 4,
'GetPolygonStipple': 32*32/8,
'GetTexEnvfv': 4,
'GetTexEnviv': 4,
'GetTexGendv': 4,
'GetTexGenfv': 4,
'GetTexGeniv': 4,
'GetTexLevelParameterfv': 1,
'GetTexLevelParameteriv': 1,
'GetTexParameterfv': 4,
'GetTexParameteriv': 4,
'GetProgramParameterdvNV': 4,
'GetProgramParameterfvNV': 4,
'GetProgramivNV': 1,
'GetTrackMatrixivNV': 1,
'GetVertexAttribPointervNV': 1,
'GetVertexAttribdvNV': 4,
'GetVertexAttribfvNV': 4,
'GetVertexAttribivNV': 4,
'GetFenceivNV': 1,
'GetVertexAttribdvARB': 4,
'GetVertexAttribfvARB': 4,
'GetVertexAttribivARB': 4,
'GetVertexAttribPointervARB': 1,
'GetProgramNamedParameterdvNV': 4,
'GetProgramNamedParameterfvNV': 4,
'GetProgramLocalParameterdvARB': 4,
'GetProgramLocalParameterfvARB': 4,
'GetProgramEnvParameterdvARB': 4,
'GetProgramEnvParameterfvARB': 4,
'GetProgramivARB': 1,
'AreProgramsResidentNV': 1,
'GetBufferParameterivARB': 1,
'GetBufferPointervARB': 1,
'GetQueryObjectivARB' : 1,
'GetQueryObjectuivARB' : 1,
'GetQueryivARB' : 1,
'GetProgramiv' : 1,
'GetShaderiv' : 1,
'GetObjectParameterfvARB': 1,
'GetObjectParameterivARB': 1,
'GetRenderbufferParameterivEXT': 1,
'GetFramebufferAttachmentParameterivEXT': 1
}
no_pnames = [
'GetClipPlane',
'GetPolygonStipple',
'GetProgramLocalParameterdvARB',
'GetProgramLocalParameterfvARB',
'GetProgramNamedParameterdvNV',
'GetProgramNamedParameterfvNV',
'GetProgramNamedParameterdvNV',
'GetProgramNamedParameterfvNV',
'GetProgramEnvParameterdvARB',
'GetProgramEnvParameterfvARB',
'GetProgramivARB',
'AreProgramsResidentNV',
'GetProgramiv',
'GetShaderiv',
'GetObjectParameterfvARB',
'GetObjectParameterivARB',
'GetRenderbufferParameterivEXT',
'GetFramebufferAttachmentParameterivEXT'
];
convert_bufferid = [
'GetVertexAttribdvARB',
'GetVertexAttribdvNV',
'GetVertexAttribfvARB',
'GetVertexAttribfvNV',
'GetVertexAttribivARB',
'GetVertexAttribivNV'
];
keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
for func_name in keys:
#(return_type, arg_names, arg_types) = gl_mapping[func_name]
if ("get" in apiutil.Properties(func_name) and
apiutil.ReturnType(func_name) == "void" and
not apiutil.FindSpecial( "server", func_name )):
params = apiutil.Parameters(func_name)
print 'void SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % (func_name, apiutil.MakeDeclarationString( params ) )
print '{'
lastParam = params[-1]
assert apiutil.IsPointer(lastParam[1])
local_argtype = apiutil.PointerType(lastParam[1])
local_argname = 'local_%s' % lastParam[0]
print '\t%s %s[%d];' % ( local_argtype, local_argname, max_components[func_name] )
print '\t(void) %s;' % lastParam[0]
params[-1] = (local_argname, local_argtype, 0)
print '\tcr_server.head_spu->dispatch_table.%s( %s );' % ( func_name, apiutil.MakeCallString(params) )
if func_name in convert_bufferid:
print '\tif (pname==GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB){'
print '\t\tlocal_params[0]=(%s)crStateBufferHWIDtoID((GLint)local_params[0]);' % (local_argtype);
print '\t}'
if func_name in no_pnames:
print '\tcrServerReturnValue( &(%s[0]), %d*sizeof(%s) );' % (local_argname, max_components[func_name], local_argtype );
else:
print '\tcrServerReturnValue( &(%s[0]), crStateHlpComponentsCount(pname)*sizeof(%s) );' % (local_argname, local_argtype );
print '}\n'
|