1 #ifdef _DEBUG
2 struct D3DRenderStateInfo
3 {
4 const TCHAR *name;
5 D3DRENDERSTATETYPE value;
6 };
7 #define D3DRSINFO(value) {#value, value}
8 static const D3DRenderStateInfo d3dRenderStateInfos[] = {
9 D3DRSINFO(D3DRS_ZENABLE) , /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */
10 D3DRSINFO(D3DRS_FILLMODE) , /* D3DFILLMODE */
11 D3DRSINFO(D3DRS_SHADEMODE) , /* D3DSHADEMODE */
12 D3DRSINFO(D3DRS_ZWRITEENABLE) , /* TRUE to enable z writes */
13 D3DRSINFO(D3DRS_ALPHATESTENABLE) , /* TRUE to enable alpha tests */
14 D3DRSINFO(D3DRS_LASTPIXEL) , /* TRUE for last-pixel on lines */
15 D3DRSINFO(D3DRS_SRCBLEND) , /* D3DBLEND */
16 D3DRSINFO(D3DRS_DESTBLEND) , /* D3DBLEND */
17 D3DRSINFO(D3DRS_CULLMODE) , /* D3DCULL */
18 D3DRSINFO(D3DRS_ZFUNC) , /* D3DCMPFUNC */
19 D3DRSINFO(D3DRS_ALPHAREF) , /* D3DFIXED */
20 D3DRSINFO(D3DRS_ALPHAFUNC) , /* D3DCMPFUNC */
21 D3DRSINFO(D3DRS_DITHERENABLE) , /* TRUE to enable dithering */
22 D3DRSINFO(D3DRS_ALPHABLENDENABLE) , /* TRUE to enable alpha blending */
23 D3DRSINFO(D3DRS_FOGENABLE) , /* TRUE to enable fog blending */
24 D3DRSINFO(D3DRS_SPECULARENABLE) , /* TRUE to enable specular */
25 D3DRSINFO(D3DRS_FOGCOLOR) , /* D3DCOLOR */
26 D3DRSINFO(D3DRS_FOGTABLEMODE) , /* D3DFOGMODE */
27 D3DRSINFO(D3DRS_FOGSTART) , /* Fog start (for both vertex and pixel fog) */
28 D3DRSINFO(D3DRS_FOGEND) , /* Fog end */
29 D3DRSINFO(D3DRS_FOGDENSITY) , /* Fog density */
30 D3DRSINFO(D3DRS_RANGEFOGENABLE) , /* Enables range-based fog */
31 D3DRSINFO(D3DRS_STENCILENABLE) , /* BOOL enable/disable stenciling */
32 D3DRSINFO(D3DRS_STENCILFAIL) , /* D3DSTENCILOP to do if stencil test fails */
33 D3DRSINFO(D3DRS_STENCILZFAIL) , /* D3DSTENCILOP to do if stencil test passes and Z test fails */
34 D3DRSINFO(D3DRS_STENCILPASS) , /* D3DSTENCILOP to do if both stencil and Z tests pass */
35 D3DRSINFO(D3DRS_STENCILFUNC) , /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
36 D3DRSINFO(D3DRS_STENCILREF) , /* Reference value used in stencil test */
37 D3DRSINFO(D3DRS_STENCILMASK) , /* Mask value used in stencil test */
38 D3DRSINFO(D3DRS_STENCILWRITEMASK) , /* Write mask applied to values written to stencil buffer */
39 D3DRSINFO(D3DRS_TEXTUREFACTOR) , /* D3DCOLOR used for multi-texture blend */
40 D3DRSINFO(D3DRS_WRAP0) , /* wrap for 1st texture coord. set */
41 D3DRSINFO(D3DRS_WRAP1) , /* wrap for 2nd texture coord. set */
42 D3DRSINFO(D3DRS_WRAP2) , /* wrap for 3rd texture coord. set */
43 D3DRSINFO(D3DRS_WRAP3) , /* wrap for 4th texture coord. set */
44 D3DRSINFO(D3DRS_WRAP4) , /* wrap for 5th texture coord. set */
45 D3DRSINFO(D3DRS_WRAP5) , /* wrap for 6th texture coord. set */
46 D3DRSINFO(D3DRS_WRAP6) , /* wrap for 7th texture coord. set */
47 D3DRSINFO(D3DRS_WRAP7) , /* wrap for 8th texture coord. set */
48 D3DRSINFO(D3DRS_CLIPPING) ,
49 D3DRSINFO(D3DRS_LIGHTING) ,
50 D3DRSINFO(D3DRS_AMBIENT) ,
51 D3DRSINFO(D3DRS_FOGVERTEXMODE) ,
52 D3DRSINFO(D3DRS_COLORVERTEX) ,
53 D3DRSINFO(D3DRS_LOCALVIEWER) ,
54 D3DRSINFO(D3DRS_NORMALIZENORMALS) ,
55 D3DRSINFO(D3DRS_DIFFUSEMATERIALSOURCE) ,
56 D3DRSINFO(D3DRS_SPECULARMATERIALSOURCE) ,
57 D3DRSINFO(D3DRS_AMBIENTMATERIALSOURCE) ,
58 D3DRSINFO(D3DRS_EMISSIVEMATERIALSOURCE) ,
59 D3DRSINFO(D3DRS_VERTEXBLEND) ,
60 D3DRSINFO(D3DRS_CLIPPLANEENABLE) ,
61 D3DRSINFO(D3DRS_POINTSIZE) , /* float point size */
62 D3DRSINFO(D3DRS_POINTSIZE_MIN) , /* float point size min threshold */
63 D3DRSINFO(D3DRS_POINTSPRITEENABLE) , /* BOOL point texture coord control */
64 D3DRSINFO(D3DRS_POINTSCALEENABLE) , /* BOOL point size scale enable */
65 D3DRSINFO(D3DRS_POINTSCALE_A) , /* float point attenuation A value */
66 D3DRSINFO(D3DRS_POINTSCALE_B) , /* float point attenuation B value */
67 D3DRSINFO(D3DRS_POINTSCALE_C) , /* float point attenuation C value */
68 D3DRSINFO(D3DRS_MULTISAMPLEANTIALIAS) , /* BOOL - set to do FSAA with multisample buffer */
69 D3DRSINFO(D3DRS_MULTISAMPLEMASK) , /* DWORD - per-sample enable/disable */
70 D3DRSINFO(D3DRS_PATCHEDGESTYLE) , /* Sets whether patch edges will use float style tessellation */
71 D3DRSINFO(D3DRS_DEBUGMONITORTOKEN) , /* DEBUG ONLY - token to debug monitor */
72 D3DRSINFO(D3DRS_POINTSIZE_MAX) , /* float point size max threshold */
73 D3DRSINFO(D3DRS_INDEXEDVERTEXBLENDENABLE) ,
74 D3DRSINFO(D3DRS_COLORWRITEENABLE) , /* per-channel write enable */
75 D3DRSINFO(D3DRS_TWEENFACTOR) , /* float tween factor */
76 D3DRSINFO(D3DRS_BLENDOP) , /* D3DBLENDOP setting */
77 D3DRSINFO(D3DRS_POSITIONDEGREE) , /* NPatch position interpolation degree. D3DDEGREE_LINEAR or D3DDEGREE_CUBIC (default) */
78 D3DRSINFO(D3DRS_NORMALDEGREE) , /* NPatch normal interpolation degree. D3DDEGREE_LINEAR (default) or D3DDEGREE_QUADRATIC */
79 D3DRSINFO(D3DRS_SCISSORTESTENABLE) ,
80 D3DRSINFO(D3DRS_SLOPESCALEDEPTHBIAS) ,
81 D3DRSINFO(D3DRS_ANTIALIASEDLINEENABLE) ,
82 D3DRSINFO(D3DRS_MINTESSELLATIONLEVEL) ,
83 D3DRSINFO(D3DRS_MAXTESSELLATIONLEVEL) ,
84 D3DRSINFO(D3DRS_ADAPTIVETESS_X) ,
85 D3DRSINFO(D3DRS_ADAPTIVETESS_Y) ,
86 D3DRSINFO(D3DRS_ADAPTIVETESS_Z) ,
87 D3DRSINFO(D3DRS_ADAPTIVETESS_W) ,
88 D3DRSINFO(D3DRS_ENABLEADAPTIVETESSELLATION),
89 D3DRSINFO(D3DRS_TWOSIDEDSTENCILMODE) , /* BOOL enable/disable 2 sided stenciling */
90 D3DRSINFO(D3DRS_CCW_STENCILFAIL) , /* D3DSTENCILOP to do if ccw stencil test fails */
91 D3DRSINFO(D3DRS_CCW_STENCILZFAIL) , /* D3DSTENCILOP to do if ccw stencil test passes and Z test fails */
92 D3DRSINFO(D3DRS_CCW_STENCILPASS) , /* D3DSTENCILOP to do if both ccw stencil and Z tests pass */
93 D3DRSINFO(D3DRS_CCW_STENCILFUNC) , /* D3DCMPFUNC fn. ccw Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
94 D3DRSINFO(D3DRS_COLORWRITEENABLE1) , /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */
95 D3DRSINFO(D3DRS_COLORWRITEENABLE2) , /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */
96 D3DRSINFO(D3DRS_COLORWRITEENABLE3) , /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */
97 D3DRSINFO(D3DRS_BLENDFACTOR) , /* D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR */
98 D3DRSINFO(D3DRS_SRGBWRITEENABLE) , /* Enable rendertarget writes to be DE-linearized to SRGB (for formats that expose D3DUSAGE_QUERY_SRGBWRITE) */
99 D3DRSINFO(D3DRS_DEPTHBIAS) ,
100 D3DRSINFO(D3DRS_WRAP8) , /* Additional wrap states for vs_3_0+ attributes with D3DDECLUSAGE_TEXCOORD */
101 D3DRSINFO(D3DRS_WRAP9) ,
102 D3DRSINFO(D3DRS_WRAP10) ,
103 D3DRSINFO(D3DRS_WRAP11) ,
104 D3DRSINFO(D3DRS_WRAP12) ,
105 D3DRSINFO(D3DRS_WRAP13) ,
106 D3DRSINFO(D3DRS_WRAP14) ,
107 D3DRSINFO(D3DRS_WRAP15) ,
108 D3DRSINFO(D3DRS_SEPARATEALPHABLENDENABLE) , /* TRUE to enable a separate blending function for the alpha channel */
109 D3DRSINFO(D3DRS_SRCBLENDALPHA) , /* SRC blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */
110 D3DRSINFO(D3DRS_DESTBLENDALPHA) , /* DST blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */
111 D3DRSINFO(D3DRS_BLENDOPALPHA) , /* Blending operation for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */
112 };
113 #define DEBUG_PRINT_RENDERSTATES(dev) \
114 DebugPrint(_T("************************************************\n"));\
115 for (int i = 0; i < sizeof(d3dRenderStateInfos) / sizeof(D3DRenderStateInfo); ++i) {\
116 DWORD dwValue;\
117 (dev)->GetRenderState(d3dRenderStateInfos[i].value, &dwValue);\
118 DebugPrint(_T("Render State: %s - Value: %d\n"), d3dRenderStateInfos[i].name, dwValue);\
119 }\
120 DebugPrint(_T("************************************************\n"));
121 #endif // _DEBUG
2 struct D3DRenderStateInfo
3 {
4 const TCHAR *name;
5 D3DRENDERSTATETYPE value;
6 };
7 #define D3DRSINFO(value) {#value, value}
8 static const D3DRenderStateInfo d3dRenderStateInfos[] = {
9 D3DRSINFO(D3DRS_ZENABLE) , /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */
10 D3DRSINFO(D3DRS_FILLMODE) , /* D3DFILLMODE */
11 D3DRSINFO(D3DRS_SHADEMODE) , /* D3DSHADEMODE */
12 D3DRSINFO(D3DRS_ZWRITEENABLE) , /* TRUE to enable z writes */
13 D3DRSINFO(D3DRS_ALPHATESTENABLE) , /* TRUE to enable alpha tests */
14 D3DRSINFO(D3DRS_LASTPIXEL) , /* TRUE for last-pixel on lines */
15 D3DRSINFO(D3DRS_SRCBLEND) , /* D3DBLEND */
16 D3DRSINFO(D3DRS_DESTBLEND) , /* D3DBLEND */
17 D3DRSINFO(D3DRS_CULLMODE) , /* D3DCULL */
18 D3DRSINFO(D3DRS_ZFUNC) , /* D3DCMPFUNC */
19 D3DRSINFO(D3DRS_ALPHAREF) , /* D3DFIXED */
20 D3DRSINFO(D3DRS_ALPHAFUNC) , /* D3DCMPFUNC */
21 D3DRSINFO(D3DRS_DITHERENABLE) , /* TRUE to enable dithering */
22 D3DRSINFO(D3DRS_ALPHABLENDENABLE) , /* TRUE to enable alpha blending */
23 D3DRSINFO(D3DRS_FOGENABLE) , /* TRUE to enable fog blending */
24 D3DRSINFO(D3DRS_SPECULARENABLE) , /* TRUE to enable specular */
25 D3DRSINFO(D3DRS_FOGCOLOR) , /* D3DCOLOR */
26 D3DRSINFO(D3DRS_FOGTABLEMODE) , /* D3DFOGMODE */
27 D3DRSINFO(D3DRS_FOGSTART) , /* Fog start (for both vertex and pixel fog) */
28 D3DRSINFO(D3DRS_FOGEND) , /* Fog end */
29 D3DRSINFO(D3DRS_FOGDENSITY) , /* Fog density */
30 D3DRSINFO(D3DRS_RANGEFOGENABLE) , /* Enables range-based fog */
31 D3DRSINFO(D3DRS_STENCILENABLE) , /* BOOL enable/disable stenciling */
32 D3DRSINFO(D3DRS_STENCILFAIL) , /* D3DSTENCILOP to do if stencil test fails */
33 D3DRSINFO(D3DRS_STENCILZFAIL) , /* D3DSTENCILOP to do if stencil test passes and Z test fails */
34 D3DRSINFO(D3DRS_STENCILPASS) , /* D3DSTENCILOP to do if both stencil and Z tests pass */
35 D3DRSINFO(D3DRS_STENCILFUNC) , /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
36 D3DRSINFO(D3DRS_STENCILREF) , /* Reference value used in stencil test */
37 D3DRSINFO(D3DRS_STENCILMASK) , /* Mask value used in stencil test */
38 D3DRSINFO(D3DRS_STENCILWRITEMASK) , /* Write mask applied to values written to stencil buffer */
39 D3DRSINFO(D3DRS_TEXTUREFACTOR) , /* D3DCOLOR used for multi-texture blend */
40 D3DRSINFO(D3DRS_WRAP0) , /* wrap for 1st texture coord. set */
41 D3DRSINFO(D3DRS_WRAP1) , /* wrap for 2nd texture coord. set */
42 D3DRSINFO(D3DRS_WRAP2) , /* wrap for 3rd texture coord. set */
43 D3DRSINFO(D3DRS_WRAP3) , /* wrap for 4th texture coord. set */
44 D3DRSINFO(D3DRS_WRAP4) , /* wrap for 5th texture coord. set */
45 D3DRSINFO(D3DRS_WRAP5) , /* wrap for 6th texture coord. set */
46 D3DRSINFO(D3DRS_WRAP6) , /* wrap for 7th texture coord. set */
47 D3DRSINFO(D3DRS_WRAP7) , /* wrap for 8th texture coord. set */
48 D3DRSINFO(D3DRS_CLIPPING) ,
49 D3DRSINFO(D3DRS_LIGHTING) ,
50 D3DRSINFO(D3DRS_AMBIENT) ,
51 D3DRSINFO(D3DRS_FOGVERTEXMODE) ,
52 D3DRSINFO(D3DRS_COLORVERTEX) ,
53 D3DRSINFO(D3DRS_LOCALVIEWER) ,
54 D3DRSINFO(D3DRS_NORMALIZENORMALS) ,
55 D3DRSINFO(D3DRS_DIFFUSEMATERIALSOURCE) ,
56 D3DRSINFO(D3DRS_SPECULARMATERIALSOURCE) ,
57 D3DRSINFO(D3DRS_AMBIENTMATERIALSOURCE) ,
58 D3DRSINFO(D3DRS_EMISSIVEMATERIALSOURCE) ,
59 D3DRSINFO(D3DRS_VERTEXBLEND) ,
60 D3DRSINFO(D3DRS_CLIPPLANEENABLE) ,
61 D3DRSINFO(D3DRS_POINTSIZE) , /* float point size */
62 D3DRSINFO(D3DRS_POINTSIZE_MIN) , /* float point size min threshold */
63 D3DRSINFO(D3DRS_POINTSPRITEENABLE) , /* BOOL point texture coord control */
64 D3DRSINFO(D3DRS_POINTSCALEENABLE) , /* BOOL point size scale enable */
65 D3DRSINFO(D3DRS_POINTSCALE_A) , /* float point attenuation A value */
66 D3DRSINFO(D3DRS_POINTSCALE_B) , /* float point attenuation B value */
67 D3DRSINFO(D3DRS_POINTSCALE_C) , /* float point attenuation C value */
68 D3DRSINFO(D3DRS_MULTISAMPLEANTIALIAS) , /* BOOL - set to do FSAA with multisample buffer */
69 D3DRSINFO(D3DRS_MULTISAMPLEMASK) , /* DWORD - per-sample enable/disable */
70 D3DRSINFO(D3DRS_PATCHEDGESTYLE) , /* Sets whether patch edges will use float style tessellation */
71 D3DRSINFO(D3DRS_DEBUGMONITORTOKEN) , /* DEBUG ONLY - token to debug monitor */
72 D3DRSINFO(D3DRS_POINTSIZE_MAX) , /* float point size max threshold */
73 D3DRSINFO(D3DRS_INDEXEDVERTEXBLENDENABLE) ,
74 D3DRSINFO(D3DRS_COLORWRITEENABLE) , /* per-channel write enable */
75 D3DRSINFO(D3DRS_TWEENFACTOR) , /* float tween factor */
76 D3DRSINFO(D3DRS_BLENDOP) , /* D3DBLENDOP setting */
77 D3DRSINFO(D3DRS_POSITIONDEGREE) , /* NPatch position interpolation degree. D3DDEGREE_LINEAR or D3DDEGREE_CUBIC (default) */
78 D3DRSINFO(D3DRS_NORMALDEGREE) , /* NPatch normal interpolation degree. D3DDEGREE_LINEAR (default) or D3DDEGREE_QUADRATIC */
79 D3DRSINFO(D3DRS_SCISSORTESTENABLE) ,
80 D3DRSINFO(D3DRS_SLOPESCALEDEPTHBIAS) ,
81 D3DRSINFO(D3DRS_ANTIALIASEDLINEENABLE) ,
82 D3DRSINFO(D3DRS_MINTESSELLATIONLEVEL) ,
83 D3DRSINFO(D3DRS_MAXTESSELLATIONLEVEL) ,
84 D3DRSINFO(D3DRS_ADAPTIVETESS_X) ,
85 D3DRSINFO(D3DRS_ADAPTIVETESS_Y) ,
86 D3DRSINFO(D3DRS_ADAPTIVETESS_Z) ,
87 D3DRSINFO(D3DRS_ADAPTIVETESS_W) ,
88 D3DRSINFO(D3DRS_ENABLEADAPTIVETESSELLATION),
89 D3DRSINFO(D3DRS_TWOSIDEDSTENCILMODE) , /* BOOL enable/disable 2 sided stenciling */
90 D3DRSINFO(D3DRS_CCW_STENCILFAIL) , /* D3DSTENCILOP to do if ccw stencil test fails */
91 D3DRSINFO(D3DRS_CCW_STENCILZFAIL) , /* D3DSTENCILOP to do if ccw stencil test passes and Z test fails */
92 D3DRSINFO(D3DRS_CCW_STENCILPASS) , /* D3DSTENCILOP to do if both ccw stencil and Z tests pass */
93 D3DRSINFO(D3DRS_CCW_STENCILFUNC) , /* D3DCMPFUNC fn. ccw Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
94 D3DRSINFO(D3DRS_COLORWRITEENABLE1) , /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */
95 D3DRSINFO(D3DRS_COLORWRITEENABLE2) , /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */
96 D3DRSINFO(D3DRS_COLORWRITEENABLE3) , /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */
97 D3DRSINFO(D3DRS_BLENDFACTOR) , /* D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR */
98 D3DRSINFO(D3DRS_SRGBWRITEENABLE) , /* Enable rendertarget writes to be DE-linearized to SRGB (for formats that expose D3DUSAGE_QUERY_SRGBWRITE) */
99 D3DRSINFO(D3DRS_DEPTHBIAS) ,
100 D3DRSINFO(D3DRS_WRAP8) , /* Additional wrap states for vs_3_0+ attributes with D3DDECLUSAGE_TEXCOORD */
101 D3DRSINFO(D3DRS_WRAP9) ,
102 D3DRSINFO(D3DRS_WRAP10) ,
103 D3DRSINFO(D3DRS_WRAP11) ,
104 D3DRSINFO(D3DRS_WRAP12) ,
105 D3DRSINFO(D3DRS_WRAP13) ,
106 D3DRSINFO(D3DRS_WRAP14) ,
107 D3DRSINFO(D3DRS_WRAP15) ,
108 D3DRSINFO(D3DRS_SEPARATEALPHABLENDENABLE) , /* TRUE to enable a separate blending function for the alpha channel */
109 D3DRSINFO(D3DRS_SRCBLENDALPHA) , /* SRC blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */
110 D3DRSINFO(D3DRS_DESTBLENDALPHA) , /* DST blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */
111 D3DRSINFO(D3DRS_BLENDOPALPHA) , /* Blending operation for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */
112 };
113 #define DEBUG_PRINT_RENDERSTATES(dev) \
114 DebugPrint(_T("************************************************\n"));\
115 for (int i = 0; i < sizeof(d3dRenderStateInfos) / sizeof(D3DRenderStateInfo); ++i) {\
116 DWORD dwValue;\
117 (dev)->GetRenderState(d3dRenderStateInfos[i].value, &dwValue);\
118 DebugPrint(_T("Render State: %s - Value: %d\n"), d3dRenderStateInfos[i].name, dwValue);\
119 }\
120 DebugPrint(_T("************************************************\n"));
121 #endif // _DEBUG