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_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 | for pname in sorted(params.keys()):
|
---|
98 | print("\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname)
|
---|
99 | print("\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname)
|
---|
100 |
|
---|
101 | for pname in sorted(extended_params.keys()):
|
---|
102 | (srctype,ifdef,fields) = extended_params[pname]
|
---|
103 | ext = ifdef[3:] # the extension name with the "GL_" prefix removed
|
---|
104 | ext = ifdef
|
---|
105 | print('#ifdef CR_%s' % ext)
|
---|
106 | print("\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname)
|
---|
107 | print("\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname)
|
---|
108 | print('#endif /* CR_%s */' % ext)
|
---|
109 |
|
---|
110 | #print "//missing enable props:"
|
---|
111 | #for prop in enableprops:
|
---|
112 | # try:
|
---|
113 | # keyvalues = params[prop]
|
---|
114 | # except KeyError:
|
---|
115 | # try:
|
---|
116 | # keyvalues = extended_params[prop]
|
---|
117 | # except KeyError:
|
---|
118 | # print "//%s" % prop
|
---|
119 | #
|
---|
120 | print("""
|
---|
121 | }
|
---|
122 | #endif
|
---|
123 | """)
|
---|
124 |
|
---|
125 | texenv_mappings = {
|
---|
126 | 'GL_TEXTURE_ENV' : [
|
---|
127 | 'GL_TEXTURE_ENV_MODE',
|
---|
128 | 'GL_TEXTURE_ENV_COLOR',
|
---|
129 | 'GL_COMBINE_RGB',
|
---|
130 | 'GL_COMBINE_ALPHA',
|
---|
131 | 'GL_RGB_SCALE',
|
---|
132 | 'GL_ALPHA_SCALE',
|
---|
133 | 'GL_SRC0_RGB',
|
---|
134 | 'GL_SRC1_RGB',
|
---|
135 | 'GL_SRC2_RGB',
|
---|
136 | 'GL_SRC0_ALPHA',
|
---|
137 | 'GL_SRC1_ALPHA',
|
---|
138 | 'GL_SRC2_ALPHA'
|
---|
139 | ],
|
---|
140 | 'GL_TEXTURE_FILTER_CONTROL' : [
|
---|
141 | 'GL_TEXTURE_LOD_BIAS'
|
---|
142 | ],
|
---|
143 | 'GL_POINT_SPRITE' : [
|
---|
144 | 'GL_COORD_REPLACE'
|
---|
145 | ]
|
---|
146 | }
|
---|
147 |
|
---|
148 | texgen_coords = [
|
---|
149 | 'GL_S',
|
---|
150 | 'GL_T',
|
---|
151 | 'GL_R',
|
---|
152 | 'GL_Q'
|
---|
153 | ]
|
---|
154 |
|
---|
155 | texgen_names = [
|
---|
156 | 'GL_TEXTURE_GEN_MODE',
|
---|
157 | 'GL_OBJECT_PLANE',
|
---|
158 | 'GL_EYE_PLANE'
|
---|
159 | ]
|
---|
160 |
|
---|
161 | texparam_names = [
|
---|
162 | 'GL_TEXTURE_MAG_FILTER',
|
---|
163 | 'GL_TEXTURE_MIN_FILTER',
|
---|
164 | 'GL_TEXTURE_MIN_LOD',
|
---|
165 | 'GL_TEXTURE_MAX_LOD',
|
---|
166 | 'GL_TEXTURE_BASE_LEVEL',
|
---|
167 | 'GL_TEXTURE_MAX_LEVEL',
|
---|
168 | 'GL_TEXTURE_WRAP_S',
|
---|
169 | 'GL_TEXTURE_WRAP_T',
|
---|
170 | 'GL_TEXTURE_WRAP_R',
|
---|
171 | 'GL_TEXTURE_BORDER_COLOR',
|
---|
172 | 'GL_TEXTURE_PRIORITY',
|
---|
173 | 'GL_TEXTURE_RESIDENT',
|
---|
174 | 'GL_TEXTURE_COMPARE_MODE',
|
---|
175 | 'GL_TEXTURE_COMPARE_FUNC',
|
---|
176 | 'GL_DEPTH_TEXTURE_MODE',
|
---|
177 | 'GL_GENERATE_MIPMAP'
|
---|
178 | ]
|
---|
179 |
|
---|
180 | print("""
|
---|
181 | void crRecDumpTexParam(CR_RECORDER *pRec, CRContext *ctx, GLenum enmTarget)
|
---|
182 | {
|
---|
183 | GLfloat afBuf[4];
|
---|
184 | char acBuf[1024];
|
---|
185 | unsigned int cComponents;
|
---|
186 | crDmpStrF(pRec->pDumper, "==TEX_PARAM for target(0x%x)==", enmTarget);
|
---|
187 | """)
|
---|
188 | for pname in texparam_names:
|
---|
189 | print("\tcComponents = crStateHlpComponentsCount(%s);" % pname)
|
---|
190 | print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));")
|
---|
191 | print("\tmemset(afBuf, 0, sizeof (afBuf));")
|
---|
192 | print("\tpRec->pDispatch->GetTexParameterfv(enmTarget, %s, afBuf);" % pname)
|
---|
193 | print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);")
|
---|
194 | print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname)
|
---|
195 | print("""
|
---|
196 | crDmpStrF(pRec->pDumper, "==Done TEX_PARAM for target(0x%x)==", enmTarget);
|
---|
197 | }
|
---|
198 | """)
|
---|
199 |
|
---|
200 | print("""
|
---|
201 | void crRecDumpTexEnv(CR_RECORDER *pRec, CRContext *ctx)
|
---|
202 | {
|
---|
203 | GLfloat afBuf[4];
|
---|
204 | char acBuf[1024];
|
---|
205 | unsigned int cComponents;
|
---|
206 | crDmpStrF(pRec->pDumper, "==TEX_ENV==");
|
---|
207 | """)
|
---|
208 |
|
---|
209 | for target in sorted(texenv_mappings.keys()):
|
---|
210 | print("\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % target)
|
---|
211 | values = texenv_mappings[target]
|
---|
212 | for pname in values:
|
---|
213 | print("\tcComponents = crStateHlpComponentsCount(%s);" % pname)
|
---|
214 | print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));")
|
---|
215 | print("\tmemset(afBuf, 0, sizeof (afBuf));")
|
---|
216 | print("\tpRec->pDispatch->GetTexEnvfv(%s, %s, afBuf);" % (target, pname))
|
---|
217 | print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);")
|
---|
218 | print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname)
|
---|
219 | print("\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % target)
|
---|
220 | print("""
|
---|
221 | crDmpStrF(pRec->pDumper, "==Done TEX_ENV==");
|
---|
222 | }
|
---|
223 | """)
|
---|
224 |
|
---|
225 |
|
---|
226 | print("""
|
---|
227 | void crRecDumpTexGen(CR_RECORDER *pRec, CRContext *ctx)
|
---|
228 | {
|
---|
229 | GLdouble afBuf[4];
|
---|
230 | char acBuf[1024];
|
---|
231 | unsigned int cComponents;
|
---|
232 | crDmpStrF(pRec->pDumper, "==TEX_GEN==");
|
---|
233 | """)
|
---|
234 |
|
---|
235 | for coord in texgen_coords:
|
---|
236 | print("\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % coord)
|
---|
237 | for pname in texgen_names:
|
---|
238 | print("\tcComponents = crStateHlpComponentsCount(%s);" % pname)
|
---|
239 | print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));")
|
---|
240 | print("\tmemset(afBuf, 0, sizeof (afBuf));")
|
---|
241 | print("\tpRec->pDispatch->GetTexGendv(%s, %s, afBuf);" % (coord, pname))
|
---|
242 | print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);")
|
---|
243 | print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname)
|
---|
244 | print("\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % coord)
|
---|
245 | print("""
|
---|
246 | crDmpStrF(pRec->pDumper, "==Done TEX_GEN==");
|
---|
247 | }
|
---|
248 | """)
|
---|