17ec681f3Smrg
27ec681f3Smrg#include "nine_debug.h"
37ec681f3Smrg#include "nine_pipe.h"
47ec681f3Smrg
57ec681f3Smrg#include <stdio.h>
67ec681f3Smrg#include "util/u_memory.h"
77ec681f3Smrg#include "util/u_math.h"
87ec681f3Smrg
97ec681f3Smrg#include "nine_dump.h"
107ec681f3Smrg
117ec681f3Smrg#if defined(DEBUG) || !defined(NDEBUG)
127ec681f3Smrg
137ec681f3Smrgstatic char __thread tls[128];
147ec681f3Smrg
157ec681f3Smrgconst char *nine_D3DDEVTYPE_to_str(D3DDEVTYPE type)
167ec681f3Smrg{
177ec681f3Smrg    switch (type) {
187ec681f3Smrg    case D3DDEVTYPE_HAL: return "HAL";
197ec681f3Smrg    case D3DDEVTYPE_NULLREF: return "NULLREF";
207ec681f3Smrg    case D3DDEVTYPE_REF: return "REF";
217ec681f3Smrg    case D3DDEVTYPE_SW: return "SW";
227ec681f3Smrg    default:
237ec681f3Smrg       return "(D3DDEVTYPE_?)";
247ec681f3Smrg    }
257ec681f3Smrg}
267ec681f3Smrg
277ec681f3Smrgconst char *nine_D3DPOOL_to_str(D3DPOOL pool)
287ec681f3Smrg{
297ec681f3Smrg    switch (pool) {
307ec681f3Smrg    case D3DPOOL_DEFAULT: return "DEFAULT";
317ec681f3Smrg    case D3DPOOL_MANAGED: return "MANAGED";
327ec681f3Smrg    case D3DPOOL_SYSTEMMEM: return "SYSTEMMEM";
337ec681f3Smrg    case D3DPOOL_SCRATCH: return "SCRATCH";
347ec681f3Smrg    default:
357ec681f3Smrg        return "(D3DPOOL_?)";
367ec681f3Smrg    }
377ec681f3Smrg}
387ec681f3Smrg
397ec681f3Smrgconst char *nine_D3DSAMP_to_str(DWORD samp)
407ec681f3Smrg{
417ec681f3Smrg    switch (samp) {
427ec681f3Smrg    case D3DSAMP_ADDRESSU: return "ADDRESSU";
437ec681f3Smrg    case D3DSAMP_ADDRESSV: return "ADDRESSV";
447ec681f3Smrg    case D3DSAMP_ADDRESSW: return "ADDRESSW";
457ec681f3Smrg    case D3DSAMP_BORDERCOLOR: return "BORDERCOLOR";
467ec681f3Smrg    case D3DSAMP_MAGFILTER: return "MAGFILTER";
477ec681f3Smrg    case D3DSAMP_MINFILTER: return "MINFILTER";
487ec681f3Smrg    case D3DSAMP_MIPFILTER: return "MIPFILTER";
497ec681f3Smrg    case D3DSAMP_MIPMAPLODBIAS: return "MIPMAPLODBIAS";
507ec681f3Smrg    case D3DSAMP_MAXMIPLEVEL: return "MAXMIPLEVEL";
517ec681f3Smrg    case D3DSAMP_MAXANISOTROPY: return "MAXANISOTROPY";
527ec681f3Smrg    case D3DSAMP_SRGBTEXTURE: return "SRGBTEXTURE";
537ec681f3Smrg    case D3DSAMP_ELEMENTINDEX: return "ELEMENTINDEX";
547ec681f3Smrg    case D3DSAMP_DMAPOFFSET: return "DMAPOFFSET";
557ec681f3Smrg    default:
567ec681f3Smrg        return "(D3DSAMP_?)";
577ec681f3Smrg    }
587ec681f3Smrg}
597ec681f3Smrg
607ec681f3Smrg#define C2S(n,s) \
617ec681f3Smrg    do { \
627ec681f3Smrg        if (usage & D3DUSAGE_##n) p += snprintf(&tls[p], sizeof(tls) - p, s); \
637ec681f3Smrg    } while(0)
647ec681f3Smrgconst char *nine_D3DUSAGE_to_str(DWORD usage)
657ec681f3Smrg{
667ec681f3Smrg    int p = 0;
677ec681f3Smrg    tls[0] = 0;
687ec681f3Smrg    C2S(AUTOGENMIPMAP, "MIPGEN");
697ec681f3Smrg    C2S(WRITEONLY, "WO");
707ec681f3Smrg    C2S(DYNAMIC, "DYNAMIC");
717ec681f3Smrg    C2S(DEPTHSTENCIL, "DS");
727ec681f3Smrg    C2S(RENDERTARGET, "RT");
737ec681f3Smrg    C2S(SOFTWAREPROCESSING, "SW");
747ec681f3Smrg    C2S(DONOTCLIP, "NOCLIP");
757ec681f3Smrg    C2S(POINTS, "POINTS");
767ec681f3Smrg    C2S(DMAP, "DMAP");
777ec681f3Smrg    C2S(NPATCHES, "NPATCHES");
787ec681f3Smrg    C2S(RTPATCHES, "RTPATCHES");
797ec681f3Smrg    C2S(TEXTAPI, "TEXTAPI");
807ec681f3Smrg    C2S(NONSECURE, "NONSECURE");
817ec681f3Smrg    C2S(RESTRICTED_CONTENT, "RESTRICTED_CONTENT");
827ec681f3Smrg    C2S(RESTRICT_SHARED_RESOURCE, "RESTRICT_SHARED_RESOURCE");
837ec681f3Smrg    C2S(RESTRICT_SHARED_RESOURCE_DRIVER, "RESTRICT_SHARED_RESOURCE_DRIVER");
847ec681f3Smrg    return tls;
857ec681f3Smrg}
867ec681f3Smrg#undef C2S
877ec681f3Smrg
887ec681f3Smrg#define C2S(n) \
897ec681f3Smrg    do { \
907ec681f3Smrg        if (flags & D3DPRESENTFLAG_##n) \
917ec681f3Smrg            p += snprintf(&tls[p], sizeof(tls) - p, #n); \
927ec681f3Smrg    } while(0)
937ec681f3Smrgconst char *nine_D3DPRESENTFLAG_to_str(DWORD flags)
947ec681f3Smrg{
957ec681f3Smrg    int p = 0;
967ec681f3Smrg    tls[0] = 0;
977ec681f3Smrg    C2S(DEVICECLIP);
987ec681f3Smrg    C2S(DISCARD_DEPTHSTENCIL);
997ec681f3Smrg    C2S(LOCKABLE_BACKBUFFER);
1007ec681f3Smrg    C2S(NOAUTOROTATE);
1017ec681f3Smrg    C2S(UNPRUNEDMODE);
1027ec681f3Smrg    C2S(VIDEO);
1037ec681f3Smrg    C2S(OVERLAY_LIMITEDRGB);
1047ec681f3Smrg    C2S(OVERLAY_YCbCr_BT709);
1057ec681f3Smrg    C2S(OVERLAY_YCbCr_xvYCC);
1067ec681f3Smrg    C2S(RESTRICTED_CONTENT);
1077ec681f3Smrg    C2S(RESTRICT_SHARED_RESOURCE_DRIVER);
1087ec681f3Smrg    return tls;
1097ec681f3Smrg}
1107ec681f3Smrg#undef C2S
1117ec681f3Smrg
1127ec681f3Smrg#define C2S(n) \
1137ec681f3Smrg    do { \
1147ec681f3Smrg        if (lock & D3DLOCK_##n) p += snprintf(&tls[p], sizeof(tls) - p, #n"|"); \
1157ec681f3Smrg    } while(0)
1167ec681f3Smrgconst char *nine_D3DLOCK_to_str(DWORD lock)
1177ec681f3Smrg{
1187ec681f3Smrg    int p = 0;
1197ec681f3Smrg    tls[0] = 0;
1207ec681f3Smrg    C2S(DISCARD);
1217ec681f3Smrg    C2S(DONOTWAIT);
1227ec681f3Smrg    C2S(NO_DIRTY_UPDATE);
1237ec681f3Smrg    C2S(NOOVERWRITE);
1247ec681f3Smrg    C2S(NOSYSLOCK);
1257ec681f3Smrg    C2S(READONLY);
1267ec681f3Smrg    return tls;
1277ec681f3Smrg}
1287ec681f3Smrg#undef C2S
1297ec681f3Smrg
1307ec681f3Smrgconst char *nine_D3DRTYPE_to_str(D3DRESOURCETYPE type)
1317ec681f3Smrg{
1327ec681f3Smrg    switch (type) {
1337ec681f3Smrg    case D3DRTYPE_SURFACE: return "SURFACE";
1347ec681f3Smrg    case D3DRTYPE_VOLUME: return "VOLUME";
1357ec681f3Smrg    case D3DRTYPE_TEXTURE: return "TEXTURE";
1367ec681f3Smrg    case D3DRTYPE_VOLUMETEXTURE: return "VOLUMETEXTURE";
1377ec681f3Smrg    case D3DRTYPE_CUBETEXTURE: return "CUBETEXTURE";
1387ec681f3Smrg    case D3DRTYPE_VERTEXBUFFER: return "VERTEXBUFFER";
1397ec681f3Smrg    case D3DRTYPE_INDEXBUFFER: return "INDEXBUFFER";
1407ec681f3Smrg    default:
1417ec681f3Smrg        return "(D3DRTYPE_?)";
1427ec681f3Smrg    }
1437ec681f3Smrg}
1447ec681f3Smrg
1457ec681f3Smrgconst char *nine_D3DQUERYTYPE_to_str(D3DQUERYTYPE type)
1467ec681f3Smrg{
1477ec681f3Smrg    switch (type) {
1487ec681f3Smrg    case D3DQUERYTYPE_VCACHE: return "VCACHE";
1497ec681f3Smrg    case D3DQUERYTYPE_RESOURCEMANAGER: return "RESOURCEMANAGER";
1507ec681f3Smrg    case D3DQUERYTYPE_VERTEXSTATS: return "VERTEXSTATS";
1517ec681f3Smrg    case D3DQUERYTYPE_EVENT: return "EVENT";
1527ec681f3Smrg    case D3DQUERYTYPE_OCCLUSION: return "OCCLUSION";
1537ec681f3Smrg    case D3DQUERYTYPE_TIMESTAMP: return "TIMESTAMP";
1547ec681f3Smrg    case D3DQUERYTYPE_TIMESTAMPDISJOINT: return "TIMESTAMPDISJOINT";
1557ec681f3Smrg    case D3DQUERYTYPE_TIMESTAMPFREQ: return "TIMESTAMPFREQ";
1567ec681f3Smrg    case D3DQUERYTYPE_PIPELINETIMINGS: return "PIPELINETIMINGS";
1577ec681f3Smrg    case D3DQUERYTYPE_INTERFACETIMINGS: return "INTERFACETIMINGS";
1587ec681f3Smrg    case D3DQUERYTYPE_VERTEXTIMINGS: return "VERTEXTIMINGS";
1597ec681f3Smrg    case D3DQUERYTYPE_PIXELTIMINGS: return "PIXELTIMINGS";
1607ec681f3Smrg    case D3DQUERYTYPE_BANDWIDTHTIMINGS: return "BANDWIDTHTIMINGS";
1617ec681f3Smrg    case D3DQUERYTYPE_CACHEUTILIZATION: return "CACHEUTILIZATION";
1627ec681f3Smrg    default:
1637ec681f3Smrg        return "(D3DQUERYTYPE_?)";
1647ec681f3Smrg    }
1657ec681f3Smrg}
1667ec681f3Smrg
1677ec681f3Smrgconst char *nine_D3DTSS_to_str(D3DTEXTURESTAGESTATETYPE type)
1687ec681f3Smrg{
1697ec681f3Smrg    switch (type) {
1707ec681f3Smrg    case D3DTSS_COLOROP: return "COLOROP";
1717ec681f3Smrg    case D3DTSS_ALPHAOP: return "ALPHAOP";
1727ec681f3Smrg    case D3DTSS_COLORARG0: return "COLORARG0";
1737ec681f3Smrg    case D3DTSS_COLORARG1: return "COLORARG1";
1747ec681f3Smrg    case D3DTSS_COLORARG2: return "COLORARG2";
1757ec681f3Smrg    case D3DTSS_ALPHAARG0: return "ALPHAARG0";
1767ec681f3Smrg    case D3DTSS_ALPHAARG1: return "ALPHAARG1";
1777ec681f3Smrg    case D3DTSS_ALPHAARG2: return "ALPHAARG2";
1787ec681f3Smrg    case D3DTSS_RESULTARG: return "RESULTARG";
1797ec681f3Smrg    case D3DTSS_BUMPENVMAT00: return "BUMPENVMAT00";
1807ec681f3Smrg    case D3DTSS_BUMPENVMAT01: return "BUMPENVMAT01";
1817ec681f3Smrg    case D3DTSS_BUMPENVMAT10: return "BUMPENVMAT10";
1827ec681f3Smrg    case D3DTSS_BUMPENVMAT11: return "BUMPENVMAT11";
1837ec681f3Smrg    case D3DTSS_BUMPENVLSCALE: return "BUMPENVLSCALE";
1847ec681f3Smrg    case D3DTSS_BUMPENVLOFFSET: return "BUMPENVLOFFSET";
1857ec681f3Smrg    case D3DTSS_TEXCOORDINDEX: return "TEXCOORDINDEX";
1867ec681f3Smrg    case D3DTSS_TEXTURETRANSFORMFLAGS: return "TEXTURETRANSFORMFLAGS";
1877ec681f3Smrg    case D3DTSS_CONSTANT: return "CONSTANT";
1887ec681f3Smrg    default:
1897ec681f3Smrg        return "(D3DTSS_?)";
1907ec681f3Smrg    }
1917ec681f3Smrg}
1927ec681f3Smrg
1937ec681f3Smrg#define D3DTOP_TO_STR_CASE(n) case D3DTOP_##n: return #n
1947ec681f3Smrgconst char *nine_D3DTOP_to_str(D3DTEXTUREOP top)
1957ec681f3Smrg{
1967ec681f3Smrg    switch (top) {
1977ec681f3Smrg    D3DTOP_TO_STR_CASE(DISABLE);
1987ec681f3Smrg    D3DTOP_TO_STR_CASE(SELECTARG1);
1997ec681f3Smrg    D3DTOP_TO_STR_CASE(SELECTARG2);
2007ec681f3Smrg    D3DTOP_TO_STR_CASE(MODULATE);
2017ec681f3Smrg    D3DTOP_TO_STR_CASE(MODULATE2X);
2027ec681f3Smrg    D3DTOP_TO_STR_CASE(MODULATE4X);
2037ec681f3Smrg    D3DTOP_TO_STR_CASE(ADD);
2047ec681f3Smrg    D3DTOP_TO_STR_CASE(ADDSIGNED);
2057ec681f3Smrg    D3DTOP_TO_STR_CASE(ADDSIGNED2X);
2067ec681f3Smrg    D3DTOP_TO_STR_CASE(SUBTRACT);
2077ec681f3Smrg    D3DTOP_TO_STR_CASE(ADDSMOOTH);
2087ec681f3Smrg    D3DTOP_TO_STR_CASE(BLENDDIFFUSEALPHA);
2097ec681f3Smrg    D3DTOP_TO_STR_CASE(BLENDTEXTUREALPHA);
2107ec681f3Smrg    D3DTOP_TO_STR_CASE(BLENDFACTORALPHA);
2117ec681f3Smrg    D3DTOP_TO_STR_CASE(BLENDTEXTUREALPHAPM);
2127ec681f3Smrg    D3DTOP_TO_STR_CASE(BLENDCURRENTALPHA);
2137ec681f3Smrg    D3DTOP_TO_STR_CASE(PREMODULATE);
2147ec681f3Smrg    D3DTOP_TO_STR_CASE(MODULATEALPHA_ADDCOLOR);
2157ec681f3Smrg    D3DTOP_TO_STR_CASE(MODULATECOLOR_ADDALPHA);
2167ec681f3Smrg    D3DTOP_TO_STR_CASE(MODULATEINVALPHA_ADDCOLOR);
2177ec681f3Smrg    D3DTOP_TO_STR_CASE(MODULATEINVCOLOR_ADDALPHA);
2187ec681f3Smrg    D3DTOP_TO_STR_CASE(BUMPENVMAP);
2197ec681f3Smrg    D3DTOP_TO_STR_CASE(BUMPENVMAPLUMINANCE);
2207ec681f3Smrg    D3DTOP_TO_STR_CASE(DOTPRODUCT3);
2217ec681f3Smrg    D3DTOP_TO_STR_CASE(MULTIPLYADD);
2227ec681f3Smrg    D3DTOP_TO_STR_CASE(LERP);
2237ec681f3Smrg    default:
2247ec681f3Smrg        return "(D3DTOP_?)";
2257ec681f3Smrg    }
2267ec681f3Smrg}
2277ec681f3Smrg
2287ec681f3Smrgstatic const char *
2297ec681f3Smrgnine_D3DLIGHTTYPE_to_str(D3DLIGHTTYPE type)
2307ec681f3Smrg{
2317ec681f3Smrg    switch (type) {
2327ec681f3Smrg    case D3DLIGHT_POINT: return "POINT";
2337ec681f3Smrg    case D3DLIGHT_SPOT: return "SPOT";
2347ec681f3Smrg    case D3DLIGHT_DIRECTIONAL: return "DIRECTIONAL";
2357ec681f3Smrg    default:
2367ec681f3Smrg        return "(D3DLIGHT_?)";
2377ec681f3Smrg    }
2387ec681f3Smrg}
2397ec681f3Smrg
2407ec681f3Smrgstatic const char *
2417ec681f3Smrgnine_D3DTA_to_str(DWORD value)
2427ec681f3Smrg{
2437ec681f3Smrg    switch (value & D3DTA_SELECTMASK) {
2447ec681f3Smrg    case D3DTA_DIFFUSE: return "DIFFUSE";
2457ec681f3Smrg    case D3DTA_CURRENT: return "CURRENT";
2467ec681f3Smrg    case D3DTA_TEXTURE: return "TEXTURE";
2477ec681f3Smrg    case D3DTA_TFACTOR: return "TFACTOR";
2487ec681f3Smrg    case D3DTA_SPECULAR: return "SPECULAR";
2497ec681f3Smrg    case D3DTA_TEMP: return "TEMP";
2507ec681f3Smrg    case D3DTA_CONSTANT: return "CONSTANT";
2517ec681f3Smrg    default:
2527ec681f3Smrg        return "(D3DTA_?)";
2537ec681f3Smrg    }
2547ec681f3Smrg}
2557ec681f3Smrg
2567ec681f3Smrgstatic const char *
2577ec681f3Smrgnine_D3DTSS_TCI_to_str(DWORD value)
2587ec681f3Smrg{
2597ec681f3Smrg    switch (value & 0xf0000) {
2607ec681f3Smrg    case D3DTSS_TCI_PASSTHRU: return "PASSTHRU";
2617ec681f3Smrg    case D3DTSS_TCI_CAMERASPACENORMAL: return "CAMERASPACENORMAL";
2627ec681f3Smrg    case D3DTSS_TCI_CAMERASPACEPOSITION: return "CAMERASPACEPOSITION";
2637ec681f3Smrg    case D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
2647ec681f3Smrg        return "CAMERASPACEREFLECTIONVECTOR";
2657ec681f3Smrg    case D3DTSS_TCI_SPHEREMAP: return "SPHEREMAP";
2667ec681f3Smrg    default:
2677ec681f3Smrg        return "(D3DTSS_TCI_?)";
2687ec681f3Smrg    }
2697ec681f3Smrg}
2707ec681f3Smrg
2717ec681f3Smrgstatic const char *
2727ec681f3Smrgnine_D3DTTFF_to_str(DWORD value)
2737ec681f3Smrg{
2747ec681f3Smrg    switch (value) {
2757ec681f3Smrg    case D3DTTFF_DISABLE: return "DISABLE";
2767ec681f3Smrg    case D3DTTFF_COUNT1: return "COUNT1";
2777ec681f3Smrg    case D3DTTFF_COUNT2: return "COUNT2";
2787ec681f3Smrg    case D3DTTFF_COUNT3: return "COUNT3";
2797ec681f3Smrg    case D3DTTFF_COUNT4: return "COUNT4";
2807ec681f3Smrg    case D3DTTFF_PROJECTED: return "PROJECTED";
2817ec681f3Smrg    default:
2827ec681f3Smrg        return "(D3DTTFF_?)";
2837ec681f3Smrg    }
2847ec681f3Smrg}
2857ec681f3Smrg
2867ec681f3Smrgvoid
2877ec681f3Smrgnine_dump_D3DLIGHT9(unsigned ch, const D3DLIGHT9 *lit)
2887ec681f3Smrg{
2897ec681f3Smrg    DBG_FLAG(ch, "D3DLIGHT9(%p):\n"
2907ec681f3Smrg             "Type: %s\n"
2917ec681f3Smrg             "Diffuse: (%f %f %f %f)\n"
2927ec681f3Smrg             "Specular: (%f %f %f %f)\n"
2937ec681f3Smrg             "Ambient: (%f %f %f %f)\n"
2947ec681f3Smrg             "Position: (%f %f %f)\n"
2957ec681f3Smrg             "Direction: (%f %f %f)\n"
2967ec681f3Smrg             "Range: %f\n"
2977ec681f3Smrg             "Falloff: %f\n"
2987ec681f3Smrg             "Attenuation: %f + %f * d + %f * d^2\n"
2997ec681f3Smrg             "Theta: %f deg\n"
3007ec681f3Smrg             "Phi: %f deg\n", lit,
3017ec681f3Smrg             nine_D3DLIGHTTYPE_to_str(lit->Type),
3027ec681f3Smrg             lit->Diffuse.r,lit->Diffuse.r,lit->Diffuse.g,lit->Diffuse.a,
3037ec681f3Smrg             lit->Specular.r,lit->Specular.r,lit->Specular.g,lit->Specular.a,
3047ec681f3Smrg             lit->Ambient.r,lit->Ambient.r,lit->Ambient.g,lit->Ambient.a,
3057ec681f3Smrg             lit->Position.x,lit->Position.y,lit->Position.z,
3067ec681f3Smrg             lit->Direction.x,lit->Direction.y,lit->Direction.z,
3077ec681f3Smrg             lit->Range,lit->Falloff,
3087ec681f3Smrg             lit->Attenuation0,lit->Attenuation1,lit->Attenuation2,
3097ec681f3Smrg             lit->Theta * 360.0f / M_PI,lit->Phi * 360.0f / M_PI);
3107ec681f3Smrg}
3117ec681f3Smrg
3127ec681f3Smrgvoid
3137ec681f3Smrgnine_dump_D3DMATERIAL9(unsigned ch, const D3DMATERIAL9 *mat)
3147ec681f3Smrg{
3157ec681f3Smrg    DBG_FLAG(ch, "D3DMATERIAL9(%p):\n"
3167ec681f3Smrg             "Diffuse: (%f %f %f %f)\n"
3177ec681f3Smrg             "Specular: (%f %f %f %f)\n"
3187ec681f3Smrg             "Ambient: (%f %f %f %f)\n"
3197ec681f3Smrg             "Emissive: (%f %f %f %f)\n"
3207ec681f3Smrg             "Power: %f\n", mat,
3217ec681f3Smrg             mat->Diffuse.r,mat->Diffuse.r,mat->Diffuse.g,mat->Diffuse.a,
3227ec681f3Smrg             mat->Specular.r,mat->Specular.r,mat->Specular.g,mat->Specular.a,
3237ec681f3Smrg             mat->Ambient.r,mat->Ambient.r,mat->Ambient.g,mat->Ambient.a,
3247ec681f3Smrg             mat->Emissive.r,mat->Emissive.r,mat->Emissive.g,mat->Emissive.a,
3257ec681f3Smrg             mat->Power);
3267ec681f3Smrg}
3277ec681f3Smrg
3287ec681f3Smrgvoid
3297ec681f3Smrgnine_dump_D3DTSS_value(unsigned ch, D3DTEXTURESTAGESTATETYPE type, DWORD value)
3307ec681f3Smrg{
3317ec681f3Smrg    float rgba[4];
3327ec681f3Smrg
3337ec681f3Smrg    switch (type) {
3347ec681f3Smrg    case D3DTSS_COLOROP:
3357ec681f3Smrg    case D3DTSS_ALPHAOP:
3367ec681f3Smrg        DBG_FLAG(ch, "D3DTSS_%s = %s\n",
3377ec681f3Smrg                 nine_D3DTSS_to_str(type), nine_D3DTOP_to_str(value));
3387ec681f3Smrg        break;
3397ec681f3Smrg    case D3DTSS_COLORARG0:
3407ec681f3Smrg    case D3DTSS_COLORARG1:
3417ec681f3Smrg    case D3DTSS_COLORARG2:
3427ec681f3Smrg    case D3DTSS_ALPHAARG0:
3437ec681f3Smrg    case D3DTSS_ALPHAARG1:
3447ec681f3Smrg    case D3DTSS_ALPHAARG2:
3457ec681f3Smrg    case D3DTSS_RESULTARG:
3467ec681f3Smrg        DBG_FLAG(ch, "D3DTSS_%s = %s%s%s\n",
3477ec681f3Smrg                 nine_D3DTSS_to_str(type),
3487ec681f3Smrg                 (value & D3DTA_COMPLEMENT) ? "COMPLEMENT " : "",
3497ec681f3Smrg                 (value & D3DTA_ALPHAREPLICATE) ? "ALPHAREPLICATE " : "",
3507ec681f3Smrg                 nine_D3DTA_to_str(value));
3517ec681f3Smrg        break;
3527ec681f3Smrg    case D3DTSS_BUMPENVMAT00:
3537ec681f3Smrg    case D3DTSS_BUMPENVMAT01:
3547ec681f3Smrg    case D3DTSS_BUMPENVMAT10:
3557ec681f3Smrg    case D3DTSS_BUMPENVMAT11:
3567ec681f3Smrg    case D3DTSS_BUMPENVLSCALE:
3577ec681f3Smrg    case D3DTSS_BUMPENVLOFFSET:
3587ec681f3Smrg        DBG_FLAG(ch, "D3DTSS_%s = %f\n",
3597ec681f3Smrg                 nine_D3DTSS_to_str(type), asfloat(value));
3607ec681f3Smrg        break;
3617ec681f3Smrg    case D3DTSS_TEXCOORDINDEX:
3627ec681f3Smrg        DBG_FLAG(ch, "D3DTSS_TEXCOORDINDEX = %s %u\n",
3637ec681f3Smrg                 nine_D3DTSS_TCI_to_str(value),
3647ec681f3Smrg                 value & 0xffff);
3657ec681f3Smrg        break;
3667ec681f3Smrg    case D3DTSS_TEXTURETRANSFORMFLAGS:
3677ec681f3Smrg        DBG_FLAG(ch, "D3DTSS_TEXTURETRANSFORMFLAGS = %s\n",
3687ec681f3Smrg                 nine_D3DTTFF_to_str(value));
3697ec681f3Smrg        break;
3707ec681f3Smrg    case D3DTSS_CONSTANT:
3717ec681f3Smrg        d3dcolor_to_rgba(rgba, value);
3727ec681f3Smrg        DBG_FLAG(ch, "D3DTSS_CONSTANT = %f %f %f %F\n",
3737ec681f3Smrg                 rgba[0],rgba[1],rgba[2],rgba[3]);
3747ec681f3Smrg        break;
3757ec681f3Smrg    default:
3767ec681f3Smrg        DBG_FLAG(ch, "D3DTSS_? = 0x%08x\n", value);
3777ec681f3Smrg        break;
3787ec681f3Smrg    }
3797ec681f3Smrg}
3807ec681f3Smrg
3817ec681f3Smrgvoid
3827ec681f3Smrgnine_dump_D3DADAPTER_IDENTIFIER9(unsigned ch, const D3DADAPTER_IDENTIFIER9 *id)
3837ec681f3Smrg{
3847ec681f3Smrg    DBG_FLAG(ch, "D3DADAPTER_IDENTIFIER9(%p):\n"
3857ec681f3Smrg             "Driver: %s\n"
3867ec681f3Smrg             "Description: %s\n"
3877ec681f3Smrg             "DeviceName: %s\n"
3887ec681f3Smrg             "DriverVersion: %08x.%08x\n"
3897ec681f3Smrg             "VendorId: %x\n"
3907ec681f3Smrg             "DeviceId: %x\n"
3917ec681f3Smrg             "SubSysId: %x\n"
3927ec681f3Smrg             "Revision: %u\n"
3937ec681f3Smrg             "GUID: %08x.%04x.%04x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x\n"
3947ec681f3Smrg             "WHQLLevel: %u\n", id, id->Driver, id->Description,
3957ec681f3Smrg             id->DeviceName,
3967ec681f3Smrg             id->DriverVersionLowPart, id->DriverVersionHighPart,
3977ec681f3Smrg             id->VendorId, id->DeviceId, id->SubSysId,
3987ec681f3Smrg             id->Revision,
3997ec681f3Smrg             id->DeviceIdentifier.Data1,
4007ec681f3Smrg             id->DeviceIdentifier.Data2,
4017ec681f3Smrg             id->DeviceIdentifier.Data3,
4027ec681f3Smrg             id->DeviceIdentifier.Data4[0],
4037ec681f3Smrg             id->DeviceIdentifier.Data4[1],
4047ec681f3Smrg             id->DeviceIdentifier.Data4[2],
4057ec681f3Smrg             id->DeviceIdentifier.Data4[3],
4067ec681f3Smrg             id->DeviceIdentifier.Data4[4],
4077ec681f3Smrg             id->DeviceIdentifier.Data4[5],
4087ec681f3Smrg             id->DeviceIdentifier.Data4[6],
4097ec681f3Smrg             id->DeviceIdentifier.Data4[7],
4107ec681f3Smrg             id->WHQLLevel);
4117ec681f3Smrg}
4127ec681f3Smrg
4137ec681f3Smrg#define C2S(args...) p += snprintf(&s[p],c-p,args)
4147ec681f3Smrg
4157ec681f3Smrg#define CAP_CASE(m,p,n) \
4167ec681f3Smrg    do {                     \
4177ec681f3Smrg        if (caps->m & p##_##n) \
4187ec681f3Smrg            C2S(" "#n); \
4197ec681f3Smrg        else \
4207ec681f3Smrg            C2S(" ("#n")"); \
4217ec681f3Smrg    } while(0)
4227ec681f3Smrg
4237ec681f3Smrgvoid
4247ec681f3Smrgnine_dump_D3DCAPS9(unsigned ch, const D3DCAPS9 *caps)
4257ec681f3Smrg{
4267ec681f3Smrg    const int c = 1 << 17;
4277ec681f3Smrg    int p = 0;
4287ec681f3Smrg    char *s = (char *)MALLOC(c);
4297ec681f3Smrg
4307ec681f3Smrg    if (!s) {
4317ec681f3Smrg        DBG_FLAG(ch, "D3DCAPS9(%p): (out of memory)\n", caps);
4327ec681f3Smrg        return;
4337ec681f3Smrg    }
4347ec681f3Smrg
4357ec681f3Smrg    C2S("DeviceType: %s\n", nine_D3DDEVTYPE_to_str(caps->DeviceType));
4367ec681f3Smrg
4377ec681f3Smrg    C2S("AdapterOrdinal: %u\nCaps:", caps->AdapterOrdinal);
4387ec681f3Smrg    if (caps->Caps & 0x20000)
4397ec681f3Smrg        C2S(" READ_SCANLINE");
4407ec681f3Smrg    if (caps->Caps & ~0x20000)
4417ec681f3Smrg        C2S(" %x", caps->Caps & ~0x20000);
4427ec681f3Smrg
4437ec681f3Smrg    C2S("\nCaps2:");
4447ec681f3Smrg    CAP_CASE(Caps2, D3DCAPS2, CANAUTOGENMIPMAP);
4457ec681f3Smrg    CAP_CASE(Caps2, D3DCAPS2, CANCALIBRATEGAMMA);
4467ec681f3Smrg    CAP_CASE(Caps2, D3DCAPS2, CANSHARERESOURCE);
4477ec681f3Smrg    CAP_CASE(Caps2, D3DCAPS2, CANMANAGERESOURCE);
4487ec681f3Smrg    CAP_CASE(Caps2, D3DCAPS2, DYNAMICTEXTURES);
4497ec681f3Smrg    CAP_CASE(Caps2, D3DCAPS2, FULLSCREENGAMMA);
4507ec681f3Smrg
4517ec681f3Smrg    C2S("\nCaps3:");
4527ec681f3Smrg    CAP_CASE(Caps3, D3DCAPS3, ALPHA_FULLSCREEN_FLIP_OR_DISCARD);
4537ec681f3Smrg    CAP_CASE(Caps3, D3DCAPS3, COPY_TO_VIDMEM);
4547ec681f3Smrg    CAP_CASE(Caps3, D3DCAPS3, COPY_TO_SYSTEMMEM);
4557ec681f3Smrg    CAP_CASE(Caps3, D3DCAPS3, DXVAHD);
4567ec681f3Smrg    CAP_CASE(Caps3, D3DCAPS3, LINEAR_TO_SRGB_PRESENTATION);
4577ec681f3Smrg
4587ec681f3Smrg    C2S("\nPresentationIntervals:");
4597ec681f3Smrg    CAP_CASE(PresentationIntervals, D3DPRESENT_INTERVAL, ONE);
4607ec681f3Smrg    CAP_CASE(PresentationIntervals, D3DPRESENT_INTERVAL, TWO);
4617ec681f3Smrg    CAP_CASE(PresentationIntervals, D3DPRESENT_INTERVAL, THREE);
4627ec681f3Smrg    CAP_CASE(PresentationIntervals, D3DPRESENT_INTERVAL, FOUR);
4637ec681f3Smrg    CAP_CASE(PresentationIntervals, D3DPRESENT_INTERVAL, IMMEDIATE);
4647ec681f3Smrg
4657ec681f3Smrg    C2S("\nCursorCaps:");
4667ec681f3Smrg    CAP_CASE(CursorCaps, D3DCURSORCAPS, COLOR);
4677ec681f3Smrg    CAP_CASE(CursorCaps, D3DCURSORCAPS, LOWRES);
4687ec681f3Smrg
4697ec681f3Smrg    C2S("\nDevCaps:");
4707ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, CANBLTSYSTONONLOCAL);
4717ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, CANRENDERAFTERFLIP);
4727ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, DRAWPRIMITIVES2);
4737ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, DRAWPRIMITIVES2EX);
4747ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, DRAWPRIMTLVERTEX);
4757ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, EXECUTESYSTEMMEMORY);
4767ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, EXECUTEVIDEOMEMORY);
4777ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, HWRASTERIZATION);
4787ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, HWTRANSFORMANDLIGHT);
4797ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, NPATCHES);
4807ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, PUREDEVICE);
4817ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, QUINTICRTPATCHES);
4827ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, RTPATCHES);
4837ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, RTPATCHHANDLEZERO);
4847ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, SEPARATETEXTUREMEMORIES);
4857ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, TEXTURENONLOCALVIDMEM);
4867ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, TEXTURESYSTEMMEMORY);
4877ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, TEXTUREVIDEOMEMORY);
4887ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, TLVERTEXSYSTEMMEMORY);
4897ec681f3Smrg    CAP_CASE(DevCaps, D3DDEVCAPS, TLVERTEXVIDEOMEMORY);
4907ec681f3Smrg
4917ec681f3Smrg    C2S("\nPrimitiveMiscCaps:");
4927ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, MASKZ);
4937ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, CULLNONE);
4947ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, CULLCW);
4957ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, CULLCCW);
4967ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, COLORWRITEENABLE);
4977ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, CLIPPLANESCALEDPOINTS);
4987ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, CLIPTLVERTS);
4997ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, TSSARGTEMP);
5007ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, BLENDOP);
5017ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, NULLREFERENCE);
5027ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, INDEPENDENTWRITEMASKS);
5037ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, PERSTAGECONSTANT);
5047ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, POSTBLENDSRGBCONVERT);
5057ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, FOGANDSPECULARALPHA);
5067ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, SEPARATEALPHABLEND);
5077ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, MRTINDEPENDENTBITDEPTHS);
5087ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, MRTPOSTPIXELSHADERBLENDING);
5097ec681f3Smrg    CAP_CASE(PrimitiveMiscCaps, D3DPMISCCAPS, FOGVERTEXCLAMPED);
5107ec681f3Smrg
5117ec681f3Smrg    C2S("\nRasterCaps:");
5127ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, ANISOTROPY);
5137ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, COLORPERSPECTIVE);
5147ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, DITHER);
5157ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, DEPTHBIAS);
5167ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, FOGRANGE);
5177ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, FOGTABLE);
5187ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, FOGVERTEX);
5197ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, MIPMAPLODBIAS);
5207ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, MULTISAMPLE_TOGGLE);
5217ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, SCISSORTEST);
5227ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, SLOPESCALEDEPTHBIAS);
5237ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, WBUFFER);
5247ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, WFOG);
5257ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, ZBUFFERLESSHSR);
5267ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, ZFOG);
5277ec681f3Smrg    CAP_CASE(RasterCaps, D3DPRASTERCAPS, ZTEST);
5287ec681f3Smrg
5297ec681f3Smrg    C2S("\nZCmpCaps:");
5307ec681f3Smrg    CAP_CASE(ZCmpCaps, D3DPCMPCAPS, ALWAYS);
5317ec681f3Smrg    CAP_CASE(ZCmpCaps, D3DPCMPCAPS, EQUAL);
5327ec681f3Smrg    CAP_CASE(ZCmpCaps, D3DPCMPCAPS, GREATER);
5337ec681f3Smrg    CAP_CASE(ZCmpCaps, D3DPCMPCAPS, GREATEREQUAL);
5347ec681f3Smrg    CAP_CASE(ZCmpCaps, D3DPCMPCAPS, LESS);
5357ec681f3Smrg    CAP_CASE(ZCmpCaps, D3DPCMPCAPS, LESSEQUAL);
5367ec681f3Smrg    CAP_CASE(ZCmpCaps, D3DPCMPCAPS, NEVER);
5377ec681f3Smrg    CAP_CASE(ZCmpCaps, D3DPCMPCAPS, NOTEQUAL);
5387ec681f3Smrg
5397ec681f3Smrg    C2S("\nSrcBlendCaps");
5407ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, BLENDFACTOR);
5417ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, BOTHINVSRCALPHA);
5427ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, BOTHSRCALPHA);
5437ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, DESTALPHA);
5447ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, DESTCOLOR);
5457ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, INVDESTALPHA);
5467ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, INVDESTCOLOR);
5477ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, INVSRCALPHA);
5487ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, INVSRCCOLOR);
5497ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, INVSRCCOLOR2);
5507ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, ONE);
5517ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, SRCALPHA);
5527ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, SRCALPHASAT);
5537ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, SRCCOLOR);
5547ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, SRCCOLOR2);
5557ec681f3Smrg    CAP_CASE(SrcBlendCaps, D3DPBLENDCAPS, ZERO);
5567ec681f3Smrg
5577ec681f3Smrg    C2S("\nDestBlendCaps");
5587ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, BLENDFACTOR);
5597ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, BOTHINVSRCALPHA);
5607ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, BOTHSRCALPHA);
5617ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, DESTALPHA);
5627ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, DESTCOLOR);
5637ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, INVDESTALPHA);
5647ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, INVDESTCOLOR);
5657ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, INVSRCALPHA);
5667ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, INVSRCCOLOR);
5677ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, INVSRCCOLOR2);
5687ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, ONE);
5697ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, SRCALPHA);
5707ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, SRCALPHASAT);
5717ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, SRCCOLOR);
5727ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, SRCCOLOR2);
5737ec681f3Smrg    CAP_CASE(DestBlendCaps, D3DPBLENDCAPS, ZERO);
5747ec681f3Smrg
5757ec681f3Smrg    C2S("\nAlphaCmpCaps:");
5767ec681f3Smrg    CAP_CASE(AlphaCmpCaps, D3DPCMPCAPS, ALWAYS);
5777ec681f3Smrg    CAP_CASE(AlphaCmpCaps, D3DPCMPCAPS, EQUAL);
5787ec681f3Smrg    CAP_CASE(AlphaCmpCaps, D3DPCMPCAPS, GREATER);
5797ec681f3Smrg    CAP_CASE(AlphaCmpCaps, D3DPCMPCAPS, GREATEREQUAL);
5807ec681f3Smrg    CAP_CASE(AlphaCmpCaps, D3DPCMPCAPS, LESS);
5817ec681f3Smrg    CAP_CASE(AlphaCmpCaps, D3DPCMPCAPS, LESSEQUAL);
5827ec681f3Smrg    CAP_CASE(AlphaCmpCaps, D3DPCMPCAPS, NEVER);
5837ec681f3Smrg    CAP_CASE(AlphaCmpCaps, D3DPCMPCAPS, NOTEQUAL);
5847ec681f3Smrg
5857ec681f3Smrg    C2S("\nShadeCaps:");
5867ec681f3Smrg    CAP_CASE(ShadeCaps, D3DPSHADECAPS, ALPHAGOURAUDBLEND);
5877ec681f3Smrg    CAP_CASE(ShadeCaps, D3DPSHADECAPS, COLORGOURAUDRGB);
5887ec681f3Smrg    CAP_CASE(ShadeCaps, D3DPSHADECAPS, FOGGOURAUD);
5897ec681f3Smrg    CAP_CASE(ShadeCaps, D3DPSHADECAPS, SPECULARGOURAUDRGB);
5907ec681f3Smrg
5917ec681f3Smrg    C2S("\nTextureCaps:");
5927ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, ALPHA);
5937ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, ALPHAPALETTE);
5947ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, CUBEMAP);
5957ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, CUBEMAP_POW2);
5967ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, MIPCUBEMAP);
5977ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, MIPMAP);
5987ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, MIPVOLUMEMAP);
5997ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, NONPOW2CONDITIONAL);
6007ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, NOPROJECTEDBUMPENV);
6017ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, PERSPECTIVE);
6027ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, POW2);
6037ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, PROJECTED);
6047ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, SQUAREONLY);
6057ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, TEXREPEATNOTSCALEDBYSIZE);
6067ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, VOLUMEMAP);
6077ec681f3Smrg    CAP_CASE(TextureCaps, D3DPTEXTURECAPS, VOLUMEMAP_POW2);
6087ec681f3Smrg
6097ec681f3Smrg    C2S("\nTextureFilterCaps:");
6107ec681f3Smrg /* CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, CONVOLUTIONMONO); */
6117ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MAGFPOINT);
6127ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MAGFLINEAR);
6137ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MAGFANISOTROPIC);
6147ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MAGFPYRAMIDALQUAD);
6157ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MAGFGAUSSIANQUAD);
6167ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MINFPOINT);
6177ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MINFLINEAR);
6187ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MINFANISOTROPIC);
6197ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MINFPYRAMIDALQUAD);
6207ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MINFGAUSSIANQUAD);
6217ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MIPFPOINT);
6227ec681f3Smrg    CAP_CASE(TextureFilterCaps, D3DPTFILTERCAPS, MIPFLINEAR);
6237ec681f3Smrg
6247ec681f3Smrg    C2S("\nCubeTextureFilterCaps:");
6257ec681f3Smrg /* CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, CONVOLUTIONMONO); */
6267ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MAGFPOINT);
6277ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MAGFLINEAR);
6287ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MAGFANISOTROPIC);
6297ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MAGFPYRAMIDALQUAD);
6307ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MAGFGAUSSIANQUAD);
6317ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MINFPOINT);
6327ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MINFLINEAR);
6337ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MINFANISOTROPIC);
6347ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MINFPYRAMIDALQUAD);
6357ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MINFGAUSSIANQUAD);
6367ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MIPFPOINT);
6377ec681f3Smrg    CAP_CASE(CubeTextureFilterCaps, D3DPTFILTERCAPS, MIPFLINEAR);
6387ec681f3Smrg
6397ec681f3Smrg    C2S("\nVolumeTextureFilterCaps:");
6407ec681f3Smrg /* CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, CONVOLUTIONMONO); */
6417ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MAGFPOINT);
6427ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MAGFLINEAR);
6437ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MAGFANISOTROPIC);
6447ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MAGFPYRAMIDALQUAD);
6457ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MAGFGAUSSIANQUAD);
6467ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MINFPOINT);
6477ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MINFLINEAR);
6487ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MINFANISOTROPIC);
6497ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MINFPYRAMIDALQUAD);
6507ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MINFGAUSSIANQUAD);
6517ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MIPFPOINT);
6527ec681f3Smrg    CAP_CASE(VolumeTextureFilterCaps, D3DPTFILTERCAPS, MIPFLINEAR);
6537ec681f3Smrg
6547ec681f3Smrg    C2S("\nTextureAddressCaps:");
6557ec681f3Smrg    CAP_CASE(TextureAddressCaps, D3DPTADDRESSCAPS, BORDER);
6567ec681f3Smrg    CAP_CASE(TextureAddressCaps, D3DPTADDRESSCAPS, CLAMP);
6577ec681f3Smrg    CAP_CASE(TextureAddressCaps, D3DPTADDRESSCAPS, INDEPENDENTUV);
6587ec681f3Smrg    CAP_CASE(TextureAddressCaps, D3DPTADDRESSCAPS, MIRROR);
6597ec681f3Smrg    CAP_CASE(TextureAddressCaps, D3DPTADDRESSCAPS, MIRRORONCE);
6607ec681f3Smrg    CAP_CASE(TextureAddressCaps, D3DPTADDRESSCAPS, WRAP);
6617ec681f3Smrg
6627ec681f3Smrg    C2S("\nVolumeTextureAddressCaps:");
6637ec681f3Smrg    CAP_CASE(VolumeTextureAddressCaps, D3DPTADDRESSCAPS, BORDER);
6647ec681f3Smrg    CAP_CASE(VolumeTextureAddressCaps, D3DPTADDRESSCAPS, CLAMP);
6657ec681f3Smrg    CAP_CASE(VolumeTextureAddressCaps, D3DPTADDRESSCAPS, INDEPENDENTUV);
6667ec681f3Smrg    CAP_CASE(VolumeTextureAddressCaps, D3DPTADDRESSCAPS, MIRROR);
6677ec681f3Smrg    CAP_CASE(VolumeTextureAddressCaps, D3DPTADDRESSCAPS, MIRRORONCE);
6687ec681f3Smrg    CAP_CASE(VolumeTextureAddressCaps, D3DPTADDRESSCAPS, WRAP);
6697ec681f3Smrg
6707ec681f3Smrg    C2S("\nLineCaps:");
6717ec681f3Smrg    CAP_CASE(LineCaps, D3DLINECAPS, ALPHACMP);
6727ec681f3Smrg    CAP_CASE(LineCaps, D3DLINECAPS, ANTIALIAS);
6737ec681f3Smrg    CAP_CASE(LineCaps, D3DLINECAPS, BLEND);
6747ec681f3Smrg    CAP_CASE(LineCaps, D3DLINECAPS, FOG);
6757ec681f3Smrg    CAP_CASE(LineCaps, D3DLINECAPS, TEXTURE);
6767ec681f3Smrg    CAP_CASE(LineCaps, D3DLINECAPS, ZTEST);
6777ec681f3Smrg
6787ec681f3Smrg    C2S("\nMaxTextureWidth: %u", caps->MaxTextureWidth);
6797ec681f3Smrg    C2S("\nMaxTextureHeight: %u", caps->MaxTextureHeight);
6807ec681f3Smrg    C2S("\nMaxVolumeExtent: %u", caps->MaxVolumeExtent);
6817ec681f3Smrg    C2S("\nMaxTextureRepeat: %u", caps->MaxTextureRepeat);
6827ec681f3Smrg    C2S("\nMaxTextureAspectRatio: %u", caps->MaxTextureAspectRatio);
6837ec681f3Smrg    C2S("\nMaxAnisotropy: %u", caps->MaxAnisotropy);
6847ec681f3Smrg    C2S("\nMaxVertexW: %f", caps->MaxVertexW);
6857ec681f3Smrg
6867ec681f3Smrg    C2S("\nGuardBandLef,Top,Right,Bottom: %f %f %f %f",
6877ec681f3Smrg        caps->GuardBandLeft, caps->GuardBandTop,
6887ec681f3Smrg        caps->GuardBandRight, caps->GuardBandBottom);
6897ec681f3Smrg
6907ec681f3Smrg    C2S("\nExtentsAdjust: %f", caps->ExtentsAdjust);
6917ec681f3Smrg
6927ec681f3Smrg    C2S("\nStencilCaps:");
6937ec681f3Smrg    CAP_CASE(StencilCaps, D3DSTENCILCAPS, KEEP);
6947ec681f3Smrg    CAP_CASE(StencilCaps, D3DSTENCILCAPS, ZERO);
6957ec681f3Smrg    CAP_CASE(StencilCaps, D3DSTENCILCAPS, REPLACE);
6967ec681f3Smrg    CAP_CASE(StencilCaps, D3DSTENCILCAPS, INCRSAT);
6977ec681f3Smrg    CAP_CASE(StencilCaps, D3DSTENCILCAPS, DECRSAT);
6987ec681f3Smrg    CAP_CASE(StencilCaps, D3DSTENCILCAPS, INVERT);
6997ec681f3Smrg    CAP_CASE(StencilCaps, D3DSTENCILCAPS, INCR);
7007ec681f3Smrg    CAP_CASE(StencilCaps, D3DSTENCILCAPS, DECR);
7017ec681f3Smrg    CAP_CASE(StencilCaps, D3DSTENCILCAPS, TWOSIDED);
7027ec681f3Smrg
7037ec681f3Smrg    C2S("\nFVFCaps:");
7047ec681f3Smrg    CAP_CASE(FVFCaps, D3DFVFCAPS, DONOTSTRIPELEMENTS);
7057ec681f3Smrg    CAP_CASE(FVFCaps, D3DFVFCAPS, PSIZE);
7067ec681f3Smrg    CAP_CASE(FVFCaps, D3DFVFCAPS, TEXCOORDCOUNTMASK);
7077ec681f3Smrg
7087ec681f3Smrg    C2S("\nTextureOpCaps:");
7097ec681f3Smrg    CAP_CASE(TextureOpCaps, D3DTEXOPCAPS, ADD);
7107ec681f3Smrg    CAP_CASE(TextureOpCaps, D3DTEXOPCAPS, ADDSIGNED);
7117ec681f3Smrg    C2S(" ...");
7127ec681f3Smrg
7137ec681f3Smrg    C2S("\nMaxTextureBlendStages: %u", caps->MaxTextureBlendStages);
7147ec681f3Smrg    C2S("\nMaxSimultaneousTextures: %u", caps->MaxTextureBlendStages);
7157ec681f3Smrg
7167ec681f3Smrg    C2S("\nVertexProcessingCaps:");
7177ec681f3Smrg    CAP_CASE(VertexProcessingCaps, D3DVTXPCAPS, DIRECTIONALLIGHTS);
7187ec681f3Smrg    CAP_CASE(VertexProcessingCaps, D3DVTXPCAPS, LOCALVIEWER);
7197ec681f3Smrg    CAP_CASE(VertexProcessingCaps, D3DVTXPCAPS, MATERIALSOURCE7);
7207ec681f3Smrg    CAP_CASE(VertexProcessingCaps, D3DVTXPCAPS, NO_TEXGEN_NONLOCALVIEWER);
7217ec681f3Smrg    CAP_CASE(VertexProcessingCaps, D3DVTXPCAPS, POSITIONALLIGHTS);
7227ec681f3Smrg    CAP_CASE(VertexProcessingCaps, D3DVTXPCAPS, TEXGEN);
7237ec681f3Smrg    CAP_CASE(VertexProcessingCaps, D3DVTXPCAPS, TEXGEN_SPHEREMAP);
7247ec681f3Smrg    CAP_CASE(VertexProcessingCaps, D3DVTXPCAPS, TWEENING);
7257ec681f3Smrg
7267ec681f3Smrg    C2S("\nMaxActiveLights: %u", caps->MaxActiveLights);
7277ec681f3Smrg    C2S("\nMaxUserClipPlanes: %u", caps->MaxUserClipPlanes);
7287ec681f3Smrg    C2S("\nMaxVertexBlendMatrices: %u", caps->MaxVertexBlendMatrices);
7297ec681f3Smrg    C2S("\nMaxVertexBlendMatrixIndex: %u", caps->MaxVertexBlendMatrixIndex);
7307ec681f3Smrg    C2S("\nMaxPointSize: %f", caps->MaxPointSize);
7317ec681f3Smrg    C2S("\nMaxPrimitiveCount: 0x%x", caps->MaxPrimitiveCount);
7327ec681f3Smrg    C2S("\nMaxVertexIndex: 0x%x", caps->MaxVertexIndex);
7337ec681f3Smrg    C2S("\nMaxStreams: %u", caps->MaxStreams);
7347ec681f3Smrg    C2S("\nMaxStreamStride: 0x%x", caps->MaxStreamStride);
7357ec681f3Smrg
7367ec681f3Smrg    C2S("\nVertexShaderVersion: %08x", caps->VertexShaderVersion);
7377ec681f3Smrg    C2S("\nMaxVertexShaderConst: %u", caps->MaxVertexShaderConst);
7387ec681f3Smrg    C2S("\nPixelShaderVersion: %08x", caps->PixelShaderVersion);
7397ec681f3Smrg    C2S("\nPixelShader1xMaxValue: %f", caps->PixelShader1xMaxValue);
7407ec681f3Smrg
7417ec681f3Smrg    DBG_FLAG(ch, "D3DCAPS9(%p) part 1:\n%s\n", caps, s);
7427ec681f3Smrg    p = 0;
7437ec681f3Smrg
7447ec681f3Smrg    C2S("DevCaps2:");
7457ec681f3Smrg    CAP_CASE(DevCaps2, D3DDEVCAPS2, ADAPTIVETESSRTPATCH);
7467ec681f3Smrg    CAP_CASE(DevCaps2, D3DDEVCAPS2, ADAPTIVETESSNPATCH);
7477ec681f3Smrg    CAP_CASE(DevCaps2, D3DDEVCAPS2, CAN_STRETCHRECT_FROM_TEXTURES);
7487ec681f3Smrg    CAP_CASE(DevCaps2, D3DDEVCAPS2, DMAPNPATCH);
7497ec681f3Smrg    CAP_CASE(DevCaps2, D3DDEVCAPS2, PRESAMPLEDDMAPNPATCH);
7507ec681f3Smrg    CAP_CASE(DevCaps2, D3DDEVCAPS2, STREAMOFFSET);
7517ec681f3Smrg    CAP_CASE(DevCaps2, D3DDEVCAPS2, VERTEXELEMENTSCANSHARESTREAMOFFSET);
7527ec681f3Smrg
7537ec681f3Smrg    C2S("\nMasterAdapterOrdinal: %u", caps->MasterAdapterOrdinal);
7547ec681f3Smrg    C2S("\nAdapterOrdinalInGroup: %u", caps->AdapterOrdinalInGroup);
7557ec681f3Smrg    C2S("\nNumberOfAdaptersInGroup: %u", caps->NumberOfAdaptersInGroup);
7567ec681f3Smrg
7577ec681f3Smrg    C2S("\nDeclTypes:");
7587ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, UBYTE4);
7597ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, UBYTE4N);
7607ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, SHORT2N);
7617ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, SHORT4N);
7627ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, USHORT2N);
7637ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, USHORT4N);
7647ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, UDEC3);
7657ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, DEC3N);
7667ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, FLOAT16_2);
7677ec681f3Smrg    CAP_CASE(DeclTypes, D3DDTCAPS, FLOAT16_4);
7687ec681f3Smrg
7697ec681f3Smrg    C2S("\nNumSimultaneousRTs: %u", caps->NumSimultaneousRTs);
7707ec681f3Smrg
7717ec681f3Smrg    C2S("\nStretchRectFilterCaps:");
7727ec681f3Smrg    CAP_CASE(StretchRectFilterCaps, D3DPTFILTERCAPS, MINFPOINT);
7737ec681f3Smrg    CAP_CASE(StretchRectFilterCaps, D3DPTFILTERCAPS, MINFLINEAR);
7747ec681f3Smrg    CAP_CASE(StretchRectFilterCaps, D3DPTFILTERCAPS, MAGFPOINT);
7757ec681f3Smrg    CAP_CASE(StretchRectFilterCaps, D3DPTFILTERCAPS, MAGFLINEAR);
7767ec681f3Smrg
7777ec681f3Smrg    C2S("\nVS20Caps.Caps: Predication=%s", caps->VS20Caps.Caps ? "yes" : "no");
7787ec681f3Smrg    C2S("\nVS20Caps.DynamicFlowControlDepth: %u", caps->VS20Caps.DynamicFlowControlDepth);
7797ec681f3Smrg    C2S("\nVS20Caps.NumTemps: %u", caps->VS20Caps.NumTemps);
7807ec681f3Smrg    C2S("\nVS20Caps.StaticFlowControlDepth: %u", caps->VS20Caps.StaticFlowControlDepth);
7817ec681f3Smrg
7827ec681f3Smrg    C2S("\nPS20Caps.Caps: Predication=%s", caps->VS20Caps.Caps ? "yes" : "no");
7837ec681f3Smrg    C2S("\nPS20Caps.DynamicFlowControlDepth: %u", caps->PS20Caps.DynamicFlowControlDepth);
7847ec681f3Smrg    C2S("\nPS20Caps.NumTemps: %u", caps->PS20Caps.NumTemps);
7857ec681f3Smrg    C2S("\nPS20Caps.StaticFlowControlDepth: %u", caps->PS20Caps.StaticFlowControlDepth);
7867ec681f3Smrg    C2S("\nPS20Caps.NumInstructionSlots: %u", caps->PS20Caps.NumInstructionSlots);
7877ec681f3Smrg
7887ec681f3Smrg    C2S("\nVertexTextureFilterCaps");
7897ec681f3Smrg /* CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, CONVOLUTIONMONO); */
7907ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MAGFPOINT);
7917ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MAGFLINEAR);
7927ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MAGFANISOTROPIC);
7937ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MAGFPYRAMIDALQUAD);
7947ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MAGFGAUSSIANQUAD);
7957ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MINFPOINT);
7967ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MINFLINEAR);
7977ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MINFANISOTROPIC);
7987ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MINFPYRAMIDALQUAD);
7997ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MINFGAUSSIANQUAD);
8007ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MIPFPOINT);
8017ec681f3Smrg    CAP_CASE(VertexTextureFilterCaps, D3DPTFILTERCAPS, MIPFLINEAR);
8027ec681f3Smrg
8037ec681f3Smrg    C2S("\nMaxVShaderInstructionsExecuted: %u", caps->MaxVShaderInstructionsExecuted);
8047ec681f3Smrg    C2S("\nMaxPShaderInstructionsExecuted: %u", caps->MaxPShaderInstructionsExecuted);
8057ec681f3Smrg    C2S("\nMaxVertexShader30InstructionSlots: %u >= 512", caps->MaxVertexShader30InstructionSlots);
8067ec681f3Smrg    C2S("\nMaxPixelShader30InstructionSlots: %u >= 512", caps->MaxPixelShader30InstructionSlots);
8077ec681f3Smrg
8087ec681f3Smrg    DBG_FLAG(ch, "D3DCAPS9(%p) part 2:\n%s\n", caps, s);
8097ec681f3Smrg
8107ec681f3Smrg    FREE(s);
8117ec681f3Smrg}
8127ec681f3Smrg
8137ec681f3Smrg#endif /* DEBUG || !NDEBUG */
814