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
26 #include "wined3d_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
29 WINE_DECLARE_DEBUG_CHANNEL(d3d_caps
);
31 #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
33 /* The driver names reflect the lowest GPU supported
34 * by a certain driver, so DRIVER_AMD_R300 supports
35 * R3xx, R4xx and R5xx GPUs. */
36 enum wined3d_display_driver
38 DRIVER_AMD_RAGE_128PRO
,
47 DRIVER_NVIDIA_GEFORCE2MX
,
48 DRIVER_NVIDIA_GEFORCEFX
,
49 DRIVER_NVIDIA_GEFORCE6
,
53 enum wined3d_driver_model
61 enum wined3d_gl_vendor
71 /* The d3d device ID */
72 static const GUID IID_D3DDEVICE_D3DUID
= { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
74 /* Extension detection */
75 struct wined3d_extension_map
77 const char *extension_string
;
78 enum wined3d_gl_extension extension
;
82 static const struct wined3d_extension_map gl_extension_map
[] =
85 {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE
, 0 },
86 {"GL_APPLE_fence", APPLE_FENCE
, 0 },
87 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS
, 0 },
88 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE
, 0 },
89 {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER
, 0 },
90 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422
, 0 },
93 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT
, 0 },
94 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT
, 0 },
95 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP
, 0 },
96 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE
, 0 },
97 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS
, 0 },
98 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX
, 0 },
99 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM
, 0 },
100 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER
, 0 },
101 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT
, 0 },
102 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4
, 0 },
103 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL
, 0 },
104 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX
, 0 },
105 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT
, 0 },
106 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE
, 0 },
107 {"GL_ARB_multisample", ARB_MULTISAMPLE
, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */
108 {"GL_ARB_multitexture", ARB_MULTITEXTURE
, 0 },
109 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY
, 0 },
110 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT
, 0 },
111 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS
, 0 },
112 {"GL_ARB_point_sprite", ARB_POINT_SPRITE
, 0 },
113 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX
, 0 },
114 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS
, 0 },
115 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD
, 0 },
116 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100
, 0 },
117 {"GL_ARB_shadow", ARB_SHADOW
, 0 },
118 {"GL_ARB_sync", ARB_SYNC
, 0 },
119 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP
, 0 },
120 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION
, 0 },
121 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC
, 0 },
122 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP
, 0 },
123 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD
, 0 },
124 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE
, 0 },
125 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3
, 0 },
126 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT
, 0 },
127 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT
, 0 },
128 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO
, MAKEDWORD_VERSION(2, 0) },
129 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE
, 0 },
130 {"GL_ARB_texture_rg", ARB_TEXTURE_RG
, 0 },
131 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
, 0 },
132 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND
, 0 },
133 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT
, 0 },
134 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM
, 0 },
135 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER
, 0 },
138 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER
, 0 },
139 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL
, 0 },
140 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC
, 0 },
141 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3
, 0 },
142 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE
, 0 },
145 {"GL_EXT_blend_color", EXT_BLEND_COLOR
, 0 },
146 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE
, 0 },
147 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE
, 0 },
148 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX
, 0 },
149 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT
, 0 },
150 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST
, 0 },
151 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2
, 0 },
152 {"GL_EXT_fog_coord", EXT_FOG_COORD
, 0 },
153 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT
, 0 },
154 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE
, 0 },
155 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT
, 0 },
156 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS
, 0 },
157 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4
, 0 },
158 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL
, 0 },
159 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE
, 0 },
160 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS
, 0 },
161 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX
, 0 },
162 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR
, 0 },
163 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE
, 0 },
164 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP
, 0 },
165 {"GL_EXT_texture3D", EXT_TEXTURE3D
, MAKEDWORD_VERSION(1, 2) },
166 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC
, 0 },
167 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC
, 0 },
168 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD
, 0 },
169 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE
, 0 },
170 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3
, 0 },
171 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC
, 0 },
172 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS
, 0 },
173 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB
, 0 },
174 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE
, 0 },
175 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA
, 0 },
178 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP
, 0 },
179 {"GL_NV_fence", NV_FENCE
, 0 },
180 {"GL_NV_fog_distance", NV_FOG_DISTANCE
, 0 },
181 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM
, 0 },
182 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2
, 0 },
183 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION
, 0 },
184 {"GL_NV_half_float", NV_HALF_FLOAT
, 0 },
185 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT
, 0 },
186 {"GL_NV_point_sprite", NV_POINT_SPRITE
, 0 },
187 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS
, 0 },
188 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2
, 0 },
189 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION
, 0 },
190 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4
, 0 },
191 {"GL_NV_texture_shader", NV_TEXTURE_SHADER
, 0 },
192 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2
, 0 },
193 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM
, 0 },
194 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1
, 0 },
195 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2
, 0 },
196 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION
, 0 },
197 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3
, 0 },
200 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP
, 0 },
203 static const struct wined3d_extension_map wgl_extension_map
[] =
205 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT
, 0 },
206 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL
, 0 },
207 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
, 0 },
210 /**********************************************************
211 * Utility functions follow
212 **********************************************************/
214 const struct min_lookup minMipLookup
[] =
216 /* NONE POINT LINEAR */
217 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
218 {{GL_NEAREST
, GL_NEAREST_MIPMAP_NEAREST
, GL_NEAREST_MIPMAP_LINEAR
}}, /* POINT*/
219 {{GL_LINEAR
, GL_LINEAR_MIPMAP_NEAREST
, GL_LINEAR_MIPMAP_LINEAR
}}, /* LINEAR */
222 const struct min_lookup minMipLookup_noFilter
[] =
224 /* NONE POINT LINEAR */
225 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
226 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
227 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* LINEAR */
230 const struct min_lookup minMipLookup_noMip
[] =
232 /* NONE POINT LINEAR */
233 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
234 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
235 {{GL_LINEAR
, GL_LINEAR
, GL_LINEAR
}}, /* LINEAR */
238 const GLenum magLookup
[] =
240 /* NONE POINT LINEAR */
241 GL_NEAREST
, GL_NEAREST
, GL_LINEAR
,
244 const GLenum magLookup_noFilter
[] =
246 /* NONE POINT LINEAR */
247 GL_NEAREST
, GL_NEAREST
, GL_NEAREST
,
250 /* drawStridedSlow attributes */
251 glAttribFunc position_funcs
[WINED3D_FFP_EMIT_COUNT
];
252 glAttribFunc diffuse_funcs
[WINED3D_FFP_EMIT_COUNT
];
253 glAttribFunc specular_func_3ubv
;
254 glAttribFunc specular_funcs
[WINED3D_FFP_EMIT_COUNT
];
255 glAttribFunc normal_funcs
[WINED3D_FFP_EMIT_COUNT
];
256 glMultiTexCoordFunc multi_texcoord_funcs
[WINED3D_FFP_EMIT_COUNT
];
259 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
260 * i.e., there is no GL Context - Get a default rendering context to enable the
261 * function query some info from GL.
264 struct wined3d_fake_gl_ctx
270 HGLRC restore_gl_ctx
;
273 static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx
*ctx
)
275 TRACE_(d3d_caps
)("Destroying fake GL context.\n");
277 if (!pwglMakeCurrent(NULL
, NULL
))
279 ERR_(d3d_caps
)("Failed to disable fake GL context.\n");
282 if (!pwglDeleteContext(ctx
->gl_ctx
))
284 DWORD err
= GetLastError();
285 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx
->gl_ctx
, err
);
288 ReleaseDC(ctx
->wnd
, ctx
->dc
);
289 DestroyWindow(ctx
->wnd
);
291 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
293 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
297 /* Do not call while under the GL lock. */
298 static BOOL
WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx
*ctx
)
300 PIXELFORMATDESCRIPTOR pfd
;
303 TRACE("getting context...\n");
305 ctx
->restore_dc
= pwglGetCurrentDC();
306 ctx
->restore_gl_ctx
= pwglGetCurrentContext();
308 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
309 ctx
->wnd
= CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME
, "WineD3D fake window",
310 WS_OVERLAPPEDWINDOW
, 10, 10, 10, 10, NULL
, NULL
, NULL
, NULL
);
313 ERR_(d3d_caps
)("Failed to create a window.\n");
317 ctx
->dc
= GetDC(ctx
->wnd
);
320 ERR_(d3d_caps
)("Failed to get a DC.\n");
324 /* PixelFormat selection */
325 ZeroMemory(&pfd
, sizeof(pfd
));
326 pfd
.nSize
= sizeof(pfd
);
328 pfd
.dwFlags
= PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
; /* PFD_GENERIC_ACCELERATED */
329 pfd
.iPixelType
= PFD_TYPE_RGBA
;
331 pfd
.iLayerType
= PFD_MAIN_PLANE
;
333 iPixelFormat
= ChoosePixelFormat(ctx
->dc
, &pfd
);
336 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
337 ERR_(d3d_caps
)("Can't find a suitable iPixelFormat.\n");
340 DescribePixelFormat(ctx
->dc
, iPixelFormat
, sizeof(pfd
), &pfd
);
341 SetPixelFormat(ctx
->dc
, iPixelFormat
, &pfd
);
343 /* Create a GL context. */
344 ctx
->gl_ctx
= pwglCreateContext(ctx
->dc
);
347 WARN_(d3d_caps
)("Error creating default context for capabilities initialization.\n");
351 /* Make it the current GL context. */
352 if (!pwglMakeCurrent(ctx
->dc
, ctx
->gl_ctx
))
354 ERR_(d3d_caps
)("Failed to make fake GL context current.\n");
361 if (ctx
->gl_ctx
) pwglDeleteContext(ctx
->gl_ctx
);
363 if (ctx
->dc
) ReleaseDC(ctx
->wnd
, ctx
->dc
);
365 if (ctx
->wnd
) DestroyWindow(ctx
->wnd
);
367 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
369 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
375 /* Adjust the amount of used texture memory */
376 unsigned int adapter_adjust_memory(struct wined3d_adapter
*adapter
, int amount
)
378 adapter
->UsedTextureRam
+= amount
;
379 TRACE("Adjusted adapter memory by %d to %d.\n", amount
, adapter
->UsedTextureRam
);
380 return adapter
->UsedTextureRam
;
383 static void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
)
385 HeapFree(GetProcessHeap(), 0, adapter
->gl_info
.formats
);
386 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
389 ULONG CDECL
wined3d_incref(struct wined3d
*wined3d
)
391 ULONG refcount
= InterlockedIncrement(&wined3d
->ref
);
393 TRACE("%p increasing refcount to %u.\n", wined3d
, refcount
);
398 ULONG CDECL
wined3d_decref(struct wined3d
*wined3d
)
400 ULONG refcount
= InterlockedDecrement(&wined3d
->ref
);
402 TRACE("%p decreasing refcount to %u.\n", wined3d
, refcount
);
408 for (i
= 0; i
< wined3d
->adapter_count
; ++i
)
410 wined3d_adapter_cleanup(&wined3d
->adapters
[i
]);
412 HeapFree(GetProcessHeap(), 0, wined3d
);
418 /* GL locking is done by the caller */
419 static inline BOOL
test_arb_vs_offset_limit(const struct wined3d_gl_info
*gl_info
)
423 const char *testcode
=
425 "PARAM C[66] = { program.env[0..65] };\n"
427 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
428 "ARL A0.x, zero.x;\n"
429 "MOV result.position, C[A0.x + 65];\n"
433 GL_EXTCALL(glGenProgramsARB(1, &prog
));
435 ERR("Failed to create an ARB offset limit test program\n");
437 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
438 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
439 strlen(testcode
), testcode
));
442 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
443 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
445 } else TRACE("OpenGL implementation allows offsets > 63\n");
447 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
448 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
449 checkGLcall("ARB vp offset limit test cleanup");
454 static DWORD
ver_for_ext(enum wined3d_gl_extension ext
)
458 for (i
= 0; i
< (sizeof(gl_extension_map
) / sizeof(*gl_extension_map
)); ++i
)
460 if (gl_extension_map
[i
].extension
== ext
)
461 return gl_extension_map
[i
].version
;
466 static BOOL
match_amd_r300_to_500(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
467 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
469 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
470 if (device
== CARD_AMD_RADEON_9500
) return TRUE
;
471 if (device
== CARD_AMD_RADEON_X700
) return TRUE
;
472 if (device
== CARD_AMD_RADEON_X1600
) return TRUE
;
476 static BOOL
match_geforce5(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
477 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
479 if (card_vendor
== HW_VENDOR_NVIDIA
)
481 if (device
== CARD_NVIDIA_GEFORCEFX_5200
||
482 device
== CARD_NVIDIA_GEFORCEFX_5600
||
483 device
== CARD_NVIDIA_GEFORCEFX_5800
)
491 static BOOL
match_apple(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
492 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
494 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
495 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
496 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
498 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
499 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
500 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
501 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
502 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
503 * the chance that other implementations support them is rather small since Win32 QuickTime uses
504 * DirectDraw, not OpenGL.
506 * This test has been moved into wined3d_guess_gl_vendor()
508 if (gl_vendor
== GL_VENDOR_APPLE
)
515 /* Context activation is done by the caller. */
516 static void test_pbo_functionality(struct wined3d_gl_info
*gl_info
)
518 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
519 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
520 * all the texture. This function detects this bug by its symptom and disables PBOs
523 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
524 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
525 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
526 * read back is compared to the original. If they are equal PBOs are assumed to work,
527 * otherwise the PBO extension is disabled. */
529 static const unsigned int pattern
[] =
531 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
532 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
533 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
534 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
536 unsigned int check
[sizeof(pattern
) / sizeof(pattern
[0])];
538 /* No PBO -> No point in testing them. */
539 if (!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
]) return;
543 while (glGetError());
544 glGenTextures(1, &texture
);
545 glBindTexture(GL_TEXTURE_2D
, texture
);
547 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAX_LEVEL
, 0);
548 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0);
549 checkGLcall("Specifying the PBO test texture");
551 GL_EXTCALL(glGenBuffersARB(1, &pbo
));
552 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, pbo
));
553 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB
, sizeof(pattern
), pattern
, GL_STREAM_DRAW_ARB
));
554 checkGLcall("Specifying the PBO test pbo");
556 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
557 checkGLcall("Loading the PBO test texture");
559 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, 0));
562 wglFinish(); /* just to be sure */
564 memset(check
, 0, sizeof(check
));
566 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, check
);
567 checkGLcall("Reading back the PBO test texture");
569 glDeleteTextures(1, &texture
);
570 GL_EXTCALL(glDeleteBuffersARB(1, &pbo
));
571 checkGLcall("PBO test cleanup");
575 if (memcmp(check
, pattern
, sizeof(check
)))
577 WARN_(d3d_caps
)("PBO test failed, read back data doesn't match original.\n");
578 WARN_(d3d_caps
)("Disabling PBOs. This may result in slower performance.\n");
579 gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
] = FALSE
;
583 TRACE_(d3d_caps
)("PBO test successful.\n");
587 static BOOL
match_apple_intel(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
588 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
590 return (card_vendor
== HW_VENDOR_INTEL
) && (gl_vendor
== GL_VENDOR_APPLE
);
593 static BOOL
match_apple_nonr500ati(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
594 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
596 if (gl_vendor
!= GL_VENDOR_APPLE
) return FALSE
;
597 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
598 if (device
== CARD_AMD_RADEON_X1600
) return FALSE
;
602 static BOOL
match_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
603 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
605 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
606 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
607 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
608 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
611 * dx10 cards usually have 64 varyings */
612 return gl_info
->limits
.glsl_varyings
> 44;
615 static BOOL
match_not_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
616 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
618 return !match_dx10_capable(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
);
621 /* A GL context is provided by the caller */
622 static BOOL
match_allows_spec_alpha(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
623 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
628 if (!gl_info
->supported
[EXT_SECONDARY_COLOR
]) return FALSE
;
632 GL_EXTCALL(glSecondaryColorPointerEXT
)(4, GL_UNSIGNED_BYTE
, 4, data
);
633 error
= glGetError();
636 if(error
== GL_NO_ERROR
)
638 TRACE("GL Implementation accepts 4 component specular color pointers\n");
643 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
644 debug_glerror(error
));
649 /* A GL context is provided by the caller */
650 static BOOL
match_broken_nv_clip(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
651 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
656 const char *testcode
=
658 "OPTION NV_vertex_program2;\n"
659 "MOV result.clip[0], 0.0;\n"
660 "MOV result.position, 0.0;\n"
663 if (!gl_info
->supported
[NV_VERTEX_PROGRAM2_OPTION
]) return FALSE
;
668 GL_EXTCALL(glGenProgramsARB(1, &prog
));
671 ERR("Failed to create the NVvp clip test program\n");
675 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
676 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
677 strlen(testcode
), testcode
));
678 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &pos
);
681 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
682 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
686 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
688 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
689 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
690 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
696 /* Context activation is done by the caller. */
697 static BOOL
match_fbo_tex_update(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
698 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
700 char data
[4 * 4 * 4];
704 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
) return FALSE
;
706 memset(data
, 0xcc, sizeof(data
));
710 glGenTextures(1, &tex
);
711 glBindTexture(GL_TEXTURE_2D
, tex
);
712 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
713 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
714 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
715 checkGLcall("glTexImage2D");
717 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
718 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
719 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
720 checkGLcall("glFramebufferTexture2D");
722 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
723 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
724 checkGLcall("glCheckFramebufferStatus");
726 memset(data
, 0x11, sizeof(data
));
727 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
728 checkGLcall("glTexSubImage2D");
730 glClearColor(0.996f
, 0.729f
, 0.745f
, 0.792f
);
731 glClear(GL_COLOR_BUFFER_BIT
);
732 checkGLcall("glClear");
734 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
735 checkGLcall("glGetTexImage");
737 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
738 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
739 glBindTexture(GL_TEXTURE_2D
, 0);
740 checkGLcall("glBindTexture");
742 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
743 glDeleteTextures(1, &tex
);
744 checkGLcall("glDeleteTextures");
748 return *(DWORD
*)data
== 0x11111111;
751 /* Context activation is done by the caller. */
752 static BOOL
match_broken_rgba16(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
753 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
755 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
756 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
762 glGenTextures(1, &tex
);
763 glBindTexture(GL_TEXTURE_2D
, tex
);
764 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA16
, 4, 4, 0, GL_RGBA
, GL_UNSIGNED_SHORT
, NULL
);
765 checkGLcall("glTexImage2D");
767 glGetTexLevelParameteriv(GL_TEXTURE_2D
, 0, GL_TEXTURE_RED_SIZE
, &size
);
768 checkGLcall("glGetTexLevelParameteriv");
769 TRACE("Real color depth is %d\n", size
);
771 glBindTexture(GL_TEXTURE_2D
, 0);
772 checkGLcall("glBindTexture");
773 glDeleteTextures(1, &tex
);
774 checkGLcall("glDeleteTextures");
781 static BOOL
match_fglrx(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
782 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
784 return gl_vendor
== GL_VENDOR_FGLRX
;
787 static void quirk_apple_glsl_constants(struct wined3d_gl_info
*gl_info
)
789 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
790 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
791 * allow 48 different offsets or other helper immediate values. */
792 TRACE_(d3d_caps
)("Reserving 12 GLSL constants for compiler private use.\n");
793 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 12);
796 static void quirk_amd_dx9(struct wined3d_gl_info
*gl_info
)
798 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
799 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
800 * If real NP2 textures are used, the driver falls back to software. We could just remove the
801 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
802 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
803 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
804 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
806 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
807 * has this extension promoted to core. The extension loading code sets this extension supported
808 * due to that, so this code works on fglrx as well. */
809 if(gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
811 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
812 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
813 gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
] = TRUE
;
817 static void quirk_no_np2(struct wined3d_gl_info
*gl_info
)
819 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
820 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
821 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
822 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
823 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
824 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
826 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
827 * triggering the software fallback. There is not much we can do here apart from disabling the
828 * software-emulated extension and reenable ARB_tex_rect (which was previously disabled
829 * in wined3d_adapter_init_gl_caps).
830 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
831 * post-processing effects in the game "Max Payne 2").
832 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
833 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
834 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
835 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = TRUE
;
838 static void quirk_texcoord_w(struct wined3d_gl_info
*gl_info
)
840 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
841 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
842 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
843 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
844 * according to the spec.
846 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
847 * makes the shader slower and eats instruction slots which should be available to the d3d app.
849 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
850 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
851 * this workaround is activated on cards that do not need it, it won't break things, just affect
852 * performance negatively. */
853 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
854 gl_info
->quirks
|= WINED3D_QUIRK_SET_TEXCOORD_W
;
857 static void quirk_clip_varying(struct wined3d_gl_info
*gl_info
)
859 gl_info
->quirks
|= WINED3D_QUIRK_GLSL_CLIP_VARYING
;
862 static void quirk_allows_specular_alpha(struct wined3d_gl_info
*gl_info
)
864 gl_info
->quirks
|= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
;
867 static void quirk_disable_nvvp_clip(struct wined3d_gl_info
*gl_info
)
869 gl_info
->quirks
|= WINED3D_QUIRK_NV_CLIP_BROKEN
;
872 static void quirk_fbo_tex_update(struct wined3d_gl_info
*gl_info
)
874 gl_info
->quirks
|= WINED3D_QUIRK_FBO_TEX_UPDATE
;
877 static void quirk_broken_rgba16(struct wined3d_gl_info
*gl_info
)
879 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_RGBA16
;
882 static void quirk_infolog_spam(struct wined3d_gl_info
*gl_info
)
884 gl_info
->quirks
|= WINED3D_QUIRK_INFO_LOG_SPAM
;
887 static void quirk_limited_tex_filtering(struct wined3d_gl_info
*gl_info
)
889 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
890 selected texture formats. They are apparently the only DX9 class GPUs
892 Also, DX9-era GPUs are somewhat limited with float textures
893 filtering and blending. */
894 gl_info
->quirks
|= WINED3D_QUIRK_LIMITED_TEX_FILTERING
;
899 BOOL (*match
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
900 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
);
901 void (*apply
)(struct wined3d_gl_info
*gl_info
);
902 const char *description
;
905 static const struct driver_quirk quirk_table
[] =
908 match_amd_r300_to_500
,
910 "AMD normalized texrect quirk"
914 quirk_apple_glsl_constants
,
915 "Apple GLSL uniform override"
920 "Geforce 5 NP2 disable"
925 "Init texcoord .w for Apple Intel GPU driver"
928 match_apple_nonr500ati
,
930 "Init texcoord .w for Apple ATI >= r600 GPU driver"
935 "Reserved varying for gl_ClipPos"
938 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
939 * GL implementations accept it. The Mac GL is the only implementation known to
942 * If we can pass 4 component specular colors, do it, because (a) we don't have
943 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
944 * passes specular alpha to the pixel shader if any is used. Otherwise the
945 * specular alpha is used to pass the fog coordinate, which we pass to opengl
946 * via GL_EXT_fog_coord.
948 match_allows_spec_alpha
,
949 quirk_allows_specular_alpha
,
950 "Allow specular alpha quirk"
953 match_broken_nv_clip
,
954 quirk_disable_nvvp_clip
,
955 "Apple NV_vertex_program clip bug quirk"
958 match_fbo_tex_update
,
959 quirk_fbo_tex_update
,
960 "FBO rebind for attachment updates"
965 "True RGBA16 is not available"
970 "Not printing GLSL infolog"
973 match_not_dx10_capable
,
974 quirk_limited_tex_filtering
,
975 "Texture filtering, blending and VTF support is limited"
979 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
980 * reporting a driver version is moot because we are not the Windows driver, and we have different
981 * bugs, features, etc.
983 * The driver version has the form "x.y.z.w".
985 * "x" is the Windows version the driver is meant for:
992 * "y" is the maximum Direct3D version the driver supports.
993 * y -> d3d version mapping:
1002 * "z" is the subversion number.
1004 * "w" is the vendor specific driver build number.
1007 struct driver_version_information
1009 enum wined3d_display_driver driver
;
1010 enum wined3d_driver_model driver_model
;
1011 const char *driver_name
; /* name of Windows driver */
1012 WORD version
; /* version word ('y'), contained in low word of DriverVersion.HighPart */
1013 WORD subversion
; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
1014 WORD build
; /* build number ('w'), contained in low word of DriverVersion.LowPart */
1017 /* The driver version table contains driver information for different devices on several OS versions. */
1018 static const struct driver_version_information driver_version_table
[] =
1021 * - Radeon HD2x00 (R600) and up supported by current drivers.
1022 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1023 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1024 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1025 {DRIVER_AMD_RAGE_128PRO
, DRIVER_MODEL_NT5X
, "ati2dvaa.dll", 13, 3279, 0},
1026 {DRIVER_AMD_R100
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6614},
1027 {DRIVER_AMD_R300
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6764},
1028 {DRIVER_AMD_R600
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 8681},
1029 {DRIVER_AMD_R300
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1030 {DRIVER_AMD_R600
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1033 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1034 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1035 * igxprd32.dll but the GMA800 driver was never updated. */
1036 {DRIVER_INTEL_GMA800
, DRIVER_MODEL_NT5X
, "ialmrnt5.dll", 14, 10, 3889},
1037 {DRIVER_INTEL_GMA900
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4764},
1038 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4926},
1039 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 5218},
1040 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 14, 10, 1504},
1041 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 15, 10, 1666},
1044 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1045 * - GeforceFX support is up to 173.x on <= XP
1046 * - Geforce2MX/3/4 up to 96.x on <= XP
1047 * - TNT/Geforce1/2 up to 71.x on <= XP
1048 * All version numbers used below are from the Linux nvidia drivers. */
1049 {DRIVER_NVIDIA_TNT
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 7186},
1050 {DRIVER_NVIDIA_GEFORCE2MX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 9371},
1051 {DRIVER_NVIDIA_GEFORCEFX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 11, 7516},
1052 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 15, 12, 6658},
1053 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 15, 12, 6658},
1056 struct gpu_description
1058 WORD vendor
; /* reported PCI card vendor ID */
1059 WORD card
; /* reported PCI card device ID */
1060 const char *description
; /* Description of the card e.g. NVIDIA RIVA TNT */
1061 enum wined3d_display_driver driver
;
1062 unsigned int vidmem
;
1065 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1066 * found on a board containing a specific GPU. */
1067 static const struct gpu_description gpu_description_table
[] =
1070 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT
, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT
, 16 },
1071 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT2
, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1072 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE
, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT
, 32 },
1073 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2
, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1074 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2_MX
, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX
,32 },
1075 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE3
, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1076 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_MX
, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1077 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_TI4200
, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX
,64, },
1078 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5200
, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX
, 64 },
1079 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5600
, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX
, 128 },
1080 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5800
, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX
, 256 },
1081 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6200
, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6
, 64 },
1082 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6600GT
, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6
, 128 },
1083 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6800
, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6
, 128 },
1084 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7300
, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6
, 256 },
1085 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7400
, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6
, 256 },
1086 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7600
, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1087 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7800GT
, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1088 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8300GS
, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1089 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8400GS
, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1090 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600GT
, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1091 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600MGT
, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1092 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTS
, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6
, 320 },
1093 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTX
, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6
, 768 },
1094 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9200
, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6
, 256 },
1095 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400M
, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE6
, 256 },
1096 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400GT
, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1097 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9500GT
, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1098 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9600GT
, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6
, 384 },
1099 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9800GT
, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1100 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_210
, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6
, 512 },
1101 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT220
, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6
, 512 },
1102 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT240
, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6
, 512 },
1103 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX260
, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6
, 1024},
1104 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX275
, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6
, 896 },
1105 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX280
, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6
, 1024},
1106 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_320M
, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE6
, 256},
1107 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT320M
, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1108 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT325M
, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1109 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT330
, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6
, 1024},
1110 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS350M
, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1111 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT420
, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6
, 2048},
1112 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT430
, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6
, 1024},
1113 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT440
, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6
, 1024},
1114 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS450
, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6
, 1024},
1115 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460
, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6
, 768 },
1116 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460M
, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE6
, 1536},
1117 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX465
, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6
, 1024},
1118 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX470
, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6
, 1280},
1119 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX480
, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6
, 1536},
1120 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT540M
, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1121 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX550
, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1122 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT555M
, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1123 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560TI
, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1124 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560
, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE6
, 1024},
1125 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX570
, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6
, 1280},
1126 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX580
, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6
, 1536},
1129 {HW_VENDOR_AMD
, CARD_AMD_RAGE_128PRO
, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO
, 16 },
1130 {HW_VENDOR_AMD
, CARD_AMD_RADEON_7200
, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100
, 32 },
1131 {HW_VENDOR_AMD
, CARD_AMD_RADEON_8500
, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100
, 64 },
1132 {HW_VENDOR_AMD
, CARD_AMD_RADEON_9500
, "ATI Radeon 9500", DRIVER_AMD_R300
, 64 },
1133 {HW_VENDOR_AMD
, CARD_AMD_RADEON_XPRESS_200M
, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300
, 64 },
1134 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X700
, "ATI Radeon X700 SE", DRIVER_AMD_R300
, 128 },
1135 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X1600
, "ATI Radeon X1600 Series", DRIVER_AMD_R300
, 128 },
1136 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2350
, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600
, 256 },
1137 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2600
, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600
, 256 },
1138 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2900
, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600
, 512 },
1139 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD3200
, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600
, 128 },
1140 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4350
, "ATI Radeon HD 4350", DRIVER_AMD_R600
, 256 },
1141 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4600
, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600
, 512 },
1142 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4700
, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600
, 512 },
1143 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4800
, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600
, 512 },
1144 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5400
, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600
, 512 },
1145 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5600
, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600
, 512 },
1146 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5700
, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600
, 512 },
1147 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5800
, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600
, 1024},
1148 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5900
, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600
, 1024},
1149 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6300
, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600
, 1024},
1150 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6400
, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600
, 1024},
1151 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6410D
, "AMD Radeon HD 6410D", DRIVER_AMD_R600
, 1024},
1152 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6550D
, "AMD Radeon HD 6550D", DRIVER_AMD_R600
, 1024},
1153 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600
, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600
, 1024},
1154 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600M
, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600
, 512 },
1155 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6800
, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600
, 1024},
1156 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6900
, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600
, 2048},
1158 {HW_VENDOR_INTEL
, CARD_INTEL_830M
, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1159 {HW_VENDOR_INTEL
, CARD_INTEL_855GM
, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1160 {HW_VENDOR_INTEL
, CARD_INTEL_845G
, "Intel(R) 845G", DRIVER_INTEL_GMA800
, 32 },
1161 {HW_VENDOR_INTEL
, CARD_INTEL_865G
, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1162 {HW_VENDOR_INTEL
, CARD_INTEL_915G
, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1163 {HW_VENDOR_INTEL
, CARD_INTEL_E7221G
, "Intel(R) E7221G", DRIVER_INTEL_GMA900
, 64 },
1164 {HW_VENDOR_INTEL
, CARD_INTEL_915GM
, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1165 {HW_VENDOR_INTEL
, CARD_INTEL_945G
, "Intel(R) 945G", DRIVER_INTEL_GMA950
, 64 },
1166 {HW_VENDOR_INTEL
, CARD_INTEL_945GM
, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950
, 64 },
1167 {HW_VENDOR_INTEL
, CARD_INTEL_945GME
, "Intel(R) 945GME", DRIVER_INTEL_GMA950
, 64 },
1168 {HW_VENDOR_INTEL
, CARD_INTEL_Q35
, "Intel(R) Q35", DRIVER_INTEL_GMA950
, 64 },
1169 {HW_VENDOR_INTEL
, CARD_INTEL_G33
, "Intel(R) G33", DRIVER_INTEL_GMA950
, 64 },
1170 {HW_VENDOR_INTEL
, CARD_INTEL_Q33
, "Intel(R) Q33", DRIVER_INTEL_GMA950
, 64 },
1171 {HW_VENDOR_INTEL
, CARD_INTEL_PNVG
, "Intel(R) IGD", DRIVER_INTEL_GMA950
, 64 },
1172 {HW_VENDOR_INTEL
, CARD_INTEL_PNVM
, "Intel(R) IGD", DRIVER_INTEL_GMA950
, 64 },
1173 {HW_VENDOR_INTEL
, CARD_INTEL_965Q
, "Intel(R) 965Q", DRIVER_INTEL_GMA3000
, 128},
1174 {HW_VENDOR_INTEL
, CARD_INTEL_965G
, "Intel(R) 965G", DRIVER_INTEL_GMA3000
, 128},
1175 {HW_VENDOR_INTEL
, CARD_INTEL_946GZ
, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000
, 128},
1176 {HW_VENDOR_INTEL
, CARD_INTEL_965GM
, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000
, 128},
1177 {HW_VENDOR_INTEL
, CARD_INTEL_965GME
, "Intel(R) 965GME", DRIVER_INTEL_GMA3000
, 128},
1178 {HW_VENDOR_INTEL
, CARD_INTEL_GM45
, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000
, 512},
1179 {HW_VENDOR_INTEL
, CARD_INTEL_IGD
, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000
, 512},
1180 {HW_VENDOR_INTEL
, CARD_INTEL_G45
, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000
, 512},
1181 {HW_VENDOR_INTEL
, CARD_INTEL_Q45
, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000
, 512},
1182 {HW_VENDOR_INTEL
, CARD_INTEL_G41
, "Intel(R) G41", DRIVER_INTEL_GMA3000
, 512},
1183 {HW_VENDOR_INTEL
, CARD_INTEL_B43
, "Intel(R) B43", DRIVER_INTEL_GMA3000
, 512},
1184 {HW_VENDOR_INTEL
, CARD_INTEL_ILKD
, "Intel(R) Ironlake Desktop", DRIVER_INTEL_GMA3000
, 1024},
1185 {HW_VENDOR_INTEL
, CARD_INTEL_ILKM
, "Intel(R) Ironlake Mobile", DRIVER_INTEL_GMA3000
, 1024},
1186 {HW_VENDOR_INTEL
, CARD_INTEL_SNBD
, "Intel(R) Sandybridge Desktop", DRIVER_INTEL_GMA3000
, 1024},
1187 {HW_VENDOR_INTEL
, CARD_INTEL_SNBM
, "Intel(R) Sandybridge Mobile", DRIVER_INTEL_GMA3000
, 1024},
1188 {HW_VENDOR_INTEL
, CARD_INTEL_SNBS
, "Intel(R) Sandybridge Server", DRIVER_INTEL_GMA3000
, 1024},
1189 {HW_VENDOR_INTEL
, CARD_INTEL_IVBD
, "Intel(R) Ivybridge Desktop", DRIVER_INTEL_GMA3000
, 1024},
1190 {HW_VENDOR_INTEL
, CARD_INTEL_IVBM
, "Intel(R) Ivybridge Mobile", DRIVER_INTEL_GMA3000
, 1024},
1191 {HW_VENDOR_INTEL
, CARD_INTEL_IVBS
, "Intel(R) Ivybridge Server", DRIVER_INTEL_GMA3000
, 1024},
1194 static const struct driver_version_information
*get_driver_version_info(enum wined3d_display_driver driver
,
1195 enum wined3d_driver_model driver_model
)
1199 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver
, driver_model
);
1200 for (i
= 0; i
< (sizeof(driver_version_table
) / sizeof(driver_version_table
[0])); i
++)
1202 const struct driver_version_information
*entry
= &driver_version_table
[i
];
1204 if (entry
->driver
== driver
&& entry
->driver_model
== driver_model
)
1206 TRACE_(d3d_caps
)("Found driver '%s' version=%d subversion=%d build=%d\n",
1207 entry
->driver_name
, entry
->version
, entry
->subversion
, entry
->build
);
1215 static void init_driver_info(struct wined3d_driver_info
*driver_info
,
1216 enum wined3d_pci_vendor vendor
, enum wined3d_pci_device device
)
1218 OSVERSIONINFOW os_version
;
1219 WORD driver_os_version
;
1221 enum wined3d_display_driver driver
= DRIVER_UNKNOWN
;
1222 enum wined3d_driver_model driver_model
;
1223 const struct driver_version_information
*version_info
;
1225 if (wined3d_settings
.pci_vendor_id
!= PCI_VENDOR_NONE
)
1227 TRACE_(d3d_caps
)("Overriding PCI vendor ID with: %04x\n", wined3d_settings
.pci_vendor_id
);
1228 vendor
= wined3d_settings
.pci_vendor_id
;
1230 driver_info
->vendor
= vendor
;
1232 if (wined3d_settings
.pci_device_id
!= PCI_DEVICE_NONE
)
1234 TRACE_(d3d_caps
)("Overriding PCI device ID with: %04x\n", wined3d_settings
.pci_device_id
);
1235 device
= wined3d_settings
.pci_device_id
;
1237 driver_info
->device
= device
;
1239 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1240 * overrides the pci ids to a card which is not in our database. */
1241 driver_info
->vidmem
= WINE_DEFAULT_VIDMEM
;
1243 memset(&os_version
, 0, sizeof(os_version
));
1244 os_version
.dwOSVersionInfoSize
= sizeof(os_version
);
1245 if (!GetVersionExW(&os_version
))
1247 ERR("Failed to get OS version, reporting 2000/XP.\n");
1248 driver_os_version
= 6;
1249 driver_model
= DRIVER_MODEL_NT5X
;
1253 TRACE("OS version %u.%u.\n", os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1254 switch (os_version
.dwMajorVersion
)
1257 /* If needed we could distinguish between 9x and NT4, but this code won't make
1258 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1260 driver_os_version
= 4;
1261 driver_model
= DRIVER_MODEL_WIN9X
;
1265 driver_os_version
= 6;
1266 driver_model
= DRIVER_MODEL_NT5X
;
1270 if (os_version
.dwMinorVersion
== 0)
1272 driver_os_version
= 7;
1273 driver_model
= DRIVER_MODEL_NT6X
;
1277 if (os_version
.dwMinorVersion
> 1)
1279 FIXME("Unhandled OS version %u.%u, reporting Win 7.\n",
1280 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1282 driver_os_version
= 8;
1283 driver_model
= DRIVER_MODEL_NT6X
;
1288 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1289 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1290 driver_os_version
= 6;
1291 driver_model
= DRIVER_MODEL_NT5X
;
1296 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1297 * This means that unless the ids are overriden, we will always find a GPU description. */
1298 for (i
= 0; i
< (sizeof(gpu_description_table
) / sizeof(gpu_description_table
[0])); i
++)
1300 if (vendor
== gpu_description_table
[i
].vendor
&& device
== gpu_description_table
[i
].card
)
1302 TRACE_(d3d_caps
)("Found card %04x:%04x in driver DB.\n", vendor
, device
);
1304 driver_info
->description
= gpu_description_table
[i
].description
;
1305 driver_info
->vidmem
= gpu_description_table
[i
].vidmem
* 1024*1024;
1306 driver
= gpu_description_table
[i
].driver
;
1311 if (wined3d_settings
.emulated_textureram
)
1313 TRACE_(d3d_caps
)("Overriding amount of video memory with: %d byte\n", wined3d_settings
.emulated_textureram
);
1314 driver_info
->vidmem
= wined3d_settings
.emulated_textureram
;
1317 /* Try to obtain driver version information for the current Windows version. This fails in
1319 * - the gpu is not available on the currently selected OS version:
1320 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1321 * version information for the current Windows version is returned instead of faked info.
1322 * We do the same and assume the default Windows version to emulate is WinXP.
1324 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1325 * For now return the XP driver info. Perhaps later on we should return VESA.
1327 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1328 * This could be an indication that our database is not up to date, so this should be fixed.
1330 version_info
= get_driver_version_info(driver
, driver_model
);
1333 driver_info
->name
= version_info
->driver_name
;
1334 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1335 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1339 version_info
= get_driver_version_info(driver
, DRIVER_MODEL_NT5X
);
1342 driver_info
->name
= version_info
->driver_name
;
1343 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1344 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1348 driver_info
->description
= "Direct3D HAL";
1349 driver_info
->name
= "Display";
1350 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, 15);
1351 driver_info
->version_low
= MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1353 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1354 vendor
, device
, driver_model
);
1358 TRACE_(d3d_caps
)("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1359 driver_info
->version_high
, driver_info
->version_low
);
1362 /* Context activation is done by the caller. */
1363 static void fixup_extensions(struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
1364 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
1368 for (i
= 0; i
< (sizeof(quirk_table
) / sizeof(*quirk_table
)); ++i
)
1370 if (!quirk_table
[i
].match(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) continue;
1371 TRACE_(d3d_caps
)("Applying driver quirk \"%s\".\n", quirk_table
[i
].description
);
1372 quirk_table
[i
].apply(gl_info
);
1375 /* Find out if PBOs work as they are supposed to. */
1376 test_pbo_functionality(gl_info
);
1379 static DWORD
wined3d_parse_gl_version(const char *gl_version
)
1381 const char *ptr
= gl_version
;
1385 if (major
<= 0) ERR_(d3d_caps
)("Invalid opengl major version: %d.\n", major
);
1387 while (isdigit(*ptr
)) ++ptr
;
1388 if (*ptr
++ != '.') ERR_(d3d_caps
)("Invalid opengl version string: %s.\n", debugstr_a(gl_version
));
1392 TRACE_(d3d_caps
)("Found OpenGL version: %d.%d.\n", major
, minor
);
1394 return MAKEDWORD_VERSION(major
, minor
);
1397 static enum wined3d_gl_vendor
wined3d_guess_gl_vendor(const struct wined3d_gl_info
*gl_info
,
1398 const char *gl_vendor_string
, const char *gl_renderer
)
1401 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1402 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1403 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1405 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1406 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1407 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1408 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1409 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1410 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1411 * DirectDraw, not OpenGL. */
1412 if (gl_info
->supported
[APPLE_FENCE
]
1413 && gl_info
->supported
[APPLE_CLIENT_STORAGE
]
1414 && gl_info
->supported
[APPLE_FLUSH_RENDER
]
1415 && gl_info
->supported
[APPLE_YCBCR_422
])
1416 return GL_VENDOR_APPLE
;
1418 if (strstr(gl_vendor_string
, "NVIDIA"))
1419 return GL_VENDOR_NVIDIA
;
1421 if (strstr(gl_vendor_string
, "ATI"))
1422 return GL_VENDOR_FGLRX
;
1424 if (strstr(gl_vendor_string
, "Intel(R)")
1425 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1426 || strstr(gl_renderer
, "Intel")
1427 || strstr(gl_vendor_string
, "Intel Inc."))
1428 return GL_VENDOR_INTEL
;
1430 if (strstr(gl_vendor_string
, "Mesa")
1431 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1432 || strstr(gl_vendor_string
, "DRI R300 Project")
1433 || strstr(gl_vendor_string
, "X.Org R300 Project")
1434 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1435 || strstr(gl_vendor_string
, "VMware, Inc.")
1436 || strstr(gl_renderer
, "Mesa")
1437 || strstr(gl_renderer
, "Gallium"))
1438 return GL_VENDOR_MESA
;
1440 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1441 debugstr_a(gl_vendor_string
));
1443 return GL_VENDOR_UNKNOWN
;
1446 static enum wined3d_pci_vendor
wined3d_guess_card_vendor(const char *gl_vendor_string
, const char *gl_renderer
)
1448 if (strstr(gl_vendor_string
, "NVIDIA")
1449 || strstr(gl_vendor_string
, "Nouveau")
1450 || strstr(gl_vendor_string
, "nouveau"))
1451 return HW_VENDOR_NVIDIA
;
1453 if (strstr(gl_vendor_string
, "ATI")
1454 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1455 || strstr(gl_vendor_string
, "X.Org R300 Project")
1456 || strstr(gl_renderer
, "AMD")
1457 || strstr(gl_renderer
, "R100")
1458 || strstr(gl_renderer
, "R200")
1459 || strstr(gl_renderer
, "R300")
1460 || strstr(gl_renderer
, "R600")
1461 || strstr(gl_renderer
, "R700"))
1462 return HW_VENDOR_AMD
;
1464 if (strstr(gl_vendor_string
, "Intel(R)")
1465 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1466 || strstr(gl_renderer
, "Intel")
1467 || strstr(gl_renderer
, "i915")
1468 || strstr(gl_vendor_string
, "Intel Inc."))
1469 return HW_VENDOR_INTEL
;
1471 if (strstr(gl_vendor_string
, "Mesa")
1472 || strstr(gl_vendor_string
, "Brian Paul")
1473 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1474 || strstr(gl_vendor_string
, "VMware, Inc."))
1475 return HW_VENDOR_SOFTWARE
;
1477 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string
));
1479 return HW_VENDOR_NVIDIA
;
1482 static UINT
d3d_level_from_gl_info(const struct wined3d_gl_info
*gl_info
)
1486 if (gl_info
->supported
[ARB_MULTITEXTURE
])
1488 if (gl_info
->supported
[ARB_TEXTURE_COMPRESSION
]
1489 && gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
]
1490 && gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
1492 if (level
== 7 && gl_info
->supported
[ARB_MULTISAMPLE
]
1493 && gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
1495 if (level
== 8 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]
1496 && gl_info
->supported
[ARB_VERTEX_SHADER
])
1498 if (level
== 9 && gl_info
->supported
[EXT_GPU_SHADER4
])
1504 static enum wined3d_pci_device
select_card_nvidia_binary(const struct wined3d_gl_info
*gl_info
,
1505 const char *gl_renderer
)
1507 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1510 if (d3d_level
>= 10)
1514 const char *renderer
;
1515 enum wined3d_pci_device id
;
1519 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580
}, /* Geforce 500 - highend */
1520 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570
}, /* Geforce 500 - midend high */
1521 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI
}, /* Geforce 500 - midend */
1522 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560
}, /* Geforce 500 - midend */
1523 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M
}, /* Geforce 500 - midend mobile */
1524 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550
}, /* Geforce 500 - midend */
1525 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M
}, /* Geforce 500 - midend mobile */
1526 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480
}, /* Geforce 400 - highend */
1527 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470
}, /* Geforce 400 - midend high */
1528 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465
}, /* Geforce 400 - midend */
1529 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M
}, /* Geforce 400 - highend mobile */
1530 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460
}, /* Geforce 400 - midend */
1531 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450
}, /* Geforce 400 - midend low */
1532 {"GT 440", CARD_NVIDIA_GEFORCE_GT440
}, /* Geforce 400 - lowend */
1533 {"GT 430", CARD_NVIDIA_GEFORCE_GT430
}, /* Geforce 400 - lowend */
1534 {"GT 420", CARD_NVIDIA_GEFORCE_GT420
}, /* Geforce 400 - lowend */
1535 {"GT 330", CARD_NVIDIA_GEFORCE_GT330
}, /* Geforce 300 - highend */
1536 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1537 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1538 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1539 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1540 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M
}, /* Geforce 300 - midend mobile */
1541 {"320M", CARD_NVIDIA_GEFORCE_320M
}, /* Geforce 300 - midend mobile */
1542 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1543 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1544 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1545 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275
}, /* Geforce 200 - midend high */
1546 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260
}, /* Geforce 200 - midend */
1547 {"GT 240", CARD_NVIDIA_GEFORCE_GT240
}, /* Geforce 200 - midend */
1548 {"GT 220", CARD_NVIDIA_GEFORCE_GT220
}, /* Geforce 200 - lowend */
1549 {"Geforce 310", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1550 {"Geforce 305", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1551 {"Geforce 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1552 {"G 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1553 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1554 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1555 {"9800", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1556 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1557 {"9600", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1558 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1559 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1560 {"9500", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1561 {"9400M", CARD_NVIDIA_GEFORCE_9400M
}, /* Geforce 9 - lowend */
1562 {"9400", CARD_NVIDIA_GEFORCE_9400GT
}, /* Geforce 9 - lowend */
1563 {"9300", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1564 {"9200", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1565 {"9100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1566 {"G 100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1567 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX
}, /* Geforce 8 - highend high */
1568 {"8800", CARD_NVIDIA_GEFORCE_8800GTS
}, /* Geforce 8 - highend */
1569 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1570 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1571 {"8700", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1572 {"8600", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1573 {"8500", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1574 {"8400", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1575 {"8300", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1576 {"8200", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1577 {"8100", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1580 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1582 if (strstr(gl_renderer
, cards
[i
].renderer
))
1586 /* Geforce8-compatible fall back if the GPU is not in the list yet */
1587 return CARD_NVIDIA_GEFORCE_8300GS
;
1590 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1591 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1593 if (d3d_level
>= 9 && gl_info
->supported
[NV_VERTEX_PROGRAM3
])
1597 const char *renderer
;
1598 enum wined3d_pci_device id
;
1602 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1603 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1604 {"7950", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1605 {"7900", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1606 {"7800", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1607 {"7700", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1608 {"7600", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1609 {"7400", CARD_NVIDIA_GEFORCE_7400
}, /* Geforce 7 - lower medium */
1610 {"7300", CARD_NVIDIA_GEFORCE_7300
}, /* Geforce 7 - lowend */
1611 {"6800", CARD_NVIDIA_GEFORCE_6800
}, /* Geforce 6 - highend */
1612 {"6700", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1613 {"6610", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1614 {"6600", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1617 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1619 if (strstr(gl_renderer
, cards
[i
].renderer
))
1623 /* Geforce 6/7 - lowend */
1624 return CARD_NVIDIA_GEFORCE_6200
; /* Geforce 6100/6150/6200/7300/7400/7500 */
1629 /* GeforceFX - highend */
1630 if (strstr(gl_renderer
, "5800")
1631 || strstr(gl_renderer
, "5900")
1632 || strstr(gl_renderer
, "5950")
1633 || strstr(gl_renderer
, "Quadro FX"))
1635 return CARD_NVIDIA_GEFORCEFX_5800
;
1638 /* GeforceFX - midend */
1639 if (strstr(gl_renderer
, "5600")
1640 || strstr(gl_renderer
, "5650")
1641 || strstr(gl_renderer
, "5700")
1642 || strstr(gl_renderer
, "5750"))
1644 return CARD_NVIDIA_GEFORCEFX_5600
;
1647 /* GeforceFX - lowend */
1648 return CARD_NVIDIA_GEFORCEFX_5200
; /* GeforceFX 5100/5200/5250/5300/5500 */
1653 if (strstr(gl_renderer
, "GeForce4 Ti") || strstr(gl_renderer
, "Quadro4"))
1655 return CARD_NVIDIA_GEFORCE4_TI4200
; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1658 return CARD_NVIDIA_GEFORCE3
; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1663 if (strstr(gl_renderer
, "GeForce4 MX"))
1665 return CARD_NVIDIA_GEFORCE4_MX
; /* MX420/MX440/MX460/MX4000 */
1668 if (strstr(gl_renderer
, "GeForce2 MX") || strstr(gl_renderer
, "Quadro2 MXR"))
1670 return CARD_NVIDIA_GEFORCE2_MX
; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1673 if (strstr(gl_renderer
, "GeForce2") || strstr(gl_renderer
, "Quadro2"))
1675 return CARD_NVIDIA_GEFORCE2
; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1678 return CARD_NVIDIA_GEFORCE
; /* Geforce 256/DDR, Quadro */
1681 if (strstr(gl_renderer
, "TNT2"))
1683 return CARD_NVIDIA_RIVA_TNT2
; /* Riva TNT2 standard/M64/Pro/Ultra */
1686 return CARD_NVIDIA_RIVA_TNT
; /* Riva TNT, Vanta */
1689 static enum wined3d_pci_device
select_card_amd_binary(const struct wined3d_gl_info
*gl_info
,
1690 const char *gl_renderer
)
1692 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1694 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1696 * Beware: renderer string do not match exact card model,
1697 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1698 if (d3d_level
>= 10)
1704 const char *renderer
;
1705 enum wined3d_pci_device id
;
1709 /* Northern Islands */
1710 {"HD 6900", CARD_AMD_RADEON_HD6900
},
1711 {"HD 6800", CARD_AMD_RADEON_HD6800
},
1712 {"HD 6770M",CARD_AMD_RADEON_HD6600M
},
1713 {"HD 6750M",CARD_AMD_RADEON_HD6600M
},
1714 {"HD 6630M",CARD_AMD_RADEON_HD6600M
},
1715 {"HD 6600M",CARD_AMD_RADEON_HD6600M
},
1716 {"HD 6600", CARD_AMD_RADEON_HD6600
},
1717 {"HD 6500M",CARD_AMD_RADEON_HD6600M
},
1718 {"HD 6500", CARD_AMD_RADEON_HD6600
},
1719 {"HD 6400", CARD_AMD_RADEON_HD6400
},
1720 {"HD 6300", CARD_AMD_RADEON_HD6300
},
1721 {"HD 6200", CARD_AMD_RADEON_HD6300
},
1723 {"HD 5870", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS PRO */
1724 {"HD 5850", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS XT */
1725 {"HD 5800", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1726 {"HD 5770", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER XT */
1727 {"HD 5750", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER LE */
1728 {"HD 5700", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1729 {"HD 5670", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD XT */
1730 {"HD 5570", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1731 {"HD 5550", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1732 {"HD 5450", CARD_AMD_RADEON_HD5400
}, /* Radeon EG CEDAR PRO */
1734 {"HD 4890", CARD_AMD_RADEON_HD4800
}, /* Radeon RV790 */
1735 {"HD 4870", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1736 {"HD 4850", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1737 {"HD 4830", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1738 {"HD 4800", CARD_AMD_RADEON_HD4800
}, /* Radeon RV7xx HD48xx generic renderer string */
1739 {"HD 4770", CARD_AMD_RADEON_HD4700
}, /* Radeon RV740 */
1740 {"HD 4700", CARD_AMD_RADEON_HD4700
}, /* Radeon RV7xx HD47xx generic renderer string */
1741 {"HD 4670", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1742 {"HD 4650", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1743 {"HD 4600", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1744 {"HD 4550", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1745 {"HD 4350", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1746 /* R600/R700 integrated */
1747 {"HD 3300", CARD_AMD_RADEON_HD3200
},
1748 {"HD 3200", CARD_AMD_RADEON_HD3200
},
1749 {"HD 3100", CARD_AMD_RADEON_HD3200
},
1751 {"HD 3870", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1752 {"HD 3850", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1753 {"HD 2900", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1754 {"HD 3830", CARD_AMD_RADEON_HD2600
}, /* China-only midend */
1755 {"HD 3690", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1756 {"HD 3650", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1757 {"HD 2600", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1758 {"HD 3470", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1759 {"HD 3450", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1760 {"HD 3430", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1761 {"HD 3400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1762 {"HD 2400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1763 {"HD 2350", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1766 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1768 if (strstr(gl_renderer
, cards
[i
].renderer
))
1772 /* Default for when no GPU has been found */
1773 return CARD_AMD_RADEON_HD3200
;
1779 if (strstr(gl_renderer
, "X1600")
1780 || strstr(gl_renderer
, "X1650")
1781 || strstr(gl_renderer
, "X1800")
1782 || strstr(gl_renderer
, "X1900")
1783 || strstr(gl_renderer
, "X1950"))
1785 return CARD_AMD_RADEON_X1600
;
1788 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1789 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1790 if (strstr(gl_renderer
, "X700")
1791 || strstr(gl_renderer
, "X800")
1792 || strstr(gl_renderer
, "X850")
1793 || strstr(gl_renderer
, "X1300")
1794 || strstr(gl_renderer
, "X1400")
1795 || strstr(gl_renderer
, "X1450")
1796 || strstr(gl_renderer
, "X1550")
1797 || strstr(gl_renderer
, "X2300")
1798 || strstr(gl_renderer
, "X2500")
1799 || strstr(gl_renderer
, "HD 2300")
1802 return CARD_AMD_RADEON_X700
;
1805 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1806 if (strstr(gl_renderer
, "Radeon Xpress"))
1808 return CARD_AMD_RADEON_XPRESS_200M
;
1812 return CARD_AMD_RADEON_9500
; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
1816 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1819 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1821 return CARD_AMD_RAGE_128PRO
;
1824 static enum wined3d_pci_device
select_card_intel(const struct wined3d_gl_info
*gl_info
,
1825 const char *gl_renderer
)
1831 const char *renderer
;
1832 enum wined3d_pci_device id
;
1837 {"Ivybridge Server", CARD_INTEL_IVBS
},
1838 {"Ivybridge Mobile", CARD_INTEL_IVBM
},
1839 {"Ivybridge Desktop", CARD_INTEL_IVBD
},
1841 {"Sandybridge Server", CARD_INTEL_SNBS
},
1842 {"Sandybridge Mobile", CARD_INTEL_SNBM
},
1843 {"Sandybridge Desktop", CARD_INTEL_SNBD
},
1845 {"Ironlake Mobile", CARD_INTEL_ILKM
},
1846 {"Ironlake Desktop", CARD_INTEL_ILKD
},
1848 {"B43", CARD_INTEL_B43
},
1849 {"G41", CARD_INTEL_G41
},
1850 {"G45", CARD_INTEL_G45
},
1851 {"Q45", CARD_INTEL_Q45
},
1852 {"Integrated Graphics Device", CARD_INTEL_IGD
},
1853 {"GM45", CARD_INTEL_GM45
},
1855 {"965GME", CARD_INTEL_965GME
},
1856 {"965GM", CARD_INTEL_965GM
},
1857 {"X3100", CARD_INTEL_965GM
}, /* MacOS */
1858 {"946GZ", CARD_INTEL_946GZ
},
1859 {"965G", CARD_INTEL_965G
},
1860 {"965Q", CARD_INTEL_965Q
},
1862 {"Pineview M", CARD_INTEL_PNVM
},
1863 {"Pineview G", CARD_INTEL_PNVG
},
1864 {"IGD", CARD_INTEL_PNVG
},
1865 {"Q33", CARD_INTEL_Q33
},
1866 {"G33", CARD_INTEL_G33
},
1867 {"Q35", CARD_INTEL_Q35
},
1868 {"945GME", CARD_INTEL_945GME
},
1869 {"945GM", CARD_INTEL_945GM
},
1870 {"GMA 950", CARD_INTEL_945GM
}, /* MacOS */
1871 {"945G", CARD_INTEL_945G
},
1873 {"915GM", CARD_INTEL_915GM
},
1874 {"E7221G", CARD_INTEL_E7221G
},
1875 {"915G", CARD_INTEL_915G
},
1877 {"865G", CARD_INTEL_865G
},
1878 {"845G", CARD_INTEL_845G
},
1879 {"855GM", CARD_INTEL_855GM
},
1880 {"830M", CARD_INTEL_830M
},
1883 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1885 if (strstr(gl_renderer
, cards
[i
].renderer
))
1889 return CARD_INTEL_915G
;
1892 static enum wined3d_pci_device
select_card_amd_mesa(const struct wined3d_gl_info
*gl_info
,
1893 const char *gl_renderer
)
1898 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1900 * Beware: renderer string do not match exact card model,
1901 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1902 if (strstr(gl_renderer
, "Gallium"))
1904 /* 20101109 - These are never returned by current Gallium radeon
1905 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
1907 * These are returned but not handled: RC410, RV380. */
1910 const char *renderer
;
1911 enum wined3d_pci_device id
;
1915 /* Northern Islands */
1916 {"CAYMAN", CARD_AMD_RADEON_HD6900
},
1917 {"BARTS", CARD_AMD_RADEON_HD6800
},
1918 {"TURKS", CARD_AMD_RADEON_HD6600
},
1919 {"SUMO2", CARD_AMD_RADEON_HD6410D
}, /* SUMO2 first, because we do a strstr(). */
1920 {"SUMO", CARD_AMD_RADEON_HD6550D
},
1921 {"CAICOS", CARD_AMD_RADEON_HD6400
},
1922 {"PALM", CARD_AMD_RADEON_HD6300
},
1924 {"HEMLOCK", CARD_AMD_RADEON_HD5900
},
1925 {"CYPRESS", CARD_AMD_RADEON_HD5800
},
1926 {"JUNIPER", CARD_AMD_RADEON_HD5700
},
1927 {"REDWOOD", CARD_AMD_RADEON_HD5600
},
1928 {"CEDAR", CARD_AMD_RADEON_HD5400
},
1930 {"R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1931 {"RV790", CARD_AMD_RADEON_HD4800
},
1932 {"RV770", CARD_AMD_RADEON_HD4800
},
1933 {"RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1934 {"RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1935 {"RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1936 /* R600/R700 integrated */
1937 {"RS880", CARD_AMD_RADEON_HD3200
},
1938 {"RS780", CARD_AMD_RADEON_HD3200
},
1940 {"R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1941 {"R600", CARD_AMD_RADEON_HD2900
},
1942 {"RV670", CARD_AMD_RADEON_HD2900
},
1943 {"RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1944 {"RV630", CARD_AMD_RADEON_HD2600
},
1945 {"RV620", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1946 {"RV610", CARD_AMD_RADEON_HD2350
},
1948 {"R580", CARD_AMD_RADEON_X1600
},
1949 {"R520", CARD_AMD_RADEON_X1600
},
1950 {"RV570", CARD_AMD_RADEON_X1600
},
1951 {"RV560", CARD_AMD_RADEON_X1600
},
1952 {"RV535", CARD_AMD_RADEON_X1600
},
1953 {"RV530", CARD_AMD_RADEON_X1600
},
1954 {"RV516", CARD_AMD_RADEON_X700
}, /* X700 is actually R400. */
1955 {"RV515", CARD_AMD_RADEON_X700
},
1957 {"R481", CARD_AMD_RADEON_X700
},
1958 {"R480", CARD_AMD_RADEON_X700
},
1959 {"R430", CARD_AMD_RADEON_X700
},
1960 {"R423", CARD_AMD_RADEON_X700
},
1961 {"R420", CARD_AMD_RADEON_X700
},
1962 {"R410", CARD_AMD_RADEON_X700
},
1963 {"RV410", CARD_AMD_RADEON_X700
},
1964 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
1965 {"RS740", CARD_AMD_RADEON_XPRESS_200M
},
1966 {"RS690", CARD_AMD_RADEON_XPRESS_200M
},
1967 {"RS600", CARD_AMD_RADEON_XPRESS_200M
},
1968 {"RS485", CARD_AMD_RADEON_XPRESS_200M
},
1969 {"RS482", CARD_AMD_RADEON_XPRESS_200M
},
1970 {"RS480", CARD_AMD_RADEON_XPRESS_200M
},
1971 {"RS400", CARD_AMD_RADEON_XPRESS_200M
},
1973 {"R360", CARD_AMD_RADEON_9500
},
1974 {"R350", CARD_AMD_RADEON_9500
},
1975 {"R300", CARD_AMD_RADEON_9500
},
1976 {"RV370", CARD_AMD_RADEON_9500
},
1977 {"RV360", CARD_AMD_RADEON_9500
},
1978 {"RV351", CARD_AMD_RADEON_9500
},
1979 {"RV350", CARD_AMD_RADEON_9500
},
1982 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1984 if (strstr(gl_renderer
, cards
[i
].renderer
))
1989 d3d_level
= d3d_level_from_gl_info(gl_info
);
1990 if (d3d_level
>= 10)
1991 return CARD_AMD_RADEON_HD2600
;
1997 const char *renderer
;
1998 enum wined3d_pci_device id
;
2003 {"(R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
2004 {"(RV790", CARD_AMD_RADEON_HD4800
},
2005 {"(RV770", CARD_AMD_RADEON_HD4800
},
2006 {"(RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
2007 {"(RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
2008 {"(RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
2009 /* R600/R700 integrated */
2010 {"RS880", CARD_AMD_RADEON_HD3200
},
2011 {"RS780", CARD_AMD_RADEON_HD3200
},
2013 {"(R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
2014 {"(R600", CARD_AMD_RADEON_HD2900
},
2015 {"(RV670", CARD_AMD_RADEON_HD2900
},
2016 {"(RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
2017 {"(RV630", CARD_AMD_RADEON_HD2600
},
2018 {"(RV620", CARD_AMD_RADEON_HD2350
}, /* HD2300/HD2400/HD3400 - lowend */
2019 {"(RV610", CARD_AMD_RADEON_HD2350
},
2022 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
2024 if (strstr(gl_renderer
, cards
[i
].renderer
))
2028 return CARD_AMD_RADEON_9500
;
2032 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
2035 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
2037 return CARD_AMD_RAGE_128PRO
;
2040 static enum wined3d_pci_device
select_card_nvidia_mesa(const struct wined3d_gl_info
*gl_info
,
2041 const char *gl_renderer
)
2048 const char *renderer
;
2049 enum wined3d_pci_device id
;
2053 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570
},
2054 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460
},
2055 {"NVC3", CARD_NVIDIA_GEFORCE_GT440
},
2056 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480
},
2057 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M
},
2058 {"NVAC", CARD_NVIDIA_GEFORCE_8200
},
2059 {"NVAA", CARD_NVIDIA_GEFORCE_8200
},
2060 {"NVA8", CARD_NVIDIA_GEFORCE_210
},
2061 {"NVA5", CARD_NVIDIA_GEFORCE_GT220
},
2062 {"NVA3", CARD_NVIDIA_GEFORCE_GT240
},
2063 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280
},
2064 {"NV98", CARD_NVIDIA_GEFORCE_9200
},
2065 {"NV96", CARD_NVIDIA_GEFORCE_9400GT
},
2066 {"NV94", CARD_NVIDIA_GEFORCE_9600GT
},
2067 {"NV92", CARD_NVIDIA_GEFORCE_9800GT
},
2068 {"NV86", CARD_NVIDIA_GEFORCE_8500GT
},
2069 {"NV84", CARD_NVIDIA_GEFORCE_8600GT
},
2070 {"NV68", CARD_NVIDIA_GEFORCE_6200
}, /* 7050 */
2071 {"NV67", CARD_NVIDIA_GEFORCE_6200
}, /* 7000M */
2072 {"NV63", CARD_NVIDIA_GEFORCE_6200
}, /* 7100 */
2073 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX
},
2074 {"NV4E", CARD_NVIDIA_GEFORCE_6200
}, /* 6100 Go / 6150 Go */
2075 {"NV4C", CARD_NVIDIA_GEFORCE_6200
}, /* 6150SE */
2076 {"NV4B", CARD_NVIDIA_GEFORCE_7600
},
2077 {"NV4A", CARD_NVIDIA_GEFORCE_6200
},
2078 {"NV49", CARD_NVIDIA_GEFORCE_7800GT
}, /* 7900 */
2079 {"NV47", CARD_NVIDIA_GEFORCE_7800GT
},
2080 {"NV46", CARD_NVIDIA_GEFORCE_7400
},
2081 {"NV45", CARD_NVIDIA_GEFORCE_6800
},
2082 {"NV44", CARD_NVIDIA_GEFORCE_6200
},
2083 {"NV43", CARD_NVIDIA_GEFORCE_6600GT
},
2084 {"NV42", CARD_NVIDIA_GEFORCE_6800
},
2085 {"NV41", CARD_NVIDIA_GEFORCE_6800
},
2086 {"NV40", CARD_NVIDIA_GEFORCE_6800
},
2087 {"NV38", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5950 Ultra */
2088 {"NV36", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5700/5750 */
2089 {"NV35", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5900 */
2090 {"NV34", CARD_NVIDIA_GEFORCEFX_5200
},
2091 {"NV31", CARD_NVIDIA_GEFORCEFX_5600
},
2092 {"NV30", CARD_NVIDIA_GEFORCEFX_5800
},
2093 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200
},
2094 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200
},
2095 {"nv20", CARD_NVIDIA_GEFORCE3
},
2096 {"nv1F", CARD_NVIDIA_GEFORCE4_MX
}, /* GF4 MX IGP */
2097 {"nv1A", CARD_NVIDIA_GEFORCE2
}, /* GF2 IGP */
2098 {"nv18", CARD_NVIDIA_GEFORCE4_MX
},
2099 {"nv17", CARD_NVIDIA_GEFORCE4_MX
},
2100 {"nv16", CARD_NVIDIA_GEFORCE2
},
2101 {"nv15", CARD_NVIDIA_GEFORCE2
},
2102 {"nv11", CARD_NVIDIA_GEFORCE2_MX
},
2103 {"nv10", CARD_NVIDIA_GEFORCE
},
2104 {"nv05", CARD_NVIDIA_RIVA_TNT2
},
2105 {"nv04", CARD_NVIDIA_RIVA_TNT
},
2106 {"nv03", CARD_NVIDIA_RIVA_128
},
2109 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
2111 if (strstr(gl_renderer
, cards
[i
].renderer
))
2115 FIXME_(d3d_caps
)("Unknown renderer %s.\n", debugstr_a(gl_renderer
));
2117 d3d_level
= d3d_level_from_gl_info(gl_info
);
2119 return CARD_NVIDIA_GEFORCEFX_5600
;
2121 return CARD_NVIDIA_GEFORCE3
;
2123 return CARD_NVIDIA_GEFORCE
;
2125 return CARD_NVIDIA_RIVA_TNT
;
2126 return CARD_NVIDIA_RIVA_128
;
2130 struct vendor_card_selection
2132 enum wined3d_gl_vendor gl_vendor
;
2133 enum wined3d_pci_vendor card_vendor
;
2134 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
2135 enum wined3d_pci_device (*select_card
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
);
2138 static const struct vendor_card_selection vendor_card_select_table
[] =
2140 {GL_VENDOR_NVIDIA
, HW_VENDOR_NVIDIA
, "Nvidia binary driver", select_card_nvidia_binary
},
2141 {GL_VENDOR_APPLE
, HW_VENDOR_NVIDIA
, "Apple OSX NVidia binary driver", select_card_nvidia_binary
},
2142 {GL_VENDOR_APPLE
, HW_VENDOR_AMD
, "Apple OSX AMD/ATI binary driver", select_card_amd_binary
},
2143 {GL_VENDOR_APPLE
, HW_VENDOR_INTEL
, "Apple OSX Intel binary driver", select_card_intel
},
2144 {GL_VENDOR_FGLRX
, HW_VENDOR_AMD
, "AMD/ATI binary driver", select_card_amd_binary
},
2145 {GL_VENDOR_MESA
, HW_VENDOR_AMD
, "Mesa AMD/ATI driver", select_card_amd_mesa
},
2146 {GL_VENDOR_MESA
, HW_VENDOR_NVIDIA
, "Mesa Nouveau driver", select_card_nvidia_mesa
},
2147 {GL_VENDOR_MESA
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
},
2148 {GL_VENDOR_INTEL
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
}
2152 static enum wined3d_pci_device
wined3d_guess_card(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
2153 enum wined3d_gl_vendor
*gl_vendor
, enum wined3d_pci_vendor
*card_vendor
)
2157 /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of
2158 * different GPUs with roughly the same features. In most cases GPUs from a
2159 * certain family differ in clockspeeds, the amount of video memory and the
2160 * number of shader pipelines.
2162 * A Direct3D device object contains the PCI id (vendor + device) of the
2163 * videocard which is used for rendering. Various applications use this
2164 * information to get a rough estimation of the features of the card and
2165 * some might use it for enabling 3d effects only on certain types of
2166 * videocards. In some cases games might even use it to work around bugs
2167 * which happen on certain videocards/driver combinations. The problem is
2168 * that OpenGL only exposes a rendering string containing the name of the
2169 * videocard and not the PCI id.
2171 * Various games depend on the PCI id, so somehow we need to provide one.
2172 * A simple option is to parse the renderer string and translate this to
2173 * the right PCI id. This is a lot of work because there are more than 200
2174 * GPUs just for Nvidia. Various cards share the same renderer string, so
2175 * the amount of code might be 'small' but there are quite a number of
2176 * exceptions which would make this a pain to maintain. Another way would
2177 * be to query the PCI id from the operating system (assuming this is the
2178 * videocard which is used for rendering which is not always the case).
2179 * This would work but it is not very portable. Second it would not work
2180 * well in, let's say, a remote X situation in which the amount of 3d
2181 * features which can be used is limited.
2183 * As said most games only use the PCI id to get an indication of the
2184 * capabilities of the card. It doesn't really matter if the given id is
2185 * the correct one if we return the id of a card with similar 3d features.
2187 * The code below checks the OpenGL capabilities of a videocard and matches
2188 * that to a certain level of Direct3D functionality. Once a card passes
2189 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2190 * least a GeforceFX. To give a better estimate we do a basic check on the
2191 * renderer string but if that won't pass we return a default card. This
2192 * way is better than maintaining a full card database as even without a
2193 * full database we can return a card with similar features. Second the
2194 * size of the database can be made quite small because when you know what
2195 * type of 3d functionality a card has, you know to which GPU family the
2196 * GPU must belong. Because of this you only have to check a small part of
2197 * the renderer string to distinguishes between different models from that
2200 * The code also selects a default amount of video memory which we will
2201 * use for an estimation of the amount of free texture memory. In case of
2202 * real D3D the amount of texture memory includes video memory and system
2203 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2204 * HyperMemory). We don't know how much system memory can be addressed by
2205 * the system but we can make a reasonable estimation about the amount of
2206 * video memory. If the value is slightly wrong it doesn't matter as we
2207 * didn't include AGP-like memory which makes the amount of addressable
2208 * memory higher and second OpenGL isn't that critical it moves to system
2209 * memory behind our backs if really needed. Note that the amount of video
2210 * memory can be overruled using a registry setting. */
2214 for (i
= 0; i
< (sizeof(vendor_card_select_table
) / sizeof(*vendor_card_select_table
)); ++i
)
2216 if ((vendor_card_select_table
[i
].gl_vendor
!= *gl_vendor
)
2217 || (vendor_card_select_table
[i
].card_vendor
!= *card_vendor
))
2219 TRACE_(d3d_caps
)("Applying card_selector \"%s\".\n", vendor_card_select_table
[i
].description
);
2220 return vendor_card_select_table
[i
].select_card(gl_info
, gl_renderer
);
2223 FIXME_(d3d_caps
)("No card selector available for GL vendor %#x and card vendor %04x (using GL_RENDERER %s).\n",
2224 *gl_vendor
, *card_vendor
, debugstr_a(gl_renderer
));
2226 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
2227 * for Nvidia was because the hardware and drivers they make are of good quality. This makes
2228 * them a good generic choice. */
2229 *card_vendor
= HW_VENDOR_NVIDIA
;
2230 d3d_level
= d3d_level_from_gl_info(gl_info
);
2232 return CARD_NVIDIA_GEFORCEFX_5600
;
2234 return CARD_NVIDIA_GEFORCE3
;
2236 return CARD_NVIDIA_GEFORCE
;
2238 return CARD_NVIDIA_RIVA_TNT
;
2239 return CARD_NVIDIA_RIVA_128
;
2242 static const struct fragment_pipeline
*select_fragment_implementation(const struct wined3d_gl_info
*gl_info
)
2244 int vs_selected_mode
, ps_selected_mode
;
2246 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2247 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2248 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_fragment_pipeline
;
2249 else if (ps_selected_mode
== SHADER_ATI
) return &atifs_fragment_pipeline
;
2250 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]
2251 && gl_info
->supported
[NV_TEXTURE_SHADER2
]) return &nvts_fragment_pipeline
;
2252 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]) return &nvrc_fragment_pipeline
;
2253 else return &ffp_fragment_pipeline
;
2256 static const struct wined3d_shader_backend_ops
*select_shader_backend(const struct wined3d_gl_info
*gl_info
)
2258 int vs_selected_mode
, ps_selected_mode
;
2260 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2261 if (vs_selected_mode
== SHADER_GLSL
|| ps_selected_mode
== SHADER_GLSL
) return &glsl_shader_backend
;
2262 if (vs_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_ARB
) return &arb_program_shader_backend
;
2263 return &none_shader_backend
;
2266 static const struct blit_shader
*select_blit_implementation(const struct wined3d_gl_info
*gl_info
)
2268 int vs_selected_mode
, ps_selected_mode
;
2270 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2271 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2272 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_blit
;
2273 else return &ffp_blit
;
2276 static void parse_extension_string(struct wined3d_gl_info
*gl_info
, const char *extensions
,
2277 const struct wined3d_extension_map
*map
, UINT entry_count
)
2285 while (isspace(*extensions
))
2288 while (!isspace(*extensions
) && *extensions
)
2291 len
= extensions
- start
;
2295 TRACE_(d3d_caps
)("- %s\n", debugstr_an(start
, len
));
2297 for (i
= 0; i
< entry_count
; ++i
)
2299 if (len
== strlen(map
[i
].extension_string
)
2300 && !memcmp(start
, map
[i
].extension_string
, len
))
2302 TRACE_(d3d_caps
)(" FOUND: %s support.\n", map
[i
].extension_string
);
2303 gl_info
->supported
[map
[i
].extension
] = TRUE
;
2310 static void load_gl_funcs(struct wined3d_gl_info
*gl_info
, DWORD gl_version
)
2314 #define USE_GL_FUNC(type, pfn, ext, replace) \
2315 if (gl_info->supported[ext]) gl_info->pfn = (type)pwglGetProcAddress(#pfn); \
2316 else if ((ver = ver_for_ext(ext)) && ver <= gl_version) gl_info->pfn = (type)pwglGetProcAddress(#replace); \
2317 else gl_info->pfn = NULL;
2322 #define USE_GL_FUNC(type, pfn, ext, replace) gl_info->pfn = (type)pwglGetProcAddress(#pfn);
2327 /* Context activation is done by the caller. */
2328 static BOOL
wined3d_adapter_init_gl_caps(struct wined3d_adapter
*adapter
)
2330 struct wined3d_driver_info
*driver_info
= &adapter
->driver_info
;
2331 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2332 const char *GL_Extensions
= NULL
;
2333 const char *WGL_Extensions
= NULL
;
2334 const char *gl_vendor_str
, *gl_renderer_str
, *gl_version_str
;
2335 struct fragment_caps fragment_caps
;
2336 enum wined3d_gl_vendor gl_vendor
;
2337 enum wined3d_pci_vendor card_vendor
;
2338 enum wined3d_pci_device device
;
2340 GLfloat gl_floatv
[2];
2345 TRACE_(d3d_caps
)("(%p)\n", gl_info
);
2349 gl_renderer_str
= (const char *)glGetString(GL_RENDERER
);
2350 TRACE_(d3d_caps
)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str
));
2351 if (!gl_renderer_str
)
2354 ERR_(d3d_caps
)("Received a NULL GL_RENDERER.\n");
2358 gl_vendor_str
= (const char *)glGetString(GL_VENDOR
);
2359 TRACE_(d3d_caps
)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str
));
2363 ERR_(d3d_caps
)("Received a NULL GL_VENDOR.\n");
2367 /* Parse the GL_VERSION field into major and minor information */
2368 gl_version_str
= (const char *)glGetString(GL_VERSION
);
2369 TRACE_(d3d_caps
)("GL_VERSION: %s.\n", debugstr_a(gl_version_str
));
2370 if (!gl_version_str
)
2373 ERR_(d3d_caps
)("Received a NULL GL_VERSION.\n");
2376 gl_version
= wined3d_parse_gl_version(gl_version_str
);
2379 * Initialize openGL extension related variables
2380 * with Default values
2382 memset(gl_info
->supported
, 0, sizeof(gl_info
->supported
));
2383 gl_info
->limits
.blends
= 1;
2384 gl_info
->limits
.buffers
= 1;
2385 gl_info
->limits
.textures
= 1;
2386 gl_info
->limits
.texture_coords
= 1;
2387 gl_info
->limits
.fragment_samplers
= 1;
2388 gl_info
->limits
.vertex_samplers
= 0;
2389 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
+ gl_info
->limits
.vertex_samplers
;
2390 gl_info
->limits
.sampler_stages
= 1;
2391 gl_info
->limits
.vertex_attribs
= 16;
2392 gl_info
->limits
.glsl_vs_float_constants
= 0;
2393 gl_info
->limits
.glsl_ps_float_constants
= 0;
2394 gl_info
->limits
.arb_vs_float_constants
= 0;
2395 gl_info
->limits
.arb_vs_native_constants
= 0;
2396 gl_info
->limits
.arb_vs_instructions
= 0;
2397 gl_info
->limits
.arb_vs_temps
= 0;
2398 gl_info
->limits
.arb_ps_float_constants
= 0;
2399 gl_info
->limits
.arb_ps_local_constants
= 0;
2400 gl_info
->limits
.arb_ps_instructions
= 0;
2401 gl_info
->limits
.arb_ps_temps
= 0;
2403 /* Retrieve opengl defaults */
2404 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
2405 gl_info
->limits
.clipplanes
= min(WINED3DMAXUSERCLIPPLANES
, gl_max
);
2406 TRACE_(d3d_caps
)("ClipPlanes support - num Planes=%d\n", gl_max
);
2408 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
2409 gl_info
->limits
.lights
= gl_max
;
2410 TRACE_(d3d_caps
)("Lights support - max lights=%d\n", gl_max
);
2412 glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_max
);
2413 gl_info
->limits
.texture_size
= gl_max
;
2414 TRACE_(d3d_caps
)("Maximum texture size support - max texture size=%d\n", gl_max
);
2416 glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE
, gl_floatv
);
2417 gl_info
->limits
.pointsize_min
= gl_floatv
[0];
2418 gl_info
->limits
.pointsize_max
= gl_floatv
[1];
2419 TRACE_(d3d_caps
)("Maximum point size support - max point size=%f\n", gl_floatv
[1]);
2421 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2422 GL_Extensions
= (const char *)glGetString(GL_EXTENSIONS
);
2426 ERR_(d3d_caps
)("Received a NULL GL_EXTENSIONS.\n");
2432 TRACE_(d3d_caps
)("GL_Extensions reported:\n");
2434 gl_info
->supported
[WINED3D_GL_EXT_NONE
] = TRUE
;
2436 parse_extension_string(gl_info
, GL_Extensions
, gl_extension_map
,
2437 sizeof(gl_extension_map
) / sizeof(*gl_extension_map
));
2439 /* Now work out what GL support this card really has */
2440 load_gl_funcs( gl_info
, gl_version
);
2442 hdc
= pwglGetCurrentDC();
2443 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
2444 if (GL_EXTCALL(wglGetExtensionsStringARB
))
2445 WGL_Extensions
= GL_EXTCALL(wglGetExtensionsStringARB(hdc
));
2446 if (!WGL_Extensions
)
2447 WARN_(d3d_caps
)("WGL extensions not supported.\n");
2449 parse_extension_string(gl_info
, WGL_Extensions
, wgl_extension_map
,
2450 sizeof(wgl_extension_map
) / sizeof(*wgl_extension_map
));
2454 /* Now mark all the extensions supported which are included in the opengl core version. Do this *after*
2455 * loading the functions, otherwise the code above will load the extension entry points instead of the
2456 * core functions, which may not work. */
2457 for (i
= 0; i
< (sizeof(gl_extension_map
) / sizeof(*gl_extension_map
)); ++i
)
2459 if (!gl_info
->supported
[gl_extension_map
[i
].extension
]
2460 && gl_extension_map
[i
].version
<= gl_version
&& gl_extension_map
[i
].version
)
2462 TRACE_(d3d_caps
)(" GL CORE: %s support.\n", gl_extension_map
[i
].extension_string
);
2463 gl_info
->supported
[gl_extension_map
[i
].extension
] = TRUE
;
2467 if (gl_version
>= MAKEDWORD_VERSION(2, 0)) gl_info
->supported
[WINED3D_GL_VERSION_2_0
] = TRUE
;
2469 if (gl_info
->supported
[APPLE_FENCE
])
2471 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2472 * The apple extension interacts with some other apple exts. Disable the NV
2473 * extension if the apple one is support to prevent confusion in other parts
2475 gl_info
->supported
[NV_FENCE
] = FALSE
;
2477 if (gl_info
->supported
[APPLE_FLOAT_PIXELS
])
2479 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2481 * The enums are the same:
2482 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881A
2483 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881B
2484 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2485 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2486 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140B
2488 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
])
2490 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_texture_float support(from GL_APPLE_float_pixels.\n");
2491 gl_info
->supported
[ARB_TEXTURE_FLOAT
] = TRUE
;
2493 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
2495 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_half_float_pixel support(from GL_APPLE_float_pixels.\n");
2496 gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
] = TRUE
;
2499 if (gl_info
->supported
[ARB_MAP_BUFFER_RANGE
])
2501 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2502 * functionality. Prefer the ARB extension */
2503 gl_info
->supported
[APPLE_FLUSH_BUFFER_RANGE
] = FALSE
;
2505 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
2507 TRACE_(d3d_caps
)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2508 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
2510 if (!gl_info
->supported
[ARB_DEPTH_CLAMP
] && gl_info
->supported
[NV_DEPTH_CLAMP
])
2512 TRACE_(d3d_caps
)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2513 gl_info
->supported
[ARB_DEPTH_CLAMP
] = TRUE
;
2515 if (!gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] && gl_info
->supported
[EXT_VERTEX_ARRAY_BGRA
])
2517 TRACE_(d3d_caps
)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2518 gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] = TRUE
;
2520 if (!gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
])
2522 TRACE_(d3d_caps
)(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
2523 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
2525 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2527 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2529 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2530 * are supported. The nv extensions provide the same functionality as the
2531 * ATI one, and a bit more(signed pixelformats). */
2532 gl_info
->supported
[ATI_FRAGMENT_SHADER
] = FALSE
;
2536 if (gl_info
->supported
[ARB_MAP_BUFFER_ALIGNMENT
])
2538 glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT
, &gl_max
);
2539 TRACE_(d3d_caps
)("Minimum buffer map alignment: %d.\n", gl_max
);
2543 WARN_(d3d_caps
)("Driver doesn't guarantee a minimum buffer map alignment.\n");
2545 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2547 glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV
, &gl_max
);
2548 gl_info
->limits
.general_combiners
= gl_max
;
2549 TRACE_(d3d_caps
)("Max general combiners: %d.\n", gl_max
);
2551 if (gl_info
->supported
[ARB_DRAW_BUFFERS
])
2553 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &gl_max
);
2554 gl_info
->limits
.buffers
= gl_max
;
2555 TRACE_(d3d_caps
)("Max draw buffers: %u.\n", gl_max
);
2557 if (gl_info
->supported
[ARB_MULTITEXTURE
])
2559 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
2560 gl_info
->limits
.textures
= min(MAX_TEXTURES
, gl_max
);
2561 TRACE_(d3d_caps
)("Max textures: %d.\n", gl_info
->limits
.textures
);
2563 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2566 glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB
, &gl_max
);
2567 gl_info
->limits
.texture_coords
= min(MAX_TEXTURES
, gl_max
);
2568 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2569 gl_info
->limits
.fragment_samplers
= min(MAX_FRAGMENT_SAMPLERS
, tmp
);
2573 gl_info
->limits
.texture_coords
= max(gl_info
->limits
.texture_coords
, gl_max
);
2574 gl_info
->limits
.fragment_samplers
= max(gl_info
->limits
.fragment_samplers
, gl_max
);
2576 TRACE_(d3d_caps
)("Max texture coords: %d.\n", gl_info
->limits
.texture_coords
);
2577 TRACE_(d3d_caps
)("Max fragment samplers: %d.\n", gl_info
->limits
.fragment_samplers
);
2579 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2582 glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2583 gl_info
->limits
.vertex_samplers
= tmp
;
2584 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2585 gl_info
->limits
.combined_samplers
= tmp
;
2586 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &tmp
);
2587 gl_info
->limits
.vertex_attribs
= tmp
;
2589 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2590 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2591 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2592 * shader is used with fixed function vertex processing we're fine too because fixed function
2593 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2594 * used we have to make sure that all vertex sampler setups are valid together with all
2595 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2596 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2597 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2598 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2599 * a fixed function pipeline anymore.
2601 * So this is just a check to check that our assumption holds true. If not, write a warning
2602 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2603 if (gl_info
->limits
.vertex_samplers
&& gl_info
->limits
.combined_samplers
< 12
2604 && MAX_TEXTURES
+ gl_info
->limits
.vertex_samplers
> gl_info
->limits
.combined_samplers
)
2606 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2607 gl_info
->limits
.vertex_samplers
, gl_info
->limits
.combined_samplers
);
2608 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2609 if (gl_info
->limits
.combined_samplers
> MAX_TEXTURES
)
2610 gl_info
->limits
.vertex_samplers
= gl_info
->limits
.combined_samplers
- MAX_TEXTURES
;
2612 gl_info
->limits
.vertex_samplers
= 0;
2617 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
;
2619 TRACE_(d3d_caps
)("Max vertex samplers: %u.\n", gl_info
->limits
.vertex_samplers
);
2620 TRACE_(d3d_caps
)("Max combined samplers: %u.\n", gl_info
->limits
.combined_samplers
);
2622 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
2624 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
2625 gl_info
->limits
.blends
= gl_max
;
2626 TRACE_(d3d_caps
)("Max blends: %u.\n", gl_info
->limits
.blends
);
2628 if (gl_info
->supported
[EXT_TEXTURE3D
])
2630 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT
, &gl_max
);
2631 gl_info
->limits
.texture3d_size
= gl_max
;
2632 TRACE_(d3d_caps
)("Max texture3D size: %d.\n", gl_info
->limits
.texture3d_size
);
2634 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
2636 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
2637 gl_info
->limits
.anisotropy
= gl_max
;
2638 TRACE_(d3d_caps
)("Max anisotropy: %d.\n", gl_info
->limits
.anisotropy
);
2640 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2642 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2643 gl_info
->limits
.arb_ps_float_constants
= gl_max
;
2644 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_ps_float_constants
);
2645 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2646 gl_info
->limits
.arb_ps_native_constants
= gl_max
;
2647 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2648 gl_info
->limits
.arb_ps_native_constants
);
2649 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2650 gl_info
->limits
.arb_ps_temps
= gl_max
;
2651 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_ps_temps
);
2652 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2653 gl_info
->limits
.arb_ps_instructions
= gl_max
;
2654 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2655 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, &gl_max
));
2656 gl_info
->limits
.arb_ps_local_constants
= gl_max
;
2657 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2659 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
])
2661 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2662 gl_info
->limits
.arb_vs_float_constants
= gl_max
;
2663 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_vs_float_constants
);
2664 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2665 gl_info
->limits
.arb_vs_native_constants
= gl_max
;
2666 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2667 gl_info
->limits
.arb_vs_native_constants
);
2668 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2669 gl_info
->limits
.arb_vs_temps
= gl_max
;
2670 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_vs_temps
);
2671 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2672 gl_info
->limits
.arb_vs_instructions
= gl_max
;
2673 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_vs_instructions
);
2675 if (test_arb_vs_offset_limit(gl_info
)) gl_info
->quirks
|= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
;
2677 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2679 glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2680 gl_info
->limits
.glsl_vs_float_constants
= gl_max
/ 4;
2681 TRACE_(d3d_caps
)("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info
->limits
.glsl_vs_float_constants
);
2683 if (gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2685 glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2686 gl_info
->limits
.glsl_ps_float_constants
= gl_max
/ 4;
2687 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info
->limits
.glsl_ps_float_constants
);
2688 glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB
, &gl_max
);
2689 gl_info
->limits
.glsl_varyings
= gl_max
;
2690 TRACE_(d3d_caps
)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max
, gl_max
/ 4);
2692 if (gl_info
->supported
[ARB_SHADING_LANGUAGE_100
])
2694 const char *str
= (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB
);
2695 unsigned int major
, minor
;
2697 TRACE_(d3d_caps
)("GLSL version string: %s.\n", debugstr_a(str
));
2699 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2700 sscanf(str
, "%u.%u", &major
, &minor
);
2701 gl_info
->glsl_version
= MAKEDWORD_VERSION(major
, minor
);
2703 if (gl_info
->supported
[NV_LIGHT_MAX_EXPONENT
])
2705 glGetFloatv(GL_MAX_SHININESS_NV
, &gl_info
->limits
.shininess
);
2709 gl_info
->limits
.shininess
= 128.0f
;
2711 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
2713 /* If we have full NP2 texture support, disable
2714 * GL_ARB_texture_rectangle because we will never use it.
2715 * This saves a few redundant glDisable calls. */
2716 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = FALSE
;
2718 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
2720 /* Disable NV_register_combiners and fragment shader if this is supported.
2721 * generally the NV extensions are preferred over the ATI ones, and this
2722 * extension is disabled if register_combiners and texture_shader2 are both
2723 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2724 * fragment processing support. */
2725 gl_info
->supported
[NV_REGISTER_COMBINERS
] = FALSE
;
2726 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = FALSE
;
2727 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
2728 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
2730 if (gl_info
->supported
[NV_HALF_FLOAT
])
2732 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2733 gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
] = TRUE
;
2735 checkGLcall("extension detection");
2739 adapter
->fragment_pipe
= select_fragment_implementation(gl_info
);
2740 adapter
->shader_backend
= select_shader_backend(gl_info
);
2741 adapter
->blitter
= select_blit_implementation(gl_info
);
2743 adapter
->fragment_pipe
->get_caps(gl_info
, &fragment_caps
);
2744 gl_info
->limits
.texture_stages
= fragment_caps
.MaxTextureBlendStages
;
2745 TRACE_(d3d_caps
)("Max texture stages: %u.\n", gl_info
->limits
.texture_stages
);
2747 /* In some cases the number of texture stages can be larger than the number
2748 * of samplers. The GF4 for example can use only 2 samplers (no fragment
2749 * shaders), but 8 texture stages (register combiners). */
2750 gl_info
->limits
.sampler_stages
= max(gl_info
->limits
.fragment_samplers
, gl_info
->limits
.texture_stages
);
2752 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
2754 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbuffer
;
2755 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbuffer
;
2756 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffers
;
2757 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffers
;
2758 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorage
;
2759 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisample
;
2760 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameteriv
;
2761 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebuffer
;
2762 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebuffer
;
2763 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffers
;
2764 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffers
;
2765 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatus
;
2766 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1D
;
2767 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2D
;
2768 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3D
;
2769 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbuffer
;
2770 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameteriv
;
2771 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebuffer
;
2772 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmap
;
2773 if (wined3d_settings
.allow_multisampling
)
2775 glGetIntegerv(GL_MAX_SAMPLES
, &gl_max
);
2776 gl_info
->limits
.samples
= gl_max
;
2781 if (gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
2783 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbufferEXT
;
2784 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbufferEXT
;
2785 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffersEXT
;
2786 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffersEXT
;
2787 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorageEXT
;
2788 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameterivEXT
;
2789 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebufferEXT
;
2790 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebufferEXT
;
2791 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffersEXT
;
2792 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffersEXT
;
2793 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatusEXT
;
2794 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1DEXT
;
2795 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2DEXT
;
2796 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3DEXT
;
2797 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbufferEXT
;
2798 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameterivEXT
;
2799 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmapEXT
;
2801 else if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2803 WARN_(d3d_caps
)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
2804 wined3d_settings
.offscreen_rendering_mode
= ORM_BACKBUFFER
;
2806 if (gl_info
->supported
[EXT_FRAMEBUFFER_BLIT
])
2808 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebufferEXT
;
2810 if (gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
2812 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisampleEXT
;
2813 if (wined3d_settings
.allow_multisampling
)
2815 glGetIntegerv(GL_MAX_SAMPLES
, &gl_max
);
2816 gl_info
->limits
.samples
= gl_max
;
2821 /* MRTs are currently only supported when FBOs are used. */
2822 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
2824 gl_info
->limits
.buffers
= 1;
2827 gl_vendor
= wined3d_guess_gl_vendor(gl_info
, gl_vendor_str
, gl_renderer_str
);
2828 card_vendor
= wined3d_guess_card_vendor(gl_vendor_str
, gl_renderer_str
);
2829 TRACE_(d3d_caps
)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str
), gl_vendor
, card_vendor
);
2831 device
= wined3d_guess_card(gl_info
, gl_renderer_str
, &gl_vendor
, &card_vendor
);
2832 TRACE_(d3d_caps
)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor
, device
);
2834 gl_info
->wrap_lookup
[WINED3D_TADDRESS_WRAP
- WINED3D_TADDRESS_WRAP
] = GL_REPEAT
;
2835 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR
- WINED3D_TADDRESS_WRAP
] =
2836 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] ? GL_MIRRORED_REPEAT_ARB
: GL_REPEAT
;
2837 gl_info
->wrap_lookup
[WINED3D_TADDRESS_CLAMP
- WINED3D_TADDRESS_WRAP
] = GL_CLAMP_TO_EDGE
;
2838 gl_info
->wrap_lookup
[WINED3D_TADDRESS_BORDER
- WINED3D_TADDRESS_WRAP
] =
2839 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] ? GL_CLAMP_TO_BORDER_ARB
: GL_REPEAT
;
2840 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR_ONCE
- WINED3D_TADDRESS_WRAP
] =
2841 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] ? GL_MIRROR_CLAMP_TO_EDGE_ATI
: GL_REPEAT
;
2843 fixup_extensions(gl_info
, gl_renderer_str
, gl_vendor
, card_vendor
, device
);
2844 init_driver_info(driver_info
, card_vendor
, device
);
2845 add_gl_compat_wrappers(gl_info
);
2850 UINT CDECL
wined3d_get_adapter_count(const struct wined3d
*wined3d
)
2852 TRACE_(d3d_caps
)("wined3d %p, reporting %u adapters.\n",
2853 wined3d
, wined3d
->adapter_count
);
2855 return wined3d
->adapter_count
;
2858 HRESULT CDECL
wined3d_register_software_device(struct wined3d
*wined3d
, void *init_function
)
2860 FIXME("wined3d %p, init_function %p stub!\n", wined3d
, init_function
);
2865 HMONITOR CDECL
wined3d_get_adapter_monitor(const struct wined3d
*wined3d
, UINT adapter_idx
)
2867 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u.\n", wined3d
, adapter_idx
);
2869 if (adapter_idx
>= wined3d
->adapter_count
)
2872 return MonitorFromPoint(wined3d
->adapters
[adapter_idx
].monitorPoint
, MONITOR_DEFAULTTOPRIMARY
);
2875 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2876 of the same bpp but different resolutions */
2878 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2879 UINT CDECL
wined3d_get_adapter_mode_count(const struct wined3d
*wined3d
, UINT adapter_idx
,
2880 enum wined3d_format_id format_id
)
2882 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s.\n", wined3d
, adapter_idx
, debug_d3dformat(format_id
));
2884 if (adapter_idx
>= wined3d
->adapter_count
)
2887 /* TODO: Store modes per adapter and read it from the adapter structure */
2890 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2891 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2896 memset(&mode
, 0, sizeof(mode
));
2897 mode
.dmSize
= sizeof(mode
);
2899 while (EnumDisplaySettingsExW(NULL
, j
, &mode
, 0))
2903 if (format_id
== WINED3DFMT_UNKNOWN
)
2905 /* This is for D3D8, do not enumerate P8 here */
2906 if (mode
.dmBitsPerPel
== 32 || mode
.dmBitsPerPel
== 16) ++i
;
2908 else if (mode
.dmBitsPerPel
== format_bits
)
2914 TRACE_(d3d_caps
)("Returning %u matching modes (out of %u total) for adapter %u.\n", i
, j
, adapter_idx
);
2920 FIXME_(d3d_caps
)("Adapter not primary display.\n");
2926 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2927 HRESULT CDECL
wined3d_enum_adapter_modes(const struct wined3d
*wined3d
, UINT adapter_idx
,
2928 enum wined3d_format_id format_id
, UINT mode_idx
, struct wined3d_display_mode
*mode
)
2930 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n",
2931 wined3d
, adapter_idx
, debug_d3dformat(format_id
), mode_idx
, mode
);
2933 /* Validate the parameters as much as possible */
2934 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
2935 || mode_idx
>= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, format_id
))
2937 return WINED3DERR_INVALIDCALL
;
2940 /* TODO: Store modes per adapter and read it from the adapter structure */
2943 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2944 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2950 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
2951 DevModeW
.dmSize
= sizeof(DevModeW
);
2953 /* If we are filtering to a specific format (D3D9), then need to skip
2954 all unrelated modes, but if mode is irrelevant (D3D8), then we can
2955 just count through the ones with valid bit depths */
2956 while (i
<= mode_idx
&& EnumDisplaySettingsExW(NULL
, j
++, &DevModeW
, 0))
2958 if (format_id
== WINED3DFMT_UNKNOWN
)
2960 /* This is for D3D8, do not enumerate P8 here */
2961 if (DevModeW
.dmBitsPerPel
== 32 || DevModeW
.dmBitsPerPel
== 16) ++i
;
2963 else if (DevModeW
.dmBitsPerPel
== format_bits
)
2971 TRACE_(d3d_caps
)("No modes found for format (%x - %s)\n", format_id
, debug_d3dformat(format_id
));
2972 return WINED3DERR_INVALIDCALL
;
2976 /* Now get the display mode via the calculated index */
2977 if (EnumDisplaySettingsExW(NULL
, ModeIdx
, &DevModeW
, 0))
2979 mode
->width
= DevModeW
.dmPelsWidth
;
2980 mode
->height
= DevModeW
.dmPelsHeight
;
2981 mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
2982 if (DevModeW
.dmFields
& DM_DISPLAYFREQUENCY
)
2983 mode
->refresh_rate
= DevModeW
.dmDisplayFrequency
;
2985 if (format_id
== WINED3DFMT_UNKNOWN
)
2986 mode
->format_id
= pixelformat_for_depth(DevModeW
.dmBitsPerPel
);
2988 mode
->format_id
= format_id
;
2992 TRACE_(d3d_caps
)("Requested mode %u out of range.\n", mode_idx
);
2993 return WINED3DERR_INVALIDCALL
;
2996 TRACE_(d3d_caps
)("W %d H %d rr %d fmt (%x - %s) bpp %u\n",
2997 mode
->width
, mode
->height
, mode
->refresh_rate
, mode
->format_id
,
2998 debug_d3dformat(mode
->format_id
), DevModeW
.dmBitsPerPel
);
3002 FIXME_(d3d_caps
)("Adapter not primary display\n");
3008 HRESULT CDECL
wined3d_get_adapter_display_mode(const struct wined3d
*wined3d
, UINT adapter_idx
,
3009 struct wined3d_display_mode
*mode
)
3011 TRACE("wined3d %p, adapter_idx %u, display_mode %p.\n", wined3d
, adapter_idx
, mode
);
3013 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
)
3014 return WINED3DERR_INVALIDCALL
;
3021 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
3022 DevModeW
.dmSize
= sizeof(DevModeW
);
3024 EnumDisplaySettingsExW(NULL
, ENUM_CURRENT_SETTINGS
, &DevModeW
, 0);
3025 mode
->width
= DevModeW
.dmPelsWidth
;
3026 mode
->height
= DevModeW
.dmPelsHeight
;
3027 bpp
= DevModeW
.dmBitsPerPel
;
3028 mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
3029 if (DevModeW
.dmFields
& DM_DISPLAYFREQUENCY
)
3030 mode
->refresh_rate
= DevModeW
.dmDisplayFrequency
;
3031 mode
->format_id
= pixelformat_for_depth(bpp
);
3035 FIXME_(d3d_caps
)("Adapter not primary display\n");
3038 TRACE_(d3d_caps
)("returning w:%d, h:%d, ref:%d, fmt:%s\n", mode
->width
,
3039 mode
->height
, mode
->refresh_rate
, debug_d3dformat(mode
->format_id
));
3043 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
3044 and fields being inserted in the middle, a new structure is used in place */
3045 HRESULT CDECL
wined3d_get_adapter_identifier(const struct wined3d
*wined3d
,
3046 UINT adapter_idx
, DWORD flags
, struct wined3d_adapter_identifier
*identifier
)
3048 const struct wined3d_adapter
*adapter
;
3051 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, flags %#x, indentifier %p.\n",
3052 wined3d
, adapter_idx
, flags
, identifier
);
3054 if (adapter_idx
>= wined3d
->adapter_count
)
3055 return WINED3DERR_INVALIDCALL
;
3057 adapter
= &wined3d
->adapters
[adapter_idx
];
3059 /* Return the information requested */
3060 TRACE_(d3d_caps
)("device/Vendor Name and Version detection using FillGLCaps\n");
3062 if (identifier
->driver_size
)
3064 const char *name
= adapter
->driver_info
.name
;
3065 len
= min(strlen(name
), identifier
->driver_size
- 1);
3066 memcpy(identifier
->driver
, name
, len
);
3067 identifier
->driver
[len
] = '\0';
3070 if (identifier
->description_size
)
3072 const char *description
= adapter
->driver_info
.description
;
3073 len
= min(strlen(description
), identifier
->description_size
- 1);
3074 memcpy(identifier
->description
, description
, len
);
3075 identifier
->description
[len
] = '\0';
3078 /* Note that d3d8 doesn't supply a device name. */
3079 if (identifier
->device_name_size
)
3081 static const char *device_name
= "\\\\.\\DISPLAY1"; /* FIXME: May depend on desktop? */
3083 len
= strlen(device_name
);
3084 if (len
>= identifier
->device_name_size
)
3086 ERR("Device name size too small.\n");
3087 return WINED3DERR_INVALIDCALL
;
3090 memcpy(identifier
->device_name
, device_name
, len
);
3091 identifier
->device_name
[len
] = '\0';
3094 identifier
->driver_version
.u
.HighPart
= adapter
->driver_info
.version_high
;
3095 identifier
->driver_version
.u
.LowPart
= adapter
->driver_info
.version_low
;
3096 identifier
->vendor_id
= adapter
->driver_info
.vendor
;
3097 identifier
->device_id
= adapter
->driver_info
.device
;
3098 identifier
->subsystem_id
= 0;
3099 identifier
->revision
= 0;
3100 memcpy(&identifier
->device_identifier
, &IID_D3DDEVICE_D3DUID
, sizeof(identifier
->device_identifier
));
3101 identifier
->whql_level
= (flags
& WINED3DENUM_NO_WHQL_LEVEL
) ? 0 : 1;
3102 memcpy(&identifier
->adapter_luid
, &adapter
->luid
, sizeof(identifier
->adapter_luid
));
3103 identifier
->video_memory
= adapter
->TextureRam
;
3108 static BOOL
wined3d_check_pixel_format_color(const struct wined3d_gl_info
*gl_info
,
3109 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3111 BYTE redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
3113 /* Float formats need FBOs. If FBOs are used this function isn't called */
3114 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3116 if(cfg
->iPixelType
== WGL_TYPE_RGBA_ARB
) { /* Integer RGBA formats */
3117 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
3119 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3123 if(cfg
->redSize
< redSize
)
3126 if(cfg
->greenSize
< greenSize
)
3129 if(cfg
->blueSize
< blueSize
)
3132 if(cfg
->alphaSize
< alphaSize
)
3138 /* Probably a RGBA_float or color index mode */
3142 static BOOL
wined3d_check_pixel_format_depth(const struct wined3d_gl_info
*gl_info
,
3143 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3145 BYTE depthSize
, stencilSize
;
3146 BOOL lockable
= FALSE
;
3148 if (!getDepthStencilBits(format
, &depthSize
, &stencilSize
))
3150 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3154 /* Float formats need FBOs. If FBOs are used this function isn't called */
3155 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3157 if ((format
->id
== WINED3DFMT_D16_LOCKABLE
) || (format
->id
== WINED3DFMT_D32_FLOAT
))
3160 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
3161 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
3162 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
3163 if(!(cfg
->depthSize
== depthSize
|| (!lockable
&& cfg
->depthSize
> depthSize
)))
3166 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
3167 * allow more stencil bits than requested. */
3168 if(cfg
->stencilSize
< stencilSize
)
3174 HRESULT CDECL
wined3d_check_depth_stencil_match(const struct wined3d
*wined3d
,
3175 UINT adapter_idx
, enum wined3d_device_type device_type
, enum wined3d_format_id adapter_format_id
,
3176 enum wined3d_format_id render_target_format_id
, enum wined3d_format_id depth_stencil_format_id
)
3178 const struct wined3d_format
*rt_format
;
3179 const struct wined3d_format
*ds_format
;
3180 const struct wined3d_adapter
*adapter
;
3182 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s,\n"
3183 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
3184 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3185 debug_d3dformat(render_target_format_id
), debug_d3dformat(depth_stencil_format_id
));
3187 if (adapter_idx
>= wined3d
->adapter_count
)
3188 return WINED3DERR_INVALIDCALL
;
3190 adapter
= &wined3d
->adapters
[adapter_idx
];
3191 rt_format
= wined3d_get_format(&adapter
->gl_info
, render_target_format_id
);
3192 ds_format
= wined3d_get_format(&adapter
->gl_info
, depth_stencil_format_id
);
3193 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3195 if ((rt_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3196 && (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)))
3198 TRACE_(d3d_caps
)("Formats match.\n");
3204 const struct wined3d_pixel_format
*cfgs
;
3205 unsigned int cfg_count
;
3208 cfgs
= adapter
->cfgs
;
3209 cfg_count
= adapter
->cfg_count
;
3210 for (i
= 0; i
< cfg_count
; ++i
)
3212 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], rt_format
)
3213 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, &cfgs
[i
], ds_format
))
3215 TRACE_(d3d_caps
)("Formats match.\n");
3221 TRACE_(d3d_caps
)("Unsupported format pair: %s and %s.\n",
3222 debug_d3dformat(render_target_format_id
),
3223 debug_d3dformat(depth_stencil_format_id
));
3225 return WINED3DERR_NOTAVAILABLE
;
3228 HRESULT CDECL
wined3d_check_device_multisample_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
3229 enum wined3d_device_type device_type
, enum wined3d_format_id surface_format_id
, BOOL windowed
,
3230 enum wined3d_multisample_type multisample_type
, DWORD
*quality_levels
)
3232 const struct wined3d_gl_info
*gl_info
;
3234 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
3235 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
3236 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(surface_format_id
),
3237 windowed
, multisample_type
, quality_levels
);
3239 if (adapter_idx
>= wined3d
->adapter_count
)
3240 return WINED3DERR_INVALIDCALL
;
3242 gl_info
= &wined3d
->adapters
[adapter_idx
].gl_info
;
3244 if (multisample_type
> gl_info
->limits
.samples
)
3246 TRACE("Returning not supported.\n");
3248 *quality_levels
= 0;
3250 return WINED3DERR_NOTAVAILABLE
;
3255 if (multisample_type
== WINED3D_MULTISAMPLE_NON_MASKABLE
)
3256 /* FIXME: This is probably wrong. */
3257 *quality_levels
= gl_info
->limits
.samples
;
3259 *quality_levels
= 1;
3265 /* Check if we support bumpmapping for a format */
3266 static BOOL
CheckBumpMapCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3268 /* Ask the fixed function pipeline implementation if it can deal
3269 * with the conversion. If we've got a GL extension giving native
3270 * support this will be an identity conversion. */
3271 return (format
->flags
& WINED3DFMT_FLAG_BUMPMAP
)
3272 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
);
3275 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
3276 static BOOL
CheckDepthStencilCapability(const struct wined3d_adapter
*adapter
,
3277 const struct wined3d_format
*display_format
, const struct wined3d_format
*ds_format
)
3279 /* Only allow depth/stencil formats */
3280 if (!(ds_format
->depth_size
|| ds_format
->stencil_size
)) return FALSE
;
3282 /* Blacklist formats not supported on Windows */
3283 switch (ds_format
->id
)
3285 case WINED3DFMT_S1_UINT_D15_UNORM
: /* Breaks the shadowvol2 dx7 sdk sample */
3286 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3287 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3294 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3296 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
3297 if (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)) return TRUE
;
3303 /* Walk through all WGL pixel formats to find a match */
3304 for (i
= 0; i
< adapter
->cfg_count
; ++i
)
3306 const struct wined3d_pixel_format
*cfg
= &adapter
->cfgs
[i
];
3307 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, cfg
, display_format
)
3308 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, cfg
, ds_format
))
3316 static BOOL
CheckFilterCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3318 /* The flags entry of a format contains the filtering capability */
3319 if ((format
->flags
& WINED3DFMT_FLAG_FILTERING
)
3320 || !(adapter
->gl_info
.quirks
& WINED3D_QUIRK_LIMITED_TEX_FILTERING
))
3326 /* Check the render target capabilities of a format */
3327 static BOOL
CheckRenderTargetCapability(const struct wined3d_adapter
*adapter
,
3328 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*check_format
)
3330 /* Filter out non-RT formats */
3331 if (!(check_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)) return FALSE
;
3332 if (wined3d_settings
.offscreen_rendering_mode
== ORM_BACKBUFFER
)
3334 BYTE AdapterRed
, AdapterGreen
, AdapterBlue
, AdapterAlpha
, AdapterTotalSize
;
3335 BYTE CheckRed
, CheckGreen
, CheckBlue
, CheckAlpha
, CheckTotalSize
;
3336 const struct wined3d_pixel_format
*cfgs
= adapter
->cfgs
;
3339 getColorBits(adapter_format
, &AdapterRed
, &AdapterGreen
, &AdapterBlue
, &AdapterAlpha
, &AdapterTotalSize
);
3340 getColorBits(check_format
, &CheckRed
, &CheckGreen
, &CheckBlue
, &CheckAlpha
, &CheckTotalSize
);
3342 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
3343 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
3344 if(!((AdapterRed
== CheckRed
) && (AdapterGreen
== CheckGreen
) && (AdapterBlue
== CheckBlue
))) {
3345 TRACE_(d3d_caps
)("[FAILED]\n");
3349 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
3350 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
3351 for (i
= 0; i
< adapter
->cfg_count
; ++i
)
3353 if (cfgs
[i
].windowDrawable
3354 && wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], check_format
))
3356 TRACE_(d3d_caps
)("Pixel format %d is compatible with format %s.\n",
3357 cfgs
[i
].iPixelFormat
, debug_d3dformat(check_format
->id
));
3362 else if(wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3364 /* For now return TRUE for FBOs until we have some proper checks.
3365 * Note that this function will only be called when the format is around for texturing. */
3371 static BOOL
CheckSrgbReadCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3373 return format
->flags
& WINED3DFMT_FLAG_SRGB_READ
;
3376 static BOOL
CheckSrgbWriteCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3378 /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
3379 * doing the color fixup in shaders.
3380 * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
3381 if (format
->flags
& WINED3DFMT_FLAG_SRGB_WRITE
)
3383 int vs_selected_mode
;
3384 int ps_selected_mode
;
3385 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
3387 if((ps_selected_mode
== SHADER_ARB
) || (ps_selected_mode
== SHADER_GLSL
)) {
3388 TRACE_(d3d_caps
)("[OK]\n");
3393 TRACE_(d3d_caps
)("[FAILED] - sRGB writes not supported by format %s.\n", debug_d3dformat(format
->id
));
3397 /* Check if a format support blending in combination with pixel shaders */
3398 static BOOL
CheckPostPixelShaderBlendingCapability(const struct wined3d_adapter
*adapter
,
3399 const struct wined3d_format
*format
)
3401 /* The flags entry of a format contains the post pixel shader blending capability */
3402 if (format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
) return TRUE
;
3407 static BOOL
CheckWrapAndMipCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3409 /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
3410 * but we have to report mipmapping so we cannot reject this flag. Tests show that
3411 * windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to show
3412 * that wrapping is supported. The lack of filtering will sort out the mipmapping
3413 * capability anyway.
3415 * For now lets report this on all formats, but in the future we may want to
3416 * restrict it to some should games need that
3421 /* Check if a texture format is supported on the given adapter */
3422 static BOOL
CheckTextureCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3424 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3429 * supported: RGB(A) formats
3431 case WINED3DFMT_B8G8R8_UNORM
:
3432 TRACE_(d3d_caps
)("[FAILED] - Not enumerated on Windows\n");
3434 case WINED3DFMT_B8G8R8A8_UNORM
:
3435 case WINED3DFMT_B8G8R8X8_UNORM
:
3436 case WINED3DFMT_B5G6R5_UNORM
:
3437 case WINED3DFMT_B5G5R5X1_UNORM
:
3438 case WINED3DFMT_B5G5R5A1_UNORM
:
3439 case WINED3DFMT_B4G4R4A4_UNORM
:
3440 case WINED3DFMT_A8_UNORM
:
3441 case WINED3DFMT_B4G4R4X4_UNORM
:
3442 case WINED3DFMT_R8G8B8A8_UNORM
:
3443 case WINED3DFMT_R8G8B8X8_UNORM
:
3444 case WINED3DFMT_B10G10R10A2_UNORM
:
3445 case WINED3DFMT_R10G10B10A2_UNORM
:
3446 case WINED3DFMT_R16G16_UNORM
:
3447 TRACE_(d3d_caps
)("[OK]\n");
3450 case WINED3DFMT_B2G3R3_UNORM
:
3451 TRACE_(d3d_caps
)("[FAILED] - Not supported on Windows\n");
3455 * Not supported: Palettized
3456 * Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of <=Direct3D7.
3457 * Since it is not widely available, don't offer it. Further no Windows driver offers
3458 * WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
3460 case WINED3DFMT_P8_UINT
:
3461 case WINED3DFMT_P8_UINT_A8_UNORM
:
3465 * Supported: (Alpha)-Luminance
3467 case WINED3DFMT_L8_UNORM
:
3468 case WINED3DFMT_L8A8_UNORM
:
3469 case WINED3DFMT_L16_UNORM
:
3470 TRACE_(d3d_caps
)("[OK]\n");
3473 /* Not supported on Windows, thus disabled */
3474 case WINED3DFMT_L4A4_UNORM
:
3475 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3479 * Supported: Depth/Stencil formats
3481 case WINED3DFMT_D16_LOCKABLE
:
3482 case WINED3DFMT_D16_UNORM
:
3483 case WINED3DFMT_X8D24_UNORM
:
3484 case WINED3DFMT_D24_UNORM_S8_UINT
:
3485 case WINED3DFMT_S8_UINT_D24_FLOAT
:
3486 case WINED3DFMT_D32_UNORM
:
3487 case WINED3DFMT_D32_FLOAT
:
3490 case WINED3DFMT_INTZ
:
3491 if (gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
]
3492 || gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3496 /* Not supported on Windows */
3497 case WINED3DFMT_S1_UINT_D15_UNORM
:
3498 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3499 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3503 * Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
3504 * GL_NV_texture_shader). Emulated by shaders
3506 case WINED3DFMT_R8G8_SNORM
:
3507 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
3508 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
3509 case WINED3DFMT_R8G8B8A8_SNORM
:
3510 case WINED3DFMT_R16G16_SNORM
:
3511 /* Ask the shader backend if it can deal with the conversion. If
3512 * we've got a GL extension giving native support this will be an
3513 * identity conversion. */
3514 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
))
3516 TRACE_(d3d_caps
)("[OK]\n");
3519 TRACE_(d3d_caps
)("[FAILED]\n");
3522 case WINED3DFMT_DXT1
:
3523 case WINED3DFMT_DXT2
:
3524 case WINED3DFMT_DXT3
:
3525 case WINED3DFMT_DXT4
:
3526 case WINED3DFMT_DXT5
:
3527 if (gl_info
->supported
[EXT_TEXTURE_COMPRESSION_S3TC
])
3529 TRACE_(d3d_caps
)("[OK]\n");
3532 TRACE_(d3d_caps
)("[FAILED]\n");
3537 * Odd formats - not supported
3539 case WINED3DFMT_VERTEXDATA
:
3540 case WINED3DFMT_R16_UINT
:
3541 case WINED3DFMT_R32_UINT
:
3542 case WINED3DFMT_R16G16B16A16_SNORM
:
3543 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM
:
3544 case WINED3DFMT_R10G11B11_SNORM
:
3545 case WINED3DFMT_R16
:
3546 case WINED3DFMT_AL16
:
3547 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3551 * WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
3553 case WINED3DFMT_R8G8_SNORM_Cx
:
3554 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3558 case WINED3DFMT_UYVY
:
3559 case WINED3DFMT_YUY2
:
3560 if (gl_info
->supported
[APPLE_YCBCR_422
])
3562 TRACE_(d3d_caps
)("[OK]\n");
3565 TRACE_(d3d_caps
)("[FAILED]\n");
3567 case WINED3DFMT_YV12
:
3568 TRACE_(d3d_caps
)("[FAILED]\n");
3571 case WINED3DFMT_R16G16B16A16_UNORM
:
3572 if (gl_info
->quirks
& WINED3D_QUIRK_BROKEN_RGBA16
)
3574 TRACE_(d3d_caps
)("[FAILED]\n");
3577 TRACE_(d3d_caps
)("[OK]\n");
3581 case WINED3DFMT_B2G3R3A8_UNORM
:
3582 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3585 /* Floating point formats */
3586 case WINED3DFMT_R16_FLOAT
:
3587 case WINED3DFMT_R16G16_FLOAT
:
3588 case WINED3DFMT_R16G16B16A16_FLOAT
:
3589 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
] && gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
3591 TRACE_(d3d_caps
)("[OK]\n");
3594 TRACE_(d3d_caps
)("[FAILED]\n");
3597 case WINED3DFMT_R32_FLOAT
:
3598 case WINED3DFMT_R32G32_FLOAT
:
3599 case WINED3DFMT_R32G32B32A32_FLOAT
:
3600 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
])
3602 TRACE_(d3d_caps
)("[OK]\n");
3605 TRACE_(d3d_caps
)("[FAILED]\n");
3608 /* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
3609 * instancing. To query if the card supports instancing CheckDeviceFormat with the special format
3610 * MAKEFOURCC('I','N','S','T') is used. Should a (broken) app check for this provide a proper return value.
3611 * We can do instancing with all shader versions, but we need vertex shaders.
3613 * Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC('I','N','S','T') once
3614 * to enable instancing. WineD3D doesn't need that and just ignores it.
3616 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows.
3618 case WINED3DFMT_INST
:
3619 TRACE("ATI Instancing check hack\n");
3620 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_VERTEX_SHADER
])
3622 TRACE_(d3d_caps
)("[OK]\n");
3625 TRACE_(d3d_caps
)("[FAILED]\n");
3628 /* Some weird FOURCC formats */
3629 case WINED3DFMT_R8G8_B8G8
:
3630 case WINED3DFMT_G8R8_G8B8
:
3631 case WINED3DFMT_MULTI2_ARGB8
:
3632 TRACE_(d3d_caps
)("[FAILED]\n");
3635 /* Vendor specific formats */
3636 case WINED3DFMT_ATI2N
:
3637 if (gl_info
->supported
[ATI_TEXTURE_COMPRESSION_3DC
]
3638 || gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
])
3640 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
)
3641 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
))
3643 TRACE_(d3d_caps
)("[OK]\n");
3647 TRACE_(d3d_caps
)("[OK]\n");
3650 TRACE_(d3d_caps
)("[FAILED]\n");
3653 /* Depth bound test. To query if the card supports it CheckDeviceFormat with the special
3654 * format MAKEFOURCC('N','V','D','B') is used.
3655 * It is enabled by setting D3DRS_ADAPTIVETESS_X render state to MAKEFOURCC('N','V','D','B') and
3656 * then controlled by setting D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax)
3659 case WINED3DFMT_NVDB
:
3660 if (gl_info
->supported
[EXT_DEPTH_BOUNDS_TEST
])
3662 TRACE_(d3d_caps
)("[OK]\n");
3665 TRACE_(d3d_caps
)("[FAILED]\n");
3668 case WINED3DFMT_NVHU
:
3669 case WINED3DFMT_NVHS
:
3670 /* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
3671 * is said to be GL_UNSIGNED_HILO16, NVHS GL_SIGNED_HILO16. Rumours say that d3d computes
3672 * a 3rd channel similarly to D3DFMT_CxV8U8(So NVHS could be called D3DFMT_CxV16U16).
3673 * ATI refused to support formats which can easily be emulated with pixel shaders, so
3674 * Applications have to deal with not having NVHS and NVHU.
3676 TRACE_(d3d_caps
)("[FAILED]\n");
3679 case WINED3DFMT_NULL
:
3680 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3684 case WINED3DFMT_UNKNOWN
:
3688 ERR("Unhandled format %s.\n", debug_d3dformat(format
->id
));
3694 static BOOL
CheckSurfaceCapability(const struct wined3d_adapter
*adapter
,
3695 const struct wined3d_format
*adapter_format
,
3696 const struct wined3d_format
*check_format
,
3697 enum wined3d_surface_type surface_type
)
3699 if (surface_type
== WINED3D_SURFACE_TYPE_GDI
)
3701 switch (check_format
->id
)
3703 case WINED3DFMT_B8G8R8_UNORM
:
3704 TRACE_(d3d_caps
)("[FAILED] - Not enumerated on Windows\n");
3706 case WINED3DFMT_B8G8R8A8_UNORM
:
3707 case WINED3DFMT_B8G8R8X8_UNORM
:
3708 case WINED3DFMT_B5G6R5_UNORM
:
3709 case WINED3DFMT_B5G5R5X1_UNORM
:
3710 case WINED3DFMT_B5G5R5A1_UNORM
:
3711 case WINED3DFMT_B4G4R4A4_UNORM
:
3712 case WINED3DFMT_B2G3R3_UNORM
:
3713 case WINED3DFMT_A8_UNORM
:
3714 case WINED3DFMT_B2G3R3A8_UNORM
:
3715 case WINED3DFMT_B4G4R4X4_UNORM
:
3716 case WINED3DFMT_R10G10B10A2_UNORM
:
3717 case WINED3DFMT_R8G8B8A8_UNORM
:
3718 case WINED3DFMT_R8G8B8X8_UNORM
:
3719 case WINED3DFMT_R16G16_UNORM
:
3720 case WINED3DFMT_B10G10R10A2_UNORM
:
3721 case WINED3DFMT_R16G16B16A16_UNORM
:
3722 case WINED3DFMT_P8_UINT
:
3723 TRACE_(d3d_caps
)("[OK]\n");
3726 TRACE_(d3d_caps
)("[FAILED] - not available on GDI surfaces\n");
3731 /* All format that are supported for textures are supported for surfaces as well */
3732 if (CheckTextureCapability(adapter
, check_format
)) return TRUE
;
3733 /* All depth stencil formats are supported on surfaces */
3734 if (CheckDepthStencilCapability(adapter
, adapter_format
, check_format
)) return TRUE
;
3736 /* If opengl can't process the format natively, the blitter may be able to convert it */
3737 if (adapter
->blitter
->blit_supported(&adapter
->gl_info
, WINED3D_BLIT_OP_COLOR_BLIT
,
3738 NULL
, WINED3D_POOL_DEFAULT
, 0, check_format
,
3739 NULL
, WINED3D_POOL_DEFAULT
, 0, adapter_format
))
3741 TRACE_(d3d_caps
)("[OK]\n");
3745 /* Reject other formats */
3746 TRACE_(d3d_caps
)("[FAILED]\n");
3750 static BOOL
CheckVertexTextureCapability(const struct wined3d_adapter
*adapter
,
3751 const struct wined3d_format
*format
)
3753 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3755 if (!gl_info
->limits
.vertex_samplers
|| !(format
->flags
& WINED3DFMT_FLAG_VTF
))
3760 case WINED3DFMT_R32G32B32A32_FLOAT
:
3761 case WINED3DFMT_R32_FLOAT
:
3764 return !(gl_info
->quirks
& WINED3D_QUIRK_LIMITED_TEX_FILTERING
);
3768 HRESULT CDECL
wined3d_check_device_format(const struct wined3d
*wined3d
, UINT adapter_idx
,
3769 enum wined3d_device_type device_type
, enum wined3d_format_id adapter_format_id
, DWORD usage
,
3770 enum wined3d_resource_type resource_type
, enum wined3d_format_id check_format_id
,
3771 enum wined3d_surface_type surface_type
)
3773 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
3774 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3775 const struct wined3d_format
*adapter_format
= wined3d_get_format(gl_info
, adapter_format_id
);
3776 const struct wined3d_format
*format
= wined3d_get_format(gl_info
, check_format_id
);
3777 DWORD usage_caps
= 0;
3779 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
3780 "resource_type %s, check_format %s, surface_type %#x.\n",
3781 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3782 debug_d3dusage(usage
), debug_d3dusagequery(usage
), debug_d3dresourcetype(resource_type
),
3783 debug_d3dformat(check_format_id
), surface_type
);
3785 if (adapter_idx
>= wined3d
->adapter_count
)
3786 return WINED3DERR_INVALIDCALL
;
3788 switch (resource_type
)
3790 case WINED3D_RTYPE_CUBE_TEXTURE
:
3791 /* Cubetexture allows:
3792 * - WINED3DUSAGE_AUTOGENMIPMAP
3793 * - WINED3DUSAGE_DEPTHSTENCIL
3794 * - WINED3DUSAGE_DYNAMIC
3795 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3796 * - WINED3DUSAGE_RENDERTARGET
3797 * - WINED3DUSAGE_SOFTWAREPROCESSING
3798 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3800 if (surface_type
!= WINED3D_SURFACE_TYPE_OPENGL
)
3802 TRACE_(d3d_caps
)("[FAILED]\n");
3803 return WINED3DERR_NOTAVAILABLE
;
3806 if (!gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3808 TRACE_(d3d_caps
)("[FAILED] - No cube texture support\n");
3809 return WINED3DERR_NOTAVAILABLE
;
3812 if (!CheckTextureCapability(adapter
, format
))
3814 TRACE_(d3d_caps
)("[FAILED] - Cube texture format not supported\n");
3815 return WINED3DERR_NOTAVAILABLE
;
3818 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3820 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3821 /* When autogenmipmap isn't around continue and return
3822 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3823 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3825 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3828 /* Always report dynamic locking. */
3829 if (usage
& WINED3DUSAGE_DYNAMIC
)
3830 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3832 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3834 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3836 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3837 return WINED3DERR_NOTAVAILABLE
;
3839 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3842 /* Always report software processing. */
3843 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
3844 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
3846 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3848 if (!CheckFilterCapability(adapter
, format
))
3850 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
3851 return WINED3DERR_NOTAVAILABLE
;
3853 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
3856 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3858 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3860 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3861 return WINED3DERR_NOTAVAILABLE
;
3863 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3866 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
3868 if (!CheckSrgbReadCapability(adapter
, format
))
3870 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
3871 return WINED3DERR_NOTAVAILABLE
;
3873 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
3876 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
3878 if (!CheckSrgbWriteCapability(adapter
, format
))
3880 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
3881 return WINED3DERR_NOTAVAILABLE
;
3883 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
3886 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
3888 if (!CheckVertexTextureCapability(adapter
, format
))
3890 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
3891 return WINED3DERR_NOTAVAILABLE
;
3893 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
3896 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
3898 if (!CheckWrapAndMipCapability(adapter
, format
))
3900 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
3901 return WINED3DERR_NOTAVAILABLE
;
3903 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
3907 case WINED3D_RTYPE_SURFACE
:
3909 * - WINED3DUSAGE_DEPTHSTENCIL
3910 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3911 * - WINED3DUSAGE_RENDERTARGET
3913 if (!CheckSurfaceCapability(adapter
, adapter_format
, format
, surface_type
))
3915 TRACE_(d3d_caps
)("[FAILED] - Not supported for plain surfaces\n");
3916 return WINED3DERR_NOTAVAILABLE
;
3919 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
3921 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
3923 TRACE_(d3d_caps
)("[FAILED] - No depthstencil support\n");
3924 return WINED3DERR_NOTAVAILABLE
;
3926 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
3929 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3931 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3933 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3934 return WINED3DERR_NOTAVAILABLE
;
3936 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3939 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3941 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3943 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3944 return WINED3DERR_NOTAVAILABLE
;
3946 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3950 case WINED3D_RTYPE_TEXTURE
:
3952 * - WINED3DUSAGE_AUTOGENMIPMAP
3953 * - WINED3DUSAGE_DEPTHSTENCIL
3954 * - WINED3DUSAGE_DMAP
3955 * - WINED3DUSAGE_DYNAMIC
3956 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3957 * - WINED3DUSAGE_RENDERTARGET
3958 * - WINED3DUSAGE_SOFTWAREPROCESSING
3959 * - WINED3DUSAGE_TEXTAPI (d3d9ex)
3960 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3962 if (surface_type
!= WINED3D_SURFACE_TYPE_OPENGL
)
3964 TRACE_(d3d_caps
)("[FAILED]\n");
3965 return WINED3DERR_NOTAVAILABLE
;
3968 if (!CheckTextureCapability(adapter
, format
))
3970 TRACE_(d3d_caps
)("[FAILED] - Texture format not supported\n");
3971 return WINED3DERR_NOTAVAILABLE
;
3974 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3976 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3977 /* When autogenmipmap isn't around continue and return
3978 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3979 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3981 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3984 /* Always report dynamic locking. */
3985 if (usage
& WINED3DUSAGE_DYNAMIC
)
3986 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3988 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3990 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3992 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3993 return WINED3DERR_NOTAVAILABLE
;
3995 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3998 /* Always report software processing. */
3999 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
4000 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
4002 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
4004 if (!CheckFilterCapability(adapter
, format
))
4006 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
4007 return WINED3DERR_NOTAVAILABLE
;
4009 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
4012 if (usage
& WINED3DUSAGE_QUERY_LEGACYBUMPMAP
)
4014 if (!CheckBumpMapCapability(adapter
, format
))
4016 TRACE_(d3d_caps
)("[FAILED] - No legacy bumpmap support\n");
4017 return WINED3DERR_NOTAVAILABLE
;
4019 usage_caps
|= WINED3DUSAGE_QUERY_LEGACYBUMPMAP
;
4022 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4024 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4026 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
4027 return WINED3DERR_NOTAVAILABLE
;
4029 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4032 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4034 if (!CheckSrgbReadCapability(adapter
, format
))
4036 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
4037 return WINED3DERR_NOTAVAILABLE
;
4039 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4042 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4044 if (!CheckSrgbWriteCapability(adapter
, format
))
4046 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
4047 return WINED3DERR_NOTAVAILABLE
;
4049 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4052 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4054 if (!CheckVertexTextureCapability(adapter
, format
))
4056 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
4057 return WINED3DERR_NOTAVAILABLE
;
4059 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4062 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4064 if (!CheckWrapAndMipCapability(adapter
, format
))
4066 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
4067 return WINED3DERR_NOTAVAILABLE
;
4069 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4072 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
4074 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
4076 TRACE_(d3d_caps
)("[FAILED] - No depth stencil support\n");
4077 return WINED3DERR_NOTAVAILABLE
;
4079 if ((format
->flags
& WINED3DFMT_FLAG_SHADOW
) && !gl_info
->supported
[ARB_SHADOW
])
4081 TRACE_(d3d_caps
)("[FAILED] - No shadow sampler support.\n");
4082 return WINED3DERR_NOTAVAILABLE
;
4084 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
4088 case WINED3D_RTYPE_VOLUME_TEXTURE
:
4089 case WINED3D_RTYPE_VOLUME
:
4090 /* Volume is to VolumeTexture what Surface is to Texture, but its
4091 * usage caps are not documented. Most driver seem to offer
4092 * (nearly) the same on Volume and VolumeTexture, so do that too.
4094 * Volumetexture allows:
4095 * - D3DUSAGE_DYNAMIC
4096 * - D3DUSAGE_NONSECURE (d3d9ex)
4097 * - D3DUSAGE_SOFTWAREPROCESSING
4098 * - D3DUSAGE_QUERY_WRAPANDMIP
4100 if (surface_type
!= WINED3D_SURFACE_TYPE_OPENGL
)
4102 TRACE_(d3d_caps
)("[FAILED]\n");
4103 return WINED3DERR_NOTAVAILABLE
;
4106 if (!gl_info
->supported
[EXT_TEXTURE3D
])
4108 TRACE_(d3d_caps
)("[FAILED] - No volume texture support\n");
4109 return WINED3DERR_NOTAVAILABLE
;
4112 if (!CheckTextureCapability(adapter
, format
))
4114 TRACE_(d3d_caps
)("[FAILED] - Format not supported\n");
4115 return WINED3DERR_NOTAVAILABLE
;
4118 /* Filter formats that need conversion; For one part, this
4119 * conversion is unimplemented, and volume textures are huge, so
4120 * it would be a big performance hit. Unless we hit an application
4121 * needing one of those formats, don't advertize them to avoid
4122 * leading applications into temptation. The windows drivers don't
4123 * support most of those formats on volumes anyway, except for
4124 * WINED3DFMT_R32_FLOAT. */
4125 switch (check_format_id
)
4127 case WINED3DFMT_P8_UINT
:
4128 case WINED3DFMT_L4A4_UNORM
:
4129 case WINED3DFMT_R32_FLOAT
:
4130 case WINED3DFMT_R16_FLOAT
:
4131 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
4132 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
4133 case WINED3DFMT_R16G16_UNORM
:
4134 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4135 return WINED3DERR_NOTAVAILABLE
;
4137 case WINED3DFMT_R8G8B8A8_SNORM
:
4138 case WINED3DFMT_R16G16_SNORM
:
4139 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4141 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4142 return WINED3DERR_NOTAVAILABLE
;
4146 case WINED3DFMT_R8G8_SNORM
:
4147 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4149 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4150 return WINED3DERR_NOTAVAILABLE
;
4154 case WINED3DFMT_DXT1
:
4155 case WINED3DFMT_DXT2
:
4156 case WINED3DFMT_DXT3
:
4157 case WINED3DFMT_DXT4
:
4158 case WINED3DFMT_DXT5
:
4159 /* The GL_EXT_texture_compression_s3tc spec requires that
4160 * loading an s3tc compressed texture results in an error.
4161 * While the D3D refrast does support s3tc volumes, at
4162 * least the nvidia windows driver does not, so we're free
4163 * not to support this format. */
4164 TRACE_(d3d_caps
)("[FAILED] - DXTn does not support 3D textures\n");
4165 return WINED3DERR_NOTAVAILABLE
;
4168 /* Do nothing, continue with checking the format below */
4172 /* Always report dynamic locking. */
4173 if (usage
& WINED3DUSAGE_DYNAMIC
)
4174 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
4176 /* Always report software processing. */
4177 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
4178 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
4180 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
4182 if (!CheckFilterCapability(adapter
, format
))
4184 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
4185 return WINED3DERR_NOTAVAILABLE
;
4187 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
4190 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4192 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4194 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
4195 return WINED3DERR_NOTAVAILABLE
;
4197 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4200 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4202 if (!CheckSrgbReadCapability(adapter
, format
))
4204 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
4205 return WINED3DERR_NOTAVAILABLE
;
4207 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4210 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4212 if (!CheckSrgbWriteCapability(adapter
, format
))
4214 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
4215 return WINED3DERR_NOTAVAILABLE
;
4217 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4220 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4222 if (!CheckVertexTextureCapability(adapter
, format
))
4224 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
4225 return WINED3DERR_NOTAVAILABLE
;
4227 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4230 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4232 if (!CheckWrapAndMipCapability(adapter
, format
))
4234 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
4235 return WINED3DERR_NOTAVAILABLE
;
4237 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4242 FIXME_(d3d_caps
)("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type
));
4243 return WINED3DERR_NOTAVAILABLE
;
4246 /* When the usage_caps exactly matches usage return WINED3D_OK except for
4247 * the situation in which WINED3DUSAGE_AUTOGENMIPMAP isn't around, then
4248 * WINED3DOK_NOAUTOGEN is returned if all the other usage flags match. */
4249 if (usage_caps
== usage
)
4251 if (usage_caps
== (usage
& ~WINED3DUSAGE_AUTOGENMIPMAP
))
4252 return WINED3DOK_NOAUTOGEN
;
4254 TRACE_(d3d_caps
)("[FAILED] - Usage %#x requested for format %s and resource_type %s but only %#x is available.\n",
4255 usage
, debug_d3dformat(check_format_id
), debug_d3dresourcetype(resource_type
), usage_caps
);
4257 return WINED3DERR_NOTAVAILABLE
;
4260 HRESULT CDECL
wined3d_check_device_format_conversion(const struct wined3d
*wined3d
, UINT adapter_idx
,
4261 enum wined3d_device_type device_type
, enum wined3d_format_id src_format
, enum wined3d_format_id dst_format
)
4263 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
4264 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(src_format
),
4265 debug_d3dformat(dst_format
));
4270 HRESULT CDECL
wined3d_check_device_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
4271 enum wined3d_device_type device_type
, enum wined3d_format_id display_format
,
4272 enum wined3d_format_id backbuffer_format
, BOOL windowed
)
4277 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
4278 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(display_format
),
4279 debug_d3dformat(backbuffer_format
), windowed
);
4281 if (adapter_idx
>= wined3d
->adapter_count
)
4282 return WINED3DERR_INVALIDCALL
;
4284 /* The task of this function is to check whether a certain display / backbuffer format
4285 * combination is available on the given adapter. In fullscreen mode microsoft specified
4286 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
4287 * and display format should match exactly.
4288 * In windowed mode format conversion can occur and this depends on the driver. When format
4289 * conversion is done, this function should nevertheless fail and applications need to use
4290 * CheckDeviceFormatConversion.
4291 * At the moment we assume that fullscreen and windowed have the same capabilities. */
4293 /* There are only 4 display formats. */
4294 if (!(display_format
== WINED3DFMT_B5G6R5_UNORM
4295 || display_format
== WINED3DFMT_B5G5R5X1_UNORM
4296 || display_format
== WINED3DFMT_B8G8R8X8_UNORM
4297 || display_format
== WINED3DFMT_B10G10R10A2_UNORM
))
4299 TRACE_(d3d_caps
)("Format %s is not supported as display format.\n", debug_d3dformat(display_format
));
4300 return WINED3DERR_NOTAVAILABLE
;
4303 /* If the requested display format is not available, don't continue. */
4304 mode_count
= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, display_format
);
4307 TRACE_(d3d_caps
)("No available modes for display format %s.\n", debug_d3dformat(display_format
));
4308 return WINED3DERR_NOTAVAILABLE
;
4311 /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format,
4312 * it means 'reuse' the display format for the backbuffer. */
4313 if (!windowed
&& backbuffer_format
== WINED3DFMT_UNKNOWN
)
4315 TRACE_(d3d_caps
)("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n");
4316 return WINED3DERR_NOTAVAILABLE
;
4319 /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with
4320 * backbuffer format WINED3DFMT_B5G6R5_UNORM. */
4321 if (display_format
== WINED3DFMT_B5G6R5_UNORM
&& backbuffer_format
!= WINED3DFMT_B5G6R5_UNORM
)
4323 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4324 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4325 return WINED3DERR_NOTAVAILABLE
;
4328 /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with
4329 * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and
4330 * WINED3DFMT_B5G5R5A1_UNORM. */
4331 if (display_format
== WINED3DFMT_B5G5R5X1_UNORM
4332 && !(backbuffer_format
== WINED3DFMT_B5G5R5X1_UNORM
|| backbuffer_format
== WINED3DFMT_B5G5R5A1_UNORM
))
4334 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4335 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4336 return WINED3DERR_NOTAVAILABLE
;
4339 /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with
4340 * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and
4341 * WINED3DFMT_B8G8R8A8_UNORM. */
4342 if (display_format
== WINED3DFMT_B8G8R8X8_UNORM
4343 && !(backbuffer_format
== WINED3DFMT_B8G8R8X8_UNORM
|| backbuffer_format
== WINED3DFMT_B8G8R8A8_UNORM
))
4345 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4346 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4347 return WINED3DERR_NOTAVAILABLE
;
4350 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it
4351 * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */
4352 if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
4353 && (backbuffer_format
!= WINED3DFMT_B10G10R10A2_UNORM
|| windowed
))
4355 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4356 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4357 return WINED3DERR_NOTAVAILABLE
;
4360 /* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
4361 hr
= wined3d_check_device_format(wined3d
, adapter_idx
, device_type
, display_format
,
4362 WINED3DUSAGE_RENDERTARGET
, WINED3D_RTYPE_SURFACE
, backbuffer_format
, WINED3D_SURFACE_TYPE_OPENGL
);
4364 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4365 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4370 HRESULT CDECL
wined3d_get_device_caps(const struct wined3d
*wined3d
, UINT adapter_idx
,
4371 enum wined3d_device_type device_type
, WINED3DCAPS
*caps
)
4373 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
4374 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4375 int vs_selected_mode
;
4376 int ps_selected_mode
;
4377 struct shader_caps shader_caps
;
4378 struct fragment_caps fragment_caps
;
4379 DWORD ckey_caps
, blit_caps
, fx_caps
, pal_caps
;
4381 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
4382 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), caps
);
4384 if (adapter_idx
>= wined3d
->adapter_count
)
4385 return WINED3DERR_INVALIDCALL
;
4387 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
4389 /* ------------------------------------------------
4390 The following fields apply to both d3d8 and d3d9
4391 ------------------------------------------------ */
4392 /* Not quite true, but use h/w supported by opengl I suppose */
4393 caps
->DeviceType
= (device_type
== WINED3D_DEVICE_TYPE_HAL
) ? WINED3D_DEVICE_TYPE_HAL
: WINED3D_DEVICE_TYPE_REF
;
4394 caps
->AdapterOrdinal
= adapter_idx
;
4397 caps
->Caps2
= WINED3DCAPS2_CANRENDERWINDOWED
|
4398 WINED3DCAPS2_FULLSCREENGAMMA
|
4399 WINED3DCAPS2_DYNAMICTEXTURES
;
4400 if (gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
4401 caps
->Caps2
|= WINED3DCAPS2_CANAUTOGENMIPMAP
;
4403 caps
->Caps3
= WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
4404 WINED3DCAPS3_COPY_TO_VIDMEM
|
4405 WINED3DCAPS3_COPY_TO_SYSTEMMEM
;
4407 caps
->PresentationIntervals
= WINED3DPRESENT_INTERVAL_IMMEDIATE
|
4408 WINED3DPRESENT_INTERVAL_ONE
;
4410 caps
->CursorCaps
= WINED3DCURSORCAPS_COLOR
|
4411 WINED3DCURSORCAPS_LOWRES
;
4413 caps
->DevCaps
= WINED3DDEVCAPS_FLOATTLVERTEX
|
4414 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY
|
4415 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
4416 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY
|
4417 WINED3DDEVCAPS_DRAWPRIMTLVERTEX
|
4418 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT
|
4419 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY
|
4420 WINED3DDEVCAPS_PUREDEVICE
|
4421 WINED3DDEVCAPS_HWRASTERIZATION
|
4422 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY
|
4423 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY
|
4424 WINED3DDEVCAPS_CANRENDERAFTERFLIP
|
4425 WINED3DDEVCAPS_DRAWPRIMITIVES2
|
4426 WINED3DDEVCAPS_DRAWPRIMITIVES2EX
|
4427 WINED3DDEVCAPS_RTPATCHES
;
4429 caps
->PrimitiveMiscCaps
= WINED3DPMISCCAPS_CULLNONE
|
4430 WINED3DPMISCCAPS_CULLCCW
|
4431 WINED3DPMISCCAPS_CULLCW
|
4432 WINED3DPMISCCAPS_COLORWRITEENABLE
|
4433 WINED3DPMISCCAPS_CLIPTLVERTS
|
4434 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
4435 WINED3DPMISCCAPS_MASKZ
|
4436 WINED3DPMISCCAPS_BLENDOP
|
4437 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
;
4439 WINED3DPMISCCAPS_NULLREFERENCE
4440 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
4441 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
4442 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
4444 if (gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
] && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
4445 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_SEPARATEALPHABLEND
;
4446 if (gl_info
->supported
[EXT_DRAW_BUFFERS2
])
4447 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
;
4449 caps
->RasterCaps
= WINED3DPRASTERCAPS_DITHER
|
4450 WINED3DPRASTERCAPS_PAT
|
4451 WINED3DPRASTERCAPS_WFOG
|
4452 WINED3DPRASTERCAPS_ZFOG
|
4453 WINED3DPRASTERCAPS_FOGVERTEX
|
4454 WINED3DPRASTERCAPS_FOGTABLE
|
4455 WINED3DPRASTERCAPS_STIPPLE
|
4456 WINED3DPRASTERCAPS_SUBPIXEL
|
4457 WINED3DPRASTERCAPS_ZTEST
|
4458 WINED3DPRASTERCAPS_SCISSORTEST
|
4459 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
4460 WINED3DPRASTERCAPS_DEPTHBIAS
;
4462 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4464 caps
->RasterCaps
|= WINED3DPRASTERCAPS_ANISOTROPY
|
4465 WINED3DPRASTERCAPS_ZBIAS
|
4466 WINED3DPRASTERCAPS_MIPMAPLODBIAS
;
4468 if (gl_info
->supported
[NV_FOG_DISTANCE
])
4470 caps
->RasterCaps
|= WINED3DPRASTERCAPS_FOGRANGE
;
4473 WINED3DPRASTERCAPS_COLORPERSPECTIVE
4474 WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
4475 WINED3DPRASTERCAPS_ANTIALIASEDGES
4476 WINED3DPRASTERCAPS_ZBUFFERLESSHSR
4477 WINED3DPRASTERCAPS_WBUFFER */
4479 caps
->ZCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4480 WINED3DPCMPCAPS_EQUAL
|
4481 WINED3DPCMPCAPS_GREATER
|
4482 WINED3DPCMPCAPS_GREATEREQUAL
|
4483 WINED3DPCMPCAPS_LESS
|
4484 WINED3DPCMPCAPS_LESSEQUAL
|
4485 WINED3DPCMPCAPS_NEVER
|
4486 WINED3DPCMPCAPS_NOTEQUAL
;
4488 caps
->SrcBlendCaps
= WINED3DPBLENDCAPS_BOTHINVSRCALPHA
|
4489 WINED3DPBLENDCAPS_BOTHSRCALPHA
|
4490 WINED3DPBLENDCAPS_DESTALPHA
|
4491 WINED3DPBLENDCAPS_DESTCOLOR
|
4492 WINED3DPBLENDCAPS_INVDESTALPHA
|
4493 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4494 WINED3DPBLENDCAPS_INVSRCALPHA
|
4495 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4496 WINED3DPBLENDCAPS_ONE
|
4497 WINED3DPBLENDCAPS_SRCALPHA
|
4498 WINED3DPBLENDCAPS_SRCALPHASAT
|
4499 WINED3DPBLENDCAPS_SRCCOLOR
|
4500 WINED3DPBLENDCAPS_ZERO
;
4502 caps
->DestBlendCaps
= WINED3DPBLENDCAPS_DESTALPHA
|
4503 WINED3DPBLENDCAPS_DESTCOLOR
|
4504 WINED3DPBLENDCAPS_INVDESTALPHA
|
4505 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4506 WINED3DPBLENDCAPS_INVSRCALPHA
|
4507 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4508 WINED3DPBLENDCAPS_ONE
|
4509 WINED3DPBLENDCAPS_SRCALPHA
|
4510 WINED3DPBLENDCAPS_SRCCOLOR
|
4511 WINED3DPBLENDCAPS_ZERO
;
4512 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
4513 * according to the glBlendFunc manpage
4515 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
4516 * legacy settings for srcblend only
4519 if (gl_info
->supported
[EXT_BLEND_COLOR
])
4521 caps
->SrcBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4522 caps
->DestBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4526 caps
->AlphaCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4527 WINED3DPCMPCAPS_EQUAL
|
4528 WINED3DPCMPCAPS_GREATER
|
4529 WINED3DPCMPCAPS_GREATEREQUAL
|
4530 WINED3DPCMPCAPS_LESS
|
4531 WINED3DPCMPCAPS_LESSEQUAL
|
4532 WINED3DPCMPCAPS_NEVER
|
4533 WINED3DPCMPCAPS_NOTEQUAL
;
4535 caps
->ShadeCaps
= WINED3DPSHADECAPS_SPECULARGOURAUDRGB
|
4536 WINED3DPSHADECAPS_COLORGOURAUDRGB
|
4537 WINED3DPSHADECAPS_ALPHAFLATBLEND
|
4538 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND
|
4539 WINED3DPSHADECAPS_COLORFLATRGB
|
4540 WINED3DPSHADECAPS_FOGFLAT
|
4541 WINED3DPSHADECAPS_FOGGOURAUD
|
4542 WINED3DPSHADECAPS_SPECULARFLATRGB
;
4544 caps
->TextureCaps
= WINED3DPTEXTURECAPS_ALPHA
|
4545 WINED3DPTEXTURECAPS_ALPHAPALETTE
|
4546 WINED3DPTEXTURECAPS_TRANSPARENCY
|
4547 WINED3DPTEXTURECAPS_BORDER
|
4548 WINED3DPTEXTURECAPS_MIPMAP
|
4549 WINED3DPTEXTURECAPS_PROJECTED
|
4550 WINED3DPTEXTURECAPS_PERSPECTIVE
;
4552 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4554 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_POW2
|
4555 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL
;
4558 if (gl_info
->supported
[EXT_TEXTURE3D
])
4560 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP
|
4561 WINED3DPTEXTURECAPS_MIPVOLUMEMAP
;
4562 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4564 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2
;
4568 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4570 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP
|
4571 WINED3DPTEXTURECAPS_MIPCUBEMAP
;
4572 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4574 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP_POW2
;
4578 caps
->TextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4579 WINED3DPTFILTERCAPS_MAGFPOINT
|
4580 WINED3DPTFILTERCAPS_MINFLINEAR
|
4581 WINED3DPTFILTERCAPS_MINFPOINT
|
4582 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4583 WINED3DPTFILTERCAPS_MIPFPOINT
|
4584 WINED3DPTFILTERCAPS_LINEAR
|
4585 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4586 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4587 WINED3DPTFILTERCAPS_MIPLINEAR
|
4588 WINED3DPTFILTERCAPS_MIPNEAREST
|
4589 WINED3DPTFILTERCAPS_NEAREST
;
4591 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4593 caps
->TextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4594 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4597 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4599 caps
->CubeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4600 WINED3DPTFILTERCAPS_MAGFPOINT
|
4601 WINED3DPTFILTERCAPS_MINFLINEAR
|
4602 WINED3DPTFILTERCAPS_MINFPOINT
|
4603 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4604 WINED3DPTFILTERCAPS_MIPFPOINT
|
4605 WINED3DPTFILTERCAPS_LINEAR
|
4606 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4607 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4608 WINED3DPTFILTERCAPS_MIPLINEAR
|
4609 WINED3DPTFILTERCAPS_MIPNEAREST
|
4610 WINED3DPTFILTERCAPS_NEAREST
;
4612 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4614 caps
->CubeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4615 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4620 caps
->CubeTextureFilterCaps
= 0;
4623 if (gl_info
->supported
[EXT_TEXTURE3D
])
4625 caps
->VolumeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4626 WINED3DPTFILTERCAPS_MAGFPOINT
|
4627 WINED3DPTFILTERCAPS_MINFLINEAR
|
4628 WINED3DPTFILTERCAPS_MINFPOINT
|
4629 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4630 WINED3DPTFILTERCAPS_MIPFPOINT
|
4631 WINED3DPTFILTERCAPS_LINEAR
|
4632 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4633 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4634 WINED3DPTFILTERCAPS_MIPLINEAR
|
4635 WINED3DPTFILTERCAPS_MIPNEAREST
|
4636 WINED3DPTFILTERCAPS_NEAREST
;
4640 caps
->VolumeTextureFilterCaps
= 0;
4643 caps
->TextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4644 WINED3DPTADDRESSCAPS_CLAMP
|
4645 WINED3DPTADDRESSCAPS_WRAP
;
4647 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4649 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4651 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4653 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4655 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4657 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4660 if (gl_info
->supported
[EXT_TEXTURE3D
])
4662 caps
->VolumeTextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4663 WINED3DPTADDRESSCAPS_CLAMP
|
4664 WINED3DPTADDRESSCAPS_WRAP
;
4665 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4667 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4669 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4671 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4673 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4675 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4680 caps
->VolumeTextureAddressCaps
= 0;
4683 caps
->LineCaps
= WINED3DLINECAPS_TEXTURE
|
4684 WINED3DLINECAPS_ZTEST
|
4685 WINED3DLINECAPS_BLEND
|
4686 WINED3DLINECAPS_ALPHACMP
|
4687 WINED3DLINECAPS_FOG
;
4688 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
4689 * idea how generating the smoothing alpha values works; the result is different
4692 caps
->MaxTextureWidth
= gl_info
->limits
.texture_size
;
4693 caps
->MaxTextureHeight
= gl_info
->limits
.texture_size
;
4695 if (gl_info
->supported
[EXT_TEXTURE3D
])
4696 caps
->MaxVolumeExtent
= gl_info
->limits
.texture3d_size
;
4698 caps
->MaxVolumeExtent
= 0;
4700 caps
->MaxTextureRepeat
= 32768;
4701 caps
->MaxTextureAspectRatio
= gl_info
->limits
.texture_size
;
4702 caps
->MaxVertexW
= 1.0f
;
4704 caps
->GuardBandLeft
= 0.0f
;
4705 caps
->GuardBandTop
= 0.0f
;
4706 caps
->GuardBandRight
= 0.0f
;
4707 caps
->GuardBandBottom
= 0.0f
;
4709 caps
->ExtentsAdjust
= 0.0f
;
4711 caps
->StencilCaps
= WINED3DSTENCILCAPS_DECRSAT
|
4712 WINED3DSTENCILCAPS_INCRSAT
|
4713 WINED3DSTENCILCAPS_INVERT
|
4714 WINED3DSTENCILCAPS_KEEP
|
4715 WINED3DSTENCILCAPS_REPLACE
|
4716 WINED3DSTENCILCAPS_ZERO
;
4717 if (gl_info
->supported
[EXT_STENCIL_WRAP
])
4719 caps
->StencilCaps
|= WINED3DSTENCILCAPS_DECR
|
4720 WINED3DSTENCILCAPS_INCR
;
4722 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
] || gl_info
->supported
[ATI_SEPARATE_STENCIL
])
4724 caps
->StencilCaps
|= WINED3DSTENCILCAPS_TWOSIDED
;
4727 caps
->FVFCaps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
4729 caps
->MaxUserClipPlanes
= gl_info
->limits
.clipplanes
;
4730 caps
->MaxActiveLights
= gl_info
->limits
.lights
;
4732 caps
->MaxVertexBlendMatrices
= gl_info
->limits
.blends
;
4733 caps
->MaxVertexBlendMatrixIndex
= 0;
4735 caps
->MaxAnisotropy
= gl_info
->limits
.anisotropy
;
4736 caps
->MaxPointSize
= gl_info
->limits
.pointsize_max
;
4739 /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
4740 caps
->VertexProcessingCaps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
|
4741 WINED3DVTXPCAPS_MATERIALSOURCE7
|
4742 WINED3DVTXPCAPS_POSITIONALLIGHTS
|
4743 WINED3DVTXPCAPS_LOCALVIEWER
|
4744 WINED3DVTXPCAPS_VERTEXFOG
|
4745 WINED3DVTXPCAPS_TEXGEN
;
4747 caps
->MaxPrimitiveCount
= 0xFFFFF; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4748 caps
->MaxVertexIndex
= 0xFFFFF;
4749 caps
->MaxStreams
= MAX_STREAMS
;
4750 caps
->MaxStreamStride
= 1024;
4752 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4753 caps
->DevCaps2
= WINED3DDEVCAPS2_STREAMOFFSET
|
4754 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
;
4755 caps
->MaxNpatchTessellationLevel
= 0;
4756 caps
->MasterAdapterOrdinal
= 0;
4757 caps
->AdapterOrdinalInGroup
= 0;
4758 caps
->NumberOfAdaptersInGroup
= 1;
4760 caps
->NumSimultaneousRTs
= gl_info
->limits
.buffers
;
4762 caps
->StretchRectFilterCaps
= WINED3DPTFILTERCAPS_MINFPOINT
|
4763 WINED3DPTFILTERCAPS_MAGFPOINT
|
4764 WINED3DPTFILTERCAPS_MINFLINEAR
|
4765 WINED3DPTFILTERCAPS_MAGFLINEAR
;
4766 caps
->VertexTextureFilterCaps
= 0;
4768 adapter
->shader_backend
->shader_get_caps(&adapter
->gl_info
, &shader_caps
);
4769 adapter
->fragment_pipe
->get_caps(&adapter
->gl_info
, &fragment_caps
);
4771 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4772 caps
->PrimitiveMiscCaps
|= fragment_caps
.PrimitiveMiscCaps
;
4774 /* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
4775 * Ignore shader model capabilities if disabled in config
4777 if (vs_selected_mode
== SHADER_NONE
)
4779 TRACE_(d3d_caps
)("Vertex shader disabled in config, reporting version 0.0\n");
4780 caps
->VertexShaderVersion
= 0;
4781 caps
->MaxVertexShaderConst
= 0;
4785 caps
->VertexShaderVersion
= shader_caps
.VertexShaderVersion
;
4786 caps
->MaxVertexShaderConst
= shader_caps
.MaxVertexShaderConst
;
4789 if (ps_selected_mode
== SHADER_NONE
)
4791 TRACE_(d3d_caps
)("Pixel shader disabled in config, reporting version 0.0\n");
4792 caps
->PixelShaderVersion
= 0;
4793 caps
->PixelShader1xMaxValue
= 0.0f
;
4795 caps
->PixelShaderVersion
= shader_caps
.PixelShaderVersion
;
4796 caps
->PixelShader1xMaxValue
= shader_caps
.PixelShader1xMaxValue
;
4799 caps
->TextureOpCaps
= fragment_caps
.TextureOpCaps
;
4800 caps
->MaxTextureBlendStages
= fragment_caps
.MaxTextureBlendStages
;
4801 caps
->MaxSimultaneousTextures
= fragment_caps
.MaxSimultaneousTextures
;
4803 /* The following caps are shader specific, but they are things we cannot detect, or which
4804 * are the same among all shader models. So to avoid code duplication set the shader version
4805 * specific, but otherwise constant caps here
4807 if (caps
->VertexShaderVersion
>= 3)
4809 /* Where possible set the caps based on OpenGL extensions and if they
4810 * aren't set (in case of software rendering) use the VS 3.0 from
4811 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4813 caps
->VS20Caps
.caps
= WINED3DVS20CAPS_PREDICATION
;
4814 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4815 caps
->VS20Caps
.dynamic_flow_control_depth
= WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4816 caps
->VS20Caps
.temp_count
= max(32, adapter
->gl_info
.limits
.arb_vs_temps
);
4817 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
4818 caps
->VS20Caps
.static_flow_control_depth
= WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
4820 caps
->MaxVShaderInstructionsExecuted
= 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
4821 caps
->MaxVertexShader30InstructionSlots
= max(512, adapter
->gl_info
.limits
.arb_vs_instructions
);
4823 else if (caps
->VertexShaderVersion
== 2)
4825 caps
->VS20Caps
.caps
= 0;
4826 caps
->VS20Caps
.dynamic_flow_control_depth
= WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
;
4827 caps
->VS20Caps
.temp_count
= max(12, adapter
->gl_info
.limits
.arb_vs_temps
);
4828 caps
->VS20Caps
.static_flow_control_depth
= 1;
4830 caps
->MaxVShaderInstructionsExecuted
= 65535;
4831 caps
->MaxVertexShader30InstructionSlots
= 0;
4835 caps
->VS20Caps
.caps
= 0;
4836 caps
->VS20Caps
.dynamic_flow_control_depth
= 0;
4837 caps
->VS20Caps
.temp_count
= 0;
4838 caps
->VS20Caps
.static_flow_control_depth
= 0;
4840 caps
->MaxVShaderInstructionsExecuted
= 0;
4841 caps
->MaxVertexShader30InstructionSlots
= 0;
4844 if (caps
->PixelShaderVersion
>= 3)
4846 /* Where possible set the caps based on OpenGL extensions and if they
4847 * aren't set (in case of software rendering) use the PS 3.0 from
4848 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4851 /* Caps is more or less undocumented on MSDN but it appears to be
4852 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
4853 * cards from Windows */
4854 caps
->PS20Caps
.caps
= WINED3DPS20CAPS_ARBITRARYSWIZZLE
|
4855 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS
|
4856 WINED3DPS20CAPS_PREDICATION
|
4857 WINED3DPS20CAPS_NODEPENDENTREADLIMIT
|
4858 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
4859 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4860 caps
->PS20Caps
.dynamic_flow_control_depth
= WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4861 caps
->PS20Caps
.temp_count
= max(32, adapter
->gl_info
.limits
.arb_ps_temps
);
4862 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
4863 caps
->PS20Caps
.static_flow_control_depth
= WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
4864 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
4865 caps
->PS20Caps
.instruction_slot_count
= WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
4867 caps
->MaxPShaderInstructionsExecuted
= 65535;
4868 caps
->MaxPixelShader30InstructionSlots
= max(WINED3DMIN30SHADERINSTRUCTIONS
,
4869 adapter
->gl_info
.limits
.arb_ps_instructions
);
4871 else if(caps
->PixelShaderVersion
== 2)
4873 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
4874 caps
->PS20Caps
.caps
= 0;
4875 caps
->PS20Caps
.dynamic_flow_control_depth
= 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
4876 caps
->PS20Caps
.temp_count
= max(12, adapter
->gl_info
.limits
.arb_ps_temps
);
4877 caps
->PS20Caps
.static_flow_control_depth
= WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH
; /* Minimum: 1 */
4878 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
4879 caps
->PS20Caps
.instruction_slot_count
= WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS
;
4881 caps
->MaxPShaderInstructionsExecuted
= 512; /* Minimum value, a GeforceFX uses 1024 */
4882 caps
->MaxPixelShader30InstructionSlots
= 0;
4886 caps
->PS20Caps
.caps
= 0;
4887 caps
->PS20Caps
.dynamic_flow_control_depth
= 0;
4888 caps
->PS20Caps
.temp_count
= 0;
4889 caps
->PS20Caps
.static_flow_control_depth
= 0;
4890 caps
->PS20Caps
.instruction_slot_count
= 0;
4892 caps
->MaxPShaderInstructionsExecuted
= 0;
4893 caps
->MaxPixelShader30InstructionSlots
= 0;
4896 if (caps
->VertexShaderVersion
>= 2)
4898 /* OpenGL supports all the formats below, perhaps not always
4899 * without conversion, but it supports them.
4900 * Further GLSL doesn't seem to have an official unsigned type so
4901 * don't advertise it yet as I'm not sure how we handle it.
4902 * We might need to add some clamping in the shader engine to
4904 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
4905 caps
->DeclTypes
= WINED3DDTCAPS_UBYTE4
|
4906 WINED3DDTCAPS_UBYTE4N
|
4907 WINED3DDTCAPS_SHORT2N
|
4908 WINED3DDTCAPS_SHORT4N
;
4909 if (gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
])
4911 caps
->DeclTypes
|= WINED3DDTCAPS_FLOAT16_2
|
4912 WINED3DDTCAPS_FLOAT16_4
;
4917 caps
->DeclTypes
= 0;
4920 /* Set DirectDraw helper Caps */
4921 ckey_caps
= WINEDDCKEYCAPS_DESTBLT
|
4922 WINEDDCKEYCAPS_SRCBLT
;
4923 fx_caps
= WINEDDFXCAPS_BLTALPHA
|
4924 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT
|
4925 WINEDDFXCAPS_BLTMIRRORUPDOWN
|
4926 WINEDDFXCAPS_BLTROTATION90
|
4927 WINEDDFXCAPS_BLTSHRINKX
|
4928 WINEDDFXCAPS_BLTSHRINKXN
|
4929 WINEDDFXCAPS_BLTSHRINKY
|
4930 WINEDDFXCAPS_BLTSHRINKXN
|
4931 WINEDDFXCAPS_BLTSTRETCHX
|
4932 WINEDDFXCAPS_BLTSTRETCHXN
|
4933 WINEDDFXCAPS_BLTSTRETCHY
|
4934 WINEDDFXCAPS_BLTSTRETCHYN
;
4935 blit_caps
= WINEDDCAPS_BLT
|
4936 WINEDDCAPS_BLTCOLORFILL
|
4937 WINEDDCAPS_BLTDEPTHFILL
|
4938 WINEDDCAPS_BLTSTRETCH
|
4939 WINEDDCAPS_CANBLTSYSMEM
|
4940 WINEDDCAPS_CANCLIP
|
4941 WINEDDCAPS_CANCLIPSTRETCHED
|
4942 WINEDDCAPS_COLORKEY
|
4943 WINEDDCAPS_COLORKEYHWASSIST
|
4944 WINEDDCAPS_ALIGNBOUNDARYSRC
;
4945 pal_caps
= WINEDDPCAPS_8BIT
|
4946 WINEDDPCAPS_PRIMARYSURFACE
;
4948 /* Fill the ddraw caps structure */
4949 caps
->ddraw_caps
.caps
= WINEDDCAPS_GDI
|
4950 WINEDDCAPS_PALETTE
|
4952 caps
->ddraw_caps
.caps2
= WINEDDCAPS2_CERTIFIED
|
4953 WINEDDCAPS2_NOPAGELOCKREQUIRED
|
4954 WINEDDCAPS2_PRIMARYGAMMA
|
4955 WINEDDCAPS2_WIDESURFACES
|
4956 WINEDDCAPS2_CANRENDERWINDOWED
;
4957 caps
->ddraw_caps
.color_key_caps
= ckey_caps
;
4958 caps
->ddraw_caps
.fx_caps
= fx_caps
;
4959 caps
->ddraw_caps
.pal_caps
= pal_caps
;
4960 caps
->ddraw_caps
.svb_caps
= blit_caps
;
4961 caps
->ddraw_caps
.svb_color_key_caps
= ckey_caps
;
4962 caps
->ddraw_caps
.svb_fx_caps
= fx_caps
;
4963 caps
->ddraw_caps
.vsb_caps
= blit_caps
;
4964 caps
->ddraw_caps
.vsb_color_key_caps
= ckey_caps
;
4965 caps
->ddraw_caps
.vsb_fx_caps
= fx_caps
;
4966 caps
->ddraw_caps
.ssb_caps
= blit_caps
;
4967 caps
->ddraw_caps
.ssb_color_key_caps
= ckey_caps
;
4968 caps
->ddraw_caps
.ssb_fx_caps
= fx_caps
;
4970 caps
->ddraw_caps
.dds_caps
= WINEDDSCAPS_ALPHA
|
4971 WINEDDSCAPS_BACKBUFFER
|
4973 WINEDDSCAPS_FRONTBUFFER
|
4974 WINEDDSCAPS_OFFSCREENPLAIN
|
4975 WINEDDSCAPS_PALETTE
|
4976 WINEDDSCAPS_PRIMARYSURFACE
|
4977 WINEDDSCAPS_SYSTEMMEMORY
|
4978 WINEDDSCAPS_VIDEOMEMORY
|
4979 WINEDDSCAPS_VISIBLE
;
4980 caps
->ddraw_caps
.stride_align
= DDRAW_PITCH_ALIGNMENT
;
4982 /* Set D3D caps if OpenGL is available. */
4983 if (adapter
->opengl
)
4985 caps
->ddraw_caps
.dds_caps
|= WINEDDSCAPS_3DDEVICE
|
4986 WINEDDSCAPS_MIPMAP
|
4987 WINEDDSCAPS_TEXTURE
|
4988 WINEDDSCAPS_ZBUFFER
;
4989 caps
->ddraw_caps
.caps
|= WINEDDCAPS_3D
;
4995 HRESULT CDECL
wined3d_device_create(struct wined3d
*wined3d
, UINT adapter_idx
, enum wined3d_device_type device_type
,
4996 HWND focus_window
, DWORD flags
, BYTE surface_alignment
, struct wined3d_device_parent
*device_parent
,
4997 struct wined3d_device
**device
)
4999 struct wined3d_device
*object
;
5002 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
5003 wined3d
, adapter_idx
, device_type
, focus_window
, flags
, device_parent
, device
);
5005 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
5006 * number and create a device without a 3D adapter for 2D only operation. */
5007 if (wined3d
->adapter_count
&& adapter_idx
>= wined3d
->adapter_count
)
5008 return WINED3DERR_INVALIDCALL
;
5010 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5013 ERR("Failed to allocate device memory.\n");
5014 return E_OUTOFMEMORY
;
5017 hr
= device_init(object
, wined3d
, adapter_idx
, device_type
,
5018 focus_window
, flags
, surface_alignment
, device_parent
);
5021 WARN("Failed to initialize device, hr %#x.\n", hr
);
5022 HeapFree(GetProcessHeap(), 0, object
);
5026 TRACE("Created device %p.\n", object
);
5029 device_parent
->ops
->wined3d_device_created(device_parent
, *device
);
5034 static void WINE_GLAPI
invalid_func(const void *data
)
5036 ERR("Invalid vertex attribute function called\n");
5040 static void WINE_GLAPI
invalid_texcoord_func(GLenum unit
, const void *data
)
5042 ERR("Invalid texcoord function called\n");
5046 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
5047 * the extension detection and are used in drawStridedSlow
5049 static void WINE_GLAPI
position_d3dcolor(const void *data
)
5051 DWORD pos
= *((const DWORD
*)data
);
5053 FIXME("Add a test for fixed function position from d3dcolor type\n");
5054 glVertex4s(D3DCOLOR_B_R(pos
),
5060 static void WINE_GLAPI
position_float4(const void *data
)
5062 const GLfloat
*pos
= data
;
5064 if (pos
[3] != 0.0f
&& pos
[3] != 1.0f
)
5066 float w
= 1.0f
/ pos
[3];
5068 glVertex4f(pos
[0] * w
, pos
[1] * w
, pos
[2] * w
, w
);
5076 static void WINE_GLAPI
diffuse_d3dcolor(const void *data
)
5078 DWORD diffuseColor
= *((const DWORD
*)data
);
5080 glColor4ub(D3DCOLOR_B_R(diffuseColor
),
5081 D3DCOLOR_B_G(diffuseColor
),
5082 D3DCOLOR_B_B(diffuseColor
),
5083 D3DCOLOR_B_A(diffuseColor
));
5086 static void WINE_GLAPI
specular_d3dcolor(const void *data
)
5088 DWORD specularColor
= *((const DWORD
*)data
);
5089 GLbyte d
[] = {D3DCOLOR_B_R(specularColor
),
5090 D3DCOLOR_B_G(specularColor
),
5091 D3DCOLOR_B_B(specularColor
)};
5093 specular_func_3ubv(d
);
5096 static void WINE_GLAPI
warn_no_specular_func(const void *data
)
5098 WARN("GL_EXT_secondary_color not supported\n");
5101 static void fillGLAttribFuncs(const struct wined3d_gl_info
*gl_info
)
5103 position_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5104 position_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5105 position_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glVertex3fv
;
5106 position_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = position_float4
;
5107 position_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = position_d3dcolor
;
5108 position_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5109 position_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5110 position_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glAttribFunc
)glVertex2sv
;
5111 position_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5112 position_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5113 position_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5114 position_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5115 position_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5116 position_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5117 position_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5118 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5119 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5121 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5122 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5123 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glColor3fv
;
5124 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glColor4fv
;
5125 diffuse_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = diffuse_d3dcolor
;
5126 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5127 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5128 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5129 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = (glAttribFunc
)glColor4ubv
;
5130 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5131 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = (glAttribFunc
)glColor4sv
;
5132 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5133 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = (glAttribFunc
)glColor4usv
;
5134 diffuse_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5135 diffuse_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5136 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5137 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5139 /* No 4 component entry points here */
5140 specular_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5141 specular_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5142 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5144 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)GL_EXTCALL(glSecondaryColor3fvEXT
);
5148 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = warn_no_specular_func
;
5150 specular_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = invalid_func
;
5151 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5153 specular_func_3ubv
= (glAttribFunc
)GL_EXTCALL(glSecondaryColor3ubvEXT
);
5154 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = specular_d3dcolor
;
5158 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = warn_no_specular_func
;
5160 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5161 specular_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5162 specular_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5163 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5164 specular_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5165 specular_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5166 specular_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5167 specular_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5168 specular_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5169 specular_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5170 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5171 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5173 /* Only 3 component entry points here. Test how others behave. Float4 normals are used
5174 * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
5176 normal_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5177 normal_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5178 normal_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glNormal3fv
;
5179 normal_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glNormal3fv
; /* Just ignore the 4th value */
5180 normal_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_func
;
5181 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5182 normal_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5183 normal_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5184 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5185 normal_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5186 normal_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5187 normal_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5188 normal_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5189 normal_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5190 normal_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5191 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5192 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5194 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord1fvARB
);
5195 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2fvARB
);
5196 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord3fvARB
);
5197 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4fvARB
);
5198 multi_texcoord_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_texcoord_func
;
5199 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_texcoord_func
;
5200 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2svARB
);
5201 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4svARB
);
5202 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_texcoord_func
;
5203 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_texcoord_func
;
5204 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_texcoord_func
;
5205 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_texcoord_func
;
5206 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_texcoord_func
;
5207 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_texcoord_func
;
5208 multi_texcoord_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_texcoord_func
;
5209 if (gl_info
->supported
[NV_HALF_FLOAT
])
5211 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
5212 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2hvNV
);
5213 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4hvNV
);
5215 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_texcoord_func
;
5216 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_texcoord_func
;
5220 /* Do not call while under the GL lock. */
5221 static BOOL
InitAdapters(struct wined3d
*wined3d
)
5223 static HMODULE mod_gl
;
5225 int ps_selected_mode
, vs_selected_mode
;
5227 /* No need to hold any lock. The calling library makes sure only one thread calls
5228 * wined3d simultaneously
5231 TRACE("Initializing adapters\n");
5234 #ifdef USE_WIN32_OPENGL
5235 #define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
5236 mod_gl
= LoadLibraryA("opengl32.dll");
5238 ERR("Can't load opengl32.dll!\n");
5242 #define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
5243 /* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
5244 mod_gl
= GetModuleHandleA("gdi32.dll");
5248 /* Load WGL core functions from opengl32.dll */
5249 #define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
5253 if(!pwglGetProcAddress
) {
5254 ERR("Unable to load wglGetProcAddress!\n");
5258 /* Dynamically load all GL core functions */
5262 /* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl
5263 * otherwise because we have to use winex11.drv's override
5265 #ifdef USE_WIN32_OPENGL
5266 wglFinish
= (void*)GetProcAddress(mod_gl
, "glFinish");
5267 wglFlush
= (void*)GetProcAddress(mod_gl
, "glFlush");
5269 wglFinish
= (void*)pwglGetProcAddress("wglFinish");
5270 wglFlush
= (void*)pwglGetProcAddress("wglFlush");
5273 glEnableWINE
= glEnable
;
5274 glDisableWINE
= glDisable
;
5276 /* For now only one default adapter */
5278 struct wined3d_adapter
*adapter
= &wined3d
->adapters
[0];
5279 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
5280 struct wined3d_fake_gl_ctx fake_gl_ctx
= {0};
5281 struct wined3d_pixel_format
*cfgs
;
5284 DISPLAY_DEVICEW DisplayDevice
;
5287 TRACE("Initializing default adapter\n");
5288 adapter
->ordinal
= 0;
5289 adapter
->monitorPoint
.x
= -1;
5290 adapter
->monitorPoint
.y
= -1;
5292 if (!AllocateLocallyUniqueId(&adapter
->luid
))
5294 DWORD err
= GetLastError();
5295 ERR("Failed to set adapter LUID (%#x).\n", err
);
5298 TRACE("Allocated LUID %08x:%08x for adapter.\n",
5299 adapter
->luid
.HighPart
, adapter
->luid
.LowPart
);
5301 if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx
))
5303 ERR("Failed to get a gl context for default adapter\n");
5307 ret
= wined3d_adapter_init_gl_caps(adapter
);
5309 ERR("Failed to initialize gl caps for default adapter\n");
5310 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5313 ret
= initPixelFormats(&adapter
->gl_info
, adapter
->driver_info
.vendor
);
5315 ERR("Failed to init gl formats\n");
5316 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5320 hdc
= fake_gl_ctx
.dc
;
5322 adapter
->TextureRam
= adapter
->driver_info
.vidmem
;
5323 adapter
->UsedTextureRam
= 0;
5324 TRACE("Emulating %dMB of texture ram\n", adapter
->TextureRam
/(1024*1024));
5326 /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
5327 DisplayDevice
.cb
= sizeof(DisplayDevice
);
5328 EnumDisplayDevicesW(NULL
, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice
, 0);
5329 TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice
.DeviceName
));
5330 strcpyW(adapter
->DeviceName
, DisplayDevice
.DeviceName
);
5332 if (gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
])
5340 attribute
= WGL_NUMBER_PIXEL_FORMATS_ARB
;
5341 GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, 0, 0, 1, &attribute
, &cfg_count
));
5342 adapter
->cfg_count
= cfg_count
;
5344 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, adapter
->cfg_count
* sizeof(*adapter
->cfgs
));
5345 cfgs
= adapter
->cfgs
;
5346 attribs
[nAttribs
++] = WGL_RED_BITS_ARB
;
5347 attribs
[nAttribs
++] = WGL_GREEN_BITS_ARB
;
5348 attribs
[nAttribs
++] = WGL_BLUE_BITS_ARB
;
5349 attribs
[nAttribs
++] = WGL_ALPHA_BITS_ARB
;
5350 attribs
[nAttribs
++] = WGL_COLOR_BITS_ARB
;
5351 attribs
[nAttribs
++] = WGL_DEPTH_BITS_ARB
;
5352 attribs
[nAttribs
++] = WGL_STENCIL_BITS_ARB
;
5353 attribs
[nAttribs
++] = WGL_DRAW_TO_WINDOW_ARB
;
5354 attribs
[nAttribs
++] = WGL_PIXEL_TYPE_ARB
;
5355 attribs
[nAttribs
++] = WGL_DOUBLE_BUFFER_ARB
;
5356 attribs
[nAttribs
++] = WGL_AUX_BUFFERS_ARB
;
5358 for (iPixelFormat
=1; iPixelFormat
<= adapter
->cfg_count
; ++iPixelFormat
)
5360 res
= GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, nAttribs
, attribs
, values
));
5365 /* Cache the pixel format */
5366 cfgs
->iPixelFormat
= iPixelFormat
;
5367 cfgs
->redSize
= values
[0];
5368 cfgs
->greenSize
= values
[1];
5369 cfgs
->blueSize
= values
[2];
5370 cfgs
->alphaSize
= values
[3];
5371 cfgs
->colorSize
= values
[4];
5372 cfgs
->depthSize
= values
[5];
5373 cfgs
->stencilSize
= values
[6];
5374 cfgs
->windowDrawable
= values
[7];
5375 cfgs
->iPixelType
= values
[8];
5376 cfgs
->doubleBuffer
= values
[9];
5377 cfgs
->auxBuffers
= values
[10];
5379 cfgs
->numSamples
= 0;
5380 /* Check multisample support */
5381 if (gl_info
->supported
[ARB_MULTISAMPLE
])
5383 int attrib
[2] = {WGL_SAMPLE_BUFFERS_ARB
, WGL_SAMPLES_ARB
};
5385 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, 2, attrib
, value
))) {
5386 /* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
5387 * value[1] = number of multi sample buffers*/
5389 cfgs
->numSamples
= value
[1];
5393 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5394 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
5395 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5396 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5397 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->numSamples
, cfgs
->windowDrawable
);
5403 int nCfgs
= DescribePixelFormat(hdc
, 0, 0, 0);
5404 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, nCfgs
* sizeof(*adapter
->cfgs
));
5405 adapter
->cfg_count
= 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
5407 cfgs
= adapter
->cfgs
;
5408 for(iPixelFormat
=1; iPixelFormat
<=nCfgs
; iPixelFormat
++)
5410 PIXELFORMATDESCRIPTOR ppfd
;
5412 res
= DescribePixelFormat(hdc
, iPixelFormat
, sizeof(PIXELFORMATDESCRIPTOR
), &ppfd
);
5416 /* We only want HW acceleration using an OpenGL ICD driver.
5417 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
5418 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
5420 if(ppfd
.dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
))
5422 TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat
);
5426 cfgs
->iPixelFormat
= iPixelFormat
;
5427 cfgs
->redSize
= ppfd
.cRedBits
;
5428 cfgs
->greenSize
= ppfd
.cGreenBits
;
5429 cfgs
->blueSize
= ppfd
.cBlueBits
;
5430 cfgs
->alphaSize
= ppfd
.cAlphaBits
;
5431 cfgs
->colorSize
= ppfd
.cColorBits
;
5432 cfgs
->depthSize
= ppfd
.cDepthBits
;
5433 cfgs
->stencilSize
= ppfd
.cStencilBits
;
5434 cfgs
->windowDrawable
= (ppfd
.dwFlags
& PFD_DRAW_TO_WINDOW
) ? 1 : 0;
5435 cfgs
->iPixelType
= (ppfd
.iPixelType
== PFD_TYPE_RGBA
) ? WGL_TYPE_RGBA_ARB
: WGL_TYPE_COLORINDEX_ARB
;
5436 cfgs
->doubleBuffer
= (ppfd
.dwFlags
& PFD_DOUBLEBUFFER
) ? 1 : 0;
5437 cfgs
->auxBuffers
= ppfd
.cAuxBuffers
;
5438 cfgs
->numSamples
= 0;
5440 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5441 "depth=%d, stencil=%d, windowDrawable=%d\n",
5442 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5443 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5444 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->windowDrawable
);
5446 adapter
->cfg_count
++;
5449 /* We haven't found any suitable formats. This should only happen
5450 * in case of GDI software rendering, which is pretty useless
5452 if (!adapter
->cfg_count
)
5454 ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
5456 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5457 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
5462 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5464 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
5465 fillGLAttribFuncs(&adapter
->gl_info
);
5466 adapter
->opengl
= TRUE
;
5468 wined3d
->adapter_count
= 1;
5469 TRACE("%u adapters successfully initialized.\n", wined3d
->adapter_count
);
5474 /* Initialize an adapter for ddraw-only memory counting */
5475 memset(wined3d
->adapters
, 0, sizeof(wined3d
->adapters
));
5476 wined3d
->adapters
[0].ordinal
= 0;
5477 wined3d
->adapters
[0].opengl
= FALSE
;
5478 wined3d
->adapters
[0].monitorPoint
.x
= -1;
5479 wined3d
->adapters
[0].monitorPoint
.y
= -1;
5481 wined3d
->adapters
[0].driver_info
.name
= "Display";
5482 wined3d
->adapters
[0].driver_info
.description
= "WineD3D DirectDraw Emulation";
5483 if (wined3d_settings
.emulated_textureram
)
5484 wined3d
->adapters
[0].TextureRam
= wined3d_settings
.emulated_textureram
;
5486 wined3d
->adapters
[0].TextureRam
= 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
5488 initPixelFormatsNoGL(&wined3d
->adapters
[0].gl_info
);
5490 wined3d
->adapter_count
= 1;
5494 static void STDMETHODCALLTYPE
wined3d_null_wined3d_object_destroyed(void *parent
) {}
5496 const struct wined3d_parent_ops wined3d_null_parent_ops
=
5498 wined3d_null_wined3d_object_destroyed
,
5501 /* Do not call while under the GL lock. */
5502 HRESULT
wined3d_init(struct wined3d
*wined3d
, UINT version
, DWORD flags
)
5504 wined3d
->dxVersion
= version
;
5506 wined3d
->flags
= flags
;
5508 if (!InitAdapters(wined3d
))
5510 WARN("Failed to initialize adapters.\n");
5513 MESSAGE("Direct3D%u is not available without OpenGL.\n", version
);