2 * Copyright 2008 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
23 #include "dxgi_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(dxgi
);
26 WINE_DECLARE_DEBUG_CHANNEL(winediag
);
28 #define WINE_DXGI_TO_STR(x) case x: return #x
30 static const char *debug_feature_level(D3D_FEATURE_LEVEL feature_level
)
32 switch (feature_level
)
34 WINE_DXGI_TO_STR(D3D_FEATURE_LEVEL_9_1
);
35 WINE_DXGI_TO_STR(D3D_FEATURE_LEVEL_9_2
);
36 WINE_DXGI_TO_STR(D3D_FEATURE_LEVEL_9_3
);
37 WINE_DXGI_TO_STR(D3D_FEATURE_LEVEL_10_0
);
38 WINE_DXGI_TO_STR(D3D_FEATURE_LEVEL_10_1
);
39 WINE_DXGI_TO_STR(D3D_FEATURE_LEVEL_11_0
);
40 WINE_DXGI_TO_STR(D3D_FEATURE_LEVEL_11_1
);
42 FIXME("Unrecognized D3D_FEATURE_LEVEL %#x.\n", feature_level
);
43 return "unrecognized";
47 const char *debug_dxgi_format(DXGI_FORMAT format
)
51 WINE_DXGI_TO_STR(DXGI_FORMAT_UNKNOWN
);
52 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32B32A32_TYPELESS
);
53 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32B32A32_FLOAT
);
54 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32B32A32_UINT
);
55 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32B32A32_SINT
);
56 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32B32_TYPELESS
);
57 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32B32_FLOAT
);
58 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32B32_UINT
);
59 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32B32_SINT
);
60 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16B16A16_TYPELESS
);
61 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16B16A16_FLOAT
);
62 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16B16A16_UNORM
);
63 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16B16A16_UINT
);
64 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16B16A16_SNORM
);
65 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16B16A16_SINT
);
66 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32_TYPELESS
);
67 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32_FLOAT
);
68 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32_UINT
);
69 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G32_SINT
);
70 WINE_DXGI_TO_STR(DXGI_FORMAT_R32G8X24_TYPELESS
);
71 WINE_DXGI_TO_STR(DXGI_FORMAT_D32_FLOAT_S8X24_UINT
);
72 WINE_DXGI_TO_STR(DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
);
73 WINE_DXGI_TO_STR(DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
);
74 WINE_DXGI_TO_STR(DXGI_FORMAT_R10G10B10A2_TYPELESS
);
75 WINE_DXGI_TO_STR(DXGI_FORMAT_R10G10B10A2_UNORM
);
76 WINE_DXGI_TO_STR(DXGI_FORMAT_R10G10B10A2_UINT
);
77 WINE_DXGI_TO_STR(DXGI_FORMAT_R11G11B10_FLOAT
);
78 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8B8A8_TYPELESS
);
79 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8B8A8_UNORM
);
80 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
);
81 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8B8A8_UINT
);
82 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8B8A8_SNORM
);
83 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8B8A8_SINT
);
84 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16_TYPELESS
);
85 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16_FLOAT
);
86 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16_UNORM
);
87 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16_UINT
);
88 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16_SNORM
);
89 WINE_DXGI_TO_STR(DXGI_FORMAT_R16G16_SINT
);
90 WINE_DXGI_TO_STR(DXGI_FORMAT_R32_TYPELESS
);
91 WINE_DXGI_TO_STR(DXGI_FORMAT_D32_FLOAT
);
92 WINE_DXGI_TO_STR(DXGI_FORMAT_R32_FLOAT
);
93 WINE_DXGI_TO_STR(DXGI_FORMAT_R32_UINT
);
94 WINE_DXGI_TO_STR(DXGI_FORMAT_R32_SINT
);
95 WINE_DXGI_TO_STR(DXGI_FORMAT_R24G8_TYPELESS
);
96 WINE_DXGI_TO_STR(DXGI_FORMAT_D24_UNORM_S8_UINT
);
97 WINE_DXGI_TO_STR(DXGI_FORMAT_R24_UNORM_X8_TYPELESS
);
98 WINE_DXGI_TO_STR(DXGI_FORMAT_X24_TYPELESS_G8_UINT
);
99 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8_TYPELESS
);
100 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8_UNORM
);
101 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8_UINT
);
102 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8_SNORM
);
103 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8_SINT
);
104 WINE_DXGI_TO_STR(DXGI_FORMAT_R16_TYPELESS
);
105 WINE_DXGI_TO_STR(DXGI_FORMAT_R16_FLOAT
);
106 WINE_DXGI_TO_STR(DXGI_FORMAT_D16_UNORM
);
107 WINE_DXGI_TO_STR(DXGI_FORMAT_R16_UNORM
);
108 WINE_DXGI_TO_STR(DXGI_FORMAT_R16_UINT
);
109 WINE_DXGI_TO_STR(DXGI_FORMAT_R16_SNORM
);
110 WINE_DXGI_TO_STR(DXGI_FORMAT_R16_SINT
);
111 WINE_DXGI_TO_STR(DXGI_FORMAT_R8_TYPELESS
);
112 WINE_DXGI_TO_STR(DXGI_FORMAT_R8_UNORM
);
113 WINE_DXGI_TO_STR(DXGI_FORMAT_R8_UINT
);
114 WINE_DXGI_TO_STR(DXGI_FORMAT_R8_SNORM
);
115 WINE_DXGI_TO_STR(DXGI_FORMAT_R8_SINT
);
116 WINE_DXGI_TO_STR(DXGI_FORMAT_A8_UNORM
);
117 WINE_DXGI_TO_STR(DXGI_FORMAT_R1_UNORM
);
118 WINE_DXGI_TO_STR(DXGI_FORMAT_R9G9B9E5_SHAREDEXP
);
119 WINE_DXGI_TO_STR(DXGI_FORMAT_R8G8_B8G8_UNORM
);
120 WINE_DXGI_TO_STR(DXGI_FORMAT_G8R8_G8B8_UNORM
);
121 WINE_DXGI_TO_STR(DXGI_FORMAT_BC1_TYPELESS
);
122 WINE_DXGI_TO_STR(DXGI_FORMAT_BC1_UNORM
);
123 WINE_DXGI_TO_STR(DXGI_FORMAT_BC1_UNORM_SRGB
);
124 WINE_DXGI_TO_STR(DXGI_FORMAT_BC2_TYPELESS
);
125 WINE_DXGI_TO_STR(DXGI_FORMAT_BC2_UNORM
);
126 WINE_DXGI_TO_STR(DXGI_FORMAT_BC2_UNORM_SRGB
);
127 WINE_DXGI_TO_STR(DXGI_FORMAT_BC3_TYPELESS
);
128 WINE_DXGI_TO_STR(DXGI_FORMAT_BC3_UNORM
);
129 WINE_DXGI_TO_STR(DXGI_FORMAT_BC3_UNORM_SRGB
);
130 WINE_DXGI_TO_STR(DXGI_FORMAT_BC4_TYPELESS
);
131 WINE_DXGI_TO_STR(DXGI_FORMAT_BC4_UNORM
);
132 WINE_DXGI_TO_STR(DXGI_FORMAT_BC4_SNORM
);
133 WINE_DXGI_TO_STR(DXGI_FORMAT_BC5_TYPELESS
);
134 WINE_DXGI_TO_STR(DXGI_FORMAT_BC5_UNORM
);
135 WINE_DXGI_TO_STR(DXGI_FORMAT_BC5_SNORM
);
136 WINE_DXGI_TO_STR(DXGI_FORMAT_B5G6R5_UNORM
);
137 WINE_DXGI_TO_STR(DXGI_FORMAT_B5G5R5A1_UNORM
);
138 WINE_DXGI_TO_STR(DXGI_FORMAT_B8G8R8A8_UNORM
);
139 WINE_DXGI_TO_STR(DXGI_FORMAT_B8G8R8X8_UNORM
);
140 WINE_DXGI_TO_STR(DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
);
141 WINE_DXGI_TO_STR(DXGI_FORMAT_B8G8R8A8_TYPELESS
);
142 WINE_DXGI_TO_STR(DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
);
143 WINE_DXGI_TO_STR(DXGI_FORMAT_B8G8R8X8_TYPELESS
);
144 WINE_DXGI_TO_STR(DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
);
145 WINE_DXGI_TO_STR(DXGI_FORMAT_BC6H_TYPELESS
);
146 WINE_DXGI_TO_STR(DXGI_FORMAT_BC6H_UF16
);
147 WINE_DXGI_TO_STR(DXGI_FORMAT_BC6H_SF16
);
148 WINE_DXGI_TO_STR(DXGI_FORMAT_BC7_TYPELESS
);
149 WINE_DXGI_TO_STR(DXGI_FORMAT_BC7_UNORM
);
150 WINE_DXGI_TO_STR(DXGI_FORMAT_BC7_UNORM_SRGB
);
152 FIXME("Unrecognized DXGI_FORMAT %#x.\n", format
);
153 return "unrecognized";
157 #undef WINE_DXGI_TO_STR
159 DXGI_FORMAT
dxgi_format_from_wined3dformat(enum wined3d_format_id format
)
163 case WINED3DFMT_UNKNOWN
: return DXGI_FORMAT_UNKNOWN
;
164 case WINED3DFMT_R32G32B32A32_TYPELESS
: return DXGI_FORMAT_R32G32B32A32_TYPELESS
;
165 case WINED3DFMT_R32G32B32A32_FLOAT
: return DXGI_FORMAT_R32G32B32A32_FLOAT
;
166 case WINED3DFMT_R32G32B32A32_UINT
: return DXGI_FORMAT_R32G32B32A32_UINT
;
167 case WINED3DFMT_R32G32B32A32_SINT
: return DXGI_FORMAT_R32G32B32A32_SINT
;
168 case WINED3DFMT_R32G32B32_TYPELESS
: return DXGI_FORMAT_R32G32B32_TYPELESS
;
169 case WINED3DFMT_R32G32B32_FLOAT
: return DXGI_FORMAT_R32G32B32_FLOAT
;
170 case WINED3DFMT_R32G32B32_UINT
: return DXGI_FORMAT_R32G32B32_UINT
;
171 case WINED3DFMT_R32G32B32_SINT
: return DXGI_FORMAT_R32G32B32_SINT
;
172 case WINED3DFMT_R16G16B16A16_TYPELESS
: return DXGI_FORMAT_R16G16B16A16_TYPELESS
;
173 case WINED3DFMT_R16G16B16A16_FLOAT
: return DXGI_FORMAT_R16G16B16A16_FLOAT
;
174 case WINED3DFMT_R16G16B16A16_UNORM
: return DXGI_FORMAT_R16G16B16A16_UNORM
;
175 case WINED3DFMT_R16G16B16A16_UINT
: return DXGI_FORMAT_R16G16B16A16_UINT
;
176 case WINED3DFMT_R16G16B16A16_SNORM
: return DXGI_FORMAT_R16G16B16A16_SNORM
;
177 case WINED3DFMT_R16G16B16A16_SINT
: return DXGI_FORMAT_R16G16B16A16_SINT
;
178 case WINED3DFMT_R32G32_TYPELESS
: return DXGI_FORMAT_R32G32_TYPELESS
;
179 case WINED3DFMT_R32G32_FLOAT
: return DXGI_FORMAT_R32G32_FLOAT
;
180 case WINED3DFMT_R32G32_UINT
: return DXGI_FORMAT_R32G32_UINT
;
181 case WINED3DFMT_R32G32_SINT
: return DXGI_FORMAT_R32G32_SINT
;
182 case WINED3DFMT_R32G8X24_TYPELESS
: return DXGI_FORMAT_R32G8X24_TYPELESS
;
183 case WINED3DFMT_D32_FLOAT_S8X24_UINT
: return DXGI_FORMAT_D32_FLOAT_S8X24_UINT
;
184 case WINED3DFMT_R32_FLOAT_X8X24_TYPELESS
: return DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
;
185 case WINED3DFMT_X32_TYPELESS_G8X24_UINT
: return DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
;
186 case WINED3DFMT_R10G10B10A2_TYPELESS
: return DXGI_FORMAT_R10G10B10A2_TYPELESS
;
187 case WINED3DFMT_R10G10B10A2_UNORM
: return DXGI_FORMAT_R10G10B10A2_UNORM
;
188 case WINED3DFMT_R10G10B10A2_UINT
: return DXGI_FORMAT_R10G10B10A2_UINT
;
189 case WINED3DFMT_R11G11B10_FLOAT
: return DXGI_FORMAT_R11G11B10_FLOAT
;
190 case WINED3DFMT_R8G8B8A8_TYPELESS
: return DXGI_FORMAT_R8G8B8A8_TYPELESS
;
191 case WINED3DFMT_R8G8B8A8_UNORM
: return DXGI_FORMAT_R8G8B8A8_UNORM
;
192 case WINED3DFMT_R8G8B8A8_UNORM_SRGB
: return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
193 case WINED3DFMT_R8G8B8A8_UINT
: return DXGI_FORMAT_R8G8B8A8_UINT
;
194 case WINED3DFMT_R8G8B8A8_SNORM
: return DXGI_FORMAT_R8G8B8A8_SNORM
;
195 case WINED3DFMT_R8G8B8A8_SINT
: return DXGI_FORMAT_R8G8B8A8_SINT
;
196 case WINED3DFMT_R16G16_TYPELESS
: return DXGI_FORMAT_R16G16_TYPELESS
;
197 case WINED3DFMT_R16G16_FLOAT
: return DXGI_FORMAT_R16G16_FLOAT
;
198 case WINED3DFMT_R16G16_UNORM
: return DXGI_FORMAT_R16G16_UNORM
;
199 case WINED3DFMT_R16G16_UINT
: return DXGI_FORMAT_R16G16_UINT
;
200 case WINED3DFMT_R16G16_SNORM
: return DXGI_FORMAT_R16G16_SNORM
;
201 case WINED3DFMT_R16G16_SINT
: return DXGI_FORMAT_R16G16_SINT
;
202 case WINED3DFMT_R32_TYPELESS
: return DXGI_FORMAT_R32_TYPELESS
;
203 case WINED3DFMT_D32_FLOAT
: return DXGI_FORMAT_D32_FLOAT
;
204 case WINED3DFMT_R32_FLOAT
: return DXGI_FORMAT_R32_FLOAT
;
205 case WINED3DFMT_R32_UINT
: return DXGI_FORMAT_R32_UINT
;
206 case WINED3DFMT_R32_SINT
: return DXGI_FORMAT_R32_SINT
;
207 case WINED3DFMT_R24G8_TYPELESS
: return DXGI_FORMAT_R24G8_TYPELESS
;
208 case WINED3DFMT_D24_UNORM_S8_UINT
: return DXGI_FORMAT_D24_UNORM_S8_UINT
;
209 case WINED3DFMT_R24_UNORM_X8_TYPELESS
: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS
;
210 case WINED3DFMT_X24_TYPELESS_G8_UINT
: return DXGI_FORMAT_X24_TYPELESS_G8_UINT
;
211 case WINED3DFMT_R8G8_TYPELESS
: return DXGI_FORMAT_R8G8_TYPELESS
;
212 case WINED3DFMT_R8G8_UNORM
: return DXGI_FORMAT_R8G8_UNORM
;
213 case WINED3DFMT_R8G8_UINT
: return DXGI_FORMAT_R8G8_UINT
;
214 case WINED3DFMT_R8G8_SNORM
: return DXGI_FORMAT_R8G8_SNORM
;
215 case WINED3DFMT_R8G8_SINT
: return DXGI_FORMAT_R8G8_SINT
;
216 case WINED3DFMT_R16_TYPELESS
: return DXGI_FORMAT_R16_TYPELESS
;
217 case WINED3DFMT_R16_FLOAT
: return DXGI_FORMAT_R16_FLOAT
;
218 case WINED3DFMT_D16_UNORM
: return DXGI_FORMAT_D16_UNORM
;
219 case WINED3DFMT_R16_UNORM
: return DXGI_FORMAT_R16_UNORM
;
220 case WINED3DFMT_R16_UINT
: return DXGI_FORMAT_R16_UINT
;
221 case WINED3DFMT_R16_SNORM
: return DXGI_FORMAT_R16_SNORM
;
222 case WINED3DFMT_R16_SINT
: return DXGI_FORMAT_R16_SINT
;
223 case WINED3DFMT_R8_TYPELESS
: return DXGI_FORMAT_R8_TYPELESS
;
224 case WINED3DFMT_R8_UNORM
: return DXGI_FORMAT_R8_UNORM
;
225 case WINED3DFMT_R8_UINT
: return DXGI_FORMAT_R8_UINT
;
226 case WINED3DFMT_R8_SNORM
: return DXGI_FORMAT_R8_SNORM
;
227 case WINED3DFMT_R8_SINT
: return DXGI_FORMAT_R8_SINT
;
228 case WINED3DFMT_A8_UNORM
: return DXGI_FORMAT_A8_UNORM
;
229 case WINED3DFMT_R1_UNORM
: return DXGI_FORMAT_R1_UNORM
;
230 case WINED3DFMT_R9G9B9E5_SHAREDEXP
: return DXGI_FORMAT_R9G9B9E5_SHAREDEXP
;
231 case WINED3DFMT_R8G8_B8G8_UNORM
: return DXGI_FORMAT_R8G8_B8G8_UNORM
;
232 case WINED3DFMT_G8R8_G8B8_UNORM
: return DXGI_FORMAT_G8R8_G8B8_UNORM
;
233 case WINED3DFMT_BC1_TYPELESS
: return DXGI_FORMAT_BC1_TYPELESS
;
234 case WINED3DFMT_BC1_UNORM
: return DXGI_FORMAT_BC1_UNORM
;
235 case WINED3DFMT_BC1_UNORM_SRGB
: return DXGI_FORMAT_BC1_UNORM_SRGB
;
236 case WINED3DFMT_BC2_TYPELESS
: return DXGI_FORMAT_BC2_TYPELESS
;
237 case WINED3DFMT_BC2_UNORM
: return DXGI_FORMAT_BC2_UNORM
;
238 case WINED3DFMT_BC2_UNORM_SRGB
: return DXGI_FORMAT_BC2_UNORM_SRGB
;
239 case WINED3DFMT_BC3_TYPELESS
: return DXGI_FORMAT_BC3_TYPELESS
;
240 case WINED3DFMT_BC3_UNORM
: return DXGI_FORMAT_BC3_UNORM
;
241 case WINED3DFMT_BC3_UNORM_SRGB
: return DXGI_FORMAT_BC3_UNORM_SRGB
;
242 case WINED3DFMT_BC4_TYPELESS
: return DXGI_FORMAT_BC4_TYPELESS
;
243 case WINED3DFMT_BC4_UNORM
: return DXGI_FORMAT_BC4_UNORM
;
244 case WINED3DFMT_BC4_SNORM
: return DXGI_FORMAT_BC4_SNORM
;
245 case WINED3DFMT_BC5_TYPELESS
: return DXGI_FORMAT_BC5_TYPELESS
;
246 case WINED3DFMT_BC5_UNORM
: return DXGI_FORMAT_BC5_UNORM
;
247 case WINED3DFMT_BC5_SNORM
: return DXGI_FORMAT_BC5_SNORM
;
248 case WINED3DFMT_B5G6R5_UNORM
: return DXGI_FORMAT_B5G6R5_UNORM
;
249 case WINED3DFMT_B5G5R5A1_UNORM
: return DXGI_FORMAT_B5G5R5A1_UNORM
;
250 case WINED3DFMT_B8G8R8A8_UNORM
: return DXGI_FORMAT_B8G8R8A8_UNORM
;
251 case WINED3DFMT_B8G8R8X8_UNORM
: return DXGI_FORMAT_B8G8R8X8_UNORM
;
252 case WINED3DFMT_R10G10B10_XR_BIAS_A2_UNORM
: return DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
;
253 case WINED3DFMT_B8G8R8A8_TYPELESS
: return DXGI_FORMAT_B8G8R8A8_TYPELESS
;
254 case WINED3DFMT_B8G8R8A8_UNORM_SRGB
: return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
;
255 case WINED3DFMT_B8G8R8X8_TYPELESS
: return DXGI_FORMAT_B8G8R8X8_TYPELESS
;
256 case WINED3DFMT_B8G8R8X8_UNORM_SRGB
: return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
;
257 case WINED3DFMT_BC6H_TYPELESS
: return DXGI_FORMAT_BC6H_TYPELESS
;
258 case WINED3DFMT_BC6H_UF16
: return DXGI_FORMAT_BC6H_UF16
;
259 case WINED3DFMT_BC6H_SF16
: return DXGI_FORMAT_BC6H_SF16
;
260 case WINED3DFMT_BC7_TYPELESS
: return DXGI_FORMAT_BC7_TYPELESS
;
261 case WINED3DFMT_BC7_UNORM
: return DXGI_FORMAT_BC7_UNORM
;
262 case WINED3DFMT_BC7_UNORM_SRGB
: return DXGI_FORMAT_BC7_UNORM_SRGB
;
264 FIXME("Unhandled wined3d format %#x.\n", format
);
265 return DXGI_FORMAT_UNKNOWN
;
269 enum wined3d_format_id
wined3dformat_from_dxgi_format(DXGI_FORMAT format
)
273 case DXGI_FORMAT_UNKNOWN
: return WINED3DFMT_UNKNOWN
;
274 case DXGI_FORMAT_R32G32B32A32_TYPELESS
: return WINED3DFMT_R32G32B32A32_TYPELESS
;
275 case DXGI_FORMAT_R32G32B32A32_FLOAT
: return WINED3DFMT_R32G32B32A32_FLOAT
;
276 case DXGI_FORMAT_R32G32B32A32_UINT
: return WINED3DFMT_R32G32B32A32_UINT
;
277 case DXGI_FORMAT_R32G32B32A32_SINT
: return WINED3DFMT_R32G32B32A32_SINT
;
278 case DXGI_FORMAT_R32G32B32_TYPELESS
: return WINED3DFMT_R32G32B32_TYPELESS
;
279 case DXGI_FORMAT_R32G32B32_FLOAT
: return WINED3DFMT_R32G32B32_FLOAT
;
280 case DXGI_FORMAT_R32G32B32_UINT
: return WINED3DFMT_R32G32B32_UINT
;
281 case DXGI_FORMAT_R32G32B32_SINT
: return WINED3DFMT_R32G32B32_SINT
;
282 case DXGI_FORMAT_R16G16B16A16_TYPELESS
: return WINED3DFMT_R16G16B16A16_TYPELESS
;
283 case DXGI_FORMAT_R16G16B16A16_FLOAT
: return WINED3DFMT_R16G16B16A16_FLOAT
;
284 case DXGI_FORMAT_R16G16B16A16_UNORM
: return WINED3DFMT_R16G16B16A16_UNORM
;
285 case DXGI_FORMAT_R16G16B16A16_UINT
: return WINED3DFMT_R16G16B16A16_UINT
;
286 case DXGI_FORMAT_R16G16B16A16_SNORM
: return WINED3DFMT_R16G16B16A16_SNORM
;
287 case DXGI_FORMAT_R16G16B16A16_SINT
: return WINED3DFMT_R16G16B16A16_SINT
;
288 case DXGI_FORMAT_R32G32_TYPELESS
: return WINED3DFMT_R32G32_TYPELESS
;
289 case DXGI_FORMAT_R32G32_FLOAT
: return WINED3DFMT_R32G32_FLOAT
;
290 case DXGI_FORMAT_R32G32_UINT
: return WINED3DFMT_R32G32_UINT
;
291 case DXGI_FORMAT_R32G32_SINT
: return WINED3DFMT_R32G32_SINT
;
292 case DXGI_FORMAT_R32G8X24_TYPELESS
: return WINED3DFMT_R32G8X24_TYPELESS
;
293 case DXGI_FORMAT_D32_FLOAT_S8X24_UINT
: return WINED3DFMT_D32_FLOAT_S8X24_UINT
;
294 case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
: return WINED3DFMT_R32_FLOAT_X8X24_TYPELESS
;
295 case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
: return WINED3DFMT_X32_TYPELESS_G8X24_UINT
;
296 case DXGI_FORMAT_R10G10B10A2_TYPELESS
: return WINED3DFMT_R10G10B10A2_TYPELESS
;
297 case DXGI_FORMAT_R10G10B10A2_UNORM
: return WINED3DFMT_R10G10B10A2_UNORM
;
298 case DXGI_FORMAT_R10G10B10A2_UINT
: return WINED3DFMT_R10G10B10A2_UINT
;
299 case DXGI_FORMAT_R11G11B10_FLOAT
: return WINED3DFMT_R11G11B10_FLOAT
;
300 case DXGI_FORMAT_R8G8B8A8_TYPELESS
: return WINED3DFMT_R8G8B8A8_TYPELESS
;
301 case DXGI_FORMAT_R8G8B8A8_UNORM
: return WINED3DFMT_R8G8B8A8_UNORM
;
302 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
: return WINED3DFMT_R8G8B8A8_UNORM_SRGB
;
303 case DXGI_FORMAT_R8G8B8A8_UINT
: return WINED3DFMT_R8G8B8A8_UINT
;
304 case DXGI_FORMAT_R8G8B8A8_SNORM
: return WINED3DFMT_R8G8B8A8_SNORM
;
305 case DXGI_FORMAT_R8G8B8A8_SINT
: return WINED3DFMT_R8G8B8A8_SINT
;
306 case DXGI_FORMAT_R16G16_TYPELESS
: return WINED3DFMT_R16G16_TYPELESS
;
307 case DXGI_FORMAT_R16G16_FLOAT
: return WINED3DFMT_R16G16_FLOAT
;
308 case DXGI_FORMAT_R16G16_UNORM
: return WINED3DFMT_R16G16_UNORM
;
309 case DXGI_FORMAT_R16G16_UINT
: return WINED3DFMT_R16G16_UINT
;
310 case DXGI_FORMAT_R16G16_SNORM
: return WINED3DFMT_R16G16_SNORM
;
311 case DXGI_FORMAT_R16G16_SINT
: return WINED3DFMT_R16G16_SINT
;
312 case DXGI_FORMAT_R32_TYPELESS
: return WINED3DFMT_R32_TYPELESS
;
313 case DXGI_FORMAT_D32_FLOAT
: return WINED3DFMT_D32_FLOAT
;
314 case DXGI_FORMAT_R32_FLOAT
: return WINED3DFMT_R32_FLOAT
;
315 case DXGI_FORMAT_R32_UINT
: return WINED3DFMT_R32_UINT
;
316 case DXGI_FORMAT_R32_SINT
: return WINED3DFMT_R32_SINT
;
317 case DXGI_FORMAT_R24G8_TYPELESS
: return WINED3DFMT_R24G8_TYPELESS
;
318 case DXGI_FORMAT_D24_UNORM_S8_UINT
: return WINED3DFMT_D24_UNORM_S8_UINT
;
319 case DXGI_FORMAT_R24_UNORM_X8_TYPELESS
: return WINED3DFMT_R24_UNORM_X8_TYPELESS
;
320 case DXGI_FORMAT_X24_TYPELESS_G8_UINT
: return WINED3DFMT_X24_TYPELESS_G8_UINT
;
321 case DXGI_FORMAT_R8G8_TYPELESS
: return WINED3DFMT_R8G8_TYPELESS
;
322 case DXGI_FORMAT_R8G8_UNORM
: return WINED3DFMT_R8G8_UNORM
;
323 case DXGI_FORMAT_R8G8_UINT
: return WINED3DFMT_R8G8_UINT
;
324 case DXGI_FORMAT_R8G8_SNORM
: return WINED3DFMT_R8G8_SNORM
;
325 case DXGI_FORMAT_R8G8_SINT
: return WINED3DFMT_R8G8_SINT
;
326 case DXGI_FORMAT_R16_TYPELESS
: return WINED3DFMT_R16_TYPELESS
;
327 case DXGI_FORMAT_R16_FLOAT
: return WINED3DFMT_R16_FLOAT
;
328 case DXGI_FORMAT_D16_UNORM
: return WINED3DFMT_D16_UNORM
;
329 case DXGI_FORMAT_R16_UNORM
: return WINED3DFMT_R16_UNORM
;
330 case DXGI_FORMAT_R16_UINT
: return WINED3DFMT_R16_UINT
;
331 case DXGI_FORMAT_R16_SNORM
: return WINED3DFMT_R16_SNORM
;
332 case DXGI_FORMAT_R16_SINT
: return WINED3DFMT_R16_SINT
;
333 case DXGI_FORMAT_R8_TYPELESS
: return WINED3DFMT_R8_TYPELESS
;
334 case DXGI_FORMAT_R8_UNORM
: return WINED3DFMT_R8_UNORM
;
335 case DXGI_FORMAT_R8_UINT
: return WINED3DFMT_R8_UINT
;
336 case DXGI_FORMAT_R8_SNORM
: return WINED3DFMT_R8_SNORM
;
337 case DXGI_FORMAT_R8_SINT
: return WINED3DFMT_R8_SINT
;
338 case DXGI_FORMAT_A8_UNORM
: return WINED3DFMT_A8_UNORM
;
339 case DXGI_FORMAT_R1_UNORM
: return WINED3DFMT_R1_UNORM
;
340 case DXGI_FORMAT_R9G9B9E5_SHAREDEXP
: return WINED3DFMT_R9G9B9E5_SHAREDEXP
;
341 case DXGI_FORMAT_R8G8_B8G8_UNORM
: return WINED3DFMT_R8G8_B8G8_UNORM
;
342 case DXGI_FORMAT_G8R8_G8B8_UNORM
: return WINED3DFMT_G8R8_G8B8_UNORM
;
343 case DXGI_FORMAT_BC1_TYPELESS
: return WINED3DFMT_BC1_TYPELESS
;
344 case DXGI_FORMAT_BC1_UNORM
: return WINED3DFMT_BC1_UNORM
;
345 case DXGI_FORMAT_BC1_UNORM_SRGB
: return WINED3DFMT_BC1_UNORM_SRGB
;
346 case DXGI_FORMAT_BC2_TYPELESS
: return WINED3DFMT_BC2_TYPELESS
;
347 case DXGI_FORMAT_BC2_UNORM
: return WINED3DFMT_BC2_UNORM
;
348 case DXGI_FORMAT_BC2_UNORM_SRGB
: return WINED3DFMT_BC2_UNORM_SRGB
;
349 case DXGI_FORMAT_BC3_TYPELESS
: return WINED3DFMT_BC3_TYPELESS
;
350 case DXGI_FORMAT_BC3_UNORM
: return WINED3DFMT_BC3_UNORM
;
351 case DXGI_FORMAT_BC3_UNORM_SRGB
: return WINED3DFMT_BC3_UNORM_SRGB
;
352 case DXGI_FORMAT_BC4_TYPELESS
: return WINED3DFMT_BC4_TYPELESS
;
353 case DXGI_FORMAT_BC4_UNORM
: return WINED3DFMT_BC4_UNORM
;
354 case DXGI_FORMAT_BC4_SNORM
: return WINED3DFMT_BC4_SNORM
;
355 case DXGI_FORMAT_BC5_TYPELESS
: return WINED3DFMT_BC5_TYPELESS
;
356 case DXGI_FORMAT_BC5_UNORM
: return WINED3DFMT_BC5_UNORM
;
357 case DXGI_FORMAT_BC5_SNORM
: return WINED3DFMT_BC5_SNORM
;
358 case DXGI_FORMAT_B5G6R5_UNORM
: return WINED3DFMT_B5G6R5_UNORM
;
359 case DXGI_FORMAT_B5G5R5A1_UNORM
: return WINED3DFMT_B5G5R5A1_UNORM
;
360 case DXGI_FORMAT_B8G8R8A8_UNORM
: return WINED3DFMT_B8G8R8A8_UNORM
;
361 case DXGI_FORMAT_B8G8R8X8_UNORM
: return WINED3DFMT_B8G8R8X8_UNORM
;
362 case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
: return WINED3DFMT_R10G10B10_XR_BIAS_A2_UNORM
;
363 case DXGI_FORMAT_B8G8R8A8_TYPELESS
: return WINED3DFMT_B8G8R8A8_TYPELESS
;
364 case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
: return WINED3DFMT_B8G8R8A8_UNORM_SRGB
;
365 case DXGI_FORMAT_B8G8R8X8_TYPELESS
: return WINED3DFMT_B8G8R8X8_TYPELESS
;
366 case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
: return WINED3DFMT_B8G8R8X8_UNORM_SRGB
;
367 case DXGI_FORMAT_BC6H_TYPELESS
: return WINED3DFMT_BC6H_TYPELESS
;
368 case DXGI_FORMAT_BC6H_UF16
: return WINED3DFMT_BC6H_UF16
;
369 case DXGI_FORMAT_BC6H_SF16
: return WINED3DFMT_BC6H_SF16
;
370 case DXGI_FORMAT_BC7_TYPELESS
: return WINED3DFMT_BC7_TYPELESS
;
371 case DXGI_FORMAT_BC7_UNORM
: return WINED3DFMT_BC7_UNORM
;
372 case DXGI_FORMAT_BC7_UNORM_SRGB
: return WINED3DFMT_BC7_UNORM_SRGB
;
374 FIXME("Unhandled DXGI_FORMAT %#x.\n", format
);
375 return WINED3DFMT_UNKNOWN
;
379 const char *debug_dxgi_mode(const DXGI_MODE_DESC
*desc
)
381 return wine_dbg_sprintf("resolution %ux%u, refresh rate %u / %u, "
382 "format %s, scanline ordering %#x, scaling %#x",
383 desc
->Width
, desc
->Height
, desc
->RefreshRate
.Numerator
, desc
->RefreshRate
.Denominator
,
384 debug_dxgi_format(desc
->Format
), desc
->ScanlineOrdering
, desc
->Scaling
);
387 void dump_feature_levels(const D3D_FEATURE_LEVEL
*feature_levels
, unsigned int level_count
)
391 if (!feature_levels
|| !level_count
)
393 TRACE("Feature levels: (null).\n");
397 TRACE("Feature levels (count = %u):\n", level_count
);
398 for (i
= 0; i
< level_count
; ++i
)
399 TRACE(" [%u] = %s.\n", i
, debug_feature_level(feature_levels
[i
]));
402 UINT
dxgi_rational_to_uint(const DXGI_RATIONAL
*rational
)
404 if (rational
->Denominator
)
405 return rational
->Numerator
/ rational
->Denominator
;
407 return rational
->Numerator
;
410 static enum wined3d_scanline_ordering
wined3d_scanline_ordering_from_dxgi(DXGI_MODE_SCANLINE_ORDER scanline_order
)
412 switch (scanline_order
)
414 case DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
:
415 return WINED3D_SCANLINE_ORDERING_UNKNOWN
;
416 case DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE
:
417 return WINED3D_SCANLINE_ORDERING_PROGRESSIVE
;
419 FIXME("Unhandled scanline ordering %#x.\n", scanline_order
);
420 return WINED3D_SCANLINE_ORDERING_UNKNOWN
;
424 void dxgi_sample_desc_from_wined3d(DXGI_SAMPLE_DESC
*desc
,
425 enum wined3d_multisample_type wined3d_type
, unsigned int wined3d_quality
)
427 desc
->Count
= wined3d_type
== WINED3D_MULTISAMPLE_NONE
? 1 : wined3d_type
;
428 desc
->Quality
= wined3d_quality
;
431 void wined3d_sample_desc_from_dxgi(enum wined3d_multisample_type
*wined3d_type
,
432 unsigned int *wined3d_quality
, const DXGI_SAMPLE_DESC
*dxgi_desc
)
434 if (dxgi_desc
->Count
> 1)
436 *wined3d_type
= dxgi_desc
->Count
;
437 *wined3d_quality
= dxgi_desc
->Quality
;
441 *wined3d_type
= WINED3D_MULTISAMPLE_NONE
;
442 *wined3d_quality
= 0;
446 void wined3d_display_mode_from_dxgi(struct wined3d_display_mode
*wined3d_mode
,
447 const DXGI_MODE_DESC
*mode
)
449 wined3d_mode
->width
= mode
->Width
;
450 wined3d_mode
->height
= mode
->Height
;
451 wined3d_mode
->refresh_rate
= dxgi_rational_to_uint(&mode
->RefreshRate
);
452 wined3d_mode
->format_id
= wined3dformat_from_dxgi_format(mode
->Format
);
453 wined3d_mode
->scanline_ordering
= wined3d_scanline_ordering_from_dxgi(mode
->ScanlineOrdering
);
456 DXGI_USAGE
dxgi_usage_from_wined3d_usage(DWORD wined3d_usage
)
458 DXGI_USAGE dxgi_usage
= 0;
460 if (wined3d_usage
& WINED3DUSAGE_TEXTURE
)
461 dxgi_usage
|= DXGI_USAGE_SHADER_INPUT
;
462 if (wined3d_usage
& WINED3DUSAGE_RENDERTARGET
)
463 dxgi_usage
|= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
465 wined3d_usage
&= ~(WINED3DUSAGE_TEXTURE
| WINED3DUSAGE_RENDERTARGET
);
467 FIXME("Unhandled wined3d usage %#x.\n", wined3d_usage
);
471 DWORD
wined3d_usage_from_dxgi_usage(DXGI_USAGE dxgi_usage
)
473 DWORD wined3d_usage
= 0;
475 if (dxgi_usage
& DXGI_USAGE_SHADER_INPUT
)
476 wined3d_usage
|= WINED3DUSAGE_TEXTURE
;
477 if (dxgi_usage
& DXGI_USAGE_RENDER_TARGET_OUTPUT
)
478 wined3d_usage
|= WINED3DUSAGE_RENDERTARGET
;
480 dxgi_usage
&= ~(DXGI_USAGE_SHADER_INPUT
| DXGI_USAGE_RENDER_TARGET_OUTPUT
);
482 FIXME("Unhandled DXGI usage %#x.\n", dxgi_usage
);
483 return wined3d_usage
;
486 #define DXGI_WINED3D_SWAPCHAIN_FLAGS \
487 (WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE | WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT)
489 unsigned int dxgi_swapchain_flags_from_wined3d(unsigned int wined3d_flags
)
491 unsigned int flags
= 0;
493 wined3d_flags
&= ~DXGI_WINED3D_SWAPCHAIN_FLAGS
;
495 if (wined3d_flags
& WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH
)
497 wined3d_flags
&= ~WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH
;
498 flags
|= DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH
;
501 if (wined3d_flags
& WINED3D_SWAPCHAIN_GDI_COMPATIBLE
)
503 wined3d_flags
&= ~WINED3D_SWAPCHAIN_GDI_COMPATIBLE
;
504 flags
|= DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE
;
508 FIXME("Unhandled flags %#x.\n", flags
);
513 unsigned int wined3d_swapchain_flags_from_dxgi(unsigned int flags
)
515 unsigned int wined3d_flags
= DXGI_WINED3D_SWAPCHAIN_FLAGS
; /* WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL? */
517 if (flags
& DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH
)
519 flags
&= ~DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH
;
520 wined3d_flags
|= WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH
;
523 if (flags
& DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE
)
525 flags
&= ~DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE
;
526 wined3d_flags
|= WINED3D_SWAPCHAIN_GDI_COMPATIBLE
;
530 FIXME("Unhandled flags %#x.\n", flags
);
532 return wined3d_flags
;
535 HRESULT
dxgi_get_private_data(struct wined3d_private_store
*store
,
536 REFGUID guid
, UINT
*data_size
, void *data
)
538 const struct wined3d_private_data
*stored_data
;
545 wined3d_mutex_lock();
546 if (!(stored_data
= wined3d_private_store_get_private_data(store
, guid
)))
548 hr
= DXGI_ERROR_NOT_FOUND
;
553 size_in
= *data_size
;
554 *data_size
= stored_data
->size
;
560 if (size_in
< stored_data
->size
)
562 hr
= DXGI_ERROR_MORE_DATA
;
566 if (stored_data
->flags
& WINED3DSPD_IUNKNOWN
)
567 IUnknown_AddRef(stored_data
->content
.object
);
568 memcpy(data
, stored_data
->content
.data
, stored_data
->size
);
572 wined3d_mutex_unlock();
577 HRESULT
dxgi_set_private_data(struct wined3d_private_store
*store
,
578 REFGUID guid
, UINT data_size
, const void *data
)
580 struct wined3d_private_data
*entry
;
585 wined3d_mutex_lock();
586 if (!(entry
= wined3d_private_store_get_private_data(store
, guid
)))
588 wined3d_mutex_unlock();
592 wined3d_private_store_free_private_data(store
, entry
);
593 wined3d_mutex_unlock();
598 wined3d_mutex_lock();
599 hr
= wined3d_private_store_set_private_data(store
, guid
, data
, data_size
, 0);
600 wined3d_mutex_unlock();
605 HRESULT
dxgi_set_private_data_interface(struct wined3d_private_store
*store
,
606 REFGUID guid
, const IUnknown
*object
)
611 return dxgi_set_private_data(store
, guid
, sizeof(object
), &object
);
613 wined3d_mutex_lock();
614 hr
= wined3d_private_store_set_private_data(store
,
615 guid
, object
, sizeof(object
), WINED3DSPD_IUNKNOWN
);
616 wined3d_mutex_unlock();
621 D3D_FEATURE_LEVEL
dxgi_check_feature_level_support(struct dxgi_factory
*factory
, struct dxgi_adapter
*adapter
,
622 const D3D_FEATURE_LEVEL
*feature_levels
, unsigned int level_count
)
626 D3D_FEATURE_LEVEL feature_level
;
629 feature_levels_sm
[] =
631 {D3D_FEATURE_LEVEL_11_1
, 5},
632 {D3D_FEATURE_LEVEL_11_0
, 5},
633 {D3D_FEATURE_LEVEL_10_1
, 4},
634 {D3D_FEATURE_LEVEL_10_0
, 4},
635 {D3D_FEATURE_LEVEL_9_3
, 3},
636 {D3D_FEATURE_LEVEL_9_2
, 2},
637 {D3D_FEATURE_LEVEL_9_1
, 2},
639 D3D_FEATURE_LEVEL selected_feature_level
= 0;
640 unsigned int shader_model
;
645 FIXME("Ignoring adapter type.\n");
647 wined3d_mutex_lock();
648 hr
= wined3d_get_device_caps(factory
->wined3d
, adapter
->ordinal
, WINED3D_DEVICE_TYPE_HAL
, &caps
);
649 wined3d_mutex_unlock();
654 shader_model
= min(caps
.VertexShaderVersion
, caps
.PixelShaderVersion
);
655 for (i
= 0; i
< level_count
; ++i
)
657 for (j
= 0; j
< sizeof(feature_levels_sm
) / sizeof(feature_levels_sm
[0]); ++j
)
659 if (feature_levels
[i
] == feature_levels_sm
[j
].feature_level
)
661 if (shader_model
>= feature_levels_sm
[j
].sm
)
663 selected_feature_level
= feature_levels
[i
];
664 TRACE("Choosing supported feature level %s (SM%u).\n",
665 debug_feature_level(selected_feature_level
), feature_levels_sm
[j
].sm
);
670 if (selected_feature_level
)
673 if (j
== sizeof(feature_levels_sm
) / sizeof(feature_levels_sm
[0]))
674 FIXME("Unexpected feature level %#x.\n", feature_levels
[i
]);
676 TRACE("Feature level %s not supported, trying next fallback if available.\n",
677 debug_feature_level(feature_levels
[i
]));
679 if (!selected_feature_level
)
680 FIXME_(winediag
)("None of the requested D3D feature levels is supported on this GPU "
681 "with the current shader backend.\n");
683 return selected_feature_level
;