2 * Copyright 2002-2004 Jason Edmeades
3 * Copyright 2003-2004 Raphael Junqueira
4 * Copyright 2004 Christian Costa
5 * Copyright 2005 Oliver Stieber
6 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
7 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wined3d_private.h"
26 #include "wine/list.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
29 WINE_DECLARE_DEBUG_CHANNEL(winediag
);
31 #define DEFAULT_REFRESH_RATE 0
33 enum wined3d_driver_model
42 struct wined3d_adapter_budget_change_notification
44 const struct wined3d_adapter
*adapter
;
47 UINT64 last_local_budget
;
48 UINT64 last_non_local_budget
;
52 static struct list adapter_budget_change_notifications
= LIST_INIT( adapter_budget_change_notifications
);
53 static HANDLE notification_thread
, notification_thread_stop_event
;
55 /* The d3d device ID */
56 static const GUID IID_D3DDEVICE_D3DUID
= { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
58 /**********************************************************
59 * Utility functions follow
60 **********************************************************/
62 const struct min_lookup minMipLookup
[] =
64 /* NONE POINT LINEAR */
65 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
66 {{GL_NEAREST
, GL_NEAREST_MIPMAP_NEAREST
, GL_NEAREST_MIPMAP_LINEAR
}}, /* POINT*/
67 {{GL_LINEAR
, GL_LINEAR_MIPMAP_NEAREST
, GL_LINEAR_MIPMAP_LINEAR
}}, /* LINEAR */
70 const GLenum magLookup
[] =
72 /* NONE POINT LINEAR */
73 GL_NEAREST
, GL_NEAREST
, GL_LINEAR
,
76 void CDECL
wined3d_output_release_ownership(const struct wined3d_output
*output
)
78 D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc
= {0};
80 TRACE("output %p.\n", output
);
82 set_owner_desc
.hDevice
= output
->kmt_device
;
83 D3DKMTSetVidPnSourceOwner(&set_owner_desc
);
86 HRESULT CDECL
wined3d_output_take_ownership(const struct wined3d_output
*output
, BOOL exclusive
)
88 D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc
;
89 D3DKMT_VIDPNSOURCEOWNER_TYPE owner_type
;
92 TRACE("output %p, exclusive %#x.\n", output
, exclusive
);
94 owner_type
= exclusive
? D3DKMT_VIDPNSOURCEOWNER_EXCLUSIVE
: D3DKMT_VIDPNSOURCEOWNER_SHARED
;
95 set_owner_desc
.pType
= &owner_type
;
96 set_owner_desc
.pVidPnSourceId
= &output
->vidpn_source_id
;
97 set_owner_desc
.VidPnSourceCount
= 1;
98 set_owner_desc
.hDevice
= output
->kmt_device
;
99 status
= D3DKMTSetVidPnSourceOwner(&set_owner_desc
);
103 case STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE
:
104 return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
;
105 case STATUS_INVALID_PARAMETER
:
107 case STATUS_PROCEDURE_NOT_FOUND
:
108 return E_NOINTERFACE
;
112 FIXME("Unhandled error %#x.\n", status
);
117 static void wined3d_output_cleanup(const struct wined3d_output
*output
)
119 D3DKMT_DESTROYDEVICE destroy_device_desc
;
121 TRACE("output %p.\n", output
);
123 destroy_device_desc
.hDevice
= output
->kmt_device
;
124 D3DKMTDestroyDevice(&destroy_device_desc
);
127 static HRESULT
wined3d_output_init(struct wined3d_output
*output
, unsigned int ordinal
,
128 struct wined3d_adapter
*adapter
, const WCHAR
*device_name
)
130 D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME open_adapter_desc
;
131 D3DKMT_CREATEDEVICE create_device_desc
= {{0}};
132 D3DKMT_CLOSEADAPTER close_adapter_desc
;
134 TRACE("output %p, device_name %s.\n", output
, wine_dbgstr_w(device_name
));
136 lstrcpyW(open_adapter_desc
.DeviceName
, device_name
);
137 if (D3DKMTOpenAdapterFromGdiDisplayName(&open_adapter_desc
))
139 close_adapter_desc
.hAdapter
= open_adapter_desc
.hAdapter
;
140 D3DKMTCloseAdapter(&close_adapter_desc
);
142 create_device_desc
.u
.hAdapter
= adapter
->kmt_adapter
;
143 if (D3DKMTCreateDevice(&create_device_desc
))
146 output
->ordinal
= ordinal
;
147 lstrcpyW(output
->device_name
, device_name
);
148 output
->adapter
= adapter
;
149 output
->screen_format
= WINED3DFMT_UNKNOWN
;
150 output
->kmt_device
= create_device_desc
.hDevice
;
151 output
->vidpn_source_id
= open_adapter_desc
.VidPnSourceId
;
156 /* Adjust the amount of used texture memory */
157 UINT64
adapter_adjust_memory(struct wined3d_adapter
*adapter
, INT64 amount
)
159 adapter
->vram_bytes_used
+= amount
;
160 TRACE("Adjusted used adapter memory by 0x%s to 0x%s.\n",
161 wine_dbgstr_longlong(amount
),
162 wine_dbgstr_longlong(adapter
->vram_bytes_used
));
163 return adapter
->vram_bytes_used
;
166 ssize_t
adapter_adjust_mapped_memory(struct wined3d_adapter
*adapter
, ssize_t size
)
168 /* Note that this needs to be thread-safe; the Vulkan adapter may map from
170 ssize_t ret
= InterlockedExchangeAddSizeT(&adapter
->mapped_size
, size
) + size
;
171 TRACE("Adjusted mapped adapter memory by %Id to %Id.\n", size
, ret
);
175 void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
)
177 D3DKMT_CLOSEADAPTER close_adapter_desc
;
178 unsigned int output_idx
;
180 for (output_idx
= 0; output_idx
< adapter
->output_count
; ++output_idx
)
181 wined3d_output_cleanup(&adapter
->outputs
[output_idx
]);
182 heap_free(adapter
->outputs
);
183 heap_free(adapter
->formats
);
184 close_adapter_desc
.hAdapter
= adapter
->kmt_adapter
;
185 D3DKMTCloseAdapter(&close_adapter_desc
);
188 ULONG CDECL
wined3d_incref(struct wined3d
*wined3d
)
190 ULONG refcount
= InterlockedIncrement(&wined3d
->ref
);
192 TRACE("%p increasing refcount to %u.\n", wined3d
, refcount
);
197 ULONG CDECL
wined3d_decref(struct wined3d
*wined3d
)
199 ULONG refcount
= InterlockedDecrement(&wined3d
->ref
);
201 TRACE("%p decreasing refcount to %u.\n", wined3d
, refcount
);
207 wined3d_mutex_lock();
208 for (i
= 0; i
< wined3d
->adapter_count
; ++i
)
210 struct wined3d_adapter
*adapter
= wined3d
->adapters
[i
];
212 adapter
->adapter_ops
->adapter_destroy(adapter
);
215 wined3d_mutex_unlock();
221 /* Certain applications (e.g. Steam) complain if we report an outdated driver
224 * The driver version has the form "x.y.z.w".
226 * "x" is the Windows version / driver model the driver is meant for:
230 * 7 -> Vista - WDDM 1.0
231 * 8 -> Windows 7 - WDDM 1.1
232 * 9 -> Windows 8 - WDDM 1.2
233 * 10 -> Windows 8.1 - WDDM 1.3
234 * 20 -> Windows 10 - WDDM 2.0
235 * 21 -> Windows 10 Anniversary Update - WDDM 2.1
236 * 22 -> Windows 10 Creators Update - WDDM 2.2
237 * 23 -> Windows 10 Fall Creators Update - WDDM 2.3
238 * 24 -> Windows 10 April 2018 Update - WDDM 2.4
239 * 25 -> Windows 10 October 2018 Update - WDDM 2.5
240 * 26 -> Windows 10 May 2019 Update - WDDM 2.6
242 * "y" is the maximum Direct3D version / feature level the driver supports.
255 * "z" is the subversion number.
257 * "w" is the vendor specific driver build number.
259 * In practice the reported version is tied to the driver, not the actual
260 * Windows version or feature level. E.g. NVIDIA driver 445.87 advertises the
261 * exact same version 26.21.14.4587 on Windows 7 as it does on Windows 10
262 * (it's in fact the same driver). Similarly for driver 310.90 that advertises
263 * itself as 9.18.13.1090 on Windows Vista with a GeForce 9600M. */
265 struct driver_version_information
267 enum wined3d_display_driver driver
;
268 enum wined3d_driver_model driver_model
;
269 const char *driver_name
; /* name of Windows driver */
270 WORD subversion
; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
271 WORD build
; /* build number ('w'), contained in low word of DriverVersion.LowPart */
274 /* The driver version table contains driver information for different devices on several OS versions. */
275 static const struct driver_version_information driver_version_table
[] =
278 * - Radeon HD2x00 (R600) and up supported by current drivers.
279 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
280 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
281 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
282 {DRIVER_AMD_RAGE_128PRO
, DRIVER_MODEL_NT5X
, "ati2dvaa.dll", 3279, 0},
283 {DRIVER_AMD_R100
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 10, 6614},
284 {DRIVER_AMD_R300
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 10, 6764},
285 {DRIVER_AMD_R600
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 10, 1280},
286 {DRIVER_AMD_R300
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 10, 741 },
287 {DRIVER_AMD_R600
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 10, 1280},
288 {DRIVER_AMD_RX
, DRIVER_MODEL_NT6X
, "aticfx32.dll", 15002, 61},
291 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
292 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
293 * igxprd32.dll but the GMA800 driver was never updated. */
294 {DRIVER_INTEL_GMA800
, DRIVER_MODEL_NT5X
, "ialmrnt5.dll", 10, 3889},
295 {DRIVER_INTEL_GMA900
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 10, 4764},
296 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 10, 4926},
297 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 10, 5218},
298 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 10, 1504},
299 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 10, 1666},
300 {DRIVER_INTEL_HD4000
, DRIVER_MODEL_NT6X
, "igdumdim32.dll", 15, 4352},
303 * - Geforce8 and newer is supported by the current 340.52 driver on XP-Win8
304 * - Geforce6 and 7 support is up to 307.83 on XP-Win8
305 * - GeforceFX support is up to 173.x on <= XP
306 * - Geforce2MX/3/4 up to 96.x on <= XP
307 * - TNT/Geforce1/2 up to 71.x on <= XP
308 * All version numbers used below are from the Linux nvidia drivers. */
309 {DRIVER_NVIDIA_TNT
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 10, 7186},
310 {DRIVER_NVIDIA_GEFORCE2MX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 10, 9371},
311 {DRIVER_NVIDIA_GEFORCEFX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 11, 7516},
312 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 13, 783},
313 {DRIVER_NVIDIA_GEFORCE8
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 13, 4052},
314 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 13, 783},
315 {DRIVER_NVIDIA_GEFORCE8
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 13, 4052},
316 {DRIVER_NVIDIA_FERMI
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 13, 9135},
317 {DRIVER_NVIDIA_KEPLER
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 14, 4587},
320 {DRIVER_REDHAT_VIRGL
, DRIVER_MODEL_GENERIC
, "virgl.dll", 0, 0},
323 {DRIVER_VMWARE
, DRIVER_MODEL_NT5X
, "vm3dum.dll", 1, 1134},
326 {DRIVER_WINE
, DRIVER_MODEL_GENERIC
, "wined3d.dll", 0, 0},
329 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
330 * found on a board containing a specific GPU. */
331 static const struct wined3d_gpu_description gpu_description_table
[] =
334 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_128
, "NVIDIA RIVA 128", DRIVER_NVIDIA_TNT
, 4 },
335 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT
, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT
, 16 },
336 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT2
, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT
, 32 },
337 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE
, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT
, 32 },
338 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2
, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT
, 32 },
339 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2_MX
, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX
,32 },
340 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE3
, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX
,64 },
341 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_MX
, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX
,64 },
342 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_TI4200
, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX
,64, },
343 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5200
, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX
, 64 },
344 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5600
, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX
, 128 },
345 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5800
, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX
, 256 },
346 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6200
, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6
, 64 },
347 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6600GT
, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6
, 128 },
348 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6800
, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6
, 128 },
349 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7300
, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6
, 256 },
350 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7400
, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6
, 256 },
351 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7600
, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
352 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7800GT
, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
353 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8200
, "NVIDIA GeForce 8200", DRIVER_NVIDIA_GEFORCE8
, 512 },
354 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8300GS
, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE8
, 128 },
355 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8400GS
, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE8
, 128 },
356 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8500GT
, "NVIDIA GeForce 8500 GT", DRIVER_NVIDIA_GEFORCE8
, 256 },
357 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600GT
, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE8
, 256 },
358 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600MGT
, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE8
, 512 },
359 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTS
, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE8
, 320 },
360 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTX
, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE8
, 768 },
361 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9200
, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE8
, 256 },
362 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9300
, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE8
, 256 },
363 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400M
, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE8
, 256 },
364 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400GT
, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE8
, 256 },
365 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9500GT
, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE8
, 256 },
366 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9600GT
, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE8
, 512 },
367 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9700MGT
, "NVIDIA GeForce 9700M GT", DRIVER_NVIDIA_GEFORCE8
, 512 },
368 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9800GT
, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE8
, 512 },
369 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_210
, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE8
, 512 },
370 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT220
, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE8
, 512 },
371 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT240
, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE8
, 512 },
372 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS250
, "NVIDIA GeForce GTS 250", DRIVER_NVIDIA_GEFORCE8
, 1024},
373 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX260
, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE8
, 1024},
374 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX275
, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE8
, 896 },
375 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX280
, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE8
, 1024},
376 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_315M
, "NVIDIA GeForce 315M", DRIVER_NVIDIA_GEFORCE8
, 512 },
377 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_320M
, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE8
, 256},
378 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT320M
, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE8
, 1024},
379 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT325M
, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE8
, 1024},
380 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT330
, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE8
, 1024},
381 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS350M
, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE8
, 1024},
382 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_410M
, "NVIDIA GeForce 410M", DRIVER_NVIDIA_FERMI
, 512},
383 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT420
, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_FERMI
, 2048},
384 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT425M
, "NVIDIA GeForce GT 425M", DRIVER_NVIDIA_FERMI
, 1024},
385 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT430
, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_FERMI
, 1024},
386 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT440
, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_FERMI
, 1024},
387 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS450
, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_FERMI
, 1024},
388 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460
, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_FERMI
, 768 },
389 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460M
, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_FERMI
, 1536},
390 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX465
, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_FERMI
, 1024},
391 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX470
, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_FERMI
, 1280},
392 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX480
, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_FERMI
, 1536},
393 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT520
, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_FERMI
, 1024},
394 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT525M
, "NVIDIA GeForce GT 525M", DRIVER_NVIDIA_FERMI
, 1024},
395 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT540M
, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_FERMI
, 1024},
396 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX550
, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_FERMI
, 1024},
397 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT555M
, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_FERMI
, 1024},
398 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560TI
, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_FERMI
, 1024},
399 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560M
, "NVIDIA GeForce GTX 560M", DRIVER_NVIDIA_FERMI
, 3072},
400 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560
, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_FERMI
, 1024},
401 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX570
, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_FERMI
, 1280},
402 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX580
, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_FERMI
, 1536},
403 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT610
, "NVIDIA GeForce GT 610", DRIVER_NVIDIA_FERMI
, 1024},
404 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT630
, "NVIDIA GeForce GT 630", DRIVER_NVIDIA_KEPLER
, 1024},
405 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT630M
, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_FERMI
, 1024},
406 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT640
, "NVIDIA GeForce GT 640", DRIVER_NVIDIA_KEPLER
, 1024},
407 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT640M
, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_KEPLER
, 1024},
408 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT650M
, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_KEPLER
, 2048},
409 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX650
, "NVIDIA GeForce GTX 650", DRIVER_NVIDIA_KEPLER
, 1024},
410 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX650TI
, "NVIDIA GeForce GTX 650 Ti", DRIVER_NVIDIA_KEPLER
, 1024},
411 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX660
, "NVIDIA GeForce GTX 660", DRIVER_NVIDIA_KEPLER
, 2048},
412 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX660M
, "NVIDIA GeForce GTX 660M", DRIVER_NVIDIA_KEPLER
, 2048},
413 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX660TI
, "NVIDIA GeForce GTX 660 Ti", DRIVER_NVIDIA_KEPLER
, 2048},
414 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX670
, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_KEPLER
, 2048},
415 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX670MX
, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_KEPLER
, 3072},
416 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX675MX_1
, "NVIDIA GeForce GTX 675MX", DRIVER_NVIDIA_KEPLER
, 4096},
417 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX675MX_2
, "NVIDIA GeForce GTX 675MX", DRIVER_NVIDIA_KEPLER
, 2048},
418 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX680
, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_KEPLER
, 2048},
419 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX690
, "NVIDIA GeForce GTX 690", DRIVER_NVIDIA_KEPLER
, 2048},
420 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT720
, "NVIDIA GeForce GT 720", DRIVER_NVIDIA_KEPLER
, 2048},
421 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT730
, "NVIDIA GeForce GT 730", DRIVER_NVIDIA_KEPLER
, 2048},
422 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT730M
, "NVIDIA GeForce GT 730M", DRIVER_NVIDIA_KEPLER
, 1024},
423 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT740M
, "NVIDIA GeForce GT 740M", DRIVER_NVIDIA_KEPLER
, 2048},
424 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT750M
, "NVIDIA GeForce GT 750M", DRIVER_NVIDIA_KEPLER
, 1024},
425 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT755M
, "NVIDIA GeForce GT 755M", DRIVER_NVIDIA_KEPLER
, 1024},
426 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX750
, "NVIDIA GeForce GTX 750", DRIVER_NVIDIA_KEPLER
, 1024},
427 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX750TI
, "NVIDIA GeForce GTX 750 Ti", DRIVER_NVIDIA_KEPLER
, 2048},
428 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX760
, "NVIDIA GeForce GTX 760", DRIVER_NVIDIA_KEPLER
, 2048},
429 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX760TI
, "NVIDIA GeForce GTX 760 Ti", DRIVER_NVIDIA_KEPLER
, 2048},
430 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX765M
, "NVIDIA GeForce GTX 765M", DRIVER_NVIDIA_KEPLER
, 2048},
431 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX770M
, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_KEPLER
, 3072},
432 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX770
, "NVIDIA GeForce GTX 770", DRIVER_NVIDIA_KEPLER
, 2048},
433 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX775M
, "NVIDIA GeForce GTX 775M", DRIVER_NVIDIA_KEPLER
, 3072},
434 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX780
, "NVIDIA GeForce GTX 780", DRIVER_NVIDIA_KEPLER
, 3072},
435 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX780M
, "NVIDIA GeForce GTX 780M", DRIVER_NVIDIA_KEPLER
, 4096},
436 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX780TI
, "NVIDIA GeForce GTX 780 Ti", DRIVER_NVIDIA_KEPLER
, 3072},
437 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTXTITAN
, "NVIDIA GeForce GTX TITAN", DRIVER_NVIDIA_KEPLER
, 6144},
438 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTXTITANB
, "NVIDIA GeForce GTX TITAN Black", DRIVER_NVIDIA_KEPLER
, 6144},
439 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTXTITANX
, "NVIDIA GeForce GTX TITAN X", DRIVER_NVIDIA_KEPLER
, 12288},
440 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTXTITANZ
, "NVIDIA GeForce GTX TITAN Z", DRIVER_NVIDIA_KEPLER
, 12288},
441 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_820M
, "NVIDIA GeForce 820M", DRIVER_NVIDIA_FERMI
, 2048},
442 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_830M
, "NVIDIA GeForce 830M", DRIVER_NVIDIA_KEPLER
, 2048},
443 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_840M
, "NVIDIA GeForce 840M", DRIVER_NVIDIA_KEPLER
, 2048},
444 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_845M
, "NVIDIA GeForce 845M", DRIVER_NVIDIA_KEPLER
, 2048},
445 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX850M
, "NVIDIA GeForce GTX 850M", DRIVER_NVIDIA_KEPLER
, 2048},
446 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX860M
, "NVIDIA GeForce GTX 860M", DRIVER_NVIDIA_KEPLER
, 2048},
447 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX870M
, "NVIDIA GeForce GTX 870M", DRIVER_NVIDIA_KEPLER
, 3072},
448 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX880M
, "NVIDIA GeForce GTX 880M", DRIVER_NVIDIA_KEPLER
, 4096},
449 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_940M
, "NVIDIA GeForce 940M", DRIVER_NVIDIA_KEPLER
, 4096},
450 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX950
, "NVIDIA GeForce GTX 950", DRIVER_NVIDIA_KEPLER
, 2048},
451 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX950M
, "NVIDIA GeForce GTX 950M", DRIVER_NVIDIA_KEPLER
, 4096},
452 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX960
, "NVIDIA GeForce GTX 960", DRIVER_NVIDIA_KEPLER
, 4096},
453 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX960M
, "NVIDIA GeForce GTX 960M", DRIVER_NVIDIA_KEPLER
, 2048},
454 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX970
, "NVIDIA GeForce GTX 970", DRIVER_NVIDIA_KEPLER
, 4096},
455 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX970M
, "NVIDIA GeForce GTX 970M", DRIVER_NVIDIA_KEPLER
, 3072},
456 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX980
, "NVIDIA GeForce GTX 980", DRIVER_NVIDIA_KEPLER
, 4096},
457 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX980TI
, "NVIDIA GeForce GTX 980 Ti", DRIVER_NVIDIA_KEPLER
, 6144},
458 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT1030
, "NVIDIA GeForce GT 1030", DRIVER_NVIDIA_KEPLER
, 2048},
459 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1050
, "NVIDIA GeForce GTX 1050", DRIVER_NVIDIA_KEPLER
, 2048},
460 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1050TI
, "NVIDIA GeForce GTX 1050 Ti", DRIVER_NVIDIA_KEPLER
, 4096},
461 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1060_3GB
,"NVIDIA GeForce GTX 1060 3GB", DRIVER_NVIDIA_KEPLER
, 3072},
462 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1060
, "NVIDIA GeForce GTX 1060", DRIVER_NVIDIA_KEPLER
, 6144},
463 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1060M
, "NVIDIA GeForce GTX 1060M", DRIVER_NVIDIA_KEPLER
, 6144},
464 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1070
, "NVIDIA GeForce GTX 1070", DRIVER_NVIDIA_KEPLER
, 8192},
465 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1080
, "NVIDIA GeForce GTX 1080", DRIVER_NVIDIA_KEPLER
, 8192},
466 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1080M
, "NVIDIA GeForce GTX 1080M", DRIVER_NVIDIA_KEPLER
, 8192},
467 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1080TI
, "NVIDIA GeForce GTX 1080 Ti", DRIVER_NVIDIA_KEPLER
, 11264},
468 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_TITANX_PASCAL
, "NVIDIA TITAN X (Pascal)", DRIVER_NVIDIA_KEPLER
, 12288},
469 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_TITANV
, "NVIDIA TITAN V", DRIVER_NVIDIA_KEPLER
, 12288},
470 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1650SUPER
,"NVIDIA GeForce GTX 1650 SUPER", DRIVER_NVIDIA_KEPLER
, 4096},
471 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1660SUPER
,"NVIDIA GeForce GTX 1660 SUPER", DRIVER_NVIDIA_KEPLER
, 6144},
472 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX1660TI
, "NVIDIA GeForce GTX 1660 Ti", DRIVER_NVIDIA_KEPLER
, 6144},
473 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_RTX2060
, "NVIDIA GeForce RTX 2060", DRIVER_NVIDIA_KEPLER
, 6144},
474 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_RTX2070
, "NVIDIA GeForce RTX 2070", DRIVER_NVIDIA_KEPLER
, 8192},
475 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_RTX2080
, "NVIDIA GeForce RTX 2080", DRIVER_NVIDIA_KEPLER
, 8192},
476 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_RTX2080TI
, "NVIDIA GeForce RTX 2080 Ti", DRIVER_NVIDIA_KEPLER
, 11264},
477 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_TESLA_T4
, "NVIDIA Tesla T4", DRIVER_NVIDIA_KEPLER
, 16384},
478 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_AMPERE_A10
, "NVIDIA Ampere A10", DRIVER_NVIDIA_KEPLER
, 24576},
481 {HW_VENDOR_AMD
, CARD_AMD_RAGE_128PRO
, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO
, 16 },
482 {HW_VENDOR_AMD
, CARD_AMD_RADEON_7200
, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100
, 32 },
483 {HW_VENDOR_AMD
, CARD_AMD_RADEON_8500
, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100
, 64 },
484 {HW_VENDOR_AMD
, CARD_AMD_RADEON_9500
, "ATI Radeon 9500", DRIVER_AMD_R300
, 64 },
485 {HW_VENDOR_AMD
, CARD_AMD_RADEON_XPRESS_200M
, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300
, 64 },
486 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X700
, "ATI Radeon X700 SE", DRIVER_AMD_R300
, 128 },
487 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X1600
, "ATI Radeon X1600 Series", DRIVER_AMD_R300
, 128 },
488 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2350
, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600
, 256 },
489 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2600
, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600
, 256 },
490 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2900
, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600
, 512 },
491 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD3200
, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600
, 128 },
492 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD3850
, "ATI Radeon HD 3850 AGP", DRIVER_AMD_R600
, 512 },
493 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4200M
, "ATI Mobility Radeon HD 4200", DRIVER_AMD_R600
, 256 },
494 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4350
, "ATI Radeon HD 4350", DRIVER_AMD_R600
, 256 },
495 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4600
, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600
, 512 },
496 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4700
, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600
, 512 },
497 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4800
, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600
, 512 },
498 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5400
, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600
, 512 },
499 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5600
, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600
, 512 },
500 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5700
, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600
, 512 },
501 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5800
, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600
, 1024},
502 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5900
, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600
, 1024},
503 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6300
, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600
, 1024},
504 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6400
, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600
, 1024},
505 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6410D
, "AMD Radeon HD 6410D", DRIVER_AMD_R600
, 1024},
506 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6480G
, "AMD Radeon HD 6480G", DRIVER_AMD_R600
, 512 },
507 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6490M
, "AMD Radeon HD 6490M", DRIVER_AMD_R600
, 1024},
508 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6550D
, "AMD Radeon HD 6550D", DRIVER_AMD_R600
, 1024},
509 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600
, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600
, 1024},
510 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600M
, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600
, 512 },
511 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6700
, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600
, 1024},
512 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6800
, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600
, 1024},
513 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6900
, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600
, 2048},
514 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD7660D
, "AMD Radeon HD 7660D", DRIVER_AMD_R600
, 2048},
515 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD7700
, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600
, 1024},
516 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD7800
, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600
, 2048},
517 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD7870
, "AMD Radeon HD 7870 Series", DRIVER_AMD_R600
, 2048},
518 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD7900
, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600
, 2048},
519 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD8600M
, "AMD Radeon HD 8600M Series", DRIVER_AMD_R600
, 1024},
520 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD8670
, "AMD Radeon HD 8670", DRIVER_AMD_R600
, 2048},
521 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD8770
, "AMD Radeon HD 8770", DRIVER_AMD_R600
, 2048},
522 {HW_VENDOR_AMD
, CARD_AMD_RADEON_R3
, "AMD Radeon HD 8400 / R3 Series", DRIVER_AMD_R600
, 2048},
523 {HW_VENDOR_AMD
, CARD_AMD_RADEON_R7
, "AMD Radeon(TM) R7 Graphics", DRIVER_AMD_R600
, 2048},
524 {HW_VENDOR_AMD
, CARD_AMD_RADEON_R9_285
, "AMD Radeon R9 285", DRIVER_AMD_RX
, 2048},
525 {HW_VENDOR_AMD
, CARD_AMD_RADEON_R9_290
, "AMD Radeon R9 290", DRIVER_AMD_RX
, 4096},
526 {HW_VENDOR_AMD
, CARD_AMD_RADEON_R9_290X
, "AMD Radeon R9 290X", DRIVER_AMD_RX
, 4096},
527 {HW_VENDOR_AMD
, CARD_AMD_RADEON_R9_FURY
, "AMD Radeon (TM) R9 Fury Series", DRIVER_AMD_RX
, 4096},
528 {HW_VENDOR_AMD
, CARD_AMD_RADEON_R9_M370X
, "AMD Radeon R9 M370X", DRIVER_AMD_RX
, 2048},
529 {HW_VENDOR_AMD
, CARD_AMD_RADEON_R9_M380
, "AMD Radeon R9 M380", DRIVER_AMD_RX
, 2048},
530 {HW_VENDOR_AMD
, CARD_AMD_RADEON_R9_M395X
, "AMD Radeon R9 M395X", DRIVER_AMD_RX
, 4096},
531 {HW_VENDOR_AMD
, CARD_AMD_RADEON_RX_460
, "Radeon(TM) RX 460 Graphics", DRIVER_AMD_RX
, 4096},
532 {HW_VENDOR_AMD
, CARD_AMD_RADEON_RX_480
, "Radeon (TM) RX 480 Graphics", DRIVER_AMD_RX
, 4096},
533 {HW_VENDOR_AMD
, CARD_AMD_RADEON_RX_VEGA_10
, "Radeon RX Vega", DRIVER_AMD_RX
, 8192},
534 {HW_VENDOR_AMD
, CARD_AMD_RADEON_RX_VEGA_12
, "Radeon Pro Vega 20", DRIVER_AMD_RX
, 4096},
535 {HW_VENDOR_AMD
, CARD_AMD_RADEON_RAVEN
, "AMD Radeon(TM) Vega 10 Mobile Graphics", DRIVER_AMD_RX
, 1024},
536 {HW_VENDOR_AMD
, CARD_AMD_RADEON_RX_VEGA_20
, "Radeon RX Vega 20", DRIVER_AMD_RX
, 4096},
537 {HW_VENDOR_AMD
, CARD_AMD_RADEON_RX_NAVI_10
, "Radeon RX 5700 / 5700 XT", DRIVER_AMD_RX
, 8192},
538 {HW_VENDOR_AMD
, CARD_AMD_RADEON_RX_NAVI_14
, "Radeon RX 5500M", DRIVER_AMD_RX
, 4096},
539 {HW_VENDOR_AMD
, CARD_AMD_RADEON_RX_NAVI_21
, "Radeon RX 6800/6800 XT / 6900 XT", DRIVER_AMD_RX
, 16384},
540 {HW_VENDOR_AMD
, CARD_AMD_RADEON_PRO_V620
, "Radeon Pro V620", DRIVER_AMD_RX
, 32768},
541 {HW_VENDOR_AMD
, CARD_AMD_RADEON_PRO_V620_VF
, "Radeon Pro V620 VF", DRIVER_AMD_RX
, 32768},
542 {HW_VENDOR_AMD
, CARD_AMD_VANGOGH
, "AMD VANGOGH", DRIVER_AMD_RX
, 4096},
545 {HW_VENDOR_REDHAT
, CARD_REDHAT_VIRGL
, "Red Hat VirtIO GPU", DRIVER_REDHAT_VIRGL
, 1024},
548 {HW_VENDOR_VMWARE
, CARD_VMWARE_SVGA3D
, "VMware SVGA 3D (Microsoft Corporation - WDDM)", DRIVER_VMWARE
, 1024},
551 {HW_VENDOR_INTEL
, CARD_INTEL_830M
, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
552 {HW_VENDOR_INTEL
, CARD_INTEL_855GM
, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
553 {HW_VENDOR_INTEL
, CARD_INTEL_845G
, "Intel(R) 845G", DRIVER_INTEL_GMA800
, 32 },
554 {HW_VENDOR_INTEL
, CARD_INTEL_865G
, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
555 {HW_VENDOR_INTEL
, CARD_INTEL_915G
, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
556 {HW_VENDOR_INTEL
, CARD_INTEL_E7221G
, "Intel(R) E7221G", DRIVER_INTEL_GMA900
, 64 },
557 {HW_VENDOR_INTEL
, CARD_INTEL_915GM
, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
558 {HW_VENDOR_INTEL
, CARD_INTEL_945G
, "Intel(R) 945G", DRIVER_INTEL_GMA950
, 64 },
559 {HW_VENDOR_INTEL
, CARD_INTEL_945GM
, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950
, 64 },
560 {HW_VENDOR_INTEL
, CARD_INTEL_945GME
, "Intel(R) 945GME", DRIVER_INTEL_GMA950
, 64 },
561 {HW_VENDOR_INTEL
, CARD_INTEL_Q35
, "Intel(R) Q35", DRIVER_INTEL_GMA950
, 64 },
562 {HW_VENDOR_INTEL
, CARD_INTEL_G33
, "Intel(R) G33", DRIVER_INTEL_GMA950
, 64 },
563 {HW_VENDOR_INTEL
, CARD_INTEL_Q33
, "Intel(R) Q33", DRIVER_INTEL_GMA950
, 64 },
564 {HW_VENDOR_INTEL
, CARD_INTEL_PNVG
, "Intel(R) IGD", DRIVER_INTEL_GMA950
, 64 },
565 {HW_VENDOR_INTEL
, CARD_INTEL_PNVM
, "Intel(R) IGD", DRIVER_INTEL_GMA950
, 64 },
566 {HW_VENDOR_INTEL
, CARD_INTEL_965Q
, "Intel(R) 965Q", DRIVER_INTEL_GMA3000
, 128},
567 {HW_VENDOR_INTEL
, CARD_INTEL_965G
, "Intel(R) 965G", DRIVER_INTEL_GMA3000
, 128},
568 {HW_VENDOR_INTEL
, CARD_INTEL_946GZ
, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000
, 128},
569 {HW_VENDOR_INTEL
, CARD_INTEL_965GM
, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000
, 128},
570 {HW_VENDOR_INTEL
, CARD_INTEL_965GME
, "Intel(R) 965GME", DRIVER_INTEL_GMA3000
, 128},
571 {HW_VENDOR_INTEL
, CARD_INTEL_GM45
, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000
, 512},
572 {HW_VENDOR_INTEL
, CARD_INTEL_IGD
, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000
, 512},
573 {HW_VENDOR_INTEL
, CARD_INTEL_G45
, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000
, 512},
574 {HW_VENDOR_INTEL
, CARD_INTEL_Q45
, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000
, 512},
575 {HW_VENDOR_INTEL
, CARD_INTEL_G41
, "Intel(R) G41", DRIVER_INTEL_GMA3000
, 512},
576 {HW_VENDOR_INTEL
, CARD_INTEL_B43
, "Intel(R) B43", DRIVER_INTEL_GMA3000
, 512},
577 {HW_VENDOR_INTEL
, CARD_INTEL_ILKD
, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000
, 1536},
578 {HW_VENDOR_INTEL
, CARD_INTEL_ILKM
, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000
, 1536},
579 {HW_VENDOR_INTEL
, CARD_INTEL_SNBD
, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000
, 1536},
580 {HW_VENDOR_INTEL
, CARD_INTEL_SNBM
, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000
, 1536},
581 {HW_VENDOR_INTEL
, CARD_INTEL_SNBS
, "Intel(R) HD Graphics Family", DRIVER_INTEL_GMA3000
, 1536},
582 {HW_VENDOR_INTEL
, CARD_INTEL_IVBD
, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000
, 1536},
583 {HW_VENDOR_INTEL
, CARD_INTEL_IVBM
, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000
, 1536},
584 {HW_VENDOR_INTEL
, CARD_INTEL_IVBS
, "Intel(R) HD Graphics Family", DRIVER_INTEL_HD4000
, 1536},
585 {HW_VENDOR_INTEL
, CARD_INTEL_HWD
, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000
, 1536},
586 {HW_VENDOR_INTEL
, CARD_INTEL_HWM
, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000
, 1536},
587 {HW_VENDOR_INTEL
, CARD_INTEL_HD5000_1
, "Intel(R) HD Graphics 5000", DRIVER_INTEL_HD4000
, 1536},
588 {HW_VENDOR_INTEL
, CARD_INTEL_HD5000_2
, "Intel(R) HD Graphics 5000", DRIVER_INTEL_HD4000
, 1536},
589 {HW_VENDOR_INTEL
, CARD_INTEL_I5100_1
, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000
, 1536},
590 {HW_VENDOR_INTEL
, CARD_INTEL_I5100_2
, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000
, 1536},
591 {HW_VENDOR_INTEL
, CARD_INTEL_I5100_3
, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000
, 1536},
592 {HW_VENDOR_INTEL
, CARD_INTEL_I5100_4
, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000
, 1536},
593 {HW_VENDOR_INTEL
, CARD_INTEL_IP5200_1
, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000
, 1536},
594 {HW_VENDOR_INTEL
, CARD_INTEL_IP5200_2
, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000
, 1536},
595 {HW_VENDOR_INTEL
, CARD_INTEL_IP5200_3
, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000
, 1536},
596 {HW_VENDOR_INTEL
, CARD_INTEL_IP5200_4
, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000
, 1536},
597 {HW_VENDOR_INTEL
, CARD_INTEL_IP5200_5
, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000
, 1536},
598 {HW_VENDOR_INTEL
, CARD_INTEL_IP5200_6
, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000
, 2048},
599 {HW_VENDOR_INTEL
, CARD_INTEL_HD5300
, "Intel(R) HD Graphics 5300", DRIVER_INTEL_HD4000
, 2048},
600 {HW_VENDOR_INTEL
, CARD_INTEL_HD5500
, "Intel(R) HD Graphics 5500", DRIVER_INTEL_HD4000
, 2048},
601 {HW_VENDOR_INTEL
, CARD_INTEL_HD5600
, "Intel(R) HD Graphics 5600", DRIVER_INTEL_HD4000
, 2048},
602 {HW_VENDOR_INTEL
, CARD_INTEL_HD6000
, "Intel(R) HD Graphics 6000", DRIVER_INTEL_HD4000
, 2048},
603 {HW_VENDOR_INTEL
, CARD_INTEL_I6100
, "Intel(R) Iris(TM) Graphics 6100", DRIVER_INTEL_HD4000
, 2048},
604 {HW_VENDOR_INTEL
, CARD_INTEL_IP6200
, "Intel(R) Iris(TM) Pro Graphics 6200", DRIVER_INTEL_HD4000
, 2048},
605 {HW_VENDOR_INTEL
, CARD_INTEL_IPP6300
, "Intel(R) Iris(TM) Pro Graphics P6300", DRIVER_INTEL_HD4000
, 2048},
606 {HW_VENDOR_INTEL
, CARD_INTEL_HD510_1
, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000
, 2048},
607 {HW_VENDOR_INTEL
, CARD_INTEL_HD510_2
, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000
, 2048},
608 {HW_VENDOR_INTEL
, CARD_INTEL_HD510_3
, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000
, 2048},
609 {HW_VENDOR_INTEL
, CARD_INTEL_HD515
, "Intel(R) HD Graphics 515", DRIVER_INTEL_HD4000
, 2048},
610 {HW_VENDOR_INTEL
, CARD_INTEL_HD520_1
, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000
, 2048},
611 {HW_VENDOR_INTEL
, CARD_INTEL_HD520_2
, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000
, 2048},
612 {HW_VENDOR_INTEL
, CARD_INTEL_HD530_1
, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000
, 2048},
613 {HW_VENDOR_INTEL
, CARD_INTEL_HD530_2
, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000
, 2048},
614 {HW_VENDOR_INTEL
, CARD_INTEL_HDP530
, "Intel(R) HD Graphics P530", DRIVER_INTEL_HD4000
, 2048},
615 {HW_VENDOR_INTEL
, CARD_INTEL_I540
, "Intel(R) Iris(TM) Graphics 540", DRIVER_INTEL_HD4000
, 2048},
616 {HW_VENDOR_INTEL
, CARD_INTEL_I550
, "Intel(R) Iris(TM) Graphics 550", DRIVER_INTEL_HD4000
, 2048},
617 {HW_VENDOR_INTEL
, CARD_INTEL_I555
, "Intel(R) Iris(TM) Graphics 555", DRIVER_INTEL_HD4000
, 2048},
618 {HW_VENDOR_INTEL
, CARD_INTEL_IP555
, "Intel(R) Iris(TM) Graphics P555", DRIVER_INTEL_HD4000
, 2048},
619 {HW_VENDOR_INTEL
, CARD_INTEL_IP580_1
, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000
, 2048},
620 {HW_VENDOR_INTEL
, CARD_INTEL_IP580_2
, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000
, 2048},
621 {HW_VENDOR_INTEL
, CARD_INTEL_IPP580_1
, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000
, 2048},
622 {HW_VENDOR_INTEL
, CARD_INTEL_IPP580_2
, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000
, 2048},
623 {HW_VENDOR_INTEL
, CARD_INTEL_UHD617
, "Intel(R) UHD Graphics 617", DRIVER_INTEL_HD4000
, 2048},
624 {HW_VENDOR_INTEL
, CARD_INTEL_UHD620
, "Intel(R) UHD Graphics 620", DRIVER_INTEL_HD4000
, 3072},
625 {HW_VENDOR_INTEL
, CARD_INTEL_HD615
, "Intel(R) HD Graphics 615", DRIVER_INTEL_HD4000
, 2048},
626 {HW_VENDOR_INTEL
, CARD_INTEL_HD620
, "Intel(R) HD Graphics 620", DRIVER_INTEL_HD4000
, 3072},
627 {HW_VENDOR_INTEL
, CARD_INTEL_HD630_1
, "Intel(R) HD Graphics 630", DRIVER_INTEL_HD4000
, 3072},
628 {HW_VENDOR_INTEL
, CARD_INTEL_HD630_2
, "Intel(R) HD Graphics 630", DRIVER_INTEL_HD4000
, 3072},
629 {HW_VENDOR_INTEL
, CARD_INTEL_UHD630
, "Intel(R) UHD Graphics 630", DRIVER_INTEL_HD4000
, 3072},
632 static const struct driver_version_information
*get_driver_version_info(enum wined3d_display_driver driver
,
633 enum wined3d_driver_model driver_model
)
637 TRACE("Looking up version info for driver %#x, driver_model %#x.\n", driver
, driver_model
);
639 for (i
= 0; i
< ARRAY_SIZE(driver_version_table
); ++i
)
641 const struct driver_version_information
*entry
= &driver_version_table
[i
];
643 if (entry
->driver
== driver
&& (driver_model
== DRIVER_MODEL_GENERIC
644 || entry
->driver_model
== driver_model
))
646 TRACE("Found driver \"%s\", subversion %u, build %u.\n",
647 entry
->driver_name
, entry
->subversion
, entry
->build
);
654 const struct wined3d_gpu_description
*wined3d_get_gpu_description(enum wined3d_pci_vendor vendor
,
655 enum wined3d_pci_device device
)
659 for (i
= 0; i
< ARRAY_SIZE(gpu_description_table
); ++i
)
661 if (vendor
== gpu_description_table
[i
].vendor
&& device
== gpu_description_table
[i
].device
)
662 return &gpu_description_table
[i
];
668 const struct wined3d_gpu_description
*wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor
,
669 enum wined3d_pci_device device
)
671 const struct wined3d_gpu_description
*gpu_desc
;
672 static unsigned int once
;
674 if (wined3d_settings
.pci_vendor_id
== PCI_VENDOR_NONE
&& wined3d_settings
.pci_device_id
== PCI_DEVICE_NONE
)
677 if (wined3d_settings
.pci_vendor_id
!= PCI_VENDOR_NONE
)
679 vendor
= wined3d_settings
.pci_vendor_id
;
680 TRACE("Overriding vendor PCI ID with 0x%04x.\n", vendor
);
682 if (wined3d_settings
.pci_device_id
!= PCI_DEVICE_NONE
)
684 device
= wined3d_settings
.pci_device_id
;
685 TRACE("Overriding device PCI ID with 0x%04x.\n", device
);
688 if (!(gpu_desc
= wined3d_get_gpu_description(vendor
, device
)) && !once
++)
689 ERR_(winediag
)("Invalid GPU override %04x:%04x specified, ignoring.\n", vendor
, device
);
694 static void wined3d_copy_name(char *dst
, const char *src
, unsigned int dst_size
)
700 len
= min(strlen(src
), dst_size
- 1);
701 memcpy(dst
, src
, len
);
702 memset(&dst
[len
], 0, dst_size
- len
);
706 bool wined3d_driver_info_init(struct wined3d_driver_info
*driver_info
,
707 const struct wined3d_gpu_description
*gpu_desc
, enum wined3d_feature_level feature_level
,
708 UINT64 vram_bytes
, UINT64 sysmem_bytes
)
710 const struct driver_version_information
*version_info
;
711 WORD driver_os_version
, driver_feature_level
= 10;
712 enum wined3d_driver_model driver_model
;
713 enum wined3d_display_driver driver
;
714 MEMORYSTATUSEX memory_status
;
715 OSVERSIONINFOW os_version
;
717 memset(&os_version
, 0, sizeof(os_version
));
718 os_version
.dwOSVersionInfoSize
= sizeof(os_version
);
719 if (!GetVersionExW(&os_version
))
721 ERR("Failed to get OS version, reporting 2000/XP.\n");
722 driver_os_version
= 6;
723 driver_model
= DRIVER_MODEL_NT5X
;
727 TRACE("OS version %u.%u.\n", os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
728 switch (os_version
.dwMajorVersion
)
733 /* If needed we could distinguish between 9x and NT4, but this code won't make
734 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
736 driver_os_version
= 4;
737 driver_model
= DRIVER_MODEL_WIN9X
;
741 driver_os_version
= 6;
742 driver_model
= DRIVER_MODEL_NT5X
;
746 if (os_version
.dwMinorVersion
== 0)
748 driver_os_version
= 7;
749 driver_model
= DRIVER_MODEL_NT6X
;
751 else if (os_version
.dwMinorVersion
== 1)
753 driver_os_version
= 8;
754 driver_model
= DRIVER_MODEL_NT6X
;
756 else if (os_version
.dwMinorVersion
== 2)
758 driver_os_version
= 9;
759 driver_model
= DRIVER_MODEL_NT6X
;
763 if (os_version
.dwMinorVersion
> 3)
765 FIXME("Unhandled OS version %u.%u, reporting Windows 8.1.\n",
766 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
768 driver_os_version
= 10;
769 driver_model
= DRIVER_MODEL_NT6X
;
774 driver_os_version
= 26;
775 driver_model
= DRIVER_MODEL_NT6X
;
779 FIXME("Unhandled OS version %u.%u, reporting Windows 7.\n",
780 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
781 driver_os_version
= 8;
782 driver_model
= DRIVER_MODEL_NT6X
;
787 TRACE("GPU maximum feature level %#x.\n", feature_level
);
788 switch (feature_level
)
790 case WINED3D_FEATURE_LEVEL_NONE
:
791 case WINED3D_FEATURE_LEVEL_5
:
792 if (driver_model
== DRIVER_MODEL_WIN9X
)
793 driver_feature_level
= 5;
795 driver_feature_level
= 10;
797 case WINED3D_FEATURE_LEVEL_6
:
798 driver_feature_level
= 11;
800 case WINED3D_FEATURE_LEVEL_7
:
801 driver_feature_level
= 12;
803 case WINED3D_FEATURE_LEVEL_8
:
804 driver_feature_level
= 13;
806 case WINED3D_FEATURE_LEVEL_9_1
:
807 case WINED3D_FEATURE_LEVEL_9_2
:
808 case WINED3D_FEATURE_LEVEL_9_3
:
809 driver_feature_level
= 14;
811 case WINED3D_FEATURE_LEVEL_10
:
812 driver_feature_level
= 15;
814 case WINED3D_FEATURE_LEVEL_10_1
:
815 driver_feature_level
= 16;
817 case WINED3D_FEATURE_LEVEL_11
:
818 driver_feature_level
= 17;
820 case WINED3D_FEATURE_LEVEL_11_1
:
821 /* Advertise support for everything up to FL 12_x. */
822 driver_feature_level
= 21;
825 if (os_version
.dwMajorVersion
== 6 && !os_version
.dwMinorVersion
)
826 driver_feature_level
= min(driver_feature_level
, 18);
827 else if (os_version
.dwMajorVersion
< 6)
828 driver_feature_level
= min(driver_feature_level
, 14);
830 driver_info
->vendor
= gpu_desc
->vendor
;
831 driver_info
->device
= gpu_desc
->device
;
832 wined3d_copy_name(driver_info
->description
, gpu_desc
->description
, ARRAY_SIZE(driver_info
->description
));
833 driver_info
->vram_bytes
= vram_bytes
? vram_bytes
: (UINT64
)gpu_desc
->vidmem
* 1024 * 1024;
834 driver
= gpu_desc
->driver
;
836 if (wined3d_settings
.emulated_textureram
)
838 driver_info
->vram_bytes
= wined3d_settings
.emulated_textureram
;
839 TRACE("Overriding amount of video memory with 0x%s bytes.\n",
840 wine_dbgstr_longlong(driver_info
->vram_bytes
));
844 * Diablo 2 crashes when the amount of video memory is greater than 0x7fffffff.
845 * In order to avoid this application bug we limit the amount of video memory
846 * to LONG_MAX for older Windows versions.
848 if (driver_model
< DRIVER_MODEL_NT6X
&& driver_info
->vram_bytes
> LONG_MAX
)
850 TRACE("Limiting amount of video memory to %#lx bytes for OS version older than Vista.\n", LONG_MAX
);
851 driver_info
->vram_bytes
= LONG_MAX
;
854 if (!(driver_info
->sysmem_bytes
= sysmem_bytes
))
856 driver_info
->sysmem_bytes
= 64 * 1024 * 1024;
857 memory_status
.dwLength
= sizeof(memory_status
);
858 if (GlobalMemoryStatusEx(&memory_status
))
859 driver_info
->sysmem_bytes
= max(memory_status
.ullTotalPhys
/ 2, driver_info
->sysmem_bytes
);
861 ERR("Failed to get global memory status.\n");
864 /* Try to obtain driver version information for the current Windows version. This fails in
866 * - the gpu is not available on the currently selected OS version:
867 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
868 * version information for the current Windows version is returned instead of faked info.
869 * We do the same and assume the default Windows version to emulate is WinXP.
871 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
872 * For now return the XP driver info. Perhaps later on we should return VESA.
874 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
875 * This could be an indication that our database is not up to date, so this should be fixed.
877 if ((version_info
= get_driver_version_info(driver
, driver_model
))
878 || (version_info
= get_driver_version_info(driver
, DRIVER_MODEL_GENERIC
)))
880 driver_info
->name
= version_info
->driver_name
;
881 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, driver_feature_level
);
882 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
887 ERR("No driver version info found for device %04x:%04x, driver model %#x.\n",
888 driver_info
->vendor
, driver_info
->device
, driver_model
);
892 enum wined3d_pci_device
wined3d_gpu_from_feature_level(enum wined3d_pci_vendor
*vendor
,
893 enum wined3d_feature_level feature_level
)
895 static const struct wined3d_fallback_card
897 enum wined3d_feature_level feature_level
;
898 enum wined3d_pci_device device_id
;
900 card_fallback_nvidia
[] =
902 {WINED3D_FEATURE_LEVEL_5
, CARD_NVIDIA_RIVA_128
},
903 {WINED3D_FEATURE_LEVEL_6
, CARD_NVIDIA_RIVA_TNT
},
904 {WINED3D_FEATURE_LEVEL_7
, CARD_NVIDIA_GEFORCE
},
905 {WINED3D_FEATURE_LEVEL_8
, CARD_NVIDIA_GEFORCE3
},
906 {WINED3D_FEATURE_LEVEL_9_2
, CARD_NVIDIA_GEFORCEFX_5800
},
907 {WINED3D_FEATURE_LEVEL_9_3
, CARD_NVIDIA_GEFORCE_6800
},
908 {WINED3D_FEATURE_LEVEL_10
, CARD_NVIDIA_GEFORCE_8800GTX
},
909 {WINED3D_FEATURE_LEVEL_11
, CARD_NVIDIA_GEFORCE_GTX470
},
910 {WINED3D_FEATURE_LEVEL_NONE
},
912 card_fallback_amd
[] =
914 {WINED3D_FEATURE_LEVEL_5
, CARD_AMD_RAGE_128PRO
},
915 {WINED3D_FEATURE_LEVEL_7
, CARD_AMD_RADEON_7200
},
916 {WINED3D_FEATURE_LEVEL_8
, CARD_AMD_RADEON_8500
},
917 {WINED3D_FEATURE_LEVEL_9_1
, CARD_AMD_RADEON_9500
},
918 {WINED3D_FEATURE_LEVEL_9_3
, CARD_AMD_RADEON_X1600
},
919 {WINED3D_FEATURE_LEVEL_10
, CARD_AMD_RADEON_HD2900
},
920 {WINED3D_FEATURE_LEVEL_11
, CARD_AMD_RADEON_HD5600
},
921 {WINED3D_FEATURE_LEVEL_NONE
},
923 card_fallback_intel
[] =
925 {WINED3D_FEATURE_LEVEL_5
, CARD_INTEL_845G
},
926 {WINED3D_FEATURE_LEVEL_8
, CARD_INTEL_915G
},
927 {WINED3D_FEATURE_LEVEL_9_3
, CARD_INTEL_945G
},
928 {WINED3D_FEATURE_LEVEL_10
, CARD_INTEL_G45
},
929 {WINED3D_FEATURE_LEVEL_11
, CARD_INTEL_IVBD
},
930 {WINED3D_FEATURE_LEVEL_NONE
},
935 enum wined3d_pci_vendor vendor
;
936 const struct wined3d_fallback_card
*cards
;
940 {HW_VENDOR_AMD
, card_fallback_amd
},
941 {HW_VENDOR_NVIDIA
, card_fallback_nvidia
},
942 {HW_VENDOR_VMWARE
, card_fallback_amd
},
943 {HW_VENDOR_INTEL
, card_fallback_intel
},
946 const struct wined3d_fallback_card
*cards
;
947 enum wined3d_pci_device device_id
;
951 for (i
= 0; i
< ARRAY_SIZE(fallbacks
); ++i
)
953 if (*vendor
== fallbacks
[i
].vendor
)
954 cards
= fallbacks
[i
].cards
;
958 *vendor
= HW_VENDOR_NVIDIA
;
959 cards
= card_fallback_nvidia
;
962 device_id
= cards
->device_id
;
963 for (i
= 0; cards
[i
].feature_level
; ++i
)
965 if (feature_level
>= cards
[i
].feature_level
)
966 device_id
= cards
[i
].device_id
;
971 struct wined3d_adapter
* CDECL
wined3d_get_adapter(const struct wined3d
*wined3d
, unsigned int idx
)
973 TRACE("wined3d %p, idx %u.\n", wined3d
, idx
);
975 if (idx
>= wined3d
->adapter_count
)
978 return wined3d
->adapters
[idx
];
981 UINT CDECL
wined3d_get_adapter_count(const struct wined3d
*wined3d
)
983 TRACE("wined3d %p, reporting %u adapters.\n",
984 wined3d
, wined3d
->adapter_count
);
986 return wined3d
->adapter_count
;
989 struct wined3d_output
* CDECL
wined3d_adapter_get_output(const struct wined3d_adapter
*adapter
,
992 TRACE("adapter %p, idx %u.\n", adapter
, idx
);
994 if (idx
>= adapter
->output_count
)
997 return &adapter
->outputs
[idx
];
1000 unsigned int CDECL
wined3d_adapter_get_output_count(const struct wined3d_adapter
*adapter
)
1002 TRACE("adapter %p, reporting %Iu outputs.\n", adapter
, adapter
->output_count
);
1004 return adapter
->output_count
;
1007 HRESULT CDECL
wined3d_adapter_get_video_memory_info(const struct wined3d_adapter
*adapter
,
1008 unsigned int node_idx
, enum wined3d_memory_segment_group group
,
1009 struct wined3d_video_memory_info
*info
)
1011 static unsigned int once
;
1012 D3DKMT_QUERYVIDEOMEMORYINFO query_memory_info
;
1013 struct wined3d_adapter_identifier adapter_id
;
1017 TRACE("adapter %p, node_idx %u, group %d, info %p.\n", adapter
, node_idx
, group
, info
);
1019 if (group
> WINED3D_MEMORY_SEGMENT_GROUP_NON_LOCAL
)
1021 WARN("Invalid memory segment group %#x.\n", group
);
1022 return E_INVALIDARG
;
1025 query_memory_info
.hProcess
= NULL
;
1026 query_memory_info
.hAdapter
= adapter
->kmt_adapter
;
1027 query_memory_info
.PhysicalAdapterIndex
= node_idx
;
1028 query_memory_info
.MemorySegmentGroup
= (D3DKMT_MEMORY_SEGMENT_GROUP
)group
;
1029 status
= D3DKMTQueryVideoMemoryInfo(&query_memory_info
);
1030 if (status
== STATUS_SUCCESS
)
1032 info
->budget
= query_memory_info
.Budget
;
1033 info
->current_usage
= query_memory_info
.CurrentUsage
;
1034 info
->current_reservation
= query_memory_info
.CurrentReservation
;
1035 info
->available_reservation
= query_memory_info
.AvailableForReservation
;
1039 /* D3DKMTQueryVideoMemoryInfo() failed, fallback to fake memory info */
1041 FIXME("Returning fake video memory info.\n");
1044 FIXME("Ignoring node index %u.\n", node_idx
);
1046 adapter_id
.driver_size
= 0;
1047 adapter_id
.description_size
= 0;
1048 if (FAILED(hr
= wined3d_adapter_get_identifier(adapter
, 0, &adapter_id
)))
1053 case WINED3D_MEMORY_SEGMENT_GROUP_LOCAL
:
1054 info
->budget
= adapter_id
.video_memory
;
1055 info
->current_usage
= adapter
->vram_bytes_used
;
1056 info
->available_reservation
= adapter_id
.video_memory
/ 2;
1057 info
->current_reservation
= 0;
1059 case WINED3D_MEMORY_SEGMENT_GROUP_NON_LOCAL
:
1060 memset(info
, 0, sizeof(*info
));
1066 static DWORD CALLBACK
notification_thread_func(void *stop_event
)
1068 struct wined3d_adapter_budget_change_notification
*notification
;
1069 struct wined3d_video_memory_info info
;
1072 SetThreadDescription(GetCurrentThread(), L
"wined3d_budget_change_notification");
1076 wined3d_mutex_lock();
1077 LIST_FOR_EACH_ENTRY(notification
, &adapter_budget_change_notifications
,
1078 struct wined3d_adapter_budget_change_notification
, entry
)
1080 hr
= wined3d_adapter_get_video_memory_info(notification
->adapter
, 0,
1081 WINED3D_MEMORY_SEGMENT_GROUP_LOCAL
, &info
);
1082 if (SUCCEEDED(hr
) && info
.budget
!= notification
->last_local_budget
)
1084 notification
->last_local_budget
= info
.budget
;
1085 SetEvent(notification
->event
);
1089 hr
= wined3d_adapter_get_video_memory_info(notification
->adapter
, 0,
1090 WINED3D_MEMORY_SEGMENT_GROUP_NON_LOCAL
, &info
);
1091 if (SUCCEEDED(hr
) && info
.budget
!= notification
->last_non_local_budget
)
1093 notification
->last_non_local_budget
= info
.budget
;
1094 SetEvent(notification
->event
);
1097 wined3d_mutex_unlock();
1099 if (WaitForSingleObject(stop_event
, 1000) == WAIT_OBJECT_0
)
1106 HRESULT CDECL
wined3d_adapter_register_budget_change_notification(const struct wined3d_adapter
*adapter
,
1107 HANDLE event
, DWORD
*cookie
)
1109 static DWORD cookie_counter
;
1110 static BOOL wrapped
;
1111 struct wined3d_adapter_budget_change_notification
*notification
, *new_notification
;
1114 new_notification
= heap_alloc_zero(sizeof(*new_notification
));
1115 if (!new_notification
)
1116 return E_OUTOFMEMORY
;
1118 wined3d_mutex_lock();
1119 new_notification
->adapter
= adapter
;
1120 new_notification
->event
= event
;
1121 new_notification
->cookie
= cookie_counter
++;
1122 if (cookie_counter
< new_notification
->cookie
)
1128 LIST_FOR_EACH_ENTRY(notification
, &adapter_budget_change_notifications
,
1129 struct wined3d_adapter_budget_change_notification
, entry
)
1131 if (notification
->cookie
== new_notification
->cookie
)
1141 new_notification
->cookie
= cookie_counter
++;
1145 *cookie
= new_notification
->cookie
;
1146 list_add_head(&adapter_budget_change_notifications
, &new_notification
->entry
);
1148 if (!notification_thread
)
1150 notification_thread_stop_event
= CreateEventW(0, FALSE
, FALSE
, NULL
);
1151 notification_thread
= CreateThread(NULL
, 0, notification_thread_func
,
1152 notification_thread_stop_event
, 0, NULL
);
1154 wined3d_mutex_unlock();
1158 HRESULT CDECL
wined3d_adapter_unregister_budget_change_notification(DWORD cookie
)
1160 struct wined3d_adapter_budget_change_notification
*notification
;
1161 HANDLE thread
, thread_stop_event
;
1163 wined3d_mutex_lock();
1164 LIST_FOR_EACH_ENTRY(notification
, &adapter_budget_change_notifications
,
1165 struct wined3d_adapter_budget_change_notification
, entry
)
1167 if (notification
->cookie
== cookie
)
1169 list_remove(¬ification
->entry
);
1170 heap_free(notification
);
1175 if (!list_empty(&adapter_budget_change_notifications
))
1177 wined3d_mutex_unlock();
1181 thread
= notification_thread
;
1182 thread_stop_event
= notification_thread_stop_event
;
1183 notification_thread
= NULL
;
1184 notification_thread_stop_event
= NULL
;
1185 wined3d_mutex_unlock();
1186 SetEvent(thread_stop_event
);
1187 WaitForSingleObject(thread
, INFINITE
);
1188 CloseHandle(thread
);
1189 CloseHandle(thread_stop_event
);
1193 HRESULT CDECL
wined3d_register_software_device(struct wined3d
*wined3d
, void *init_function
)
1195 FIXME("wined3d %p, init_function %p stub!\n", wined3d
, init_function
);
1200 static BOOL CALLBACK
enum_monitor_proc(HMONITOR monitor
, HDC hdc
, RECT
*rect
, LPARAM lparam
)
1202 struct wined3d_output_desc
*desc
= (struct wined3d_output_desc
*)lparam
;
1203 MONITORINFOEXW monitor_info
;
1205 monitor_info
.cbSize
= sizeof(monitor_info
);
1206 if (GetMonitorInfoW(monitor
, (MONITORINFO
*)&monitor_info
) &&
1207 !lstrcmpiW(desc
->device_name
, monitor_info
.szDevice
))
1209 desc
->monitor
= monitor
;
1210 desc
->desktop_rect
= monitor_info
.rcMonitor
;
1211 desc
->attached_to_desktop
= TRUE
;
1218 HRESULT CDECL
wined3d_output_get_desc(const struct wined3d_output
*output
,
1219 struct wined3d_output_desc
*desc
)
1221 TRACE("output %p, desc %p.\n", output
, desc
);
1223 memset(desc
, 0, sizeof(*desc
));
1224 desc
->ordinal
= output
->ordinal
;
1225 lstrcpyW(desc
->device_name
, output
->device_name
);
1226 EnumDisplayMonitors(NULL
, NULL
, enum_monitor_proc
, (LPARAM
)desc
);
1230 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
1231 of the same bpp but different resolutions */
1233 static void wined3d_output_update_modes(struct wined3d_output
*output
, bool cached
)
1235 struct wined3d_display_mode
*wined3d_mode
;
1236 DEVMODEW mode
= {.dmSize
= sizeof(mode
)};
1239 if (output
->modes_valid
&& cached
)
1242 output
->mode_count
= 0;
1244 for (i
= 0; EnumDisplaySettingsExW(output
->device_name
, i
, &mode
, 0); ++i
)
1246 if (!wined3d_array_reserve((void **)&output
->modes
, &output
->modes_size
,
1247 output
->mode_count
+ 1, sizeof(*output
->modes
)))
1250 wined3d_mode
= &output
->modes
[output
->mode_count
++];
1251 wined3d_mode
->width
= mode
.dmPelsWidth
;
1252 wined3d_mode
->height
= mode
.dmPelsHeight
;
1253 wined3d_mode
->format_id
= pixelformat_for_depth(mode
.dmBitsPerPel
);
1255 if (mode
.dmFields
& DM_DISPLAYFREQUENCY
)
1256 wined3d_mode
->refresh_rate
= mode
.dmDisplayFrequency
;
1258 wined3d_mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
1260 if (mode
.dmFields
& DM_DISPLAYFLAGS
)
1262 if (mode
.u2
.dmDisplayFlags
& DM_INTERLACED
)
1263 wined3d_mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_INTERLACED
;
1265 wined3d_mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_PROGRESSIVE
;
1269 wined3d_mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_UNKNOWN
;
1273 output
->modes_valid
= true;
1276 static bool mode_matches_filter(const struct wined3d_adapter
*adapter
, const struct wined3d_display_mode
*mode
,
1277 const struct wined3d_format
*format
, enum wined3d_scanline_ordering scanline_ordering
)
1279 if (scanline_ordering
!= WINED3D_SCANLINE_ORDERING_UNKNOWN
1280 && mode
->scanline_ordering
!= WINED3D_SCANLINE_ORDERING_UNKNOWN
1281 && scanline_ordering
!= mode
->scanline_ordering
)
1284 if (format
->id
== WINED3DFMT_UNKNOWN
)
1286 /* This is for d3d8, do not enumerate P8 here. */
1287 if (mode
->format_id
!= WINED3DFMT_B5G6R5_UNORM
&& mode
->format_id
!= WINED3DFMT_B8G8R8X8_UNORM
)
1292 const struct wined3d_format
*mode_format
= wined3d_get_format(adapter
,
1293 mode
->format_id
, WINED3D_BIND_RENDER_TARGET
);
1295 if (format
->byte_count
!= mode_format
->byte_count
)
1302 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
1303 unsigned int CDECL
wined3d_output_get_mode_count(struct wined3d_output
*output
,
1304 enum wined3d_format_id format_id
, enum wined3d_scanline_ordering scanline_ordering
, bool cached
)
1306 const struct wined3d_adapter
*adapter
;
1307 const struct wined3d_format
*format
;
1308 unsigned int count
= 0;
1311 TRACE("output %p, format %s, scanline_ordering %#x.\n",
1312 output
, debug_d3dformat(format_id
), scanline_ordering
);
1314 adapter
= output
->adapter
;
1315 format
= wined3d_get_format(adapter
, format_id
, WINED3D_BIND_RENDER_TARGET
);
1317 wined3d_output_update_modes(output
, cached
);
1319 for (i
= 0; i
< output
->mode_count
; ++i
)
1321 if (mode_matches_filter(adapter
, &output
->modes
[i
], format
, scanline_ordering
))
1325 TRACE("Returning %u matching modes (out of %Iu total).\n", count
, output
->mode_count
);
1330 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
1331 HRESULT CDECL
wined3d_output_get_mode(struct wined3d_output
*output
,
1332 enum wined3d_format_id format_id
, enum wined3d_scanline_ordering scanline_ordering
,
1333 unsigned int mode_idx
, struct wined3d_display_mode
*mode
, bool cached
)
1335 const struct wined3d_adapter
*adapter
;
1336 const struct wined3d_format
*format
;
1337 SIZE_T i
, match_idx
= 0;
1339 TRACE("output %p, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
1340 output
, debug_d3dformat(format_id
), scanline_ordering
, mode_idx
, mode
);
1343 return WINED3DERR_INVALIDCALL
;
1345 adapter
= output
->adapter
;
1346 format
= wined3d_get_format(adapter
, format_id
, WINED3D_BIND_RENDER_TARGET
);
1348 wined3d_output_update_modes(output
, cached
);
1350 for (i
= 0; i
< output
->mode_count
; ++i
)
1352 const struct wined3d_display_mode
*wined3d_mode
= &output
->modes
[i
];
1354 if (mode_matches_filter(adapter
, wined3d_mode
, format
, scanline_ordering
) && match_idx
++ == mode_idx
)
1356 *mode
= *wined3d_mode
;
1357 if (format_id
!= WINED3DFMT_UNKNOWN
)
1358 mode
->format_id
= format_id
;
1360 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode
->width
, mode
->height
, mode
->refresh_rate
,
1361 wined3d_get_format(adapter
, mode
->format_id
, WINED3D_BIND_RENDER_TARGET
)->byte_count
* CHAR_BIT
,
1362 debug_d3dformat(mode
->format_id
), mode
->scanline_ordering
);
1367 WARN("Invalid mode_idx %u.\n", mode_idx
);
1368 return WINED3DERR_INVALIDCALL
;
1371 HRESULT CDECL
wined3d_output_find_closest_matching_mode(struct wined3d_output
*output
,
1372 struct wined3d_display_mode
*mode
)
1374 unsigned int i
, j
, mode_count
, matching_mode_count
, closest
;
1375 struct wined3d_display_mode
**matching_modes
;
1376 struct wined3d_display_mode
*modes
;
1379 TRACE("output %p, mode %p.\n", output
, mode
);
1381 if (!(mode_count
= wined3d_output_get_mode_count(output
, mode
->format_id
,
1382 WINED3D_SCANLINE_ORDERING_UNKNOWN
, false)))
1384 WARN("Output has 0 matching modes.\n");
1388 if (!(modes
= heap_calloc(mode_count
, sizeof(*modes
))))
1389 return E_OUTOFMEMORY
;
1390 if (!(matching_modes
= heap_calloc(mode_count
, sizeof(*matching_modes
))))
1393 return E_OUTOFMEMORY
;
1396 for (i
= 0; i
< mode_count
; ++i
)
1398 if (FAILED(hr
= wined3d_output_get_mode(output
, mode
->format_id
,
1399 WINED3D_SCANLINE_ORDERING_UNKNOWN
, i
, &modes
[i
], true)))
1401 heap_free(matching_modes
);
1405 matching_modes
[i
] = &modes
[i
];
1408 matching_mode_count
= mode_count
;
1410 if (mode
->scanline_ordering
!= WINED3D_SCANLINE_ORDERING_UNKNOWN
)
1412 for (i
= 0, j
= 0; i
< matching_mode_count
; ++i
)
1414 if (matching_modes
[i
]->scanline_ordering
== mode
->scanline_ordering
)
1415 matching_modes
[j
++] = matching_modes
[i
];
1418 matching_mode_count
= j
;
1421 if (mode
->refresh_rate
)
1423 for (i
= 0, j
= 0; i
< matching_mode_count
; ++i
)
1425 if (matching_modes
[i
]->refresh_rate
== mode
->refresh_rate
)
1426 matching_modes
[j
++] = matching_modes
[i
];
1429 matching_mode_count
= j
;
1432 if (!mode
->width
|| !mode
->height
)
1434 struct wined3d_display_mode current_mode
;
1435 if (FAILED(hr
= wined3d_output_get_display_mode(output
, ¤t_mode
, NULL
)))
1437 heap_free(matching_modes
);
1441 mode
->width
= current_mode
.width
;
1442 mode
->height
= current_mode
.height
;
1446 for (i
= 0, j
= 0; i
< matching_mode_count
; ++i
)
1448 unsigned int d
= abs((int)(mode
->width
- matching_modes
[i
]->width
))
1449 + abs((int)(mode
->height
- matching_modes
[i
]->height
));
1458 *mode
= *matching_modes
[j
];
1460 heap_free(matching_modes
);
1463 TRACE("Returning %ux%u@%u %s %#x.\n", mode
->width
, mode
->height
,
1464 mode
->refresh_rate
, debug_d3dformat(mode
->format_id
),
1465 mode
->scanline_ordering
);
1470 struct wined3d_adapter
* CDECL
wined3d_output_get_adapter(const struct wined3d_output
*output
)
1472 TRACE("output %p.\n", output
);
1474 return output
->adapter
;
1477 HRESULT CDECL
wined3d_output_get_display_mode(const struct wined3d_output
*output
,
1478 struct wined3d_display_mode
*mode
, enum wined3d_display_rotation
*rotation
)
1482 TRACE("output %p, display_mode %p, rotation %p.\n", output
, mode
, rotation
);
1485 return WINED3DERR_INVALIDCALL
;
1487 memset(&m
, 0, sizeof(m
));
1488 m
.dmSize
= sizeof(m
);
1490 EnumDisplaySettingsExW(output
->device_name
, ENUM_CURRENT_SETTINGS
, &m
, 0);
1491 mode
->width
= m
.dmPelsWidth
;
1492 mode
->height
= m
.dmPelsHeight
;
1493 mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
1494 if (m
.dmFields
& DM_DISPLAYFREQUENCY
)
1495 mode
->refresh_rate
= m
.dmDisplayFrequency
;
1496 mode
->format_id
= pixelformat_for_depth(m
.dmBitsPerPel
);
1498 /* Lie about the format. X11 can't change the color depth, and some apps
1499 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
1500 * that GetDisplayMode still returns 24 bpp. This should probably be
1501 * handled in winex11 instead. */
1502 if (output
->screen_format
&& output
->screen_format
!= mode
->format_id
)
1504 WARN("Overriding format %s with stored format %s.\n",
1505 debug_d3dformat(mode
->format_id
),
1506 debug_d3dformat(output
->screen_format
));
1507 mode
->format_id
= output
->screen_format
;
1510 if (!(m
.dmFields
& DM_DISPLAYFLAGS
))
1511 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_UNKNOWN
;
1512 else if (m
.u2
.dmDisplayFlags
& DM_INTERLACED
)
1513 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_INTERLACED
;
1515 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_PROGRESSIVE
;
1519 switch (m
.u1
.s2
.dmDisplayOrientation
)
1522 *rotation
= WINED3D_DISPLAY_ROTATION_0
;
1525 *rotation
= WINED3D_DISPLAY_ROTATION_90
;
1528 *rotation
= WINED3D_DISPLAY_ROTATION_180
;
1531 *rotation
= WINED3D_DISPLAY_ROTATION_270
;
1534 FIXME("Unhandled display rotation %#x.\n", m
.u1
.s2
.dmDisplayOrientation
);
1535 *rotation
= WINED3D_DISPLAY_ROTATION_UNSPECIFIED
;
1540 TRACE("Returning %ux%u@%u %s %#x.\n", mode
->width
, mode
->height
,
1541 mode
->refresh_rate
, debug_d3dformat(mode
->format_id
),
1542 mode
->scanline_ordering
);
1546 static BOOL
equal_display_mode(const DEVMODEW
*mode1
, const DEVMODEW
*mode2
)
1548 if (mode1
->dmFields
& mode2
->dmFields
& DM_PELSWIDTH
1549 && mode1
->dmPelsWidth
!= mode2
->dmPelsWidth
)
1552 if (mode1
->dmFields
& mode2
->dmFields
& DM_PELSHEIGHT
1553 && mode1
->dmPelsHeight
!= mode2
->dmPelsHeight
)
1556 if (mode1
->dmFields
& mode2
->dmFields
& DM_BITSPERPEL
1557 && mode1
->dmBitsPerPel
!= mode2
->dmBitsPerPel
)
1560 if (mode1
->dmFields
& mode2
->dmFields
& DM_DISPLAYFLAGS
1561 && mode1
->u2
.dmDisplayFlags
!= mode2
->u2
.dmDisplayFlags
)
1564 if (mode1
->dmFields
& mode2
->dmFields
& DM_DISPLAYFREQUENCY
1565 && mode1
->dmDisplayFrequency
!= mode2
->dmDisplayFrequency
)
1568 if (mode1
->dmFields
& mode2
->dmFields
& DM_DISPLAYORIENTATION
1569 && mode1
->u1
.s2
.dmDisplayOrientation
!= mode2
->u1
.s2
.dmDisplayOrientation
)
1572 if (mode1
->dmFields
& mode2
->dmFields
& DM_POSITION
1573 && (mode1
->u1
.s2
.dmPosition
.x
!= mode2
->u1
.s2
.dmPosition
.x
1574 || mode1
->u1
.s2
.dmPosition
.y
!= mode2
->u1
.s2
.dmPosition
.y
))
1580 HRESULT CDECL
wined3d_restore_display_modes(struct wined3d
*wined3d
)
1582 unsigned int adapter_idx
, output_idx
= 0;
1583 DEVMODEW current_mode
, registry_mode
;
1584 struct wined3d_adapter
*adapter
;
1585 DISPLAY_DEVICEW display_device
;
1586 struct wined3d_output
*output
;
1587 BOOL do_mode_change
= FALSE
;
1590 TRACE("wined3d %p.\n", wined3d
);
1592 memset(¤t_mode
, 0, sizeof(current_mode
));
1593 memset(®istry_mode
, 0, sizeof(registry_mode
));
1594 current_mode
.dmSize
= sizeof(current_mode
);
1595 registry_mode
.dmSize
= sizeof(registry_mode
);
1596 display_device
.cb
= sizeof(display_device
);
1597 while (EnumDisplayDevicesW(NULL
, output_idx
++, &display_device
, 0))
1599 if (!EnumDisplaySettingsExW(display_device
.DeviceName
, ENUM_CURRENT_SETTINGS
, ¤t_mode
, 0))
1601 ERR("Failed to read the current display mode for %s.\n",
1602 wine_dbgstr_w(display_device
.DeviceName
));
1603 return WINED3DERR_NOTAVAILABLE
;
1606 if (!EnumDisplaySettingsExW(display_device
.DeviceName
, ENUM_REGISTRY_SETTINGS
, ®istry_mode
, 0))
1608 ERR("Failed to read the registry display mode for %s.\n",
1609 wine_dbgstr_w(display_device
.DeviceName
));
1610 return WINED3DERR_NOTAVAILABLE
;
1613 if (!equal_display_mode(¤t_mode
, ®istry_mode
))
1615 do_mode_change
= TRUE
;
1622 ret
= ChangeDisplaySettingsExW(NULL
, NULL
, NULL
, 0, NULL
);
1623 if (ret
!= DISP_CHANGE_SUCCESSFUL
)
1625 ERR("Failed to restore all outputs to their registry display settings, error %d.\n", ret
);
1626 return WINED3DERR_NOTAVAILABLE
;
1631 TRACE("Skipping redundant mode setting call.\n");
1634 for (adapter_idx
= 0; adapter_idx
< wined3d
->adapter_count
; ++adapter_idx
)
1636 adapter
= wined3d
->adapters
[adapter_idx
];
1637 for (output_idx
= 0; output_idx
< adapter
->output_count
; ++output_idx
)
1639 output
= &adapter
->outputs
[output_idx
];
1641 if (!EnumDisplaySettingsExW(output
->device_name
, ENUM_CURRENT_SETTINGS
, ¤t_mode
, 0))
1643 ERR("Failed to read the current display mode for %s.\n",
1644 wine_dbgstr_w(output
->device_name
));
1645 return WINED3DERR_NOTAVAILABLE
;
1648 output
->screen_format
= pixelformat_for_depth(current_mode
.dmBitsPerPel
);
1655 HRESULT CDECL
wined3d_output_set_display_mode(struct wined3d_output
*output
,
1656 const struct wined3d_display_mode
*mode
)
1658 enum wined3d_format_id new_format_id
;
1659 const struct wined3d_format
*format
;
1660 DEVMODEW new_mode
, current_mode
;
1663 TRACE("output %p, mode %p.\n", output
, mode
);
1664 TRACE("mode %ux%u@%u %s %#x.\n", mode
->width
, mode
->height
, mode
->refresh_rate
,
1665 debug_d3dformat(mode
->format_id
), mode
->scanline_ordering
);
1667 memset(&new_mode
, 0, sizeof(new_mode
));
1668 new_mode
.dmSize
= sizeof(new_mode
);
1669 memset(¤t_mode
, 0, sizeof(current_mode
));
1670 current_mode
.dmSize
= sizeof(current_mode
);
1672 format
= wined3d_get_format(output
->adapter
, mode
->format_id
, WINED3D_BIND_RENDER_TARGET
);
1674 new_mode
.dmFields
= DM_BITSPERPEL
| DM_PELSWIDTH
| DM_PELSHEIGHT
;
1675 new_mode
.dmBitsPerPel
= format
->byte_count
* CHAR_BIT
;
1676 new_mode
.dmPelsWidth
= mode
->width
;
1677 new_mode
.dmPelsHeight
= mode
->height
;
1678 new_mode
.dmDisplayFrequency
= mode
->refresh_rate
;
1679 if (mode
->refresh_rate
)
1680 new_mode
.dmFields
|= DM_DISPLAYFREQUENCY
;
1681 if (mode
->scanline_ordering
!= WINED3D_SCANLINE_ORDERING_UNKNOWN
)
1683 new_mode
.dmFields
|= DM_DISPLAYFLAGS
;
1684 if (mode
->scanline_ordering
== WINED3D_SCANLINE_ORDERING_INTERLACED
)
1685 new_mode
.u2
.dmDisplayFlags
|= DM_INTERLACED
;
1687 new_format_id
= mode
->format_id
;
1689 /* Only change the mode if necessary. */
1690 if (!EnumDisplaySettingsW(output
->device_name
, ENUM_CURRENT_SETTINGS
, ¤t_mode
))
1692 ERR("Failed to get current display mode.\n");
1694 else if (equal_display_mode(¤t_mode
, &new_mode
))
1696 TRACE("Skipping redundant mode setting call.\n");
1697 output
->screen_format
= new_format_id
;
1701 ret
= ChangeDisplaySettingsExW(output
->device_name
, &new_mode
, NULL
, CDS_FULLSCREEN
, NULL
);
1702 if (ret
!= DISP_CHANGE_SUCCESSFUL
)
1704 if (new_mode
.dmFields
& DM_DISPLAYFREQUENCY
)
1706 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
1707 new_mode
.dmFields
&= ~DM_DISPLAYFREQUENCY
;
1708 new_mode
.dmDisplayFrequency
= 0;
1709 ret
= ChangeDisplaySettingsExW(output
->device_name
, &new_mode
, NULL
, CDS_FULLSCREEN
, NULL
);
1711 if (ret
!= DISP_CHANGE_SUCCESSFUL
)
1712 return WINED3DERR_NOTAVAILABLE
;
1715 /* Store the new values. */
1716 output
->screen_format
= new_format_id
;
1721 HRESULT CDECL
wined3d_output_set_gamma_ramp(struct wined3d_output
*output
, const struct wined3d_gamma_ramp
*ramp
)
1725 TRACE("output %p, ramp %p.\n", output
, ramp
);
1727 dc
= CreateDCW(output
->device_name
, NULL
, NULL
, NULL
);
1728 SetDeviceGammaRamp(dc
, (void *)ramp
);
1734 HRESULT
wined3d_output_get_gamma_ramp(struct wined3d_output
*output
, struct wined3d_gamma_ramp
*ramp
)
1738 TRACE("output %p, ramp %p.\n", output
, ramp
);
1740 dc
= CreateDCW(output
->device_name
, NULL
, NULL
, NULL
);
1741 GetDeviceGammaRamp(dc
, ramp
);
1747 HRESULT CDECL
wined3d_adapter_get_identifier(const struct wined3d_adapter
*adapter
,
1748 DWORD flags
, struct wined3d_adapter_identifier
*identifier
)
1750 TRACE("adapter %p, flags %#x, identifier %p.\n", adapter
, flags
, identifier
);
1752 wined3d_mutex_lock();
1754 wined3d_copy_name(identifier
->driver
, adapter
->driver_info
.name
, identifier
->driver_size
);
1755 wined3d_copy_name(identifier
->description
, adapter
->driver_info
.description
, identifier
->description_size
);
1757 identifier
->driver_version
.u
.HighPart
= adapter
->driver_info
.version_high
;
1758 identifier
->driver_version
.u
.LowPart
= adapter
->driver_info
.version_low
;
1759 identifier
->vendor_id
= adapter
->driver_info
.vendor
;
1760 identifier
->device_id
= adapter
->driver_info
.device
;
1761 identifier
->subsystem_id
= 0;
1762 identifier
->revision
= 0;
1763 identifier
->device_identifier
= IID_D3DDEVICE_D3DUID
;
1764 identifier
->driver_uuid
= adapter
->driver_uuid
;
1765 identifier
->device_uuid
= adapter
->device_uuid
;
1766 identifier
->whql_level
= (flags
& WINED3DENUM_WHQL_LEVEL
) ? 1 : 0;
1767 identifier
->adapter_luid
= adapter
->luid
;
1768 identifier
->video_memory
= min(~(SIZE_T
)0, adapter
->driver_info
.vram_bytes
);
1769 identifier
->shared_system_memory
= min(~(SIZE_T
)0, adapter
->driver_info
.sysmem_bytes
);
1771 wined3d_mutex_unlock();
1776 HRESULT CDECL
wined3d_output_get_raster_status(const struct wined3d_output
*output
,
1777 struct wined3d_raster_status
*raster_status
)
1779 LONGLONG freq_per_frame
, freq_per_line
;
1780 LARGE_INTEGER counter
, freq_per_sec
;
1781 struct wined3d_display_mode mode
;
1785 FIXME("output %p, raster_status %p semi-stub!\n", output
, raster_status
);
1787 WARN("output %p, raster_status %p semi-stub!\n", output
, raster_status
);
1789 /* Obtaining the raster status is a widely implemented but optional
1790 * feature. When this method returns OK StarCraft 2 expects the
1791 * raster_status->InVBlank value to actually change over time.
1792 * And Endless Alice Crysis doesn't care even if this method fails.
1793 * Thus this method returns OK and fakes raster_status by
1794 * QueryPerformanceCounter. */
1796 if (!QueryPerformanceCounter(&counter
) || !QueryPerformanceFrequency(&freq_per_sec
))
1797 return WINED3DERR_INVALIDCALL
;
1798 if (FAILED(wined3d_output_get_display_mode(output
, &mode
, NULL
)))
1799 return WINED3DERR_INVALIDCALL
;
1800 if (mode
.refresh_rate
== DEFAULT_REFRESH_RATE
)
1801 mode
.refresh_rate
= 60;
1803 freq_per_frame
= freq_per_sec
.QuadPart
/ mode
.refresh_rate
;
1804 /* Assume 20 scan lines in the vertical blank. */
1805 freq_per_line
= freq_per_frame
/ (mode
.height
+ 20);
1806 raster_status
->scan_line
= (counter
.QuadPart
% freq_per_frame
) / freq_per_line
;
1807 if (raster_status
->scan_line
< mode
.height
)
1808 raster_status
->in_vblank
= FALSE
;
1811 raster_status
->scan_line
= 0;
1812 raster_status
->in_vblank
= TRUE
;
1815 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
1816 raster_status
->in_vblank
, raster_status
->scan_line
);
1821 HRESULT CDECL
wined3d_check_depth_stencil_match(const struct wined3d_adapter
*adapter
,
1822 enum wined3d_device_type device_type
, enum wined3d_format_id adapter_format_id
,
1823 enum wined3d_format_id render_target_format_id
, enum wined3d_format_id depth_stencil_format_id
)
1825 const struct wined3d_format
*rt_format
;
1826 const struct wined3d_format
*ds_format
;
1828 TRACE("adapter %p, device_type %s, adapter_format %s, render_target_format %s, "
1829 "depth_stencil_format %s.\n",
1830 adapter
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
1831 debug_d3dformat(render_target_format_id
), debug_d3dformat(depth_stencil_format_id
));
1833 rt_format
= wined3d_get_format(adapter
, render_target_format_id
, WINED3D_BIND_RENDER_TARGET
);
1834 ds_format
= wined3d_get_format(adapter
, depth_stencil_format_id
, WINED3D_BIND_DEPTH_STENCIL
);
1836 if (!(rt_format
->caps
[WINED3D_GL_RES_TYPE_TEX_2D
] & WINED3D_FORMAT_CAP_RENDERTARGET
))
1838 WARN("Format %s is not render target format.\n", debug_d3dformat(rt_format
->id
));
1839 return WINED3DERR_NOTAVAILABLE
;
1841 if (!(ds_format
->caps
[WINED3D_GL_RES_TYPE_TEX_2D
] & WINED3D_FORMAT_CAP_DEPTH_STENCIL
))
1843 WARN("Format %s is not depth/stencil format.\n", debug_d3dformat(ds_format
->id
));
1844 return WINED3DERR_NOTAVAILABLE
;
1847 if (adapter
->adapter_ops
->adapter_check_format(adapter
, NULL
, rt_format
, ds_format
))
1849 TRACE("Formats match.\n");
1853 TRACE("Unsupported format pair: %s and %s.\n",
1854 debug_d3dformat(render_target_format_id
),
1855 debug_d3dformat(depth_stencil_format_id
));
1857 return WINED3DERR_NOTAVAILABLE
;
1860 HRESULT CDECL
wined3d_check_device_multisample_type(const struct wined3d_adapter
*adapter
,
1861 enum wined3d_device_type device_type
, enum wined3d_format_id surface_format_id
, BOOL windowed
,
1862 enum wined3d_multisample_type multisample_type
, unsigned int *quality_levels
)
1864 const struct wined3d_format
*format
;
1865 HRESULT hr
= WINED3D_OK
;
1867 TRACE("adapter %p, device_type %s, surface_format %s, "
1868 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
1869 adapter
, debug_d3ddevicetype(device_type
), debug_d3dformat(surface_format_id
),
1870 windowed
, multisample_type
, quality_levels
);
1872 if (surface_format_id
== WINED3DFMT_UNKNOWN
)
1873 return WINED3DERR_INVALIDCALL
;
1874 if (multisample_type
< WINED3D_MULTISAMPLE_NONE
)
1875 return WINED3DERR_INVALIDCALL
;
1876 if (multisample_type
> WINED3D_MULTISAMPLE_16_SAMPLES
)
1878 FIXME("multisample_type %u not handled yet.\n", multisample_type
);
1879 return WINED3DERR_NOTAVAILABLE
;
1882 format
= wined3d_get_format(adapter
, surface_format_id
, 0);
1884 if (multisample_type
&& !(format
->multisample_types
& 1u << (multisample_type
- 1)))
1885 hr
= WINED3DERR_NOTAVAILABLE
;
1887 if (SUCCEEDED(hr
) || (multisample_type
== WINED3D_MULTISAMPLE_NON_MASKABLE
&& format
->multisample_types
))
1891 if (multisample_type
== WINED3D_MULTISAMPLE_NON_MASKABLE
)
1892 *quality_levels
= wined3d_popcount(format
->multisample_types
);
1894 *quality_levels
= 1;
1899 TRACE("Returning not supported.\n");
1903 static BOOL
wined3d_check_depth_stencil_format(const struct wined3d_adapter
*adapter
,
1904 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*ds_format
,
1905 enum wined3d_gl_resource_type gl_type
)
1907 if (!ds_format
->depth_size
&& !ds_format
->stencil_size
)
1910 return adapter
->adapter_ops
->adapter_check_format(adapter
, adapter_format
, NULL
, ds_format
);
1913 static BOOL
wined3d_check_surface_format(const struct wined3d_format
*format
)
1915 if ((format
->caps
[WINED3D_GL_RES_TYPE_TEX_2D
] | format
->caps
[WINED3D_GL_RES_TYPE_RB
])
1916 & WINED3D_FORMAT_CAP_BLIT
)
1919 if ((format
->attrs
& WINED3D_FORMAT_ATTR_EXTENSION
)
1920 && (format
->caps
[WINED3D_GL_RES_TYPE_TEX_2D
] & WINED3D_FORMAT_CAP_TEXTURE
))
1926 /* OpenGL supports mipmapping on all formats. Wrapping is unsupported, but we
1927 * have to report mipmapping so we cannot reject WRAPANDMIP. Tests show that
1928 * Windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to
1929 * show that wrapping is supported. The lack of filtering will sort out the
1930 * mipmapping capability anyway.
1932 * For now lets report this on all formats, but in the future we may want to
1933 * restrict it to some should applications need that. */
1934 HRESULT CDECL
wined3d_check_device_format(const struct wined3d
*wined3d
,
1935 const struct wined3d_adapter
*adapter
, enum wined3d_device_type device_type
,
1936 enum wined3d_format_id adapter_format_id
, DWORD usage
, unsigned int bind_flags
,
1937 enum wined3d_resource_type resource_type
, enum wined3d_format_id check_format_id
)
1939 const struct wined3d_format
*adapter_format
, *format
;
1940 enum wined3d_gl_resource_type gl_type
, gl_type_end
;
1941 unsigned int format_caps
= 0, format_attrs
= 0;
1942 BOOL mipmap_gen_supported
= TRUE
;
1943 unsigned int allowed_bind_flags
;
1944 DWORD allowed_usage
;
1946 TRACE("wined3d %p, adapter %p, device_type %s, adapter_format %s, usage %s, "
1947 "bind_flags %s, resource_type %s, check_format %s.\n",
1948 wined3d
, adapter
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
1949 debug_d3dusage(usage
), wined3d_debug_bind_flags(bind_flags
),
1950 debug_d3dresourcetype(resource_type
), debug_d3dformat(check_format_id
));
1952 adapter_format
= wined3d_get_format(adapter
, adapter_format_id
, WINED3D_BIND_RENDER_TARGET
);
1953 format
= wined3d_get_format(adapter
, check_format_id
, bind_flags
);
1955 switch (resource_type
)
1957 case WINED3D_RTYPE_NONE
:
1959 allowed_bind_flags
= WINED3D_BIND_RENDER_TARGET
1960 | WINED3D_BIND_DEPTH_STENCIL
1961 | WINED3D_BIND_UNORDERED_ACCESS
;
1962 gl_type
= WINED3D_GL_RES_TYPE_TEX_2D
;
1963 gl_type_end
= WINED3D_GL_RES_TYPE_TEX_3D
;
1966 case WINED3D_RTYPE_TEXTURE_1D
:
1967 allowed_usage
= WINED3DUSAGE_DYNAMIC
1968 | WINED3DUSAGE_SOFTWAREPROCESSING
1969 | WINED3DUSAGE_QUERY_FILTER
1970 | WINED3DUSAGE_QUERY_GENMIPMAP
1971 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
1972 | WINED3DUSAGE_QUERY_SRGBREAD
1973 | WINED3DUSAGE_QUERY_SRGBWRITE
1974 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
1975 | WINED3DUSAGE_QUERY_WRAPANDMIP
;
1976 allowed_bind_flags
= WINED3D_BIND_SHADER_RESOURCE
1977 | WINED3D_BIND_UNORDERED_ACCESS
;
1978 gl_type
= gl_type_end
= WINED3D_GL_RES_TYPE_TEX_1D
;
1981 case WINED3D_RTYPE_TEXTURE_2D
:
1982 allowed_usage
= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
1983 if (bind_flags
& WINED3D_BIND_RENDER_TARGET
)
1984 allowed_usage
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
1985 allowed_bind_flags
= WINED3D_BIND_RENDER_TARGET
1986 | WINED3D_BIND_DEPTH_STENCIL
1987 | WINED3D_BIND_UNORDERED_ACCESS
;
1988 gl_type
= gl_type_end
= WINED3D_GL_RES_TYPE_TEX_2D
;
1989 if (!(bind_flags
& WINED3D_BIND_SHADER_RESOURCE
))
1991 if (!wined3d_check_surface_format(format
))
1993 TRACE("%s is not supported for plain surfaces.\n", debug_d3dformat(format
->id
));
1994 return WINED3DERR_NOTAVAILABLE
;
1998 allowed_usage
|= WINED3DUSAGE_DYNAMIC
1999 | WINED3DUSAGE_LEGACY_CUBEMAP
2000 | WINED3DUSAGE_SOFTWAREPROCESSING
2001 | WINED3DUSAGE_QUERY_FILTER
2002 | WINED3DUSAGE_QUERY_GENMIPMAP
2003 | WINED3DUSAGE_QUERY_LEGACYBUMPMAP
2004 | WINED3DUSAGE_QUERY_SRGBREAD
2005 | WINED3DUSAGE_QUERY_SRGBWRITE
2006 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
2007 | WINED3DUSAGE_QUERY_WRAPANDMIP
;
2008 allowed_bind_flags
|= WINED3D_BIND_SHADER_RESOURCE
;
2009 if (usage
& WINED3DUSAGE_LEGACY_CUBEMAP
)
2011 allowed_usage
&= ~WINED3DUSAGE_QUERY_LEGACYBUMPMAP
;
2012 allowed_bind_flags
&= ~WINED3D_BIND_DEPTH_STENCIL
;
2013 gl_type
= gl_type_end
= WINED3D_GL_RES_TYPE_TEX_CUBE
;
2017 case WINED3D_RTYPE_TEXTURE_3D
:
2018 allowed_usage
= WINED3DUSAGE_DYNAMIC
2019 | WINED3DUSAGE_SOFTWAREPROCESSING
2020 | WINED3DUSAGE_QUERY_FILTER
2021 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
2022 | WINED3DUSAGE_QUERY_SRGBREAD
2023 | WINED3DUSAGE_QUERY_SRGBWRITE
2024 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
2025 | WINED3DUSAGE_QUERY_WRAPANDMIP
;
2026 allowed_bind_flags
= WINED3D_BIND_SHADER_RESOURCE
2027 | WINED3D_BIND_UNORDERED_ACCESS
;
2028 gl_type
= gl_type_end
= WINED3D_GL_RES_TYPE_TEX_3D
;
2031 case WINED3D_RTYPE_BUFFER
:
2032 if (wined3d_format_is_typeless(format
))
2034 TRACE("Requested WINED3D_RTYPE_BUFFER, but format %s is typeless.\n", debug_d3dformat(check_format_id
));
2035 return WINED3DERR_NOTAVAILABLE
;
2038 allowed_usage
= WINED3DUSAGE_DYNAMIC
;
2039 allowed_bind_flags
= WINED3D_BIND_SHADER_RESOURCE
2040 | WINED3D_BIND_UNORDERED_ACCESS
2041 | WINED3D_BIND_VERTEX_BUFFER
2042 | WINED3D_BIND_INDEX_BUFFER
;
2043 gl_type
= gl_type_end
= WINED3D_GL_RES_TYPE_BUFFER
;
2047 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type
));
2048 return WINED3DERR_NOTAVAILABLE
;
2051 if ((usage
& allowed_usage
) != usage
)
2053 TRACE("Requested usage %#x, but resource type %s only allows %#x.\n",
2054 usage
, debug_d3dresourcetype(resource_type
), allowed_usage
);
2055 return WINED3DERR_NOTAVAILABLE
;
2058 if ((bind_flags
& allowed_bind_flags
) != bind_flags
)
2060 TRACE("Requested bind flags %s, but resource type %s only allows %s.\n",
2061 wined3d_debug_bind_flags(bind_flags
), debug_d3dresourcetype(resource_type
),
2062 wined3d_debug_bind_flags(allowed_bind_flags
));
2063 return WINED3DERR_NOTAVAILABLE
;
2066 if (bind_flags
& WINED3D_BIND_SHADER_RESOURCE
)
2067 format_caps
|= WINED3D_FORMAT_CAP_TEXTURE
;
2068 if (bind_flags
& WINED3D_BIND_RENDER_TARGET
)
2069 format_caps
|= WINED3D_FORMAT_CAP_RENDERTARGET
;
2070 if (bind_flags
& WINED3D_BIND_DEPTH_STENCIL
)
2071 format_caps
|= WINED3D_FORMAT_CAP_DEPTH_STENCIL
;
2072 if (bind_flags
& WINED3D_BIND_UNORDERED_ACCESS
)
2073 format_caps
|= WINED3D_FORMAT_CAP_UNORDERED_ACCESS
;
2074 if (bind_flags
& WINED3D_BIND_VERTEX_BUFFER
)
2075 format_caps
|= WINED3D_FORMAT_CAP_VERTEX_ATTRIBUTE
;
2076 if (bind_flags
& WINED3D_BIND_INDEX_BUFFER
)
2077 format_caps
|= WINED3D_FORMAT_CAP_INDEX_BUFFER
;
2079 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
2080 format_caps
|= WINED3D_FORMAT_CAP_FILTERING
;
2081 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
2082 format_caps
|= WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING
;
2083 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
2084 format_caps
|= WINED3D_FORMAT_CAP_SRGB_READ
;
2085 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
2086 format_caps
|= WINED3D_FORMAT_CAP_SRGB_WRITE
;
2087 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
2088 format_caps
|= WINED3D_FORMAT_CAP_VTF
;
2089 if (usage
& WINED3DUSAGE_QUERY_LEGACYBUMPMAP
)
2090 format_attrs
|= WINED3D_FORMAT_ATTR_BUMPMAP
;
2092 if ((format_caps
& WINED3D_FORMAT_CAP_TEXTURE
) && (wined3d
->flags
& WINED3D_NO3D
))
2094 TRACE("Requested texturing support, but wined3d was created with WINED3D_NO3D.\n");
2095 return WINED3DERR_NOTAVAILABLE
;
2098 if ((format
->attrs
& format_attrs
) != format_attrs
)
2100 TRACE("Requested format attributes %#x, but format %s only has %#x.\n",
2101 format_attrs
, debug_d3dformat(check_format_id
), format
->attrs
);
2102 return WINED3DERR_NOTAVAILABLE
;
2105 for (; gl_type
<= gl_type_end
; ++gl_type
)
2107 unsigned int caps
= format
->caps
[gl_type
];
2109 if (gl_type
== WINED3D_GL_RES_TYPE_TEX_2D
&& !(bind_flags
& WINED3D_BIND_SHADER_RESOURCE
))
2110 caps
|= format
->caps
[WINED3D_GL_RES_TYPE_RB
];
2112 if ((caps
& format_caps
) != format_caps
)
2114 TRACE("Requested format caps %#x, but format %s only has %#x.\n",
2115 format_caps
, debug_d3dformat(check_format_id
), caps
);
2116 return WINED3DERR_NOTAVAILABLE
;
2119 if ((bind_flags
& WINED3D_BIND_RENDER_TARGET
)
2120 && !adapter
->adapter_ops
->adapter_check_format(adapter
, adapter_format
, format
, NULL
))
2122 TRACE("Requested WINED3D_BIND_RENDER_TARGET, but format %s is not supported for render targets.\n",
2123 debug_d3dformat(check_format_id
));
2124 return WINED3DERR_NOTAVAILABLE
;
2127 /* 3D depth / stencil textures are never supported. */
2128 if (bind_flags
== WINED3D_BIND_DEPTH_STENCIL
&& gl_type
== WINED3D_GL_RES_TYPE_TEX_3D
)
2131 if ((bind_flags
& WINED3D_BIND_DEPTH_STENCIL
)
2132 && !wined3d_check_depth_stencil_format(adapter
, adapter_format
, format
, gl_type
))
2134 TRACE("Requested WINED3D_BIND_DEPTH_STENCIL, but format %s is not supported for depth/stencil buffers.\n",
2135 debug_d3dformat(check_format_id
));
2136 return WINED3DERR_NOTAVAILABLE
;
2139 if ((bind_flags
& WINED3D_BIND_UNORDERED_ACCESS
) && wined3d_format_is_typeless(format
))
2141 TRACE("Requested WINED3D_BIND_UNORDERED_ACCESS, but format %s is typeless.\n",
2142 debug_d3dformat(check_format_id
));
2143 return WINED3DERR_NOTAVAILABLE
;
2146 if (!(caps
& WINED3D_FORMAT_CAP_GEN_MIPMAP
))
2147 mipmap_gen_supported
= FALSE
;
2150 if ((usage
& WINED3DUSAGE_QUERY_GENMIPMAP
) && !mipmap_gen_supported
)
2152 TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
2153 return WINED3DOK_NOMIPGEN
;
2159 unsigned int CDECL
wined3d_calculate_format_pitch(const struct wined3d_adapter
*adapter
,
2160 enum wined3d_format_id format_id
, unsigned int width
)
2162 unsigned int row_pitch
, slice_pitch
;
2164 TRACE("adapter %p, format_id %s, width %u.\n", adapter
, debug_d3dformat(format_id
), width
);
2166 wined3d_format_calculate_pitch(wined3d_get_format(adapter
, format_id
, 0),
2167 1, width
, 1, &row_pitch
, &slice_pitch
);
2172 HRESULT CDECL
wined3d_check_device_format_conversion(const struct wined3d_output
*output
,
2173 enum wined3d_device_type device_type
, enum wined3d_format_id src_format
,
2174 enum wined3d_format_id dst_format
)
2176 FIXME("output %p, device_type %s, src_format %s, dst_format %s stub!\n",
2177 output
, debug_d3ddevicetype(device_type
), debug_d3dformat(src_format
),
2178 debug_d3dformat(dst_format
));
2183 HRESULT CDECL
wined3d_check_device_type(const struct wined3d
*wined3d
,
2184 struct wined3d_output
*output
, enum wined3d_device_type device_type
,
2185 enum wined3d_format_id display_format
, enum wined3d_format_id backbuffer_format
,
2188 BOOL present_conversion
= wined3d
->flags
& WINED3D_PRESENT_CONVERSION
;
2190 TRACE("wined3d %p, output %p, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
2191 wined3d
, output
, debug_d3ddevicetype(device_type
), debug_d3dformat(display_format
),
2192 debug_d3dformat(backbuffer_format
), windowed
);
2194 /* The task of this function is to check whether a certain display / backbuffer format
2195 * combination is available on the given output. In fullscreen mode microsoft specified
2196 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
2197 * and display format should match exactly.
2198 * In windowed mode format conversion can occur and this depends on the driver. */
2200 /* There are only 4 display formats. */
2201 if (!(display_format
== WINED3DFMT_B5G6R5_UNORM
2202 || display_format
== WINED3DFMT_B5G5R5X1_UNORM
2203 || display_format
== WINED3DFMT_B8G8R8X8_UNORM
2204 || display_format
== WINED3DFMT_B10G10R10A2_UNORM
))
2206 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format
));
2207 return WINED3DERR_NOTAVAILABLE
;
2212 /* If the requested display format is not available, don't continue. */
2213 if (!wined3d_output_get_mode_count(output
, display_format
,
2214 WINED3D_SCANLINE_ORDERING_UNKNOWN
, false))
2216 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format
));
2217 return WINED3DERR_NOTAVAILABLE
;
2220 present_conversion
= FALSE
;
2222 else if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
)
2224 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode. */
2225 TRACE("Unsupported format combination %s / %s in windowed mode.\n",
2226 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
2227 return WINED3DERR_NOTAVAILABLE
;
2230 if (present_conversion
)
2232 /* Use the display format as back buffer format if the latter is
2233 * WINED3DFMT_UNKNOWN. */
2234 if (backbuffer_format
== WINED3DFMT_UNKNOWN
)
2235 backbuffer_format
= display_format
;
2237 if (FAILED(wined3d_check_device_format_conversion(output
, device_type
, backbuffer_format
,
2240 TRACE("Format conversion from %s to %s not supported.\n",
2241 debug_d3dformat(backbuffer_format
), debug_d3dformat(display_format
));
2242 return WINED3DERR_NOTAVAILABLE
;
2247 /* When format conversion from the back buffer format to the display
2248 * format is not allowed, only a limited number of combinations are
2251 if (display_format
== WINED3DFMT_B5G6R5_UNORM
&& backbuffer_format
!= WINED3DFMT_B5G6R5_UNORM
)
2253 TRACE("Unsupported format combination %s / %s.\n",
2254 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
2255 return WINED3DERR_NOTAVAILABLE
;
2258 if (display_format
== WINED3DFMT_B5G5R5X1_UNORM
2259 && !(backbuffer_format
== WINED3DFMT_B5G5R5X1_UNORM
|| backbuffer_format
== WINED3DFMT_B5G5R5A1_UNORM
))
2261 TRACE("Unsupported format combination %s / %s.\n",
2262 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
2263 return WINED3DERR_NOTAVAILABLE
;
2266 if (display_format
== WINED3DFMT_B8G8R8X8_UNORM
2267 && !(backbuffer_format
== WINED3DFMT_B8G8R8X8_UNORM
|| backbuffer_format
== WINED3DFMT_B8G8R8A8_UNORM
))
2269 TRACE("Unsupported format combination %s / %s.\n",
2270 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
2271 return WINED3DERR_NOTAVAILABLE
;
2274 if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
2275 && backbuffer_format
!= WINED3DFMT_B10G10R10A2_UNORM
)
2277 TRACE("Unsupported format combination %s / %s.\n",
2278 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
2279 return WINED3DERR_NOTAVAILABLE
;
2283 /* Validate that the back buffer format is usable for render targets. */
2284 if (FAILED(wined3d_check_device_format(wined3d
, output
->adapter
, device_type
,
2285 display_format
, 0, WINED3D_BIND_RENDER_TARGET
, WINED3D_RTYPE_TEXTURE_2D
,
2286 backbuffer_format
)))
2288 TRACE("Format %s not allowed for render targets.\n", debug_d3dformat(backbuffer_format
));
2289 return WINED3DERR_NOTAVAILABLE
;
2295 HRESULT CDECL
wined3d_get_device_caps(const struct wined3d_adapter
*adapter
,
2296 enum wined3d_device_type device_type
, struct wined3d_caps
*caps
)
2298 const struct wined3d_d3d_info
*d3d_info
;
2299 struct wined3d_vertex_caps vertex_caps
;
2300 DWORD ckey_caps
, blit_caps
, fx_caps
;
2301 struct fragment_caps fragment_caps
;
2302 struct shader_caps shader_caps
;
2304 TRACE("adapter %p, device_type %s, caps %p.\n",
2305 adapter
, debug_d3ddevicetype(device_type
), caps
);
2307 d3d_info
= &adapter
->d3d_info
;
2309 caps
->DeviceType
= (device_type
== WINED3D_DEVICE_TYPE_HAL
) ? WINED3D_DEVICE_TYPE_HAL
: WINED3D_DEVICE_TYPE_REF
;
2312 caps
->Caps2
= WINED3DCAPS2_CANRENDERWINDOWED
|
2313 WINED3DCAPS2_FULLSCREENGAMMA
|
2314 WINED3DCAPS2_DYNAMICTEXTURES
;
2316 caps
->Caps3
= WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
2317 WINED3DCAPS3_COPY_TO_VIDMEM
|
2318 WINED3DCAPS3_COPY_TO_SYSTEMMEM
;
2320 caps
->CursorCaps
= WINED3DCURSORCAPS_COLOR
|
2321 WINED3DCURSORCAPS_LOWRES
;
2323 caps
->DevCaps
= WINED3DDEVCAPS_FLOATTLVERTEX
|
2324 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY
|
2325 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
2326 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY
|
2327 WINED3DDEVCAPS_DRAWPRIMTLVERTEX
|
2328 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT
|
2329 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY
|
2330 WINED3DDEVCAPS_PUREDEVICE
|
2331 WINED3DDEVCAPS_HWRASTERIZATION
|
2332 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY
|
2333 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY
|
2334 WINED3DDEVCAPS_CANRENDERAFTERFLIP
|
2335 WINED3DDEVCAPS_DRAWPRIMITIVES2
|
2336 WINED3DDEVCAPS_DRAWPRIMITIVES2EX
;
2338 caps
->PrimitiveMiscCaps
= WINED3DPMISCCAPS_CULLNONE
|
2339 WINED3DPMISCCAPS_CULLCCW
|
2340 WINED3DPMISCCAPS_CULLCW
|
2341 WINED3DPMISCCAPS_COLORWRITEENABLE
|
2342 WINED3DPMISCCAPS_CLIPTLVERTS
|
2343 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
2344 WINED3DPMISCCAPS_MASKZ
|
2345 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
;
2347 WINED3DPMISCCAPS_NULLREFERENCE
2348 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
2349 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
2351 caps
->RasterCaps
= WINED3DPRASTERCAPS_DITHER
|
2352 WINED3DPRASTERCAPS_PAT
|
2353 WINED3DPRASTERCAPS_WFOG
|
2354 WINED3DPRASTERCAPS_ZFOG
|
2355 WINED3DPRASTERCAPS_FOGVERTEX
|
2356 WINED3DPRASTERCAPS_FOGTABLE
|
2357 WINED3DPRASTERCAPS_STIPPLE
|
2358 WINED3DPRASTERCAPS_SUBPIXEL
|
2359 WINED3DPRASTERCAPS_ZTEST
|
2360 WINED3DPRASTERCAPS_SCISSORTEST
|
2361 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
2362 WINED3DPRASTERCAPS_DEPTHBIAS
;
2364 caps
->ZCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
2365 WINED3DPCMPCAPS_EQUAL
|
2366 WINED3DPCMPCAPS_GREATER
|
2367 WINED3DPCMPCAPS_GREATEREQUAL
|
2368 WINED3DPCMPCAPS_LESS
|
2369 WINED3DPCMPCAPS_LESSEQUAL
|
2370 WINED3DPCMPCAPS_NEVER
|
2371 WINED3DPCMPCAPS_NOTEQUAL
;
2373 /* WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA
2374 * are legacy settings for srcblend only. */
2375 caps
->SrcBlendCaps
= WINED3DPBLENDCAPS_BOTHINVSRCALPHA
|
2376 WINED3DPBLENDCAPS_BOTHSRCALPHA
|
2377 WINED3DPBLENDCAPS_DESTALPHA
|
2378 WINED3DPBLENDCAPS_DESTCOLOR
|
2379 WINED3DPBLENDCAPS_INVDESTALPHA
|
2380 WINED3DPBLENDCAPS_INVDESTCOLOR
|
2381 WINED3DPBLENDCAPS_INVSRCALPHA
|
2382 WINED3DPBLENDCAPS_INVSRCCOLOR
|
2383 WINED3DPBLENDCAPS_ONE
|
2384 WINED3DPBLENDCAPS_SRCALPHA
|
2385 WINED3DPBLENDCAPS_SRCALPHASAT
|
2386 WINED3DPBLENDCAPS_SRCCOLOR
|
2387 WINED3DPBLENDCAPS_ZERO
;
2389 caps
->DestBlendCaps
= WINED3DPBLENDCAPS_DESTALPHA
|
2390 WINED3DPBLENDCAPS_DESTCOLOR
|
2391 WINED3DPBLENDCAPS_INVDESTALPHA
|
2392 WINED3DPBLENDCAPS_INVDESTCOLOR
|
2393 WINED3DPBLENDCAPS_INVSRCALPHA
|
2394 WINED3DPBLENDCAPS_INVSRCCOLOR
|
2395 WINED3DPBLENDCAPS_ONE
|
2396 WINED3DPBLENDCAPS_SRCALPHA
|
2397 WINED3DPBLENDCAPS_SRCCOLOR
|
2398 WINED3DPBLENDCAPS_ZERO
;
2400 caps
->AlphaCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
2401 WINED3DPCMPCAPS_EQUAL
|
2402 WINED3DPCMPCAPS_GREATER
|
2403 WINED3DPCMPCAPS_GREATEREQUAL
|
2404 WINED3DPCMPCAPS_LESS
|
2405 WINED3DPCMPCAPS_LESSEQUAL
|
2406 WINED3DPCMPCAPS_NEVER
|
2407 WINED3DPCMPCAPS_NOTEQUAL
;
2409 caps
->ShadeCaps
= WINED3DPSHADECAPS_SPECULARGOURAUDRGB
|
2410 WINED3DPSHADECAPS_COLORGOURAUDRGB
|
2411 WINED3DPSHADECAPS_ALPHAFLATBLEND
|
2412 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND
|
2413 WINED3DPSHADECAPS_COLORFLATRGB
|
2414 WINED3DPSHADECAPS_FOGFLAT
|
2415 WINED3DPSHADECAPS_FOGGOURAUD
|
2416 WINED3DPSHADECAPS_SPECULARFLATRGB
;
2418 caps
->TextureCaps
= WINED3DPTEXTURECAPS_ALPHA
|
2419 WINED3DPTEXTURECAPS_ALPHAPALETTE
|
2420 WINED3DPTEXTURECAPS_TRANSPARENCY
|
2421 WINED3DPTEXTURECAPS_BORDER
|
2422 WINED3DPTEXTURECAPS_MIPMAP
|
2423 WINED3DPTEXTURECAPS_PROJECTED
|
2424 WINED3DPTEXTURECAPS_PERSPECTIVE
;
2426 if (!d3d_info
->texture_npot
)
2428 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_POW2
;
2429 if (d3d_info
->texture_npot_conditional
)
2430 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL
;
2433 caps
->TextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
2434 WINED3DPTFILTERCAPS_MAGFPOINT
|
2435 WINED3DPTFILTERCAPS_MINFLINEAR
|
2436 WINED3DPTFILTERCAPS_MINFPOINT
|
2437 WINED3DPTFILTERCAPS_MIPFLINEAR
|
2438 WINED3DPTFILTERCAPS_MIPFPOINT
|
2439 WINED3DPTFILTERCAPS_LINEAR
|
2440 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
2441 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
2442 WINED3DPTFILTERCAPS_MIPLINEAR
|
2443 WINED3DPTFILTERCAPS_MIPNEAREST
|
2444 WINED3DPTFILTERCAPS_NEAREST
;
2446 caps
->CubeTextureFilterCaps
= 0;
2447 caps
->VolumeTextureFilterCaps
= 0;
2449 caps
->TextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
2450 WINED3DPTADDRESSCAPS_CLAMP
|
2451 WINED3DPTADDRESSCAPS_WRAP
;
2453 caps
->VolumeTextureAddressCaps
= 0;
2455 caps
->LineCaps
= WINED3DLINECAPS_TEXTURE
|
2456 WINED3DLINECAPS_ZTEST
|
2457 WINED3DLINECAPS_BLEND
|
2458 WINED3DLINECAPS_ALPHACMP
|
2459 WINED3DLINECAPS_FOG
;
2460 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
2461 * idea how generating the smoothing alpha values works; the result is different
2464 caps
->MaxTextureWidth
= d3d_info
->limits
.texture_size
;
2465 caps
->MaxTextureHeight
= d3d_info
->limits
.texture_size
;
2467 caps
->MaxVolumeExtent
= 0;
2469 caps
->MaxTextureRepeat
= 32768;
2470 caps
->MaxTextureAspectRatio
= d3d_info
->limits
.texture_size
;
2471 caps
->MaxVertexW
= 1e10f
;
2473 caps
->GuardBandLeft
= -32768.0f
;
2474 caps
->GuardBandTop
= -32768.0f
;
2475 caps
->GuardBandRight
= 32768.0f
;
2476 caps
->GuardBandBottom
= 32768.0f
;
2478 caps
->ExtentsAdjust
= 0.0f
;
2480 caps
->StencilCaps
= WINED3DSTENCILCAPS_DECRSAT
|
2481 WINED3DSTENCILCAPS_INCRSAT
|
2482 WINED3DSTENCILCAPS_INVERT
|
2483 WINED3DSTENCILCAPS_KEEP
|
2484 WINED3DSTENCILCAPS_REPLACE
|
2485 WINED3DSTENCILCAPS_ZERO
;
2487 caps
->MaxAnisotropy
= 0;
2488 caps
->MaxPointSize
= d3d_info
->limits
.pointsize_max
;
2490 caps
->MaxPrimitiveCount
= 0x555555; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
2491 caps
->MaxVertexIndex
= 0xffffff; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
2492 caps
->MaxStreams
= WINED3D_MAX_STREAMS
;
2493 caps
->MaxStreamStride
= 1024;
2495 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
2496 caps
->DevCaps2
= WINED3DDEVCAPS2_STREAMOFFSET
|
2497 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
;
2498 caps
->MaxNpatchTessellationLevel
= 0;
2500 caps
->NumSimultaneousRTs
= d3d_info
->limits
.max_rt_count
;
2502 caps
->StretchRectFilterCaps
= WINED3DPTFILTERCAPS_MINFPOINT
|
2503 WINED3DPTFILTERCAPS_MAGFPOINT
|
2504 WINED3DPTFILTERCAPS_MINFLINEAR
|
2505 WINED3DPTFILTERCAPS_MAGFLINEAR
;
2506 caps
->VertexTextureFilterCaps
= 0;
2508 adapter
->shader_backend
->shader_get_caps(adapter
, &shader_caps
);
2509 adapter
->fragment_pipe
->get_caps(adapter
, &fragment_caps
);
2510 adapter
->vertex_pipe
->vp_get_caps(adapter
, &vertex_caps
);
2512 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
2513 caps
->PrimitiveMiscCaps
|= fragment_caps
.PrimitiveMiscCaps
;
2515 caps
->VertexShaderVersion
= shader_caps
.vs_version
;
2516 caps
->MaxVertexShaderConst
= shader_caps
.vs_uniform_count
;
2518 caps
->PixelShaderVersion
= shader_caps
.ps_version
;
2519 caps
->PixelShader1xMaxValue
= shader_caps
.ps_1x_max_value
;
2521 caps
->TextureOpCaps
= fragment_caps
.TextureOpCaps
;
2522 caps
->MaxTextureBlendStages
= fragment_caps
.MaxTextureBlendStages
;
2523 caps
->MaxSimultaneousTextures
= fragment_caps
.MaxSimultaneousTextures
;
2525 caps
->MaxUserClipPlanes
= vertex_caps
.max_user_clip_planes
;
2526 caps
->MaxActiveLights
= vertex_caps
.max_active_lights
;
2527 caps
->MaxVertexBlendMatrices
= vertex_caps
.max_vertex_blend_matrices
;
2528 caps
->MaxVertexBlendMatrixIndex
= vertex_caps
.max_vertex_blend_matrix_index
;
2529 caps
->VertexProcessingCaps
= vertex_caps
.vertex_processing_caps
;
2530 caps
->FVFCaps
= vertex_caps
.fvf_caps
;
2531 caps
->RasterCaps
|= vertex_caps
.raster_caps
;
2533 /* The following caps are shader specific, but they are things we cannot detect, or which
2534 * are the same among all shader models. So to avoid code duplication set the shader version
2535 * specific, but otherwise constant caps here
2537 if (caps
->VertexShaderVersion
>= 3)
2539 /* Where possible set the caps based on OpenGL extensions and if they
2540 * aren't set (in case of software rendering) use the VS 3.0 from
2541 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
2543 caps
->VS20Caps
.caps
= WINED3DVS20CAPS_PREDICATION
;
2544 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
2545 caps
->VS20Caps
.dynamic_flow_control_depth
= WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
2546 caps
->VS20Caps
.temp_count
= 32;
2547 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
2548 caps
->VS20Caps
.static_flow_control_depth
= WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
2550 caps
->MaxVShaderInstructionsExecuted
= 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
2551 caps
->MaxVertexShader30InstructionSlots
= WINED3DMIN30SHADERINSTRUCTIONS
;
2552 caps
->VertexTextureFilterCaps
= WINED3DPTFILTERCAPS_MINFPOINT
| WINED3DPTFILTERCAPS_MAGFPOINT
;
2554 else if (caps
->VertexShaderVersion
== 2)
2556 caps
->VS20Caps
.caps
= 0;
2557 caps
->VS20Caps
.dynamic_flow_control_depth
= WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
;
2558 caps
->VS20Caps
.temp_count
= WINED3DVS20_MIN_NUMTEMPS
;
2559 caps
->VS20Caps
.static_flow_control_depth
= 1;
2561 caps
->MaxVShaderInstructionsExecuted
= 65535;
2562 caps
->MaxVertexShader30InstructionSlots
= 0;
2566 caps
->VS20Caps
.caps
= 0;
2567 caps
->VS20Caps
.dynamic_flow_control_depth
= 0;
2568 caps
->VS20Caps
.temp_count
= 0;
2569 caps
->VS20Caps
.static_flow_control_depth
= 0;
2571 caps
->MaxVShaderInstructionsExecuted
= 0;
2572 caps
->MaxVertexShader30InstructionSlots
= 0;
2575 if (caps
->PixelShaderVersion
>= 3)
2577 /* Where possible set the caps based on OpenGL extensions and if they
2578 * aren't set (in case of software rendering) use the PS 3.0 from
2579 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
2582 /* Caps is more or less undocumented on MSDN but it appears to be
2583 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
2584 * cards from Windows */
2585 caps
->PS20Caps
.caps
= WINED3DPS20CAPS_ARBITRARYSWIZZLE
|
2586 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS
|
2587 WINED3DPS20CAPS_PREDICATION
|
2588 WINED3DPS20CAPS_NODEPENDENTREADLIMIT
|
2589 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
2590 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
2591 caps
->PS20Caps
.dynamic_flow_control_depth
= WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
2592 caps
->PS20Caps
.temp_count
= 32;
2593 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
2594 caps
->PS20Caps
.static_flow_control_depth
= WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
2595 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
2596 caps
->PS20Caps
.instruction_slot_count
= WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
2598 caps
->MaxPShaderInstructionsExecuted
= 65535;
2599 caps
->MaxPixelShader30InstructionSlots
= WINED3DMIN30SHADERINSTRUCTIONS
;
2601 else if (caps
->PixelShaderVersion
== 2)
2603 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
2604 caps
->PS20Caps
.caps
= 0;
2605 caps
->PS20Caps
.dynamic_flow_control_depth
= 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
2606 caps
->PS20Caps
.temp_count
= WINED3DPS20_MIN_NUMTEMPS
;
2607 caps
->PS20Caps
.static_flow_control_depth
= WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH
; /* Minimum: 1 */
2608 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
2609 caps
->PS20Caps
.instruction_slot_count
= WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS
;
2611 caps
->MaxPShaderInstructionsExecuted
= 512; /* Minimum value, a GeforceFX uses 1024 */
2612 caps
->MaxPixelShader30InstructionSlots
= 0;
2616 caps
->PS20Caps
.caps
= 0;
2617 caps
->PS20Caps
.dynamic_flow_control_depth
= 0;
2618 caps
->PS20Caps
.temp_count
= 0;
2619 caps
->PS20Caps
.static_flow_control_depth
= 0;
2620 caps
->PS20Caps
.instruction_slot_count
= 0;
2622 caps
->MaxPShaderInstructionsExecuted
= 0;
2623 caps
->MaxPixelShader30InstructionSlots
= 0;
2626 if (caps
->VertexShaderVersion
>= 2)
2628 /* OpenGL supports all the formats below, perhaps not always
2629 * without conversion, but it supports them.
2630 * Further GLSL doesn't seem to have an official unsigned type so
2631 * don't advertise it yet as I'm not sure how we handle it.
2632 * We might need to add some clamping in the shader engine to
2634 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
2635 caps
->DeclTypes
= WINED3DDTCAPS_UBYTE4
|
2636 WINED3DDTCAPS_UBYTE4N
|
2637 WINED3DDTCAPS_SHORT2N
|
2638 WINED3DDTCAPS_SHORT4N
;
2642 caps
->DeclTypes
= 0;
2645 /* Set DirectDraw helper Caps */
2646 ckey_caps
= WINEDDCKEYCAPS_DESTBLT
|
2647 WINEDDCKEYCAPS_SRCBLT
;
2648 fx_caps
= WINEDDFXCAPS_BLTALPHA
|
2649 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT
|
2650 WINEDDFXCAPS_BLTMIRRORUPDOWN
|
2651 WINEDDFXCAPS_BLTROTATION90
|
2652 WINEDDFXCAPS_BLTSHRINKX
|
2653 WINEDDFXCAPS_BLTSHRINKXN
|
2654 WINEDDFXCAPS_BLTSHRINKY
|
2655 WINEDDFXCAPS_BLTSHRINKYN
|
2656 WINEDDFXCAPS_BLTSTRETCHX
|
2657 WINEDDFXCAPS_BLTSTRETCHXN
|
2658 WINEDDFXCAPS_BLTSTRETCHY
|
2659 WINEDDFXCAPS_BLTSTRETCHYN
;
2660 blit_caps
= WINEDDCAPS_BLT
|
2661 WINEDDCAPS_BLTCOLORFILL
|
2662 WINEDDCAPS_BLTDEPTHFILL
|
2663 WINEDDCAPS_BLTSTRETCH
|
2664 WINEDDCAPS_CANBLTSYSMEM
|
2665 WINEDDCAPS_CANCLIP
|
2666 WINEDDCAPS_CANCLIPSTRETCHED
|
2667 WINEDDCAPS_COLORKEY
|
2668 WINEDDCAPS_COLORKEYHWASSIST
;
2670 /* Fill the ddraw caps structure */
2671 caps
->ddraw_caps
.caps
= WINEDDCAPS_GDI
|
2672 WINEDDCAPS_PALETTE
|
2674 caps
->ddraw_caps
.caps2
= WINEDDCAPS2_CERTIFIED
|
2675 WINEDDCAPS2_NOPAGELOCKREQUIRED
|
2676 WINEDDCAPS2_PRIMARYGAMMA
|
2677 WINEDDCAPS2_WIDESURFACES
|
2678 WINEDDCAPS2_CANRENDERWINDOWED
;
2679 caps
->ddraw_caps
.color_key_caps
= ckey_caps
;
2680 caps
->ddraw_caps
.fx_caps
= fx_caps
;
2681 caps
->ddraw_caps
.svb_caps
= blit_caps
;
2682 caps
->ddraw_caps
.svb_color_key_caps
= ckey_caps
;
2683 caps
->ddraw_caps
.svb_fx_caps
= fx_caps
;
2684 caps
->ddraw_caps
.vsb_caps
= blit_caps
;
2685 caps
->ddraw_caps
.vsb_color_key_caps
= ckey_caps
;
2686 caps
->ddraw_caps
.vsb_fx_caps
= fx_caps
;
2687 caps
->ddraw_caps
.ssb_caps
= blit_caps
;
2688 caps
->ddraw_caps
.ssb_color_key_caps
= ckey_caps
;
2689 caps
->ddraw_caps
.ssb_fx_caps
= fx_caps
;
2691 caps
->ddraw_caps
.dds_caps
= WINEDDSCAPS_FLIP
2692 | WINEDDSCAPS_OFFSCREENPLAIN
2693 | WINEDDSCAPS_PALETTE
2694 | WINEDDSCAPS_PRIMARYSURFACE
2695 | WINEDDSCAPS_TEXTURE
2696 | WINEDDSCAPS_ZBUFFER
2697 | WINEDDSCAPS_MIPMAP
;
2699 caps
->shader_double_precision
= d3d_info
->shader_double_precision
;
2700 caps
->viewport_array_index_any_shader
= d3d_info
->viewport_array_index_any_shader
;
2702 caps
->max_feature_level
= d3d_info
->feature_level
;
2704 adapter
->adapter_ops
->adapter_get_wined3d_caps(adapter
, caps
);
2709 HRESULT CDECL
wined3d_device_create(struct wined3d
*wined3d
, struct wined3d_adapter
*adapter
,
2710 enum wined3d_device_type device_type
, HWND focus_window
, DWORD flags
, BYTE surface_alignment
,
2711 const enum wined3d_feature_level
*feature_levels
, unsigned int feature_level_count
,
2712 struct wined3d_device_parent
*device_parent
, struct wined3d_device
**device
)
2714 struct wined3d_device
*object
;
2717 TRACE("wined3d %p, adapter %p, device_type %#x, focus_window %p, flags %#x, "
2718 "surface_alignment %u, feature_levels %p, feature_level_count %u, device_parent %p, device %p.\n",
2719 wined3d
, adapter
, device_type
, focus_window
, flags
, surface_alignment
,
2720 feature_levels
, feature_level_count
, device_parent
, device
);
2722 if (FAILED(hr
= adapter
->adapter_ops
->adapter_create_device(wined3d
, adapter
,
2723 device_type
, focus_window
, flags
, surface_alignment
,
2724 feature_levels
, feature_level_count
, device_parent
, &object
)))
2727 TRACE("Created device %p.\n", object
);
2730 device_parent
->ops
->wined3d_device_created(device_parent
, *device
);
2735 static const struct wined3d_state_entry_template misc_state_template_no3d
[] =
2737 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), {STATE_VDECL
}},
2738 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
), {STATE_VDECL
}},
2739 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
), {STATE_VDECL
}},
2740 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
), {STATE_VDECL
}},
2741 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), {STATE_VDECL
}},
2742 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), {STATE_VDECL
}},
2743 {STATE_GRAPHICS_SHADER_RESOURCE_BINDING
, {STATE_VDECL
}},
2744 {STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
, {STATE_VDECL
}},
2745 {STATE_COMPUTE_SHADER_RESOURCE_BINDING
, {STATE_VDECL
}},
2746 {STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
, {STATE_VDECL
}},
2747 {STATE_STREAM_OUTPUT
, {STATE_VDECL
}},
2748 {STATE_BLEND
, {STATE_VDECL
}},
2749 {STATE_BLEND_FACTOR
, {STATE_VDECL
}},
2750 {STATE_SAMPLE_MASK
, {STATE_VDECL
}},
2751 {STATE_DEPTH_STENCIL
, {STATE_VDECL
}},
2752 {STATE_STENCIL_REF
, {STATE_VDECL
}},
2753 {STATE_STREAMSRC
, {STATE_VDECL
}},
2754 {STATE_VDECL
, {STATE_VDECL
, state_nop
}},
2755 {STATE_RASTERIZER
, {STATE_VDECL
}},
2756 {STATE_SCISSORRECT
, {STATE_VDECL
}},
2757 {STATE_POINTSPRITECOORDORIGIN
, {STATE_VDECL
}},
2759 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), {STATE_VDECL
}},
2760 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01
), {STATE_VDECL
}},
2761 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10
), {STATE_VDECL
}},
2762 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11
), {STATE_VDECL
}},
2763 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), {STATE_VDECL
}},
2764 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01
), {STATE_VDECL
}},
2765 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10
), {STATE_VDECL
}},
2766 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11
), {STATE_VDECL
}},
2767 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), {STATE_VDECL
}},
2768 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01
), {STATE_VDECL
}},
2769 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10
), {STATE_VDECL
}},
2770 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11
), {STATE_VDECL
}},
2771 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), {STATE_VDECL
}},
2772 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01
), {STATE_VDECL
}},
2773 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10
), {STATE_VDECL
}},
2774 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11
), {STATE_VDECL
}},
2775 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), {STATE_VDECL
}},
2776 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01
), {STATE_VDECL
}},
2777 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10
), {STATE_VDECL
}},
2778 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11
), {STATE_VDECL
}},
2779 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), {STATE_VDECL
}},
2780 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01
), {STATE_VDECL
}},
2781 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10
), {STATE_VDECL
}},
2782 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11
), {STATE_VDECL
}},
2783 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), {STATE_VDECL
}},
2784 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01
), {STATE_VDECL
}},
2785 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10
), {STATE_VDECL
}},
2786 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11
), {STATE_VDECL
}},
2787 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), {STATE_VDECL
}},
2788 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01
), {STATE_VDECL
}},
2789 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10
), {STATE_VDECL
}},
2790 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11
), {STATE_VDECL
}},
2791 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), {STATE_VDECL
}},
2792 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LOFFSET
), {STATE_VDECL
}},
2793 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), {STATE_VDECL
}},
2794 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LOFFSET
), {STATE_VDECL
}},
2795 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), {STATE_VDECL
}},
2796 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LOFFSET
), {STATE_VDECL
}},
2797 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), {STATE_VDECL
}},
2798 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LOFFSET
), {STATE_VDECL
}},
2799 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), {STATE_VDECL
}},
2800 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LOFFSET
), {STATE_VDECL
}},
2801 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), {STATE_VDECL
}},
2802 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LOFFSET
), {STATE_VDECL
}},
2803 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), {STATE_VDECL
}},
2804 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LOFFSET
), {STATE_VDECL
}},
2805 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), {STATE_VDECL
}},
2806 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LOFFSET
), {STATE_VDECL
}},
2808 {STATE_VIEWPORT
, {STATE_VDECL
}},
2809 {STATE_INDEXBUFFER
, {STATE_VDECL
}},
2810 {STATE_RENDER(WINED3D_RS_ANTIALIAS
), {STATE_VDECL
}},
2811 {STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), {STATE_VDECL
}},
2812 {STATE_RENDER(WINED3D_RS_WRAPU
), {STATE_VDECL
}},
2813 {STATE_RENDER(WINED3D_RS_WRAPV
), {STATE_VDECL
}},
2814 {STATE_RENDER(WINED3D_RS_LINEPATTERN
), {STATE_VDECL
}},
2815 {STATE_RENDER(WINED3D_RS_MONOENABLE
), {STATE_VDECL
}},
2816 {STATE_RENDER(WINED3D_RS_ROP2
), {STATE_VDECL
}},
2817 {STATE_RENDER(WINED3D_RS_PLANEMASK
), {STATE_VDECL
}},
2818 {STATE_RENDER(WINED3D_RS_LASTPIXEL
), {STATE_VDECL
}},
2819 {STATE_RENDER(WINED3D_RS_ZFUNC
), {STATE_VDECL
}},
2820 {STATE_RENDER(WINED3D_RS_DITHERENABLE
), {STATE_VDECL
}},
2821 {STATE_RENDER(WINED3D_RS_SUBPIXEL
), {STATE_VDECL
}},
2822 {STATE_RENDER(WINED3D_RS_SUBPIXELX
), {STATE_VDECL
}},
2823 {STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), {STATE_VDECL
}},
2824 {STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), {STATE_VDECL
}},
2825 {STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), {STATE_VDECL
}},
2826 {STATE_RENDER(WINED3D_RS_ANISOTROPY
), {STATE_VDECL
}},
2827 {STATE_RENDER(WINED3D_RS_FLUSHBATCH
), {STATE_VDECL
}},
2828 {STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
), {STATE_VDECL
}},
2829 {STATE_RENDER(WINED3D_RS_WRAP0
), {STATE_VDECL
}},
2830 {STATE_RENDER(WINED3D_RS_WRAP1
), {STATE_VDECL
}},
2831 {STATE_RENDER(WINED3D_RS_WRAP2
), {STATE_VDECL
}},
2832 {STATE_RENDER(WINED3D_RS_WRAP3
), {STATE_VDECL
}},
2833 {STATE_RENDER(WINED3D_RS_WRAP4
), {STATE_VDECL
}},
2834 {STATE_RENDER(WINED3D_RS_WRAP5
), {STATE_VDECL
}},
2835 {STATE_RENDER(WINED3D_RS_WRAP6
), {STATE_VDECL
}},
2836 {STATE_RENDER(WINED3D_RS_WRAP7
), {STATE_VDECL
}},
2837 {STATE_RENDER(WINED3D_RS_WRAP8
), {STATE_VDECL
}},
2838 {STATE_RENDER(WINED3D_RS_WRAP9
), {STATE_VDECL
}},
2839 {STATE_RENDER(WINED3D_RS_WRAP10
), {STATE_VDECL
}},
2840 {STATE_RENDER(WINED3D_RS_WRAP11
), {STATE_VDECL
}},
2841 {STATE_RENDER(WINED3D_RS_WRAP12
), {STATE_VDECL
}},
2842 {STATE_RENDER(WINED3D_RS_WRAP13
), {STATE_VDECL
}},
2843 {STATE_RENDER(WINED3D_RS_WRAP14
), {STATE_VDECL
}},
2844 {STATE_RENDER(WINED3D_RS_WRAP15
), {STATE_VDECL
}},
2845 {STATE_RENDER(WINED3D_RS_EXTENTS
), {STATE_VDECL
}},
2846 {STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), {STATE_VDECL
}},
2847 {STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), {STATE_VDECL
}},
2848 {STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), {STATE_VDECL
}},
2849 {STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), {STATE_VDECL
}},
2850 {STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), {STATE_VDECL
}},
2851 {STATE_RENDER(WINED3D_RS_NORMALDEGREE
), {STATE_VDECL
}},
2852 {STATE_RENDER(WINED3D_RS_MINTESSELLATIONLEVEL
), {STATE_VDECL
}},
2853 {STATE_RENDER(WINED3D_RS_MAXTESSELLATIONLEVEL
), {STATE_VDECL
}},
2854 {STATE_RENDER(WINED3D_RS_ADAPTIVETESS_X
), {STATE_VDECL
}},
2855 {STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y
), {STATE_VDECL
}},
2856 {STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Z
), {STATE_VDECL
}},
2857 {STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W
), {STATE_VDECL
}},
2858 {STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
), {STATE_VDECL
}},
2859 {STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), {STATE_VDECL
}},
2860 {STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), {STATE_VDECL
}},
2861 {STATE_RENDER(WINED3D_RS_ZVISIBLE
), {STATE_VDECL
}},
2863 {STATE_SAMPLER(0), {STATE_VDECL
}},
2864 {STATE_SAMPLER(1), {STATE_VDECL
}},
2865 {STATE_SAMPLER(2), {STATE_VDECL
}},
2866 {STATE_SAMPLER(3), {STATE_VDECL
}},
2867 {STATE_SAMPLER(4), {STATE_VDECL
}},
2868 {STATE_SAMPLER(5), {STATE_VDECL
}},
2869 {STATE_SAMPLER(6), {STATE_VDECL
}},
2870 {STATE_SAMPLER(7), {STATE_VDECL
}},
2871 {STATE_SAMPLER(8), {STATE_VDECL
}},
2872 {STATE_SAMPLER(9), {STATE_VDECL
}},
2873 {STATE_SAMPLER(10), {STATE_VDECL
}},
2874 {STATE_SAMPLER(11), {STATE_VDECL
}},
2875 {STATE_SAMPLER(12), {STATE_VDECL
}},
2876 {STATE_SAMPLER(13), {STATE_VDECL
}},
2877 {STATE_SAMPLER(14), {STATE_VDECL
}},
2878 {STATE_SAMPLER(15), {STATE_VDECL
}},
2879 {STATE_SAMPLER(16), /* Vertex sampler 0 */ {STATE_VDECL
}},
2880 {STATE_SAMPLER(17), /* Vertex sampler 1 */ {STATE_VDECL
}},
2881 {STATE_SAMPLER(18), /* Vertex sampler 2 */ {STATE_VDECL
}},
2882 {STATE_SAMPLER(19), /* Vertex sampler 3 */ {STATE_VDECL
}},
2883 {STATE_BASEVERTEXINDEX
, {STATE_VDECL
}},
2884 {STATE_FRAMEBUFFER
, {STATE_VDECL
}},
2885 {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), {STATE_VDECL
}},
2886 {STATE_SHADER(WINED3D_SHADER_TYPE_HULL
), {STATE_VDECL
}},
2887 {STATE_SHADER(WINED3D_SHADER_TYPE_DOMAIN
), {STATE_VDECL
}},
2888 {STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), {STATE_VDECL
}},
2889 {STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
), {STATE_VDECL
}},
2890 {0}, /* Terminate */
2893 static void adapter_no3d_destroy(struct wined3d_adapter
*adapter
)
2895 wined3d_adapter_cleanup(adapter
);
2899 static HRESULT
adapter_no3d_create_device(struct wined3d
*wined3d
, const struct wined3d_adapter
*adapter
,
2900 enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
, BYTE surface_alignment
,
2901 const enum wined3d_feature_level
*levels
, unsigned int level_count
,
2902 struct wined3d_device_parent
*device_parent
, struct wined3d_device
**device
)
2904 struct wined3d_device_no3d
*device_no3d
;
2907 if (!(device_no3d
= heap_alloc_zero(sizeof(*device_no3d
))))
2908 return E_OUTOFMEMORY
;
2910 if (FAILED(hr
= wined3d_device_init(&device_no3d
->d
, wined3d
, adapter
->ordinal
, device_type
, focus_window
,
2911 flags
, surface_alignment
, levels
, level_count
, adapter
->gl_info
.supported
, device_parent
)))
2913 WARN("Failed to initialize device, hr %#x.\n", hr
);
2914 heap_free(device_no3d
);
2918 *device
= &device_no3d
->d
;
2923 static void adapter_no3d_destroy_device(struct wined3d_device
*device
)
2925 wined3d_device_cleanup(device
);
2929 static struct wined3d_context
*adapter_no3d_acquire_context(struct wined3d_device
*device
,
2930 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
)
2932 TRACE("device %p, texture %p, sub_resource_idx %u.\n", device
, texture
, sub_resource_idx
);
2934 wined3d_from_cs(device
->cs
);
2936 if (!device
->context_count
)
2939 return &wined3d_device_no3d(device
)->context_no3d
;
2942 static void adapter_no3d_release_context(struct wined3d_context
*context
)
2944 TRACE("context %p.\n", context
);
2947 static void adapter_no3d_get_wined3d_caps(const struct wined3d_adapter
*adapter
, struct wined3d_caps
*caps
)
2951 static BOOL
adapter_no3d_check_format(const struct wined3d_adapter
*adapter
,
2952 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*rt_format
,
2953 const struct wined3d_format
*ds_format
)
2958 static HRESULT
adapter_no3d_init_3d(struct wined3d_device
*device
)
2960 struct wined3d_context
*context_no3d
;
2963 TRACE("device %p.\n", device
);
2965 context_no3d
= &wined3d_device_no3d(device
)->context_no3d
;
2966 if (FAILED(hr
= wined3d_context_no3d_init(context_no3d
, device
->swapchains
[0])))
2968 WARN("Failed to initialise context.\n");
2972 if (!device_context_add(device
, context_no3d
))
2974 ERR("Failed to add the newly created context to the context list.\n");
2975 wined3d_context_cleanup(context_no3d
);
2979 TRACE("Initialised context %p.\n", context_no3d
);
2981 if (!(device
->blitter
= wined3d_cpu_blitter_create()))
2983 ERR("Failed to create CPU blitter.\n");
2984 device_context_remove(device
, context_no3d
);
2985 wined3d_context_cleanup(context_no3d
);
2992 static void adapter_no3d_uninit_3d(struct wined3d_device
*device
)
2994 struct wined3d_context
*context_no3d
;
2996 TRACE("device %p.\n", device
);
2998 context_no3d
= &wined3d_device_no3d(device
)->context_no3d
;
2999 device
->blitter
->ops
->blitter_destroy(device
->blitter
, NULL
);
3000 wined3d_cs_finish(device
->cs
, WINED3D_CS_QUEUE_DEFAULT
);
3002 device_context_remove(device
, context_no3d
);
3003 wined3d_context_cleanup(context_no3d
);
3006 static void *adapter_no3d_map_bo_address(struct wined3d_context
*context
,
3007 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
)
3009 if (data
->buffer_object
)
3011 ERR("Unsupported buffer object %p.\n", data
->buffer_object
);
3018 static void adapter_no3d_unmap_bo_address(struct wined3d_context
*context
,
3019 const struct wined3d_bo_address
*data
, unsigned int range_count
, const struct wined3d_range
*ranges
)
3021 if (data
->buffer_object
)
3022 ERR("Unsupported buffer object %p.\n", data
->buffer_object
);
3025 static void adapter_no3d_copy_bo_address(struct wined3d_context
*context
,
3026 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
3027 unsigned int range_count
, const struct wined3d_range
*ranges
)
3031 if (dst
->buffer_object
)
3032 ERR("Unsupported dst buffer object %p.\n", dst
->buffer_object
);
3033 if (src
->buffer_object
)
3034 ERR("Unsupported src buffer object %p.\n", src
->buffer_object
);
3035 if (dst
->buffer_object
|| src
->buffer_object
)
3038 for (i
= 0; i
< range_count
; ++i
)
3039 memcpy(dst
->addr
+ ranges
[i
].offset
, src
->addr
+ ranges
[i
].offset
, ranges
[i
].size
);
3042 static void adapter_no3d_flush_bo_address(struct wined3d_context
*context
,
3043 const struct wined3d_const_bo_address
*data
, size_t size
)
3047 static bool adapter_no3d_alloc_bo(struct wined3d_device
*device
, struct wined3d_resource
*resource
,
3048 unsigned int sub_resource_idx
, struct wined3d_bo_address
*addr
)
3053 static void adapter_no3d_destroy_bo(struct wined3d_context
*context
, struct wined3d_bo
*bo
)
3057 static HRESULT
adapter_no3d_create_swapchain(struct wined3d_device
*device
,
3058 struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain_state_parent
*state_parent
,
3059 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_swapchain
**swapchain
)
3061 struct wined3d_swapchain
*swapchain_no3d
;
3064 TRACE("device %p, desc %p, state_parent %p, parent %p, parent_ops %p, swapchain %p.\n",
3065 device
, desc
, state_parent
, parent
, parent_ops
, swapchain
);
3067 if (!(swapchain_no3d
= heap_alloc_zero(sizeof(*swapchain_no3d
))))
3068 return E_OUTOFMEMORY
;
3070 if (FAILED(hr
= wined3d_swapchain_no3d_init(swapchain_no3d
, device
, desc
, state_parent
, parent
,
3073 WARN("Failed to initialise swapchain, hr %#x.\n", hr
);
3074 heap_free(swapchain_no3d
);
3078 TRACE("Created swapchain %p.\n", swapchain_no3d
);
3079 *swapchain
= swapchain_no3d
;
3084 static void adapter_no3d_destroy_swapchain(struct wined3d_swapchain
*swapchain
)
3086 wined3d_swapchain_cleanup(swapchain
);
3087 heap_free(swapchain
);
3090 static HRESULT
adapter_no3d_create_buffer(struct wined3d_device
*device
,
3091 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
3092 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_buffer
**buffer
)
3094 struct wined3d_buffer
*buffer_no3d
;
3097 TRACE("device %p, desc %p, data %p, parent %p, parent_ops %p, buffer %p.\n",
3098 device
, desc
, data
, parent
, parent_ops
, buffer
);
3100 if (!(buffer_no3d
= heap_alloc_zero(sizeof(*buffer_no3d
))))
3101 return E_OUTOFMEMORY
;
3103 if (FAILED(hr
= wined3d_buffer_no3d_init(buffer_no3d
, device
, desc
, data
, parent
, parent_ops
)))
3105 WARN("Failed to initialise buffer, hr %#x.\n", hr
);
3106 heap_free(buffer_no3d
);
3110 TRACE("Created buffer %p.\n", buffer_no3d
);
3111 *buffer
= buffer_no3d
;
3116 static void adapter_no3d_destroy_buffer(struct wined3d_buffer
*buffer
)
3118 struct wined3d_device
*device
= buffer
->resource
.device
;
3119 unsigned int swapchain_count
= device
->swapchain_count
;
3121 TRACE("buffer %p.\n", buffer
);
3123 /* Take a reference to the device, in case releasing the buffer would
3124 * cause the device to be destroyed. However, swapchain resources don't
3125 * take a reference to the device, and we wouldn't want to increment the
3126 * refcount on a device that's in the process of being destroyed. */
3127 if (swapchain_count
)
3128 wined3d_device_incref(device
);
3129 wined3d_buffer_cleanup(buffer
);
3130 wined3d_cs_destroy_object(device
->cs
, heap_free
, buffer
);
3131 if (swapchain_count
)
3132 wined3d_device_decref(device
);
3135 static HRESULT
adapter_no3d_create_texture(struct wined3d_device
*device
,
3136 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
3137 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_texture
**texture
)
3139 struct wined3d_texture
*texture_no3d
;
3142 TRACE("device %p, desc %p, layer_count %u, level_count %u, flags %#x, parent %p, parent_ops %p, texture %p.\n",
3143 device
, desc
, layer_count
, level_count
, flags
, parent
, parent_ops
, texture
);
3145 if (!(texture_no3d
= wined3d_texture_allocate_object_memory(sizeof(*texture_no3d
), level_count
, layer_count
)))
3146 return E_OUTOFMEMORY
;
3148 if (FAILED(hr
= wined3d_texture_no3d_init(texture_no3d
, device
, desc
,
3149 layer_count
, level_count
, flags
, parent
, parent_ops
)))
3151 WARN("Failed to initialise texture, hr %#x.\n", hr
);
3152 heap_free(texture_no3d
);
3156 TRACE("Created texture %p.\n", texture_no3d
);
3157 *texture
= texture_no3d
;
3162 static void adapter_no3d_destroy_texture(struct wined3d_texture
*texture
)
3164 struct wined3d_device
*device
= texture
->resource
.device
;
3165 unsigned int swapchain_count
= device
->swapchain_count
;
3167 TRACE("texture %p.\n", texture
);
3169 /* Take a reference to the device, in case releasing the texture would
3170 * cause the device to be destroyed. However, swapchain resources don't
3171 * take a reference to the device, and we wouldn't want to increment the
3172 * refcount on a device that's in the process of being destroyed. */
3173 if (swapchain_count
)
3174 wined3d_device_incref(device
);
3176 wined3d_texture_sub_resources_destroyed(texture
);
3177 texture
->resource
.parent_ops
->wined3d_object_destroyed(texture
->resource
.parent
);
3179 wined3d_texture_cleanup(texture
);
3180 wined3d_cs_destroy_object(device
->cs
, heap_free
, texture
);
3182 if (swapchain_count
)
3183 wined3d_device_decref(device
);
3186 static HRESULT
adapter_no3d_create_rendertarget_view(const struct wined3d_view_desc
*desc
,
3187 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3188 struct wined3d_rendertarget_view
**view
)
3190 struct wined3d_rendertarget_view
*view_no3d
;
3193 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
3194 wined3d_debug_view_desc(desc
, resource
), resource
, parent
, parent_ops
, view
);
3196 if (!(view_no3d
= heap_alloc_zero(sizeof(*view_no3d
))))
3197 return E_OUTOFMEMORY
;
3199 if (FAILED(hr
= wined3d_rendertarget_view_no3d_init(view_no3d
, desc
, resource
, parent
, parent_ops
)))
3201 WARN("Failed to initialise view, hr %#x.\n", hr
);
3202 heap_free(view_no3d
);
3206 TRACE("Created render target view %p.\n", view_no3d
);
3212 static void adapter_no3d_destroy_rendertarget_view(struct wined3d_rendertarget_view
*view
)
3214 struct wined3d_device
*device
= view
->resource
->device
;
3215 unsigned int swapchain_count
= device
->swapchain_count
;
3217 TRACE("view %p.\n", view
);
3219 /* Take a reference to the device, in case releasing the view's resource
3220 * would cause the device to be destroyed. However, swapchain resources
3221 * don't take a reference to the device, and we wouldn't want to increment
3222 * the refcount on a device that's in the process of being destroyed. */
3223 if (swapchain_count
)
3224 wined3d_device_incref(device
);
3225 wined3d_rendertarget_view_cleanup(view
);
3226 wined3d_cs_destroy_object(device
->cs
, heap_free
, view
);
3227 if (swapchain_count
)
3228 wined3d_device_decref(device
);
3231 static HRESULT
adapter_no3d_create_shader_resource_view(const struct wined3d_view_desc
*desc
,
3232 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3233 struct wined3d_shader_resource_view
**view
)
3235 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
3236 wined3d_debug_view_desc(desc
, resource
), resource
, parent
, parent_ops
, view
);
3241 static void adapter_no3d_destroy_shader_resource_view(struct wined3d_shader_resource_view
*view
)
3243 TRACE("view %p.\n", view
);
3246 static HRESULT
adapter_no3d_create_unordered_access_view(const struct wined3d_view_desc
*desc
,
3247 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3248 struct wined3d_unordered_access_view
**view
)
3250 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
3251 wined3d_debug_view_desc(desc
, resource
), resource
, parent
, parent_ops
, view
);
3256 static void adapter_no3d_destroy_unordered_access_view(struct wined3d_unordered_access_view
*view
)
3258 TRACE("view %p.\n", view
);
3261 static HRESULT
adapter_no3d_create_sampler(struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
3262 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_sampler
**sampler
)
3264 TRACE("device %p, desc %p, parent %p, parent_ops %p, sampler %p.\n",
3265 device
, desc
, parent
, parent_ops
, sampler
);
3270 static void adapter_no3d_destroy_sampler(struct wined3d_sampler
*sampler
)
3272 TRACE("sampler %p.\n", sampler
);
3275 static HRESULT
adapter_no3d_create_query(struct wined3d_device
*device
, enum wined3d_query_type type
,
3276 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
)
3278 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
3279 device
, type
, parent
, parent_ops
, query
);
3281 return WINED3DERR_NOTAVAILABLE
;
3284 static void adapter_no3d_destroy_query(struct wined3d_query
*query
)
3286 TRACE("query %p.\n", query
);
3289 static void adapter_no3d_flush_context(struct wined3d_context
*context
)
3291 TRACE("context %p.\n", context
);
3294 static void adapter_no3d_draw_primitive(struct wined3d_device
*device
,
3295 const struct wined3d_state
*state
, const struct wined3d_draw_parameters
*parameters
)
3297 ERR("device %p, state %p, parameters %p.\n", device
, state
, parameters
);
3300 static void adapter_no3d_dispatch_compute(struct wined3d_device
*device
,
3301 const struct wined3d_state
*state
, const struct wined3d_dispatch_parameters
*parameters
)
3303 ERR("device %p, state %p, parameters %p.\n", device
, state
, parameters
);
3306 static void adapter_no3d_clear_uav(struct wined3d_context
*context
,
3307 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
)
3309 ERR("context %p, view %p, clear_value %s, fp %#x.\n", context
, view
, debug_uvec4(clear_value
), fp
);
3312 static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops
=
3314 .adapter_destroy
= adapter_no3d_destroy
,
3315 .adapter_create_device
= adapter_no3d_create_device
,
3316 .adapter_destroy_device
= adapter_no3d_destroy_device
,
3317 .adapter_acquire_context
= adapter_no3d_acquire_context
,
3318 .adapter_release_context
= adapter_no3d_release_context
,
3319 .adapter_get_wined3d_caps
= adapter_no3d_get_wined3d_caps
,
3320 .adapter_check_format
= adapter_no3d_check_format
,
3321 .adapter_init_3d
= adapter_no3d_init_3d
,
3322 .adapter_uninit_3d
= adapter_no3d_uninit_3d
,
3323 .adapter_map_bo_address
= adapter_no3d_map_bo_address
,
3324 .adapter_unmap_bo_address
= adapter_no3d_unmap_bo_address
,
3325 .adapter_copy_bo_address
= adapter_no3d_copy_bo_address
,
3326 .adapter_flush_bo_address
= adapter_no3d_flush_bo_address
,
3327 .adapter_alloc_bo
= adapter_no3d_alloc_bo
,
3328 .adapter_destroy_bo
= adapter_no3d_destroy_bo
,
3329 .adapter_create_swapchain
= adapter_no3d_create_swapchain
,
3330 .adapter_destroy_swapchain
= adapter_no3d_destroy_swapchain
,
3331 .adapter_create_buffer
= adapter_no3d_create_buffer
,
3332 .adapter_destroy_buffer
= adapter_no3d_destroy_buffer
,
3333 .adapter_create_texture
= adapter_no3d_create_texture
,
3334 .adapter_destroy_texture
= adapter_no3d_destroy_texture
,
3335 .adapter_create_rendertarget_view
= adapter_no3d_create_rendertarget_view
,
3336 .adapter_destroy_rendertarget_view
= adapter_no3d_destroy_rendertarget_view
,
3337 .adapter_create_shader_resource_view
= adapter_no3d_create_shader_resource_view
,
3338 .adapter_destroy_shader_resource_view
= adapter_no3d_destroy_shader_resource_view
,
3339 .adapter_create_unordered_access_view
= adapter_no3d_create_unordered_access_view
,
3340 .adapter_destroy_unordered_access_view
= adapter_no3d_destroy_unordered_access_view
,
3341 .adapter_create_sampler
= adapter_no3d_create_sampler
,
3342 .adapter_destroy_sampler
= adapter_no3d_destroy_sampler
,
3343 .adapter_create_query
= adapter_no3d_create_query
,
3344 .adapter_destroy_query
= adapter_no3d_destroy_query
,
3345 .adapter_flush_context
= adapter_no3d_flush_context
,
3346 .adapter_draw_primitive
= adapter_no3d_draw_primitive
,
3347 .adapter_dispatch_compute
= adapter_no3d_dispatch_compute
,
3348 .adapter_clear_uav
= adapter_no3d_clear_uav
,
3351 static void wined3d_adapter_no3d_init_d3d_info(struct wined3d_adapter
*adapter
, unsigned int wined3d_creation_flags
)
3353 struct wined3d_d3d_info
*d3d_info
= &adapter
->d3d_info
;
3355 d3d_info
->wined3d_creation_flags
= wined3d_creation_flags
;
3356 d3d_info
->texture_npot
= TRUE
;
3357 d3d_info
->feature_level
= WINED3D_FEATURE_LEVEL_5
;
3360 static struct wined3d_adapter
*wined3d_adapter_no3d_create(unsigned int ordinal
, unsigned int wined3d_creation_flags
)
3362 struct wined3d_adapter
*adapter
;
3363 LUID primary_luid
, *luid
= NULL
;
3365 static const struct wined3d_gpu_description gpu_description
=
3367 HW_VENDOR_SOFTWARE
, CARD_WINE
, "WineD3D DirectDraw Emulation", DRIVER_WINE
, 128,
3370 TRACE("ordinal %u, wined3d_creation_flags %#x.\n", ordinal
, wined3d_creation_flags
);
3372 if (!(adapter
= heap_alloc_zero(sizeof(*adapter
))))
3375 if (ordinal
== 0 && wined3d_get_primary_adapter_luid(&primary_luid
))
3376 luid
= &primary_luid
;
3378 if (!wined3d_adapter_init(adapter
, ordinal
, luid
, &wined3d_adapter_no3d_ops
))
3384 if (!wined3d_adapter_no3d_init_format_info(adapter
))
3386 wined3d_adapter_cleanup(adapter
);
3391 if (!wined3d_driver_info_init(&adapter
->driver_info
, &gpu_description
, WINED3D_FEATURE_LEVEL_NONE
, 0, 0))
3393 wined3d_adapter_cleanup(adapter
);
3397 adapter
->vram_bytes_used
= 0;
3398 TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter
->driver_info
.vram_bytes
));
3400 adapter
->vertex_pipe
= &none_vertex_pipe
;
3401 adapter
->fragment_pipe
= &none_fragment_pipe
;
3402 adapter
->misc_state_template
= misc_state_template_no3d
;
3403 adapter
->shader_backend
= &none_shader_backend
;
3405 wined3d_adapter_no3d_init_d3d_info(adapter
, wined3d_creation_flags
);
3407 TRACE("Created adapter %p.\n", adapter
);
3412 static BOOL
wined3d_adapter_create_output(struct wined3d_adapter
*adapter
, const WCHAR
*output_name
)
3416 if (!wined3d_array_reserve((void **)&adapter
->outputs
, &adapter
->outputs_size
,
3417 adapter
->output_count
+ 1, sizeof(*adapter
->outputs
)))
3420 if (FAILED(hr
= wined3d_output_init(&adapter
->outputs
[adapter
->output_count
],
3421 adapter
->output_count
, adapter
, output_name
)))
3423 ERR("Failed to initialise output %s, hr %#x.\n", wine_dbgstr_w(output_name
), hr
);
3427 ++adapter
->output_count
;
3428 TRACE("Initialised output %s.\n", wine_dbgstr_w(output_name
));
3432 BOOL
wined3d_adapter_init(struct wined3d_adapter
*adapter
, unsigned int ordinal
, const LUID
*luid
,
3433 const struct wined3d_adapter_ops
*adapter_ops
)
3435 D3DKMT_OPENADAPTERFROMLUID open_adapter_desc
;
3436 unsigned int output_idx
= 0, primary_idx
= 0;
3437 D3DKMT_CLOSEADAPTER close_adapter_desc
;
3438 DISPLAY_DEVICEW display_device
;
3441 adapter
->ordinal
= ordinal
;
3442 adapter
->output_count
= 0;
3443 adapter
->outputs
= NULL
;
3447 adapter
->luid
= *luid
;
3451 WARN("Allocating a random LUID.\n");
3452 if (!AllocateLocallyUniqueId(&adapter
->luid
))
3454 ERR("Failed to allocate a LUID, error %#x.\n", GetLastError());
3458 TRACE("adapter %p LUID %08x:%08x.\n", adapter
, adapter
->luid
.HighPart
, adapter
->luid
.LowPart
);
3460 open_adapter_desc
.AdapterLuid
= adapter
->luid
;
3461 if (D3DKMTOpenAdapterFromLuid(&open_adapter_desc
))
3463 adapter
->kmt_adapter
= open_adapter_desc
.hAdapter
;
3465 display_device
.cb
= sizeof(display_device
);
3466 while (EnumDisplayDevicesW(NULL
, output_idx
++, &display_device
, 0))
3468 /* Detached outputs are not enumerated */
3469 if (!(display_device
.StateFlags
& DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
))
3472 if (display_device
.StateFlags
& DISPLAY_DEVICE_PRIMARY_DEVICE
)
3473 primary_idx
= adapter
->output_count
;
3475 if (!wined3d_adapter_create_output(adapter
, display_device
.DeviceName
))
3478 TRACE("Initialised %Iu outputs for adapter %p.\n", adapter
->output_count
, adapter
);
3480 /* Make the primary output first */
3483 struct wined3d_output tmp
= adapter
->outputs
[0];
3484 adapter
->outputs
[0] = adapter
->outputs
[primary_idx
];
3485 adapter
->outputs
[0].ordinal
= 0;
3486 adapter
->outputs
[primary_idx
] = tmp
;
3487 adapter
->outputs
[primary_idx
].ordinal
= primary_idx
;
3490 memset(&adapter
->driver_uuid
, 0, sizeof(adapter
->driver_uuid
));
3491 memset(&adapter
->device_uuid
, 0, sizeof(adapter
->device_uuid
));
3493 adapter
->formats
= NULL
;
3494 adapter
->adapter_ops
= adapter_ops
;
3499 for (output_idx
= 0; output_idx
< adapter
->output_count
; ++output_idx
)
3500 wined3d_output_cleanup(&adapter
->outputs
[output_idx
]);
3501 heap_free(adapter
->outputs
);
3502 close_adapter_desc
.hAdapter
= adapter
->kmt_adapter
;
3503 D3DKMTCloseAdapter(&close_adapter_desc
);
3508 static struct wined3d_adapter
*wined3d_adapter_create(unsigned int ordinal
, DWORD wined3d_creation_flags
)
3510 if (wined3d_creation_flags
& WINED3D_NO3D
)
3511 return wined3d_adapter_no3d_create(ordinal
, wined3d_creation_flags
);
3513 if (wined3d_settings
.renderer
== WINED3D_RENDERER_VULKAN
)
3514 return wined3d_adapter_vk_create(ordinal
, wined3d_creation_flags
);
3516 return wined3d_adapter_gl_create(ordinal
, wined3d_creation_flags
);
3519 static void STDMETHODCALLTYPE
wined3d_null_wined3d_object_destroyed(void *parent
) {}
3521 const struct wined3d_parent_ops wined3d_null_parent_ops
=
3523 wined3d_null_wined3d_object_destroyed
,
3526 HRESULT
wined3d_init(struct wined3d
*wined3d
, DWORD flags
)
3529 wined3d
->flags
= flags
;
3531 TRACE("Initialising adapters.\n");
3533 if (!(wined3d
->adapters
[0] = wined3d_adapter_create(0, flags
)))
3535 WARN("Failed to create adapter.\n");
3538 wined3d
->adapter_count
= 1;