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
25 #include "wine/port.h"
29 #include "wined3d_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
34 #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
36 /* The driver names reflect the lowest GPU supported
37 * by a certain driver, so DRIVER_AMD_R300 supports
38 * R3xx, R4xx and R5xx GPUs. */
39 enum wined3d_display_driver
41 DRIVER_AMD_RAGE_128PRO
,
50 DRIVER_NVIDIA_GEFORCE2MX
,
51 DRIVER_NVIDIA_GEFORCEFX
,
52 DRIVER_NVIDIA_GEFORCE6
,
56 enum wined3d_driver_model
64 enum wined3d_gl_vendor
74 /* The d3d device ID */
75 static const GUID IID_D3DDEVICE_D3DUID
= { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
77 /* Extension detection */
78 struct wined3d_extension_map
80 const char *extension_string
;
81 enum wined3d_gl_extension extension
;
84 static const struct wined3d_extension_map gl_extension_map
[] =
87 {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE
},
88 {"GL_APPLE_fence", APPLE_FENCE
},
89 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS
},
90 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE
},
91 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422
},
94 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT
},
95 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT
},
96 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP
},
97 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE
},
98 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS
},
99 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX
},
100 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM
},
101 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER
},
102 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT
},
103 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4
},
104 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL
},
105 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX
},
106 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT
},
107 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE
},
108 {"GL_ARB_multisample", ARB_MULTISAMPLE
}, /* needs GLX_ARB_MULTISAMPLE as well */
109 {"GL_ARB_multitexture", ARB_MULTITEXTURE
},
110 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY
},
111 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT
},
112 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS
},
113 {"GL_ARB_point_sprite", ARB_POINT_SPRITE
},
114 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX
},
115 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS
},
116 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD
},
117 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100
},
118 {"GL_ARB_shadow", ARB_SHADOW
},
119 {"GL_ARB_sync", ARB_SYNC
},
120 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP
},
121 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION
},
122 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC
},
123 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP
},
124 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD
},
125 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE
},
126 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3
},
127 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT
},
128 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT
},
129 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO
},
130 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE
},
131 {"GL_ARB_texture_rg", ARB_TEXTURE_RG
},
132 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
},
133 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND
},
134 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT
},
135 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM
},
136 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER
},
139 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER
},
140 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL
},
141 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC
},
142 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3
},
143 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE
},
146 {"GL_EXT_blend_color", EXT_BLEND_COLOR
},
147 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE
},
148 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE
},
149 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX
},
150 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT
},
151 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST
},
152 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2
},
153 {"GL_EXT_fog_coord", EXT_FOG_COORD
},
154 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT
},
155 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE
},
156 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT
},
157 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS
},
158 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4
},
159 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL
},
160 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE
},
161 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS
},
162 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX
},
163 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR
},
164 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE
},
165 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP
},
166 {"GL_EXT_texture3D", EXT_TEXTURE3D
},
167 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC
},
168 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC
},
169 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD
},
170 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE
},
171 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3
},
172 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC
},
173 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS
},
174 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB
},
175 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE
},
176 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA
},
179 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP
},
180 {"GL_NV_fence", NV_FENCE
},
181 {"GL_NV_fog_distance", NV_FOG_DISTANCE
},
182 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM
},
183 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2
},
184 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION
},
185 {"GL_NV_half_float", NV_HALF_FLOAT
},
186 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT
},
187 {"GL_NV_point_sprite", NV_POINT_SPRITE
},
188 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS
},
189 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2
},
190 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION
},
191 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4
},
192 {"GL_NV_texture_shader", NV_TEXTURE_SHADER
},
193 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2
},
194 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM
},
195 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1
},
196 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2
},
197 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION
},
198 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3
},
201 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP
},
204 static const struct wined3d_extension_map wgl_extension_map
[] =
206 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT
},
207 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL
},
208 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
},
211 /**********************************************************
212 * Utility functions follow
213 **********************************************************/
215 const struct min_lookup minMipLookup
[] =
217 /* NONE POINT LINEAR */
218 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
219 {{GL_NEAREST
, GL_NEAREST_MIPMAP_NEAREST
, GL_NEAREST_MIPMAP_LINEAR
}}, /* POINT*/
220 {{GL_LINEAR
, GL_LINEAR_MIPMAP_NEAREST
, GL_LINEAR_MIPMAP_LINEAR
}}, /* LINEAR */
223 const struct min_lookup minMipLookup_noFilter
[] =
225 /* NONE POINT LINEAR */
226 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
227 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
228 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* LINEAR */
231 const struct min_lookup minMipLookup_noMip
[] =
233 /* NONE POINT LINEAR */
234 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
235 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
236 {{GL_LINEAR
, GL_LINEAR
, GL_LINEAR
}}, /* LINEAR */
239 const GLenum magLookup
[] =
241 /* NONE POINT LINEAR */
242 GL_NEAREST
, GL_NEAREST
, GL_LINEAR
,
245 const GLenum magLookup_noFilter
[] =
247 /* NONE POINT LINEAR */
248 GL_NEAREST
, GL_NEAREST
, GL_NEAREST
,
251 /* drawStridedSlow attributes */
252 glAttribFunc position_funcs
[WINED3D_FFP_EMIT_COUNT
];
253 glAttribFunc diffuse_funcs
[WINED3D_FFP_EMIT_COUNT
];
254 glAttribFunc specular_func_3ubv
;
255 glAttribFunc specular_funcs
[WINED3D_FFP_EMIT_COUNT
];
256 glAttribFunc normal_funcs
[WINED3D_FFP_EMIT_COUNT
];
257 glMultiTexCoordFunc multi_texcoord_funcs
[WINED3D_FFP_EMIT_COUNT
];
260 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
261 * i.e., there is no GL Context - Get a default rendering context to enable the
262 * function query some info from GL.
265 struct wined3d_fake_gl_ctx
271 HGLRC restore_gl_ctx
;
274 static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx
*ctx
)
276 TRACE("Destroying fake GL context.\n");
278 if (!pwglMakeCurrent(NULL
, NULL
))
279 ERR("Failed to disable fake GL context.\n");
281 if (!pwglDeleteContext(ctx
->gl_ctx
))
283 DWORD err
= GetLastError();
284 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx
->gl_ctx
, err
);
287 ReleaseDC(ctx
->wnd
, ctx
->dc
);
288 DestroyWindow(ctx
->wnd
);
290 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
291 ERR("Failed to restore previous GL context.\n");
294 /* Do not call while under the GL lock. */
295 static BOOL
WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx
*ctx
)
297 PIXELFORMATDESCRIPTOR pfd
;
300 TRACE("getting context...\n");
302 ctx
->restore_dc
= pwglGetCurrentDC();
303 ctx
->restore_gl_ctx
= pwglGetCurrentContext();
305 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
306 ctx
->wnd
= CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME
, "WineD3D fake window",
307 WS_OVERLAPPEDWINDOW
, 10, 10, 10, 10, NULL
, NULL
, NULL
, NULL
);
310 ERR("Failed to create a window.\n");
314 ctx
->dc
= GetDC(ctx
->wnd
);
317 ERR("Failed to get a DC.\n");
321 /* PixelFormat selection */
322 ZeroMemory(&pfd
, sizeof(pfd
));
323 pfd
.nSize
= sizeof(pfd
);
325 pfd
.dwFlags
= PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
; /* PFD_GENERIC_ACCELERATED */
326 pfd
.iPixelType
= PFD_TYPE_RGBA
;
328 pfd
.iLayerType
= PFD_MAIN_PLANE
;
330 if (!(iPixelFormat
= ChoosePixelFormat(ctx
->dc
, &pfd
)))
332 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
333 ERR("Failed to find a suitable pixel format.\n");
336 DescribePixelFormat(ctx
->dc
, iPixelFormat
, sizeof(pfd
), &pfd
);
337 SetPixelFormat(ctx
->dc
, iPixelFormat
, &pfd
);
339 /* Create a GL context. */
340 if (!(ctx
->gl_ctx
= pwglCreateContext(ctx
->dc
)))
342 WARN("Failed to create default context for capabilities initialization.\n");
346 /* Make it the current GL context. */
347 if (!pwglMakeCurrent(ctx
->dc
, ctx
->gl_ctx
))
349 ERR("Failed to make fake GL context current.\n");
356 if (ctx
->gl_ctx
) pwglDeleteContext(ctx
->gl_ctx
);
358 if (ctx
->dc
) ReleaseDC(ctx
->wnd
, ctx
->dc
);
360 if (ctx
->wnd
) DestroyWindow(ctx
->wnd
);
362 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
363 ERR("Failed to restore previous GL context.\n");
368 /* Adjust the amount of used texture memory */
369 unsigned int adapter_adjust_memory(struct wined3d_adapter
*adapter
, int amount
)
371 adapter
->UsedTextureRam
+= amount
;
372 TRACE("Adjusted adapter memory by %d to %d.\n", amount
, adapter
->UsedTextureRam
);
373 return adapter
->UsedTextureRam
;
376 static void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
)
378 HeapFree(GetProcessHeap(), 0, adapter
->gl_info
.formats
);
379 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
382 ULONG CDECL
wined3d_incref(struct wined3d
*wined3d
)
384 ULONG refcount
= InterlockedIncrement(&wined3d
->ref
);
386 TRACE("%p increasing refcount to %u.\n", wined3d
, refcount
);
391 ULONG CDECL
wined3d_decref(struct wined3d
*wined3d
)
393 ULONG refcount
= InterlockedDecrement(&wined3d
->ref
);
395 TRACE("%p decreasing refcount to %u.\n", wined3d
, refcount
);
401 for (i
= 0; i
< wined3d
->adapter_count
; ++i
)
403 wined3d_adapter_cleanup(&wined3d
->adapters
[i
]);
405 HeapFree(GetProcessHeap(), 0, wined3d
);
411 /* GL locking is done by the caller */
412 static inline BOOL
test_arb_vs_offset_limit(const struct wined3d_gl_info
*gl_info
)
416 const char *testcode
=
418 "PARAM C[66] = { program.env[0..65] };\n"
420 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
421 "ARL A0.x, zero.x;\n"
422 "MOV result.position, C[A0.x + 65];\n"
425 while (gl_info
->gl_ops
.gl
.p_glGetError());
426 GL_EXTCALL(glGenProgramsARB(1, &prog
));
428 ERR("Failed to create an ARB offset limit test program\n");
430 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
431 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
432 strlen(testcode
), testcode
));
433 if (gl_info
->gl_ops
.gl
.p_glGetError())
435 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
436 TRACE("error: %s\n", debugstr_a((const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
438 } else TRACE("OpenGL implementation allows offsets > 63\n");
440 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
441 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
442 checkGLcall("ARB vp offset limit test cleanup");
447 static BOOL
match_amd_r300_to_500(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
448 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
450 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
451 if (device
== CARD_AMD_RADEON_9500
) return TRUE
;
452 if (device
== CARD_AMD_RADEON_X700
) return TRUE
;
453 if (device
== CARD_AMD_RADEON_X1600
) return TRUE
;
457 static BOOL
match_geforce5(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
458 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
460 if (card_vendor
== HW_VENDOR_NVIDIA
)
462 if (device
== CARD_NVIDIA_GEFORCEFX_5200
||
463 device
== CARD_NVIDIA_GEFORCEFX_5600
||
464 device
== CARD_NVIDIA_GEFORCEFX_5800
)
472 static BOOL
match_apple(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
473 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
475 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
476 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
477 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
479 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
480 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
481 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
482 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
483 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
484 * the chance that other implementations support them is rather small since Win32 QuickTime uses
485 * DirectDraw, not OpenGL.
487 * This test has been moved into wined3d_guess_gl_vendor()
489 if (gl_vendor
== GL_VENDOR_APPLE
)
496 /* Context activation is done by the caller. */
497 static void test_pbo_functionality(struct wined3d_gl_info
*gl_info
)
499 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
500 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
501 * all the texture. This function detects this bug by its symptom and disables PBOs
504 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
505 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
506 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
507 * read back is compared to the original. If they are equal PBOs are assumed to work,
508 * otherwise the PBO extension is disabled. */
510 static const unsigned int pattern
[] =
512 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
513 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
514 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
515 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
517 unsigned int check
[sizeof(pattern
) / sizeof(pattern
[0])];
519 /* No PBO -> No point in testing them. */
520 if (!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
]) return;
524 while (gl_info
->gl_ops
.gl
.p_glGetError());
525 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &texture
);
526 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, texture
);
528 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAX_LEVEL
, 0);
529 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0);
530 checkGLcall("Specifying the PBO test texture");
532 GL_EXTCALL(glGenBuffersARB(1, &pbo
));
533 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, pbo
));
534 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB
, sizeof(pattern
), pattern
, GL_STREAM_DRAW_ARB
));
535 checkGLcall("Specifying the PBO test pbo");
537 gl_info
->gl_ops
.gl
.p_glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
538 checkGLcall("Loading the PBO test texture");
540 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, 0));
543 gl_info
->gl_ops
.gl
.p_glFinish(); /* just to be sure */
545 memset(check
, 0, sizeof(check
));
547 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, check
);
548 checkGLcall("Reading back the PBO test texture");
550 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &texture
);
551 GL_EXTCALL(glDeleteBuffersARB(1, &pbo
));
552 checkGLcall("PBO test cleanup");
556 if (memcmp(check
, pattern
, sizeof(check
)))
558 WARN("PBO test failed, read back data doesn't match original.\n"
559 "Disabling PBOs. This may result in slower performance.\n");
560 gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
] = FALSE
;
564 TRACE("PBO test successful.\n");
568 static BOOL
match_apple_intel(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
569 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
571 return (card_vendor
== HW_VENDOR_INTEL
) && (gl_vendor
== GL_VENDOR_APPLE
);
574 static BOOL
match_apple_nonr500ati(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
575 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
577 if (gl_vendor
!= GL_VENDOR_APPLE
) return FALSE
;
578 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
579 if (device
== CARD_AMD_RADEON_X1600
) return FALSE
;
583 static BOOL
match_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
584 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
586 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
587 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
588 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
589 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
592 * dx10 cards usually have 64 varyings */
593 return gl_info
->limits
.glsl_varyings
> 44;
596 static BOOL
match_not_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
597 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
599 return !match_dx10_capable(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
);
602 /* A GL context is provided by the caller */
603 static BOOL
match_allows_spec_alpha(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
604 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
609 if (!gl_info
->supported
[EXT_SECONDARY_COLOR
])
613 while (gl_info
->gl_ops
.gl
.p_glGetError());
614 GL_EXTCALL(glSecondaryColorPointerEXT
)(4, GL_UNSIGNED_BYTE
, 4, data
);
615 error
= gl_info
->gl_ops
.gl
.p_glGetError();
618 if (error
== GL_NO_ERROR
)
620 TRACE("GL Implementation accepts 4 component specular color pointers\n");
625 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
626 debug_glerror(error
));
631 /* A GL context is provided by the caller */
632 static BOOL
match_broken_nv_clip(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
633 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
638 const char *testcode
=
640 "OPTION NV_vertex_program2;\n"
641 "MOV result.clip[0], 0.0;\n"
642 "MOV result.position, 0.0;\n"
645 if (!gl_info
->supported
[NV_VERTEX_PROGRAM2_OPTION
]) return FALSE
;
648 while (gl_info
->gl_ops
.gl
.p_glGetError());
650 GL_EXTCALL(glGenProgramsARB(1, &prog
));
653 ERR("Failed to create the NVvp clip test program\n");
657 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
658 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
659 strlen(testcode
), testcode
));
660 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &pos
);
663 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
664 TRACE("error: %s\n", debugstr_a((const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
666 while (gl_info
->gl_ops
.gl
.p_glGetError());
668 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
670 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
671 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
672 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
678 /* Context activation is done by the caller. */
679 static BOOL
match_fbo_tex_update(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
680 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
682 char data
[4 * 4 * 4];
686 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
) return FALSE
;
688 memset(data
, 0xcc, sizeof(data
));
692 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
693 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
694 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
695 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
696 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
697 checkGLcall("glTexImage2D");
699 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
700 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
701 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
702 checkGLcall("glFramebufferTexture2D");
704 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
705 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
706 checkGLcall("glCheckFramebufferStatus");
708 memset(data
, 0x11, sizeof(data
));
709 gl_info
->gl_ops
.gl
.p_glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
710 checkGLcall("glTexSubImage2D");
712 gl_info
->gl_ops
.gl
.p_glClearColor(0.996f
, 0.729f
, 0.745f
, 0.792f
);
713 gl_info
->gl_ops
.gl
.p_glClear(GL_COLOR_BUFFER_BIT
);
714 checkGLcall("glClear");
716 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
717 checkGLcall("glGetTexImage");
719 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
720 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
721 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
722 checkGLcall("glBindTexture");
724 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
725 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
726 checkGLcall("glDeleteTextures");
730 return *(DWORD
*)data
== 0x11111111;
733 /* Context activation is done by the caller. */
734 static BOOL
match_broken_rgba16(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
735 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
737 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
738 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
744 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
745 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
746 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA16
, 4, 4, 0, GL_RGBA
, GL_UNSIGNED_SHORT
, NULL
);
747 checkGLcall("glTexImage2D");
749 gl_info
->gl_ops
.gl
.p_glGetTexLevelParameteriv(GL_TEXTURE_2D
, 0, GL_TEXTURE_RED_SIZE
, &size
);
750 checkGLcall("glGetTexLevelParameteriv");
751 TRACE("Real color depth is %d\n", size
);
753 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
754 checkGLcall("glBindTexture");
755 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
756 checkGLcall("glDeleteTextures");
763 static BOOL
match_fglrx(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
764 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
766 return gl_vendor
== GL_VENDOR_FGLRX
;
769 static void quirk_apple_glsl_constants(struct wined3d_gl_info
*gl_info
)
771 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
772 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
773 * allow 48 different offsets or other helper immediate values. */
774 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
775 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 12);
778 static void quirk_amd_dx9(struct wined3d_gl_info
*gl_info
)
780 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
781 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
782 * If real NP2 textures are used, the driver falls back to software. We could just remove the
783 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
784 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
785 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
786 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
788 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
789 * has this extension promoted to core. The extension loading code sets this extension supported
790 * due to that, so this code works on fglrx as well. */
791 if(gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
793 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
794 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
795 gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
] = TRUE
;
799 static void quirk_no_np2(struct wined3d_gl_info
*gl_info
)
801 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
802 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
803 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
804 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
805 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
806 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
808 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
809 * triggering the software fallback. There is not much we can do here apart from disabling the
810 * software-emulated extension and re-enable ARB_tex_rect (which was previously disabled
811 * in wined3d_adapter_init_gl_caps).
812 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
813 * post-processing effects in the game "Max Payne 2").
814 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
815 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
816 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
817 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = TRUE
;
820 static void quirk_texcoord_w(struct wined3d_gl_info
*gl_info
)
822 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
823 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
824 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
825 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
826 * according to the spec.
828 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
829 * makes the shader slower and eats instruction slots which should be available to the d3d app.
831 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
832 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
833 * this workaround is activated on cards that do not need it, it won't break things, just affect
834 * performance negatively. */
835 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
836 gl_info
->quirks
|= WINED3D_QUIRK_SET_TEXCOORD_W
;
839 static void quirk_clip_varying(struct wined3d_gl_info
*gl_info
)
841 gl_info
->quirks
|= WINED3D_QUIRK_GLSL_CLIP_VARYING
;
844 static void quirk_allows_specular_alpha(struct wined3d_gl_info
*gl_info
)
846 gl_info
->quirks
|= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
;
849 static void quirk_disable_nvvp_clip(struct wined3d_gl_info
*gl_info
)
851 gl_info
->quirks
|= WINED3D_QUIRK_NV_CLIP_BROKEN
;
854 static void quirk_fbo_tex_update(struct wined3d_gl_info
*gl_info
)
856 gl_info
->quirks
|= WINED3D_QUIRK_FBO_TEX_UPDATE
;
859 static void quirk_broken_rgba16(struct wined3d_gl_info
*gl_info
)
861 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_RGBA16
;
864 static void quirk_infolog_spam(struct wined3d_gl_info
*gl_info
)
866 gl_info
->quirks
|= WINED3D_QUIRK_INFO_LOG_SPAM
;
869 static void quirk_limited_tex_filtering(struct wined3d_gl_info
*gl_info
)
871 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
872 selected texture formats. They are apparently the only DX9 class GPUs
874 Also, DX9-era GPUs are somewhat limited with float textures
875 filtering and blending. */
876 gl_info
->quirks
|= WINED3D_QUIRK_LIMITED_TEX_FILTERING
;
881 BOOL (*match
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
882 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
);
883 void (*apply
)(struct wined3d_gl_info
*gl_info
);
884 const char *description
;
887 static const struct driver_quirk quirk_table
[] =
890 match_amd_r300_to_500
,
892 "AMD normalized texrect quirk"
896 quirk_apple_glsl_constants
,
897 "Apple GLSL uniform override"
902 "Geforce 5 NP2 disable"
907 "Init texcoord .w for Apple Intel GPU driver"
910 match_apple_nonr500ati
,
912 "Init texcoord .w for Apple ATI >= r600 GPU driver"
917 "Reserved varying for gl_ClipPos"
920 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
921 * GL implementations accept it. The Mac GL is the only implementation known to
924 * If we can pass 4 component specular colors, do it, because (a) we don't have
925 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
926 * passes specular alpha to the pixel shader if any is used. Otherwise the
927 * specular alpha is used to pass the fog coordinate, which we pass to opengl
928 * via GL_EXT_fog_coord.
930 match_allows_spec_alpha
,
931 quirk_allows_specular_alpha
,
932 "Allow specular alpha quirk"
935 match_broken_nv_clip
,
936 quirk_disable_nvvp_clip
,
937 "Apple NV_vertex_program clip bug quirk"
940 match_fbo_tex_update
,
941 quirk_fbo_tex_update
,
942 "FBO rebind for attachment updates"
947 "True RGBA16 is not available"
952 "Not printing GLSL infolog"
955 match_not_dx10_capable
,
956 quirk_limited_tex_filtering
,
957 "Texture filtering, blending and VTF support is limited"
961 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
962 * reporting a driver version is moot because we are not the Windows driver, and we have different
963 * bugs, features, etc.
965 * The driver version has the form "x.y.z.w".
967 * "x" is the Windows version the driver is meant for:
974 * "y" is the maximum Direct3D version the driver supports.
975 * y -> d3d version mapping:
984 * "z" is the subversion number.
986 * "w" is the vendor specific driver build number.
989 struct driver_version_information
991 enum wined3d_display_driver driver
;
992 enum wined3d_driver_model driver_model
;
993 const char *driver_name
; /* name of Windows driver */
994 WORD version
; /* version word ('y'), contained in low word of DriverVersion.HighPart */
995 WORD subversion
; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
996 WORD build
; /* build number ('w'), contained in low word of DriverVersion.LowPart */
999 /* The driver version table contains driver information for different devices on several OS versions. */
1000 static const struct driver_version_information driver_version_table
[] =
1003 * - Radeon HD2x00 (R600) and up supported by current drivers.
1004 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1005 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1006 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1007 {DRIVER_AMD_RAGE_128PRO
, DRIVER_MODEL_NT5X
, "ati2dvaa.dll", 13, 3279, 0},
1008 {DRIVER_AMD_R100
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6614},
1009 {DRIVER_AMD_R300
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6764},
1010 {DRIVER_AMD_R600
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 8681},
1011 {DRIVER_AMD_R300
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1012 {DRIVER_AMD_R600
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1015 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1016 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1017 * igxprd32.dll but the GMA800 driver was never updated. */
1018 {DRIVER_INTEL_GMA800
, DRIVER_MODEL_NT5X
, "ialmrnt5.dll", 14, 10, 3889},
1019 {DRIVER_INTEL_GMA900
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4764},
1020 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4926},
1021 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 5218},
1022 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 14, 10, 1504},
1023 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 15, 10, 1666},
1026 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1027 * - GeforceFX support is up to 173.x on <= XP
1028 * - Geforce2MX/3/4 up to 96.x on <= XP
1029 * - TNT/Geforce1/2 up to 71.x on <= XP
1030 * All version numbers used below are from the Linux nvidia drivers. */
1031 {DRIVER_NVIDIA_TNT
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 7186},
1032 {DRIVER_NVIDIA_GEFORCE2MX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 9371},
1033 {DRIVER_NVIDIA_GEFORCEFX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 11, 7516},
1034 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 15, 12, 6658},
1035 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 15, 12, 6658},
1038 struct gpu_description
1040 WORD vendor
; /* reported PCI card vendor ID */
1041 WORD card
; /* reported PCI card device ID */
1042 const char *description
; /* Description of the card e.g. NVIDIA RIVA TNT */
1043 enum wined3d_display_driver driver
;
1044 unsigned int vidmem
;
1047 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1048 * found on a board containing a specific GPU. */
1049 static const struct gpu_description gpu_description_table
[] =
1052 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT
, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT
, 16 },
1053 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT2
, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1054 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE
, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT
, 32 },
1055 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2
, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1056 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2_MX
, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX
,32 },
1057 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE3
, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1058 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_MX
, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1059 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_TI4200
, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX
,64, },
1060 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5200
, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX
, 64 },
1061 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5600
, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX
, 128 },
1062 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5800
, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX
, 256 },
1063 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6200
, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6
, 64 },
1064 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6600GT
, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6
, 128 },
1065 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6800
, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6
, 128 },
1066 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7300
, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6
, 256 },
1067 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7400
, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6
, 256 },
1068 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7600
, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1069 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7800GT
, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1070 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8300GS
, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1071 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8400GS
, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1072 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600GT
, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1073 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600MGT
, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1074 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTS
, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6
, 320 },
1075 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTX
, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6
, 768 },
1076 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9200
, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6
, 256 },
1077 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400M
, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE6
, 256 },
1078 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400GT
, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1079 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9500GT
, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1080 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9600GT
, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6
, 384 },
1081 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9800GT
, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1082 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_210
, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6
, 512 },
1083 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT220
, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6
, 512 },
1084 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT240
, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6
, 512 },
1085 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX260
, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6
, 1024},
1086 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX275
, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6
, 896 },
1087 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX280
, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6
, 1024},
1088 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_320M
, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE6
, 256},
1089 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT320M
, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1090 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT325M
, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1091 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT330
, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6
, 1024},
1092 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS350M
, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1093 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT420
, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6
, 2048},
1094 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT430
, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6
, 1024},
1095 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT440
, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6
, 1024},
1096 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS450
, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6
, 1024},
1097 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460
, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6
, 768 },
1098 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460M
, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE6
, 1536},
1099 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX465
, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6
, 1024},
1100 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX470
, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6
, 1280},
1101 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX480
, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6
, 1536},
1102 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT540M
, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1103 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX550
, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1104 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT555M
, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1105 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560TI
, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1106 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560
, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE6
, 1024},
1107 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX570
, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6
, 1280},
1108 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX580
, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6
, 1536},
1109 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX670
, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE6
, 2048},
1110 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX680
, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE6
, 2048},
1113 {HW_VENDOR_AMD
, CARD_AMD_RAGE_128PRO
, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO
, 16 },
1114 {HW_VENDOR_AMD
, CARD_AMD_RADEON_7200
, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100
, 32 },
1115 {HW_VENDOR_AMD
, CARD_AMD_RADEON_8500
, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100
, 64 },
1116 {HW_VENDOR_AMD
, CARD_AMD_RADEON_9500
, "ATI Radeon 9500", DRIVER_AMD_R300
, 64 },
1117 {HW_VENDOR_AMD
, CARD_AMD_RADEON_XPRESS_200M
, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300
, 64 },
1118 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X700
, "ATI Radeon X700 SE", DRIVER_AMD_R300
, 128 },
1119 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X1600
, "ATI Radeon X1600 Series", DRIVER_AMD_R300
, 128 },
1120 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2350
, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600
, 256 },
1121 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2600
, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600
, 256 },
1122 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2900
, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600
, 512 },
1123 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD3200
, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600
, 128 },
1124 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4350
, "ATI Radeon HD 4350", DRIVER_AMD_R600
, 256 },
1125 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4600
, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600
, 512 },
1126 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4700
, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600
, 512 },
1127 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4800
, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600
, 512 },
1128 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5400
, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600
, 512 },
1129 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5600
, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600
, 512 },
1130 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5700
, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600
, 512 },
1131 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5800
, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600
, 1024},
1132 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5900
, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600
, 1024},
1133 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6300
, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600
, 1024},
1134 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6400
, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600
, 1024},
1135 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6410D
, "AMD Radeon HD 6410D", DRIVER_AMD_R600
, 1024},
1136 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6550D
, "AMD Radeon HD 6550D", DRIVER_AMD_R600
, 1024},
1137 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600
, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600
, 1024},
1138 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600M
, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600
, 512 },
1139 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6700
, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600
, 1024},
1140 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6800
, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600
, 1024},
1141 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6900
, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600
, 2048},
1142 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD7900
, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600
, 2048},
1144 {HW_VENDOR_INTEL
, CARD_INTEL_830M
, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1145 {HW_VENDOR_INTEL
, CARD_INTEL_855GM
, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1146 {HW_VENDOR_INTEL
, CARD_INTEL_845G
, "Intel(R) 845G", DRIVER_INTEL_GMA800
, 32 },
1147 {HW_VENDOR_INTEL
, CARD_INTEL_865G
, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1148 {HW_VENDOR_INTEL
, CARD_INTEL_915G
, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1149 {HW_VENDOR_INTEL
, CARD_INTEL_E7221G
, "Intel(R) E7221G", DRIVER_INTEL_GMA900
, 64 },
1150 {HW_VENDOR_INTEL
, CARD_INTEL_915GM
, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1151 {HW_VENDOR_INTEL
, CARD_INTEL_945G
, "Intel(R) 945G", DRIVER_INTEL_GMA950
, 64 },
1152 {HW_VENDOR_INTEL
, CARD_INTEL_945GM
, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950
, 64 },
1153 {HW_VENDOR_INTEL
, CARD_INTEL_945GME
, "Intel(R) 945GME", DRIVER_INTEL_GMA950
, 64 },
1154 {HW_VENDOR_INTEL
, CARD_INTEL_Q35
, "Intel(R) Q35", DRIVER_INTEL_GMA950
, 64 },
1155 {HW_VENDOR_INTEL
, CARD_INTEL_G33
, "Intel(R) G33", DRIVER_INTEL_GMA950
, 64 },
1156 {HW_VENDOR_INTEL
, CARD_INTEL_Q33
, "Intel(R) Q33", DRIVER_INTEL_GMA950
, 64 },
1157 {HW_VENDOR_INTEL
, CARD_INTEL_PNVG
, "Intel(R) IGD", DRIVER_INTEL_GMA950
, 64 },
1158 {HW_VENDOR_INTEL
, CARD_INTEL_PNVM
, "Intel(R) IGD", DRIVER_INTEL_GMA950
, 64 },
1159 {HW_VENDOR_INTEL
, CARD_INTEL_965Q
, "Intel(R) 965Q", DRIVER_INTEL_GMA3000
, 128},
1160 {HW_VENDOR_INTEL
, CARD_INTEL_965G
, "Intel(R) 965G", DRIVER_INTEL_GMA3000
, 128},
1161 {HW_VENDOR_INTEL
, CARD_INTEL_946GZ
, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000
, 128},
1162 {HW_VENDOR_INTEL
, CARD_INTEL_965GM
, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000
, 128},
1163 {HW_VENDOR_INTEL
, CARD_INTEL_965GME
, "Intel(R) 965GME", DRIVER_INTEL_GMA3000
, 128},
1164 {HW_VENDOR_INTEL
, CARD_INTEL_GM45
, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000
, 512},
1165 {HW_VENDOR_INTEL
, CARD_INTEL_IGD
, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000
, 512},
1166 {HW_VENDOR_INTEL
, CARD_INTEL_G45
, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000
, 512},
1167 {HW_VENDOR_INTEL
, CARD_INTEL_Q45
, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000
, 512},
1168 {HW_VENDOR_INTEL
, CARD_INTEL_G41
, "Intel(R) G41", DRIVER_INTEL_GMA3000
, 512},
1169 {HW_VENDOR_INTEL
, CARD_INTEL_B43
, "Intel(R) B43", DRIVER_INTEL_GMA3000
, 512},
1170 {HW_VENDOR_INTEL
, CARD_INTEL_ILKD
, "Intel(R) Ironlake Desktop", DRIVER_INTEL_GMA3000
, 1024},
1171 {HW_VENDOR_INTEL
, CARD_INTEL_ILKM
, "Intel(R) Ironlake Mobile", DRIVER_INTEL_GMA3000
, 1024},
1172 {HW_VENDOR_INTEL
, CARD_INTEL_SNBD
, "Intel(R) Sandybridge Desktop", DRIVER_INTEL_GMA3000
, 1024},
1173 {HW_VENDOR_INTEL
, CARD_INTEL_SNBM
, "Intel(R) Sandybridge Mobile", DRIVER_INTEL_GMA3000
, 1024},
1174 {HW_VENDOR_INTEL
, CARD_INTEL_SNBS
, "Intel(R) Sandybridge Server", DRIVER_INTEL_GMA3000
, 1024},
1175 {HW_VENDOR_INTEL
, CARD_INTEL_IVBD
, "Intel(R) Ivybridge Desktop", DRIVER_INTEL_GMA3000
, 1024},
1176 {HW_VENDOR_INTEL
, CARD_INTEL_IVBM
, "Intel(R) Ivybridge Mobile", DRIVER_INTEL_GMA3000
, 1024},
1177 {HW_VENDOR_INTEL
, CARD_INTEL_IVBS
, "Intel(R) Ivybridge Server", DRIVER_INTEL_GMA3000
, 1024},
1180 static const struct driver_version_information
*get_driver_version_info(enum wined3d_display_driver driver
,
1181 enum wined3d_driver_model driver_model
)
1185 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver
, driver_model
);
1186 for (i
= 0; i
< (sizeof(driver_version_table
) / sizeof(driver_version_table
[0])); i
++)
1188 const struct driver_version_information
*entry
= &driver_version_table
[i
];
1190 if (entry
->driver
== driver
&& entry
->driver_model
== driver_model
)
1192 TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
1193 entry
->driver_name
, entry
->version
, entry
->subversion
, entry
->build
);
1200 static void init_driver_info(struct wined3d_driver_info
*driver_info
,
1201 enum wined3d_pci_vendor vendor
, enum wined3d_pci_device device
)
1203 OSVERSIONINFOW os_version
;
1204 WORD driver_os_version
;
1206 enum wined3d_display_driver driver
= DRIVER_UNKNOWN
;
1207 enum wined3d_driver_model driver_model
;
1208 const struct driver_version_information
*version_info
;
1210 if (wined3d_settings
.pci_vendor_id
!= PCI_VENDOR_NONE
)
1212 TRACE("Overriding PCI vendor ID with 0x%04x.\n", wined3d_settings
.pci_vendor_id
);
1213 vendor
= wined3d_settings
.pci_vendor_id
;
1215 driver_info
->vendor
= vendor
;
1217 if (wined3d_settings
.pci_device_id
!= PCI_DEVICE_NONE
)
1219 TRACE("Overriding PCI device ID with 0x%04x.\n", wined3d_settings
.pci_device_id
);
1220 device
= wined3d_settings
.pci_device_id
;
1222 driver_info
->device
= device
;
1224 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1225 * overrides the pci ids to a card which is not in our database. */
1226 driver_info
->vidmem
= WINE_DEFAULT_VIDMEM
;
1228 memset(&os_version
, 0, sizeof(os_version
));
1229 os_version
.dwOSVersionInfoSize
= sizeof(os_version
);
1230 if (!GetVersionExW(&os_version
))
1232 ERR("Failed to get OS version, reporting 2000/XP.\n");
1233 driver_os_version
= 6;
1234 driver_model
= DRIVER_MODEL_NT5X
;
1238 TRACE("OS version %u.%u.\n", os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1239 switch (os_version
.dwMajorVersion
)
1242 /* If needed we could distinguish between 9x and NT4, but this code won't make
1243 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1245 driver_os_version
= 4;
1246 driver_model
= DRIVER_MODEL_WIN9X
;
1250 driver_os_version
= 6;
1251 driver_model
= DRIVER_MODEL_NT5X
;
1255 if (os_version
.dwMinorVersion
== 0)
1257 driver_os_version
= 7;
1258 driver_model
= DRIVER_MODEL_NT6X
;
1262 if (os_version
.dwMinorVersion
> 1)
1264 FIXME("Unhandled OS version %u.%u, reporting Win 7.\n",
1265 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1267 driver_os_version
= 8;
1268 driver_model
= DRIVER_MODEL_NT6X
;
1273 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1274 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1275 driver_os_version
= 6;
1276 driver_model
= DRIVER_MODEL_NT5X
;
1281 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1282 * This means that unless the ids are overridden, we will always find a GPU description. */
1283 for (i
= 0; i
< (sizeof(gpu_description_table
) / sizeof(gpu_description_table
[0])); i
++)
1285 if (vendor
== gpu_description_table
[i
].vendor
&& device
== gpu_description_table
[i
].card
)
1287 TRACE("Found card %04x:%04x in driver DB.\n", vendor
, device
);
1289 driver_info
->description
= gpu_description_table
[i
].description
;
1290 driver_info
->vidmem
= gpu_description_table
[i
].vidmem
* 1024*1024;
1291 driver
= gpu_description_table
[i
].driver
;
1296 if (wined3d_settings
.emulated_textureram
)
1298 TRACE("Overriding amount of video memory with %u bytes.\n", wined3d_settings
.emulated_textureram
);
1299 driver_info
->vidmem
= wined3d_settings
.emulated_textureram
;
1302 /* Try to obtain driver version information for the current Windows version. This fails in
1304 * - the gpu is not available on the currently selected OS version:
1305 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1306 * version information for the current Windows version is returned instead of faked info.
1307 * We do the same and assume the default Windows version to emulate is WinXP.
1309 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1310 * For now return the XP driver info. Perhaps later on we should return VESA.
1312 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1313 * This could be an indication that our database is not up to date, so this should be fixed.
1315 version_info
= get_driver_version_info(driver
, driver_model
);
1318 driver_info
->name
= version_info
->driver_name
;
1319 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1320 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1324 version_info
= get_driver_version_info(driver
, DRIVER_MODEL_NT5X
);
1327 driver_info
->name
= version_info
->driver_name
;
1328 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1329 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1333 driver_info
->description
= "Direct3D HAL";
1334 driver_info
->name
= "Display";
1335 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, 15);
1336 driver_info
->version_low
= MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1338 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1339 vendor
, device
, driver_model
);
1343 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1344 driver_info
->version_high
, driver_info
->version_low
);
1347 /* Context activation is done by the caller. */
1348 static void fixup_extensions(struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
1349 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
1353 for (i
= 0; i
< (sizeof(quirk_table
) / sizeof(*quirk_table
)); ++i
)
1355 if (!quirk_table
[i
].match(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) continue;
1356 TRACE("Applying driver quirk \"%s\".\n", quirk_table
[i
].description
);
1357 quirk_table
[i
].apply(gl_info
);
1360 /* Find out if PBOs work as they are supposed to. */
1361 test_pbo_functionality(gl_info
);
1364 static DWORD
wined3d_parse_gl_version(const char *gl_version
)
1366 const char *ptr
= gl_version
;
1371 ERR("Invalid OpenGL major version %d.\n", major
);
1373 while (isdigit(*ptr
)) ++ptr
;
1375 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version
));
1379 TRACE("Found OpenGL version %d.%d.\n", major
, minor
);
1381 return MAKEDWORD_VERSION(major
, minor
);
1384 static enum wined3d_gl_vendor
wined3d_guess_gl_vendor(const struct wined3d_gl_info
*gl_info
,
1385 const char *gl_vendor_string
, const char *gl_renderer
)
1388 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1389 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1390 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1392 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1393 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1394 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1395 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1396 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1397 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1398 * DirectDraw, not OpenGL. */
1399 if (gl_info
->supported
[APPLE_FENCE
]
1400 && gl_info
->supported
[APPLE_CLIENT_STORAGE
]
1401 && gl_info
->supported
[APPLE_YCBCR_422
])
1402 return GL_VENDOR_APPLE
;
1404 if (strstr(gl_vendor_string
, "NVIDIA"))
1405 return GL_VENDOR_NVIDIA
;
1407 if (strstr(gl_vendor_string
, "ATI"))
1408 return GL_VENDOR_FGLRX
;
1410 if (strstr(gl_vendor_string
, "Intel(R)")
1411 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1412 || strstr(gl_renderer
, "Intel")
1413 || strstr(gl_vendor_string
, "Intel Inc."))
1414 return GL_VENDOR_INTEL
;
1416 if (strstr(gl_vendor_string
, "Mesa")
1417 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1418 || strstr(gl_vendor_string
, "DRI R300 Project")
1419 || strstr(gl_vendor_string
, "X.Org R300 Project")
1420 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1421 || strstr(gl_vendor_string
, "VMware, Inc.")
1422 || strstr(gl_renderer
, "Mesa")
1423 || strstr(gl_renderer
, "Gallium"))
1424 return GL_VENDOR_MESA
;
1426 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1427 debugstr_a(gl_vendor_string
));
1429 return GL_VENDOR_UNKNOWN
;
1432 static enum wined3d_pci_vendor
wined3d_guess_card_vendor(const char *gl_vendor_string
, const char *gl_renderer
)
1434 if (strstr(gl_vendor_string
, "NVIDIA")
1435 || strstr(gl_vendor_string
, "Nouveau")
1436 || strstr(gl_vendor_string
, "nouveau"))
1437 return HW_VENDOR_NVIDIA
;
1439 if (strstr(gl_vendor_string
, "ATI")
1440 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1441 || strstr(gl_vendor_string
, "X.Org R300 Project")
1442 || strstr(gl_renderer
, "AMD")
1443 || strstr(gl_renderer
, "R100")
1444 || strstr(gl_renderer
, "R200")
1445 || strstr(gl_renderer
, "R300")
1446 || strstr(gl_renderer
, "R600")
1447 || strstr(gl_renderer
, "R700"))
1448 return HW_VENDOR_AMD
;
1450 if (strstr(gl_vendor_string
, "Intel(R)")
1451 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1452 || strstr(gl_renderer
, "Intel")
1453 || strstr(gl_renderer
, "i915")
1454 || strstr(gl_vendor_string
, "Intel Inc."))
1455 return HW_VENDOR_INTEL
;
1457 if (strstr(gl_vendor_string
, "Mesa")
1458 || strstr(gl_vendor_string
, "Brian Paul")
1459 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1460 || strstr(gl_vendor_string
, "VMware, Inc."))
1461 return HW_VENDOR_SOFTWARE
;
1463 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string
));
1465 return HW_VENDOR_NVIDIA
;
1468 static UINT
d3d_level_from_gl_info(const struct wined3d_gl_info
*gl_info
)
1472 if (gl_info
->supported
[ARB_MULTITEXTURE
])
1474 if (gl_info
->supported
[ARB_TEXTURE_COMPRESSION
]
1475 && gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
]
1476 && gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
1478 if (level
== 7 && gl_info
->supported
[ARB_MULTISAMPLE
]
1479 && gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
1481 if (level
== 8 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]
1482 && gl_info
->supported
[ARB_VERTEX_SHADER
])
1484 if (level
== 9 && gl_info
->supported
[EXT_GPU_SHADER4
])
1490 static enum wined3d_pci_device
select_card_nvidia_binary(const struct wined3d_gl_info
*gl_info
,
1491 const char *gl_renderer
)
1493 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1496 if (d3d_level
>= 10)
1500 const char *renderer
;
1501 enum wined3d_pci_device id
;
1505 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680
}, /* Geforce 600 - highend */
1506 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670
}, /* Geforce 600 - midend high */
1507 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580
}, /* Geforce 500 - highend */
1508 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570
}, /* Geforce 500 - midend high */
1509 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI
}, /* Geforce 500 - midend */
1510 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560
}, /* Geforce 500 - midend */
1511 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M
}, /* Geforce 500 - midend mobile */
1512 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550
}, /* Geforce 500 - midend */
1513 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M
}, /* Geforce 500 - midend mobile */
1514 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480
}, /* Geforce 400 - highend */
1515 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470
}, /* Geforce 400 - midend high */
1516 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465
}, /* Geforce 400 - midend */
1517 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M
}, /* Geforce 400 - highend mobile */
1518 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460
}, /* Geforce 400 - midend */
1519 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450
}, /* Geforce 400 - midend low */
1520 {"GT 440", CARD_NVIDIA_GEFORCE_GT440
}, /* Geforce 400 - lowend */
1521 {"GT 430", CARD_NVIDIA_GEFORCE_GT430
}, /* Geforce 400 - lowend */
1522 {"GT 420", CARD_NVIDIA_GEFORCE_GT420
}, /* Geforce 400 - lowend */
1523 {"GT 330", CARD_NVIDIA_GEFORCE_GT330
}, /* Geforce 300 - highend */
1524 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1525 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1526 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1527 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1528 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M
}, /* Geforce 300 - midend mobile */
1529 {"320M", CARD_NVIDIA_GEFORCE_320M
}, /* Geforce 300 - midend mobile */
1530 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1531 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1532 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1533 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275
}, /* Geforce 200 - midend high */
1534 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260
}, /* Geforce 200 - midend */
1535 {"GT 240", CARD_NVIDIA_GEFORCE_GT240
}, /* Geforce 200 - midend */
1536 {"GT 220", CARD_NVIDIA_GEFORCE_GT220
}, /* Geforce 200 - lowend */
1537 {"Geforce 310", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1538 {"Geforce 305", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1539 {"Geforce 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1540 {"G 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1541 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1542 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1543 {"9800", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1544 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1545 {"9600", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1546 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1547 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1548 {"9500", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1549 {"9400M", CARD_NVIDIA_GEFORCE_9400M
}, /* Geforce 9 - lowend */
1550 {"9400", CARD_NVIDIA_GEFORCE_9400GT
}, /* Geforce 9 - lowend */
1551 {"9300", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1552 {"9200", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1553 {"9100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1554 {"G 100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1555 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX
}, /* Geforce 8 - highend high */
1556 {"8800", CARD_NVIDIA_GEFORCE_8800GTS
}, /* Geforce 8 - highend */
1557 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1558 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1559 {"8700", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1560 {"8600", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1561 {"8500", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1562 {"8400", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1563 {"8300", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1564 {"8200", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1565 {"8100", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1568 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1570 if (strstr(gl_renderer
, cards
[i
].renderer
))
1574 /* Geforce8-compatible fall back if the GPU is not in the list yet */
1575 return CARD_NVIDIA_GEFORCE_8300GS
;
1578 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1579 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1581 if (d3d_level
>= 9 && gl_info
->supported
[NV_VERTEX_PROGRAM3
])
1585 const char *renderer
;
1586 enum wined3d_pci_device id
;
1590 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1591 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1592 {"7950", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1593 {"7900", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1594 {"7800", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1595 {"7700", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1596 {"7600", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1597 {"7400", CARD_NVIDIA_GEFORCE_7400
}, /* Geforce 7 - lower medium */
1598 {"7300", CARD_NVIDIA_GEFORCE_7300
}, /* Geforce 7 - lowend */
1599 {"6800", CARD_NVIDIA_GEFORCE_6800
}, /* Geforce 6 - highend */
1600 {"6700", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1601 {"6610", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1602 {"6600", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1605 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1607 if (strstr(gl_renderer
, cards
[i
].renderer
))
1611 /* Geforce 6/7 - lowend */
1612 return CARD_NVIDIA_GEFORCE_6200
; /* Geforce 6100/6150/6200/7300/7400/7500 */
1617 /* GeforceFX - highend */
1618 if (strstr(gl_renderer
, "5800")
1619 || strstr(gl_renderer
, "5900")
1620 || strstr(gl_renderer
, "5950")
1621 || strstr(gl_renderer
, "Quadro FX"))
1623 return CARD_NVIDIA_GEFORCEFX_5800
;
1626 /* GeforceFX - midend */
1627 if (strstr(gl_renderer
, "5600")
1628 || strstr(gl_renderer
, "5650")
1629 || strstr(gl_renderer
, "5700")
1630 || strstr(gl_renderer
, "5750"))
1632 return CARD_NVIDIA_GEFORCEFX_5600
;
1635 /* GeforceFX - lowend */
1636 return CARD_NVIDIA_GEFORCEFX_5200
; /* GeforceFX 5100/5200/5250/5300/5500 */
1641 if (strstr(gl_renderer
, "GeForce4 Ti") || strstr(gl_renderer
, "Quadro4"))
1643 return CARD_NVIDIA_GEFORCE4_TI4200
; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1646 return CARD_NVIDIA_GEFORCE3
; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1651 if (strstr(gl_renderer
, "GeForce4 MX"))
1653 return CARD_NVIDIA_GEFORCE4_MX
; /* MX420/MX440/MX460/MX4000 */
1656 if (strstr(gl_renderer
, "GeForce2 MX") || strstr(gl_renderer
, "Quadro2 MXR"))
1658 return CARD_NVIDIA_GEFORCE2_MX
; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1661 if (strstr(gl_renderer
, "GeForce2") || strstr(gl_renderer
, "Quadro2"))
1663 return CARD_NVIDIA_GEFORCE2
; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1666 return CARD_NVIDIA_GEFORCE
; /* Geforce 256/DDR, Quadro */
1669 if (strstr(gl_renderer
, "TNT2"))
1671 return CARD_NVIDIA_RIVA_TNT2
; /* Riva TNT2 standard/M64/Pro/Ultra */
1674 return CARD_NVIDIA_RIVA_TNT
; /* Riva TNT, Vanta */
1677 static enum wined3d_pci_device
select_card_amd_binary(const struct wined3d_gl_info
*gl_info
,
1678 const char *gl_renderer
)
1680 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1682 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1684 * Beware: renderer string do not match exact card model,
1685 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1686 if (d3d_level
>= 10)
1692 const char *renderer
;
1693 enum wined3d_pci_device id
;
1697 /* Southern Islands */
1698 {"HD 7900", CARD_AMD_RADEON_HD7900
},
1699 /* Northern Islands */
1700 {"HD 6900", CARD_AMD_RADEON_HD6900
},
1701 {"HD 6800", CARD_AMD_RADEON_HD6800
},
1702 {"HD 6770M",CARD_AMD_RADEON_HD6600M
},
1703 {"HD 6750M",CARD_AMD_RADEON_HD6600M
},
1704 {"HD 6700", CARD_AMD_RADEON_HD6700
},
1705 {"HD 6630M",CARD_AMD_RADEON_HD6600M
},
1706 {"HD 6600M",CARD_AMD_RADEON_HD6600M
},
1707 {"HD 6600", CARD_AMD_RADEON_HD6600
},
1708 {"HD 6500M",CARD_AMD_RADEON_HD6600M
},
1709 {"HD 6500", CARD_AMD_RADEON_HD6600
},
1710 {"HD 6400", CARD_AMD_RADEON_HD6400
},
1711 {"HD 6300", CARD_AMD_RADEON_HD6300
},
1712 {"HD 6200", CARD_AMD_RADEON_HD6300
},
1714 {"HD 5870", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS PRO */
1715 {"HD 5850", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS XT */
1716 {"HD 5800", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1717 {"HD 5770", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER XT */
1718 {"HD 5750", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER LE */
1719 {"HD 5700", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1720 {"HD 5670", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD XT */
1721 {"HD 5570", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1722 {"HD 5550", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1723 {"HD 5450", CARD_AMD_RADEON_HD5400
}, /* Radeon EG CEDAR PRO */
1725 {"HD 4890", CARD_AMD_RADEON_HD4800
}, /* Radeon RV790 */
1726 {"HD 4870", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1727 {"HD 4850", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1728 {"HD 4830", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1729 {"HD 4800", CARD_AMD_RADEON_HD4800
}, /* Radeon RV7xx HD48xx generic renderer string */
1730 {"HD 4770", CARD_AMD_RADEON_HD4700
}, /* Radeon RV740 */
1731 {"HD 4700", CARD_AMD_RADEON_HD4700
}, /* Radeon RV7xx HD47xx generic renderer string */
1732 {"HD 4670", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1733 {"HD 4650", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1734 {"HD 4600", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1735 {"HD 4550", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1736 {"HD 4350", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1737 /* R600/R700 integrated */
1738 {"HD 3300", CARD_AMD_RADEON_HD3200
},
1739 {"HD 3200", CARD_AMD_RADEON_HD3200
},
1740 {"HD 3100", CARD_AMD_RADEON_HD3200
},
1742 {"HD 3870", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1743 {"HD 3850", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1744 {"HD 2900", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1745 {"HD 3830", CARD_AMD_RADEON_HD2600
}, /* China-only midend */
1746 {"HD 3690", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1747 {"HD 3650", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1748 {"HD 2600", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1749 {"HD 3470", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1750 {"HD 3450", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1751 {"HD 3430", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1752 {"HD 3400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1753 {"HD 2400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1754 {"HD 2350", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1757 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1759 if (strstr(gl_renderer
, cards
[i
].renderer
))
1763 /* Default for when no GPU has been found */
1764 return CARD_AMD_RADEON_HD3200
;
1770 if (strstr(gl_renderer
, "X1600")
1771 || strstr(gl_renderer
, "X1650")
1772 || strstr(gl_renderer
, "X1800")
1773 || strstr(gl_renderer
, "X1900")
1774 || strstr(gl_renderer
, "X1950"))
1776 return CARD_AMD_RADEON_X1600
;
1779 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1780 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1781 if (strstr(gl_renderer
, "X700")
1782 || strstr(gl_renderer
, "X800")
1783 || strstr(gl_renderer
, "X850")
1784 || strstr(gl_renderer
, "X1300")
1785 || strstr(gl_renderer
, "X1400")
1786 || strstr(gl_renderer
, "X1450")
1787 || strstr(gl_renderer
, "X1550")
1788 || strstr(gl_renderer
, "X2300")
1789 || strstr(gl_renderer
, "X2500")
1790 || strstr(gl_renderer
, "HD 2300")
1793 return CARD_AMD_RADEON_X700
;
1796 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1797 if (strstr(gl_renderer
, "Radeon Xpress"))
1799 return CARD_AMD_RADEON_XPRESS_200M
;
1803 return CARD_AMD_RADEON_9500
; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
1807 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1810 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1812 return CARD_AMD_RAGE_128PRO
;
1815 static enum wined3d_pci_device
select_card_intel(const struct wined3d_gl_info
*gl_info
,
1816 const char *gl_renderer
)
1822 const char *renderer
;
1823 enum wined3d_pci_device id
;
1828 {"Ivybridge Server", CARD_INTEL_IVBS
},
1829 {"Ivybridge Mobile", CARD_INTEL_IVBM
},
1830 {"Ivybridge Desktop", CARD_INTEL_IVBD
},
1832 {"Sandybridge Server", CARD_INTEL_SNBS
},
1833 {"Sandybridge Mobile", CARD_INTEL_SNBM
},
1834 {"Sandybridge Desktop", CARD_INTEL_SNBD
},
1836 {"Ironlake Mobile", CARD_INTEL_ILKM
},
1837 {"Ironlake Desktop", CARD_INTEL_ILKD
},
1839 {"B43", CARD_INTEL_B43
},
1840 {"G41", CARD_INTEL_G41
},
1841 {"G45", CARD_INTEL_G45
},
1842 {"Q45", CARD_INTEL_Q45
},
1843 {"Integrated Graphics Device", CARD_INTEL_IGD
},
1844 {"GM45", CARD_INTEL_GM45
},
1846 {"965GME", CARD_INTEL_965GME
},
1847 {"965GM", CARD_INTEL_965GM
},
1848 {"X3100", CARD_INTEL_965GM
}, /* MacOS */
1849 {"946GZ", CARD_INTEL_946GZ
},
1850 {"965G", CARD_INTEL_965G
},
1851 {"965Q", CARD_INTEL_965Q
},
1853 {"Pineview M", CARD_INTEL_PNVM
},
1854 {"Pineview G", CARD_INTEL_PNVG
},
1855 {"IGD", CARD_INTEL_PNVG
},
1856 {"Q33", CARD_INTEL_Q33
},
1857 {"G33", CARD_INTEL_G33
},
1858 {"Q35", CARD_INTEL_Q35
},
1859 {"945GME", CARD_INTEL_945GME
},
1860 {"945GM", CARD_INTEL_945GM
},
1861 {"GMA 950", CARD_INTEL_945GM
}, /* MacOS */
1862 {"945G", CARD_INTEL_945G
},
1864 {"915GM", CARD_INTEL_915GM
},
1865 {"E7221G", CARD_INTEL_E7221G
},
1866 {"915G", CARD_INTEL_915G
},
1868 {"865G", CARD_INTEL_865G
},
1869 {"845G", CARD_INTEL_845G
},
1870 {"855GM", CARD_INTEL_855GM
},
1871 {"830M", CARD_INTEL_830M
},
1874 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1876 if (strstr(gl_renderer
, cards
[i
].renderer
))
1880 return CARD_INTEL_915G
;
1883 static enum wined3d_pci_device
select_card_amd_mesa(const struct wined3d_gl_info
*gl_info
,
1884 const char *gl_renderer
)
1889 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1891 * Beware: renderer string do not match exact card model,
1892 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1893 if (strstr(gl_renderer
, "Gallium"))
1895 /* 20101109 - These are never returned by current Gallium radeon
1896 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
1898 * These are returned but not handled: RC410, RV380. */
1901 const char *renderer
;
1902 enum wined3d_pci_device id
;
1906 /* Southern Islands */
1907 {"TAHITI", CARD_AMD_RADEON_HD7900
},
1908 /* Northern Islands */
1909 {"CAYMAN", CARD_AMD_RADEON_HD6900
},
1910 {"BARTS", CARD_AMD_RADEON_HD6800
},
1911 {"TURKS", CARD_AMD_RADEON_HD6600
},
1912 {"SUMO2", CARD_AMD_RADEON_HD6410D
}, /* SUMO2 first, because we do a strstr(). */
1913 {"SUMO", CARD_AMD_RADEON_HD6550D
},
1914 {"CAICOS", CARD_AMD_RADEON_HD6400
},
1915 {"PALM", CARD_AMD_RADEON_HD6300
},
1917 {"HEMLOCK", CARD_AMD_RADEON_HD5900
},
1918 {"CYPRESS", CARD_AMD_RADEON_HD5800
},
1919 {"JUNIPER", CARD_AMD_RADEON_HD5700
},
1920 {"REDWOOD", CARD_AMD_RADEON_HD5600
},
1921 {"CEDAR", CARD_AMD_RADEON_HD5400
},
1923 {"R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1924 {"RV790", CARD_AMD_RADEON_HD4800
},
1925 {"RV770", CARD_AMD_RADEON_HD4800
},
1926 {"RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1927 {"RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1928 {"RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1929 /* R600/R700 integrated */
1930 {"RS880", CARD_AMD_RADEON_HD3200
},
1931 {"RS780", CARD_AMD_RADEON_HD3200
},
1933 {"R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1934 {"R600", CARD_AMD_RADEON_HD2900
},
1935 {"RV670", CARD_AMD_RADEON_HD2900
},
1936 {"RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1937 {"RV630", CARD_AMD_RADEON_HD2600
},
1938 {"RV620", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1939 {"RV610", CARD_AMD_RADEON_HD2350
},
1941 {"R580", CARD_AMD_RADEON_X1600
},
1942 {"R520", CARD_AMD_RADEON_X1600
},
1943 {"RV570", CARD_AMD_RADEON_X1600
},
1944 {"RV560", CARD_AMD_RADEON_X1600
},
1945 {"RV535", CARD_AMD_RADEON_X1600
},
1946 {"RV530", CARD_AMD_RADEON_X1600
},
1947 {"RV516", CARD_AMD_RADEON_X700
}, /* X700 is actually R400. */
1948 {"RV515", CARD_AMD_RADEON_X700
},
1950 {"R481", CARD_AMD_RADEON_X700
},
1951 {"R480", CARD_AMD_RADEON_X700
},
1952 {"R430", CARD_AMD_RADEON_X700
},
1953 {"R423", CARD_AMD_RADEON_X700
},
1954 {"R420", CARD_AMD_RADEON_X700
},
1955 {"R410", CARD_AMD_RADEON_X700
},
1956 {"RV410", CARD_AMD_RADEON_X700
},
1957 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
1958 {"RS740", CARD_AMD_RADEON_XPRESS_200M
},
1959 {"RS690", CARD_AMD_RADEON_XPRESS_200M
},
1960 {"RS600", CARD_AMD_RADEON_XPRESS_200M
},
1961 {"RS485", CARD_AMD_RADEON_XPRESS_200M
},
1962 {"RS482", CARD_AMD_RADEON_XPRESS_200M
},
1963 {"RS480", CARD_AMD_RADEON_XPRESS_200M
},
1964 {"RS400", CARD_AMD_RADEON_XPRESS_200M
},
1966 {"R360", CARD_AMD_RADEON_9500
},
1967 {"R350", CARD_AMD_RADEON_9500
},
1968 {"R300", CARD_AMD_RADEON_9500
},
1969 {"RV370", CARD_AMD_RADEON_9500
},
1970 {"RV360", CARD_AMD_RADEON_9500
},
1971 {"RV351", CARD_AMD_RADEON_9500
},
1972 {"RV350", CARD_AMD_RADEON_9500
},
1975 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1977 if (strstr(gl_renderer
, cards
[i
].renderer
))
1982 d3d_level
= d3d_level_from_gl_info(gl_info
);
1983 if (d3d_level
>= 10)
1984 return CARD_AMD_RADEON_HD2600
;
1990 const char *renderer
;
1991 enum wined3d_pci_device id
;
1996 {"(R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1997 {"(RV790", CARD_AMD_RADEON_HD4800
},
1998 {"(RV770", CARD_AMD_RADEON_HD4800
},
1999 {"(RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
2000 {"(RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
2001 {"(RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
2002 /* R600/R700 integrated */
2003 {"RS880", CARD_AMD_RADEON_HD3200
},
2004 {"RS780", CARD_AMD_RADEON_HD3200
},
2006 {"(R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
2007 {"(R600", CARD_AMD_RADEON_HD2900
},
2008 {"(RV670", CARD_AMD_RADEON_HD2900
},
2009 {"(RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
2010 {"(RV630", CARD_AMD_RADEON_HD2600
},
2011 {"(RV620", CARD_AMD_RADEON_HD2350
}, /* HD2300/HD2400/HD3400 - lowend */
2012 {"(RV610", CARD_AMD_RADEON_HD2350
},
2015 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
2017 if (strstr(gl_renderer
, cards
[i
].renderer
))
2021 return CARD_AMD_RADEON_9500
;
2025 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
2028 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
2030 return CARD_AMD_RAGE_128PRO
;
2033 static enum wined3d_pci_device
select_card_nvidia_mesa(const struct wined3d_gl_info
*gl_info
,
2034 const char *gl_renderer
)
2041 const char *renderer
;
2042 enum wined3d_pci_device id
;
2047 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680
},
2049 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550
},
2050 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560
},
2051 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570
},
2052 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460
},
2053 {"NVC3", CARD_NVIDIA_GEFORCE_GT440
},
2054 {"NVC1", CARD_NVIDIA_GEFORCE_GT420
},
2055 {"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 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX
},
2072 {"NV68", CARD_NVIDIA_GEFORCE_6200
}, /* 7050 */
2073 {"NV67", CARD_NVIDIA_GEFORCE_6200
}, /* 7000M */
2074 {"NV63", CARD_NVIDIA_GEFORCE_6200
}, /* 7100 */
2075 {"NV4E", CARD_NVIDIA_GEFORCE_6200
}, /* 6100 Go / 6150 Go */
2076 {"NV4C", CARD_NVIDIA_GEFORCE_6200
}, /* 6150SE */
2077 {"NV4B", CARD_NVIDIA_GEFORCE_7600
},
2078 {"NV4A", CARD_NVIDIA_GEFORCE_6200
},
2079 {"NV49", CARD_NVIDIA_GEFORCE_7800GT
}, /* 7900 */
2080 {"NV47", CARD_NVIDIA_GEFORCE_7800GT
},
2081 {"NV46", CARD_NVIDIA_GEFORCE_7400
},
2082 {"NV45", CARD_NVIDIA_GEFORCE_6800
},
2083 {"NV44", CARD_NVIDIA_GEFORCE_6200
},
2084 {"NV43", CARD_NVIDIA_GEFORCE_6600GT
},
2085 {"NV42", CARD_NVIDIA_GEFORCE_6800
},
2086 {"NV41", CARD_NVIDIA_GEFORCE_6800
},
2087 {"NV40", CARD_NVIDIA_GEFORCE_6800
},
2089 {"NV38", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5950 Ultra */
2090 {"NV36", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5700/5750 */
2091 {"NV35", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5900 */
2092 {"NV34", CARD_NVIDIA_GEFORCEFX_5200
},
2093 {"NV31", CARD_NVIDIA_GEFORCEFX_5600
},
2094 {"NV30", CARD_NVIDIA_GEFORCEFX_5800
},
2096 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200
},
2097 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200
},
2098 {"nv20", CARD_NVIDIA_GEFORCE3
},
2100 {"nv1F", CARD_NVIDIA_GEFORCE4_MX
}, /* GF4 MX IGP */
2101 {"nv1A", CARD_NVIDIA_GEFORCE2
}, /* GF2 IGP */
2102 {"nv18", CARD_NVIDIA_GEFORCE4_MX
},
2103 {"nv17", CARD_NVIDIA_GEFORCE4_MX
},
2104 {"nv16", CARD_NVIDIA_GEFORCE2
},
2105 {"nv15", CARD_NVIDIA_GEFORCE2
},
2106 {"nv11", CARD_NVIDIA_GEFORCE2_MX
},
2107 {"nv10", CARD_NVIDIA_GEFORCE
},
2109 {"nv05", CARD_NVIDIA_RIVA_TNT2
},
2110 {"nv04", CARD_NVIDIA_RIVA_TNT
},
2111 {"nv03", CARD_NVIDIA_RIVA_128
},
2114 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
2116 if (strstr(gl_renderer
, cards
[i
].renderer
))
2120 FIXME("Unknown renderer %s.\n", debugstr_a(gl_renderer
));
2122 d3d_level
= d3d_level_from_gl_info(gl_info
);
2123 if (d3d_level
>= 10)
2124 return CARD_NVIDIA_GEFORCE_8800GTX
;
2126 return CARD_NVIDIA_GEFORCEFX_5800
;
2128 return CARD_NVIDIA_GEFORCE3
;
2130 return CARD_NVIDIA_GEFORCE
;
2132 return CARD_NVIDIA_RIVA_TNT
;
2133 return CARD_NVIDIA_RIVA_128
;
2137 struct vendor_card_selection
2139 enum wined3d_gl_vendor gl_vendor
;
2140 enum wined3d_pci_vendor card_vendor
;
2141 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
2142 enum wined3d_pci_device (*select_card
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
);
2145 static const struct vendor_card_selection vendor_card_select_table
[] =
2147 {GL_VENDOR_NVIDIA
, HW_VENDOR_NVIDIA
, "Nvidia binary driver", select_card_nvidia_binary
},
2148 {GL_VENDOR_APPLE
, HW_VENDOR_NVIDIA
, "Apple OSX NVidia binary driver", select_card_nvidia_binary
},
2149 {GL_VENDOR_APPLE
, HW_VENDOR_AMD
, "Apple OSX AMD/ATI binary driver", select_card_amd_binary
},
2150 {GL_VENDOR_APPLE
, HW_VENDOR_INTEL
, "Apple OSX Intel binary driver", select_card_intel
},
2151 {GL_VENDOR_FGLRX
, HW_VENDOR_AMD
, "AMD/ATI binary driver", select_card_amd_binary
},
2152 {GL_VENDOR_MESA
, HW_VENDOR_AMD
, "Mesa AMD/ATI driver", select_card_amd_mesa
},
2153 {GL_VENDOR_MESA
, HW_VENDOR_NVIDIA
, "Mesa Nouveau driver", select_card_nvidia_mesa
},
2154 {GL_VENDOR_MESA
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
},
2155 {GL_VENDOR_INTEL
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
}
2159 static enum wined3d_pci_device
wined3d_guess_card(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
2160 enum wined3d_gl_vendor
*gl_vendor
, enum wined3d_pci_vendor
*card_vendor
)
2164 /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of
2165 * different GPUs with roughly the same features. In most cases GPUs from a
2166 * certain family differ in clockspeeds, the amount of video memory and the
2167 * number of shader pipelines.
2169 * A Direct3D device object contains the PCI id (vendor + device) of the
2170 * videocard which is used for rendering. Various applications use this
2171 * information to get a rough estimation of the features of the card and
2172 * some might use it for enabling 3d effects only on certain types of
2173 * videocards. In some cases games might even use it to work around bugs
2174 * which happen on certain videocards/driver combinations. The problem is
2175 * that OpenGL only exposes a rendering string containing the name of the
2176 * videocard and not the PCI id.
2178 * Various games depend on the PCI id, so somehow we need to provide one.
2179 * A simple option is to parse the renderer string and translate this to
2180 * the right PCI id. This is a lot of work because there are more than 200
2181 * GPUs just for Nvidia. Various cards share the same renderer string, so
2182 * the amount of code might be 'small' but there are quite a number of
2183 * exceptions which would make this a pain to maintain. Another way would
2184 * be to query the PCI id from the operating system (assuming this is the
2185 * videocard which is used for rendering which is not always the case).
2186 * This would work but it is not very portable. Second it would not work
2187 * well in, let's say, a remote X situation in which the amount of 3d
2188 * features which can be used is limited.
2190 * As said most games only use the PCI id to get an indication of the
2191 * capabilities of the card. It doesn't really matter if the given id is
2192 * the correct one if we return the id of a card with similar 3d features.
2194 * The code below checks the OpenGL capabilities of a videocard and matches
2195 * that to a certain level of Direct3D functionality. Once a card passes
2196 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2197 * least a GeforceFX. To give a better estimate we do a basic check on the
2198 * renderer string but if that won't pass we return a default card. This
2199 * way is better than maintaining a full card database as even without a
2200 * full database we can return a card with similar features. Second the
2201 * size of the database can be made quite small because when you know what
2202 * type of 3d functionality a card has, you know to which GPU family the
2203 * GPU must belong. Because of this you only have to check a small part of
2204 * the renderer string to distinguishes between different models from that
2207 * The code also selects a default amount of video memory which we will
2208 * use for an estimation of the amount of free texture memory. In case of
2209 * real D3D the amount of texture memory includes video memory and system
2210 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2211 * HyperMemory). We don't know how much system memory can be addressed by
2212 * the system but we can make a reasonable estimation about the amount of
2213 * video memory. If the value is slightly wrong it doesn't matter as we
2214 * didn't include AGP-like memory which makes the amount of addressable
2215 * memory higher and second OpenGL isn't that critical it moves to system
2216 * memory behind our backs if really needed. Note that the amount of video
2217 * memory can be overruled using a registry setting. */
2221 for (i
= 0; i
< (sizeof(vendor_card_select_table
) / sizeof(*vendor_card_select_table
)); ++i
)
2223 if ((vendor_card_select_table
[i
].gl_vendor
!= *gl_vendor
)
2224 || (vendor_card_select_table
[i
].card_vendor
!= *card_vendor
))
2226 TRACE("Applying card_selector \"%s\".\n", vendor_card_select_table
[i
].description
);
2227 return vendor_card_select_table
[i
].select_card(gl_info
, gl_renderer
);
2230 FIXME("No card selector available for GL vendor %#x and card vendor %04x (using GL_RENDERER %s).\n",
2231 *gl_vendor
, *card_vendor
, debugstr_a(gl_renderer
));
2233 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
2234 * for Nvidia was because the hardware and drivers they make are of good quality. This makes
2235 * them a good generic choice. */
2236 *card_vendor
= HW_VENDOR_NVIDIA
;
2237 d3d_level
= d3d_level_from_gl_info(gl_info
);
2239 return CARD_NVIDIA_GEFORCEFX_5600
;
2241 return CARD_NVIDIA_GEFORCE3
;
2243 return CARD_NVIDIA_GEFORCE
;
2245 return CARD_NVIDIA_RIVA_TNT
;
2246 return CARD_NVIDIA_RIVA_128
;
2249 static const struct fragment_pipeline
*select_fragment_implementation(const struct wined3d_gl_info
*gl_info
)
2251 int vs_selected_mode
, ps_selected_mode
;
2253 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2254 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2255 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_fragment_pipeline
;
2256 else if (ps_selected_mode
== SHADER_ATI
) return &atifs_fragment_pipeline
;
2257 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]
2258 && gl_info
->supported
[NV_TEXTURE_SHADER2
]) return &nvts_fragment_pipeline
;
2259 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]) return &nvrc_fragment_pipeline
;
2260 else return &ffp_fragment_pipeline
;
2263 static const struct wined3d_shader_backend_ops
*select_shader_backend(const struct wined3d_gl_info
*gl_info
)
2265 int vs_selected_mode
, ps_selected_mode
;
2267 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2268 if (vs_selected_mode
== SHADER_GLSL
|| ps_selected_mode
== SHADER_GLSL
) return &glsl_shader_backend
;
2269 if (vs_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_ARB
) return &arb_program_shader_backend
;
2270 return &none_shader_backend
;
2273 static const struct blit_shader
*select_blit_implementation(const struct wined3d_gl_info
*gl_info
)
2275 int vs_selected_mode
, ps_selected_mode
;
2277 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2278 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2279 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_blit
;
2280 else return &ffp_blit
;
2283 static void parse_extension_string(struct wined3d_gl_info
*gl_info
, const char *extensions
,
2284 const struct wined3d_extension_map
*map
, UINT entry_count
)
2292 while (isspace(*extensions
))
2295 while (!isspace(*extensions
) && *extensions
)
2298 len
= extensions
- start
;
2302 TRACE("- %s.\n", debugstr_an(start
, len
));
2304 for (i
= 0; i
< entry_count
; ++i
)
2306 if (len
== strlen(map
[i
].extension_string
)
2307 && !memcmp(start
, map
[i
].extension_string
, len
))
2309 TRACE(" FOUND: %s support.\n", map
[i
].extension_string
);
2310 gl_info
->supported
[map
[i
].extension
] = TRUE
;
2317 static void load_gl_funcs(struct wined3d_gl_info
*gl_info
)
2319 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)pwglGetProcAddress(#pfn);
2323 #ifndef USE_WIN32_OPENGL
2324 /* hack: use the functions directly from the TEB table to bypass the thunks */
2325 /* note that we still need the above wglGetProcAddress calls to initialize the table */
2326 gl_info
->gl_ops
.ext
= ((struct opengl_funcs
*)NtCurrentTeb()->glTable
)->ext
;
2330 static void wined3d_adapter_init_limits(struct wined3d_gl_info
*gl_info
)
2332 GLfloat gl_floatv
[2];
2335 gl_info
->limits
.blends
= 1;
2336 gl_info
->limits
.buffers
= 1;
2337 gl_info
->limits
.textures
= 1;
2338 gl_info
->limits
.texture_coords
= 1;
2339 gl_info
->limits
.fragment_samplers
= 1;
2340 gl_info
->limits
.vertex_samplers
= 0;
2341 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
+ gl_info
->limits
.vertex_samplers
;
2342 gl_info
->limits
.vertex_attribs
= 16;
2343 gl_info
->limits
.glsl_vs_float_constants
= 0;
2344 gl_info
->limits
.glsl_ps_float_constants
= 0;
2345 gl_info
->limits
.arb_vs_float_constants
= 0;
2346 gl_info
->limits
.arb_vs_native_constants
= 0;
2347 gl_info
->limits
.arb_vs_instructions
= 0;
2348 gl_info
->limits
.arb_vs_temps
= 0;
2349 gl_info
->limits
.arb_ps_float_constants
= 0;
2350 gl_info
->limits
.arb_ps_local_constants
= 0;
2351 gl_info
->limits
.arb_ps_instructions
= 0;
2352 gl_info
->limits
.arb_ps_temps
= 0;
2354 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
2355 gl_info
->limits
.clipplanes
= min(WINED3DMAXUSERCLIPPLANES
, gl_max
);
2356 TRACE("Clip plane support - max planes %d.\n", gl_max
);
2358 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
2359 gl_info
->limits
.lights
= gl_max
;
2360 TRACE("Light support - max lights %d.\n", gl_max
);
2362 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_max
);
2363 gl_info
->limits
.texture_size
= gl_max
;
2364 TRACE("Maximum texture size support - max texture size %d.\n", gl_max
);
2366 gl_info
->gl_ops
.gl
.p_glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE
, gl_floatv
);
2367 gl_info
->limits
.pointsize_min
= gl_floatv
[0];
2368 gl_info
->limits
.pointsize_max
= gl_floatv
[1];
2369 TRACE("Maximum point size support - max point size %f.\n", gl_floatv
[1]);
2371 if (gl_info
->supported
[ARB_MAP_BUFFER_ALIGNMENT
])
2373 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT
, &gl_max
);
2374 TRACE("Minimum buffer map alignment: %d.\n", gl_max
);
2378 WARN("Driver doesn't guarantee a minimum buffer map alignment.\n");
2380 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2382 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV
, &gl_max
);
2383 gl_info
->limits
.general_combiners
= gl_max
;
2384 TRACE("Max general combiners: %d.\n", gl_max
);
2386 if (gl_info
->supported
[ARB_DRAW_BUFFERS
] && wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2388 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &gl_max
);
2389 gl_info
->limits
.buffers
= gl_max
;
2390 TRACE("Max draw buffers: %u.\n", gl_max
);
2392 if (gl_info
->supported
[ARB_MULTITEXTURE
])
2394 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
2395 gl_info
->limits
.textures
= min(MAX_TEXTURES
, gl_max
);
2396 TRACE("Max textures: %d.\n", gl_info
->limits
.textures
);
2398 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2401 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB
, &gl_max
);
2402 gl_info
->limits
.texture_coords
= min(MAX_TEXTURES
, gl_max
);
2403 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2404 gl_info
->limits
.fragment_samplers
= min(MAX_FRAGMENT_SAMPLERS
, tmp
);
2408 gl_info
->limits
.texture_coords
= max(gl_info
->limits
.texture_coords
, gl_max
);
2409 gl_info
->limits
.fragment_samplers
= max(gl_info
->limits
.fragment_samplers
, gl_max
);
2411 TRACE("Max texture coords: %d.\n", gl_info
->limits
.texture_coords
);
2412 TRACE("Max fragment samplers: %d.\n", gl_info
->limits
.fragment_samplers
);
2414 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2417 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2418 gl_info
->limits
.vertex_samplers
= tmp
;
2419 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2420 gl_info
->limits
.combined_samplers
= tmp
;
2421 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &tmp
);
2422 gl_info
->limits
.vertex_attribs
= tmp
;
2424 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2425 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2426 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2427 * shader is used with fixed function vertex processing we're fine too because fixed function
2428 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2429 * used we have to make sure that all vertex sampler setups are valid together with all
2430 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2431 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2432 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2433 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2434 * a fixed function pipeline anymore.
2436 * So this is just a check to check that our assumption holds true. If not, write a warning
2437 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2438 if (gl_info
->limits
.vertex_samplers
&& gl_info
->limits
.combined_samplers
< 12
2439 && MAX_TEXTURES
+ gl_info
->limits
.vertex_samplers
> gl_info
->limits
.combined_samplers
)
2441 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2442 gl_info
->limits
.vertex_samplers
, gl_info
->limits
.combined_samplers
);
2443 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2444 if (gl_info
->limits
.combined_samplers
> MAX_TEXTURES
)
2445 gl_info
->limits
.vertex_samplers
= gl_info
->limits
.combined_samplers
- MAX_TEXTURES
;
2447 gl_info
->limits
.vertex_samplers
= 0;
2452 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
;
2454 TRACE("Max vertex samplers: %u.\n", gl_info
->limits
.vertex_samplers
);
2455 TRACE("Max combined samplers: %u.\n", gl_info
->limits
.combined_samplers
);
2457 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
2459 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
2460 gl_info
->limits
.blends
= gl_max
;
2461 TRACE("Max blends: %u.\n", gl_info
->limits
.blends
);
2463 if (gl_info
->supported
[EXT_TEXTURE3D
])
2465 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT
, &gl_max
);
2466 gl_info
->limits
.texture3d_size
= gl_max
;
2467 TRACE("Max texture3D size: %d.\n", gl_info
->limits
.texture3d_size
);
2469 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
2471 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
2472 gl_info
->limits
.anisotropy
= gl_max
;
2473 TRACE("Max anisotropy: %d.\n", gl_info
->limits
.anisotropy
);
2475 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2477 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2478 gl_info
->limits
.arb_ps_float_constants
= gl_max
;
2479 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_ps_float_constants
);
2480 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2481 gl_info
->limits
.arb_ps_native_constants
= gl_max
;
2482 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2483 gl_info
->limits
.arb_ps_native_constants
);
2484 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2485 gl_info
->limits
.arb_ps_temps
= gl_max
;
2486 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_ps_temps
);
2487 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2488 gl_info
->limits
.arb_ps_instructions
= gl_max
;
2489 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2490 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, &gl_max
));
2491 gl_info
->limits
.arb_ps_local_constants
= gl_max
;
2492 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2494 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
])
2496 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2497 gl_info
->limits
.arb_vs_float_constants
= gl_max
;
2498 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_vs_float_constants
);
2499 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2500 gl_info
->limits
.arb_vs_native_constants
= gl_max
;
2501 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2502 gl_info
->limits
.arb_vs_native_constants
);
2503 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2504 gl_info
->limits
.arb_vs_temps
= gl_max
;
2505 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_vs_temps
);
2506 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2507 gl_info
->limits
.arb_vs_instructions
= gl_max
;
2508 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_vs_instructions
);
2510 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2512 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2513 gl_info
->limits
.glsl_vs_float_constants
= gl_max
/ 4;
2514 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info
->limits
.glsl_vs_float_constants
);
2516 if (gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2518 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2519 gl_info
->limits
.glsl_ps_float_constants
= gl_max
/ 4;
2520 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info
->limits
.glsl_ps_float_constants
);
2521 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB
, &gl_max
);
2522 gl_info
->limits
.glsl_varyings
= gl_max
;
2523 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max
, gl_max
/ 4);
2526 if (gl_info
->supported
[NV_LIGHT_MAX_EXPONENT
])
2527 gl_info
->gl_ops
.gl
.p_glGetFloatv(GL_MAX_SHININESS_NV
, &gl_info
->limits
.shininess
);
2529 gl_info
->limits
.shininess
= 128.0f
;
2531 if ((gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
] || gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
2532 && wined3d_settings
.allow_multisampling
)
2534 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_SAMPLES
, &gl_max
);
2535 gl_info
->limits
.samples
= gl_max
;
2539 /* Context activation is done by the caller. */
2540 static BOOL
wined3d_adapter_init_gl_caps(struct wined3d_adapter
*adapter
)
2542 struct wined3d_driver_info
*driver_info
= &adapter
->driver_info
;
2543 const char *gl_vendor_str
, *gl_renderer_str
, *gl_version_str
;
2544 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2545 enum wined3d_pci_vendor card_vendor
;
2546 struct fragment_caps fragment_caps
;
2547 const char *WGL_Extensions
= NULL
;
2548 const char *GL_Extensions
= NULL
;
2549 enum wined3d_gl_vendor gl_vendor
;
2550 enum wined3d_pci_device device
;
2554 TRACE("adapter %p.\n", adapter
);
2558 gl_renderer_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_RENDERER
);
2559 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str
));
2560 if (!gl_renderer_str
)
2563 ERR("Received a NULL GL_RENDERER.\n");
2567 gl_vendor_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_VENDOR
);
2568 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str
));
2572 ERR("Received a NULL GL_VENDOR.\n");
2576 /* Parse the GL_VERSION field into major and minor information */
2577 gl_version_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_VERSION
);
2578 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str
));
2579 if (!gl_version_str
)
2582 ERR("Received a NULL GL_VERSION.\n");
2585 gl_version
= wined3d_parse_gl_version(gl_version_str
);
2587 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2588 GL_Extensions
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_EXTENSIONS
);
2592 ERR("Received a NULL GL_EXTENSIONS.\n");
2598 memset(gl_info
->supported
, 0, sizeof(gl_info
->supported
));
2599 gl_info
->supported
[WINED3D_GL_EXT_NONE
] = TRUE
;
2601 TRACE("GL extensions reported:\n");
2602 parse_extension_string(gl_info
, GL_Extensions
, gl_extension_map
,
2603 sizeof(gl_extension_map
) / sizeof(*gl_extension_map
));
2605 /* Now work out what GL support this card really has. */
2606 load_gl_funcs( gl_info
);
2608 hdc
= pwglGetCurrentDC();
2609 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
2610 if (GL_EXTCALL(wglGetExtensionsStringARB
))
2611 WGL_Extensions
= (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc
));
2612 if (!WGL_Extensions
)
2613 WARN("WGL extensions not supported.\n");
2615 parse_extension_string(gl_info
, WGL_Extensions
, wgl_extension_map
,
2616 sizeof(wgl_extension_map
) / sizeof(*wgl_extension_map
));
2618 if (!gl_info
->supported
[EXT_TEXTURE3D
] && gl_version
>= MAKEDWORD_VERSION(1, 2))
2620 TRACE("GL CORE: GL_EXT_texture3D support.\n");
2621 gl_info
->gl_ops
.ext
.p_glTexImage3DEXT
= (void *)gl_info
->gl_ops
.ext
.p_glTexImage3D
;
2622 gl_info
->gl_ops
.ext
.p_glTexSubImage3DEXT
= gl_info
->gl_ops
.ext
.p_glTexSubImage3D
;
2623 gl_info
->supported
[EXT_TEXTURE3D
] = TRUE
;
2626 if (!gl_info
->supported
[NV_POINT_SPRITE
] && gl_version
>= MAKEDWORD_VERSION(1, 4))
2628 TRACE("GL CORE: GL_NV_point_sprite support.\n");
2629 gl_info
->gl_ops
.ext
.p_glPointParameterivNV
= gl_info
->gl_ops
.ext
.p_glPointParameteriv
;
2630 gl_info
->gl_ops
.ext
.p_glPointParameteriNV
= gl_info
->gl_ops
.ext
.p_glPointParameteri
;
2631 gl_info
->supported
[NV_POINT_SPRITE
] = TRUE
;
2634 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] && gl_version
>= MAKEDWORD_VERSION(2, 0))
2636 TRACE("GL CORE: GL_ARB_texture_non_power_of_two support.\n");
2637 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = TRUE
;
2640 if (gl_version
>= MAKEDWORD_VERSION(2, 0)) gl_info
->supported
[WINED3D_GL_VERSION_2_0
] = TRUE
;
2642 if (gl_info
->supported
[APPLE_FENCE
])
2644 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2645 * The apple extension interacts with some other apple exts. Disable the NV
2646 * extension if the apple one is support to prevent confusion in other parts
2648 gl_info
->supported
[NV_FENCE
] = FALSE
;
2650 if (gl_info
->supported
[APPLE_FLOAT_PIXELS
])
2652 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2654 * The enums are the same:
2655 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
2656 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
2657 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2658 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2659 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
2661 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
])
2663 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
2664 gl_info
->supported
[ARB_TEXTURE_FLOAT
] = TRUE
;
2666 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
2668 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
2669 gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
] = TRUE
;
2672 if (gl_info
->supported
[ARB_MAP_BUFFER_RANGE
])
2674 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2675 * functionality. Prefer the ARB extension */
2676 gl_info
->supported
[APPLE_FLUSH_BUFFER_RANGE
] = FALSE
;
2678 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
2680 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2681 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
2683 if (!gl_info
->supported
[ARB_DEPTH_CLAMP
] && gl_info
->supported
[NV_DEPTH_CLAMP
])
2685 TRACE(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2686 gl_info
->supported
[ARB_DEPTH_CLAMP
] = TRUE
;
2688 if (!gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] && gl_info
->supported
[EXT_VERTEX_ARRAY_BGRA
])
2690 TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2691 gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] = TRUE
;
2693 if (!gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
])
2695 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
2696 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
2698 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2700 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2702 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2703 * are supported. The nv extensions provide the same functionality as the
2704 * ATI one, and a bit more(signed pixelformats). */
2705 gl_info
->supported
[ATI_FRAGMENT_SHADER
] = FALSE
;
2708 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
2710 /* If we have full NP2 texture support, disable
2711 * GL_ARB_texture_rectangle because we will never use it.
2712 * This saves a few redundant glDisable calls. */
2713 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = FALSE
;
2715 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
2717 /* Disable NV_register_combiners and fragment shader if this is supported.
2718 * generally the NV extensions are preferred over the ATI ones, and this
2719 * extension is disabled if register_combiners and texture_shader2 are both
2720 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2721 * fragment processing support. */
2722 gl_info
->supported
[NV_REGISTER_COMBINERS
] = FALSE
;
2723 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = FALSE
;
2724 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
2725 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
2727 if (gl_info
->supported
[NV_HALF_FLOAT
])
2729 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2730 gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
] = TRUE
;
2735 wined3d_adapter_init_limits(gl_info
);
2737 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] && test_arb_vs_offset_limit(gl_info
))
2738 gl_info
->quirks
|= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
;
2740 if (gl_info
->supported
[ARB_SHADING_LANGUAGE_100
])
2742 const char *str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB
);
2743 unsigned int major
, minor
;
2745 TRACE("GLSL version string: %s.\n", debugstr_a(str
));
2747 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2748 sscanf(str
, "%u.%u", &major
, &minor
);
2749 gl_info
->glsl_version
= MAKEDWORD_VERSION(major
, minor
);
2752 checkGLcall("extension detection");
2756 adapter
->fragment_pipe
= select_fragment_implementation(gl_info
);
2757 adapter
->shader_backend
= select_shader_backend(gl_info
);
2758 adapter
->blitter
= select_blit_implementation(gl_info
);
2760 adapter
->fragment_pipe
->get_caps(gl_info
, &fragment_caps
);
2761 gl_info
->limits
.texture_stages
= fragment_caps
.MaxTextureBlendStages
;
2762 TRACE("Max texture stages: %u.\n", gl_info
->limits
.texture_stages
);
2764 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
2766 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->gl_ops
.ext
.p_glIsRenderbuffer
;
2767 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->gl_ops
.ext
.p_glBindRenderbuffer
;
2768 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->gl_ops
.ext
.p_glDeleteRenderbuffers
;
2769 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->gl_ops
.ext
.p_glGenRenderbuffers
;
2770 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorage
;
2771 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorageMultisample
;
2772 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->gl_ops
.ext
.p_glGetRenderbufferParameteriv
;
2773 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->gl_ops
.ext
.p_glIsFramebuffer
;
2774 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->gl_ops
.ext
.p_glBindFramebuffer
;
2775 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->gl_ops
.ext
.p_glDeleteFramebuffers
;
2776 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->gl_ops
.ext
.p_glGenFramebuffers
;
2777 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->gl_ops
.ext
.p_glCheckFramebufferStatus
;
2778 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture1D
;
2779 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture2D
;
2780 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture3D
;
2781 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->gl_ops
.ext
.p_glFramebufferRenderbuffer
;
2782 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
2783 = gl_info
->gl_ops
.ext
.p_glGetFramebufferAttachmentParameteriv
;
2784 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->gl_ops
.ext
.p_glBlitFramebuffer
;
2785 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->gl_ops
.ext
.p_glGenerateMipmap
;
2789 if (gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
2791 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->gl_ops
.ext
.p_glIsRenderbufferEXT
;
2792 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->gl_ops
.ext
.p_glBindRenderbufferEXT
;
2793 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->gl_ops
.ext
.p_glDeleteRenderbuffersEXT
;
2794 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->gl_ops
.ext
.p_glGenRenderbuffersEXT
;
2795 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorageEXT
;
2796 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->gl_ops
.ext
.p_glGetRenderbufferParameterivEXT
;
2797 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->gl_ops
.ext
.p_glIsFramebufferEXT
;
2798 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->gl_ops
.ext
.p_glBindFramebufferEXT
;
2799 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->gl_ops
.ext
.p_glDeleteFramebuffersEXT
;
2800 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->gl_ops
.ext
.p_glGenFramebuffersEXT
;
2801 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->gl_ops
.ext
.p_glCheckFramebufferStatusEXT
;
2802 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture1DEXT
;
2803 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture2DEXT
;
2804 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture3DEXT
;
2805 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->gl_ops
.ext
.p_glFramebufferRenderbufferEXT
;
2806 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
2807 = gl_info
->gl_ops
.ext
.p_glGetFramebufferAttachmentParameterivEXT
;
2808 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->gl_ops
.ext
.p_glGenerateMipmapEXT
;
2810 else if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2812 WARN("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
2813 wined3d_settings
.offscreen_rendering_mode
= ORM_BACKBUFFER
;
2815 if (gl_info
->supported
[EXT_FRAMEBUFFER_BLIT
])
2817 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->gl_ops
.ext
.p_glBlitFramebufferEXT
;
2819 if (gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
2821 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
2822 = gl_info
->gl_ops
.ext
.p_glRenderbufferStorageMultisampleEXT
;
2826 gl_vendor
= wined3d_guess_gl_vendor(gl_info
, gl_vendor_str
, gl_renderer_str
);
2827 card_vendor
= wined3d_guess_card_vendor(gl_vendor_str
, gl_renderer_str
);
2828 TRACE("Found GL_VENDOR (%s)->(0x%04x/0x%04x).\n", debugstr_a(gl_vendor_str
), gl_vendor
, card_vendor
);
2830 device
= wined3d_guess_card(gl_info
, gl_renderer_str
, &gl_vendor
, &card_vendor
);
2831 TRACE("Found (fake) card: 0x%x (vendor id), 0x%x (device id).\n", card_vendor
, device
);
2833 gl_info
->wrap_lookup
[WINED3D_TADDRESS_WRAP
- WINED3D_TADDRESS_WRAP
] = GL_REPEAT
;
2834 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR
- WINED3D_TADDRESS_WRAP
] =
2835 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] ? GL_MIRRORED_REPEAT_ARB
: GL_REPEAT
;
2836 gl_info
->wrap_lookup
[WINED3D_TADDRESS_CLAMP
- WINED3D_TADDRESS_WRAP
] = GL_CLAMP_TO_EDGE
;
2837 gl_info
->wrap_lookup
[WINED3D_TADDRESS_BORDER
- WINED3D_TADDRESS_WRAP
] =
2838 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] ? GL_CLAMP_TO_BORDER_ARB
: GL_REPEAT
;
2839 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR_ONCE
- WINED3D_TADDRESS_WRAP
] =
2840 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] ? GL_MIRROR_CLAMP_TO_EDGE_ATI
: GL_REPEAT
;
2842 fixup_extensions(gl_info
, gl_renderer_str
, gl_vendor
, card_vendor
, device
);
2843 init_driver_info(driver_info
, card_vendor
, device
);
2844 add_gl_compat_wrappers(gl_info
);
2849 UINT CDECL
wined3d_get_adapter_count(const struct wined3d
*wined3d
)
2851 TRACE("wined3d %p, reporting %u adapters.\n",
2852 wined3d
, wined3d
->adapter_count
);
2854 return wined3d
->adapter_count
;
2857 HRESULT CDECL
wined3d_register_software_device(struct wined3d
*wined3d
, void *init_function
)
2859 FIXME("wined3d %p, init_function %p stub!\n", wined3d
, init_function
);
2864 HMONITOR CDECL
wined3d_get_adapter_monitor(const struct wined3d
*wined3d
, UINT adapter_idx
)
2866 TRACE("wined3d %p, adapter_idx %u.\n", wined3d
, adapter_idx
);
2868 if (adapter_idx
>= wined3d
->adapter_count
)
2871 return MonitorFromPoint(wined3d
->adapters
[adapter_idx
].monitorPoint
, MONITOR_DEFAULTTOPRIMARY
);
2874 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2875 of the same bpp but different resolutions */
2877 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2878 UINT CDECL
wined3d_get_adapter_mode_count(const struct wined3d
*wined3d
, UINT adapter_idx
,
2879 enum wined3d_format_id format_id
, enum wined3d_scanline_ordering scanline_ordering
)
2881 const struct wined3d_adapter
*adapter
;
2882 const struct wined3d_format
*format
;
2888 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
2889 wined3d
, adapter_idx
, debug_d3dformat(format_id
), scanline_ordering
);
2891 if (adapter_idx
>= wined3d
->adapter_count
)
2894 adapter
= &wined3d
->adapters
[adapter_idx
];
2895 format
= wined3d_get_format(&adapter
->gl_info
, format_id
);
2896 format_bits
= format
->byte_count
* CHAR_BIT
;
2898 memset(&mode
, 0, sizeof(mode
));
2899 mode
.dmSize
= sizeof(mode
);
2901 while (EnumDisplaySettingsExW(adapter
->DeviceName
, j
++, &mode
, 0))
2903 if (mode
.dmFields
& DM_DISPLAYFLAGS
)
2905 if (scanline_ordering
== WINED3D_SCANLINE_ORDERING_PROGRESSIVE
2906 && (mode
.u2
.dmDisplayFlags
& DM_INTERLACED
))
2909 if (scanline_ordering
== WINED3D_SCANLINE_ORDERING_INTERLACED
2910 && !(mode
.u2
.dmDisplayFlags
& DM_INTERLACED
))
2914 if (format_id
== WINED3DFMT_UNKNOWN
)
2916 /* This is for d3d8, do not enumerate P8 here. */
2917 if (mode
.dmBitsPerPel
== 32 || mode
.dmBitsPerPel
== 16) ++i
;
2919 else if (mode
.dmBitsPerPel
== format_bits
)
2925 TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i
, j
, adapter_idx
);
2930 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2931 HRESULT CDECL
wined3d_enum_adapter_modes(const struct wined3d
*wined3d
, UINT adapter_idx
,
2932 enum wined3d_format_id format_id
, enum wined3d_scanline_ordering scanline_ordering
,
2933 UINT mode_idx
, struct wined3d_display_mode
*mode
)
2935 const struct wined3d_adapter
*adapter
;
2936 const struct wined3d_format
*format
;
2942 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
2943 wined3d
, adapter_idx
, debug_d3dformat(format_id
), scanline_ordering
, mode_idx
, mode
);
2945 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
)
2946 return WINED3DERR_INVALIDCALL
;
2948 adapter
= &wined3d
->adapters
[adapter_idx
];
2949 format
= wined3d_get_format(&adapter
->gl_info
, format_id
);
2950 format_bits
= format
->byte_count
* CHAR_BIT
;
2952 memset(&m
, 0, sizeof(m
));
2953 m
.dmSize
= sizeof(m
);
2955 while (i
<= mode_idx
)
2957 if (!EnumDisplaySettingsExW(adapter
->DeviceName
, j
++, &m
, 0))
2959 WARN("Invalid mode_idx %u.\n", mode_idx
);
2960 return WINED3DERR_INVALIDCALL
;
2963 if (m
.dmFields
& DM_DISPLAYFLAGS
)
2965 if (scanline_ordering
== WINED3D_SCANLINE_ORDERING_PROGRESSIVE
2966 && (m
.u2
.dmDisplayFlags
& DM_INTERLACED
))
2969 if (scanline_ordering
== WINED3D_SCANLINE_ORDERING_INTERLACED
2970 && !(m
.u2
.dmDisplayFlags
& DM_INTERLACED
))
2974 if (format_id
== WINED3DFMT_UNKNOWN
)
2976 /* This is for d3d8, do not enumerate P8 here. */
2977 if (m
.dmBitsPerPel
== 32 || m
.dmBitsPerPel
== 16) ++i
;
2979 else if (m
.dmBitsPerPel
== format_bits
)
2985 mode
->width
= m
.dmPelsWidth
;
2986 mode
->height
= m
.dmPelsHeight
;
2987 mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
2988 if (m
.dmFields
& DM_DISPLAYFREQUENCY
)
2989 mode
->refresh_rate
= m
.dmDisplayFrequency
;
2991 if (format_id
== WINED3DFMT_UNKNOWN
)
2992 mode
->format_id
= pixelformat_for_depth(m
.dmBitsPerPel
);
2994 mode
->format_id
= format_id
;
2996 if (!(m
.dmFields
& DM_DISPLAYFLAGS
))
2997 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_UNKNOWN
;
2998 else if (m
.u2
.dmDisplayFlags
& DM_INTERLACED
)
2999 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_INTERLACED
;
3001 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_PROGRESSIVE
;
3003 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode
->width
, mode
->height
, mode
->refresh_rate
,
3004 m
.dmBitsPerPel
, debug_d3dformat(mode
->format_id
), mode
->scanline_ordering
);
3009 HRESULT CDECL
wined3d_get_adapter_display_mode(const struct wined3d
*wined3d
, UINT adapter_idx
,
3010 struct wined3d_display_mode
*mode
, enum wined3d_display_rotation
*rotation
)
3012 const struct wined3d_adapter
*adapter
;
3015 TRACE("wined3d %p, adapter_idx %u, display_mode %p, rotation %p.\n",
3016 wined3d
, adapter_idx
, mode
, rotation
);
3018 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
)
3019 return WINED3DERR_INVALIDCALL
;
3021 adapter
= &wined3d
->adapters
[adapter_idx
];
3023 memset(&m
, 0, sizeof(m
));
3024 m
.dmSize
= sizeof(m
);
3026 EnumDisplaySettingsExW(adapter
->DeviceName
, ENUM_CURRENT_SETTINGS
, &m
, 0);
3027 mode
->width
= m
.dmPelsWidth
;
3028 mode
->height
= m
.dmPelsHeight
;
3029 mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
3030 if (m
.dmFields
& DM_DISPLAYFREQUENCY
)
3031 mode
->refresh_rate
= m
.dmDisplayFrequency
;
3032 mode
->format_id
= pixelformat_for_depth(m
.dmBitsPerPel
);
3034 /* Lie about the format. X11 can't change the color depth, and some apps
3035 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
3036 * that GetDisplayMode still returns 24 bpp. This should probably be
3037 * handled in winex11 instead. */
3038 if (adapter
->screen_format
&& adapter
->screen_format
!= mode
->format_id
)
3040 WARN("Overriding format %s with stored format %s.\n",
3041 debug_d3dformat(mode
->format_id
),
3042 debug_d3dformat(adapter
->screen_format
));
3043 mode
->format_id
= adapter
->screen_format
;
3046 if (!(m
.dmFields
& DM_DISPLAYFLAGS
))
3047 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_UNKNOWN
;
3048 else if (m
.u2
.dmDisplayFlags
& DM_INTERLACED
)
3049 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_INTERLACED
;
3051 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_PROGRESSIVE
;
3055 switch (m
.u1
.s2
.dmDisplayOrientation
)
3058 *rotation
= WINED3D_DISPLAY_ROTATION_0
;
3061 *rotation
= WINED3D_DISPLAY_ROTATION_90
;
3064 *rotation
= WINED3D_DISPLAY_ROTATION_180
;
3067 *rotation
= WINED3D_DISPLAY_ROTATION_270
;
3070 FIXME("Unhandled display rotation %#x.\n", m
.u1
.s2
.dmDisplayOrientation
);
3071 *rotation
= WINED3D_DISPLAY_ROTATION_UNSPECIFIED
;
3076 TRACE("Returning %ux%u@%u %s %#x.\n", mode
->width
, mode
->height
,
3077 mode
->refresh_rate
, debug_d3dformat(mode
->format_id
),
3078 mode
->scanline_ordering
);
3082 HRESULT CDECL
wined3d_set_adapter_display_mode(struct wined3d
*wined3d
,
3083 UINT adapter_idx
, const struct wined3d_display_mode
*mode
)
3085 struct wined3d_display_mode current_mode
;
3086 const struct wined3d_format
*format
;
3087 struct wined3d_adapter
*adapter
;
3093 TRACE("wined3d %p, adapter_idx %u, mode %p (%ux%u@%u %s %#x).\n", wined3d
, adapter_idx
, mode
,
3094 mode
->width
, mode
->height
, mode
->refresh_rate
, debug_d3dformat(mode
->format_id
),
3095 mode
->scanline_ordering
);
3097 if (adapter_idx
>= wined3d
->adapter_count
)
3098 return WINED3DERR_INVALIDCALL
;
3100 adapter
= &wined3d
->adapters
[adapter_idx
];
3101 format
= wined3d_get_format(&adapter
->gl_info
, mode
->format_id
);
3103 memset(&devmode
, 0, sizeof(devmode
));
3104 devmode
.dmSize
= sizeof(devmode
);
3105 devmode
.dmFields
= DM_BITSPERPEL
| DM_PELSWIDTH
| DM_PELSHEIGHT
;
3106 devmode
.dmBitsPerPel
= format
->byte_count
* CHAR_BIT
;
3107 devmode
.dmPelsWidth
= mode
->width
;
3108 devmode
.dmPelsHeight
= mode
->height
;
3110 devmode
.dmDisplayFrequency
= mode
->refresh_rate
;
3111 if (mode
->refresh_rate
)
3112 devmode
.dmFields
|= DM_DISPLAYFREQUENCY
;
3114 if (mode
->scanline_ordering
!= WINED3D_SCANLINE_ORDERING_UNKNOWN
)
3116 devmode
.dmFields
|= DM_DISPLAYFLAGS
;
3117 if (mode
->scanline_ordering
== WINED3D_SCANLINE_ORDERING_INTERLACED
)
3118 devmode
.u2
.dmDisplayFlags
|= DM_INTERLACED
;
3121 /* Only change the mode if necessary. */
3122 if (FAILED(hr
= wined3d_get_adapter_display_mode(wined3d
, adapter_idx
, ¤t_mode
, NULL
)))
3124 ERR("Failed to get current display mode, hr %#x.\n", hr
);
3126 else if (current_mode
.width
== mode
->width
3127 && current_mode
.height
== mode
->height
3128 && current_mode
.format_id
== mode
->format_id
3129 && (current_mode
.refresh_rate
== mode
->refresh_rate
3130 || !mode
->refresh_rate
)
3131 && (current_mode
.scanline_ordering
== mode
->scanline_ordering
3132 || mode
->scanline_ordering
== WINED3D_SCANLINE_ORDERING_UNKNOWN
))
3134 TRACE("Skipping redundant mode setting call.\n");
3138 ret
= ChangeDisplaySettingsExW(adapter
->DeviceName
, &devmode
, NULL
, CDS_FULLSCREEN
, NULL
);
3139 if (ret
!= DISP_CHANGE_SUCCESSFUL
)
3141 if (devmode
.dmDisplayFrequency
)
3143 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
3144 devmode
.dmFields
&= ~DM_DISPLAYFREQUENCY
;
3145 devmode
.dmDisplayFrequency
= 0;
3146 ret
= ChangeDisplaySettingsExW(adapter
->DeviceName
, &devmode
, NULL
, CDS_FULLSCREEN
, NULL
);
3148 if (ret
!= DISP_CHANGE_SUCCESSFUL
)
3149 return WINED3DERR_NOTAVAILABLE
;
3152 /* Store the new values. */
3153 adapter
->screen_format
= mode
->format_id
;
3155 /* And finally clip mouse to our screen. */
3156 SetRect(&clip_rc
, 0, 0, mode
->width
, mode
->height
);
3157 ClipCursor(&clip_rc
);
3162 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
3163 and fields being inserted in the middle, a new structure is used in place */
3164 HRESULT CDECL
wined3d_get_adapter_identifier(const struct wined3d
*wined3d
,
3165 UINT adapter_idx
, DWORD flags
, struct wined3d_adapter_identifier
*identifier
)
3167 const struct wined3d_adapter
*adapter
;
3170 TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n",
3171 wined3d
, adapter_idx
, flags
, identifier
);
3173 if (adapter_idx
>= wined3d
->adapter_count
)
3174 return WINED3DERR_INVALIDCALL
;
3176 adapter
= &wined3d
->adapters
[adapter_idx
];
3178 if (identifier
->driver_size
)
3180 const char *name
= adapter
->driver_info
.name
;
3181 len
= min(strlen(name
), identifier
->driver_size
- 1);
3182 memcpy(identifier
->driver
, name
, len
);
3183 identifier
->driver
[len
] = '\0';
3186 if (identifier
->description_size
)
3188 const char *description
= adapter
->driver_info
.description
;
3189 len
= min(strlen(description
), identifier
->description_size
- 1);
3190 memcpy(identifier
->description
, description
, len
);
3191 identifier
->description
[len
] = '\0';
3194 /* Note that d3d8 doesn't supply a device name. */
3195 if (identifier
->device_name_size
)
3197 if (!WideCharToMultiByte(CP_ACP
, 0, adapter
->DeviceName
, -1, identifier
->device_name
,
3198 identifier
->device_name_size
, NULL
, NULL
))
3200 ERR("Failed to convert device name, last error %#x.\n", GetLastError());
3201 return WINED3DERR_INVALIDCALL
;
3205 identifier
->driver_version
.u
.HighPart
= adapter
->driver_info
.version_high
;
3206 identifier
->driver_version
.u
.LowPart
= adapter
->driver_info
.version_low
;
3207 identifier
->vendor_id
= adapter
->driver_info
.vendor
;
3208 identifier
->device_id
= adapter
->driver_info
.device
;
3209 identifier
->subsystem_id
= 0;
3210 identifier
->revision
= 0;
3211 memcpy(&identifier
->device_identifier
, &IID_D3DDEVICE_D3DUID
, sizeof(identifier
->device_identifier
));
3212 identifier
->whql_level
= (flags
& WINED3DENUM_NO_WHQL_LEVEL
) ? 0 : 1;
3213 memcpy(&identifier
->adapter_luid
, &adapter
->luid
, sizeof(identifier
->adapter_luid
));
3214 identifier
->video_memory
= adapter
->TextureRam
;
3219 HRESULT CDECL
wined3d_get_adapter_raster_status(const struct wined3d
*wined3d
, UINT adapter_idx
,
3220 struct wined3d_raster_status
*raster_status
)
3222 LONGLONG freq_per_frame
, freq_per_line
;
3223 LARGE_INTEGER counter
, freq_per_sec
;
3224 struct wined3d_display_mode mode
;
3228 FIXME("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
3229 wined3d
, adapter_idx
, raster_status
);
3231 WARN("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
3232 wined3d
, adapter_idx
, raster_status
);
3234 /* Obtaining the raster status is a widely implemented but optional
3235 * feature. When this method returns OK StarCraft 2 expects the
3236 * raster_status->InVBlank value to actually change over time.
3237 * And Endless Alice Crysis doesn't care even if this method fails.
3238 * Thus this method returns OK and fakes raster_status by
3239 * QueryPerformanceCounter. */
3241 if (!QueryPerformanceCounter(&counter
) || !QueryPerformanceFrequency(&freq_per_sec
))
3242 return WINED3DERR_INVALIDCALL
;
3243 if (FAILED(wined3d_get_adapter_display_mode(wined3d
, adapter_idx
, &mode
, NULL
)))
3244 return WINED3DERR_INVALIDCALL
;
3245 if (mode
.refresh_rate
== DEFAULT_REFRESH_RATE
)
3246 mode
.refresh_rate
= 60;
3248 freq_per_frame
= freq_per_sec
.QuadPart
/ mode
.refresh_rate
;
3249 /* Assume 20 scan lines in the vertical blank. */
3250 freq_per_line
= freq_per_frame
/ (mode
.height
+ 20);
3251 raster_status
->scan_line
= (counter
.QuadPart
% freq_per_frame
) / freq_per_line
;
3252 if (raster_status
->scan_line
< mode
.height
)
3253 raster_status
->in_vblank
= FALSE
;
3256 raster_status
->scan_line
= 0;
3257 raster_status
->in_vblank
= TRUE
;
3260 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
3261 raster_status
->in_vblank
, raster_status
->scan_line
);
3266 static BOOL
wined3d_check_pixel_format_color(const struct wined3d_gl_info
*gl_info
,
3267 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3269 BYTE redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
3271 /* Float formats need FBOs. If FBOs are used this function isn't called */
3272 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3274 if(cfg
->iPixelType
== WGL_TYPE_RGBA_ARB
) { /* Integer RGBA formats */
3275 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
3277 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3281 if(cfg
->redSize
< redSize
)
3284 if(cfg
->greenSize
< greenSize
)
3287 if(cfg
->blueSize
< blueSize
)
3290 if(cfg
->alphaSize
< alphaSize
)
3296 /* Probably a RGBA_float or color index mode */
3300 static BOOL
wined3d_check_pixel_format_depth(const struct wined3d_gl_info
*gl_info
,
3301 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3303 BYTE depthSize
, stencilSize
;
3304 BOOL lockable
= FALSE
;
3306 if (!getDepthStencilBits(format
, &depthSize
, &stencilSize
))
3308 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3312 /* Float formats need FBOs. If FBOs are used this function isn't called */
3313 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3315 if ((format
->id
== WINED3DFMT_D16_LOCKABLE
) || (format
->id
== WINED3DFMT_D32_FLOAT
))
3318 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
3319 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
3320 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
3321 if(!(cfg
->depthSize
== depthSize
|| (!lockable
&& cfg
->depthSize
> depthSize
)))
3324 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
3325 * allow more stencil bits than requested. */
3326 if(cfg
->stencilSize
< stencilSize
)
3332 HRESULT CDECL
wined3d_check_depth_stencil_match(const struct wined3d
*wined3d
,
3333 UINT adapter_idx
, enum wined3d_device_type device_type
, enum wined3d_format_id adapter_format_id
,
3334 enum wined3d_format_id render_target_format_id
, enum wined3d_format_id depth_stencil_format_id
)
3336 const struct wined3d_format
*rt_format
;
3337 const struct wined3d_format
*ds_format
;
3338 const struct wined3d_adapter
*adapter
;
3340 TRACE("wined3d %p, adapter_idx %u, device_type %s,\n"
3341 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
3342 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3343 debug_d3dformat(render_target_format_id
), debug_d3dformat(depth_stencil_format_id
));
3345 if (adapter_idx
>= wined3d
->adapter_count
)
3346 return WINED3DERR_INVALIDCALL
;
3348 adapter
= &wined3d
->adapters
[adapter_idx
];
3349 rt_format
= wined3d_get_format(&adapter
->gl_info
, render_target_format_id
);
3350 ds_format
= wined3d_get_format(&adapter
->gl_info
, depth_stencil_format_id
);
3351 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3353 if ((rt_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3354 && (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)))
3356 TRACE("Formats match.\n");
3362 const struct wined3d_pixel_format
*cfgs
;
3363 unsigned int cfg_count
;
3366 cfgs
= adapter
->cfgs
;
3367 cfg_count
= adapter
->cfg_count
;
3368 for (i
= 0; i
< cfg_count
; ++i
)
3370 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], rt_format
)
3371 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, &cfgs
[i
], ds_format
))
3373 TRACE("Formats match.\n");
3379 TRACE("Unsupported format pair: %s and %s.\n",
3380 debug_d3dformat(render_target_format_id
),
3381 debug_d3dformat(depth_stencil_format_id
));
3383 return WINED3DERR_NOTAVAILABLE
;
3386 HRESULT CDECL
wined3d_check_device_multisample_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
3387 enum wined3d_device_type device_type
, enum wined3d_format_id surface_format_id
, BOOL windowed
,
3388 enum wined3d_multisample_type multisample_type
, DWORD
*quality_levels
)
3390 const struct wined3d_gl_info
*gl_info
;
3392 TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
3393 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
3394 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(surface_format_id
),
3395 windowed
, multisample_type
, quality_levels
);
3397 if (adapter_idx
>= wined3d
->adapter_count
)
3398 return WINED3DERR_INVALIDCALL
;
3400 gl_info
= &wined3d
->adapters
[adapter_idx
].gl_info
;
3402 if (multisample_type
> gl_info
->limits
.samples
)
3404 TRACE("Returning not supported.\n");
3406 *quality_levels
= 0;
3408 return WINED3DERR_NOTAVAILABLE
;
3413 if (multisample_type
== WINED3D_MULTISAMPLE_NON_MASKABLE
)
3414 /* FIXME: This is probably wrong. */
3415 *quality_levels
= gl_info
->limits
.samples
;
3417 *quality_levels
= 1;
3423 /* Check if we support bumpmapping for a format */
3424 static BOOL
CheckBumpMapCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3426 /* Ask the fixed function pipeline implementation if it can deal
3427 * with the conversion. If we've got a GL extension giving native
3428 * support this will be an identity conversion. */
3429 return (format
->flags
& WINED3DFMT_FLAG_BUMPMAP
)
3430 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
);
3433 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
3434 static BOOL
CheckDepthStencilCapability(const struct wined3d_adapter
*adapter
,
3435 const struct wined3d_format
*display_format
, const struct wined3d_format
*ds_format
)
3437 /* Only allow depth/stencil formats */
3438 if (!(ds_format
->depth_size
|| ds_format
->stencil_size
)) return FALSE
;
3440 /* Blacklist formats not supported on Windows */
3441 switch (ds_format
->id
)
3443 case WINED3DFMT_S1_UINT_D15_UNORM
: /* Breaks the shadowvol2 dx7 sdk sample */
3444 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3445 TRACE("[FAILED] - not supported on windows.\n");
3452 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3454 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
3455 if (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)) return TRUE
;
3461 /* Walk through all WGL pixel formats to find a match */
3462 for (i
= 0; i
< adapter
->cfg_count
; ++i
)
3464 const struct wined3d_pixel_format
*cfg
= &adapter
->cfgs
[i
];
3465 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, cfg
, display_format
)
3466 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, cfg
, ds_format
))
3474 static BOOL
CheckFilterCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3476 /* The flags entry of a format contains the filtering capability */
3477 if ((format
->flags
& WINED3DFMT_FLAG_FILTERING
)
3478 || !(adapter
->gl_info
.quirks
& WINED3D_QUIRK_LIMITED_TEX_FILTERING
))
3484 /* Check the render target capabilities of a format */
3485 static BOOL
CheckRenderTargetCapability(const struct wined3d_adapter
*adapter
,
3486 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*check_format
)
3488 /* Filter out non-RT formats */
3489 if (!(check_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)) return FALSE
;
3490 if (wined3d_settings
.offscreen_rendering_mode
== ORM_BACKBUFFER
)
3492 BYTE AdapterRed
, AdapterGreen
, AdapterBlue
, AdapterAlpha
, AdapterTotalSize
;
3493 BYTE CheckRed
, CheckGreen
, CheckBlue
, CheckAlpha
, CheckTotalSize
;
3494 const struct wined3d_pixel_format
*cfgs
= adapter
->cfgs
;
3497 getColorBits(adapter_format
, &AdapterRed
, &AdapterGreen
, &AdapterBlue
, &AdapterAlpha
, &AdapterTotalSize
);
3498 getColorBits(check_format
, &CheckRed
, &CheckGreen
, &CheckBlue
, &CheckAlpha
, &CheckTotalSize
);
3500 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
3501 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
3502 if (!((AdapterRed
== CheckRed
) && (AdapterGreen
== CheckGreen
) && (AdapterBlue
== CheckBlue
)))
3504 TRACE("[FAILED]\n");
3508 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
3509 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
3510 for (i
= 0; i
< adapter
->cfg_count
; ++i
)
3512 if (cfgs
[i
].windowDrawable
3513 && wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], check_format
))
3515 TRACE("Pixel format %d is compatible with format %s.\n",
3516 cfgs
[i
].iPixelFormat
, debug_d3dformat(check_format
->id
));
3521 else if(wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3523 /* For now return TRUE for FBOs until we have some proper checks.
3524 * Note that this function will only be called when the format is around for texturing. */
3530 static BOOL
CheckSrgbReadCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3532 return format
->flags
& WINED3DFMT_FLAG_SRGB_READ
;
3535 static BOOL
CheckSrgbWriteCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3537 /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
3538 * doing the color fixup in shaders.
3539 * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
3540 if (format
->flags
& WINED3DFMT_FLAG_SRGB_WRITE
)
3542 int vs_selected_mode
;
3543 int ps_selected_mode
;
3544 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
3546 if ((ps_selected_mode
== SHADER_ARB
) || (ps_selected_mode
== SHADER_GLSL
))
3553 TRACE("[FAILED] - sRGB writes not supported by format %s.\n", debug_d3dformat(format
->id
));
3557 /* Check if a format support blending in combination with pixel shaders */
3558 static BOOL
CheckPostPixelShaderBlendingCapability(const struct wined3d_adapter
*adapter
,
3559 const struct wined3d_format
*format
)
3561 /* The flags entry of a format contains the post pixel shader blending capability */
3562 if (format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
) return TRUE
;
3567 static BOOL
CheckWrapAndMipCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3569 /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
3570 * but we have to report mipmapping so we cannot reject this flag. Tests show that
3571 * windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to show
3572 * that wrapping is supported. The lack of filtering will sort out the mipmapping
3573 * capability anyway.
3575 * For now lets report this on all formats, but in the future we may want to
3576 * restrict it to some should games need that
3581 /* Check if a texture format is supported on the given adapter */
3582 static BOOL
CheckTextureCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3584 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3589 * supported: RGB(A) formats
3591 case WINED3DFMT_B8G8R8_UNORM
:
3592 TRACE("[FAILED] - Not enumerated on Windows.\n");
3594 case WINED3DFMT_B8G8R8A8_UNORM
:
3595 case WINED3DFMT_B8G8R8X8_UNORM
:
3596 case WINED3DFMT_B5G6R5_UNORM
:
3597 case WINED3DFMT_B5G5R5X1_UNORM
:
3598 case WINED3DFMT_B5G5R5A1_UNORM
:
3599 case WINED3DFMT_B4G4R4A4_UNORM
:
3600 case WINED3DFMT_A8_UNORM
:
3601 case WINED3DFMT_B4G4R4X4_UNORM
:
3602 case WINED3DFMT_R8G8B8A8_UNORM
:
3603 case WINED3DFMT_R8G8B8X8_UNORM
:
3604 case WINED3DFMT_B10G10R10A2_UNORM
:
3605 case WINED3DFMT_R10G10B10A2_UNORM
:
3606 case WINED3DFMT_R16G16_UNORM
:
3610 case WINED3DFMT_B2G3R3_UNORM
:
3611 TRACE("[FAILED] - Not supported on Windows.\n");
3615 * Not supported: Palettized
3616 * Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of <=Direct3D7.
3617 * Since it is not widely available, don't offer it. Further no Windows driver offers
3618 * WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
3620 case WINED3DFMT_P8_UINT
:
3621 case WINED3DFMT_P8_UINT_A8_UNORM
:
3625 * Supported: (Alpha)-Luminance
3627 case WINED3DFMT_L8_UNORM
:
3628 case WINED3DFMT_L8A8_UNORM
:
3629 case WINED3DFMT_L16_UNORM
:
3633 /* Not supported on Windows, thus disabled */
3634 case WINED3DFMT_L4A4_UNORM
:
3635 TRACE("[FAILED] - not supported on windows\n");
3639 * Supported: Depth/Stencil formats
3641 case WINED3DFMT_D16_LOCKABLE
:
3642 case WINED3DFMT_D16_UNORM
:
3643 case WINED3DFMT_X8D24_UNORM
:
3644 case WINED3DFMT_D24_UNORM_S8_UINT
:
3645 case WINED3DFMT_S8_UINT_D24_FLOAT
:
3646 case WINED3DFMT_D32_UNORM
:
3647 case WINED3DFMT_D32_FLOAT
:
3650 case WINED3DFMT_INTZ
:
3651 if (gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
]
3652 || gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3656 /* Not supported on Windows */
3657 case WINED3DFMT_S1_UINT_D15_UNORM
:
3658 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3659 TRACE("[FAILED] - not supported on windows\n");
3663 * Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
3664 * GL_NV_texture_shader). Emulated by shaders
3666 case WINED3DFMT_R8G8_SNORM
:
3667 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
3668 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
3669 case WINED3DFMT_R8G8B8A8_SNORM
:
3670 case WINED3DFMT_R16G16_SNORM
:
3671 /* Ask the shader backend if it can deal with the conversion. If
3672 * we've got a GL extension giving native support this will be an
3673 * identity conversion. */
3674 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
))
3679 TRACE("[FAILED]\n");
3682 case WINED3DFMT_DXT1
:
3683 case WINED3DFMT_DXT2
:
3684 case WINED3DFMT_DXT3
:
3685 case WINED3DFMT_DXT4
:
3686 case WINED3DFMT_DXT5
:
3687 if (gl_info
->supported
[EXT_TEXTURE_COMPRESSION_S3TC
])
3692 TRACE("[FAILED]\n");
3697 * Odd formats - not supported
3699 case WINED3DFMT_VERTEXDATA
:
3700 case WINED3DFMT_R16_UINT
:
3701 case WINED3DFMT_R32_UINT
:
3702 case WINED3DFMT_R16G16B16A16_SNORM
:
3703 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM
:
3704 case WINED3DFMT_R10G11B11_SNORM
:
3705 case WINED3DFMT_R16
:
3706 case WINED3DFMT_AL16
:
3707 TRACE("[FAILED]\n"); /* Enable when implemented */
3711 * WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
3713 case WINED3DFMT_R8G8_SNORM_Cx
:
3714 TRACE("[FAILED]\n"); /* Enable when implemented */
3718 case WINED3DFMT_UYVY
:
3719 case WINED3DFMT_YUY2
:
3720 if (gl_info
->supported
[APPLE_YCBCR_422
])
3725 TRACE("[FAILED]\n");
3727 case WINED3DFMT_YV12
:
3728 TRACE("[FAILED]\n");
3731 case WINED3DFMT_R16G16B16A16_UNORM
:
3732 if (gl_info
->quirks
& WINED3D_QUIRK_BROKEN_RGBA16
)
3734 TRACE("[FAILED]\n");
3741 case WINED3DFMT_B2G3R3A8_UNORM
:
3742 TRACE("[FAILED]\n"); /* Enable when implemented */
3745 /* Floating point formats */
3746 case WINED3DFMT_R16_FLOAT
:
3747 case WINED3DFMT_R16G16_FLOAT
:
3748 case WINED3DFMT_R16G16B16A16_FLOAT
:
3749 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
] && gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
3754 TRACE("[FAILED]\n");
3757 case WINED3DFMT_R32_FLOAT
:
3758 case WINED3DFMT_R32G32_FLOAT
:
3759 case WINED3DFMT_R32G32B32A32_FLOAT
:
3760 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
])
3765 TRACE("[FAILED]\n");
3768 /* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
3769 * instancing. To query if the card supports instancing CheckDeviceFormat with the special format
3770 * MAKEFOURCC('I','N','S','T') is used. Should a (broken) app check for this provide a proper return value.
3771 * We can do instancing with all shader versions, but we need vertex shaders.
3773 * Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC('I','N','S','T') once
3774 * to enable instancing. WineD3D doesn't need that and just ignores it.
3776 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows.
3778 case WINED3DFMT_INST
:
3779 TRACE("ATI Instancing check hack\n");
3780 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_VERTEX_SHADER
])
3785 TRACE("[FAILED]\n");
3788 /* Some weird FOURCC formats */
3789 case WINED3DFMT_R8G8_B8G8
:
3790 case WINED3DFMT_G8R8_G8B8
:
3791 case WINED3DFMT_MULTI2_ARGB8
:
3792 TRACE("[FAILED]\n");
3795 /* Vendor specific formats */
3796 case WINED3DFMT_ATI2N
:
3797 if (gl_info
->supported
[ATI_TEXTURE_COMPRESSION_3DC
]
3798 || gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
])
3800 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
)
3801 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
))
3810 TRACE("[FAILED]\n");
3813 /* Depth bound test. To query if the card supports it CheckDeviceFormat with the special
3814 * format MAKEFOURCC('N','V','D','B') is used.
3815 * It is enabled by setting D3DRS_ADAPTIVETESS_X render state to MAKEFOURCC('N','V','D','B') and
3816 * then controlled by setting D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax)
3819 case WINED3DFMT_NVDB
:
3820 if (gl_info
->supported
[EXT_DEPTH_BOUNDS_TEST
])
3825 TRACE("[FAILED]\n");
3828 case WINED3DFMT_NVHU
:
3829 case WINED3DFMT_NVHS
:
3830 /* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
3831 * is said to be GL_UNSIGNED_HILO16, NVHS GL_SIGNED_HILO16. Rumours say that d3d computes
3832 * a 3rd channel similarly to D3DFMT_CxV8U8(So NVHS could be called D3DFMT_CxV16U16).
3833 * ATI refused to support formats which can easily be emulated with pixel shaders, so
3834 * Applications have to deal with not having NVHS and NVHU.
3836 TRACE("[FAILED]\n");
3839 case WINED3DFMT_NULL
:
3840 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3844 case WINED3DFMT_UNKNOWN
:
3848 ERR("Unhandled format %s.\n", debug_d3dformat(format
->id
));
3854 static BOOL
CheckSurfaceCapability(const struct wined3d_adapter
*adapter
,
3855 const struct wined3d_format
*adapter_format
,
3856 const struct wined3d_format
*check_format
,
3857 enum wined3d_surface_type surface_type
)
3859 if (surface_type
== WINED3D_SURFACE_TYPE_GDI
)
3861 switch (check_format
->id
)
3863 case WINED3DFMT_B8G8R8_UNORM
:
3864 TRACE("[FAILED] - Not enumerated on Windows.\n");
3866 case WINED3DFMT_B8G8R8A8_UNORM
:
3867 case WINED3DFMT_B8G8R8X8_UNORM
:
3868 case WINED3DFMT_B5G6R5_UNORM
:
3869 case WINED3DFMT_B5G5R5X1_UNORM
:
3870 case WINED3DFMT_B5G5R5A1_UNORM
:
3871 case WINED3DFMT_B4G4R4A4_UNORM
:
3872 case WINED3DFMT_B2G3R3_UNORM
:
3873 case WINED3DFMT_A8_UNORM
:
3874 case WINED3DFMT_B2G3R3A8_UNORM
:
3875 case WINED3DFMT_B4G4R4X4_UNORM
:
3876 case WINED3DFMT_R10G10B10A2_UNORM
:
3877 case WINED3DFMT_R8G8B8A8_UNORM
:
3878 case WINED3DFMT_R8G8B8X8_UNORM
:
3879 case WINED3DFMT_R16G16_UNORM
:
3880 case WINED3DFMT_B10G10R10A2_UNORM
:
3881 case WINED3DFMT_R16G16B16A16_UNORM
:
3882 case WINED3DFMT_P8_UINT
:
3886 TRACE("[FAILED] - Not available on GDI surfaces.\n");
3891 /* All format that are supported for textures are supported for surfaces as well */
3892 if (CheckTextureCapability(adapter
, check_format
)) return TRUE
;
3893 /* All depth stencil formats are supported on surfaces */
3894 if (CheckDepthStencilCapability(adapter
, adapter_format
, check_format
)) return TRUE
;
3896 /* If opengl can't process the format natively, the blitter may be able to convert it */
3897 if (adapter
->blitter
->blit_supported(&adapter
->gl_info
, WINED3D_BLIT_OP_COLOR_BLIT
,
3898 NULL
, WINED3D_POOL_DEFAULT
, 0, check_format
,
3899 NULL
, WINED3D_POOL_DEFAULT
, 0, adapter_format
))
3905 /* Reject other formats */
3906 TRACE("[FAILED]\n");
3910 static BOOL
CheckVertexTextureCapability(const struct wined3d_adapter
*adapter
,
3911 const struct wined3d_format
*format
)
3913 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3915 if (!gl_info
->limits
.vertex_samplers
|| !(format
->flags
& WINED3DFMT_FLAG_VTF
))
3920 case WINED3DFMT_R32G32B32A32_FLOAT
:
3921 case WINED3DFMT_R32_FLOAT
:
3924 return !(gl_info
->quirks
& WINED3D_QUIRK_LIMITED_TEX_FILTERING
);
3928 HRESULT CDECL
wined3d_check_device_format(const struct wined3d
*wined3d
, UINT adapter_idx
,
3929 enum wined3d_device_type device_type
, enum wined3d_format_id adapter_format_id
, DWORD usage
,
3930 enum wined3d_resource_type resource_type
, enum wined3d_format_id check_format_id
,
3931 enum wined3d_surface_type surface_type
)
3933 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
3934 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3935 const struct wined3d_format
*adapter_format
= wined3d_get_format(gl_info
, adapter_format_id
);
3936 const struct wined3d_format
*format
= wined3d_get_format(gl_info
, check_format_id
);
3937 DWORD usage_caps
= 0;
3939 TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
3940 "resource_type %s, check_format %s, surface_type %#x.\n",
3941 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3942 debug_d3dusage(usage
), debug_d3dusagequery(usage
), debug_d3dresourcetype(resource_type
),
3943 debug_d3dformat(check_format_id
), surface_type
);
3945 if (adapter_idx
>= wined3d
->adapter_count
)
3946 return WINED3DERR_INVALIDCALL
;
3948 switch (resource_type
)
3950 case WINED3D_RTYPE_CUBE_TEXTURE
:
3951 /* Cubetexture allows:
3952 * - WINED3DUSAGE_AUTOGENMIPMAP
3953 * - WINED3DUSAGE_DEPTHSTENCIL
3954 * - WINED3DUSAGE_DYNAMIC
3955 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3956 * - WINED3DUSAGE_RENDERTARGET
3957 * - WINED3DUSAGE_SOFTWAREPROCESSING
3958 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3960 if (surface_type
!= WINED3D_SURFACE_TYPE_OPENGL
)
3962 TRACE("[FAILED]\n");
3963 return WINED3DERR_NOTAVAILABLE
;
3966 if (!gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3968 TRACE("[FAILED] - No cube texture support.\n");
3969 return WINED3DERR_NOTAVAILABLE
;
3972 if (!CheckTextureCapability(adapter
, format
))
3974 TRACE("[FAILED] - Cube texture format not supported.\n");
3975 return WINED3DERR_NOTAVAILABLE
;
3978 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3980 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3981 /* When autogenmipmap isn't around continue and return
3982 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3983 TRACE("[FAILED] - No autogenmipmap support, but continuing.\n");
3985 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3988 /* Always report dynamic locking. */
3989 if (usage
& WINED3DUSAGE_DYNAMIC
)
3990 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3992 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3994 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3996 TRACE("[FAILED] - No render target support.\n");
3997 return WINED3DERR_NOTAVAILABLE
;
3999 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
4002 /* Always report software processing. */
4003 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
4004 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
4006 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
4008 if (!CheckFilterCapability(adapter
, format
))
4010 TRACE("[FAILED] - No filter support.\n");
4011 return WINED3DERR_NOTAVAILABLE
;
4013 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
4016 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4018 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4020 TRACE("[FAILED] - No post pixelshader blending support.\n");
4021 return WINED3DERR_NOTAVAILABLE
;
4023 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4026 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4028 if (!CheckSrgbReadCapability(adapter
, format
))
4030 TRACE("[FAILED] - No sRGB read support.\n");
4031 return WINED3DERR_NOTAVAILABLE
;
4033 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4036 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4038 if (!CheckSrgbWriteCapability(adapter
, format
))
4040 TRACE("[FAILED] - No sRGB write support.\n");
4041 return WINED3DERR_NOTAVAILABLE
;
4043 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4046 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4048 if (!CheckVertexTextureCapability(adapter
, format
))
4050 TRACE("[FAILED] - No vertex texture support.\n");
4051 return WINED3DERR_NOTAVAILABLE
;
4053 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4056 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4058 if (!CheckWrapAndMipCapability(adapter
, format
))
4060 TRACE("[FAILED] - No wrapping and mipmapping support.\n");
4061 return WINED3DERR_NOTAVAILABLE
;
4063 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4067 case WINED3D_RTYPE_SURFACE
:
4069 * - WINED3DUSAGE_DEPTHSTENCIL
4070 * - WINED3DUSAGE_NONSECURE (d3d9ex)
4071 * - WINED3DUSAGE_RENDERTARGET
4073 if (!CheckSurfaceCapability(adapter
, adapter_format
, format
, surface_type
))
4075 TRACE("[FAILED] - Not supported for plain surfaces.\n");
4076 return WINED3DERR_NOTAVAILABLE
;
4079 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
4081 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
4083 TRACE("[FAILED] - No depth/stencil support.\n");
4084 return WINED3DERR_NOTAVAILABLE
;
4086 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
4089 if (usage
& WINED3DUSAGE_RENDERTARGET
)
4091 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
4093 TRACE("[FAILED] - No render target support.\n");
4094 return WINED3DERR_NOTAVAILABLE
;
4096 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
4099 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4101 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4103 TRACE("[FAILED] - No post pixelshader blending support.\n");
4104 return WINED3DERR_NOTAVAILABLE
;
4106 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4110 case WINED3D_RTYPE_TEXTURE
:
4112 * - WINED3DUSAGE_AUTOGENMIPMAP
4113 * - WINED3DUSAGE_DEPTHSTENCIL
4114 * - WINED3DUSAGE_DMAP
4115 * - WINED3DUSAGE_DYNAMIC
4116 * - WINED3DUSAGE_NONSECURE (d3d9ex)
4117 * - WINED3DUSAGE_RENDERTARGET
4118 * - WINED3DUSAGE_SOFTWAREPROCESSING
4119 * - WINED3DUSAGE_TEXTAPI (d3d9ex)
4120 * - WINED3DUSAGE_QUERY_WRAPANDMIP
4122 if (surface_type
!= WINED3D_SURFACE_TYPE_OPENGL
)
4124 TRACE("[FAILED]\n");
4125 return WINED3DERR_NOTAVAILABLE
;
4128 if (!CheckTextureCapability(adapter
, format
))
4130 TRACE("[FAILED] - Texture format not supported.\n");
4131 return WINED3DERR_NOTAVAILABLE
;
4134 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
4136 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
4137 /* When autogenmipmap isn't around continue and return
4138 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
4139 TRACE("[FAILED] - No autogenmipmap support, but continuing.\n");
4141 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
4144 /* Always report dynamic locking. */
4145 if (usage
& WINED3DUSAGE_DYNAMIC
)
4146 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
4148 if (usage
& WINED3DUSAGE_RENDERTARGET
)
4150 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
4152 TRACE("[FAILED] - No render target support.\n");
4153 return WINED3DERR_NOTAVAILABLE
;
4155 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
4158 /* Always report software processing. */
4159 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
4160 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
4162 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
4164 if (!CheckFilterCapability(adapter
, format
))
4166 TRACE("[FAILED] - No filter support.\n");
4167 return WINED3DERR_NOTAVAILABLE
;
4169 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
4172 if (usage
& WINED3DUSAGE_QUERY_LEGACYBUMPMAP
)
4174 if (!CheckBumpMapCapability(adapter
, format
))
4176 TRACE("[FAILED] - No legacy bumpmap support.\n");
4177 return WINED3DERR_NOTAVAILABLE
;
4179 usage_caps
|= WINED3DUSAGE_QUERY_LEGACYBUMPMAP
;
4182 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4184 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4186 TRACE("[FAILED] - No post pixelshader blending support.\n");
4187 return WINED3DERR_NOTAVAILABLE
;
4189 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4192 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4194 if (!CheckSrgbReadCapability(adapter
, format
))
4196 TRACE("[FAILED] - No sRGB read support.\n");
4197 return WINED3DERR_NOTAVAILABLE
;
4199 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4202 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4204 if (!CheckSrgbWriteCapability(adapter
, format
))
4206 TRACE("[FAILED] - No sRGB write support.\n");
4207 return WINED3DERR_NOTAVAILABLE
;
4209 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4212 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4214 if (!CheckVertexTextureCapability(adapter
, format
))
4216 TRACE("[FAILED] - No vertex texture support.\n");
4217 return WINED3DERR_NOTAVAILABLE
;
4219 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4222 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4224 if (!CheckWrapAndMipCapability(adapter
, format
))
4226 TRACE("[FAILED] - No wrapping and mipmapping support.\n");
4227 return WINED3DERR_NOTAVAILABLE
;
4229 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4232 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
4234 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
4236 TRACE("[FAILED] - No depth/stencil support.\n");
4237 return WINED3DERR_NOTAVAILABLE
;
4239 if ((format
->flags
& WINED3DFMT_FLAG_SHADOW
) && !gl_info
->supported
[ARB_SHADOW
])
4241 TRACE("[FAILED] - No shadow sampler support.\n");
4242 return WINED3DERR_NOTAVAILABLE
;
4244 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
4248 case WINED3D_RTYPE_VOLUME_TEXTURE
:
4249 case WINED3D_RTYPE_VOLUME
:
4250 /* Volume is to VolumeTexture what Surface is to Texture, but its
4251 * usage caps are not documented. Most driver seem to offer
4252 * (nearly) the same on Volume and VolumeTexture, so do that too.
4254 * Volumetexture allows:
4255 * - D3DUSAGE_DYNAMIC
4256 * - D3DUSAGE_NONSECURE (d3d9ex)
4257 * - D3DUSAGE_SOFTWAREPROCESSING
4258 * - D3DUSAGE_QUERY_WRAPANDMIP
4260 if (surface_type
!= WINED3D_SURFACE_TYPE_OPENGL
)
4262 TRACE("[FAILED]\n");
4263 return WINED3DERR_NOTAVAILABLE
;
4266 if (!gl_info
->supported
[EXT_TEXTURE3D
])
4268 TRACE("[FAILED] - No volume texture support.\n");
4269 return WINED3DERR_NOTAVAILABLE
;
4272 if (!CheckTextureCapability(adapter
, format
))
4274 TRACE("[FAILED] - Format not supported.\n");
4275 return WINED3DERR_NOTAVAILABLE
;
4278 /* Filter formats that need conversion; For one part, this
4279 * conversion is unimplemented, and volume textures are huge, so
4280 * it would be a big performance hit. Unless we hit an application
4281 * needing one of those formats, don't advertize them to avoid
4282 * leading applications into temptation. The windows drivers don't
4283 * support most of those formats on volumes anyway, except for
4284 * WINED3DFMT_R32_FLOAT. */
4285 switch (check_format_id
)
4287 case WINED3DFMT_P8_UINT
:
4288 case WINED3DFMT_L4A4_UNORM
:
4289 case WINED3DFMT_R32_FLOAT
:
4290 case WINED3DFMT_R16_FLOAT
:
4291 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
4292 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
4293 case WINED3DFMT_R16G16_UNORM
:
4294 TRACE("[FAILED] - No converted formats on volumes.\n");
4295 return WINED3DERR_NOTAVAILABLE
;
4297 case WINED3DFMT_R8G8B8A8_SNORM
:
4298 case WINED3DFMT_R16G16_SNORM
:
4299 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4301 TRACE("[FAILED] - No converted formats on volumes.\n");
4302 return WINED3DERR_NOTAVAILABLE
;
4306 case WINED3DFMT_R8G8_SNORM
:
4307 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4309 TRACE("[FAILED] - No converted formats on volumes.\n");
4310 return WINED3DERR_NOTAVAILABLE
;
4314 case WINED3DFMT_DXT1
:
4315 case WINED3DFMT_DXT2
:
4316 case WINED3DFMT_DXT3
:
4317 case WINED3DFMT_DXT4
:
4318 case WINED3DFMT_DXT5
:
4319 /* The GL_EXT_texture_compression_s3tc spec requires that
4320 * loading an s3tc compressed texture results in an error.
4321 * While the D3D refrast does support s3tc volumes, at
4322 * least the nvidia windows driver does not, so we're free
4323 * not to support this format. */
4324 TRACE("[FAILED] - DXTn does not support 3D textures.\n");
4325 return WINED3DERR_NOTAVAILABLE
;
4328 /* Do nothing, continue with checking the format below */
4332 /* Always report dynamic locking. */
4333 if (usage
& WINED3DUSAGE_DYNAMIC
)
4334 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
4336 /* Always report software processing. */
4337 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
4338 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
4340 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
4342 if (!CheckFilterCapability(adapter
, format
))
4344 TRACE("[FAILED] - No filter support.\n");
4345 return WINED3DERR_NOTAVAILABLE
;
4347 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
4350 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4352 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4354 TRACE("[FAILED] - No post pixelshader blending support.\n");
4355 return WINED3DERR_NOTAVAILABLE
;
4357 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4360 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4362 if (!CheckSrgbReadCapability(adapter
, format
))
4364 TRACE("[FAILED] - No sRGB read support.\n");
4365 return WINED3DERR_NOTAVAILABLE
;
4367 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4370 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4372 if (!CheckSrgbWriteCapability(adapter
, format
))
4374 TRACE("[FAILED] - No sRGB write support.\n");
4375 return WINED3DERR_NOTAVAILABLE
;
4377 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4380 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4382 if (!CheckVertexTextureCapability(adapter
, format
))
4384 TRACE("[FAILED] - No vertex texture support.\n");
4385 return WINED3DERR_NOTAVAILABLE
;
4387 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4390 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4392 if (!CheckWrapAndMipCapability(adapter
, format
))
4394 TRACE("[FAILED] - No wrapping and mipmapping support.\n");
4395 return WINED3DERR_NOTAVAILABLE
;
4397 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4402 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type
));
4403 return WINED3DERR_NOTAVAILABLE
;
4406 /* When the usage_caps exactly matches usage return WINED3D_OK except for
4407 * the situation in which WINED3DUSAGE_AUTOGENMIPMAP isn't around, then
4408 * WINED3DOK_NOAUTOGEN is returned if all the other usage flags match. */
4409 if (usage_caps
== usage
)
4411 if (usage_caps
== (usage
& ~WINED3DUSAGE_AUTOGENMIPMAP
))
4412 return WINED3DOK_NOAUTOGEN
;
4414 TRACE("[FAILED] - Usage %#x requested for format %s and resource_type %s but only %#x is available.\n",
4415 usage
, debug_d3dformat(check_format_id
), debug_d3dresourcetype(resource_type
), usage_caps
);
4417 return WINED3DERR_NOTAVAILABLE
;
4420 HRESULT CDECL
wined3d_check_device_format_conversion(const struct wined3d
*wined3d
, UINT adapter_idx
,
4421 enum wined3d_device_type device_type
, enum wined3d_format_id src_format
, enum wined3d_format_id dst_format
)
4423 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
4424 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(src_format
),
4425 debug_d3dformat(dst_format
));
4430 HRESULT CDECL
wined3d_check_device_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
4431 enum wined3d_device_type device_type
, enum wined3d_format_id display_format
,
4432 enum wined3d_format_id backbuffer_format
, BOOL windowed
)
4437 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
4438 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(display_format
),
4439 debug_d3dformat(backbuffer_format
), windowed
);
4441 if (adapter_idx
>= wined3d
->adapter_count
)
4442 return WINED3DERR_INVALIDCALL
;
4444 /* The task of this function is to check whether a certain display / backbuffer format
4445 * combination is available on the given adapter. In fullscreen mode microsoft specified
4446 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
4447 * and display format should match exactly.
4448 * In windowed mode format conversion can occur and this depends on the driver. When format
4449 * conversion is done, this function should nevertheless fail and applications need to use
4450 * CheckDeviceFormatConversion.
4451 * At the moment we assume that fullscreen and windowed have the same capabilities. */
4453 /* There are only 4 display formats. */
4454 if (!(display_format
== WINED3DFMT_B5G6R5_UNORM
4455 || display_format
== WINED3DFMT_B5G5R5X1_UNORM
4456 || display_format
== WINED3DFMT_B8G8R8X8_UNORM
4457 || display_format
== WINED3DFMT_B10G10R10A2_UNORM
))
4459 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format
));
4460 return WINED3DERR_NOTAVAILABLE
;
4463 /* If the requested display format is not available, don't continue. */
4464 mode_count
= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
,
4465 display_format
, WINED3D_SCANLINE_ORDERING_UNKNOWN
);
4468 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format
));
4469 return WINED3DERR_NOTAVAILABLE
;
4472 /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format,
4473 * it means 'reuse' the display format for the backbuffer. */
4474 if (!windowed
&& backbuffer_format
== WINED3DFMT_UNKNOWN
)
4476 TRACE("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n");
4477 return WINED3DERR_NOTAVAILABLE
;
4480 /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with
4481 * backbuffer format WINED3DFMT_B5G6R5_UNORM. */
4482 if (display_format
== WINED3DFMT_B5G6R5_UNORM
&& backbuffer_format
!= WINED3DFMT_B5G6R5_UNORM
)
4484 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4485 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4486 return WINED3DERR_NOTAVAILABLE
;
4489 /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with
4490 * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and
4491 * WINED3DFMT_B5G5R5A1_UNORM. */
4492 if (display_format
== WINED3DFMT_B5G5R5X1_UNORM
4493 && !(backbuffer_format
== WINED3DFMT_B5G5R5X1_UNORM
|| backbuffer_format
== WINED3DFMT_B5G5R5A1_UNORM
))
4495 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4496 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4497 return WINED3DERR_NOTAVAILABLE
;
4500 /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with
4501 * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and
4502 * WINED3DFMT_B8G8R8A8_UNORM. */
4503 if (display_format
== WINED3DFMT_B8G8R8X8_UNORM
4504 && !(backbuffer_format
== WINED3DFMT_B8G8R8X8_UNORM
|| backbuffer_format
== WINED3DFMT_B8G8R8A8_UNORM
))
4506 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4507 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4508 return WINED3DERR_NOTAVAILABLE
;
4511 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it
4512 * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */
4513 if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
4514 && (backbuffer_format
!= WINED3DFMT_B10G10R10A2_UNORM
|| windowed
))
4516 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4517 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4518 return WINED3DERR_NOTAVAILABLE
;
4521 /* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
4522 hr
= wined3d_check_device_format(wined3d
, adapter_idx
, device_type
, display_format
,
4523 WINED3DUSAGE_RENDERTARGET
, WINED3D_RTYPE_SURFACE
, backbuffer_format
, WINED3D_SURFACE_TYPE_OPENGL
);
4525 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4526 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4531 HRESULT CDECL
wined3d_get_device_caps(const struct wined3d
*wined3d
, UINT adapter_idx
,
4532 enum wined3d_device_type device_type
, WINED3DCAPS
*caps
)
4534 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
4535 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4536 int vs_selected_mode
;
4537 int ps_selected_mode
;
4538 struct shader_caps shader_caps
;
4539 struct fragment_caps fragment_caps
;
4540 DWORD ckey_caps
, blit_caps
, fx_caps
, pal_caps
;
4542 TRACE("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
4543 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), caps
);
4545 if (adapter_idx
>= wined3d
->adapter_count
)
4546 return WINED3DERR_INVALIDCALL
;
4548 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
4550 /* ------------------------------------------------
4551 The following fields apply to both d3d8 and d3d9
4552 ------------------------------------------------ */
4553 /* Not quite true, but use h/w supported by opengl I suppose */
4554 caps
->DeviceType
= (device_type
== WINED3D_DEVICE_TYPE_HAL
) ? WINED3D_DEVICE_TYPE_HAL
: WINED3D_DEVICE_TYPE_REF
;
4555 caps
->AdapterOrdinal
= adapter_idx
;
4558 caps
->Caps2
= WINED3DCAPS2_CANRENDERWINDOWED
|
4559 WINED3DCAPS2_FULLSCREENGAMMA
|
4560 WINED3DCAPS2_DYNAMICTEXTURES
;
4561 if (gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
4562 caps
->Caps2
|= WINED3DCAPS2_CANAUTOGENMIPMAP
;
4564 caps
->Caps3
= WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
4565 WINED3DCAPS3_COPY_TO_VIDMEM
|
4566 WINED3DCAPS3_COPY_TO_SYSTEMMEM
;
4568 caps
->PresentationIntervals
= WINED3DPRESENT_INTERVAL_IMMEDIATE
|
4569 WINED3DPRESENT_INTERVAL_ONE
;
4571 caps
->CursorCaps
= WINED3DCURSORCAPS_COLOR
|
4572 WINED3DCURSORCAPS_LOWRES
;
4574 caps
->DevCaps
= WINED3DDEVCAPS_FLOATTLVERTEX
|
4575 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY
|
4576 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
4577 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY
|
4578 WINED3DDEVCAPS_DRAWPRIMTLVERTEX
|
4579 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT
|
4580 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY
|
4581 WINED3DDEVCAPS_PUREDEVICE
|
4582 WINED3DDEVCAPS_HWRASTERIZATION
|
4583 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY
|
4584 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY
|
4585 WINED3DDEVCAPS_CANRENDERAFTERFLIP
|
4586 WINED3DDEVCAPS_DRAWPRIMITIVES2
|
4587 WINED3DDEVCAPS_DRAWPRIMITIVES2EX
|
4588 WINED3DDEVCAPS_RTPATCHES
;
4590 caps
->PrimitiveMiscCaps
= WINED3DPMISCCAPS_CULLNONE
|
4591 WINED3DPMISCCAPS_CULLCCW
|
4592 WINED3DPMISCCAPS_CULLCW
|
4593 WINED3DPMISCCAPS_COLORWRITEENABLE
|
4594 WINED3DPMISCCAPS_CLIPTLVERTS
|
4595 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
4596 WINED3DPMISCCAPS_MASKZ
|
4597 WINED3DPMISCCAPS_BLENDOP
|
4598 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
;
4600 WINED3DPMISCCAPS_NULLREFERENCE
4601 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
4602 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
4603 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
4605 if (gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
] && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
4606 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_SEPARATEALPHABLEND
;
4607 if (gl_info
->supported
[EXT_DRAW_BUFFERS2
])
4608 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
;
4610 caps
->RasterCaps
= WINED3DPRASTERCAPS_DITHER
|
4611 WINED3DPRASTERCAPS_PAT
|
4612 WINED3DPRASTERCAPS_WFOG
|
4613 WINED3DPRASTERCAPS_ZFOG
|
4614 WINED3DPRASTERCAPS_FOGVERTEX
|
4615 WINED3DPRASTERCAPS_FOGTABLE
|
4616 WINED3DPRASTERCAPS_STIPPLE
|
4617 WINED3DPRASTERCAPS_SUBPIXEL
|
4618 WINED3DPRASTERCAPS_ZTEST
|
4619 WINED3DPRASTERCAPS_SCISSORTEST
|
4620 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
4621 WINED3DPRASTERCAPS_DEPTHBIAS
;
4623 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4625 caps
->RasterCaps
|= WINED3DPRASTERCAPS_ANISOTROPY
|
4626 WINED3DPRASTERCAPS_ZBIAS
|
4627 WINED3DPRASTERCAPS_MIPMAPLODBIAS
;
4629 if (gl_info
->supported
[NV_FOG_DISTANCE
])
4631 caps
->RasterCaps
|= WINED3DPRASTERCAPS_FOGRANGE
;
4634 WINED3DPRASTERCAPS_COLORPERSPECTIVE
4635 WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
4636 WINED3DPRASTERCAPS_ANTIALIASEDGES
4637 WINED3DPRASTERCAPS_ZBUFFERLESSHSR
4638 WINED3DPRASTERCAPS_WBUFFER */
4640 caps
->ZCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4641 WINED3DPCMPCAPS_EQUAL
|
4642 WINED3DPCMPCAPS_GREATER
|
4643 WINED3DPCMPCAPS_GREATEREQUAL
|
4644 WINED3DPCMPCAPS_LESS
|
4645 WINED3DPCMPCAPS_LESSEQUAL
|
4646 WINED3DPCMPCAPS_NEVER
|
4647 WINED3DPCMPCAPS_NOTEQUAL
;
4649 caps
->SrcBlendCaps
= WINED3DPBLENDCAPS_BOTHINVSRCALPHA
|
4650 WINED3DPBLENDCAPS_BOTHSRCALPHA
|
4651 WINED3DPBLENDCAPS_DESTALPHA
|
4652 WINED3DPBLENDCAPS_DESTCOLOR
|
4653 WINED3DPBLENDCAPS_INVDESTALPHA
|
4654 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4655 WINED3DPBLENDCAPS_INVSRCALPHA
|
4656 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4657 WINED3DPBLENDCAPS_ONE
|
4658 WINED3DPBLENDCAPS_SRCALPHA
|
4659 WINED3DPBLENDCAPS_SRCALPHASAT
|
4660 WINED3DPBLENDCAPS_SRCCOLOR
|
4661 WINED3DPBLENDCAPS_ZERO
;
4663 caps
->DestBlendCaps
= WINED3DPBLENDCAPS_DESTALPHA
|
4664 WINED3DPBLENDCAPS_DESTCOLOR
|
4665 WINED3DPBLENDCAPS_INVDESTALPHA
|
4666 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4667 WINED3DPBLENDCAPS_INVSRCALPHA
|
4668 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4669 WINED3DPBLENDCAPS_ONE
|
4670 WINED3DPBLENDCAPS_SRCALPHA
|
4671 WINED3DPBLENDCAPS_SRCCOLOR
|
4672 WINED3DPBLENDCAPS_ZERO
;
4673 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
4674 * according to the glBlendFunc manpage
4676 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
4677 * legacy settings for srcblend only
4680 if (gl_info
->supported
[EXT_BLEND_COLOR
])
4682 caps
->SrcBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4683 caps
->DestBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4687 caps
->AlphaCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4688 WINED3DPCMPCAPS_EQUAL
|
4689 WINED3DPCMPCAPS_GREATER
|
4690 WINED3DPCMPCAPS_GREATEREQUAL
|
4691 WINED3DPCMPCAPS_LESS
|
4692 WINED3DPCMPCAPS_LESSEQUAL
|
4693 WINED3DPCMPCAPS_NEVER
|
4694 WINED3DPCMPCAPS_NOTEQUAL
;
4696 caps
->ShadeCaps
= WINED3DPSHADECAPS_SPECULARGOURAUDRGB
|
4697 WINED3DPSHADECAPS_COLORGOURAUDRGB
|
4698 WINED3DPSHADECAPS_ALPHAFLATBLEND
|
4699 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND
|
4700 WINED3DPSHADECAPS_COLORFLATRGB
|
4701 WINED3DPSHADECAPS_FOGFLAT
|
4702 WINED3DPSHADECAPS_FOGGOURAUD
|
4703 WINED3DPSHADECAPS_SPECULARFLATRGB
;
4705 caps
->TextureCaps
= WINED3DPTEXTURECAPS_ALPHA
|
4706 WINED3DPTEXTURECAPS_ALPHAPALETTE
|
4707 WINED3DPTEXTURECAPS_TRANSPARENCY
|
4708 WINED3DPTEXTURECAPS_BORDER
|
4709 WINED3DPTEXTURECAPS_MIPMAP
|
4710 WINED3DPTEXTURECAPS_PROJECTED
|
4711 WINED3DPTEXTURECAPS_PERSPECTIVE
;
4713 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4715 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_POW2
|
4716 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL
;
4719 if (gl_info
->supported
[EXT_TEXTURE3D
])
4721 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP
|
4722 WINED3DPTEXTURECAPS_MIPVOLUMEMAP
;
4723 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4725 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2
;
4729 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4731 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP
|
4732 WINED3DPTEXTURECAPS_MIPCUBEMAP
;
4733 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4735 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP_POW2
;
4739 caps
->TextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4740 WINED3DPTFILTERCAPS_MAGFPOINT
|
4741 WINED3DPTFILTERCAPS_MINFLINEAR
|
4742 WINED3DPTFILTERCAPS_MINFPOINT
|
4743 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4744 WINED3DPTFILTERCAPS_MIPFPOINT
|
4745 WINED3DPTFILTERCAPS_LINEAR
|
4746 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4747 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4748 WINED3DPTFILTERCAPS_MIPLINEAR
|
4749 WINED3DPTFILTERCAPS_MIPNEAREST
|
4750 WINED3DPTFILTERCAPS_NEAREST
;
4752 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4754 caps
->TextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4755 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4758 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4760 caps
->CubeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4761 WINED3DPTFILTERCAPS_MAGFPOINT
|
4762 WINED3DPTFILTERCAPS_MINFLINEAR
|
4763 WINED3DPTFILTERCAPS_MINFPOINT
|
4764 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4765 WINED3DPTFILTERCAPS_MIPFPOINT
|
4766 WINED3DPTFILTERCAPS_LINEAR
|
4767 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4768 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4769 WINED3DPTFILTERCAPS_MIPLINEAR
|
4770 WINED3DPTFILTERCAPS_MIPNEAREST
|
4771 WINED3DPTFILTERCAPS_NEAREST
;
4773 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4775 caps
->CubeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4776 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4781 caps
->CubeTextureFilterCaps
= 0;
4784 if (gl_info
->supported
[EXT_TEXTURE3D
])
4786 caps
->VolumeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4787 WINED3DPTFILTERCAPS_MAGFPOINT
|
4788 WINED3DPTFILTERCAPS_MINFLINEAR
|
4789 WINED3DPTFILTERCAPS_MINFPOINT
|
4790 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4791 WINED3DPTFILTERCAPS_MIPFPOINT
|
4792 WINED3DPTFILTERCAPS_LINEAR
|
4793 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4794 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4795 WINED3DPTFILTERCAPS_MIPLINEAR
|
4796 WINED3DPTFILTERCAPS_MIPNEAREST
|
4797 WINED3DPTFILTERCAPS_NEAREST
;
4801 caps
->VolumeTextureFilterCaps
= 0;
4804 caps
->TextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4805 WINED3DPTADDRESSCAPS_CLAMP
|
4806 WINED3DPTADDRESSCAPS_WRAP
;
4808 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4810 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4812 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4814 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4816 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4818 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4821 if (gl_info
->supported
[EXT_TEXTURE3D
])
4823 caps
->VolumeTextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4824 WINED3DPTADDRESSCAPS_CLAMP
|
4825 WINED3DPTADDRESSCAPS_WRAP
;
4826 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4828 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4830 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4832 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4834 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4836 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4841 caps
->VolumeTextureAddressCaps
= 0;
4844 caps
->LineCaps
= WINED3DLINECAPS_TEXTURE
|
4845 WINED3DLINECAPS_ZTEST
|
4846 WINED3DLINECAPS_BLEND
|
4847 WINED3DLINECAPS_ALPHACMP
|
4848 WINED3DLINECAPS_FOG
;
4849 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
4850 * idea how generating the smoothing alpha values works; the result is different
4853 caps
->MaxTextureWidth
= gl_info
->limits
.texture_size
;
4854 caps
->MaxTextureHeight
= gl_info
->limits
.texture_size
;
4856 if (gl_info
->supported
[EXT_TEXTURE3D
])
4857 caps
->MaxVolumeExtent
= gl_info
->limits
.texture3d_size
;
4859 caps
->MaxVolumeExtent
= 0;
4861 caps
->MaxTextureRepeat
= 32768;
4862 caps
->MaxTextureAspectRatio
= gl_info
->limits
.texture_size
;
4863 caps
->MaxVertexW
= 1.0f
;
4865 caps
->GuardBandLeft
= 0.0f
;
4866 caps
->GuardBandTop
= 0.0f
;
4867 caps
->GuardBandRight
= 0.0f
;
4868 caps
->GuardBandBottom
= 0.0f
;
4870 caps
->ExtentsAdjust
= 0.0f
;
4872 caps
->StencilCaps
= WINED3DSTENCILCAPS_DECRSAT
|
4873 WINED3DSTENCILCAPS_INCRSAT
|
4874 WINED3DSTENCILCAPS_INVERT
|
4875 WINED3DSTENCILCAPS_KEEP
|
4876 WINED3DSTENCILCAPS_REPLACE
|
4877 WINED3DSTENCILCAPS_ZERO
;
4878 if (gl_info
->supported
[EXT_STENCIL_WRAP
])
4880 caps
->StencilCaps
|= WINED3DSTENCILCAPS_DECR
|
4881 WINED3DSTENCILCAPS_INCR
;
4883 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
] || gl_info
->supported
[ATI_SEPARATE_STENCIL
])
4885 caps
->StencilCaps
|= WINED3DSTENCILCAPS_TWOSIDED
;
4888 caps
->FVFCaps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
4890 caps
->MaxUserClipPlanes
= gl_info
->limits
.clipplanes
;
4891 caps
->MaxActiveLights
= gl_info
->limits
.lights
;
4893 caps
->MaxVertexBlendMatrices
= gl_info
->limits
.blends
;
4894 caps
->MaxVertexBlendMatrixIndex
= 0;
4896 caps
->MaxAnisotropy
= gl_info
->limits
.anisotropy
;
4897 caps
->MaxPointSize
= gl_info
->limits
.pointsize_max
;
4900 /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
4901 caps
->VertexProcessingCaps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
|
4902 WINED3DVTXPCAPS_MATERIALSOURCE7
|
4903 WINED3DVTXPCAPS_POSITIONALLIGHTS
|
4904 WINED3DVTXPCAPS_LOCALVIEWER
|
4905 WINED3DVTXPCAPS_VERTEXFOG
|
4906 WINED3DVTXPCAPS_TEXGEN
;
4908 caps
->MaxPrimitiveCount
= 0xfffff; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4909 caps
->MaxVertexIndex
= 0xfffff;
4910 caps
->MaxStreams
= MAX_STREAMS
;
4911 caps
->MaxStreamStride
= 1024;
4913 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4914 caps
->DevCaps2
= WINED3DDEVCAPS2_STREAMOFFSET
|
4915 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
;
4916 caps
->MaxNpatchTessellationLevel
= 0;
4917 caps
->MasterAdapterOrdinal
= 0;
4918 caps
->AdapterOrdinalInGroup
= 0;
4919 caps
->NumberOfAdaptersInGroup
= 1;
4921 caps
->NumSimultaneousRTs
= gl_info
->limits
.buffers
;
4923 caps
->StretchRectFilterCaps
= WINED3DPTFILTERCAPS_MINFPOINT
|
4924 WINED3DPTFILTERCAPS_MAGFPOINT
|
4925 WINED3DPTFILTERCAPS_MINFLINEAR
|
4926 WINED3DPTFILTERCAPS_MAGFLINEAR
;
4927 caps
->VertexTextureFilterCaps
= 0;
4929 adapter
->shader_backend
->shader_get_caps(&adapter
->gl_info
, &shader_caps
);
4930 adapter
->fragment_pipe
->get_caps(&adapter
->gl_info
, &fragment_caps
);
4932 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4933 caps
->PrimitiveMiscCaps
|= fragment_caps
.PrimitiveMiscCaps
;
4935 /* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
4936 * Ignore shader model capabilities if disabled in config
4938 if (vs_selected_mode
== SHADER_NONE
)
4940 TRACE("Vertex shader disabled in config, reporting version 0.0.\n");
4941 caps
->VertexShaderVersion
= 0;
4942 caps
->MaxVertexShaderConst
= 0;
4946 caps
->VertexShaderVersion
= shader_caps
.VertexShaderVersion
;
4947 caps
->MaxVertexShaderConst
= shader_caps
.MaxVertexShaderConst
;
4950 if (ps_selected_mode
== SHADER_NONE
)
4952 TRACE("Pixel shader disabled in config, reporting version 0.0.\n");
4953 caps
->PixelShaderVersion
= 0;
4954 caps
->PixelShader1xMaxValue
= 0.0f
;
4956 caps
->PixelShaderVersion
= shader_caps
.PixelShaderVersion
;
4957 caps
->PixelShader1xMaxValue
= shader_caps
.PixelShader1xMaxValue
;
4960 caps
->TextureOpCaps
= fragment_caps
.TextureOpCaps
;
4961 caps
->MaxTextureBlendStages
= fragment_caps
.MaxTextureBlendStages
;
4962 caps
->MaxSimultaneousTextures
= fragment_caps
.MaxSimultaneousTextures
;
4964 /* The following caps are shader specific, but they are things we cannot detect, or which
4965 * are the same among all shader models. So to avoid code duplication set the shader version
4966 * specific, but otherwise constant caps here
4968 if (caps
->VertexShaderVersion
>= 3)
4970 /* Where possible set the caps based on OpenGL extensions and if they
4971 * aren't set (in case of software rendering) use the VS 3.0 from
4972 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4974 caps
->VS20Caps
.caps
= WINED3DVS20CAPS_PREDICATION
;
4975 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4976 caps
->VS20Caps
.dynamic_flow_control_depth
= WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4977 caps
->VS20Caps
.temp_count
= max(32, adapter
->gl_info
.limits
.arb_vs_temps
);
4978 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
4979 caps
->VS20Caps
.static_flow_control_depth
= WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
4981 caps
->MaxVShaderInstructionsExecuted
= 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
4982 caps
->MaxVertexShader30InstructionSlots
= max(512, adapter
->gl_info
.limits
.arb_vs_instructions
);
4984 else if (caps
->VertexShaderVersion
== 2)
4986 caps
->VS20Caps
.caps
= 0;
4987 caps
->VS20Caps
.dynamic_flow_control_depth
= WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
;
4988 caps
->VS20Caps
.temp_count
= max(12, adapter
->gl_info
.limits
.arb_vs_temps
);
4989 caps
->VS20Caps
.static_flow_control_depth
= 1;
4991 caps
->MaxVShaderInstructionsExecuted
= 65535;
4992 caps
->MaxVertexShader30InstructionSlots
= 0;
4996 caps
->VS20Caps
.caps
= 0;
4997 caps
->VS20Caps
.dynamic_flow_control_depth
= 0;
4998 caps
->VS20Caps
.temp_count
= 0;
4999 caps
->VS20Caps
.static_flow_control_depth
= 0;
5001 caps
->MaxVShaderInstructionsExecuted
= 0;
5002 caps
->MaxVertexShader30InstructionSlots
= 0;
5005 if (caps
->PixelShaderVersion
>= 3)
5007 /* Where possible set the caps based on OpenGL extensions and if they
5008 * aren't set (in case of software rendering) use the PS 3.0 from
5009 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
5012 /* Caps is more or less undocumented on MSDN but it appears to be
5013 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
5014 * cards from Windows */
5015 caps
->PS20Caps
.caps
= WINED3DPS20CAPS_ARBITRARYSWIZZLE
|
5016 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS
|
5017 WINED3DPS20CAPS_PREDICATION
|
5018 WINED3DPS20CAPS_NODEPENDENTREADLIMIT
|
5019 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
5020 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
5021 caps
->PS20Caps
.dynamic_flow_control_depth
= WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
5022 caps
->PS20Caps
.temp_count
= max(32, adapter
->gl_info
.limits
.arb_ps_temps
);
5023 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
5024 caps
->PS20Caps
.static_flow_control_depth
= WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
5025 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
5026 caps
->PS20Caps
.instruction_slot_count
= WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
5028 caps
->MaxPShaderInstructionsExecuted
= 65535;
5029 caps
->MaxPixelShader30InstructionSlots
= max(WINED3DMIN30SHADERINSTRUCTIONS
,
5030 adapter
->gl_info
.limits
.arb_ps_instructions
);
5032 else if(caps
->PixelShaderVersion
== 2)
5034 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
5035 caps
->PS20Caps
.caps
= 0;
5036 caps
->PS20Caps
.dynamic_flow_control_depth
= 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
5037 caps
->PS20Caps
.temp_count
= max(12, adapter
->gl_info
.limits
.arb_ps_temps
);
5038 caps
->PS20Caps
.static_flow_control_depth
= WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH
; /* Minimum: 1 */
5039 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
5040 caps
->PS20Caps
.instruction_slot_count
= WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS
;
5042 caps
->MaxPShaderInstructionsExecuted
= 512; /* Minimum value, a GeforceFX uses 1024 */
5043 caps
->MaxPixelShader30InstructionSlots
= 0;
5047 caps
->PS20Caps
.caps
= 0;
5048 caps
->PS20Caps
.dynamic_flow_control_depth
= 0;
5049 caps
->PS20Caps
.temp_count
= 0;
5050 caps
->PS20Caps
.static_flow_control_depth
= 0;
5051 caps
->PS20Caps
.instruction_slot_count
= 0;
5053 caps
->MaxPShaderInstructionsExecuted
= 0;
5054 caps
->MaxPixelShader30InstructionSlots
= 0;
5057 if (caps
->VertexShaderVersion
>= 2)
5059 /* OpenGL supports all the formats below, perhaps not always
5060 * without conversion, but it supports them.
5061 * Further GLSL doesn't seem to have an official unsigned type so
5062 * don't advertise it yet as I'm not sure how we handle it.
5063 * We might need to add some clamping in the shader engine to
5065 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
5066 caps
->DeclTypes
= WINED3DDTCAPS_UBYTE4
|
5067 WINED3DDTCAPS_UBYTE4N
|
5068 WINED3DDTCAPS_SHORT2N
|
5069 WINED3DDTCAPS_SHORT4N
;
5070 if (gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
])
5072 caps
->DeclTypes
|= WINED3DDTCAPS_FLOAT16_2
|
5073 WINED3DDTCAPS_FLOAT16_4
;
5078 caps
->DeclTypes
= 0;
5081 /* Set DirectDraw helper Caps */
5082 ckey_caps
= WINEDDCKEYCAPS_DESTBLT
|
5083 WINEDDCKEYCAPS_SRCBLT
;
5084 fx_caps
= WINEDDFXCAPS_BLTALPHA
|
5085 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT
|
5086 WINEDDFXCAPS_BLTMIRRORUPDOWN
|
5087 WINEDDFXCAPS_BLTROTATION90
|
5088 WINEDDFXCAPS_BLTSHRINKX
|
5089 WINEDDFXCAPS_BLTSHRINKXN
|
5090 WINEDDFXCAPS_BLTSHRINKY
|
5091 WINEDDFXCAPS_BLTSHRINKXN
|
5092 WINEDDFXCAPS_BLTSTRETCHX
|
5093 WINEDDFXCAPS_BLTSTRETCHXN
|
5094 WINEDDFXCAPS_BLTSTRETCHY
|
5095 WINEDDFXCAPS_BLTSTRETCHYN
;
5096 blit_caps
= WINEDDCAPS_BLT
|
5097 WINEDDCAPS_BLTCOLORFILL
|
5098 WINEDDCAPS_BLTDEPTHFILL
|
5099 WINEDDCAPS_BLTSTRETCH
|
5100 WINEDDCAPS_CANBLTSYSMEM
|
5101 WINEDDCAPS_CANCLIP
|
5102 WINEDDCAPS_CANCLIPSTRETCHED
|
5103 WINEDDCAPS_COLORKEY
|
5104 WINEDDCAPS_COLORKEYHWASSIST
|
5105 WINEDDCAPS_ALIGNBOUNDARYSRC
;
5106 pal_caps
= WINEDDPCAPS_8BIT
|
5107 WINEDDPCAPS_PRIMARYSURFACE
;
5109 /* Fill the ddraw caps structure */
5110 caps
->ddraw_caps
.caps
= WINEDDCAPS_GDI
|
5111 WINEDDCAPS_PALETTE
|
5113 caps
->ddraw_caps
.caps2
= WINEDDCAPS2_CERTIFIED
|
5114 WINEDDCAPS2_NOPAGELOCKREQUIRED
|
5115 WINEDDCAPS2_PRIMARYGAMMA
|
5116 WINEDDCAPS2_WIDESURFACES
|
5117 WINEDDCAPS2_CANRENDERWINDOWED
;
5118 caps
->ddraw_caps
.color_key_caps
= ckey_caps
;
5119 caps
->ddraw_caps
.fx_caps
= fx_caps
;
5120 caps
->ddraw_caps
.pal_caps
= pal_caps
;
5121 caps
->ddraw_caps
.svb_caps
= blit_caps
;
5122 caps
->ddraw_caps
.svb_color_key_caps
= ckey_caps
;
5123 caps
->ddraw_caps
.svb_fx_caps
= fx_caps
;
5124 caps
->ddraw_caps
.vsb_caps
= blit_caps
;
5125 caps
->ddraw_caps
.vsb_color_key_caps
= ckey_caps
;
5126 caps
->ddraw_caps
.vsb_fx_caps
= fx_caps
;
5127 caps
->ddraw_caps
.ssb_caps
= blit_caps
;
5128 caps
->ddraw_caps
.ssb_color_key_caps
= ckey_caps
;
5129 caps
->ddraw_caps
.ssb_fx_caps
= fx_caps
;
5131 caps
->ddraw_caps
.dds_caps
= WINEDDSCAPS_ALPHA
|
5132 WINEDDSCAPS_BACKBUFFER
|
5134 WINEDDSCAPS_FRONTBUFFER
|
5135 WINEDDSCAPS_OFFSCREENPLAIN
|
5136 WINEDDSCAPS_PALETTE
|
5137 WINEDDSCAPS_PRIMARYSURFACE
|
5138 WINEDDSCAPS_SYSTEMMEMORY
|
5139 WINEDDSCAPS_VIDEOMEMORY
|
5140 WINEDDSCAPS_VISIBLE
;
5141 caps
->ddraw_caps
.stride_align
= DDRAW_PITCH_ALIGNMENT
;
5143 /* Set D3D caps if OpenGL is available. */
5144 if (adapter
->opengl
)
5146 caps
->ddraw_caps
.dds_caps
|= WINEDDSCAPS_3DDEVICE
|
5147 WINEDDSCAPS_MIPMAP
|
5148 WINEDDSCAPS_TEXTURE
|
5149 WINEDDSCAPS_ZBUFFER
;
5150 caps
->ddraw_caps
.caps
|= WINEDDCAPS_3D
;
5156 HRESULT CDECL
wined3d_device_create(struct wined3d
*wined3d
, UINT adapter_idx
, enum wined3d_device_type device_type
,
5157 HWND focus_window
, DWORD flags
, BYTE surface_alignment
, struct wined3d_device_parent
*device_parent
,
5158 struct wined3d_device
**device
)
5160 struct wined3d_device
*object
;
5163 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
5164 wined3d
, adapter_idx
, device_type
, focus_window
, flags
, device_parent
, device
);
5166 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
5167 * number and create a device without a 3D adapter for 2D only operation. */
5168 if (wined3d
->adapter_count
&& adapter_idx
>= wined3d
->adapter_count
)
5169 return WINED3DERR_INVALIDCALL
;
5171 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5174 ERR("Failed to allocate device memory.\n");
5175 return E_OUTOFMEMORY
;
5178 hr
= device_init(object
, wined3d
, adapter_idx
, device_type
,
5179 focus_window
, flags
, surface_alignment
, device_parent
);
5182 WARN("Failed to initialize device, hr %#x.\n", hr
);
5183 HeapFree(GetProcessHeap(), 0, object
);
5187 TRACE("Created device %p.\n", object
);
5190 device_parent
->ops
->wined3d_device_created(device_parent
, *device
);
5195 static void WINE_GLAPI
invalid_func(const void *data
)
5197 ERR("Invalid vertex attribute function called\n");
5201 static void WINE_GLAPI
invalid_texcoord_func(GLenum unit
, const void *data
)
5203 ERR("Invalid texcoord function called\n");
5207 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
5208 * the extension detection and are used in drawStridedSlow
5210 static void WINE_GLAPI
position_d3dcolor(const void *data
)
5212 DWORD pos
= *((const DWORD
*)data
);
5214 FIXME("Add a test for fixed function position from d3dcolor type\n");
5215 context_get_current()->gl_info
->gl_ops
.gl
.p_glVertex4s(D3DCOLOR_B_R(pos
),
5221 static void WINE_GLAPI
position_float4(const void *data
)
5223 const GLfloat
*pos
= data
;
5225 if (pos
[3] != 0.0f
&& pos
[3] != 1.0f
)
5227 float w
= 1.0f
/ pos
[3];
5229 context_get_current()->gl_info
->gl_ops
.gl
.p_glVertex4f(pos
[0] * w
, pos
[1] * w
, pos
[2] * w
, w
);
5233 context_get_current()->gl_info
->gl_ops
.gl
.p_glVertex3fv(pos
);
5237 static void WINE_GLAPI
diffuse_d3dcolor(const void *data
)
5239 DWORD diffuseColor
= *((const DWORD
*)data
);
5241 context_get_current()->gl_info
->gl_ops
.gl
.p_glColor4ub(D3DCOLOR_B_R(diffuseColor
),
5242 D3DCOLOR_B_G(diffuseColor
),
5243 D3DCOLOR_B_B(diffuseColor
),
5244 D3DCOLOR_B_A(diffuseColor
));
5247 static void WINE_GLAPI
specular_d3dcolor(const void *data
)
5249 DWORD specularColor
= *((const DWORD
*)data
);
5250 GLbyte d
[] = {D3DCOLOR_B_R(specularColor
),
5251 D3DCOLOR_B_G(specularColor
),
5252 D3DCOLOR_B_B(specularColor
)};
5254 specular_func_3ubv(d
);
5257 static void WINE_GLAPI
warn_no_specular_func(const void *data
)
5259 WARN("GL_EXT_secondary_color not supported\n");
5262 static void fillGLAttribFuncs(const struct wined3d_gl_info
*gl_info
)
5264 position_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5265 position_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5266 position_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)gl_info
->gl_ops
.gl
.p_glVertex3fv
;
5267 position_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = position_float4
;
5268 position_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = position_d3dcolor
;
5269 position_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5270 position_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5271 position_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glAttribFunc
)gl_info
->gl_ops
.gl
.p_glVertex2sv
;
5272 position_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5273 position_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5274 position_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5275 position_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5276 position_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5277 position_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5278 position_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5279 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5280 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5282 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5283 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5284 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)gl_info
->gl_ops
.gl
.p_glColor3fv
;
5285 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)gl_info
->gl_ops
.gl
.p_glColor4fv
;
5286 diffuse_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = diffuse_d3dcolor
;
5287 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5288 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5289 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5290 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = (glAttribFunc
)gl_info
->gl_ops
.gl
.p_glColor4ubv
;
5291 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5292 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = (glAttribFunc
)gl_info
->gl_ops
.gl
.p_glColor4sv
;
5293 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5294 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = (glAttribFunc
)gl_info
->gl_ops
.gl
.p_glColor4usv
;
5295 diffuse_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5296 diffuse_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5297 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5298 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5300 /* No 4 component entry points here */
5301 specular_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5302 specular_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5303 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5305 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)GL_EXTCALL(glSecondaryColor3fvEXT
);
5309 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = warn_no_specular_func
;
5311 specular_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = invalid_func
;
5312 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5314 specular_func_3ubv
= (glAttribFunc
)GL_EXTCALL(glSecondaryColor3ubvEXT
);
5315 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = specular_d3dcolor
;
5319 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = warn_no_specular_func
;
5321 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5322 specular_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5323 specular_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5324 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5325 specular_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5326 specular_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5327 specular_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5328 specular_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5329 specular_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5330 specular_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5331 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5332 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5334 /* Only 3 component entry points here. Test how others behave. Float4 normals are used
5335 * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
5337 normal_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5338 normal_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5339 normal_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)gl_info
->gl_ops
.gl
.p_glNormal3fv
;
5340 normal_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)gl_info
->gl_ops
.gl
.p_glNormal3fv
; /* Just ignore the 4th value */
5341 normal_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_func
;
5342 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5343 normal_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5344 normal_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5345 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5346 normal_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5347 normal_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5348 normal_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5349 normal_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5350 normal_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5351 normal_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5352 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5353 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5355 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord1fvARB
);
5356 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2fvARB
);
5357 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord3fvARB
);
5358 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4fvARB
);
5359 multi_texcoord_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_texcoord_func
;
5360 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_texcoord_func
;
5361 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2svARB
);
5362 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4svARB
);
5363 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_texcoord_func
;
5364 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_texcoord_func
;
5365 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_texcoord_func
;
5366 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_texcoord_func
;
5367 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_texcoord_func
;
5368 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_texcoord_func
;
5369 multi_texcoord_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_texcoord_func
;
5370 if (gl_info
->supported
[NV_HALF_FLOAT
])
5372 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
5373 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2hvNV
);
5374 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4hvNV
);
5376 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_texcoord_func
;
5377 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_texcoord_func
;
5381 /* Do not call while under the GL lock. */
5382 static BOOL
InitAdapters(struct wined3d
*wined3d
)
5384 struct wined3d_adapter
*adapter
= &wined3d
->adapters
[0];
5385 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
5386 static HMODULE mod_gl
;
5388 int ps_selected_mode
, vs_selected_mode
;
5390 /* No need to hold any lock. The calling library makes sure only one thread calls
5391 * wined3d simultaneously
5394 TRACE("Initializing adapters\n");
5397 mod_gl
= LoadLibraryA("opengl32.dll");
5399 ERR("Can't load opengl32.dll!\n");
5404 /* Load WGL core functions from opengl32.dll */
5405 #define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
5409 /* Dynamically load all GL core functions */
5410 #ifdef USE_WIN32_OPENGL
5411 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
5415 /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
5417 HDC hdc
= GetDC( 0 );
5418 const struct opengl_funcs
*wgl_driver
= __wine_get_wgl_driver( hdc
, WINE_WGL_DRIVER_VERSION
);
5419 ReleaseDC( 0, hdc
);
5420 if (!wgl_driver
|| wgl_driver
== (void *)-1) goto nogl_adapter
;
5421 gl_info
->gl_ops
.gl
= wgl_driver
->gl
;
5425 glEnableWINE
= gl_info
->gl_ops
.gl
.p_glEnable
;
5426 glDisableWINE
= gl_info
->gl_ops
.gl
.p_glDisable
;
5428 /* For now only one default adapter */
5430 struct wined3d_fake_gl_ctx fake_gl_ctx
= {0};
5431 struct wined3d_pixel_format
*cfgs
;
5434 DISPLAY_DEVICEW DisplayDevice
;
5437 TRACE("Initializing default adapter\n");
5438 adapter
->ordinal
= 0;
5439 adapter
->monitorPoint
.x
= -1;
5440 adapter
->monitorPoint
.y
= -1;
5442 if (!AllocateLocallyUniqueId(&adapter
->luid
))
5444 DWORD err
= GetLastError();
5445 ERR("Failed to set adapter LUID (%#x).\n", err
);
5448 TRACE("Allocated LUID %08x:%08x for adapter.\n",
5449 adapter
->luid
.HighPart
, adapter
->luid
.LowPart
);
5451 if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx
))
5453 ERR("Failed to get a gl context for default adapter\n");
5457 ret
= wined3d_adapter_init_gl_caps(adapter
);
5459 ERR("Failed to initialize gl caps for default adapter\n");
5460 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5463 ret
= initPixelFormats(&adapter
->gl_info
, adapter
->driver_info
.vendor
);
5465 ERR("Failed to init gl formats\n");
5466 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5470 hdc
= fake_gl_ctx
.dc
;
5472 adapter
->TextureRam
= adapter
->driver_info
.vidmem
;
5473 adapter
->UsedTextureRam
= 0;
5474 TRACE("Emulating %dMB of texture ram\n", adapter
->TextureRam
/(1024*1024));
5476 /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
5477 DisplayDevice
.cb
= sizeof(DisplayDevice
);
5478 EnumDisplayDevicesW(NULL
, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice
, 0);
5479 TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice
.DeviceName
));
5480 strcpyW(adapter
->DeviceName
, DisplayDevice
.DeviceName
);
5482 if (gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
])
5490 attribute
= WGL_NUMBER_PIXEL_FORMATS_ARB
;
5491 GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, 0, 0, 1, &attribute
, &cfg_count
));
5492 adapter
->cfg_count
= cfg_count
;
5494 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, adapter
->cfg_count
* sizeof(*adapter
->cfgs
));
5495 cfgs
= adapter
->cfgs
;
5496 attribs
[nAttribs
++] = WGL_RED_BITS_ARB
;
5497 attribs
[nAttribs
++] = WGL_GREEN_BITS_ARB
;
5498 attribs
[nAttribs
++] = WGL_BLUE_BITS_ARB
;
5499 attribs
[nAttribs
++] = WGL_ALPHA_BITS_ARB
;
5500 attribs
[nAttribs
++] = WGL_COLOR_BITS_ARB
;
5501 attribs
[nAttribs
++] = WGL_DEPTH_BITS_ARB
;
5502 attribs
[nAttribs
++] = WGL_STENCIL_BITS_ARB
;
5503 attribs
[nAttribs
++] = WGL_DRAW_TO_WINDOW_ARB
;
5504 attribs
[nAttribs
++] = WGL_PIXEL_TYPE_ARB
;
5505 attribs
[nAttribs
++] = WGL_DOUBLE_BUFFER_ARB
;
5506 attribs
[nAttribs
++] = WGL_AUX_BUFFERS_ARB
;
5508 for (iPixelFormat
=1; iPixelFormat
<= adapter
->cfg_count
; ++iPixelFormat
)
5510 res
= GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, nAttribs
, attribs
, values
));
5515 /* Cache the pixel format */
5516 cfgs
->iPixelFormat
= iPixelFormat
;
5517 cfgs
->redSize
= values
[0];
5518 cfgs
->greenSize
= values
[1];
5519 cfgs
->blueSize
= values
[2];
5520 cfgs
->alphaSize
= values
[3];
5521 cfgs
->colorSize
= values
[4];
5522 cfgs
->depthSize
= values
[5];
5523 cfgs
->stencilSize
= values
[6];
5524 cfgs
->windowDrawable
= values
[7];
5525 cfgs
->iPixelType
= values
[8];
5526 cfgs
->doubleBuffer
= values
[9];
5527 cfgs
->auxBuffers
= values
[10];
5529 cfgs
->numSamples
= 0;
5530 /* Check multisample support */
5531 if (gl_info
->supported
[ARB_MULTISAMPLE
])
5533 int attrib
[2] = {WGL_SAMPLE_BUFFERS_ARB
, WGL_SAMPLES_ARB
};
5535 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, 2, attrib
, value
))) {
5536 /* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
5537 * value[1] = number of multi sample buffers*/
5539 cfgs
->numSamples
= value
[1];
5543 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5544 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
5545 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5546 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5547 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->numSamples
, cfgs
->windowDrawable
);
5553 int nCfgs
= DescribePixelFormat(hdc
, 0, 0, 0);
5554 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, nCfgs
* sizeof(*adapter
->cfgs
));
5555 adapter
->cfg_count
= 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
5557 cfgs
= adapter
->cfgs
;
5558 for(iPixelFormat
=1; iPixelFormat
<=nCfgs
; iPixelFormat
++)
5560 PIXELFORMATDESCRIPTOR ppfd
;
5562 res
= DescribePixelFormat(hdc
, iPixelFormat
, sizeof(PIXELFORMATDESCRIPTOR
), &ppfd
);
5566 /* We only want HW acceleration using an OpenGL ICD driver.
5567 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
5568 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
5570 if(ppfd
.dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
))
5572 TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat
);
5576 cfgs
->iPixelFormat
= iPixelFormat
;
5577 cfgs
->redSize
= ppfd
.cRedBits
;
5578 cfgs
->greenSize
= ppfd
.cGreenBits
;
5579 cfgs
->blueSize
= ppfd
.cBlueBits
;
5580 cfgs
->alphaSize
= ppfd
.cAlphaBits
;
5581 cfgs
->colorSize
= ppfd
.cColorBits
;
5582 cfgs
->depthSize
= ppfd
.cDepthBits
;
5583 cfgs
->stencilSize
= ppfd
.cStencilBits
;
5584 cfgs
->windowDrawable
= (ppfd
.dwFlags
& PFD_DRAW_TO_WINDOW
) ? 1 : 0;
5585 cfgs
->iPixelType
= (ppfd
.iPixelType
== PFD_TYPE_RGBA
) ? WGL_TYPE_RGBA_ARB
: WGL_TYPE_COLORINDEX_ARB
;
5586 cfgs
->doubleBuffer
= (ppfd
.dwFlags
& PFD_DOUBLEBUFFER
) ? 1 : 0;
5587 cfgs
->auxBuffers
= ppfd
.cAuxBuffers
;
5588 cfgs
->numSamples
= 0;
5590 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5591 "depth=%d, stencil=%d, windowDrawable=%d\n",
5592 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5593 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5594 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->windowDrawable
);
5596 adapter
->cfg_count
++;
5599 /* We haven't found any suitable formats. This should only happen
5600 * in case of GDI software rendering, which is pretty useless
5602 if (!adapter
->cfg_count
)
5604 ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
5606 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5607 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
5612 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5614 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
5615 fillGLAttribFuncs(&adapter
->gl_info
);
5616 adapter
->opengl
= TRUE
;
5618 wined3d
->adapter_count
= 1;
5619 TRACE("%u adapters successfully initialized.\n", wined3d
->adapter_count
);
5624 /* Initialize an adapter for ddraw-only memory counting */
5625 memset(wined3d
->adapters
, 0, sizeof(wined3d
->adapters
));
5626 wined3d
->adapters
[0].ordinal
= 0;
5627 wined3d
->adapters
[0].opengl
= FALSE
;
5628 wined3d
->adapters
[0].monitorPoint
.x
= -1;
5629 wined3d
->adapters
[0].monitorPoint
.y
= -1;
5631 wined3d
->adapters
[0].driver_info
.name
= "Display";
5632 wined3d
->adapters
[0].driver_info
.description
= "WineD3D DirectDraw Emulation";
5633 if (wined3d_settings
.emulated_textureram
)
5634 wined3d
->adapters
[0].TextureRam
= wined3d_settings
.emulated_textureram
;
5636 wined3d
->adapters
[0].TextureRam
= 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
5638 initPixelFormatsNoGL(&wined3d
->adapters
[0].gl_info
);
5640 wined3d
->adapter_count
= 1;
5644 static void STDMETHODCALLTYPE
wined3d_null_wined3d_object_destroyed(void *parent
) {}
5646 const struct wined3d_parent_ops wined3d_null_parent_ops
=
5648 wined3d_null_wined3d_object_destroyed
,
5651 /* Do not call while under the GL lock. */
5652 HRESULT
wined3d_init(struct wined3d
*wined3d
, UINT version
, DWORD flags
)
5654 wined3d
->dxVersion
= version
;
5656 wined3d
->flags
= flags
;
5658 if (!InitAdapters(wined3d
))
5660 WARN("Failed to initialize adapters.\n");
5663 MESSAGE("Direct3D%u is not available without OpenGL.\n", version
);