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