1 | import sys
|
---|
2 |
|
---|
3 | import apiutil
|
---|
4 |
|
---|
5 | import sys, re, string
|
---|
6 |
|
---|
7 |
|
---|
8 | line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s+(.*)\s*$')
|
---|
9 | extensions_line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s(\S+)\s+(.*)\s*$')
|
---|
10 |
|
---|
11 | params = {}
|
---|
12 | extended_params = {}
|
---|
13 |
|
---|
14 | input = open( sys.argv[2]+"/state_isenabled.txt", 'r' )
|
---|
15 | for line in input.readlines():
|
---|
16 | match = line_re.match( line )
|
---|
17 | if match:
|
---|
18 | type = match.group(1)
|
---|
19 | pname = match.group(2)
|
---|
20 | fields = string.split( match.group(3) )
|
---|
21 | params[pname] = ( type, fields )
|
---|
22 |
|
---|
23 | input = open( sys.argv[2]+"/state_extensions_isenabled.txt", 'r' )
|
---|
24 | for line in input.readlines():
|
---|
25 | match = extensions_line_re.match( line )
|
---|
26 | if match:
|
---|
27 | type = match.group(1)
|
---|
28 | pname = match.group(2)
|
---|
29 | ifdef = match.group(3)
|
---|
30 | fields = string.split( match.group(4) )
|
---|
31 | extended_params[pname] = ( type, ifdef, fields )
|
---|
32 |
|
---|
33 |
|
---|
34 | apiutil.CopyrightC()
|
---|
35 |
|
---|
36 | print """#include "cr_blitter.h"
|
---|
37 | #include "cr_spu.h"
|
---|
38 | #include "chromium.h"
|
---|
39 | #include "cr_error.h"
|
---|
40 | #include "cr_net.h"
|
---|
41 | #include "cr_rand.h"
|
---|
42 | #include "cr_mem.h"
|
---|
43 | #include "cr_string.h"
|
---|
44 | #include <cr_dump.h>
|
---|
45 | #include "cr_pixeldata.h"
|
---|
46 |
|
---|
47 | #include <iprt/cdefs.h>
|
---|
48 | #include <iprt/types.h>
|
---|
49 | #include <iprt/mem.h>
|
---|
50 |
|
---|
51 | #include <stdio.h>
|
---|
52 |
|
---|
53 | #ifdef VBOX_WITH_CRDUMPER
|
---|
54 | """
|
---|
55 |
|
---|
56 | from get_sizes import *;
|
---|
57 |
|
---|
58 | getprops = apiutil.ParamProps("GetDoublev")
|
---|
59 | enableprops = apiutil.ParamProps("Enable")
|
---|
60 |
|
---|
61 | #print "//missing get props:"
|
---|
62 | #for prop in getprops:
|
---|
63 | # try:
|
---|
64 | # tmp = num_get_values[prop]
|
---|
65 | # except KeyError:
|
---|
66 | # try:
|
---|
67 | # keyvalues = extensions_num_get_values[prop]
|
---|
68 | # except KeyError:
|
---|
69 | # print "//%s" % prop
|
---|
70 | #
|
---|
71 | print """
|
---|
72 | static void crRecDumpPrintVal(CR_DUMPER *pDumper, struct nv_struct *pDesc, float *pfData)
|
---|
73 | {
|
---|
74 | char aBuf[4096];
|
---|
75 | crDmpFormatArray(aBuf, sizeof (aBuf), "%f", sizeof (float), pfData, pDesc->num_values);
|
---|
76 | crDmpStrF(pDumper, "%s = %s;", pDesc->pszName, aBuf);
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | void crRecDumpGlGetState(CR_RECORDER *pRec, CRContext *ctx)
|
---|
81 | {
|
---|
82 | float afData[CR_MAX_GET_VALUES];
|
---|
83 | struct nv_struct *pDesc;
|
---|
84 |
|
---|
85 | for (pDesc = num_values_array; pDesc->num_values != 0 ; pDesc++)
|
---|
86 | {
|
---|
87 | memset(afData, 0, sizeof(afData));
|
---|
88 | pRec->pDispatch->GetFloatv(pDesc->pname, afData);
|
---|
89 | crRecDumpPrintVal(pRec->pDumper, pDesc, afData);
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | void crRecDumpGlEnableState(CR_RECORDER *pRec, CRContext *ctx)
|
---|
94 | {
|
---|
95 | GLboolean fEnabled;
|
---|
96 | """
|
---|
97 | keys = params.keys()
|
---|
98 | keys.sort();
|
---|
99 |
|
---|
100 | for pname in keys:
|
---|
101 | print "\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname
|
---|
102 | print "\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname
|
---|
103 |
|
---|
104 | keys = extended_params.keys();
|
---|
105 | keys.sort()
|
---|
106 |
|
---|
107 | for pname in keys:
|
---|
108 | (srctype,ifdef,fields) = extended_params[pname]
|
---|
109 | ext = ifdef[3:] # the extension name with the "GL_" prefix removed
|
---|
110 | ext = ifdef
|
---|
111 | print '#ifdef CR_%s' % ext
|
---|
112 | print "\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname
|
---|
113 | print "\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname
|
---|
114 | print '#endif /* CR_%s */' % ext
|
---|
115 |
|
---|
116 | #print "//missing enable props:"
|
---|
117 | #for prop in enableprops:
|
---|
118 | # try:
|
---|
119 | # keyvalues = params[prop]
|
---|
120 | # except KeyError:
|
---|
121 | # try:
|
---|
122 | # keyvalues = extended_params[prop]
|
---|
123 | # except KeyError:
|
---|
124 | # print "//%s" % prop
|
---|
125 | #
|
---|
126 | print """
|
---|
127 | }
|
---|
128 | #endif
|
---|
129 | """
|
---|
130 |
|
---|
131 | texenv_mappings = {
|
---|
132 | 'GL_TEXTURE_ENV' : [
|
---|
133 | 'GL_TEXTURE_ENV_MODE',
|
---|
134 | 'GL_TEXTURE_ENV_COLOR',
|
---|
135 | 'GL_COMBINE_RGB',
|
---|
136 | 'GL_COMBINE_ALPHA',
|
---|
137 | 'GL_RGB_SCALE',
|
---|
138 | 'GL_ALPHA_SCALE',
|
---|
139 | 'GL_SRC0_RGB',
|
---|
140 | 'GL_SRC1_RGB',
|
---|
141 | 'GL_SRC2_RGB',
|
---|
142 | 'GL_SRC0_ALPHA',
|
---|
143 | 'GL_SRC1_ALPHA',
|
---|
144 | 'GL_SRC2_ALPHA'
|
---|
145 | ],
|
---|
146 | 'GL_TEXTURE_FILTER_CONTROL' : [
|
---|
147 | 'GL_TEXTURE_LOD_BIAS'
|
---|
148 | ],
|
---|
149 | 'GL_POINT_SPRITE' : [
|
---|
150 | 'GL_COORD_REPLACE'
|
---|
151 | ]
|
---|
152 | }
|
---|
153 |
|
---|
154 | texgen_coords = [
|
---|
155 | 'GL_S',
|
---|
156 | 'GL_T',
|
---|
157 | 'GL_R',
|
---|
158 | 'GL_Q'
|
---|
159 | ]
|
---|
160 |
|
---|
161 | texgen_names = [
|
---|
162 | 'GL_TEXTURE_GEN_MODE',
|
---|
163 | 'GL_OBJECT_PLANE',
|
---|
164 | 'GL_EYE_PLANE'
|
---|
165 | ]
|
---|
166 |
|
---|
167 | texparam_names = [
|
---|
168 | 'GL_TEXTURE_MAG_FILTER',
|
---|
169 | 'GL_TEXTURE_MIN_FILTER',
|
---|
170 | 'GL_TEXTURE_MIN_LOD',
|
---|
171 | 'GL_TEXTURE_MAX_LOD',
|
---|
172 | 'GL_TEXTURE_BASE_LEVEL',
|
---|
173 | 'GL_TEXTURE_MAX_LEVEL',
|
---|
174 | 'GL_TEXTURE_WRAP_S',
|
---|
175 | 'GL_TEXTURE_WRAP_T',
|
---|
176 | 'GL_TEXTURE_WRAP_R',
|
---|
177 | 'GL_TEXTURE_BORDER_COLOR',
|
---|
178 | 'GL_TEXTURE_PRIORITY',
|
---|
179 | 'GL_TEXTURE_RESIDENT',
|
---|
180 | 'GL_TEXTURE_COMPARE_MODE',
|
---|
181 | 'GL_TEXTURE_COMPARE_FUNC',
|
---|
182 | 'GL_DEPTH_TEXTURE_MODE',
|
---|
183 | 'GL_GENERATE_MIPMAP'
|
---|
184 | ]
|
---|
185 |
|
---|
186 | print """
|
---|
187 | void crRecDumpTexParam(CR_RECORDER *pRec, CRContext *ctx, GLenum enmTarget)
|
---|
188 | {
|
---|
189 | GLfloat afBuf[4];
|
---|
190 | char acBuf[1024];
|
---|
191 | unsigned int cComponents;
|
---|
192 | crDmpStrF(pRec->pDumper, "==TEX_PARAM for target(0x%x)==", enmTarget);
|
---|
193 | """
|
---|
194 | for pname in texparam_names:
|
---|
195 | print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
|
---|
196 | print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
|
---|
197 | print "\tmemset(afBuf, 0, sizeof (afBuf));"
|
---|
198 | print "\tpRec->pDispatch->GetTexParameterfv(enmTarget, %s, afBuf);" % pname
|
---|
199 | print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
|
---|
200 | print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
|
---|
201 | print """
|
---|
202 | crDmpStrF(pRec->pDumper, "==Done TEX_PARAM for target(0x%x)==", enmTarget);
|
---|
203 | }
|
---|
204 | """
|
---|
205 |
|
---|
206 | print """
|
---|
207 | void crRecDumpTexEnv(CR_RECORDER *pRec, CRContext *ctx)
|
---|
208 | {
|
---|
209 | GLfloat afBuf[4];
|
---|
210 | char acBuf[1024];
|
---|
211 | unsigned int cComponents;
|
---|
212 | crDmpStrF(pRec->pDumper, "==TEX_ENV==");
|
---|
213 | """
|
---|
214 |
|
---|
215 | keys = texenv_mappings.keys()
|
---|
216 | keys.sort();
|
---|
217 |
|
---|
218 | for target in keys:
|
---|
219 | print "\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % target
|
---|
220 | values = texenv_mappings[target]
|
---|
221 | for pname in values:
|
---|
222 | print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
|
---|
223 | print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
|
---|
224 | print "\tmemset(afBuf, 0, sizeof (afBuf));"
|
---|
225 | print "\tpRec->pDispatch->GetTexEnvfv(%s, %s, afBuf);" % (target, pname)
|
---|
226 | print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
|
---|
227 | print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
|
---|
228 | print "\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % target
|
---|
229 | print """
|
---|
230 | crDmpStrF(pRec->pDumper, "==Done TEX_ENV==");
|
---|
231 | }
|
---|
232 | """
|
---|
233 |
|
---|
234 |
|
---|
235 | print """
|
---|
236 | void crRecDumpTexGen(CR_RECORDER *pRec, CRContext *ctx)
|
---|
237 | {
|
---|
238 | GLdouble afBuf[4];
|
---|
239 | char acBuf[1024];
|
---|
240 | unsigned int cComponents;
|
---|
241 | crDmpStrF(pRec->pDumper, "==TEX_GEN==");
|
---|
242 | """
|
---|
243 |
|
---|
244 | for coord in texgen_coords:
|
---|
245 | print "\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % coord
|
---|
246 | for pname in texgen_names:
|
---|
247 | print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
|
---|
248 | print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
|
---|
249 | print "\tmemset(afBuf, 0, sizeof (afBuf));"
|
---|
250 | print "\tpRec->pDispatch->GetTexGendv(%s, %s, afBuf);" % (coord, pname)
|
---|
251 | print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
|
---|
252 | print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
|
---|
253 | print "\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % coord
|
---|
254 | print """
|
---|
255 | crDmpStrF(pRec->pDumper, "==Done TEX_GEN==");
|
---|
256 | }
|
---|
257 | """
|
---|