Move the Check* type functions into wined3d and copy from d3d9, and
[wine] / dlls / wined3d / utils.c
1 /*
2  * Utility functions for the WineD3D Library
3  *
4  * Copyright 2002-2004 Jason Edmeades
5  * Copyright 2003-2004 Raphael Junqueira
6  * Copyright 2004 Christian Costa
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "config.h"
24 #include "wined3d_private.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
27
28 const char* debug_d3dformat(D3DFORMAT fmt) {
29   switch (fmt) {
30 #define FMT_TO_STR(fmt) case fmt: return #fmt
31     FMT_TO_STR(D3DFMT_UNKNOWN);
32     FMT_TO_STR(D3DFMT_R8G8B8);
33     FMT_TO_STR(D3DFMT_A8R8G8B8);
34     FMT_TO_STR(D3DFMT_X8R8G8B8);
35     FMT_TO_STR(D3DFMT_R5G6B5);
36     FMT_TO_STR(D3DFMT_X1R5G5B5);
37     FMT_TO_STR(D3DFMT_A1R5G5B5);
38     FMT_TO_STR(D3DFMT_A4R4G4B4);
39     FMT_TO_STR(D3DFMT_R3G3B2);
40     FMT_TO_STR(D3DFMT_A8);
41     FMT_TO_STR(D3DFMT_A8R3G3B2);
42     FMT_TO_STR(D3DFMT_X4R4G4B4);
43     FMT_TO_STR(D3DFMT_A8P8);
44     FMT_TO_STR(D3DFMT_P8);
45     FMT_TO_STR(D3DFMT_L8);
46     FMT_TO_STR(D3DFMT_A8L8);
47     FMT_TO_STR(D3DFMT_A4L4);
48     FMT_TO_STR(D3DFMT_V8U8);
49     FMT_TO_STR(D3DFMT_L6V5U5);
50     FMT_TO_STR(D3DFMT_X8L8V8U8);
51     FMT_TO_STR(D3DFMT_Q8W8V8U8);
52     FMT_TO_STR(D3DFMT_V16U16);
53     FMT_TO_STR(D3DFMT_W11V11U10);
54     FMT_TO_STR(D3DFMT_UYVY);
55     FMT_TO_STR(D3DFMT_YUY2);
56     FMT_TO_STR(D3DFMT_DXT1);
57     FMT_TO_STR(D3DFMT_DXT2);
58     FMT_TO_STR(D3DFMT_DXT3);
59     FMT_TO_STR(D3DFMT_DXT4);
60     FMT_TO_STR(D3DFMT_DXT5);
61     FMT_TO_STR(D3DFMT_D16_LOCKABLE);
62     FMT_TO_STR(D3DFMT_D32);
63     FMT_TO_STR(D3DFMT_D15S1);
64     FMT_TO_STR(D3DFMT_D24S8);
65     FMT_TO_STR(D3DFMT_D16);
66     FMT_TO_STR(D3DFMT_D24X8);
67     FMT_TO_STR(D3DFMT_D24X4S4);
68     FMT_TO_STR(D3DFMT_VERTEXDATA);
69     FMT_TO_STR(D3DFMT_INDEX16);
70     FMT_TO_STR(D3DFMT_INDEX32);
71 #undef FMT_TO_STR
72   default:
73     FIXME("Unrecognized %u D3DFORMAT!\n", fmt);
74     return "unrecognized";
75   }
76 }
77
78 const char* debug_d3ddevicetype(D3DDEVTYPE devtype) {
79   switch (devtype) {
80 #define DEVTYPE_TO_STR(dev) case dev: return #dev
81     DEVTYPE_TO_STR(D3DDEVTYPE_HAL);
82     DEVTYPE_TO_STR(D3DDEVTYPE_REF);
83     DEVTYPE_TO_STR(D3DDEVTYPE_SW);    
84 #undef DEVTYPE_TO_STR
85   default:
86     FIXME("Unrecognized %u D3DDEVTYPE!\n", devtype);
87     return "unrecognized";
88   }
89 }
90
91 const char* debug_d3dusage(DWORD usage) {
92   switch (usage) {
93 #define D3DUSAGE_TO_STR(u) case u: return #u
94     D3DUSAGE_TO_STR(D3DUSAGE_RENDERTARGET);
95     D3DUSAGE_TO_STR(D3DUSAGE_DEPTHSTENCIL);
96     D3DUSAGE_TO_STR(D3DUSAGE_WRITEONLY);
97     D3DUSAGE_TO_STR(D3DUSAGE_SOFTWAREPROCESSING);
98     D3DUSAGE_TO_STR(D3DUSAGE_DONOTCLIP);
99     D3DUSAGE_TO_STR(D3DUSAGE_POINTS);
100     D3DUSAGE_TO_STR(D3DUSAGE_RTPATCHES);
101     D3DUSAGE_TO_STR(D3DUSAGE_NPATCHES);
102     D3DUSAGE_TO_STR(D3DUSAGE_DYNAMIC);
103 #undef D3DUSAGE_TO_STR
104   case 0: return "none";
105   default:
106     FIXME("Unrecognized %lu Usage!\n", usage);
107     return "unrecognized";
108   }
109 }
110
111 const char* debug_d3dresourcetype(D3DRESOURCETYPE res) {
112   switch (res) {
113 #define RES_TO_STR(res) case res: return #res;
114     RES_TO_STR(D3DRTYPE_SURFACE);
115     RES_TO_STR(D3DRTYPE_VOLUME);
116     RES_TO_STR(D3DRTYPE_TEXTURE);
117     RES_TO_STR(D3DRTYPE_VOLUMETEXTURE);
118     RES_TO_STR(D3DRTYPE_CUBETEXTURE);
119     RES_TO_STR(D3DRTYPE_VERTEXBUFFER);
120     RES_TO_STR(D3DRTYPE_INDEXBUFFER);
121 #undef  RES_TO_STR
122   default:
123     FIXME("Unrecognized %u D3DRESOURCETYPE!\n", res);
124     return "unrecognized";
125   }
126 }