VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dbg/DumpD3DCaps9.cpp

Last change on this file was 98141, checked in by vboxsync, 17 months ago

Add/WinNT/Graphics: Converted some optionally compiled 3D related tests and windbg extensions from VBOXR3STATIC to more appropriate templates and made them build again. Guard is now called VBOX_WITH_VBOXVIDEOWINDBG. bugref:10348

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 44.0 KB
Line 
1/* $Id: DumpD3DCaps9.cpp 98141 2023-01-19 14:25:46Z vboxsync $ */
2/** @file
3 * ???
4 */
5
6/*
7 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#include <iprt/win/windows.h>
29#include <d3d9types.h>
30#include <d3d9caps.h>
31#include <d3d9.h>
32#include <stdio.h>
33
34#define MAX(_v1, _v2) ((_v1) > (_v2) ? (_v1) : (_v2))
35#define MIN(_v1, _v2) ((_v1) < (_v2) ? (_v1) : (_v2))
36
37#define MISSING_FLAGS(_dw1, _dw2) ((_dw2) & ((_dw1) ^ (_dw2)))
38
39#define MyLog(_m) do { printf _m ; } while (0)
40
41#define DUMP_STRCASE(_t) \
42 case _t: { MyLog(("%s", #_t"")); break; }
43#define DUMP_STRCASE_DEFAULT_INT(_dw) \
44 default: { MyLog(("0x%08x", (_dw))); break; }
45
46#define DUMP_STRIF_INIT(_ps, _t) \
47 const char * _pSep = (_ps); \
48 bool _fSep = false; \
49 _t _fFlags = 0; \
50
51#define DUMP_STRIF(_v, _t) do { \
52 if ((_v) & _t) { \
53 if (_fSep) { \
54 MyLog(("%s%s", _pSep ,#_t"")); \
55 } \
56 else { \
57 MyLog(("%s", #_t"")); \
58 _fSep = !!_pSep; \
59 } \
60 _fFlags |= _t; \
61 } \
62 } while (0)
63
64#define DUMP_STRIF_MISSED(_dw) do { \
65 _fFlags = MISSING_FLAGS(_fFlags, _dw); \
66 if (_fFlags) { \
67 if (_fSep) { \
68 MyLog(("%s0x%08lx", _pSep, (_fFlags))); \
69 } \
70 else { \
71 MyLog(("0x%08lx", (_fFlags))); \
72 _fSep = !!_pSep; \
73 } \
74 } \
75 _fFlags = _dw & ~(_fFlags); /* revert the flags valus back */ \
76 } while (0)
77
78/*
79#define DUMP_DIFF_CAPS_VAL(_f, _name, _c1, _c2) do { \
80 DWORD dwTmp = MISSING_FLAGS((_c1), (_c2)); \
81 if (dwTmp) { _f(_name " |= ", " | ", dwTmp, ";\n"); } \
82 dwTmp = MISSING_FLAGS((_c2), (_c1)); \
83 if (dwTmp) { _f("// " _name " &= ~(", " | ", dwTmp, ");\n"); } \
84 } while (0)
85
86#define DUMP_DIFF_CAPS_FIELD(_f, _field, _name, _c1, _c2) DUMP_DIFF_CAPS_VAL(_f, _name""_field, (_c1)->_field, (_c2)->_field)
87*/
88#define DUMP_DIFF_CAPS(_f, _field) do { \
89 DWORD dwTmp = MISSING_FLAGS((pCaps1->_field), (pCaps2->_field)); \
90 if (dwTmp) { _f("pCaps->" #_field " |= ", " | ", dwTmp, ";\n"); } \
91 dwTmp = MISSING_FLAGS((pCaps2->_field), (pCaps1->_field)); \
92 if (dwTmp) { _f("// pCaps->" #_field " &= ~(", " | ", dwTmp, ");\n"); } \
93 } while (0)
94
95#define DUMP_DIFF_VAL(_field, _format) do { \
96 if (pCaps1->_field != pCaps2->_field) { MyLog(("pCaps->" #_field " = " _format "; // " _format " \n", pCaps2->_field, pCaps1->_field)); } \
97 } while (0)
98
99static void printDeviceType(const char* pszPrefix, D3DDEVTYPE DeviceType, const char* pszSuffix)
100{
101 MyLog(("%s", pszPrefix));
102 switch(DeviceType)
103 {
104 DUMP_STRCASE(D3DDEVTYPE_HAL)
105 DUMP_STRCASE(D3DDEVTYPE_REF)
106 DUMP_STRCASE(D3DDEVTYPE_SW)
107 DUMP_STRCASE(D3DDEVTYPE_NULLREF)
108 DUMP_STRCASE_DEFAULT_INT(DeviceType)
109 }
110 MyLog(("%s", pszSuffix));
111}
112
113static void printCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
114{
115 DUMP_STRIF_INIT(pszSeparator, DWORD);
116 MyLog(("%s", pszPrefix));
117// DUMP_STRIF(Caps, D3DCAPS_OVERLAY);
118 DUMP_STRIF(Caps, D3DCAPS_READ_SCANLINE);
119 DUMP_STRIF_MISSED(Caps);
120 MyLog(("%s", pszSuffix));
121}
122
123
124static void printCaps2(const char* pszPrefix, const char* pszSeparator, DWORD Caps2, const char* pszSuffix)
125{
126 DUMP_STRIF_INIT(pszSeparator, DWORD);
127 MyLog(("%s", pszPrefix));
128 DUMP_STRIF(Caps2, D3DCAPS2_FULLSCREENGAMMA);
129 DUMP_STRIF(Caps2, D3DCAPS2_CANCALIBRATEGAMMA);
130 DUMP_STRIF(Caps2, D3DCAPS2_RESERVED);
131 DUMP_STRIF(Caps2, D3DCAPS2_CANMANAGERESOURCE);
132 DUMP_STRIF(Caps2, D3DCAPS2_DYNAMICTEXTURES);
133 DUMP_STRIF(Caps2, D3DCAPS2_CANAUTOGENMIPMAP);
134 DUMP_STRIF(Caps2, D3DCAPS2_CANSHARERESOURCE);
135 DUMP_STRIF_MISSED(Caps2);
136 MyLog(("%s", pszSuffix));
137}
138
139static void printCaps3(const char* pszPrefix, const char* pszSeparator, DWORD Caps3, const char* pszSuffix)
140{
141 DUMP_STRIF_INIT(pszSeparator, DWORD);
142 MyLog(("%s", pszPrefix));
143 DUMP_STRIF(Caps3, D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD);
144 DUMP_STRIF(Caps3, D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION);
145 DUMP_STRIF(Caps3, D3DCAPS3_COPY_TO_VIDMEM);
146 DUMP_STRIF(Caps3, D3DCAPS3_COPY_TO_SYSTEMMEM);
147// DUMP_STRIF(Caps3, D3DCAPS3_DXVAHD);
148 DUMP_STRIF_MISSED(Caps3);
149 MyLog(("%s", pszSuffix));
150}
151
152static void printPresentationIntervals(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
153{
154 DUMP_STRIF_INIT(pszSeparator, DWORD);
155 MyLog(("%s", pszPrefix));
156 DUMP_STRIF(Caps, D3DPRESENT_INTERVAL_ONE);
157 DUMP_STRIF(Caps, D3DPRESENT_INTERVAL_TWO);
158 DUMP_STRIF(Caps, D3DPRESENT_INTERVAL_THREE);
159 DUMP_STRIF(Caps, D3DPRESENT_INTERVAL_FOUR);
160 DUMP_STRIF(Caps, D3DPRESENT_INTERVAL_IMMEDIATE);
161 DUMP_STRIF_MISSED(Caps);
162 MyLog(("%s", pszSuffix));
163}
164
165static void printCursorCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
166{
167 DUMP_STRIF_INIT(pszSeparator, DWORD);
168 MyLog(("%s", pszPrefix));
169 DUMP_STRIF(Caps, D3DCURSORCAPS_COLOR);
170 DUMP_STRIF(Caps, D3DCURSORCAPS_LOWRES);
171 DUMP_STRIF_MISSED(Caps);
172 MyLog(("%s", pszSuffix));
173}
174
175static void printDevCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
176{
177 DUMP_STRIF_INIT(pszSeparator, DWORD);
178 MyLog(("%s", pszPrefix));
179 DUMP_STRIF(Caps, D3DDEVCAPS_EXECUTESYSTEMMEMORY);
180 DUMP_STRIF(Caps, D3DDEVCAPS_EXECUTEVIDEOMEMORY);
181 DUMP_STRIF(Caps, D3DDEVCAPS_TLVERTEXSYSTEMMEMORY);
182 DUMP_STRIF(Caps, D3DDEVCAPS_TLVERTEXVIDEOMEMORY);
183 DUMP_STRIF(Caps, D3DDEVCAPS_TEXTURESYSTEMMEMORY);
184 DUMP_STRIF(Caps, D3DDEVCAPS_TEXTUREVIDEOMEMORY);
185 DUMP_STRIF(Caps, D3DDEVCAPS_DRAWPRIMTLVERTEX);
186 DUMP_STRIF(Caps, D3DDEVCAPS_CANRENDERAFTERFLIP);
187 DUMP_STRIF(Caps, D3DDEVCAPS_TEXTURENONLOCALVIDMEM);
188 DUMP_STRIF(Caps, D3DDEVCAPS_DRAWPRIMITIVES2);
189 DUMP_STRIF(Caps, D3DDEVCAPS_SEPARATETEXTUREMEMORIES);
190 DUMP_STRIF(Caps, D3DDEVCAPS_DRAWPRIMITIVES2EX);
191 DUMP_STRIF(Caps, D3DDEVCAPS_HWTRANSFORMANDLIGHT);
192 DUMP_STRIF(Caps, D3DDEVCAPS_CANBLTSYSTONONLOCAL);
193 DUMP_STRIF(Caps, D3DDEVCAPS_HWRASTERIZATION);
194 DUMP_STRIF(Caps, D3DDEVCAPS_PUREDEVICE);
195 DUMP_STRIF(Caps, D3DDEVCAPS_QUINTICRTPATCHES);
196 DUMP_STRIF(Caps, D3DDEVCAPS_RTPATCHES);
197 DUMP_STRIF(Caps, D3DDEVCAPS_RTPATCHHANDLEZERO);
198 DUMP_STRIF(Caps, D3DDEVCAPS_NPATCHES);
199 DUMP_STRIF_MISSED(Caps);
200 MyLog(("%s", pszSuffix));
201}
202
203static void printPrimitiveMiscCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
204{
205 DUMP_STRIF_INIT(pszSeparator, DWORD);
206 MyLog(("%s", pszPrefix));
207 DUMP_STRIF(Caps, D3DPMISCCAPS_MASKZ);
208 DUMP_STRIF(Caps, D3DPMISCCAPS_CULLNONE);
209 DUMP_STRIF(Caps, D3DPMISCCAPS_CULLCW);
210 DUMP_STRIF(Caps, D3DPMISCCAPS_CULLCCW);
211 DUMP_STRIF(Caps, D3DPMISCCAPS_COLORWRITEENABLE);
212 DUMP_STRIF(Caps, D3DPMISCCAPS_CLIPPLANESCALEDPOINTS);
213 DUMP_STRIF(Caps, D3DPMISCCAPS_CLIPTLVERTS);
214 DUMP_STRIF(Caps, D3DPMISCCAPS_TSSARGTEMP);
215 DUMP_STRIF(Caps, D3DPMISCCAPS_BLENDOP);
216 DUMP_STRIF(Caps, D3DPMISCCAPS_NULLREFERENCE);
217 DUMP_STRIF(Caps, D3DPMISCCAPS_INDEPENDENTWRITEMASKS);
218 DUMP_STRIF(Caps, D3DPMISCCAPS_PERSTAGECONSTANT);
219 DUMP_STRIF(Caps, D3DPMISCCAPS_FOGANDSPECULARALPHA);
220 DUMP_STRIF(Caps, D3DPMISCCAPS_SEPARATEALPHABLEND);
221 DUMP_STRIF(Caps, D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS);
222 DUMP_STRIF(Caps, D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING);
223 DUMP_STRIF(Caps, D3DPMISCCAPS_FOGVERTEXCLAMPED);
224 DUMP_STRIF(Caps, D3DPMISCCAPS_POSTBLENDSRGBCONVERT);
225 DUMP_STRIF_MISSED(Caps);
226 MyLog(("%s", pszSuffix));
227}
228
229static void printRasterCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
230{
231 DUMP_STRIF_INIT(pszSeparator, DWORD);
232 MyLog(("%s", pszPrefix));
233 DUMP_STRIF(Caps, D3DPRASTERCAPS_DITHER);
234 DUMP_STRIF(Caps, D3DPRASTERCAPS_ZTEST);
235 DUMP_STRIF(Caps, D3DPRASTERCAPS_FOGVERTEX);
236 DUMP_STRIF(Caps, D3DPRASTERCAPS_FOGTABLE);
237 DUMP_STRIF(Caps, D3DPRASTERCAPS_MIPMAPLODBIAS);
238 DUMP_STRIF(Caps, D3DPRASTERCAPS_ZBUFFERLESSHSR);
239 DUMP_STRIF(Caps, D3DPRASTERCAPS_FOGRANGE);
240 DUMP_STRIF(Caps, D3DPRASTERCAPS_ANISOTROPY);
241 DUMP_STRIF(Caps, D3DPRASTERCAPS_WBUFFER);
242 DUMP_STRIF(Caps, D3DPRASTERCAPS_WFOG);
243 DUMP_STRIF(Caps, D3DPRASTERCAPS_ZFOG);
244 DUMP_STRIF(Caps, D3DPRASTERCAPS_COLORPERSPECTIVE);
245 DUMP_STRIF(Caps, D3DPRASTERCAPS_SCISSORTEST);
246 DUMP_STRIF(Caps, D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS);
247 DUMP_STRIF(Caps, D3DPRASTERCAPS_DEPTHBIAS);
248 DUMP_STRIF(Caps, D3DPRASTERCAPS_MULTISAMPLE_TOGGLE);
249 DUMP_STRIF_MISSED(Caps);
250 MyLog(("%s", pszSuffix));
251}
252
253static void printCmpCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
254{
255 DUMP_STRIF_INIT(pszSeparator, DWORD);
256 MyLog(("%s", pszPrefix));
257 DUMP_STRIF(Caps, D3DPCMPCAPS_NEVER);
258 DUMP_STRIF(Caps, D3DPCMPCAPS_LESS);
259 DUMP_STRIF(Caps, D3DPCMPCAPS_EQUAL);
260 DUMP_STRIF(Caps, D3DPCMPCAPS_LESSEQUAL);
261 DUMP_STRIF(Caps, D3DPCMPCAPS_GREATER);
262 DUMP_STRIF(Caps, D3DPCMPCAPS_NOTEQUAL);
263 DUMP_STRIF(Caps, D3DPCMPCAPS_GREATEREQUAL);
264 DUMP_STRIF(Caps, D3DPCMPCAPS_ALWAYS);
265 DUMP_STRIF_MISSED(Caps);
266 MyLog(("%s", pszSuffix));
267}
268
269static void printBlendCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
270{
271 DUMP_STRIF_INIT(pszSeparator, DWORD);
272 MyLog(("%s", pszPrefix));
273 DUMP_STRIF(Caps, D3DPBLENDCAPS_ZERO);
274 DUMP_STRIF(Caps, D3DPBLENDCAPS_ONE);
275 DUMP_STRIF(Caps, D3DPBLENDCAPS_SRCCOLOR);
276 DUMP_STRIF(Caps, D3DPBLENDCAPS_INVSRCCOLOR);
277 DUMP_STRIF(Caps, D3DPBLENDCAPS_SRCALPHA);
278 DUMP_STRIF(Caps, D3DPBLENDCAPS_INVSRCALPHA);
279 DUMP_STRIF(Caps, D3DPBLENDCAPS_DESTALPHA);
280 DUMP_STRIF(Caps, D3DPBLENDCAPS_INVDESTALPHA);
281 DUMP_STRIF(Caps, D3DPBLENDCAPS_DESTCOLOR);
282 DUMP_STRIF(Caps, D3DPBLENDCAPS_INVDESTCOLOR);
283 DUMP_STRIF(Caps, D3DPBLENDCAPS_SRCALPHASAT);
284 DUMP_STRIF(Caps, D3DPBLENDCAPS_BOTHSRCALPHA);
285 DUMP_STRIF(Caps, D3DPBLENDCAPS_BOTHINVSRCALPHA);
286 DUMP_STRIF(Caps, D3DPBLENDCAPS_BLENDFACTOR);
287 DUMP_STRIF(Caps, D3DPBLENDCAPS_SRCCOLOR2);
288 DUMP_STRIF(Caps, D3DPBLENDCAPS_INVSRCCOLOR2);
289 DUMP_STRIF_MISSED(Caps);
290 MyLog(("%s", pszSuffix));
291}
292
293static void printShadeCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
294{
295 DUMP_STRIF_INIT(pszSeparator, DWORD);
296 MyLog(("%s", pszPrefix));
297 DUMP_STRIF(Caps, D3DPSHADECAPS_COLORGOURAUDRGB);
298 DUMP_STRIF(Caps, D3DPSHADECAPS_SPECULARGOURAUDRGB);
299 DUMP_STRIF(Caps, D3DPSHADECAPS_ALPHAGOURAUDBLEND);
300 DUMP_STRIF(Caps, D3DPSHADECAPS_FOGGOURAUD);
301 DUMP_STRIF_MISSED(Caps);
302 MyLog(("%s", pszSuffix));
303}
304
305static void printTextureCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
306{
307 DUMP_STRIF_INIT(pszSeparator, DWORD);
308 MyLog(("%s", pszPrefix));
309 DUMP_STRIF(Caps, D3DPTEXTURECAPS_PERSPECTIVE);
310 DUMP_STRIF(Caps, D3DPTEXTURECAPS_POW2);
311 DUMP_STRIF(Caps, D3DPTEXTURECAPS_ALPHA);
312 DUMP_STRIF(Caps, D3DPTEXTURECAPS_SQUAREONLY);
313 DUMP_STRIF(Caps, D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE);
314 DUMP_STRIF(Caps, D3DPTEXTURECAPS_ALPHAPALETTE);
315 DUMP_STRIF(Caps, D3DPTEXTURECAPS_NONPOW2CONDITIONAL);
316 DUMP_STRIF(Caps, D3DPTEXTURECAPS_PROJECTED);
317 DUMP_STRIF(Caps, D3DPTEXTURECAPS_CUBEMAP);
318 DUMP_STRIF(Caps, D3DPTEXTURECAPS_VOLUMEMAP);
319 DUMP_STRIF(Caps, D3DPTEXTURECAPS_MIPMAP);
320 DUMP_STRIF(Caps, D3DPTEXTURECAPS_MIPVOLUMEMAP);
321 DUMP_STRIF(Caps, D3DPTEXTURECAPS_MIPCUBEMAP);
322 DUMP_STRIF(Caps, D3DPTEXTURECAPS_CUBEMAP_POW2);
323 DUMP_STRIF(Caps, D3DPTEXTURECAPS_VOLUMEMAP_POW2);
324 DUMP_STRIF(Caps, D3DPTEXTURECAPS_NOPROJECTEDBUMPENV);
325 DUMP_STRIF_MISSED(Caps);
326 MyLog(("%s", pszSuffix));
327}
328
329static void printFilterCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
330{
331 DUMP_STRIF_INIT(pszSeparator, DWORD);
332 MyLog(("%s", pszPrefix));
333 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MINFPOINT);
334 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MINFLINEAR);
335 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MINFANISOTROPIC);
336 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MINFPYRAMIDALQUAD);
337 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MINFGAUSSIANQUAD);
338 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MIPFPOINT);
339 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MIPFLINEAR);
340 DUMP_STRIF(Caps, D3DPTFILTERCAPS_CONVOLUTIONMONO);
341 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MAGFPOINT);
342 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MAGFLINEAR);
343 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MAGFANISOTROPIC);
344 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD);
345 DUMP_STRIF(Caps, D3DPTFILTERCAPS_MAGFGAUSSIANQUAD);
346 DUMP_STRIF_MISSED(Caps);
347 MyLog(("%s", pszSuffix));
348}
349
350static void printTextureAddressCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
351{
352 DUMP_STRIF_INIT(pszSeparator, DWORD);
353 MyLog(("%s", pszPrefix));
354 DUMP_STRIF(Caps, D3DPTADDRESSCAPS_WRAP);
355 DUMP_STRIF(Caps, D3DPTADDRESSCAPS_MIRROR);
356 DUMP_STRIF(Caps, D3DPTADDRESSCAPS_CLAMP);
357 DUMP_STRIF(Caps, D3DPTADDRESSCAPS_BORDER);
358 DUMP_STRIF(Caps, D3DPTADDRESSCAPS_INDEPENDENTUV);
359 DUMP_STRIF(Caps, D3DPTADDRESSCAPS_MIRRORONCE);
360 DUMP_STRIF_MISSED(Caps);
361 MyLog(("%s", pszSuffix));
362}
363
364static void printLineCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
365{
366 DUMP_STRIF_INIT(pszSeparator, DWORD);
367 MyLog(("%s", pszPrefix));
368 DUMP_STRIF(Caps, D3DLINECAPS_TEXTURE);
369 DUMP_STRIF(Caps, D3DLINECAPS_ZTEST);
370 DUMP_STRIF(Caps, D3DLINECAPS_BLEND);
371 DUMP_STRIF(Caps, D3DLINECAPS_ALPHACMP);
372 DUMP_STRIF(Caps, D3DLINECAPS_FOG);
373 DUMP_STRIF(Caps, D3DLINECAPS_ANTIALIAS);
374 DUMP_STRIF_MISSED(Caps);
375 MyLog(("%s", pszSuffix));
376}
377
378static void printStencilCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
379{
380 DUMP_STRIF_INIT(pszSeparator, DWORD);
381 MyLog(("%s", pszPrefix));
382 DUMP_STRIF(Caps, D3DSTENCILCAPS_KEEP);
383 DUMP_STRIF(Caps, D3DSTENCILCAPS_ZERO);
384 DUMP_STRIF(Caps, D3DSTENCILCAPS_REPLACE);
385 DUMP_STRIF(Caps, D3DSTENCILCAPS_INCRSAT);
386 DUMP_STRIF(Caps, D3DSTENCILCAPS_DECRSAT);
387 DUMP_STRIF(Caps, D3DSTENCILCAPS_INVERT);
388 DUMP_STRIF(Caps, D3DSTENCILCAPS_INCR);
389 DUMP_STRIF(Caps, D3DSTENCILCAPS_DECR);
390 DUMP_STRIF(Caps, D3DSTENCILCAPS_TWOSIDED);
391 DUMP_STRIF_MISSED(Caps);
392 MyLog(("%s", pszSuffix));
393}
394
395static void printFVFCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
396{
397 DUMP_STRIF_INIT(pszSeparator, DWORD);
398 MyLog(("%s", pszPrefix));
399 DUMP_STRIF(Caps, D3DFVFCAPS_TEXCOORDCOUNTMASK);
400 DUMP_STRIF(Caps, D3DFVFCAPS_DONOTSTRIPELEMENTS);
401 DUMP_STRIF(Caps, D3DFVFCAPS_PSIZE);
402 DUMP_STRIF_MISSED(Caps);
403 MyLog(("%s", pszSuffix));
404}
405
406static void printTextureOpCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
407{
408 DUMP_STRIF_INIT(pszSeparator, DWORD);
409 MyLog(("%s", pszPrefix));
410 DUMP_STRIF(Caps, D3DTEXOPCAPS_DISABLE);
411 DUMP_STRIF(Caps, D3DTEXOPCAPS_SELECTARG1);
412 DUMP_STRIF(Caps, D3DTEXOPCAPS_SELECTARG2);
413 DUMP_STRIF(Caps, D3DTEXOPCAPS_MODULATE);
414 DUMP_STRIF(Caps, D3DTEXOPCAPS_MODULATE2X);
415 DUMP_STRIF(Caps, D3DTEXOPCAPS_MODULATE4X);
416 DUMP_STRIF(Caps, D3DTEXOPCAPS_ADD);
417 DUMP_STRIF(Caps, D3DTEXOPCAPS_ADDSIGNED);
418 DUMP_STRIF(Caps, D3DTEXOPCAPS_ADDSIGNED2X);
419 DUMP_STRIF(Caps, D3DTEXOPCAPS_SUBTRACT);
420 DUMP_STRIF(Caps, D3DTEXOPCAPS_ADDSMOOTH);
421 DUMP_STRIF(Caps, D3DTEXOPCAPS_BLENDDIFFUSEALPHA);
422 DUMP_STRIF(Caps, D3DTEXOPCAPS_BLENDTEXTUREALPHA);
423 DUMP_STRIF(Caps, D3DTEXOPCAPS_BLENDFACTORALPHA);
424 DUMP_STRIF(Caps, D3DTEXOPCAPS_BLENDTEXTUREALPHAPM);
425 DUMP_STRIF(Caps, D3DTEXOPCAPS_BLENDCURRENTALPHA);
426 DUMP_STRIF(Caps, D3DTEXOPCAPS_PREMODULATE);
427 DUMP_STRIF(Caps, D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR);
428 DUMP_STRIF(Caps, D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA);
429 DUMP_STRIF(Caps, D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR);
430 DUMP_STRIF(Caps, D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA);
431 DUMP_STRIF(Caps, D3DTEXOPCAPS_BUMPENVMAP);
432 DUMP_STRIF(Caps, D3DTEXOPCAPS_BUMPENVMAPLUMINANCE);
433 DUMP_STRIF(Caps, D3DTEXOPCAPS_DOTPRODUCT3);
434 DUMP_STRIF(Caps, D3DTEXOPCAPS_MULTIPLYADD);
435 DUMP_STRIF(Caps, D3DTEXOPCAPS_LERP);
436 DUMP_STRIF_MISSED(Caps);
437 MyLog(("%s", pszSuffix));
438}
439
440static void printVertexProcessingCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
441{
442 DUMP_STRIF_INIT(pszSeparator, DWORD);
443 MyLog(("%s", pszPrefix));
444 DUMP_STRIF(Caps, D3DVTXPCAPS_TEXGEN);
445 DUMP_STRIF(Caps, D3DVTXPCAPS_MATERIALSOURCE7);
446 DUMP_STRIF(Caps, D3DVTXPCAPS_DIRECTIONALLIGHTS);
447 DUMP_STRIF(Caps, D3DVTXPCAPS_POSITIONALLIGHTS);
448 DUMP_STRIF(Caps, D3DVTXPCAPS_LOCALVIEWER);
449 DUMP_STRIF(Caps, D3DVTXPCAPS_TWEENING);
450 DUMP_STRIF(Caps, D3DVTXPCAPS_TEXGEN_SPHEREMAP);
451 DUMP_STRIF(Caps, D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER);
452 DUMP_STRIF_MISSED(Caps);
453 MyLog(("%s", pszSuffix));
454}
455
456static void printDevCaps2(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
457{
458 DUMP_STRIF_INIT(pszSeparator, DWORD);
459 MyLog(("%s", pszPrefix));
460 DUMP_STRIF(Caps, D3DDEVCAPS2_STREAMOFFSET);
461 DUMP_STRIF(Caps, D3DDEVCAPS2_DMAPNPATCH);
462 DUMP_STRIF(Caps, D3DDEVCAPS2_ADAPTIVETESSRTPATCH);
463 DUMP_STRIF(Caps, D3DDEVCAPS2_ADAPTIVETESSNPATCH);
464 DUMP_STRIF(Caps, D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES);
465 DUMP_STRIF(Caps, D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH);
466 DUMP_STRIF(Caps, D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET);
467 DUMP_STRIF_MISSED(Caps);
468 MyLog(("%s", pszSuffix));
469}
470
471static void printDeclTypes(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
472{
473 DUMP_STRIF_INIT(pszSeparator, DWORD);
474 MyLog(("%s", pszPrefix));
475 DUMP_STRIF(Caps, D3DDTCAPS_UBYTE4);
476 DUMP_STRIF(Caps, D3DDTCAPS_UBYTE4N);
477 DUMP_STRIF(Caps, D3DDTCAPS_SHORT2N);
478 DUMP_STRIF(Caps, D3DDTCAPS_SHORT4N);
479 DUMP_STRIF(Caps, D3DDTCAPS_USHORT2N);
480 DUMP_STRIF(Caps, D3DDTCAPS_USHORT4N);
481 DUMP_STRIF(Caps, D3DDTCAPS_UDEC3);
482 DUMP_STRIF(Caps, D3DDTCAPS_DEC3N);
483 DUMP_STRIF(Caps, D3DDTCAPS_FLOAT16_2);
484 DUMP_STRIF(Caps, D3DDTCAPS_FLOAT16_4);
485 DUMP_STRIF_MISSED(Caps);
486 MyLog(("%s", pszSuffix));
487}
488
489#if 0
490static void printXxxCaps(const char* pszPrefix, const char* pszSeparator, DWORD Caps, const char* pszSuffix)
491{
492 DUMP_STRIF_INIT(pszSeparator, DWORD);
493 MyLog(("%s", pszPrefix));
494 DUMP_STRIF(Caps, );
495 DUMP_STRIF(Caps, );
496 DUMP_STRIF(Caps, );
497 DUMP_STRIF(Caps, );
498 DUMP_STRIF(Caps, );
499 DUMP_STRIF(Caps, );
500 DUMP_STRIF(Caps, );
501 DUMP_STRIF(Caps, );
502 DUMP_STRIF(Caps, );
503 DUMP_STRIF(Caps, );
504 DUMP_STRIF(Caps, );
505 DUMP_STRIF(Caps, );
506 DUMP_STRIF(Caps, );
507 DUMP_STRIF(Caps, );
508 DUMP_STRIF(Caps, );
509 DUMP_STRIF(Caps, );
510 DUMP_STRIF_MISSED(Caps);
511 MyLog(("%s", pszSuffix));
512}
513#endif
514
515static void diffCaps(D3DCAPS9 *pCaps1, D3DCAPS9 *pCaps2)
516{
517 if (!memcmp(pCaps1, pCaps2, sizeof (D3DCAPS9)))
518 {
519 MyLog(("caps are identical!\n"));
520 return;
521 }
522
523 MyLog(("caps differ, doing detailed diff..\n"));
524
525 if (pCaps1->DeviceType != pCaps2->DeviceType)
526 {
527 printDeviceType("pCaps->DeviceType = ", pCaps2->DeviceType, ";\n");
528 }
529
530 DUMP_DIFF_VAL(AdapterOrdinal, "%d");
531
532 DUMP_DIFF_CAPS(printCaps, Caps);
533 DUMP_DIFF_CAPS(printCaps2, Caps2);
534 DUMP_DIFF_CAPS(printCaps3, Caps3);
535 DUMP_DIFF_CAPS(printPresentationIntervals, PresentationIntervals);
536 DUMP_DIFF_CAPS(printCursorCaps, CursorCaps);
537 DUMP_DIFF_CAPS(printDevCaps, DevCaps);
538 DUMP_DIFF_CAPS(printPrimitiveMiscCaps, PrimitiveMiscCaps);
539 DUMP_DIFF_CAPS(printRasterCaps, RasterCaps);
540 DUMP_DIFF_CAPS(printCmpCaps, ZCmpCaps);
541 DUMP_DIFF_CAPS(printBlendCaps, SrcBlendCaps);
542 DUMP_DIFF_CAPS(printBlendCaps, DestBlendCaps);
543 DUMP_DIFF_CAPS(printCmpCaps, AlphaCmpCaps);
544 DUMP_DIFF_CAPS(printShadeCaps, ShadeCaps);
545 DUMP_DIFF_CAPS(printTextureCaps, TextureCaps);
546 DUMP_DIFF_CAPS(printFilterCaps, TextureFilterCaps);
547 DUMP_DIFF_CAPS(printFilterCaps, CubeTextureFilterCaps);
548 DUMP_DIFF_CAPS(printFilterCaps, VolumeTextureFilterCaps);
549 DUMP_DIFF_CAPS(printTextureAddressCaps, TextureAddressCaps);
550 DUMP_DIFF_CAPS(printTextureAddressCaps, VolumeTextureAddressCaps);
551 DUMP_DIFF_CAPS(printLineCaps, LineCaps);
552
553 /* non-caps */
554 DUMP_DIFF_VAL(MaxTextureWidth, "%ld");
555 DUMP_DIFF_VAL(MaxTextureHeight, "%ld");
556 DUMP_DIFF_VAL(MaxVolumeExtent, "%ld");
557 DUMP_DIFF_VAL(MaxTextureRepeat, "%ld");
558 DUMP_DIFF_VAL(MaxTextureAspectRatio, "%ld");
559 DUMP_DIFF_VAL(MaxAnisotropy, "%ld");
560 DUMP_DIFF_VAL(MaxVertexW, "%f");
561 DUMP_DIFF_VAL(GuardBandLeft, "%f");
562 DUMP_DIFF_VAL(GuardBandTop, "%f");
563 DUMP_DIFF_VAL(GuardBandRight, "%f");
564 DUMP_DIFF_VAL(GuardBandBottom, "%f");
565 DUMP_DIFF_VAL(ExtentsAdjust, "%f");
566
567 /* caps */
568 DUMP_DIFF_CAPS(printStencilCaps, StencilCaps);
569 DUMP_DIFF_CAPS(printFVFCaps, FVFCaps);
570 DUMP_DIFF_CAPS(printTextureOpCaps, TextureOpCaps);
571
572 /* non-caps */
573 DUMP_DIFF_VAL(MaxTextureBlendStages, "%ld");
574 DUMP_DIFF_VAL(MaxSimultaneousTextures, "%ld");
575
576 /* caps */
577 DUMP_DIFF_CAPS(printVertexProcessingCaps, VertexProcessingCaps);
578
579 /* non-caps */
580 DUMP_DIFF_VAL(MaxActiveLights, "%ld");
581 DUMP_DIFF_VAL(MaxUserClipPlanes, "%ld");
582 DUMP_DIFF_VAL(MaxVertexBlendMatrices, "%ld");
583 DUMP_DIFF_VAL(MaxVertexBlendMatrixIndex, "%ld");
584 DUMP_DIFF_VAL(MaxPointSize, "%f");
585 DUMP_DIFF_VAL(MaxPrimitiveCount, "%ld");
586 DUMP_DIFF_VAL(MaxVertexIndex, "%ld");
587 DUMP_DIFF_VAL(MaxStreams, "%ld");
588 DUMP_DIFF_VAL(MaxStreamStride, "%ld");
589 DUMP_DIFF_VAL(VertexShaderVersion, "0x%lx");
590 DUMP_DIFF_VAL(MaxVertexShaderConst, "%ld");
591 DUMP_DIFF_VAL(PixelShaderVersion, "0x%lx");
592 DUMP_DIFF_VAL(PixelShader1xMaxValue, "%f");
593
594 /* D3D9 */
595 /* caps */
596 DUMP_DIFF_CAPS(printDevCaps2, DevCaps2);
597
598 /* non-caps */
599 DUMP_DIFF_VAL(MaxNpatchTessellationLevel, "%f");
600 DUMP_DIFF_VAL(Reserved5, "%ld");
601 DUMP_DIFF_VAL(MasterAdapterOrdinal, "%d");
602 DUMP_DIFF_VAL(AdapterOrdinalInGroup, "%d");
603 DUMP_DIFF_VAL(NumberOfAdaptersInGroup, "%d");
604
605 /* caps */
606 DUMP_DIFF_CAPS(printDeclTypes, DeclTypes);
607
608 /* non-caps */
609 DUMP_DIFF_VAL(NumSimultaneousRTs, "%ld");
610
611 /* caps */
612 DUMP_DIFF_CAPS(printFilterCaps, StretchRectFilterCaps);
613
614 /* non-caps */
615 DUMP_DIFF_VAL(VS20Caps.Caps, "0x%lx");
616 DUMP_DIFF_VAL(VS20Caps.DynamicFlowControlDepth, "%d");
617 DUMP_DIFF_VAL(VS20Caps.NumTemps, "%d");
618 DUMP_DIFF_VAL(VS20Caps.StaticFlowControlDepth, "%d");
619
620 DUMP_DIFF_VAL(PS20Caps.Caps, "0x%lx");
621 DUMP_DIFF_VAL(PS20Caps.DynamicFlowControlDepth, "%d");
622 DUMP_DIFF_VAL(PS20Caps.NumTemps, "%d");
623 DUMP_DIFF_VAL(PS20Caps.StaticFlowControlDepth, "%d");
624 DUMP_DIFF_VAL(PS20Caps.NumInstructionSlots, "%d");
625
626 DUMP_DIFF_CAPS(printFilterCaps, VertexTextureFilterCaps);
627 DUMP_DIFF_VAL(MaxVShaderInstructionsExecuted, "%ld");
628 DUMP_DIFF_VAL(MaxPShaderInstructionsExecuted, "%ld");
629 DUMP_DIFF_VAL(MaxVertexShader30InstructionSlots, "%ld");
630 DUMP_DIFF_VAL(MaxPixelShader30InstructionSlots, "%ld");
631}
632
633static DWORD g_aCaps1[] = {
634 0x00000001, 0x00000000, 0x00020000, 0xe0000000,
635 0x00000320, 0x80000001, 0x00000003, 0x0019aff0,
636 0x000f4ff2, 0x07736191, 0x000000ff, 0x00003fff,
637 0x000023ff, 0x000000ff, 0x00084208, 0x0001ecc5,
638 0x07030700, 0x07030700, 0x03030300, 0x0000003f,
639 0x0000003f, 0x0000001f, 0x00001000, 0x00001000,
640 0x00000100, 0x00008000, 0x00001000, 0x00000010,
641 0x3f800000, 0xc6000000, 0xc6000000, 0x46000000,
642 0x46000000, 0x00000000, 0x000001ff, 0x00100008,
643 0x03feffff, 0x00000008, 0x00000008, 0x0000013b,
644 0x00000008, 0x00000006, 0x00000000, 0x00000000,
645 0x437f0000, 0x000fffff, 0x000fffff, 0x00000010,
646 0x00000400, 0xfffe0200, 0x00000080, 0xffff0200,
647 0x41000000, 0x00000051, 0x00000000, 0x00000000,
648 0x00000000, 0x00000000, 0x00000001, 0x0000030f,
649 0x00000001, 0x03000300, 0x00000000, 0x00000018,
650 0x00000020, 0x00000001, 0x00000000, 0x00000018,
651 0x00000020, 0x00000000, 0x00000060, 0x01000100,
652 0x0000ffff, 0x00000200, 0x00000000, 0x00000000
653};
654
655
656static DWORD g_aCaps2[] = {
657 0x00000001, 0x00000000, 0x00000000, 0x60020000,
658 0x00000320, 0x80000001, 0x00000003, 0x0019aff0,
659 0x000a0ff2, 0x07332191, 0x000000ff, 0x00003fff,
660 0x000023ff, 0x000000ff, 0x00084208, 0x0001ec85,
661 0x07030700, 0x07030700, 0x03030300, 0x0000001f,
662 0x0000001f, 0x0000001f, 0x00001000, 0x00001000,
663 0x00000100, 0x00008000, 0x00001000, 0x00000010,
664 0x3f800000, 0x00000000, 0x00000000, 0x00000000,
665 0x00000000, 0x00000000, 0x000001ff, 0x00100008,
666 0x03feffff, 0x00000008, 0x00000008, 0x0000013b,
667 0x00000008, 0x00000006, 0x00000000, 0x00000000,
668 0x437f0000, 0x000fffff, 0x000fffff, 0x00000010,
669 0x00000400, 0xfffe0200, 0x00000080, 0xffff0200,
670 0x41000000, 0x00000051, 0x00000000, 0x00000000,
671 0x00000000, 0x00000000, 0x00000001, 0x0000000f,
672 0x00000001, 0x03000300, 0x00000000, 0x00000000,
673 0x0000001f, 0x00000001, 0x00000000, 0x00000000,
674 0x00000100, 0x00000000, 0x00000060, 0x00000000,
675 0x0000ffff, 0x00000200, 0x00000000, 0x00000000
676};
677
678
679/* ogl stuff */
680static const char * strNext(const char * pcszStr)
681{
682 pcszStr = strchr(pcszStr, ' ');
683 if (!pcszStr)
684 return NULL;
685
686 do
687 {
688 ++pcszStr;
689 if (*pcszStr == '\0')
690 return NULL;
691 else if (*pcszStr != ' ')
692 return pcszStr;
693 } while (1);
694
695 MyLog(("WARNING: should NOT be here!\n"));
696 return NULL;
697}
698
699static int strLength(const char * pcszStr, char sep)
700{
701 if (sep == '\0')
702 return (int)strlen(pcszStr);
703 const char * pcszNext = strchr(pcszStr, sep);
704 if (pcszNext)
705 return (int)(pcszNext - pcszStr);
706 return (int)strlen(pcszStr);
707}
708
709static int strCmp(const char * pcszStr1, const char * pcszStr2, char sep)
710{
711 if (sep == '\0')
712 return strcmp(pcszStr1, pcszStr2);
713
714 int cStr1 = strLength(pcszStr1, sep);
715 int cStr2 = strLength(pcszStr2, sep);
716 int iCmp = strncmp(pcszStr1, pcszStr2, MIN(cStr1, cStr2));
717 if (iCmp)
718 return iCmp;
719 return cStr1 - cStr2;
720}
721
722static char * strDupCur(const char * pcszStr, char sep)
723{
724 int cStr = strLength(pcszStr, sep);
725 char * newStr = (char *)malloc(cStr+1);
726 if (!newStr)
727 {
728 MyLog(("malloc failed!\n"));
729 return NULL;
730 }
731 memcpy(newStr, pcszStr, cStr);
732 newStr[cStr] = '\0';
733 return newStr;
734}
735
736static char * strDupTotal(const char * pcszStr)
737{
738 int cStr = (int)strlen(pcszStr);
739 char * newStr = (char *)malloc(cStr+1+1);
740 if (!newStr)
741 {
742 MyLog(("malloc failed!\n"));
743 return NULL;
744 }
745 memcpy(newStr, pcszStr, cStr);
746 newStr[cStr] = '\0';
747 newStr[cStr+1] = '\0';
748 return newStr;
749}
750
751static char * strDupSort(const char * pcszStr)
752{
753 int cStr = (int)strlen(pcszStr);
754 char * pNewStr = (char *)malloc(cStr+1+1+1);
755 if (!pNewStr)
756 {
757 MyLog(("malloc failed!\n"));
758 return NULL;
759 }
760 char *pCurNew = pNewStr;
761 const char *pPrevCmp = NULL;
762 const char * pCmp = "\001";
763 const char * pCur;
764 int cLength, cPrevLength = 0;
765
766 do
767 {
768 cLength = 0;
769 for (pCur = pcszStr; pCur; pCur = strNext(pCur))
770 {
771 int cCur = strLength(pCur, ' ');
772 int cCmp = strLength(pCmp, ' ');
773 int iCmp = strncmp(pCur, pCmp, MIN(cCur, cCmp));
774 if (!iCmp)
775 iCmp = cCur - cCmp;
776 if (iCmp > 0)
777 {
778 if (!cLength)
779 {
780 pCmp = pCur;
781 cLength = cCur;
782 }
783 }
784 else if (iCmp < 0)
785 {
786 if (cLength)
787 {
788 if (pPrevCmp)
789 {
790 iCmp = strncmp(pCur, pPrevCmp, MIN(cCur, cPrevLength));
791 if (!iCmp)
792 iCmp = cCur - cPrevLength;
793 if (iCmp > 0)
794 {
795 pCmp = pCur;
796 cLength = cCur;
797 }
798 }
799 else
800 {
801 pCmp = pCur;
802 cLength = cCur;
803 }
804 }
805 }
806 }
807
808 if (!cLength)
809 break;
810
811 pPrevCmp = pCmp;
812 cPrevLength = cLength;
813 memcpy(pCurNew, pCmp, cLength);
814 pCurNew += cLength;
815 *pCurNew = ' ';
816 ++pCurNew;
817 } while (1);
818
819 *pCurNew = '\0';
820 ++pCurNew;
821
822 return pNewStr;
823}
824
825
826#define DUMP_DIFF_STR_ADDED(_pStr) do { \
827 char * pszCopy = strDupCur(_pStr, ' '); \
828 MyLog(("+ %s\n", pszCopy)); \
829 if (pszCopy) free(pszCopy); \
830 } while (0)
831
832#define DUMP_DIFF_STR_REMOVED(_pStr) do { \
833 char * pszCopy = strDupCur(_pStr, ' '); \
834 MyLog(("- %s\n", pszCopy)); \
835 if (pszCopy) free(pszCopy); \
836 } while (0)
837
838#define DIFF_STR_ADDED(_ppStr) do { \
839 DUMP_DIFF_STR_ADDED(*(_ppStr)); \
840 *(_ppStr) = strNext(*(_ppStr)); \
841 } while (0)
842
843#define DIFF_STR_REMOVED(_ppStr) do { \
844 DUMP_DIFF_STR_REMOVED(*(_ppStr)); \
845 *(_ppStr) = strNext(*(_ppStr)); \
846 } while (0)
847
848#define DIFF_STR_MATCHED(_ppStr1, _ppStr2) do { \
849 *(_ppStr1) = strNext(*(_ppStr1)); \
850 *(_ppStr2) = strNext(*(_ppStr2)); \
851 } while (0)
852
853static void diffStrOrderedLists(const char * pcszStr1, const char * pcszStr2)
854{
855 while (pcszStr1 || pcszStr2)
856 {
857 if (pcszStr1 && pcszStr2)
858 {
859 int iCmp = strCmp(pcszStr1, pcszStr2, ' ');
860// int cStr1 = strLength(pcszStr1, ' ');
861// int cStr2 = strLength(pcszStr2, ' ');
862// int iCmp = strncmp(pcszStr1, pcszStr2, MAX(cStr1, cStr2));
863 if (iCmp > 0)
864 DIFF_STR_ADDED(&pcszStr2);
865 else if (iCmp < 0)
866 DIFF_STR_REMOVED(&pcszStr1);
867 else
868 DIFF_STR_MATCHED(&pcszStr1, &pcszStr2);
869 }
870 else if (pcszStr1)
871 DIFF_STR_REMOVED(&pcszStr1);
872 else
873 DIFF_STR_ADDED(&pcszStr2);
874 }
875}
876
877static void diffGlExts(const char * pcszExts1, const char * pcszExts2)
878{
879 pcszExts1 = strDupSort(pcszExts1);
880 pcszExts2 = strDupSort(pcszExts2);
881
882 if (!strcmp(pcszExts1, pcszExts2))
883 {
884 MyLog(("GL Exts identical!\n"));
885 MyLog(("%s\n", pcszExts1));
886 return;
887 }
888
889 MyLog(("%s\n", pcszExts1));
890
891 MyLog(("Diffing GL Exts..\n"));
892 diffStrOrderedLists(pcszExts1, pcszExts2);
893}
894
895static char *g_GlExts1 =
896 "GL_ARB_multisample GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_logic_op GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_copy_texture "
897 "GL_EXT_polygon_offset GL_EXT_subtexture GL_EXT_texture_object GL_EXT_vertex_array GL_EXT_compiled_vertex_array GL_EXT_texture GL_EXT_texture3D "
898 "GL_IBM_rasterpos_clip GL_ARB_point_parameters GL_EXT_draw_range_elements GL_EXT_packed_pixels GL_EXT_point_parameters GL_EXT_rescale_normal "
899 "GL_EXT_separate_specular_color GL_EXT_texture_edge_clamp GL_SGIS_generate_mipmap GL_SGIS_texture_border_clamp GL_SGIS_texture_edge_clamp "
900 "GL_SGIS_texture_lod GL_ARB_framebuffer_sRGB GL_ARB_multitexture GL_EXT_framebuffer_sRGB GL_IBM_multimode_draw_arrays GL_IBM_texture_mirrored_repeat "
901 "GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_transpose_matrix GL_EXT_blend_func_separate GL_EXT_fog_coord GL_EXT_multi_draw_arrays "
902 "GL_EXT_secondary_color GL_EXT_texture_env_add GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_INGR_blend_func_separate GL_NV_blend_square "
903 "GL_NV_light_max_exponent GL_NV_texgen_reflection GL_NV_texture_env_combine4 GL_SUN_multi_draw_arrays GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_EXT_framebuffer_object "
904 "GL_EXT_texture_env_dot3 GL_MESA_window_pos GL_NV_packed_depth_stencil GL_NV_texture_rectangle GL_ARB_depth_texture GL_ARB_occlusion_query GL_ARB_shadow GL_ARB_texture_env_combine "
905 "GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_mirrored_repeat GL_ARB_window_pos GL_EXT_stencil_two_side GL_EXT_texture_cube_map GL_NV_depth_clamp GL_APPLE_packed_pixels "
906 "GL_APPLE_vertex_array_object GL_ARB_draw_buffers GL_ARB_fragment_program GL_ARB_fragment_shader GL_ARB_shader_objects GL_ARB_vertex_program GL_ARB_vertex_shader GL_ATI_draw_buffers GL_ATI_texture_env_combine3 "
907 "GL_EXT_shadow_funcs GL_EXT_stencil_wrap GL_MESA_pack_invert GL_NV_primitive_restart GL_ARB_depth_clamp GL_ARB_fragment_program_shadow GL_ARB_half_float_pixel GL_ARB_occlusion_query2 GL_ARB_point_sprite "
908 "GL_ARB_shading_language_100 GL_ARB_sync GL_ARB_texture_non_power_of_two GL_ARB_vertex_buffer_object GL_ATI_blend_equation_separate GL_EXT_blend_equation_separate GL_OES_read_format GL_ARB_color_buffer_float "
909 "GL_ARB_pixel_buffer_object GL_ARB_texture_compression_rgtc GL_ARB_texture_rectangle GL_EXT_packed_float GL_EXT_pixel_buffer_object GL_EXT_texture_compression_rgtc GL_EXT_texture_mirror_clamp GL_EXT_texture_rectangle "
910 "GL_EXT_texture_sRGB GL_EXT_texture_shared_exponent GL_ARB_framebuffer_object GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_packed_depth_stencil GL_ARB_vertex_array_object GL_ATI_separate_stencil "
911 "GL_ATI_texture_mirror_once GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_gpu_program_parameters GL_EXT_texture_env_combine GL_EXT_texture_sRGB_decode GL_EXT_timer_query GL_OES_EGL_image GL_ARB_copy_buffer "
912 "GL_ARB_draw_instanced GL_ARB_half_float_vertex GL_ARB_instanced_arrays GL_ARB_map_buffer_range GL_ARB_texture_rg GL_ARB_texture_swizzle GL_ARB_vertex_array_bgra GL_EXT_separate_shader_objects GL_EXT_texture_swizzle "
913 "GL_EXT_vertex_array_bgra GL_NV_conditional_render GL_ARB_ES2_compatibility GL_ARB_draw_elements_base_vertex GL_ARB_explicit_attrib_location GL_ARB_fragment_coord_conventions GL_ARB_provoking_vertex "
914 "GL_ARB_sampler_objects GL_ARB_shader_texture_lod GL_EXT_provoking_vertex GL_EXT_texture_snorm GL_MESA_texture_signed_rgba GL_NV_texture_barrier GL_ARB_robustness"
915 ;
916static char *g_GlExts2 = "GL_ARB_blend_func_extended GL_ARB_color_buffer_float GL_ARB_compatibility GL_ARB_copy_buffer GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers "
917 "GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_ES2_compatibility GL_ARB_explicit_attrib_location GL_ARB_fragment_coord_conventions GL_ARB_fragment_program GL_ARB_fragment_program_shadow "
918 "GL_ARB_fragment_shader GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_geometry_shader4 GL_ARB_get_program_binary GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_instanced_arrays "
919 "GL_ARB_map_buffer_range GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_occlusion_query2 GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_provoking_vertex "
920 "GL_ARB_robustness GL_ARB_sampler_objects GL_ARB_seamless_cube_map GL_ARB_separate_shader_objects GL_ARB_shader_bit_encoding GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_shading_language_include "
921 "GL_ARB_shadow GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_buffer_object GL_ARB_texture_compression GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine "
922 "GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_multisample GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_texture_rg "
923 "GL_ARB_texture_rgb10_a2ui GL_ARB_texture_swizzle GL_ARB_timer_query GL_ARB_transpose_matrix GL_ARB_uniform_buffer_object GL_ARB_vertex_array_bgra GL_ARB_vertex_array_object GL_ARB_vertex_buffer_object GL_ARB_vertex_program "
924 "GL_ARB_vertex_shader GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_viewport_array GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_texture_float GL_ATI_texture_mirror_once GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra "
925 "GL_EXT_bindable_uniform GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_depth_bounds_test "
926 "GL_EXT_direct_state_access GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXTX_framebuffer_mixed_formats "
927 "GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels "
928 "GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_shader_objects GL_EXT_separate_specular_color GL_EXT_shadow_funcs "
929 "GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_buffer_object GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_latc GL_EXT_texture_compression_rgtc "
930 "GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_integer "
931 "GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_shared_exponent GL_EXT_texture_sRGB GL_EXT_texture_swizzle GL_EXT_texture_type_2_10_10_10_REV GL_EXT_timer_query "
932 "GL_EXT_vertex_array GL_EXT_vertex_array_bgra GL_EXT_x11_sync_object GL_EXT_import_sync_object GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NV_alpha_test GL_NV_blend_minmax GL_NV_blend_square "
933 "GL_NV_complex_primitives GL_NV_conditional_render GL_NV_copy_depth_to_color GL_NV_copy_image GL_NV_depth_buffer_float GL_NV_depth_clamp GL_NV_explicit_multisample GL_NV_fbo_color_attachments "
934 "GL_NV_fence GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragdepth GL_NV_fragment_program GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_framebuffer_multisample_coverage GL_NV_geometry_shader4 "
935 "GL_NV_gpu_program4 GL_NV_half_float GL_NV_light_max_exponent GL_NV_multisample_coverage GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_parameter_buffer_object "
936 "GL_NV_parameter_buffer_object2 GL_NV_path_rendering GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_primitive_restart GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_shader_buffer_load GL_NV_texgen_reflection "
937 "GL_NV_texture_barrier GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_expand_normal GL_NV_texture_lod_clamp GL_NV_texture_multisample GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 "
938 "GL_NV_texture_shader3 GL_NV_transform_feedback GL_NV_vdpau_interop GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_buffer_unified_memory GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2 "
939 "GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_NVX_conditional_render GL_NVX_gpu_memory_info GL_OES_depth24 GL_OES_depth32 GL_OES_depth_texture GL_OES_element_index_uint GL_OES_fbo_render_mipmap "
940 "GL_OES_get_program_binary GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float "
941 "GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_array_object GL_OES_vertex_half_float GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum";
942
943typedef enum
944{
945 D3DCAPSSOURCE_TYPE_UNDEFINED = 0,
946 D3DCAPSSOURCE_TYPE_EMBEDDED1,
947 D3DCAPSSOURCE_TYPE_EMBEDDED2,
948 D3DCAPSSOURCE_TYPE_NULL,
949 D3DCAPSSOURCE_TYPE_LOCAL,
950 D3DCAPSSOURCE_TYPE_FILE,
951 D3DCAPSSOURCE_TYPE_NONE
952} D3DCAPSSOURCE_TYPE;
953
954static D3DCAPS9* selectCaps(D3DCAPS9 *pLocalStorage, D3DCAPS9 *pLocalEmbedded1, D3DCAPS9 *pLocalEmbedded2, D3DCAPSSOURCE_TYPE enmCapsType)
955{
956 switch (enmCapsType)
957 {
958 case D3DCAPSSOURCE_TYPE_EMBEDDED1:
959 return pLocalEmbedded1;
960 case D3DCAPSSOURCE_TYPE_EMBEDDED2:
961 return pLocalEmbedded2;
962 case D3DCAPSSOURCE_TYPE_NULL:
963 memset (pLocalStorage, 0, sizeof (*pLocalStorage));
964 return pLocalStorage;
965 case D3DCAPSSOURCE_TYPE_LOCAL:
966 {
967 LPDIRECT3D9EX pD3D = NULL;
968 HRESULT hr = Direct3DCreate9Ex(D3D_SDK_VERSION, &pD3D);
969 if (FAILED(hr))
970 {
971 MyLog(("Direct3DCreate9Ex failed hr 0x%lx\n", hr));
972 return NULL;
973 }
974
975 memset (pLocalStorage, 0, sizeof (*pLocalStorage));
976
977 hr = pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pLocalStorage);
978
979 pD3D->Release();
980
981 if (FAILED(hr))
982 {
983 MyLog(("GetDeviceCaps failed hr 0x%lx\n", hr));
984 return NULL;
985 }
986
987 return pLocalStorage;
988 }
989 case D3DCAPSSOURCE_TYPE_FILE:
990 {
991 MyLog(("Loading caps from file not implemented yet!"));
992 return NULL;
993 }
994 case D3DCAPSSOURCE_TYPE_NONE:
995 return NULL;
996 default:
997 {
998 MyLog(("Unsupported type %d", enmCapsType));
999 }
1000 }
1001
1002 return NULL;
1003}
1004
1005static void vboxUmdDumpDword(DWORD *pvData, DWORD cData)
1006{
1007 char aBuf[16*4];
1008 DWORD dw1, dw2, dw3, dw4;
1009 for (UINT i = 0; i < (cData & (~3)); i+=4)
1010 {
1011 dw1 = *pvData++;
1012 dw2 = *pvData++;
1013 dw3 = *pvData++;
1014 dw4 = *pvData++;
1015 sprintf(aBuf, "0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx,\n", dw1, dw2, dw3, dw4);
1016 MyLog(("%s", aBuf));
1017 }
1018
1019 cData = cData % 4;
1020 switch (cData)
1021 {
1022 case 3:
1023 dw1 = *pvData++;
1024 dw2 = *pvData++;
1025 dw3 = *pvData++;
1026 sprintf(aBuf, "0x%08lx, 0x%08lx, 0x%08lx\n", dw1, dw2, dw3);
1027 MyLog(("%s", aBuf));
1028 break;
1029 case 2:
1030 dw1 = *pvData++;
1031 dw2 = *pvData++;
1032 sprintf(aBuf, "0x%08lx, 0x%08lx\n", dw1, dw2);
1033 MyLog(("%s", aBuf));
1034 break;
1035 case 1:
1036 dw1 = *pvData++;
1037 sprintf(aBuf, "0x%8lx\n", dw1);
1038 MyLog(("%s", aBuf));
1039 break;
1040 default:
1041 break;
1042 }
1043}
1044
1045int main()
1046{
1047 diffGlExts(g_GlExts1, g_GlExts2);
1048
1049 if (sizeof (g_aCaps1) != sizeof (D3DCAPS9))
1050 {
1051 MyLog(("incorrect caps 1 size (%zd), expected(%zd)\n", sizeof (g_aCaps1), sizeof (D3DCAPS9)));
1052 return 1;
1053 }
1054
1055 if (sizeof (g_aCaps2) != sizeof (D3DCAPS9))
1056 {
1057 MyLog(("incorrect caps 2 size (%zd), expected(%zd)\n", sizeof (g_aCaps2), sizeof (D3DCAPS9)));
1058 return 1;
1059 }
1060
1061 D3DCAPS9 Caps1, Caps2;
1062 D3DCAPS9 *pCaps1, *pCaps2;
1063 D3DCAPSSOURCE_TYPE enmCaps1 = D3DCAPSSOURCE_TYPE_EMBEDDED1;
1064 D3DCAPSSOURCE_TYPE enmCaps2 = D3DCAPSSOURCE_TYPE_EMBEDDED2;
1065
1066 pCaps1 = selectCaps(&Caps1, (D3DCAPS9*)g_aCaps1, (D3DCAPS9*)g_aCaps2, enmCaps1);
1067 if (!pCaps1)
1068 {
1069 MyLog(("Failed to select Caps1"));
1070 return 1;
1071 }
1072
1073 if (D3DCAPSSOURCE_TYPE_NONE != enmCaps2)
1074 {
1075 pCaps2 = selectCaps(&Caps2, (D3DCAPS9*)g_aCaps1, (D3DCAPS9*)g_aCaps2, enmCaps2);
1076 if (!pCaps2)
1077 {
1078 MyLog(("Failed to select Caps2"));
1079 return 1;
1080 }
1081
1082 diffCaps((D3DCAPS9*)pCaps1, (D3DCAPS9*)pCaps2);
1083 }
1084 else
1085 {
1086 vboxUmdDumpDword((DWORD*)pCaps1, sizeof (*pCaps1) / sizeof (DWORD));
1087 }
1088 return 0;
1089}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use