VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py@ 46741

Last change on this file since 46741 was 46515, checked in by vboxsync, 12 years ago

crOpenGL: more debugging/dumping

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1import sys
2
3import apiutil
4
5import sys, re, string
6
7
8line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s+(.*)\s*$')
9extensions_line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s(\S+)\s+(.*)\s*$')
10
11params = {}
12extended_params = {}
13
14input = open( sys.argv[2]+"/state_isenabled.txt", 'r' )
15for 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
23input = open( sys.argv[2]+"/state_extensions_isenabled.txt", 'r' )
24for 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
34apiutil.CopyrightC()
35
36print """#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
56from get_sizes import *;
57
58getprops = apiutil.ParamProps("GetDoublev")
59enableprops = 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#
71print """
72static 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
80void 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
93void crRecDumpGlEnableState(CR_RECORDER *pRec, CRContext *ctx)
94{
95 GLboolean fEnabled;
96"""
97keys = params.keys()
98keys.sort();
99
100for pname in keys:
101 print "\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname
102 print "\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname
103
104keys = extended_params.keys();
105keys.sort()
106
107for 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#
126print """
127}
128#endif
129"""
130
131from get_components import *;
132
133texenv_mappings = {
134 'GL_TEXTURE_ENV' : [
135 'GL_TEXTURE_ENV_MODE',
136 'GL_TEXTURE_ENV_COLOR',
137 'GL_COMBINE_RGB',
138 'GL_COMBINE_ALPHA',
139 'GL_RGB_SCALE',
140 'GL_ALPHA_SCALE',
141 'GL_SRC0_RGB',
142 'GL_SRC1_RGB',
143 'GL_SRC2_RGB',
144 'GL_SRC0_ALPHA',
145 'GL_SRC1_ALPHA',
146 'GL_SRC2_ALPHA'
147 ],
148 'GL_TEXTURE_FILTER_CONTROL' : [
149 'GL_TEXTURE_LOD_BIAS'
150 ],
151 'GL_POINT_SPRITE' : [
152 'GL_COORD_REPLACE'
153 ]
154}
155
156texgen_coords = [
157 'GL_S',
158 'GL_T',
159 'GL_R',
160 'GL_Q'
161]
162
163texgen_names = [
164 'GL_TEXTURE_GEN_MODE',
165 'GL_OBJECT_PLANE',
166 'GL_EYE_PLANE'
167]
168
169texparam_names = [
170 'GL_TEXTURE_MAG_FILTER',
171 'GL_TEXTURE_MIN_FILTER',
172 'GL_TEXTURE_MIN_LOD',
173 'GL_TEXTURE_MAX_LOD',
174 'GL_TEXTURE_BASE_LEVEL',
175 'GL_TEXTURE_MAX_LEVEL',
176 'GL_TEXTURE_WRAP_S',
177 'GL_TEXTURE_WRAP_T',
178 'GL_TEXTURE_WRAP_R',
179 'GL_TEXTURE_BORDER_COLOR',
180 'GL_TEXTURE_PRIORITY',
181 'GL_TEXTURE_RESIDENT',
182 'GL_TEXTURE_COMPARE_MODE',
183 'GL_TEXTURE_COMPARE_FUNC',
184 'GL_DEPTH_TEXTURE_MODE',
185 'GL_GENERATE_MIPMAP'
186]
187
188print """
189void crRecDumpTexParam(CR_RECORDER *pRec, CRContext *ctx, GLenum enmTarget)
190{
191 GLfloat afBuf[4];
192 char acBuf[1024];
193 unsigned int cComponents;
194 crDmpStrF(pRec->pDumper, "==TEX_PARAM for target(0x%x)==", enmTarget);
195"""
196for pname in texparam_names:
197 print "\tcComponents = lookupComponents(%s);" % pname
198 print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
199 print "\tmemset(afBuf, 0, sizeof (afBuf));"
200 print "\tpRec->pDispatch->GetTexParameterfv(enmTarget, %s, afBuf);" % pname
201 print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
202 print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
203print """
204 crDmpStrF(pRec->pDumper, "==Done TEX_PARAM for target(0x%x)==", enmTarget);
205}
206"""
207
208print """
209void crRecDumpTexEnv(CR_RECORDER *pRec, CRContext *ctx)
210{
211 GLfloat afBuf[4];
212 char acBuf[1024];
213 unsigned int cComponents;
214 crDmpStrF(pRec->pDumper, "==TEX_ENV==");
215"""
216
217keys = texenv_mappings.keys()
218keys.sort();
219
220for target in keys:
221 print "\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % target
222 values = texenv_mappings[target]
223 for pname in values:
224 print "\tcComponents = lookupComponents(%s);" % pname
225 print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
226 print "\tmemset(afBuf, 0, sizeof (afBuf));"
227 print "\tpRec->pDispatch->GetTexEnvfv(%s, %s, afBuf);" % (target, pname)
228 print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
229 print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
230 print "\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % target
231print """
232 crDmpStrF(pRec->pDumper, "==Done TEX_ENV==");
233}
234"""
235
236
237print """
238void crRecDumpTexGen(CR_RECORDER *pRec, CRContext *ctx)
239{
240 GLdouble afBuf[4];
241 char acBuf[1024];
242 unsigned int cComponents;
243 crDmpStrF(pRec->pDumper, "==TEX_GEN==");
244"""
245
246for coord in texgen_coords:
247 print "\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % coord
248 for pname in texgen_names:
249 print "\tcComponents = lookupComponents(%s);" % pname
250 print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
251 print "\tmemset(afBuf, 0, sizeof (afBuf));"
252 print "\tpRec->pDispatch->GetTexGendv(%s, %s, afBuf);" % (coord, pname)
253 print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
254 print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
255 print "\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % coord
256print """
257 crDmpStrF(pRec->pDumper, "==Done TEX_GEN==");
258}
259"""
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette