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-2010 Henri Verbeet for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wined3d_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
29 WINE_DECLARE_DEBUG_CHANNEL(d3d_caps
);
31 #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
33 /* The driver names reflect the lowest GPU supported
34 * by a certain driver, so DRIVER_AMD_R300 supports
35 * R3xx, R4xx and R5xx GPUs. */
36 enum wined3d_display_driver
38 DRIVER_AMD_RAGE_128PRO
,
47 DRIVER_NVIDIA_GEFORCE2MX
,
48 DRIVER_NVIDIA_GEFORCEFX
,
49 DRIVER_NVIDIA_GEFORCE6
,
53 enum wined3d_driver_model
61 enum wined3d_gl_vendor
71 /* The d3d device ID */
72 static const GUID IID_D3DDEVICE_D3DUID
= { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
74 /* Extension detection */
77 const char *extension_string
;
78 enum wined3d_gl_extension extension
;
84 {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE
, 0 },
85 {"GL_APPLE_fence", APPLE_FENCE
, 0 },
86 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS
, 0 },
87 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE
, 0 },
88 {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER
, 0 },
89 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422
, 0 },
92 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT
, 0 },
93 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT
, 0 },
94 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP
, 0 },
95 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE
, 0 },
96 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS
, 0 },
97 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX
, 0 },
98 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM
, 0 },
99 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER
, 0 },
100 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT
, 0 },
101 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4
, 0 },
102 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL
, 0 },
103 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX
, 0 },
104 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE
, 0 },
105 {"GL_ARB_multisample", ARB_MULTISAMPLE
, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */
106 {"GL_ARB_multitexture", ARB_MULTITEXTURE
, 0 },
107 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY
, 0 },
108 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT
, 0 },
109 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS
, 0 },
110 {"GL_ARB_point_sprite", ARB_POINT_SPRITE
, 0 },
111 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX
, 0 },
112 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS
, 0 },
113 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD
, 0 },
114 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100
, 0 },
115 {"GL_ARB_shadow", ARB_SHADOW
, 0 },
116 {"GL_ARB_sync", ARB_SYNC
, 0 },
117 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP
, 0 },
118 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION
, 0 },
119 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC
, 0 },
120 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP
, 0 },
121 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD
, 0 },
122 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE
, 0 },
123 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3
, 0 },
124 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT
, 0 },
125 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT
, 0 },
126 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO
, MAKEDWORD_VERSION(2, 0) },
127 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE
, 0 },
128 {"GL_ARB_texture_rg", ARB_TEXTURE_RG
, 0 },
129 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
, 0 },
130 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND
, 0 },
131 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT
, 0 },
132 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM
, 0 },
133 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER
, 0 },
136 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER
, 0 },
137 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL
, 0 },
138 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC
, 0 },
139 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3
, 0 },
140 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE
, 0 },
143 {"GL_EXT_blend_color", EXT_BLEND_COLOR
, 0 },
144 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE
, 0 },
145 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE
, 0 },
146 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX
, 0 },
147 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT
, 0 },
148 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST
, 0 },
149 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2
, 0 },
150 {"GL_EXT_fog_coord", EXT_FOG_COORD
, 0 },
151 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT
, 0 },
152 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE
, 0 },
153 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT
, 0 },
154 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS
, 0 },
155 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4
, 0 },
156 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL
, 0 },
157 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE
, 0 },
158 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS
, 0 },
159 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX
, 0 },
160 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR
, 0 },
161 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE
, 0 },
162 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP
, 0 },
163 {"GL_EXT_texture3D", EXT_TEXTURE3D
, MAKEDWORD_VERSION(1, 2) },
164 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC
, 0 },
165 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC
, 0 },
166 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD
, 0 },
167 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE
, 0 },
168 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3
, 0 },
169 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC
, 0 },
170 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS
, 0 },
171 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB
, 0 },
172 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE
, 0 },
173 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA
, 0 },
176 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP
, 0 },
177 {"GL_NV_fence", NV_FENCE
, 0 },
178 {"GL_NV_fog_distance", NV_FOG_DISTANCE
, 0 },
179 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM
, 0 },
180 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2
, 0 },
181 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION
, 0 },
182 {"GL_NV_half_float", NV_HALF_FLOAT
, 0 },
183 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT
, 0 },
184 {"GL_NV_point_sprite", NV_POINT_SPRITE
, 0 },
185 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS
, 0 },
186 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2
, 0 },
187 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION
, 0 },
188 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4
, 0 },
189 {"GL_NV_texture_shader", NV_TEXTURE_SHADER
, 0 },
190 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2
, 0 },
191 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM
, 0 },
192 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1
, 0 },
193 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2
, 0 },
194 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION
, 0 },
195 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3
, 0 },
198 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP
, 0 },
201 /**********************************************************
202 * Utility functions follow
203 **********************************************************/
205 const struct min_lookup minMipLookup
[] =
207 /* NONE POINT LINEAR */
208 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
209 {{GL_NEAREST
, GL_NEAREST_MIPMAP_NEAREST
, GL_NEAREST_MIPMAP_LINEAR
}}, /* POINT*/
210 {{GL_LINEAR
, GL_LINEAR_MIPMAP_NEAREST
, GL_LINEAR_MIPMAP_LINEAR
}}, /* LINEAR */
213 const struct min_lookup minMipLookup_noFilter
[] =
215 /* NONE POINT LINEAR */
216 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
217 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
218 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* LINEAR */
221 const struct min_lookup minMipLookup_noMip
[] =
223 /* NONE POINT LINEAR */
224 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
225 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
226 {{GL_LINEAR
, GL_LINEAR
, GL_LINEAR
}}, /* LINEAR */
229 const GLenum magLookup
[] =
231 /* NONE POINT LINEAR */
232 GL_NEAREST
, GL_NEAREST
, GL_LINEAR
,
235 const GLenum magLookup_noFilter
[] =
237 /* NONE POINT LINEAR */
238 GL_NEAREST
, GL_NEAREST
, GL_NEAREST
,
241 /* drawStridedSlow attributes */
242 glAttribFunc position_funcs
[WINED3D_FFP_EMIT_COUNT
];
243 glAttribFunc diffuse_funcs
[WINED3D_FFP_EMIT_COUNT
];
244 glAttribFunc specular_func_3ubv
;
245 glAttribFunc specular_funcs
[WINED3D_FFP_EMIT_COUNT
];
246 glAttribFunc normal_funcs
[WINED3D_FFP_EMIT_COUNT
];
247 glMultiTexCoordFunc multi_texcoord_funcs
[WINED3D_FFP_EMIT_COUNT
];
250 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
251 * i.e., there is no GL Context - Get a default rendering context to enable the
252 * function query some info from GL.
255 struct wined3d_fake_gl_ctx
261 HGLRC restore_gl_ctx
;
264 static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx
*ctx
)
266 TRACE_(d3d_caps
)("Destroying fake GL context.\n");
268 if (!pwglMakeCurrent(NULL
, NULL
))
270 ERR_(d3d_caps
)("Failed to disable fake GL context.\n");
273 if (!pwglDeleteContext(ctx
->gl_ctx
))
275 DWORD err
= GetLastError();
276 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx
->gl_ctx
, err
);
279 ReleaseDC(ctx
->wnd
, ctx
->dc
);
280 DestroyWindow(ctx
->wnd
);
282 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
284 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
288 /* Do not call while under the GL lock. */
289 static BOOL
WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx
*ctx
)
291 PIXELFORMATDESCRIPTOR pfd
;
294 TRACE("getting context...\n");
296 ctx
->restore_dc
= pwglGetCurrentDC();
297 ctx
->restore_gl_ctx
= pwglGetCurrentContext();
299 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
300 ctx
->wnd
= CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME
, "WineD3D fake window",
301 WS_OVERLAPPEDWINDOW
, 10, 10, 10, 10, NULL
, NULL
, NULL
, NULL
);
304 ERR_(d3d_caps
)("Failed to create a window.\n");
308 ctx
->dc
= GetDC(ctx
->wnd
);
311 ERR_(d3d_caps
)("Failed to get a DC.\n");
315 /* PixelFormat selection */
316 ZeroMemory(&pfd
, sizeof(pfd
));
317 pfd
.nSize
= sizeof(pfd
);
319 pfd
.dwFlags
= PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
; /* PFD_GENERIC_ACCELERATED */
320 pfd
.iPixelType
= PFD_TYPE_RGBA
;
322 pfd
.iLayerType
= PFD_MAIN_PLANE
;
324 iPixelFormat
= ChoosePixelFormat(ctx
->dc
, &pfd
);
327 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
328 ERR_(d3d_caps
)("Can't find a suitable iPixelFormat.\n");
331 DescribePixelFormat(ctx
->dc
, iPixelFormat
, sizeof(pfd
), &pfd
);
332 SetPixelFormat(ctx
->dc
, iPixelFormat
, &pfd
);
334 /* Create a GL context. */
335 ctx
->gl_ctx
= pwglCreateContext(ctx
->dc
);
338 WARN_(d3d_caps
)("Error creating default context for capabilities initialization.\n");
342 /* Make it the current GL context. */
343 if (!context_set_current(NULL
))
345 ERR_(d3d_caps
)("Failed to clear current D3D context.\n");
348 if (!pwglMakeCurrent(ctx
->dc
, ctx
->gl_ctx
))
350 ERR_(d3d_caps
)("Failed to make fake GL context current.\n");
357 if (ctx
->gl_ctx
) pwglDeleteContext(ctx
->gl_ctx
);
359 if (ctx
->dc
) ReleaseDC(ctx
->wnd
, ctx
->dc
);
361 if (ctx
->wnd
) DestroyWindow(ctx
->wnd
);
363 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
365 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
371 /* Adjust the amount of used texture memory */
372 unsigned int WineD3DAdapterChangeGLRam(struct wined3d_device
*device
, int glram
)
374 struct wined3d_adapter
*adapter
= device
->adapter
;
376 adapter
->UsedTextureRam
+= glram
;
377 TRACE("Adjusted gl ram by %d to %d\n", glram
, adapter
->UsedTextureRam
);
378 return adapter
->UsedTextureRam
;
381 static void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
)
383 HeapFree(GetProcessHeap(), 0, adapter
->gl_info
.formats
);
384 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
387 ULONG CDECL
wined3d_incref(struct wined3d
*wined3d
)
389 ULONG refcount
= InterlockedIncrement(&wined3d
->ref
);
391 TRACE("%p increasing refcount to %u.\n", wined3d
, refcount
);
396 ULONG CDECL
wined3d_decref(struct wined3d
*wined3d
)
398 ULONG refcount
= InterlockedDecrement(&wined3d
->ref
);
400 TRACE("%p decreasing refcount to %u.\n", wined3d
, refcount
);
406 for (i
= 0; i
< wined3d
->adapter_count
; ++i
)
408 wined3d_adapter_cleanup(&wined3d
->adapters
[i
]);
410 HeapFree(GetProcessHeap(), 0, wined3d
);
416 /* GL locking is done by the caller */
417 static inline BOOL
test_arb_vs_offset_limit(const struct wined3d_gl_info
*gl_info
)
421 const char *testcode
=
423 "PARAM C[66] = { program.env[0..65] };\n"
425 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
426 "ARL A0.x, zero.x;\n"
427 "MOV result.position, C[A0.x + 65];\n"
431 GL_EXTCALL(glGenProgramsARB(1, &prog
));
433 ERR("Failed to create an ARB offset limit test program\n");
435 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
436 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
437 strlen(testcode
), testcode
));
440 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
441 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
443 } else TRACE("OpenGL implementation allows offsets > 63\n");
445 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
446 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
447 checkGLcall("ARB vp offset limit test cleanup");
452 static DWORD
ver_for_ext(enum wined3d_gl_extension ext
)
455 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
) {
456 if(EXTENSION_MAP
[i
].extension
== ext
) {
457 return EXTENSION_MAP
[i
].version
;
463 static BOOL
match_amd_r300_to_500(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
464 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
466 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
467 if (device
== CARD_AMD_RADEON_9500
) return TRUE
;
468 if (device
== CARD_AMD_RADEON_X700
) return TRUE
;
469 if (device
== CARD_AMD_RADEON_X1600
) return TRUE
;
473 static BOOL
match_geforce5(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
474 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
476 if (card_vendor
== HW_VENDOR_NVIDIA
)
478 if (device
== CARD_NVIDIA_GEFORCEFX_5200
||
479 device
== CARD_NVIDIA_GEFORCEFX_5600
||
480 device
== CARD_NVIDIA_GEFORCEFX_5800
)
488 static BOOL
match_apple(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
489 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
491 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
492 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
493 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
495 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
496 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
497 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
498 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
499 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
500 * the chance that other implementations support them is rather small since Win32 QuickTime uses
501 * DirectDraw, not OpenGL.
503 * This test has been moved into wined3d_guess_gl_vendor()
505 if (gl_vendor
== GL_VENDOR_APPLE
)
512 /* Context activation is done by the caller. */
513 static void test_pbo_functionality(struct wined3d_gl_info
*gl_info
)
515 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
516 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
517 * all the texture. This function detects this bug by its symptom and disables PBOs
520 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
521 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
522 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
523 * read back is compared to the original. If they are equal PBOs are assumed to work,
524 * otherwise the PBO extension is disabled. */
526 static const unsigned int pattern
[] =
528 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
529 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
530 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
531 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
533 unsigned int check
[sizeof(pattern
) / sizeof(pattern
[0])];
535 /* No PBO -> No point in testing them. */
536 if (!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
]) return;
540 while (glGetError());
541 glGenTextures(1, &texture
);
542 glBindTexture(GL_TEXTURE_2D
, texture
);
544 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAX_LEVEL
, 0);
545 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0);
546 checkGLcall("Specifying the PBO test texture");
548 GL_EXTCALL(glGenBuffersARB(1, &pbo
));
549 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, pbo
));
550 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB
, sizeof(pattern
), pattern
, GL_STREAM_DRAW_ARB
));
551 checkGLcall("Specifying the PBO test pbo");
553 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
554 checkGLcall("Loading the PBO test texture");
556 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, 0));
559 wglFinish(); /* just to be sure */
561 memset(check
, 0, sizeof(check
));
563 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, check
);
564 checkGLcall("Reading back the PBO test texture");
566 glDeleteTextures(1, &texture
);
567 GL_EXTCALL(glDeleteBuffersARB(1, &pbo
));
568 checkGLcall("PBO test cleanup");
572 if (memcmp(check
, pattern
, sizeof(check
)))
574 WARN_(d3d_caps
)("PBO test failed, read back data doesn't match original.\n");
575 WARN_(d3d_caps
)("Disabling PBOs. This may result in slower performance.\n");
576 gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
] = FALSE
;
580 TRACE_(d3d_caps
)("PBO test successful.\n");
584 static BOOL
match_apple_intel(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
585 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
587 return (card_vendor
== HW_VENDOR_INTEL
) && (gl_vendor
== GL_VENDOR_APPLE
);
590 static BOOL
match_apple_nonr500ati(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
591 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
593 if (gl_vendor
!= GL_VENDOR_APPLE
) return FALSE
;
594 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
595 if (device
== CARD_AMD_RADEON_X1600
) return FALSE
;
599 static BOOL
match_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
600 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
602 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
603 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
604 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
605 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
608 * dx10 cards usually have 64 varyings */
609 return gl_info
->limits
.glsl_varyings
> 44;
612 /* A GL context is provided by the caller */
613 static BOOL
match_allows_spec_alpha(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
614 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
619 if (!gl_info
->supported
[EXT_SECONDARY_COLOR
]) return FALSE
;
623 GL_EXTCALL(glSecondaryColorPointerEXT
)(4, GL_UNSIGNED_BYTE
, 4, data
);
624 error
= glGetError();
627 if(error
== GL_NO_ERROR
)
629 TRACE("GL Implementation accepts 4 component specular color pointers\n");
634 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
635 debug_glerror(error
));
640 static BOOL
match_apple_nvts(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
641 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
643 if (!match_apple(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) return FALSE
;
644 return gl_info
->supported
[NV_TEXTURE_SHADER
];
647 /* A GL context is provided by the caller */
648 static BOOL
match_broken_nv_clip(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
649 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
654 const char *testcode
=
656 "OPTION NV_vertex_program2;\n"
657 "MOV result.clip[0], 0.0;\n"
658 "MOV result.position, 0.0;\n"
661 if (!gl_info
->supported
[NV_VERTEX_PROGRAM2_OPTION
]) return FALSE
;
666 GL_EXTCALL(glGenProgramsARB(1, &prog
));
669 ERR("Failed to create the NVvp clip test program\n");
673 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
674 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
675 strlen(testcode
), testcode
));
676 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &pos
);
679 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
680 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
684 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
686 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
687 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
688 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
694 /* Context activation is done by the caller. */
695 static BOOL
match_fbo_tex_update(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
696 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
698 char data
[4 * 4 * 4];
702 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
) return FALSE
;
704 memset(data
, 0xcc, sizeof(data
));
708 glGenTextures(1, &tex
);
709 glBindTexture(GL_TEXTURE_2D
, tex
);
710 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
711 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
712 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
713 checkGLcall("glTexImage2D");
715 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
716 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
717 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
718 checkGLcall("glFramebufferTexture2D");
720 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
721 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
722 checkGLcall("glCheckFramebufferStatus");
724 memset(data
, 0x11, sizeof(data
));
725 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
726 checkGLcall("glTexSubImage2D");
728 glClearColor(0.996f
, 0.729f
, 0.745f
, 0.792f
);
729 glClear(GL_COLOR_BUFFER_BIT
);
730 checkGLcall("glClear");
732 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
733 checkGLcall("glGetTexImage");
735 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
736 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
737 glBindTexture(GL_TEXTURE_2D
, 0);
738 checkGLcall("glBindTexture");
740 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
741 glDeleteTextures(1, &tex
);
742 checkGLcall("glDeleteTextures");
746 return *(DWORD
*)data
== 0x11111111;
749 /* Context activation is done by the caller. */
750 static BOOL
match_broken_rgba16(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
751 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
753 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
754 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
760 glGenTextures(1, &tex
);
761 glBindTexture(GL_TEXTURE_2D
, tex
);
762 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA16
, 4, 4, 0, GL_RGBA
, GL_UNSIGNED_SHORT
, NULL
);
763 checkGLcall("glTexImage2D");
765 glGetTexLevelParameteriv(GL_TEXTURE_2D
, 0, GL_TEXTURE_RED_SIZE
, &size
);
766 checkGLcall("glGetTexLevelParameteriv");
767 TRACE("Real color depth is %d\n", size
);
769 glBindTexture(GL_TEXTURE_2D
, 0);
770 checkGLcall("glBindTexture");
771 glDeleteTextures(1, &tex
);
772 checkGLcall("glDeleteTextures");
779 static void quirk_arb_constants(struct wined3d_gl_info
*gl_info
)
781 TRACE_(d3d_caps
)("Using ARB vs constant limit(=%u) for GLSL.\n", gl_info
->limits
.arb_vs_native_constants
);
782 gl_info
->limits
.glsl_vs_float_constants
= gl_info
->limits
.arb_vs_native_constants
;
783 TRACE_(d3d_caps
)("Using ARB ps constant limit(=%u) for GLSL.\n", gl_info
->limits
.arb_ps_native_constants
);
784 gl_info
->limits
.glsl_ps_float_constants
= gl_info
->limits
.arb_ps_native_constants
;
787 static void quirk_apple_glsl_constants(struct wined3d_gl_info
*gl_info
)
789 quirk_arb_constants(gl_info
);
790 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
791 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
792 * allow 48 different offsets or other helper immediate values. */
793 TRACE_(d3d_caps
)("Reserving 12 GLSL constants for compiler private use.\n");
794 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 12);
797 static void quirk_amd_dx9(struct wined3d_gl_info
*gl_info
)
799 quirk_arb_constants(gl_info
);
801 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
802 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
803 * If real NP2 textures are used, the driver falls back to software. We could just remove the
804 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
805 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
806 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
807 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
809 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
810 * has this extension promoted to core. The extension loading code sets this extension supported
811 * due to that, so this code works on fglrx as well. */
812 if(gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
814 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
815 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
816 gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
] = TRUE
;
819 /* fglrx has the same structural issues as the one described in quirk_apple_glsl_constants, although
820 * it is generally more efficient. Reserve just 8 constants. */
821 TRACE_(d3d_caps
)("Reserving 8 GLSL constants for compiler private use.\n");
822 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 8);
825 static void quirk_no_np2(struct wined3d_gl_info
*gl_info
)
827 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
828 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
829 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
830 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
831 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
832 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
834 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
835 * triggering the software fallback. There is not much we can do here apart from disabling the
836 * software-emulated extension and reenable ARB_tex_rect (which was previously disabled
837 * in wined3d_adapter_init_gl_caps).
838 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
839 * post-processing effects in the game "Max Payne 2").
840 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
841 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
842 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
843 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = TRUE
;
846 static void quirk_texcoord_w(struct wined3d_gl_info
*gl_info
)
848 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
849 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
850 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
851 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
852 * according to the spec.
854 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
855 * makes the shader slower and eats instruction slots which should be available to the d3d app.
857 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
858 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
859 * this workaround is activated on cards that do not need it, it won't break things, just affect
860 * performance negatively. */
861 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
862 gl_info
->quirks
|= WINED3D_QUIRK_SET_TEXCOORD_W
;
865 static void quirk_clip_varying(struct wined3d_gl_info
*gl_info
)
867 gl_info
->quirks
|= WINED3D_QUIRK_GLSL_CLIP_VARYING
;
870 static void quirk_allows_specular_alpha(struct wined3d_gl_info
*gl_info
)
872 gl_info
->quirks
|= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
;
875 static void quirk_apple_nvts(struct wined3d_gl_info
*gl_info
)
877 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
878 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
881 static void quirk_disable_nvvp_clip(struct wined3d_gl_info
*gl_info
)
883 gl_info
->quirks
|= WINED3D_QUIRK_NV_CLIP_BROKEN
;
886 static void quirk_fbo_tex_update(struct wined3d_gl_info
*gl_info
)
888 gl_info
->quirks
|= WINED3D_QUIRK_FBO_TEX_UPDATE
;
891 static void quirk_broken_rgba16(struct wined3d_gl_info
*gl_info
)
893 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_RGBA16
;
898 BOOL (*match
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
899 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
);
900 void (*apply
)(struct wined3d_gl_info
*gl_info
);
901 const char *description
;
904 static const struct driver_quirk quirk_table
[] =
907 match_amd_r300_to_500
,
909 "AMD GLSL constant and normalized texrect quirk"
911 /* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
912 * used it falls back to software. While the compiler can detect if the shader uses all declared
913 * uniforms, the optimization fails if the shader uses relative addressing. So any GLSL shader
914 * using relative addressing falls back to software.
916 * ARB vp gives the correct amount of uniforms, so use it instead of GLSL. */
919 quirk_apple_glsl_constants
,
920 "Apple GLSL uniform override"
925 "Geforce 5 NP2 disable"
930 "Init texcoord .w for Apple Intel GPU driver"
933 match_apple_nonr500ati
,
935 "Init texcoord .w for Apple ATI >= r600 GPU driver"
940 "Reserved varying for gl_ClipPos"
943 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
944 * GL implementations accept it. The Mac GL is the only implementation known to
947 * If we can pass 4 component specular colors, do it, because (a) we don't have
948 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
949 * passes specular alpha to the pixel shader if any is used. Otherwise the
950 * specular alpha is used to pass the fog coordinate, which we pass to opengl
951 * via GL_EXT_fog_coord.
953 match_allows_spec_alpha
,
954 quirk_allows_specular_alpha
,
955 "Allow specular alpha quirk"
958 /* The pixel formats provided by GL_NV_texture_shader are broken on OSX
963 "Apple NV_texture_shader disable"
966 match_broken_nv_clip
,
967 quirk_disable_nvvp_clip
,
968 "Apple NV_vertex_program clip bug quirk"
971 match_fbo_tex_update
,
972 quirk_fbo_tex_update
,
973 "FBO rebind for attachment updates"
978 "True RGBA16 is not available"
982 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
983 * reporting a driver version is moot because we are not the Windows driver, and we have different
984 * bugs, features, etc.
986 * The driver version has the form "x.y.z.w".
988 * "x" is the Windows version the driver is meant for:
995 * "y" is the maximum Direct3D version the driver supports.
996 * y -> d3d version mapping:
1005 * "z" is the subversion number.
1007 * "w" is the vendor specific driver build number.
1010 struct driver_version_information
1012 enum wined3d_display_driver driver
;
1013 enum wined3d_driver_model driver_model
;
1014 const char *driver_name
; /* name of Windows driver */
1015 WORD version
; /* version word ('y'), contained in low word of DriverVersion.HighPart */
1016 WORD subversion
; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
1017 WORD build
; /* build number ('w'), contained in low word of DriverVersion.LowPart */
1020 /* The driver version table contains driver information for different devices on several OS versions. */
1021 static const struct driver_version_information driver_version_table
[] =
1024 * - Radeon HD2x00 (R600) and up supported by current drivers.
1025 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1026 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1027 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1028 {DRIVER_AMD_RAGE_128PRO
, DRIVER_MODEL_NT5X
, "ati2dvaa.dll", 13, 3279, 0},
1029 {DRIVER_AMD_R100
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6614},
1030 {DRIVER_AMD_R300
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6764},
1031 {DRIVER_AMD_R600
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 8681},
1032 {DRIVER_AMD_R300
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1033 {DRIVER_AMD_R600
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1036 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1037 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1038 * igxprd32.dll but the GMA800 driver was never updated. */
1039 {DRIVER_INTEL_GMA800
, DRIVER_MODEL_NT5X
, "ialmrnt5.dll", 14, 10, 3889},
1040 {DRIVER_INTEL_GMA900
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4764},
1041 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4926},
1042 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 5218},
1043 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 14, 10, 1504},
1044 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 15, 10, 1666},
1047 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1048 * - GeforceFX support is up to 173.x on <= XP
1049 * - Geforce2MX/3/4 up to 96.x on <= XP
1050 * - TNT/Geforce1/2 up to 71.x on <= XP
1051 * All version numbers used below are from the Linux nvidia drivers. */
1052 {DRIVER_NVIDIA_TNT
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 7186},
1053 {DRIVER_NVIDIA_GEFORCE2MX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 9371},
1054 {DRIVER_NVIDIA_GEFORCEFX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 11, 7516},
1055 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 15, 12, 6658},
1056 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 15, 12, 6658},
1059 struct gpu_description
1061 WORD vendor
; /* reported PCI card vendor ID */
1062 WORD card
; /* reported PCI card device ID */
1063 const char *description
; /* Description of the card e.g. NVIDIA RIVA TNT */
1064 enum wined3d_display_driver driver
;
1065 unsigned int vidmem
;
1068 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1069 * found on a board containing a specific GPU. */
1070 static const struct gpu_description gpu_description_table
[] =
1073 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT
, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT
, 16 },
1074 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT2
, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1075 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE
, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT
, 32 },
1076 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2
, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1077 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2_MX
, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX
,32 },
1078 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE3
, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1079 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_MX
, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1080 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_TI4200
, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX
,64, },
1081 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5200
, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX
, 64 },
1082 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5600
, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX
, 128 },
1083 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5800
, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX
, 256 },
1084 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6200
, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6
, 64 },
1085 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6600GT
, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6
, 128 },
1086 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6800
, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6
, 128 },
1087 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7300
, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6
, 256 },
1088 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7400
, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6
, 256 },
1089 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7600
, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1090 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7800GT
, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1091 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8300GS
, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1092 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8400GS
, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1093 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600GT
, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1094 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600MGT
, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1095 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTS
, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6
, 320 },
1096 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTX
, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6
, 768 },
1097 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9200
, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6
, 256 },
1098 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400GT
, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1099 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9500GT
, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1100 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9600GT
, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6
, 384 },
1101 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9800GT
, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1102 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_210
, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6
, 512 },
1103 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT220
, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6
, 512 },
1104 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT240
, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6
, 512 },
1105 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX260
, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6
, 1024},
1106 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX275
, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6
, 896 },
1107 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX280
, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6
, 1024},
1108 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT320M
, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1109 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT325M
, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1110 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT330
, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6
, 1024},
1111 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS350M
, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1112 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT420
, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6
, 2048},
1113 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT430
, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6
, 1024},
1114 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT440
, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6
, 1024},
1115 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS450
, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6
, 1024},
1116 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460
, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6
, 768 },
1117 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX465
, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6
, 1024},
1118 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX470
, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6
, 1280},
1119 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX480
, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6
, 1536},
1120 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX550
, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1121 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560
, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1122 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX570
, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6
, 1280},
1123 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX580
, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6
, 1536},
1126 {HW_VENDOR_AMD
, CARD_AMD_RAGE_128PRO
, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO
, 16 },
1127 {HW_VENDOR_AMD
, CARD_AMD_RADEON_7200
, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100
, 32 },
1128 {HW_VENDOR_AMD
, CARD_AMD_RADEON_8500
, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100
, 64 },
1129 {HW_VENDOR_AMD
, CARD_AMD_RADEON_9500
, "ATI Radeon 9500", DRIVER_AMD_R300
, 64 },
1130 {HW_VENDOR_AMD
, CARD_AMD_RADEON_XPRESS_200M
, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300
, 64 },
1131 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X700
, "ATI Radeon X700 SE", DRIVER_AMD_R300
, 128 },
1132 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X1600
, "ATI Radeon X1600 Series", DRIVER_AMD_R300
, 128 },
1133 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2350
, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600
, 256 },
1134 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2600
, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600
, 256 },
1135 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2900
, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600
, 512 },
1136 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD3200
, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600
, 128 },
1137 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4350
, "ATI Radeon HD 4350", DRIVER_AMD_R600
, 256 },
1138 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4600
, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600
, 512 },
1139 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4700
, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600
, 512 },
1140 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4800
, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600
, 512 },
1141 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5400
, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600
, 512 },
1142 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5600
, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600
, 512 },
1143 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5700
, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600
, 512 },
1144 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5800
, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600
, 1024},
1145 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5900
, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600
, 1024},
1146 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6300
, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600
, 1024},
1147 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6400
, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600
, 1024},
1148 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600
, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600
, 1024},
1149 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6800
, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600
, 1024},
1150 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6900
, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600
, 2048},
1152 {HW_VENDOR_INTEL
, CARD_INTEL_I830G
, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1153 {HW_VENDOR_INTEL
, CARD_INTEL_I855G
, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1154 {HW_VENDOR_INTEL
, CARD_INTEL_I865G
, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1155 {HW_VENDOR_INTEL
, CARD_INTEL_I915G
, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1156 {HW_VENDOR_INTEL
, CARD_INTEL_I915GM
, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1157 {HW_VENDOR_INTEL
, CARD_INTEL_I945GM
, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950
, 64 },
1158 {HW_VENDOR_INTEL
, CARD_INTEL_X3100
, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000
, 128},
1159 {HW_VENDOR_INTEL
, CARD_INTEL_GM45
, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000
, 512}
1162 static const struct driver_version_information
*get_driver_version_info(enum wined3d_display_driver driver
,
1163 enum wined3d_driver_model driver_model
)
1167 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver
, driver_model
);
1168 for (i
= 0; i
< (sizeof(driver_version_table
) / sizeof(driver_version_table
[0])); i
++)
1170 const struct driver_version_information
*entry
= &driver_version_table
[i
];
1172 if (entry
->driver
== driver
&& entry
->driver_model
== driver_model
)
1174 TRACE_(d3d_caps
)("Found driver '%s' version=%d subversion=%d build=%d\n",
1175 entry
->driver_name
, entry
->version
, entry
->subversion
, entry
->build
);
1183 static void init_driver_info(struct wined3d_driver_info
*driver_info
,
1184 enum wined3d_pci_vendor vendor
, enum wined3d_pci_device device
)
1186 OSVERSIONINFOW os_version
;
1187 WORD driver_os_version
;
1189 enum wined3d_display_driver driver
= DRIVER_UNKNOWN
;
1190 enum wined3d_driver_model driver_model
;
1191 const struct driver_version_information
*version_info
;
1193 if (wined3d_settings
.pci_vendor_id
!= PCI_VENDOR_NONE
)
1195 TRACE_(d3d_caps
)("Overriding PCI vendor ID with: %04x\n", wined3d_settings
.pci_vendor_id
);
1196 vendor
= wined3d_settings
.pci_vendor_id
;
1198 driver_info
->vendor
= vendor
;
1200 if (wined3d_settings
.pci_device_id
!= PCI_DEVICE_NONE
)
1202 TRACE_(d3d_caps
)("Overriding PCI device ID with: %04x\n", wined3d_settings
.pci_device_id
);
1203 device
= wined3d_settings
.pci_device_id
;
1205 driver_info
->device
= device
;
1207 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1208 * overrides the pci ids to a card which is not in our database. */
1209 driver_info
->vidmem
= WINE_DEFAULT_VIDMEM
;
1211 memset(&os_version
, 0, sizeof(os_version
));
1212 os_version
.dwOSVersionInfoSize
= sizeof(os_version
);
1213 if (!GetVersionExW(&os_version
))
1215 ERR("Failed to get OS version, reporting 2000/XP.\n");
1216 driver_os_version
= 6;
1217 driver_model
= DRIVER_MODEL_NT5X
;
1221 TRACE("OS version %u.%u.\n", os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1222 switch (os_version
.dwMajorVersion
)
1225 /* If needed we could distinguish between 9x and NT4, but this code won't make
1226 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1228 driver_os_version
= 4;
1229 driver_model
= DRIVER_MODEL_WIN9X
;
1233 driver_os_version
= 6;
1234 driver_model
= DRIVER_MODEL_NT5X
;
1238 if (os_version
.dwMinorVersion
== 0)
1240 driver_os_version
= 7;
1241 driver_model
= DRIVER_MODEL_NT6X
;
1245 if (os_version
.dwMinorVersion
> 1)
1247 FIXME("Unhandled OS version %u.%u, reporting Win 7.\n",
1248 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1250 driver_os_version
= 8;
1251 driver_model
= DRIVER_MODEL_NT6X
;
1256 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1257 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1258 driver_os_version
= 6;
1259 driver_model
= DRIVER_MODEL_NT5X
;
1264 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1265 * This means that unless the ids are overriden, we will always find a GPU description. */
1266 for (i
= 0; i
< (sizeof(gpu_description_table
) / sizeof(gpu_description_table
[0])); i
++)
1268 if (vendor
== gpu_description_table
[i
].vendor
&& device
== gpu_description_table
[i
].card
)
1270 TRACE_(d3d_caps
)("Found card %04x:%04x in driver DB.\n", vendor
, device
);
1272 driver_info
->description
= gpu_description_table
[i
].description
;
1273 driver_info
->vidmem
= gpu_description_table
[i
].vidmem
* 1024*1024;
1274 driver
= gpu_description_table
[i
].driver
;
1279 if (wined3d_settings
.emulated_textureram
)
1281 TRACE_(d3d_caps
)("Overriding amount of video memory with: %d byte\n", wined3d_settings
.emulated_textureram
);
1282 driver_info
->vidmem
= wined3d_settings
.emulated_textureram
;
1285 /* Try to obtain driver version information for the current Windows version. This fails in
1287 * - the gpu is not available on the currently selected OS version:
1288 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1289 * version information for the current Windows version is returned instead of faked info.
1290 * We do the same and assume the default Windows version to emulate is WinXP.
1292 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1293 * For now return the XP driver info. Perhaps later on we should return VESA.
1295 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1296 * This could be an indication that our database is not up to date, so this should be fixed.
1298 version_info
= get_driver_version_info(driver
, driver_model
);
1301 driver_info
->name
= version_info
->driver_name
;
1302 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1303 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1307 version_info
= get_driver_version_info(driver
, DRIVER_MODEL_NT5X
);
1310 driver_info
->name
= version_info
->driver_name
;
1311 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1312 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1316 driver_info
->description
= "Direct3D HAL";
1317 driver_info
->name
= "Display";
1318 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, 15);
1319 driver_info
->version_low
= MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1321 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1322 vendor
, device
, driver_model
);
1326 TRACE_(d3d_caps
)("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1327 driver_info
->version_high
, driver_info
->version_low
);
1330 /* Context activation is done by the caller. */
1331 static void fixup_extensions(struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
1332 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
1336 for (i
= 0; i
< (sizeof(quirk_table
) / sizeof(*quirk_table
)); ++i
)
1338 if (!quirk_table
[i
].match(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) continue;
1339 TRACE_(d3d_caps
)("Applying driver quirk \"%s\".\n", quirk_table
[i
].description
);
1340 quirk_table
[i
].apply(gl_info
);
1343 /* Find out if PBOs work as they are supposed to. */
1344 test_pbo_functionality(gl_info
);
1347 static DWORD
wined3d_parse_gl_version(const char *gl_version
)
1349 const char *ptr
= gl_version
;
1353 if (major
<= 0) ERR_(d3d_caps
)("Invalid opengl major version: %d.\n", major
);
1355 while (isdigit(*ptr
)) ++ptr
;
1356 if (*ptr
++ != '.') ERR_(d3d_caps
)("Invalid opengl version string: %s.\n", debugstr_a(gl_version
));
1360 TRACE_(d3d_caps
)("Found OpenGL version: %d.%d.\n", major
, minor
);
1362 return MAKEDWORD_VERSION(major
, minor
);
1365 static enum wined3d_gl_vendor
wined3d_guess_gl_vendor(const struct wined3d_gl_info
*gl_info
,
1366 const char *gl_vendor_string
, const char *gl_renderer
)
1369 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1370 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1371 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1373 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1374 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1375 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1376 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1377 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1378 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1379 * DirectDraw, not OpenGL. */
1380 if (gl_info
->supported
[APPLE_FENCE
]
1381 && gl_info
->supported
[APPLE_CLIENT_STORAGE
]
1382 && gl_info
->supported
[APPLE_FLUSH_RENDER
]
1383 && gl_info
->supported
[APPLE_YCBCR_422
])
1384 return GL_VENDOR_APPLE
;
1386 if (strstr(gl_vendor_string
, "NVIDIA"))
1387 return GL_VENDOR_NVIDIA
;
1389 if (strstr(gl_vendor_string
, "ATI"))
1390 return GL_VENDOR_FGLRX
;
1392 if (strstr(gl_vendor_string
, "Intel(R)")
1393 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1394 || strstr(gl_renderer
, "Intel")
1395 || strstr(gl_vendor_string
, "Intel Inc."))
1396 return GL_VENDOR_INTEL
;
1398 if (strstr(gl_vendor_string
, "Mesa")
1399 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1400 || strstr(gl_vendor_string
, "DRI R300 Project")
1401 || strstr(gl_vendor_string
, "X.Org R300 Project")
1402 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1403 || strstr(gl_vendor_string
, "VMware, Inc.")
1404 || strstr(gl_renderer
, "Mesa")
1405 || strstr(gl_renderer
, "Gallium"))
1406 return GL_VENDOR_MESA
;
1408 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1409 debugstr_a(gl_vendor_string
));
1411 return GL_VENDOR_UNKNOWN
;
1414 static enum wined3d_pci_vendor
wined3d_guess_card_vendor(const char *gl_vendor_string
, const char *gl_renderer
)
1416 if (strstr(gl_vendor_string
, "NVIDIA")
1417 || strstr(gl_vendor_string
, "nouveau"))
1418 return HW_VENDOR_NVIDIA
;
1420 if (strstr(gl_vendor_string
, "ATI")
1421 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1422 || strstr(gl_vendor_string
, "X.Org R300 Project")
1423 || strstr(gl_renderer
, "AMD")
1424 || strstr(gl_renderer
, "R100")
1425 || strstr(gl_renderer
, "R200")
1426 || strstr(gl_renderer
, "R300")
1427 || strstr(gl_renderer
, "R600")
1428 || strstr(gl_renderer
, "R700"))
1429 return HW_VENDOR_AMD
;
1431 if (strstr(gl_vendor_string
, "Intel(R)")
1432 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1433 || strstr(gl_renderer
, "Intel")
1434 || strstr(gl_vendor_string
, "Intel Inc."))
1435 return HW_VENDOR_INTEL
;
1437 if (strstr(gl_vendor_string
, "Mesa")
1438 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1439 || strstr(gl_vendor_string
, "VMware, Inc."))
1440 return HW_VENDOR_SOFTWARE
;
1442 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string
));
1444 return HW_VENDOR_NVIDIA
;
1447 static UINT
d3d_level_from_gl_info(const struct wined3d_gl_info
*gl_info
)
1451 if (gl_info
->supported
[ARB_MULTITEXTURE
])
1453 if (gl_info
->supported
[ARB_TEXTURE_COMPRESSION
]
1454 && gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
]
1455 && gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
1457 if (level
== 7 && gl_info
->supported
[ARB_MULTISAMPLE
]
1458 && gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
1460 if (level
== 8 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]
1461 && gl_info
->supported
[ARB_VERTEX_SHADER
])
1463 if (level
== 9 && gl_info
->supported
[EXT_GPU_SHADER4
])
1469 static enum wined3d_pci_device
select_card_nvidia_binary(const struct wined3d_gl_info
*gl_info
,
1470 const char *gl_renderer
)
1472 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1475 if (d3d_level
>= 10)
1479 const char *renderer
;
1480 enum wined3d_pci_device id
;
1484 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580
}, /* Geforce 500 - highend */
1485 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570
}, /* Geforce 500 - midend high */
1486 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560
}, /* Geforce 500 - midend */
1487 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550
}, /* Geforce 500 - midend */
1488 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480
}, /* Geforce 400 - highend */
1489 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470
}, /* Geforce 400 - midend high */
1490 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465
}, /* Geforce 400 - midend */
1491 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460
}, /* Geforce 400 - midend */
1492 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450
}, /* Geforce 400 - midend low */
1493 {"GT 440", CARD_NVIDIA_GEFORCE_GT440
}, /* Geforce 400 - lowend */
1494 {"GT 430", CARD_NVIDIA_GEFORCE_GT430
}, /* Geforce 400 - lowend */
1495 {"GT 420", CARD_NVIDIA_GEFORCE_GT420
}, /* Geforce 400 - lowend */
1496 {"GT 330", CARD_NVIDIA_GEFORCE_GT330
}, /* Geforce 300 - highend */
1497 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1498 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1499 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1500 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1501 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M
}, /* Geforce 300 - midend mobile */
1502 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1503 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1504 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1505 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275
}, /* Geforce 200 - midend high */
1506 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260
}, /* Geforce 200 - midend */
1507 {"GT 240", CARD_NVIDIA_GEFORCE_GT240
}, /* Geforce 200 - midend */
1508 {"GT 220", CARD_NVIDIA_GEFORCE_GT220
}, /* Geforce 200 - lowend */
1509 {"Geforce 310", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1510 {"Geforce 305", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1511 {"Geforce 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1512 {"G 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1513 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1514 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1515 {"9800", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1516 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1517 {"9600", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1518 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1519 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1520 {"9500", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1521 {"9400", CARD_NVIDIA_GEFORCE_9400GT
}, /* Geforce 9 - lowend */
1522 {"9300", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1523 {"9200", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1524 {"9100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1525 {"G 100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1526 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX
}, /* Geforce 8 - highend high */
1527 {"8800", CARD_NVIDIA_GEFORCE_8800GTS
}, /* Geforce 8 - highend */
1528 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1529 {"8700", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1530 {"8600", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1531 {"8500", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1532 {"8400", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1533 {"8300", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1534 {"8200", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1535 {"8100", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1538 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1540 if (strstr(gl_renderer
, cards
[i
].renderer
))
1544 /* Geforce8-compatible fall back if the GPU is not in the list yet */
1545 return CARD_NVIDIA_GEFORCE_8300GS
;
1548 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1549 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1551 if (d3d_level
>= 9 && gl_info
->supported
[NV_VERTEX_PROGRAM3
])
1555 const char *renderer
;
1556 enum wined3d_pci_device id
;
1560 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1561 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1562 {"7950", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1563 {"7900", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1564 {"7800", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1565 {"7700", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1566 {"7600", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1567 {"7400", CARD_NVIDIA_GEFORCE_7400
}, /* Geforce 7 - lower medium */
1568 {"7300", CARD_NVIDIA_GEFORCE_7300
}, /* Geforce 7 - lowend */
1569 {"6800", CARD_NVIDIA_GEFORCE_6800
}, /* Geforce 6 - highend */
1570 {"6700", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1571 {"6610", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1572 {"6600", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1575 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1577 if (strstr(gl_renderer
, cards
[i
].renderer
))
1581 /* Geforce 6/7 - lowend */
1582 return CARD_NVIDIA_GEFORCE_6200
; /* Geforce 6100/6150/6200/7300/7400/7500 */
1587 /* GeforceFX - highend */
1588 if (strstr(gl_renderer
, "5800")
1589 || strstr(gl_renderer
, "5900")
1590 || strstr(gl_renderer
, "5950")
1591 || strstr(gl_renderer
, "Quadro FX"))
1593 return CARD_NVIDIA_GEFORCEFX_5800
;
1596 /* GeforceFX - midend */
1597 if (strstr(gl_renderer
, "5600")
1598 || strstr(gl_renderer
, "5650")
1599 || strstr(gl_renderer
, "5700")
1600 || strstr(gl_renderer
, "5750"))
1602 return CARD_NVIDIA_GEFORCEFX_5600
;
1605 /* GeforceFX - lowend */
1606 return CARD_NVIDIA_GEFORCEFX_5200
; /* GeforceFX 5100/5200/5250/5300/5500 */
1611 if (strstr(gl_renderer
, "GeForce4 Ti") || strstr(gl_renderer
, "Quadro4"))
1613 return CARD_NVIDIA_GEFORCE4_TI4200
; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1616 return CARD_NVIDIA_GEFORCE3
; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1621 if (strstr(gl_renderer
, "GeForce4 MX"))
1623 return CARD_NVIDIA_GEFORCE4_MX
; /* MX420/MX440/MX460/MX4000 */
1626 if (strstr(gl_renderer
, "GeForce2 MX") || strstr(gl_renderer
, "Quadro2 MXR"))
1628 return CARD_NVIDIA_GEFORCE2_MX
; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1631 if (strstr(gl_renderer
, "GeForce2") || strstr(gl_renderer
, "Quadro2"))
1633 return CARD_NVIDIA_GEFORCE2
; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1636 return CARD_NVIDIA_GEFORCE
; /* Geforce 256/DDR, Quadro */
1639 if (strstr(gl_renderer
, "TNT2"))
1641 return CARD_NVIDIA_RIVA_TNT2
; /* Riva TNT2 standard/M64/Pro/Ultra */
1644 return CARD_NVIDIA_RIVA_TNT
; /* Riva TNT, Vanta */
1647 static enum wined3d_pci_device
select_card_amd_binary(const struct wined3d_gl_info
*gl_info
,
1648 const char *gl_renderer
)
1650 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1652 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1654 * Beware: renderer string do not match exact card model,
1655 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1656 if (d3d_level
>= 10)
1662 const char *renderer
;
1663 enum wined3d_pci_device id
;
1668 {"HD 5870", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS PRO */
1669 {"HD 5850", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS XT */
1670 {"HD 5800", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1671 {"HD 5770", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER XT */
1672 {"HD 5750", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER LE */
1673 {"HD 5700", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1674 {"HD 5670", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD XT */
1675 {"HD 5570", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1676 {"HD 5550", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1677 {"HD 5450", CARD_AMD_RADEON_HD5400
}, /* Radeon EG CEDAR PRO */
1679 {"HD 4890", CARD_AMD_RADEON_HD4800
}, /* Radeon RV790 */
1680 {"HD 4870", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1681 {"HD 4850", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1682 {"HD 4830", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1683 {"HD 4800", CARD_AMD_RADEON_HD4800
}, /* Radeon RV7xx HD48xx generic renderer string */
1684 {"HD 4770", CARD_AMD_RADEON_HD4700
}, /* Radeon RV740 */
1685 {"HD 4700", CARD_AMD_RADEON_HD4700
}, /* Radeon RV7xx HD47xx generic renderer string */
1686 {"HD 4670", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1687 {"HD 4650", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1688 {"HD 4600", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1689 {"HD 4550", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1690 {"HD 4350", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1691 /* R600/R700 integrated */
1692 {"HD 3300", CARD_AMD_RADEON_HD3200
},
1693 {"HD 3200", CARD_AMD_RADEON_HD3200
},
1694 {"HD 3100", CARD_AMD_RADEON_HD3200
},
1696 {"HD 3870", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1697 {"HD 3850", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1698 {"HD 2900", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1699 {"HD 3830", CARD_AMD_RADEON_HD2600
}, /* China-only midend */
1700 {"HD 3690", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1701 {"HD 3650", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1702 {"HD 2600", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1703 {"HD 3470", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1704 {"HD 3450", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1705 {"HD 3430", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1706 {"HD 3400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1707 {"HD 2400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1708 {"HD 2350", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1711 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1713 if (strstr(gl_renderer
, cards
[i
].renderer
))
1717 /* Default for when no GPU has been found */
1718 return CARD_AMD_RADEON_HD3200
;
1724 if (strstr(gl_renderer
, "X1600")
1725 || strstr(gl_renderer
, "X1650")
1726 || strstr(gl_renderer
, "X1800")
1727 || strstr(gl_renderer
, "X1900")
1728 || strstr(gl_renderer
, "X1950"))
1730 return CARD_AMD_RADEON_X1600
;
1733 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1734 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1735 if (strstr(gl_renderer
, "X700")
1736 || strstr(gl_renderer
, "X800")
1737 || strstr(gl_renderer
, "X850")
1738 || strstr(gl_renderer
, "X1300")
1739 || strstr(gl_renderer
, "X1400")
1740 || strstr(gl_renderer
, "X1450")
1741 || strstr(gl_renderer
, "X1550")
1742 || strstr(gl_renderer
, "X2300")
1743 || strstr(gl_renderer
, "X2500")
1744 || strstr(gl_renderer
, "HD 2300")
1747 return CARD_AMD_RADEON_X700
;
1750 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1751 if (strstr(gl_renderer
, "Radeon Xpress"))
1753 return CARD_AMD_RADEON_XPRESS_200M
;
1757 return CARD_AMD_RADEON_9500
; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
1761 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1764 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1766 return CARD_AMD_RAGE_128PRO
;
1769 static enum wined3d_pci_device
select_card_intel(const struct wined3d_gl_info
*gl_info
,
1770 const char *gl_renderer
)
1772 if (strstr(gl_renderer
, "GM45")) return CARD_INTEL_GM45
;
1773 if (strstr(gl_renderer
, "X3100") || strstr(gl_renderer
, "965GM"))
1775 /* MacOS calls the card GMA X3100, otherwise known as GM965/GL960 */
1776 return CARD_INTEL_X3100
;
1779 if (strstr(gl_renderer
, "GMA 950") || strstr(gl_renderer
, "945GM"))
1781 /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
1782 return CARD_INTEL_I945GM
;
1785 if (strstr(gl_renderer
, "915GM")) return CARD_INTEL_I915GM
;
1786 if (strstr(gl_renderer
, "915G")) return CARD_INTEL_I915G
;
1787 if (strstr(gl_renderer
, "865G")) return CARD_INTEL_I865G
;
1788 if (strstr(gl_renderer
, "855G")) return CARD_INTEL_I855G
;
1789 if (strstr(gl_renderer
, "830G")) return CARD_INTEL_I830G
;
1790 return CARD_INTEL_I915G
;
1794 static enum wined3d_pci_device
select_card_amd_mesa(const struct wined3d_gl_info
*gl_info
,
1795 const char *gl_renderer
)
1800 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1802 * Beware: renderer string do not match exact card model,
1803 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1804 if (strstr(gl_renderer
, "Gallium"))
1806 /* 20101109 - These are never returned by current Gallium radeon
1807 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
1809 * These are returned but not handled: RC410, RV380. */
1812 const char *renderer
;
1813 enum wined3d_pci_device id
;
1817 /* Northern Islands */
1818 {"CAYMAN", CARD_AMD_RADEON_HD6900
},
1819 {"BARTS", CARD_AMD_RADEON_HD6800
},
1820 {"TURKS", CARD_AMD_RADEON_HD6600
},
1821 {"CAICOS", CARD_AMD_RADEON_HD6400
},
1822 {"PALM", CARD_AMD_RADEON_HD6300
},
1824 {"HEMLOCK", CARD_AMD_RADEON_HD5900
},
1825 {"CYPRESS", CARD_AMD_RADEON_HD5800
},
1826 {"JUNIPER", CARD_AMD_RADEON_HD5700
},
1827 {"REDWOOD", CARD_AMD_RADEON_HD5600
},
1828 {"CEDAR", CARD_AMD_RADEON_HD5400
},
1830 {"R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1831 {"RV790", CARD_AMD_RADEON_HD4800
},
1832 {"RV770", CARD_AMD_RADEON_HD4800
},
1833 {"RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1834 {"RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1835 {"RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1836 /* R600/R700 integrated */
1837 {"RS880", CARD_AMD_RADEON_HD3200
},
1838 {"RS780", CARD_AMD_RADEON_HD3200
},
1840 {"R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1841 {"R600", CARD_AMD_RADEON_HD2900
},
1842 {"RV670", CARD_AMD_RADEON_HD2900
},
1843 {"RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1844 {"RV630", CARD_AMD_RADEON_HD2600
},
1845 {"RV620", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1846 {"RV610", CARD_AMD_RADEON_HD2350
},
1848 {"R580", CARD_AMD_RADEON_X1600
},
1849 {"R520", CARD_AMD_RADEON_X1600
},
1850 {"RV570", CARD_AMD_RADEON_X1600
},
1851 {"RV560", CARD_AMD_RADEON_X1600
},
1852 {"RV535", CARD_AMD_RADEON_X1600
},
1853 {"RV530", CARD_AMD_RADEON_X1600
},
1854 {"RV516", CARD_AMD_RADEON_X700
}, /* X700 is actually R400. */
1855 {"RV515", CARD_AMD_RADEON_X700
},
1857 {"R481", CARD_AMD_RADEON_X700
},
1858 {"R480", CARD_AMD_RADEON_X700
},
1859 {"R430", CARD_AMD_RADEON_X700
},
1860 {"R423", CARD_AMD_RADEON_X700
},
1861 {"R420", CARD_AMD_RADEON_X700
},
1862 {"R410", CARD_AMD_RADEON_X700
},
1863 {"RV410", CARD_AMD_RADEON_X700
},
1864 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
1865 {"RS740", CARD_AMD_RADEON_XPRESS_200M
},
1866 {"RS690", CARD_AMD_RADEON_XPRESS_200M
},
1867 {"RS600", CARD_AMD_RADEON_XPRESS_200M
},
1868 {"RS485", CARD_AMD_RADEON_XPRESS_200M
},
1869 {"RS482", CARD_AMD_RADEON_XPRESS_200M
},
1870 {"RS480", CARD_AMD_RADEON_XPRESS_200M
},
1871 {"RS400", CARD_AMD_RADEON_XPRESS_200M
},
1873 {"R360", CARD_AMD_RADEON_9500
},
1874 {"R350", CARD_AMD_RADEON_9500
},
1875 {"R300", CARD_AMD_RADEON_9500
},
1876 {"RV370", CARD_AMD_RADEON_9500
},
1877 {"RV360", CARD_AMD_RADEON_9500
},
1878 {"RV351", CARD_AMD_RADEON_9500
},
1879 {"RV350", CARD_AMD_RADEON_9500
},
1882 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1884 if (strstr(gl_renderer
, cards
[i
].renderer
))
1889 d3d_level
= d3d_level_from_gl_info(gl_info
);
1894 const char *renderer
;
1895 enum wined3d_pci_device id
;
1900 {"(R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1901 {"(RV790", CARD_AMD_RADEON_HD4800
},
1902 {"(RV770", CARD_AMD_RADEON_HD4800
},
1903 {"(RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1904 {"(RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1905 {"(RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1906 /* R600/R700 integrated */
1907 {"RS880", CARD_AMD_RADEON_HD3200
},
1908 {"RS780", CARD_AMD_RADEON_HD3200
},
1910 {"(R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1911 {"(R600", CARD_AMD_RADEON_HD2900
},
1912 {"(RV670", CARD_AMD_RADEON_HD2900
},
1913 {"(RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1914 {"(RV630", CARD_AMD_RADEON_HD2600
},
1915 {"(RV620", CARD_AMD_RADEON_HD2350
}, /* HD2300/HD2400/HD3400 - lowend */
1916 {"(RV610", CARD_AMD_RADEON_HD2350
},
1919 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1921 if (strstr(gl_renderer
, cards
[i
].renderer
))
1927 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1930 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1932 return CARD_AMD_RAGE_128PRO
;
1935 static enum wined3d_pci_device
select_card_nvidia_mesa(const struct wined3d_gl_info
*gl_info
,
1936 const char *gl_renderer
)
1940 if (strstr(gl_renderer
, "Gallium"))
1946 const char *renderer
;
1947 enum wined3d_pci_device id
;
1951 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570
},
1952 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460
},
1953 {"NVC3", CARD_NVIDIA_GEFORCE_GT440
},
1954 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480
},
1955 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M
},
1956 {"NVAC", CARD_NVIDIA_GEFORCE_8200
},
1957 {"NVAA", CARD_NVIDIA_GEFORCE_8200
},
1958 {"NVA8", CARD_NVIDIA_GEFORCE_210
},
1959 {"NVA5", CARD_NVIDIA_GEFORCE_GT220
},
1960 {"NVA3", CARD_NVIDIA_GEFORCE_GT240
},
1961 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280
},
1962 {"NV98", CARD_NVIDIA_GEFORCE_9200
},
1963 {"NV96", CARD_NVIDIA_GEFORCE_9400GT
},
1964 {"NV94", CARD_NVIDIA_GEFORCE_9600GT
},
1965 {"NV92", CARD_NVIDIA_GEFORCE_9800GT
},
1966 {"NV86", CARD_NVIDIA_GEFORCE_8500GT
},
1967 {"NV84", CARD_NVIDIA_GEFORCE_8600GT
},
1968 {"NV68", CARD_NVIDIA_GEFORCE_6200
}, /* 7050 */
1969 {"NV67", CARD_NVIDIA_GEFORCE_6200
}, /* 7000M */
1970 {"NV63", CARD_NVIDIA_GEFORCE_6200
}, /* 7100 */
1971 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX
},
1972 {"NV4E", CARD_NVIDIA_GEFORCE_6200
}, /* 6100 Go / 6150 Go */
1973 {"NV4C", CARD_NVIDIA_GEFORCE_6200
}, /* 6150SE */
1974 {"NV4B", CARD_NVIDIA_GEFORCE_7600
},
1975 {"NV4A", CARD_NVIDIA_GEFORCE_6200
},
1976 {"NV49", CARD_NVIDIA_GEFORCE_7800GT
}, /* 7900 */
1977 {"NV47", CARD_NVIDIA_GEFORCE_7800GT
},
1978 {"NV46", CARD_NVIDIA_GEFORCE_7400
},
1979 {"NV45", CARD_NVIDIA_GEFORCE_6800
},
1980 {"NV44", CARD_NVIDIA_GEFORCE_6200
},
1981 {"NV43", CARD_NVIDIA_GEFORCE_6600GT
},
1982 {"NV42", CARD_NVIDIA_GEFORCE_6800
},
1983 {"NV41", CARD_NVIDIA_GEFORCE_6800
},
1984 {"NV40", CARD_NVIDIA_GEFORCE_6800
},
1985 {"NV38", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5950 Ultra */
1986 {"NV36", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5700/5750 */
1987 {"NV35", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5900 */
1988 {"NV34", CARD_NVIDIA_GEFORCEFX_5200
},
1989 {"NV31", CARD_NVIDIA_GEFORCEFX_5600
},
1990 {"NV30", CARD_NVIDIA_GEFORCEFX_5800
},
1991 {"NV28", CARD_NVIDIA_GEFORCE4_TI4200
},
1992 {"NV25", CARD_NVIDIA_GEFORCE4_TI4200
},
1993 {"NV20", CARD_NVIDIA_GEFORCE3
},
1994 {"NV1F", CARD_NVIDIA_GEFORCE4_MX
}, /* GF4 MX IGP */
1995 {"NV1A", CARD_NVIDIA_GEFORCE2
}, /* GF2 IGP */
1996 {"NV18", CARD_NVIDIA_GEFORCE4_MX
},
1997 {"NV17", CARD_NVIDIA_GEFORCE4_MX
},
1998 {"NV16", CARD_NVIDIA_GEFORCE2
},
1999 {"NV15", CARD_NVIDIA_GEFORCE2
},
2000 {"NV11", CARD_NVIDIA_GEFORCE2_MX
},
2001 {"NV10", CARD_NVIDIA_GEFORCE
},
2002 {"NV05", CARD_NVIDIA_RIVA_TNT2
},
2003 {"NV04", CARD_NVIDIA_RIVA_TNT
},
2004 {"NV03", CARD_NVIDIA_RIVA_128
},
2007 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
2009 if (strstr(gl_renderer
, cards
[i
].renderer
))
2014 FIXME_(d3d_caps
)("Unknown renderer %s.\n", debugstr_a(gl_renderer
));
2016 d3d_level
= d3d_level_from_gl_info(gl_info
);
2018 return CARD_NVIDIA_GEFORCEFX_5600
;
2020 return CARD_NVIDIA_GEFORCE3
;
2022 return CARD_NVIDIA_GEFORCE
;
2024 return CARD_NVIDIA_RIVA_TNT
;
2025 return CARD_NVIDIA_RIVA_128
;
2029 struct vendor_card_selection
2031 enum wined3d_gl_vendor gl_vendor
;
2032 enum wined3d_pci_vendor card_vendor
;
2033 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
2034 enum wined3d_pci_device (*select_card
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
);
2037 static const struct vendor_card_selection vendor_card_select_table
[] =
2039 {GL_VENDOR_NVIDIA
, HW_VENDOR_NVIDIA
, "Nvidia binary driver", select_card_nvidia_binary
},
2040 {GL_VENDOR_APPLE
, HW_VENDOR_NVIDIA
, "Apple OSX NVidia binary driver", select_card_nvidia_binary
},
2041 {GL_VENDOR_APPLE
, HW_VENDOR_AMD
, "Apple OSX AMD/ATI binary driver", select_card_amd_binary
},
2042 {GL_VENDOR_APPLE
, HW_VENDOR_INTEL
, "Apple OSX Intel binary driver", select_card_intel
},
2043 {GL_VENDOR_FGLRX
, HW_VENDOR_AMD
, "AMD/ATI binary driver", select_card_amd_binary
},
2044 {GL_VENDOR_MESA
, HW_VENDOR_AMD
, "Mesa AMD/ATI driver", select_card_amd_mesa
},
2045 {GL_VENDOR_MESA
, HW_VENDOR_NVIDIA
, "Mesa Nouveau driver", select_card_nvidia_mesa
},
2046 {GL_VENDOR_MESA
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
},
2047 {GL_VENDOR_INTEL
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
}
2051 static enum wined3d_pci_device
wined3d_guess_card(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
2052 enum wined3d_gl_vendor
*gl_vendor
, enum wined3d_pci_vendor
*card_vendor
)
2056 /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of
2057 * different GPUs with roughly the same features. In most cases GPUs from a
2058 * certain family differ in clockspeeds, the amount of video memory and the
2059 * number of shader pipelines.
2061 * A Direct3D device object contains the PCI id (vendor + device) of the
2062 * videocard which is used for rendering. Various applications use this
2063 * information to get a rough estimation of the features of the card and
2064 * some might use it for enabling 3d effects only on certain types of
2065 * videocards. In some cases games might even use it to work around bugs
2066 * which happen on certain videocards/driver combinations. The problem is
2067 * that OpenGL only exposes a rendering string containing the name of the
2068 * videocard and not the PCI id.
2070 * Various games depend on the PCI id, so somehow we need to provide one.
2071 * A simple option is to parse the renderer string and translate this to
2072 * the right PCI id. This is a lot of work because there are more than 200
2073 * GPUs just for Nvidia. Various cards share the same renderer string, so
2074 * the amount of code might be 'small' but there are quite a number of
2075 * exceptions which would make this a pain to maintain. Another way would
2076 * be to query the PCI id from the operating system (assuming this is the
2077 * videocard which is used for rendering which is not always the case).
2078 * This would work but it is not very portable. Second it would not work
2079 * well in, let's say, a remote X situation in which the amount of 3d
2080 * features which can be used is limited.
2082 * As said most games only use the PCI id to get an indication of the
2083 * capabilities of the card. It doesn't really matter if the given id is
2084 * the correct one if we return the id of a card with similar 3d features.
2086 * The code below checks the OpenGL capabilities of a videocard and matches
2087 * that to a certain level of Direct3D functionality. Once a card passes
2088 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2089 * least a GeforceFX. To give a better estimate we do a basic check on the
2090 * renderer string but if that won't pass we return a default card. This
2091 * way is better than maintaining a full card database as even without a
2092 * full database we can return a card with similar features. Second the
2093 * size of the database can be made quite small because when you know what
2094 * type of 3d functionality a card has, you know to which GPU family the
2095 * GPU must belong. Because of this you only have to check a small part of
2096 * the renderer string to distinguishes between different models from that
2099 * The code also selects a default amount of video memory which we will
2100 * use for an estimation of the amount of free texture memory. In case of
2101 * real D3D the amount of texture memory includes video memory and system
2102 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2103 * HyperMemory). We don't know how much system memory can be addressed by
2104 * the system but we can make a reasonable estimation about the amount of
2105 * video memory. If the value is slightly wrong it doesn't matter as we
2106 * didn't include AGP-like memory which makes the amount of addressable
2107 * memory higher and second OpenGL isn't that critical it moves to system
2108 * memory behind our backs if really needed. Note that the amount of video
2109 * memory can be overruled using a registry setting. */
2113 for (i
= 0; i
< (sizeof(vendor_card_select_table
) / sizeof(*vendor_card_select_table
)); ++i
)
2115 if ((vendor_card_select_table
[i
].gl_vendor
!= *gl_vendor
)
2116 || (vendor_card_select_table
[i
].card_vendor
!= *card_vendor
))
2118 TRACE_(d3d_caps
)("Applying card_selector \"%s\".\n", vendor_card_select_table
[i
].description
);
2119 return vendor_card_select_table
[i
].select_card(gl_info
, gl_renderer
);
2122 FIXME_(d3d_caps
)("No card selector available for GL vendor %d and card vendor %04x.\n",
2123 *gl_vendor
, *card_vendor
);
2125 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
2126 * for Nvidia was because the hardware and drivers they make are of good quality. This makes
2127 * them a good generic choice. */
2128 *card_vendor
= HW_VENDOR_NVIDIA
;
2129 d3d_level
= d3d_level_from_gl_info(gl_info
);
2131 return CARD_NVIDIA_GEFORCEFX_5600
;
2133 return CARD_NVIDIA_GEFORCE3
;
2135 return CARD_NVIDIA_GEFORCE
;
2137 return CARD_NVIDIA_RIVA_TNT
;
2138 return CARD_NVIDIA_RIVA_128
;
2141 static const struct fragment_pipeline
*select_fragment_implementation(const struct wined3d_gl_info
*gl_info
)
2143 int vs_selected_mode
, ps_selected_mode
;
2145 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2146 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2147 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_fragment_pipeline
;
2148 else if (ps_selected_mode
== SHADER_ATI
) return &atifs_fragment_pipeline
;
2149 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]
2150 && gl_info
->supported
[NV_TEXTURE_SHADER2
]) return &nvts_fragment_pipeline
;
2151 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]) return &nvrc_fragment_pipeline
;
2152 else return &ffp_fragment_pipeline
;
2155 static const struct wined3d_shader_backend_ops
*select_shader_backend(const struct wined3d_gl_info
*gl_info
)
2157 int vs_selected_mode
, ps_selected_mode
;
2159 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2160 if (vs_selected_mode
== SHADER_GLSL
|| ps_selected_mode
== SHADER_GLSL
) return &glsl_shader_backend
;
2161 if (vs_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_ARB
) return &arb_program_shader_backend
;
2162 return &none_shader_backend
;
2165 static const struct blit_shader
*select_blit_implementation(const struct wined3d_gl_info
*gl_info
)
2167 int vs_selected_mode
, ps_selected_mode
;
2169 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2170 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2171 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_blit
;
2172 else return &ffp_blit
;
2175 static void load_gl_funcs(struct wined3d_gl_info
*gl_info
, DWORD gl_version
)
2179 #define USE_GL_FUNC(type, pfn, ext, replace) \
2180 if (gl_info->supported[ext]) gl_info->pfn = (type)pwglGetProcAddress(#pfn); \
2181 else if ((ver = ver_for_ext(ext)) && ver <= gl_version) gl_info->pfn = (type)pwglGetProcAddress(#replace); \
2182 else gl_info->pfn = NULL;
2187 #define USE_GL_FUNC(type, pfn, ext, replace) gl_info->pfn = (type)pwglGetProcAddress(#pfn);
2192 /* Context activation is done by the caller. */
2193 static BOOL
wined3d_adapter_init_gl_caps(struct wined3d_adapter
*adapter
)
2195 struct wined3d_driver_info
*driver_info
= &adapter
->driver_info
;
2196 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2197 const char *GL_Extensions
= NULL
;
2198 const char *WGL_Extensions
= NULL
;
2199 const char *gl_vendor_str
, *gl_renderer_str
, *gl_version_str
;
2200 struct fragment_caps fragment_caps
;
2201 enum wined3d_gl_vendor gl_vendor
;
2202 enum wined3d_pci_vendor card_vendor
;
2203 enum wined3d_pci_device device
;
2205 GLfloat gl_floatv
[2];
2211 TRACE_(d3d_caps
)("(%p)\n", gl_info
);
2215 gl_renderer_str
= (const char *)glGetString(GL_RENDERER
);
2216 TRACE_(d3d_caps
)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str
));
2217 if (!gl_renderer_str
)
2220 ERR_(d3d_caps
)("Received a NULL GL_RENDERER.\n");
2224 gl_vendor_str
= (const char *)glGetString(GL_VENDOR
);
2225 TRACE_(d3d_caps
)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str
));
2229 ERR_(d3d_caps
)("Received a NULL GL_VENDOR.\n");
2233 /* Parse the GL_VERSION field into major and minor information */
2234 gl_version_str
= (const char *)glGetString(GL_VERSION
);
2235 TRACE_(d3d_caps
)("GL_VERSION: %s.\n", debugstr_a(gl_version_str
));
2236 if (!gl_version_str
)
2239 ERR_(d3d_caps
)("Received a NULL GL_VERSION.\n");
2242 gl_version
= wined3d_parse_gl_version(gl_version_str
);
2245 * Initialize openGL extension related variables
2246 * with Default values
2248 memset(gl_info
->supported
, 0, sizeof(gl_info
->supported
));
2249 gl_info
->limits
.blends
= 1;
2250 gl_info
->limits
.buffers
= 1;
2251 gl_info
->limits
.textures
= 1;
2252 gl_info
->limits
.fragment_samplers
= 1;
2253 gl_info
->limits
.vertex_samplers
= 0;
2254 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
+ gl_info
->limits
.vertex_samplers
;
2255 gl_info
->limits
.sampler_stages
= 1;
2256 gl_info
->limits
.glsl_vs_float_constants
= 0;
2257 gl_info
->limits
.glsl_ps_float_constants
= 0;
2258 gl_info
->limits
.arb_vs_float_constants
= 0;
2259 gl_info
->limits
.arb_vs_native_constants
= 0;
2260 gl_info
->limits
.arb_vs_instructions
= 0;
2261 gl_info
->limits
.arb_vs_temps
= 0;
2262 gl_info
->limits
.arb_ps_float_constants
= 0;
2263 gl_info
->limits
.arb_ps_local_constants
= 0;
2264 gl_info
->limits
.arb_ps_instructions
= 0;
2265 gl_info
->limits
.arb_ps_temps
= 0;
2267 /* Retrieve opengl defaults */
2268 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
2269 gl_info
->limits
.clipplanes
= min(WINED3DMAXUSERCLIPPLANES
, gl_max
);
2270 TRACE_(d3d_caps
)("ClipPlanes support - num Planes=%d\n", gl_max
);
2272 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
2273 gl_info
->limits
.lights
= gl_max
;
2274 TRACE_(d3d_caps
)("Lights support - max lights=%d\n", gl_max
);
2276 glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_max
);
2277 gl_info
->limits
.texture_size
= gl_max
;
2278 TRACE_(d3d_caps
)("Maximum texture size support - max texture size=%d\n", gl_max
);
2280 glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE
, gl_floatv
);
2281 gl_info
->limits
.pointsize_min
= gl_floatv
[0];
2282 gl_info
->limits
.pointsize_max
= gl_floatv
[1];
2283 TRACE_(d3d_caps
)("Maximum point size support - max point size=%f\n", gl_floatv
[1]);
2285 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2286 GL_Extensions
= (const char *)glGetString(GL_EXTENSIONS
);
2290 ERR_(d3d_caps
)("Received a NULL GL_EXTENSIONS.\n");
2296 TRACE_(d3d_caps
)("GL_Extensions reported:\n");
2298 gl_info
->supported
[WINED3D_GL_EXT_NONE
] = TRUE
;
2300 while (*GL_Extensions
)
2304 while (isspace(*GL_Extensions
)) ++GL_Extensions
;
2305 start
= GL_Extensions
;
2306 while (!isspace(*GL_Extensions
) && *GL_Extensions
) ++GL_Extensions
;
2308 len
= GL_Extensions
- start
;
2311 TRACE_(d3d_caps
)("- %s\n", debugstr_an(start
, len
));
2313 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
)
2315 if (len
== strlen(EXTENSION_MAP
[i
].extension_string
)
2316 && !memcmp(start
, EXTENSION_MAP
[i
].extension_string
, len
))
2318 TRACE_(d3d_caps
)(" FOUND: %s support.\n", EXTENSION_MAP
[i
].extension_string
);
2319 gl_info
->supported
[EXTENSION_MAP
[i
].extension
] = TRUE
;
2325 /* Now work out what GL support this card really has */
2326 load_gl_funcs( gl_info
, gl_version
);
2330 /* Now mark all the extensions supported which are included in the opengl core version. Do this *after*
2331 * loading the functions, otherwise the code above will load the extension entry points instead of the
2332 * core functions, which may not work. */
2333 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
)
2335 if (!gl_info
->supported
[EXTENSION_MAP
[i
].extension
]
2336 && EXTENSION_MAP
[i
].version
<= gl_version
&& EXTENSION_MAP
[i
].version
)
2338 TRACE_(d3d_caps
)(" GL CORE: %s support.\n", EXTENSION_MAP
[i
].extension_string
);
2339 gl_info
->supported
[EXTENSION_MAP
[i
].extension
] = TRUE
;
2343 if (gl_version
>= MAKEDWORD_VERSION(2, 0)) gl_info
->supported
[WINED3D_GL_VERSION_2_0
] = TRUE
;
2345 if (gl_info
->supported
[APPLE_FENCE
])
2347 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2348 * The apple extension interacts with some other apple exts. Disable the NV
2349 * extension if the apple one is support to prevent confusion in other parts
2351 gl_info
->supported
[NV_FENCE
] = FALSE
;
2353 if (gl_info
->supported
[APPLE_FLOAT_PIXELS
])
2355 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2357 * The enums are the same:
2358 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881A
2359 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881B
2360 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2361 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2362 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140B
2364 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
])
2366 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_texture_float support(from GL_APPLE_float_pixels.\n");
2367 gl_info
->supported
[ARB_TEXTURE_FLOAT
] = TRUE
;
2369 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
2371 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_half_float_pixel support(from GL_APPLE_float_pixels.\n");
2372 gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
] = TRUE
;
2375 if (gl_info
->supported
[ARB_MAP_BUFFER_RANGE
])
2377 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2378 * functionality. Prefer the ARB extension */
2379 gl_info
->supported
[APPLE_FLUSH_BUFFER_RANGE
] = FALSE
;
2381 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
2383 TRACE_(d3d_caps
)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2384 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
2386 if (!gl_info
->supported
[ARB_DEPTH_CLAMP
] && gl_info
->supported
[NV_DEPTH_CLAMP
])
2388 TRACE_(d3d_caps
)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2389 gl_info
->supported
[ARB_DEPTH_CLAMP
] = TRUE
;
2391 if (!gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] && gl_info
->supported
[EXT_VERTEX_ARRAY_BGRA
])
2393 TRACE_(d3d_caps
)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2394 gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] = TRUE
;
2396 if (!gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
])
2398 TRACE_(d3d_caps
)(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
2399 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
2401 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2403 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2405 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2406 * are supported. The nv extensions provide the same functionality as the
2407 * ATI one, and a bit more(signed pixelformats). */
2408 gl_info
->supported
[ATI_FRAGMENT_SHADER
] = FALSE
;
2412 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2414 glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV
, &gl_max
);
2415 gl_info
->limits
.general_combiners
= gl_max
;
2416 TRACE_(d3d_caps
)("Max general combiners: %d.\n", gl_max
);
2418 if (gl_info
->supported
[ARB_DRAW_BUFFERS
])
2420 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &gl_max
);
2421 gl_info
->limits
.buffers
= gl_max
;
2422 TRACE_(d3d_caps
)("Max draw buffers: %u.\n", gl_max
);
2424 if (gl_info
->supported
[ARB_MULTITEXTURE
])
2426 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
2427 gl_info
->limits
.textures
= min(MAX_TEXTURES
, gl_max
);
2428 TRACE_(d3d_caps
)("Max textures: %d.\n", gl_info
->limits
.textures
);
2430 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2433 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2434 gl_info
->limits
.fragment_samplers
= min(MAX_FRAGMENT_SAMPLERS
, tmp
);
2438 gl_info
->limits
.fragment_samplers
= max(gl_info
->limits
.fragment_samplers
, gl_max
);
2440 TRACE_(d3d_caps
)("Max fragment samplers: %d.\n", gl_info
->limits
.fragment_samplers
);
2442 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2445 glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2446 gl_info
->limits
.vertex_samplers
= tmp
;
2447 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2448 gl_info
->limits
.combined_samplers
= tmp
;
2450 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2451 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2452 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2453 * shader is used with fixed function vertex processing we're fine too because fixed function
2454 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2455 * used we have to make sure that all vertex sampler setups are valid together with all
2456 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2457 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2458 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2459 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2460 * a fixed function pipeline anymore.
2462 * So this is just a check to check that our assumption holds true. If not, write a warning
2463 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2464 if (gl_info
->limits
.vertex_samplers
&& gl_info
->limits
.combined_samplers
< 12
2465 && MAX_TEXTURES
+ gl_info
->limits
.vertex_samplers
> gl_info
->limits
.combined_samplers
)
2467 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2468 gl_info
->limits
.vertex_samplers
, gl_info
->limits
.combined_samplers
);
2469 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2470 if (gl_info
->limits
.combined_samplers
> MAX_TEXTURES
)
2471 gl_info
->limits
.vertex_samplers
= gl_info
->limits
.combined_samplers
- MAX_TEXTURES
;
2473 gl_info
->limits
.vertex_samplers
= 0;
2478 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
;
2480 TRACE_(d3d_caps
)("Max vertex samplers: %u.\n", gl_info
->limits
.vertex_samplers
);
2481 TRACE_(d3d_caps
)("Max combined samplers: %u.\n", gl_info
->limits
.combined_samplers
);
2483 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
2485 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
2486 gl_info
->limits
.blends
= gl_max
;
2487 TRACE_(d3d_caps
)("Max blends: %u.\n", gl_info
->limits
.blends
);
2489 if (gl_info
->supported
[EXT_TEXTURE3D
])
2491 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT
, &gl_max
);
2492 gl_info
->limits
.texture3d_size
= gl_max
;
2493 TRACE_(d3d_caps
)("Max texture3D size: %d.\n", gl_info
->limits
.texture3d_size
);
2495 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
2497 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
2498 gl_info
->limits
.anisotropy
= gl_max
;
2499 TRACE_(d3d_caps
)("Max anisotropy: %d.\n", gl_info
->limits
.anisotropy
);
2501 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2503 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2504 gl_info
->limits
.arb_ps_float_constants
= gl_max
;
2505 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_ps_float_constants
);
2506 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2507 gl_info
->limits
.arb_ps_native_constants
= gl_max
;
2508 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2509 gl_info
->limits
.arb_ps_native_constants
);
2510 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2511 gl_info
->limits
.arb_ps_temps
= gl_max
;
2512 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_ps_temps
);
2513 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2514 gl_info
->limits
.arb_ps_instructions
= gl_max
;
2515 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2516 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, &gl_max
));
2517 gl_info
->limits
.arb_ps_local_constants
= gl_max
;
2518 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2520 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
])
2522 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2523 gl_info
->limits
.arb_vs_float_constants
= gl_max
;
2524 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_vs_float_constants
);
2525 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2526 gl_info
->limits
.arb_vs_native_constants
= gl_max
;
2527 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2528 gl_info
->limits
.arb_vs_native_constants
);
2529 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2530 gl_info
->limits
.arb_vs_temps
= gl_max
;
2531 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_vs_temps
);
2532 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2533 gl_info
->limits
.arb_vs_instructions
= gl_max
;
2534 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_vs_instructions
);
2536 if (test_arb_vs_offset_limit(gl_info
)) gl_info
->quirks
|= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
;
2538 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2540 glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2541 gl_info
->limits
.glsl_vs_float_constants
= gl_max
/ 4;
2542 TRACE_(d3d_caps
)("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info
->limits
.glsl_vs_float_constants
);
2544 if (gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2546 glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2547 gl_info
->limits
.glsl_ps_float_constants
= gl_max
/ 4;
2548 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info
->limits
.glsl_ps_float_constants
);
2549 glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB
, &gl_max
);
2550 gl_info
->limits
.glsl_varyings
= gl_max
;
2551 TRACE_(d3d_caps
)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max
, gl_max
/ 4);
2553 if (gl_info
->supported
[ARB_SHADING_LANGUAGE_100
])
2555 const char *str
= (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB
);
2556 unsigned int major
, minor
;
2558 TRACE_(d3d_caps
)("GLSL version string: %s.\n", debugstr_a(str
));
2560 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2561 sscanf(str
, "%u.%u", &major
, &minor
);
2562 gl_info
->glsl_version
= MAKEDWORD_VERSION(major
, minor
);
2564 if (gl_info
->supported
[NV_LIGHT_MAX_EXPONENT
])
2566 glGetFloatv(GL_MAX_SHININESS_NV
, &gl_info
->limits
.shininess
);
2570 gl_info
->limits
.shininess
= 128.0f
;
2572 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
2574 /* If we have full NP2 texture support, disable
2575 * GL_ARB_texture_rectangle because we will never use it.
2576 * This saves a few redundant glDisable calls. */
2577 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = FALSE
;
2579 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
2581 /* Disable NV_register_combiners and fragment shader if this is supported.
2582 * generally the NV extensions are preferred over the ATI ones, and this
2583 * extension is disabled if register_combiners and texture_shader2 are both
2584 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2585 * fragment processing support. */
2586 gl_info
->supported
[NV_REGISTER_COMBINERS
] = FALSE
;
2587 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = FALSE
;
2588 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
2589 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
2591 if (gl_info
->supported
[NV_HALF_FLOAT
])
2593 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2594 gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
] = TRUE
;
2596 checkGLcall("extension detection");
2600 adapter
->fragment_pipe
= select_fragment_implementation(gl_info
);
2601 adapter
->shader_backend
= select_shader_backend(gl_info
);
2602 adapter
->blitter
= select_blit_implementation(gl_info
);
2604 adapter
->fragment_pipe
->get_caps(gl_info
, &fragment_caps
);
2605 gl_info
->limits
.texture_stages
= fragment_caps
.MaxTextureBlendStages
;
2606 TRACE_(d3d_caps
)("Max texture stages: %u.\n", gl_info
->limits
.texture_stages
);
2608 /* In some cases the number of texture stages can be larger than the number
2609 * of samplers. The GF4 for example can use only 2 samplers (no fragment
2610 * shaders), but 8 texture stages (register combiners). */
2611 gl_info
->limits
.sampler_stages
= max(gl_info
->limits
.fragment_samplers
, gl_info
->limits
.texture_stages
);
2613 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
2615 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbuffer
;
2616 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbuffer
;
2617 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffers
;
2618 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffers
;
2619 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorage
;
2620 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisample
;
2621 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameteriv
;
2622 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebuffer
;
2623 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebuffer
;
2624 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffers
;
2625 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffers
;
2626 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatus
;
2627 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1D
;
2628 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2D
;
2629 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3D
;
2630 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbuffer
;
2631 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameteriv
;
2632 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebuffer
;
2633 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmap
;
2637 if (gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
2639 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbufferEXT
;
2640 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbufferEXT
;
2641 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffersEXT
;
2642 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffersEXT
;
2643 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorageEXT
;
2644 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameterivEXT
;
2645 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebufferEXT
;
2646 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebufferEXT
;
2647 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffersEXT
;
2648 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffersEXT
;
2649 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatusEXT
;
2650 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1DEXT
;
2651 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2DEXT
;
2652 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3DEXT
;
2653 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbufferEXT
;
2654 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameterivEXT
;
2655 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmapEXT
;
2657 else if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2659 WARN_(d3d_caps
)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
2660 wined3d_settings
.offscreen_rendering_mode
= ORM_BACKBUFFER
;
2662 if (gl_info
->supported
[EXT_FRAMEBUFFER_BLIT
])
2664 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebufferEXT
;
2666 if (gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
2668 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisampleEXT
;
2672 /* MRTs are currently only supported when FBOs are used. */
2673 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
2675 gl_info
->limits
.buffers
= 1;
2678 gl_vendor
= wined3d_guess_gl_vendor(gl_info
, gl_vendor_str
, gl_renderer_str
);
2679 card_vendor
= wined3d_guess_card_vendor(gl_vendor_str
, gl_renderer_str
);
2680 TRACE_(d3d_caps
)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str
), gl_vendor
, card_vendor
);
2682 device
= wined3d_guess_card(gl_info
, gl_renderer_str
, &gl_vendor
, &card_vendor
);
2683 TRACE_(d3d_caps
)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor
, device
);
2685 gl_info
->wrap_lookup
[WINED3DTADDRESS_WRAP
- WINED3DTADDRESS_WRAP
] = GL_REPEAT
;
2686 gl_info
->wrap_lookup
[WINED3DTADDRESS_MIRROR
- WINED3DTADDRESS_WRAP
] =
2687 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] ? GL_MIRRORED_REPEAT_ARB
: GL_REPEAT
;
2688 gl_info
->wrap_lookup
[WINED3DTADDRESS_CLAMP
- WINED3DTADDRESS_WRAP
] = GL_CLAMP_TO_EDGE
;
2689 gl_info
->wrap_lookup
[WINED3DTADDRESS_BORDER
- WINED3DTADDRESS_WRAP
] =
2690 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] ? GL_CLAMP_TO_BORDER_ARB
: GL_REPEAT
;
2691 gl_info
->wrap_lookup
[WINED3DTADDRESS_MIRRORONCE
- WINED3DTADDRESS_WRAP
] =
2692 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] ? GL_MIRROR_CLAMP_TO_EDGE_ATI
: GL_REPEAT
;
2694 /* Make sure there's an active HDC else the WGL extensions will fail */
2695 hdc
= pwglGetCurrentDC();
2697 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox */
2698 if(GL_EXTCALL(wglGetExtensionsStringARB
))
2699 WGL_Extensions
= GL_EXTCALL(wglGetExtensionsStringARB(hdc
));
2701 if (!WGL_Extensions
)
2703 ERR(" WGL_Extensions returns NULL\n");
2707 TRACE_(d3d_caps
)("WGL_Extensions reported:\n");
2708 while (*WGL_Extensions
)
2713 while (isspace(*WGL_Extensions
)) WGL_Extensions
++;
2714 Start
= WGL_Extensions
;
2715 while (!isspace(*WGL_Extensions
) && *WGL_Extensions
) ++WGL_Extensions
;
2717 len
= WGL_Extensions
- Start
;
2718 if (!len
|| len
>= sizeof(ThisExtn
))
2721 memcpy(ThisExtn
, Start
, len
);
2722 ThisExtn
[len
] = '\0';
2723 TRACE_(d3d_caps
)("- %s\n", debugstr_a(ThisExtn
));
2725 if (!strcmp(ThisExtn
, "WGL_ARB_pixel_format")) {
2726 gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
] = TRUE
;
2727 TRACE_(d3d_caps
)("FOUND: WGL_ARB_pixel_format support\n");
2729 if (!strcmp(ThisExtn
, "WGL_EXT_swap_control")) {
2730 gl_info
->supported
[WGL_EXT_SWAP_CONTROL
] = TRUE
;
2731 TRACE_(d3d_caps
)("FOUND: WGL_EXT_swap_control support\n");
2733 if (!strcmp(ThisExtn
, "WGL_WINE_pixel_format_passthrough")) {
2734 gl_info
->supported
[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
] = TRUE
;
2735 TRACE_(d3d_caps
)("FOUND: WGL_WINE_pixel_format_passthrough support\n");
2741 fixup_extensions(gl_info
, gl_renderer_str
, gl_vendor
, card_vendor
, device
);
2742 init_driver_info(driver_info
, card_vendor
, device
);
2743 add_gl_compat_wrappers(gl_info
);
2748 UINT CDECL
wined3d_get_adapter_count(const struct wined3d
*wined3d
)
2750 TRACE_(d3d_caps
)("wined3d %p, reporting %u adapters.\n",
2751 wined3d
, wined3d
->adapter_count
);
2753 return wined3d
->adapter_count
;
2756 HRESULT CDECL
wined3d_register_software_device(struct wined3d
*wined3d
, void *init_function
)
2758 FIXME("wined3d %p, init_function %p stub!\n", wined3d
, init_function
);
2763 HMONITOR CDECL
wined3d_get_adapter_monitor(const struct wined3d
*wined3d
, UINT adapter_idx
)
2765 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u.\n", wined3d
, adapter_idx
);
2767 if (adapter_idx
>= wined3d
->adapter_count
)
2770 return MonitorFromPoint(wined3d
->adapters
[adapter_idx
].monitorPoint
, MONITOR_DEFAULTTOPRIMARY
);
2773 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2774 of the same bpp but different resolutions */
2776 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2777 UINT CDECL
wined3d_get_adapter_mode_count(const struct wined3d
*wined3d
, UINT adapter_idx
,
2778 enum wined3d_format_id format_id
)
2780 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s.\n", wined3d
, adapter_idx
, debug_d3dformat(format_id
));
2782 if (adapter_idx
>= wined3d
->adapter_count
)
2785 /* TODO: Store modes per adapter and read it from the adapter structure */
2788 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2789 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2794 memset(&mode
, 0, sizeof(mode
));
2795 mode
.dmSize
= sizeof(mode
);
2797 while (EnumDisplaySettingsExW(NULL
, j
, &mode
, 0))
2801 if (format_id
== WINED3DFMT_UNKNOWN
)
2803 /* This is for D3D8, do not enumerate P8 here */
2804 if (mode
.dmBitsPerPel
== 32 || mode
.dmBitsPerPel
== 16) ++i
;
2806 else if (mode
.dmBitsPerPel
== format_bits
)
2812 TRACE_(d3d_caps
)("Returning %u matching modes (out of %u total) for adapter %u.\n", i
, j
, adapter_idx
);
2818 FIXME_(d3d_caps
)("Adapter not primary display.\n");
2824 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2825 HRESULT CDECL
wined3d_enum_adapter_modes(const struct wined3d
*wined3d
, UINT adapter_idx
,
2826 enum wined3d_format_id format_id
, UINT mode_idx
, WINED3DDISPLAYMODE
*mode
)
2828 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n",
2829 wined3d
, adapter_idx
, debug_d3dformat(format_id
), mode_idx
, mode
);
2831 /* Validate the parameters as much as possible */
2832 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
2833 || mode_idx
>= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, format_id
))
2835 return WINED3DERR_INVALIDCALL
;
2838 /* TODO: Store modes per adapter and read it from the adapter structure */
2841 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2842 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2848 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
2849 DevModeW
.dmSize
= sizeof(DevModeW
);
2851 /* If we are filtering to a specific format (D3D9), then need to skip
2852 all unrelated modes, but if mode is irrelevant (D3D8), then we can
2853 just count through the ones with valid bit depths */
2854 while (i
<= mode_idx
&& EnumDisplaySettingsExW(NULL
, j
++, &DevModeW
, 0))
2856 if (format_id
== WINED3DFMT_UNKNOWN
)
2858 /* This is for D3D8, do not enumerate P8 here */
2859 if (DevModeW
.dmBitsPerPel
== 32 || DevModeW
.dmBitsPerPel
== 16) ++i
;
2861 else if (DevModeW
.dmBitsPerPel
== format_bits
)
2869 TRACE_(d3d_caps
)("No modes found for format (%x - %s)\n", format_id
, debug_d3dformat(format_id
));
2870 return WINED3DERR_INVALIDCALL
;
2874 /* Now get the display mode via the calculated index */
2875 if (EnumDisplaySettingsExW(NULL
, ModeIdx
, &DevModeW
, 0))
2877 mode
->Width
= DevModeW
.dmPelsWidth
;
2878 mode
->Height
= DevModeW
.dmPelsHeight
;
2879 mode
->RefreshRate
= DEFAULT_REFRESH_RATE
;
2880 if (DevModeW
.dmFields
& DM_DISPLAYFREQUENCY
)
2881 mode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
2883 if (format_id
== WINED3DFMT_UNKNOWN
)
2884 mode
->Format
= pixelformat_for_depth(DevModeW
.dmBitsPerPel
);
2886 mode
->Format
= format_id
;
2890 TRACE_(d3d_caps
)("Requested mode %u out of range.\n", mode_idx
);
2891 return WINED3DERR_INVALIDCALL
;
2894 TRACE_(d3d_caps
)("W %d H %d rr %d fmt (%x - %s) bpp %u\n",
2895 mode
->Width
, mode
->Height
, mode
->RefreshRate
, mode
->Format
,
2896 debug_d3dformat(mode
->Format
), DevModeW
.dmBitsPerPel
);
2900 FIXME_(d3d_caps
)("Adapter not primary display\n");
2906 HRESULT CDECL
wined3d_get_adapter_display_mode(const struct wined3d
*wined3d
, UINT adapter_idx
,
2907 WINED3DDISPLAYMODE
*mode
)
2909 TRACE("wined3d %p, adapter_idx %u, display_mode %p.\n", wined3d
, adapter_idx
, mode
);
2911 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
)
2912 return WINED3DERR_INVALIDCALL
;
2919 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
2920 DevModeW
.dmSize
= sizeof(DevModeW
);
2922 EnumDisplaySettingsExW(NULL
, ENUM_CURRENT_SETTINGS
, &DevModeW
, 0);
2923 mode
->Width
= DevModeW
.dmPelsWidth
;
2924 mode
->Height
= DevModeW
.dmPelsHeight
;
2925 bpp
= DevModeW
.dmBitsPerPel
;
2926 mode
->RefreshRate
= DEFAULT_REFRESH_RATE
;
2927 if (DevModeW
.dmFields
&DM_DISPLAYFREQUENCY
)
2928 mode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
2929 mode
->Format
= pixelformat_for_depth(bpp
);
2933 FIXME_(d3d_caps
)("Adapter not primary display\n");
2936 TRACE_(d3d_caps
)("returning w:%d, h:%d, ref:%d, fmt:%s\n", mode
->Width
,
2937 mode
->Height
, mode
->RefreshRate
, debug_d3dformat(mode
->Format
));
2941 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
2942 and fields being inserted in the middle, a new structure is used in place */
2943 HRESULT CDECL
wined3d_get_adapter_identifier(const struct wined3d
*wined3d
,
2944 UINT adapter_idx
, DWORD flags
, WINED3DADAPTER_IDENTIFIER
*identifier
)
2946 const struct wined3d_adapter
*adapter
;
2949 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, flags %#x, indentifier %p.\n",
2950 wined3d
, adapter_idx
, flags
, identifier
);
2952 if (adapter_idx
>= wined3d
->adapter_count
)
2953 return WINED3DERR_INVALIDCALL
;
2955 adapter
= &wined3d
->adapters
[adapter_idx
];
2957 /* Return the information requested */
2958 TRACE_(d3d_caps
)("device/Vendor Name and Version detection using FillGLCaps\n");
2960 if (identifier
->driver_size
)
2962 const char *name
= adapter
->driver_info
.name
;
2963 len
= min(strlen(name
), identifier
->driver_size
- 1);
2964 memcpy(identifier
->driver
, name
, len
);
2965 identifier
->driver
[len
] = '\0';
2968 if (identifier
->description_size
)
2970 const char *description
= adapter
->driver_info
.description
;
2971 len
= min(strlen(description
), identifier
->description_size
- 1);
2972 memcpy(identifier
->description
, description
, len
);
2973 identifier
->description
[len
] = '\0';
2976 /* Note that d3d8 doesn't supply a device name. */
2977 if (identifier
->device_name_size
)
2979 static const char *device_name
= "\\\\.\\DISPLAY1"; /* FIXME: May depend on desktop? */
2981 len
= strlen(device_name
);
2982 if (len
>= identifier
->device_name_size
)
2984 ERR("Device name size too small.\n");
2985 return WINED3DERR_INVALIDCALL
;
2988 memcpy(identifier
->device_name
, device_name
, len
);
2989 identifier
->device_name
[len
] = '\0';
2992 identifier
->driver_version
.u
.HighPart
= adapter
->driver_info
.version_high
;
2993 identifier
->driver_version
.u
.LowPart
= adapter
->driver_info
.version_low
;
2994 identifier
->vendor_id
= adapter
->driver_info
.vendor
;
2995 identifier
->device_id
= adapter
->driver_info
.device
;
2996 identifier
->subsystem_id
= 0;
2997 identifier
->revision
= 0;
2998 memcpy(&identifier
->device_identifier
, &IID_D3DDEVICE_D3DUID
, sizeof(identifier
->device_identifier
));
2999 identifier
->whql_level
= (flags
& WINED3DENUM_NO_WHQL_LEVEL
) ? 0 : 1;
3000 memcpy(&identifier
->adapter_luid
, &adapter
->luid
, sizeof(identifier
->adapter_luid
));
3001 identifier
->video_memory
= adapter
->TextureRam
;
3006 static BOOL
wined3d_check_pixel_format_color(const struct wined3d_gl_info
*gl_info
,
3007 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3009 BYTE redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
3011 /* Float formats need FBOs. If FBOs are used this function isn't called */
3012 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3014 if(cfg
->iPixelType
== WGL_TYPE_RGBA_ARB
) { /* Integer RGBA formats */
3015 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
3017 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3021 if(cfg
->redSize
< redSize
)
3024 if(cfg
->greenSize
< greenSize
)
3027 if(cfg
->blueSize
< blueSize
)
3030 if(cfg
->alphaSize
< alphaSize
)
3036 /* Probably a RGBA_float or color index mode */
3040 static BOOL
wined3d_check_pixel_format_depth(const struct wined3d_gl_info
*gl_info
,
3041 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3043 BYTE depthSize
, stencilSize
;
3044 BOOL lockable
= FALSE
;
3046 if (!getDepthStencilBits(format
, &depthSize
, &stencilSize
))
3048 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3052 /* Float formats need FBOs. If FBOs are used this function isn't called */
3053 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3055 if ((format
->id
== WINED3DFMT_D16_LOCKABLE
) || (format
->id
== WINED3DFMT_D32_FLOAT
))
3058 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
3059 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
3060 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
3061 if(!(cfg
->depthSize
== depthSize
|| (!lockable
&& cfg
->depthSize
> depthSize
)))
3064 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
3065 * allow more stencil bits than requested. */
3066 if(cfg
->stencilSize
< stencilSize
)
3072 HRESULT CDECL
wined3d_check_depth_stencil_match(const struct wined3d
*wined3d
,
3073 UINT adapter_idx
, WINED3DDEVTYPE device_type
, enum wined3d_format_id adapter_format_id
,
3074 enum wined3d_format_id render_target_format_id
, enum wined3d_format_id depth_stencil_format_id
)
3076 const struct wined3d_format
*rt_format
;
3077 const struct wined3d_format
*ds_format
;
3078 const struct wined3d_adapter
*adapter
;
3080 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s,\n"
3081 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
3082 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3083 debug_d3dformat(render_target_format_id
), debug_d3dformat(depth_stencil_format_id
));
3085 if (adapter_idx
>= wined3d
->adapter_count
)
3086 return WINED3DERR_INVALIDCALL
;
3088 adapter
= &wined3d
->adapters
[adapter_idx
];
3089 rt_format
= wined3d_get_format(&adapter
->gl_info
, render_target_format_id
);
3090 ds_format
= wined3d_get_format(&adapter
->gl_info
, depth_stencil_format_id
);
3091 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3093 if ((rt_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3094 && (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)))
3096 TRACE_(d3d_caps
)("Formats match.\n");
3102 const struct wined3d_pixel_format
*cfgs
;
3103 unsigned int cfg_count
;
3106 cfgs
= adapter
->cfgs
;
3107 cfg_count
= adapter
->nCfgs
;
3108 for (i
= 0; i
< cfg_count
; ++i
)
3110 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], rt_format
)
3111 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, &cfgs
[i
], ds_format
))
3113 TRACE_(d3d_caps
)("Formats match.\n");
3119 TRACE_(d3d_caps
)("Unsupported format pair: %s and %s.\n",
3120 debug_d3dformat(render_target_format_id
),
3121 debug_d3dformat(depth_stencil_format_id
));
3123 return WINED3DERR_NOTAVAILABLE
;
3126 HRESULT CDECL
wined3d_check_device_multisample_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
3127 WINED3DDEVTYPE device_type
, enum wined3d_format_id surface_format_id
, BOOL windowed
,
3128 WINED3DMULTISAMPLE_TYPE multisample_type
, DWORD
*quality_levels
)
3130 const struct wined3d_adapter
*adapter
;
3131 const struct wined3d_format
*format
;
3133 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
3134 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
3135 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(surface_format_id
),
3136 windowed
, multisample_type
, quality_levels
);
3138 if (adapter_idx
>= wined3d
->adapter_count
)
3139 return WINED3DERR_INVALIDCALL
;
3141 /* TODO: Handle windowed, add more quality levels. */
3143 if (WINED3DMULTISAMPLE_NONE
== multisample_type
)
3145 if (quality_levels
) *quality_levels
= 1;
3149 /* By default multisampling is disabled right now as it causes issues
3150 * on some Nvidia driver versions and it doesn't work well in combination
3152 if (!wined3d_settings
.allow_multisampling
)
3153 return WINED3DERR_NOTAVAILABLE
;
3155 adapter
= &wined3d
->adapters
[adapter_idx
];
3156 format
= wined3d_get_format(&adapter
->gl_info
, surface_format_id
);
3157 if (!format
) return WINED3DERR_INVALIDCALL
;
3159 if (format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
))
3161 const struct wined3d_pixel_format
*cfgs
;
3162 unsigned int i
, cfg_count
;
3164 cfgs
= adapter
->cfgs
;
3165 cfg_count
= adapter
->nCfgs
;
3166 for (i
= 0; i
< cfg_count
; ++i
)
3168 if(cfgs
[i
].numSamples
!= multisample_type
)
3171 if (!wined3d_check_pixel_format_depth(&adapter
->gl_info
, &cfgs
[i
], format
))
3174 TRACE("Found pixel format %u to support multisample_type %#x for format %s.\n",
3175 cfgs
[i
].iPixelFormat
, multisample_type
, debug_d3dformat(surface_format_id
));
3177 if (quality_levels
) *quality_levels
= 1;
3182 else if (format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3184 BYTE redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
3185 const struct wined3d_pixel_format
*cfgs
;
3186 unsigned int i
, cfg_count
;
3188 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
3190 ERR("Unable to get color bits for format %s, can't check multisampling capability.\n",
3191 debug_d3dformat(surface_format_id
));
3192 return WINED3DERR_NOTAVAILABLE
;
3195 cfgs
= adapter
->cfgs
;
3196 cfg_count
= adapter
->nCfgs
;
3197 for (i
= 0; i
< cfg_count
; ++i
)
3199 if(cfgs
[i
].numSamples
!= multisample_type
)
3201 if(cfgs
[i
].redSize
!= redSize
)
3203 if(cfgs
[i
].greenSize
!= greenSize
)
3205 if(cfgs
[i
].blueSize
!= blueSize
)
3207 /* Not all drivers report alpha-less formats since they use 32-bit
3208 * anyway, so accept alpha even if we didn't ask for it. */
3209 if(alphaSize
&& cfgs
[i
].alphaSize
!= alphaSize
)
3211 if (cfgs
[i
].colorSize
!= (format
->byte_count
<< 3))
3214 TRACE("Found pixel format %u to support multisample_type %#x for format %s.\n",
3215 cfgs
[i
].iPixelFormat
, multisample_type
, debug_d3dformat(surface_format_id
));
3217 if (quality_levels
) *quality_levels
= 1;
3222 return WINED3DERR_NOTAVAILABLE
;
3225 /* Check if we support bumpmapping for a format */
3226 static BOOL
CheckBumpMapCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3228 /* Ask the fixed function pipeline implementation if it can deal
3229 * with the conversion. If we've got a GL extension giving native
3230 * support this will be an identity conversion. */
3231 return (format
->flags
& WINED3DFMT_FLAG_BUMPMAP
)
3232 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
);
3235 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
3236 static BOOL
CheckDepthStencilCapability(const struct wined3d_adapter
*adapter
,
3237 const struct wined3d_format
*display_format
, const struct wined3d_format
*ds_format
)
3241 /* Only allow depth/stencil formats */
3242 if (!(ds_format
->depth_size
|| ds_format
->stencil_size
)) return FALSE
;
3244 /* Blacklist formats not supported on Windows */
3245 switch (ds_format
->id
)
3247 case WINED3DFMT_S1_UINT_D15_UNORM
: /* Breaks the shadowvol2 dx7 sdk sample */
3248 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3249 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3256 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3258 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
3259 if (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)) return TRUE
;
3263 /* Walk through all WGL pixel formats to find a match */
3264 for (it
= 0; it
< adapter
->nCfgs
; ++it
)
3266 const struct wined3d_pixel_format
*cfg
= &adapter
->cfgs
[it
];
3267 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, cfg
, display_format
)
3268 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, cfg
, ds_format
))
3276 static BOOL
CheckFilterCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3278 /* The flags entry of a format contains the filtering capability */
3279 if (format
->flags
& WINED3DFMT_FLAG_FILTERING
) return TRUE
;
3284 /* Check the render target capabilities of a format */
3285 static BOOL
CheckRenderTargetCapability(const struct wined3d_adapter
*adapter
,
3286 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*check_format
)
3288 /* Filter out non-RT formats */
3289 if (!(check_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)) return FALSE
;
3290 if (wined3d_settings
.offscreen_rendering_mode
== ORM_BACKBUFFER
)
3292 BYTE AdapterRed
, AdapterGreen
, AdapterBlue
, AdapterAlpha
, AdapterTotalSize
;
3293 BYTE CheckRed
, CheckGreen
, CheckBlue
, CheckAlpha
, CheckTotalSize
;
3294 const struct wined3d_pixel_format
*cfgs
= adapter
->cfgs
;
3297 getColorBits(adapter_format
, &AdapterRed
, &AdapterGreen
, &AdapterBlue
, &AdapterAlpha
, &AdapterTotalSize
);
3298 getColorBits(check_format
, &CheckRed
, &CheckGreen
, &CheckBlue
, &CheckAlpha
, &CheckTotalSize
);
3300 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
3301 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
3302 if(!((AdapterRed
== CheckRed
) && (AdapterGreen
== CheckGreen
) && (AdapterBlue
== CheckBlue
))) {
3303 TRACE_(d3d_caps
)("[FAILED]\n");
3307 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
3308 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
3309 for (it
= 0; it
< adapter
->nCfgs
; ++it
)
3311 if (cfgs
[it
].windowDrawable
3312 && wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[it
], check_format
))
3314 TRACE_(d3d_caps
)("Pixel format %d is compatible with format %s.\n",
3315 cfgs
[it
].iPixelFormat
, debug_d3dformat(check_format
->id
));
3320 else if(wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3322 /* For now return TRUE for FBOs until we have some proper checks.
3323 * Note that this function will only be called when the format is around for texturing. */
3329 static BOOL
CheckSrgbReadCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3331 return format
->flags
& WINED3DFMT_FLAG_SRGB_READ
;
3334 static BOOL
CheckSrgbWriteCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3336 /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
3337 * doing the color fixup in shaders.
3338 * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
3339 if (format
->flags
& WINED3DFMT_FLAG_SRGB_WRITE
)
3341 int vs_selected_mode
;
3342 int ps_selected_mode
;
3343 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
3345 if((ps_selected_mode
== SHADER_ARB
) || (ps_selected_mode
== SHADER_GLSL
)) {
3346 TRACE_(d3d_caps
)("[OK]\n");
3351 TRACE_(d3d_caps
)("[FAILED] - sRGB writes not supported by format %s.\n", debug_d3dformat(format
->id
));
3355 /* Check if a format support blending in combination with pixel shaders */
3356 static BOOL
CheckPostPixelShaderBlendingCapability(const struct wined3d_adapter
*adapter
,
3357 const struct wined3d_format
*format
)
3359 /* The flags entry of a format contains the post pixel shader blending capability */
3360 if (format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
) return TRUE
;
3365 static BOOL
CheckWrapAndMipCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3367 /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
3368 * but we have to report mipmapping so we cannot reject this flag. Tests show that
3369 * windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to show
3370 * that wrapping is supported. The lack of filtering will sort out the mipmapping
3371 * capability anyway.
3373 * For now lets report this on all formats, but in the future we may want to
3374 * restrict it to some should games need that
3379 /* Check if a texture format is supported on the given adapter */
3380 static BOOL
CheckTextureCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3382 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3387 * supported: RGB(A) formats
3389 case WINED3DFMT_B8G8R8_UNORM
: /* Enable for dx7, blacklisted for 8 and 9 above */
3390 case WINED3DFMT_B8G8R8A8_UNORM
:
3391 case WINED3DFMT_B8G8R8X8_UNORM
:
3392 case WINED3DFMT_B5G6R5_UNORM
:
3393 case WINED3DFMT_B5G5R5X1_UNORM
:
3394 case WINED3DFMT_B5G5R5A1_UNORM
:
3395 case WINED3DFMT_B4G4R4A4_UNORM
:
3396 case WINED3DFMT_A8_UNORM
:
3397 case WINED3DFMT_B4G4R4X4_UNORM
:
3398 case WINED3DFMT_R8G8B8A8_UNORM
:
3399 case WINED3DFMT_R8G8B8X8_UNORM
:
3400 case WINED3DFMT_B10G10R10A2_UNORM
:
3401 case WINED3DFMT_R10G10B10A2_UNORM
:
3402 case WINED3DFMT_R16G16_UNORM
:
3403 TRACE_(d3d_caps
)("[OK]\n");
3406 case WINED3DFMT_B2G3R3_UNORM
:
3407 TRACE_(d3d_caps
)("[FAILED] - Not supported on Windows\n");
3411 * Not supported: Palettized
3412 * Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of <=Direct3D7.
3413 * Since it is not widely available, don't offer it. Further no Windows driver offers
3414 * WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
3416 case WINED3DFMT_P8_UINT
:
3417 case WINED3DFMT_P8_UINT_A8_UNORM
:
3421 * Supported: (Alpha)-Luminance
3423 case WINED3DFMT_L8_UNORM
:
3424 case WINED3DFMT_L8A8_UNORM
:
3425 case WINED3DFMT_L16_UNORM
:
3426 TRACE_(d3d_caps
)("[OK]\n");
3429 /* Not supported on Windows, thus disabled */
3430 case WINED3DFMT_L4A4_UNORM
:
3431 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3435 * Supported: Depth/Stencil formats
3437 case WINED3DFMT_D16_LOCKABLE
:
3438 case WINED3DFMT_D16_UNORM
:
3439 case WINED3DFMT_X8D24_UNORM
:
3440 case WINED3DFMT_D24_UNORM_S8_UINT
:
3441 case WINED3DFMT_S8_UINT_D24_FLOAT
:
3442 case WINED3DFMT_D32_UNORM
:
3443 case WINED3DFMT_D32_FLOAT
:
3446 case WINED3DFMT_INTZ
:
3447 if (gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
]
3448 || gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3452 /* Not supported on Windows */
3453 case WINED3DFMT_S1_UINT_D15_UNORM
:
3454 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3455 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3459 * Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
3460 * GL_NV_texture_shader). Emulated by shaders
3462 case WINED3DFMT_R8G8_SNORM
:
3463 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
3464 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
3465 case WINED3DFMT_R8G8B8A8_SNORM
:
3466 case WINED3DFMT_R16G16_SNORM
:
3467 /* Ask the shader backend if it can deal with the conversion. If
3468 * we've got a GL extension giving native support this will be an
3469 * identity conversion. */
3470 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
))
3472 TRACE_(d3d_caps
)("[OK]\n");
3475 TRACE_(d3d_caps
)("[FAILED]\n");
3478 case WINED3DFMT_DXT1
:
3479 case WINED3DFMT_DXT2
:
3480 case WINED3DFMT_DXT3
:
3481 case WINED3DFMT_DXT4
:
3482 case WINED3DFMT_DXT5
:
3483 if (gl_info
->supported
[EXT_TEXTURE_COMPRESSION_S3TC
])
3485 TRACE_(d3d_caps
)("[OK]\n");
3488 TRACE_(d3d_caps
)("[FAILED]\n");
3493 * Odd formats - not supported
3495 case WINED3DFMT_VERTEXDATA
:
3496 case WINED3DFMT_R16_UINT
:
3497 case WINED3DFMT_R32_UINT
:
3498 case WINED3DFMT_R16G16B16A16_SNORM
:
3499 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM
:
3500 case WINED3DFMT_R10G11B11_SNORM
:
3501 case WINED3DFMT_R16
:
3502 case WINED3DFMT_AL16
:
3503 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3507 * WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
3509 case WINED3DFMT_R8G8_SNORM_Cx
:
3510 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3514 case WINED3DFMT_UYVY
:
3515 case WINED3DFMT_YUY2
:
3516 if (gl_info
->supported
[APPLE_YCBCR_422
])
3518 TRACE_(d3d_caps
)("[OK]\n");
3521 TRACE_(d3d_caps
)("[FAILED]\n");
3523 case WINED3DFMT_YV12
:
3524 TRACE_(d3d_caps
)("[FAILED]\n");
3527 case WINED3DFMT_R16G16B16A16_UNORM
:
3528 if (gl_info
->quirks
& WINED3D_QUIRK_BROKEN_RGBA16
)
3530 TRACE_(d3d_caps
)("[FAILED]\n");
3533 TRACE_(d3d_caps
)("[OK]\n");
3537 case WINED3DFMT_B2G3R3A8_UNORM
:
3538 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3541 /* Floating point formats */
3542 case WINED3DFMT_R16_FLOAT
:
3543 case WINED3DFMT_R16G16_FLOAT
:
3544 case WINED3DFMT_R16G16B16A16_FLOAT
:
3545 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
] && gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
3547 TRACE_(d3d_caps
)("[OK]\n");
3550 TRACE_(d3d_caps
)("[FAILED]\n");
3553 case WINED3DFMT_R32_FLOAT
:
3554 case WINED3DFMT_R32G32_FLOAT
:
3555 case WINED3DFMT_R32G32B32A32_FLOAT
:
3556 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
])
3558 TRACE_(d3d_caps
)("[OK]\n");
3561 TRACE_(d3d_caps
)("[FAILED]\n");
3564 /* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
3565 * instancing. To query if the card supports instancing CheckDeviceFormat with the special format
3566 * MAKEFOURCC('I','N','S','T') is used. Should a (broken) app check for this provide a proper return value.
3567 * We can do instancing with all shader versions, but we need vertex shaders.
3569 * Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC('I','N','S','T') once
3570 * to enable instancing. WineD3D doesn't need that and just ignores it.
3572 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows.
3574 case WINED3DFMT_INST
:
3575 TRACE("ATI Instancing check hack\n");
3576 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_VERTEX_SHADER
])
3578 TRACE_(d3d_caps
)("[OK]\n");
3581 TRACE_(d3d_caps
)("[FAILED]\n");
3584 /* Some weird FOURCC formats */
3585 case WINED3DFMT_R8G8_B8G8
:
3586 case WINED3DFMT_G8R8_G8B8
:
3587 case WINED3DFMT_MULTI2_ARGB8
:
3588 TRACE_(d3d_caps
)("[FAILED]\n");
3591 /* Vendor specific formats */
3592 case WINED3DFMT_ATI2N
:
3593 if (gl_info
->supported
[ATI_TEXTURE_COMPRESSION_3DC
]
3594 || gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
])
3596 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
)
3597 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
))
3599 TRACE_(d3d_caps
)("[OK]\n");
3603 TRACE_(d3d_caps
)("[OK]\n");
3606 TRACE_(d3d_caps
)("[FAILED]\n");
3609 /* Depth bound test. To query if the card supports it CheckDeviceFormat with the special
3610 * format MAKEFOURCC('N','V','D','B') is used.
3611 * It is enabled by setting D3DRS_ADAPTIVETESS_X render state to MAKEFOURCC('N','V','D','B') and
3612 * then controlled by setting D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax)
3615 case WINED3DFMT_NVDB
:
3616 if (gl_info
->supported
[EXT_DEPTH_BOUNDS_TEST
])
3618 TRACE_(d3d_caps
)("[OK]\n");
3621 TRACE_(d3d_caps
)("[FAILED]\n");
3624 case WINED3DFMT_NVHU
:
3625 case WINED3DFMT_NVHS
:
3626 /* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
3627 * is said to be GL_UNSIGNED_HILO16, NVHS GL_SIGNED_HILO16. Rumours say that d3d computes
3628 * a 3rd channel similarly to D3DFMT_CxV8U8(So NVHS could be called D3DFMT_CxV16U16).
3629 * ATI refused to support formats which can easily be emulated with pixel shaders, so
3630 * Applications have to deal with not having NVHS and NVHU.
3632 TRACE_(d3d_caps
)("[FAILED]\n");
3635 case WINED3DFMT_NULL
:
3636 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3640 case WINED3DFMT_UNKNOWN
:
3644 ERR("Unhandled format %s.\n", debug_d3dformat(format
->id
));
3650 static BOOL
CheckSurfaceCapability(const struct wined3d_adapter
*adapter
,
3651 const struct wined3d_format
*adapter_format
,
3652 const struct wined3d_format
*check_format
,
3653 WINED3DSURFTYPE SurfaceType
)
3655 if (SurfaceType
== SURFACE_GDI
)
3657 switch (check_format
->id
)
3659 case WINED3DFMT_B8G8R8_UNORM
:
3660 case WINED3DFMT_B8G8R8A8_UNORM
:
3661 case WINED3DFMT_B8G8R8X8_UNORM
:
3662 case WINED3DFMT_B5G6R5_UNORM
:
3663 case WINED3DFMT_B5G5R5X1_UNORM
:
3664 case WINED3DFMT_B5G5R5A1_UNORM
:
3665 case WINED3DFMT_B4G4R4A4_UNORM
:
3666 case WINED3DFMT_B2G3R3_UNORM
:
3667 case WINED3DFMT_A8_UNORM
:
3668 case WINED3DFMT_B2G3R3A8_UNORM
:
3669 case WINED3DFMT_B4G4R4X4_UNORM
:
3670 case WINED3DFMT_R10G10B10A2_UNORM
:
3671 case WINED3DFMT_R8G8B8A8_UNORM
:
3672 case WINED3DFMT_R8G8B8X8_UNORM
:
3673 case WINED3DFMT_R16G16_UNORM
:
3674 case WINED3DFMT_B10G10R10A2_UNORM
:
3675 case WINED3DFMT_R16G16B16A16_UNORM
:
3676 case WINED3DFMT_P8_UINT
:
3677 TRACE_(d3d_caps
)("[OK]\n");
3680 TRACE_(d3d_caps
)("[FAILED] - not available on GDI surfaces\n");
3685 /* All format that are supported for textures are supported for surfaces as well */
3686 if (CheckTextureCapability(adapter
, check_format
)) return TRUE
;
3687 /* All depth stencil formats are supported on surfaces */
3688 if (CheckDepthStencilCapability(adapter
, adapter_format
, check_format
)) return TRUE
;
3690 /* If opengl can't process the format natively, the blitter may be able to convert it */
3691 if (adapter
->blitter
->blit_supported(&adapter
->gl_info
, WINED3D_BLIT_OP_COLOR_BLIT
,
3692 NULL
, WINED3DPOOL_DEFAULT
, 0, check_format
,
3693 NULL
, WINED3DPOOL_DEFAULT
, 0, adapter_format
))
3695 TRACE_(d3d_caps
)("[OK]\n");
3699 /* Reject other formats */
3700 TRACE_(d3d_caps
)("[FAILED]\n");
3704 static BOOL
CheckVertexTextureCapability(const struct wined3d_adapter
*adapter
,
3705 const struct wined3d_format
*format
)
3707 return adapter
->gl_info
.limits
.vertex_samplers
&& (format
->flags
& WINED3DFMT_FLAG_VTF
);
3710 HRESULT CDECL
wined3d_check_device_format(const struct wined3d
*wined3d
, UINT adapter_idx
,
3711 WINED3DDEVTYPE device_type
, enum wined3d_format_id adapter_format_id
, DWORD usage
,
3712 WINED3DRESOURCETYPE resource_type
, enum wined3d_format_id check_format_id
, WINED3DSURFTYPE surface_type
)
3714 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
3715 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3716 const struct wined3d_format
*adapter_format
= wined3d_get_format(gl_info
, adapter_format_id
);
3717 const struct wined3d_format
*format
= wined3d_get_format(gl_info
, check_format_id
);
3718 DWORD usage_caps
= 0;
3720 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
3721 "resource_type %s, check_format %s, surface_type %#x.\n",
3722 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3723 debug_d3dusage(usage
), debug_d3dusagequery(usage
), debug_d3dresourcetype(resource_type
),
3724 debug_d3dformat(check_format_id
), surface_type
);
3726 if (adapter_idx
>= wined3d
->adapter_count
)
3727 return WINED3DERR_INVALIDCALL
;
3729 switch (resource_type
)
3731 case WINED3DRTYPE_CUBETEXTURE
:
3732 /* Cubetexture allows:
3733 * - WINED3DUSAGE_AUTOGENMIPMAP
3734 * - WINED3DUSAGE_DEPTHSTENCIL
3735 * - WINED3DUSAGE_DYNAMIC
3736 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3737 * - WINED3DUSAGE_RENDERTARGET
3738 * - WINED3DUSAGE_SOFTWAREPROCESSING
3739 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3741 if (surface_type
!= SURFACE_OPENGL
)
3743 TRACE_(d3d_caps
)("[FAILED]\n");
3744 return WINED3DERR_NOTAVAILABLE
;
3747 if (!gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3749 TRACE_(d3d_caps
)("[FAILED] - No cube texture support\n");
3750 return WINED3DERR_NOTAVAILABLE
;
3753 if (!CheckTextureCapability(adapter
, format
))
3755 TRACE_(d3d_caps
)("[FAILED] - Cube texture format not supported\n");
3756 return WINED3DERR_NOTAVAILABLE
;
3759 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3761 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3762 /* When autogenmipmap isn't around continue and return
3763 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3764 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3766 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3769 /* Always report dynamic locking. */
3770 if (usage
& WINED3DUSAGE_DYNAMIC
)
3771 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3773 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3775 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3777 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3778 return WINED3DERR_NOTAVAILABLE
;
3780 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3783 /* Always report software processing. */
3784 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
3785 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
3787 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3789 if (!CheckFilterCapability(adapter
, format
))
3791 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
3792 return WINED3DERR_NOTAVAILABLE
;
3794 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
3797 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3799 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3801 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3802 return WINED3DERR_NOTAVAILABLE
;
3804 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3807 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
3809 if (!CheckSrgbReadCapability(adapter
, format
))
3811 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
3812 return WINED3DERR_NOTAVAILABLE
;
3814 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
3817 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
3819 if (!CheckSrgbWriteCapability(adapter
, format
))
3821 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
3822 return WINED3DERR_NOTAVAILABLE
;
3824 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
3827 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
3829 if (!CheckVertexTextureCapability(adapter
, format
))
3831 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
3832 return WINED3DERR_NOTAVAILABLE
;
3834 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
3837 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
3839 if (!CheckWrapAndMipCapability(adapter
, format
))
3841 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
3842 return WINED3DERR_NOTAVAILABLE
;
3844 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
3848 case WINED3DRTYPE_SURFACE
:
3850 * - WINED3DUSAGE_DEPTHSTENCIL
3851 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3852 * - WINED3DUSAGE_RENDERTARGET
3854 if (!CheckSurfaceCapability(adapter
, adapter_format
, format
, surface_type
))
3856 TRACE_(d3d_caps
)("[FAILED] - Not supported for plain surfaces\n");
3857 return WINED3DERR_NOTAVAILABLE
;
3860 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
3862 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
3864 TRACE_(d3d_caps
)("[FAILED] - No depthstencil support\n");
3865 return WINED3DERR_NOTAVAILABLE
;
3867 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
3870 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3872 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3874 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3875 return WINED3DERR_NOTAVAILABLE
;
3877 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3880 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3882 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3884 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3885 return WINED3DERR_NOTAVAILABLE
;
3887 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3891 case WINED3DRTYPE_TEXTURE
:
3893 * - WINED3DUSAGE_AUTOGENMIPMAP
3894 * - WINED3DUSAGE_DEPTHSTENCIL
3895 * - WINED3DUSAGE_DMAP
3896 * - WINED3DUSAGE_DYNAMIC
3897 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3898 * - WINED3DUSAGE_RENDERTARGET
3899 * - WINED3DUSAGE_SOFTWAREPROCESSING
3900 * - WINED3DUSAGE_TEXTAPI (d3d9ex)
3901 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3903 if (surface_type
!= SURFACE_OPENGL
)
3905 TRACE_(d3d_caps
)("[FAILED]\n");
3906 return WINED3DERR_NOTAVAILABLE
;
3909 if (!CheckTextureCapability(adapter
, format
))
3911 TRACE_(d3d_caps
)("[FAILED] - Texture format not supported\n");
3912 return WINED3DERR_NOTAVAILABLE
;
3915 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3917 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3918 /* When autogenmipmap isn't around continue and return
3919 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3920 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3922 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3925 /* Always report dynamic locking. */
3926 if (usage
& WINED3DUSAGE_DYNAMIC
)
3927 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3929 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3931 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3933 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3934 return WINED3DERR_NOTAVAILABLE
;
3936 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3939 /* Always report software processing. */
3940 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
3941 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
3943 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3945 if (!CheckFilterCapability(adapter
, format
))
3947 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
3948 return WINED3DERR_NOTAVAILABLE
;
3950 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
3953 if (usage
& WINED3DUSAGE_QUERY_LEGACYBUMPMAP
)
3955 if (!CheckBumpMapCapability(adapter
, format
))
3957 TRACE_(d3d_caps
)("[FAILED] - No legacy bumpmap support\n");
3958 return WINED3DERR_NOTAVAILABLE
;
3960 usage_caps
|= WINED3DUSAGE_QUERY_LEGACYBUMPMAP
;
3963 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3965 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3967 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3968 return WINED3DERR_NOTAVAILABLE
;
3970 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3973 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
3975 if (!CheckSrgbReadCapability(adapter
, format
))
3977 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
3978 return WINED3DERR_NOTAVAILABLE
;
3980 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
3983 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
3985 if (!CheckSrgbWriteCapability(adapter
, format
))
3987 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
3988 return WINED3DERR_NOTAVAILABLE
;
3990 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
3993 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
3995 if (!CheckVertexTextureCapability(adapter
, format
))
3997 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
3998 return WINED3DERR_NOTAVAILABLE
;
4000 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4003 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4005 if (!CheckWrapAndMipCapability(adapter
, format
))
4007 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
4008 return WINED3DERR_NOTAVAILABLE
;
4010 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4013 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
4015 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
4017 TRACE_(d3d_caps
)("[FAILED] - No depth stencil support\n");
4018 return WINED3DERR_NOTAVAILABLE
;
4020 if ((format
->flags
& WINED3DFMT_FLAG_SHADOW
) && !gl_info
->supported
[ARB_SHADOW
])
4022 TRACE_(d3d_caps
)("[FAILED] - No shadow sampler support.\n");
4023 return WINED3DERR_NOTAVAILABLE
;
4025 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
4029 case WINED3DRTYPE_VOLUMETEXTURE
:
4030 case WINED3DRTYPE_VOLUME
:
4031 /* Volume is to VolumeTexture what Surface is to Texture, but its
4032 * usage caps are not documented. Most driver seem to offer
4033 * (nearly) the same on Volume and VolumeTexture, so do that too.
4035 * Volumetexture allows:
4036 * - D3DUSAGE_DYNAMIC
4037 * - D3DUSAGE_NONSECURE (d3d9ex)
4038 * - D3DUSAGE_SOFTWAREPROCESSING
4039 * - D3DUSAGE_QUERY_WRAPANDMIP
4041 if (surface_type
!= SURFACE_OPENGL
)
4043 TRACE_(d3d_caps
)("[FAILED]\n");
4044 return WINED3DERR_NOTAVAILABLE
;
4047 if (!gl_info
->supported
[EXT_TEXTURE3D
])
4049 TRACE_(d3d_caps
)("[FAILED] - No volume texture support\n");
4050 return WINED3DERR_NOTAVAILABLE
;
4053 if (!CheckTextureCapability(adapter
, format
))
4055 TRACE_(d3d_caps
)("[FAILED] - Format not supported\n");
4056 return WINED3DERR_NOTAVAILABLE
;
4059 /* Filter formats that need conversion; For one part, this
4060 * conversion is unimplemented, and volume textures are huge, so
4061 * it would be a big performance hit. Unless we hit an application
4062 * needing one of those formats, don't advertize them to avoid
4063 * leading applications into temptation. The windows drivers don't
4064 * support most of those formats on volumes anyway, except for
4065 * WINED3DFMT_R32_FLOAT. */
4066 switch (check_format_id
)
4068 case WINED3DFMT_P8_UINT
:
4069 case WINED3DFMT_L4A4_UNORM
:
4070 case WINED3DFMT_R32_FLOAT
:
4071 case WINED3DFMT_R16_FLOAT
:
4072 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
4073 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
4074 case WINED3DFMT_R16G16_UNORM
:
4075 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4076 return WINED3DERR_NOTAVAILABLE
;
4078 case WINED3DFMT_R8G8B8A8_SNORM
:
4079 case WINED3DFMT_R16G16_SNORM
:
4080 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4082 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4083 return WINED3DERR_NOTAVAILABLE
;
4087 case WINED3DFMT_R8G8_SNORM
:
4088 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4090 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4091 return WINED3DERR_NOTAVAILABLE
;
4095 case WINED3DFMT_DXT1
:
4096 case WINED3DFMT_DXT2
:
4097 case WINED3DFMT_DXT3
:
4098 case WINED3DFMT_DXT4
:
4099 case WINED3DFMT_DXT5
:
4100 /* The GL_EXT_texture_compression_s3tc spec requires that
4101 * loading an s3tc compressed texture results in an error.
4102 * While the D3D refrast does support s3tc volumes, at
4103 * least the nvidia windows driver does not, so we're free
4104 * not to support this format. */
4105 TRACE_(d3d_caps
)("[FAILED] - DXTn does not support 3D textures\n");
4106 return WINED3DERR_NOTAVAILABLE
;
4109 /* Do nothing, continue with checking the format below */
4113 /* Always report dynamic locking. */
4114 if (usage
& WINED3DUSAGE_DYNAMIC
)
4115 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
4117 /* Always report software processing. */
4118 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
4119 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
4121 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
4123 if (!CheckFilterCapability(adapter
, format
))
4125 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
4126 return WINED3DERR_NOTAVAILABLE
;
4128 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
4131 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4133 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4135 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
4136 return WINED3DERR_NOTAVAILABLE
;
4138 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4141 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4143 if (!CheckSrgbReadCapability(adapter
, format
))
4145 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
4146 return WINED3DERR_NOTAVAILABLE
;
4148 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4151 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4153 if (!CheckSrgbWriteCapability(adapter
, format
))
4155 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
4156 return WINED3DERR_NOTAVAILABLE
;
4158 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4161 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4163 if (!CheckVertexTextureCapability(adapter
, format
))
4165 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
4166 return WINED3DERR_NOTAVAILABLE
;
4168 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4171 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4173 if (!CheckWrapAndMipCapability(adapter
, format
))
4175 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
4176 return WINED3DERR_NOTAVAILABLE
;
4178 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4183 FIXME_(d3d_caps
)("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type
));
4184 return WINED3DERR_NOTAVAILABLE
;
4187 /* When the usage_caps exactly matches usage return WINED3D_OK except for
4188 * the situation in which WINED3DUSAGE_AUTOGENMIPMAP isn't around, then
4189 * WINED3DOK_NOAUTOGEN is returned if all the other usage flags match. */
4190 if (usage_caps
== usage
)
4192 if (usage_caps
== (usage
& ~WINED3DUSAGE_AUTOGENMIPMAP
))
4193 return WINED3DOK_NOAUTOGEN
;
4195 TRACE_(d3d_caps
)("[FAILED] - Usage %#x requested for format %s and resource_type %s but only %#x is available.\n",
4196 usage
, debug_d3dformat(check_format_id
), debug_d3dresourcetype(resource_type
), usage_caps
);
4198 return WINED3DERR_NOTAVAILABLE
;
4201 HRESULT CDECL
wined3d_check_device_format_conversion(const struct wined3d
*wined3d
, UINT adapter_idx
,
4202 WINED3DDEVTYPE device_type
, enum wined3d_format_id src_format
, enum wined3d_format_id dst_format
)
4204 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
4205 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(src_format
),
4206 debug_d3dformat(dst_format
));
4211 HRESULT CDECL
wined3d_check_device_type(const struct wined3d
*wined3d
, UINT adapter_idx
, WINED3DDEVTYPE device_type
,
4212 enum wined3d_format_id display_format
, enum wined3d_format_id backbuffer_format
, BOOL windowed
)
4217 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
4218 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(display_format
),
4219 debug_d3dformat(backbuffer_format
), windowed
);
4221 if (adapter_idx
>= wined3d
->adapter_count
)
4222 return WINED3DERR_INVALIDCALL
;
4224 /* The task of this function is to check whether a certain display / backbuffer format
4225 * combination is available on the given adapter. In fullscreen mode microsoft specified
4226 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
4227 * and display format should match exactly.
4228 * In windowed mode format conversion can occur and this depends on the driver. When format
4229 * conversion is done, this function should nevertheless fail and applications need to use
4230 * CheckDeviceFormatConversion.
4231 * At the moment we assume that fullscreen and windowed have the same capabilities. */
4233 /* There are only 4 display formats. */
4234 if (!(display_format
== WINED3DFMT_B5G6R5_UNORM
4235 || display_format
== WINED3DFMT_B5G5R5X1_UNORM
4236 || display_format
== WINED3DFMT_B8G8R8X8_UNORM
4237 || display_format
== WINED3DFMT_B10G10R10A2_UNORM
))
4239 TRACE_(d3d_caps
)("Format %s is not supported as display format.\n", debug_d3dformat(display_format
));
4240 return WINED3DERR_NOTAVAILABLE
;
4243 /* If the requested display format is not available, don't continue. */
4244 mode_count
= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, display_format
);
4247 TRACE_(d3d_caps
)("No available modes for display format %s.\n", debug_d3dformat(display_format
));
4248 return WINED3DERR_NOTAVAILABLE
;
4251 /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format,
4252 * it means 'reuse' the display format for the backbuffer. */
4253 if (!windowed
&& backbuffer_format
== WINED3DFMT_UNKNOWN
)
4255 TRACE_(d3d_caps
)("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n");
4256 return WINED3DERR_NOTAVAILABLE
;
4259 /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with
4260 * backbuffer format WINED3DFMT_B5G6R5_UNORM. */
4261 if (display_format
== WINED3DFMT_B5G6R5_UNORM
&& backbuffer_format
!= WINED3DFMT_B5G6R5_UNORM
)
4263 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4264 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4265 return WINED3DERR_NOTAVAILABLE
;
4268 /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with
4269 * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and
4270 * WINED3DFMT_B5G5R5A1_UNORM. */
4271 if (display_format
== WINED3DFMT_B5G5R5X1_UNORM
4272 && !(backbuffer_format
== WINED3DFMT_B5G5R5X1_UNORM
|| backbuffer_format
== WINED3DFMT_B5G5R5A1_UNORM
))
4274 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4275 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4276 return WINED3DERR_NOTAVAILABLE
;
4279 /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with
4280 * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and
4281 * WINED3DFMT_B8G8R8A8_UNORM. */
4282 if (display_format
== WINED3DFMT_B8G8R8X8_UNORM
4283 && !(backbuffer_format
== WINED3DFMT_B8G8R8X8_UNORM
|| backbuffer_format
== WINED3DFMT_B8G8R8A8_UNORM
))
4285 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4286 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4287 return WINED3DERR_NOTAVAILABLE
;
4290 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it
4291 * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */
4292 if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
4293 && (backbuffer_format
!= WINED3DFMT_B10G10R10A2_UNORM
|| windowed
))
4295 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4296 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4297 return WINED3DERR_NOTAVAILABLE
;
4300 /* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
4301 hr
= wined3d_check_device_format(wined3d
, adapter_idx
, device_type
, display_format
,
4302 WINED3DUSAGE_RENDERTARGET
, WINED3DRTYPE_SURFACE
, backbuffer_format
, SURFACE_OPENGL
);
4304 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4305 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4310 /* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
4311 subset of a D3DCAPS9 structure. However, it has to come via a void *
4312 as the d3d8 interface cannot import the d3d9 header */
4313 HRESULT CDECL
wined3d_get_device_caps(const struct wined3d
*wined3d
, UINT adapter_idx
,
4314 WINED3DDEVTYPE device_type
, WINED3DCAPS
*caps
)
4316 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
4317 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4318 int vs_selected_mode
;
4319 int ps_selected_mode
;
4320 struct shader_caps shader_caps
;
4321 struct fragment_caps fragment_caps
;
4322 DWORD ckey_caps
, blit_caps
, fx_caps
, pal_caps
;
4324 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
4325 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), caps
);
4327 if (adapter_idx
>= wined3d
->adapter_count
)
4328 return WINED3DERR_INVALIDCALL
;
4330 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
4332 /* ------------------------------------------------
4333 The following fields apply to both d3d8 and d3d9
4334 ------------------------------------------------ */
4335 /* Not quite true, but use h/w supported by opengl I suppose */
4336 caps
->DeviceType
= (device_type
== WINED3DDEVTYPE_HAL
) ? WINED3DDEVTYPE_HAL
: WINED3DDEVTYPE_REF
;
4337 caps
->AdapterOrdinal
= adapter_idx
;
4340 caps
->Caps2
= WINED3DCAPS2_CANRENDERWINDOWED
|
4341 WINED3DCAPS2_FULLSCREENGAMMA
|
4342 WINED3DCAPS2_DYNAMICTEXTURES
;
4343 if (gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
4344 caps
->Caps2
|= WINED3DCAPS2_CANAUTOGENMIPMAP
;
4346 caps
->Caps3
= WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
4347 WINED3DCAPS3_COPY_TO_VIDMEM
|
4348 WINED3DCAPS3_COPY_TO_SYSTEMMEM
;
4350 caps
->PresentationIntervals
= WINED3DPRESENT_INTERVAL_IMMEDIATE
|
4351 WINED3DPRESENT_INTERVAL_ONE
;
4353 caps
->CursorCaps
= WINED3DCURSORCAPS_COLOR
|
4354 WINED3DCURSORCAPS_LOWRES
;
4356 caps
->DevCaps
= WINED3DDEVCAPS_FLOATTLVERTEX
|
4357 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY
|
4358 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
4359 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY
|
4360 WINED3DDEVCAPS_DRAWPRIMTLVERTEX
|
4361 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT
|
4362 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY
|
4363 WINED3DDEVCAPS_PUREDEVICE
|
4364 WINED3DDEVCAPS_HWRASTERIZATION
|
4365 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY
|
4366 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY
|
4367 WINED3DDEVCAPS_CANRENDERAFTERFLIP
|
4368 WINED3DDEVCAPS_DRAWPRIMITIVES2
|
4369 WINED3DDEVCAPS_DRAWPRIMITIVES2EX
|
4370 WINED3DDEVCAPS_RTPATCHES
;
4372 caps
->PrimitiveMiscCaps
= WINED3DPMISCCAPS_CULLNONE
|
4373 WINED3DPMISCCAPS_CULLCCW
|
4374 WINED3DPMISCCAPS_CULLCW
|
4375 WINED3DPMISCCAPS_COLORWRITEENABLE
|
4376 WINED3DPMISCCAPS_CLIPTLVERTS
|
4377 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
4378 WINED3DPMISCCAPS_MASKZ
|
4379 WINED3DPMISCCAPS_BLENDOP
|
4380 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
;
4382 WINED3DPMISCCAPS_NULLREFERENCE
4383 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
4384 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
4385 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
4387 if (gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
] && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
4388 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_SEPARATEALPHABLEND
;
4389 if (gl_info
->supported
[EXT_DRAW_BUFFERS2
])
4390 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
;
4392 caps
->RasterCaps
= WINED3DPRASTERCAPS_DITHER
|
4393 WINED3DPRASTERCAPS_PAT
|
4394 WINED3DPRASTERCAPS_WFOG
|
4395 WINED3DPRASTERCAPS_ZFOG
|
4396 WINED3DPRASTERCAPS_FOGVERTEX
|
4397 WINED3DPRASTERCAPS_FOGTABLE
|
4398 WINED3DPRASTERCAPS_STIPPLE
|
4399 WINED3DPRASTERCAPS_SUBPIXEL
|
4400 WINED3DPRASTERCAPS_ZTEST
|
4401 WINED3DPRASTERCAPS_SCISSORTEST
|
4402 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
4403 WINED3DPRASTERCAPS_DEPTHBIAS
;
4405 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4407 caps
->RasterCaps
|= WINED3DPRASTERCAPS_ANISOTROPY
|
4408 WINED3DPRASTERCAPS_ZBIAS
|
4409 WINED3DPRASTERCAPS_MIPMAPLODBIAS
;
4411 if (gl_info
->supported
[NV_FOG_DISTANCE
])
4413 caps
->RasterCaps
|= WINED3DPRASTERCAPS_FOGRANGE
;
4416 WINED3DPRASTERCAPS_COLORPERSPECTIVE
4417 WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
4418 WINED3DPRASTERCAPS_ANTIALIASEDGES
4419 WINED3DPRASTERCAPS_ZBUFFERLESSHSR
4420 WINED3DPRASTERCAPS_WBUFFER */
4422 caps
->ZCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4423 WINED3DPCMPCAPS_EQUAL
|
4424 WINED3DPCMPCAPS_GREATER
|
4425 WINED3DPCMPCAPS_GREATEREQUAL
|
4426 WINED3DPCMPCAPS_LESS
|
4427 WINED3DPCMPCAPS_LESSEQUAL
|
4428 WINED3DPCMPCAPS_NEVER
|
4429 WINED3DPCMPCAPS_NOTEQUAL
;
4431 caps
->SrcBlendCaps
= WINED3DPBLENDCAPS_BOTHINVSRCALPHA
|
4432 WINED3DPBLENDCAPS_BOTHSRCALPHA
|
4433 WINED3DPBLENDCAPS_DESTALPHA
|
4434 WINED3DPBLENDCAPS_DESTCOLOR
|
4435 WINED3DPBLENDCAPS_INVDESTALPHA
|
4436 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4437 WINED3DPBLENDCAPS_INVSRCALPHA
|
4438 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4439 WINED3DPBLENDCAPS_ONE
|
4440 WINED3DPBLENDCAPS_SRCALPHA
|
4441 WINED3DPBLENDCAPS_SRCALPHASAT
|
4442 WINED3DPBLENDCAPS_SRCCOLOR
|
4443 WINED3DPBLENDCAPS_ZERO
;
4445 caps
->DestBlendCaps
= WINED3DPBLENDCAPS_DESTALPHA
|
4446 WINED3DPBLENDCAPS_DESTCOLOR
|
4447 WINED3DPBLENDCAPS_INVDESTALPHA
|
4448 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4449 WINED3DPBLENDCAPS_INVSRCALPHA
|
4450 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4451 WINED3DPBLENDCAPS_ONE
|
4452 WINED3DPBLENDCAPS_SRCALPHA
|
4453 WINED3DPBLENDCAPS_SRCCOLOR
|
4454 WINED3DPBLENDCAPS_ZERO
;
4455 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
4456 * according to the glBlendFunc manpage
4458 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
4459 * legacy settings for srcblend only
4462 if (gl_info
->supported
[EXT_BLEND_COLOR
])
4464 caps
->SrcBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4465 caps
->DestBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4469 caps
->AlphaCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4470 WINED3DPCMPCAPS_EQUAL
|
4471 WINED3DPCMPCAPS_GREATER
|
4472 WINED3DPCMPCAPS_GREATEREQUAL
|
4473 WINED3DPCMPCAPS_LESS
|
4474 WINED3DPCMPCAPS_LESSEQUAL
|
4475 WINED3DPCMPCAPS_NEVER
|
4476 WINED3DPCMPCAPS_NOTEQUAL
;
4478 caps
->ShadeCaps
= WINED3DPSHADECAPS_SPECULARGOURAUDRGB
|
4479 WINED3DPSHADECAPS_COLORGOURAUDRGB
|
4480 WINED3DPSHADECAPS_ALPHAFLATBLEND
|
4481 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND
|
4482 WINED3DPSHADECAPS_COLORFLATRGB
|
4483 WINED3DPSHADECAPS_FOGFLAT
|
4484 WINED3DPSHADECAPS_FOGGOURAUD
|
4485 WINED3DPSHADECAPS_SPECULARFLATRGB
;
4487 caps
->TextureCaps
= WINED3DPTEXTURECAPS_ALPHA
|
4488 WINED3DPTEXTURECAPS_ALPHAPALETTE
|
4489 WINED3DPTEXTURECAPS_TRANSPARENCY
|
4490 WINED3DPTEXTURECAPS_BORDER
|
4491 WINED3DPTEXTURECAPS_MIPMAP
|
4492 WINED3DPTEXTURECAPS_PROJECTED
|
4493 WINED3DPTEXTURECAPS_PERSPECTIVE
;
4495 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4497 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_POW2
|
4498 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL
;
4501 if (gl_info
->supported
[EXT_TEXTURE3D
])
4503 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP
|
4504 WINED3DPTEXTURECAPS_MIPVOLUMEMAP
;
4505 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4507 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2
;
4511 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4513 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP
|
4514 WINED3DPTEXTURECAPS_MIPCUBEMAP
;
4515 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4517 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP_POW2
;
4521 caps
->TextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4522 WINED3DPTFILTERCAPS_MAGFPOINT
|
4523 WINED3DPTFILTERCAPS_MINFLINEAR
|
4524 WINED3DPTFILTERCAPS_MINFPOINT
|
4525 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4526 WINED3DPTFILTERCAPS_MIPFPOINT
|
4527 WINED3DPTFILTERCAPS_LINEAR
|
4528 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4529 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4530 WINED3DPTFILTERCAPS_MIPLINEAR
|
4531 WINED3DPTFILTERCAPS_MIPNEAREST
|
4532 WINED3DPTFILTERCAPS_NEAREST
;
4534 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4536 caps
->TextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4537 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4540 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4542 caps
->CubeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4543 WINED3DPTFILTERCAPS_MAGFPOINT
|
4544 WINED3DPTFILTERCAPS_MINFLINEAR
|
4545 WINED3DPTFILTERCAPS_MINFPOINT
|
4546 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4547 WINED3DPTFILTERCAPS_MIPFPOINT
|
4548 WINED3DPTFILTERCAPS_LINEAR
|
4549 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4550 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4551 WINED3DPTFILTERCAPS_MIPLINEAR
|
4552 WINED3DPTFILTERCAPS_MIPNEAREST
|
4553 WINED3DPTFILTERCAPS_NEAREST
;
4555 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4557 caps
->CubeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4558 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4563 caps
->CubeTextureFilterCaps
= 0;
4566 if (gl_info
->supported
[EXT_TEXTURE3D
])
4568 caps
->VolumeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4569 WINED3DPTFILTERCAPS_MAGFPOINT
|
4570 WINED3DPTFILTERCAPS_MINFLINEAR
|
4571 WINED3DPTFILTERCAPS_MINFPOINT
|
4572 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4573 WINED3DPTFILTERCAPS_MIPFPOINT
|
4574 WINED3DPTFILTERCAPS_LINEAR
|
4575 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4576 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4577 WINED3DPTFILTERCAPS_MIPLINEAR
|
4578 WINED3DPTFILTERCAPS_MIPNEAREST
|
4579 WINED3DPTFILTERCAPS_NEAREST
;
4583 caps
->VolumeTextureFilterCaps
= 0;
4586 caps
->TextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4587 WINED3DPTADDRESSCAPS_CLAMP
|
4588 WINED3DPTADDRESSCAPS_WRAP
;
4590 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4592 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4594 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4596 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4598 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4600 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4603 if (gl_info
->supported
[EXT_TEXTURE3D
])
4605 caps
->VolumeTextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4606 WINED3DPTADDRESSCAPS_CLAMP
|
4607 WINED3DPTADDRESSCAPS_WRAP
;
4608 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4610 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4612 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4614 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4616 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4618 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4623 caps
->VolumeTextureAddressCaps
= 0;
4626 caps
->LineCaps
= WINED3DLINECAPS_TEXTURE
|
4627 WINED3DLINECAPS_ZTEST
|
4628 WINED3DLINECAPS_BLEND
|
4629 WINED3DLINECAPS_ALPHACMP
|
4630 WINED3DLINECAPS_FOG
;
4631 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
4632 * idea how generating the smoothing alpha values works; the result is different
4635 caps
->MaxTextureWidth
= gl_info
->limits
.texture_size
;
4636 caps
->MaxTextureHeight
= gl_info
->limits
.texture_size
;
4638 if (gl_info
->supported
[EXT_TEXTURE3D
])
4639 caps
->MaxVolumeExtent
= gl_info
->limits
.texture3d_size
;
4641 caps
->MaxVolumeExtent
= 0;
4643 caps
->MaxTextureRepeat
= 32768;
4644 caps
->MaxTextureAspectRatio
= gl_info
->limits
.texture_size
;
4645 caps
->MaxVertexW
= 1.0f
;
4647 caps
->GuardBandLeft
= 0.0f
;
4648 caps
->GuardBandTop
= 0.0f
;
4649 caps
->GuardBandRight
= 0.0f
;
4650 caps
->GuardBandBottom
= 0.0f
;
4652 caps
->ExtentsAdjust
= 0.0f
;
4654 caps
->StencilCaps
= WINED3DSTENCILCAPS_DECRSAT
|
4655 WINED3DSTENCILCAPS_INCRSAT
|
4656 WINED3DSTENCILCAPS_INVERT
|
4657 WINED3DSTENCILCAPS_KEEP
|
4658 WINED3DSTENCILCAPS_REPLACE
|
4659 WINED3DSTENCILCAPS_ZERO
;
4660 if (gl_info
->supported
[EXT_STENCIL_WRAP
])
4662 caps
->StencilCaps
|= WINED3DSTENCILCAPS_DECR
|
4663 WINED3DSTENCILCAPS_INCR
;
4665 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
] || gl_info
->supported
[ATI_SEPARATE_STENCIL
])
4667 caps
->StencilCaps
|= WINED3DSTENCILCAPS_TWOSIDED
;
4670 caps
->FVFCaps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
4672 caps
->MaxUserClipPlanes
= gl_info
->limits
.clipplanes
;
4673 caps
->MaxActiveLights
= gl_info
->limits
.lights
;
4675 caps
->MaxVertexBlendMatrices
= gl_info
->limits
.blends
;
4676 caps
->MaxVertexBlendMatrixIndex
= 0;
4678 caps
->MaxAnisotropy
= gl_info
->limits
.anisotropy
;
4679 caps
->MaxPointSize
= gl_info
->limits
.pointsize_max
;
4682 /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
4683 caps
->VertexProcessingCaps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
|
4684 WINED3DVTXPCAPS_MATERIALSOURCE7
|
4685 WINED3DVTXPCAPS_POSITIONALLIGHTS
|
4686 WINED3DVTXPCAPS_LOCALVIEWER
|
4687 WINED3DVTXPCAPS_VERTEXFOG
|
4688 WINED3DVTXPCAPS_TEXGEN
;
4690 caps
->MaxPrimitiveCount
= 0xFFFFF; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4691 caps
->MaxVertexIndex
= 0xFFFFF;
4692 caps
->MaxStreams
= MAX_STREAMS
;
4693 caps
->MaxStreamStride
= 1024;
4695 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4696 caps
->DevCaps2
= WINED3DDEVCAPS2_STREAMOFFSET
|
4697 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
;
4698 caps
->MaxNpatchTessellationLevel
= 0;
4699 caps
->MasterAdapterOrdinal
= 0;
4700 caps
->AdapterOrdinalInGroup
= 0;
4701 caps
->NumberOfAdaptersInGroup
= 1;
4703 caps
->NumSimultaneousRTs
= gl_info
->limits
.buffers
;
4705 caps
->StretchRectFilterCaps
= WINED3DPTFILTERCAPS_MINFPOINT
|
4706 WINED3DPTFILTERCAPS_MAGFPOINT
|
4707 WINED3DPTFILTERCAPS_MINFLINEAR
|
4708 WINED3DPTFILTERCAPS_MAGFLINEAR
;
4709 caps
->VertexTextureFilterCaps
= 0;
4711 adapter
->shader_backend
->shader_get_caps(&adapter
->gl_info
, &shader_caps
);
4712 adapter
->fragment_pipe
->get_caps(&adapter
->gl_info
, &fragment_caps
);
4714 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4715 caps
->PrimitiveMiscCaps
|= fragment_caps
.PrimitiveMiscCaps
;
4717 /* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
4718 * Ignore shader model capabilities if disabled in config
4720 if (vs_selected_mode
== SHADER_NONE
)
4722 TRACE_(d3d_caps
)("Vertex shader disabled in config, reporting version 0.0\n");
4723 caps
->VertexShaderVersion
= WINED3DVS_VERSION(0,0);
4724 caps
->MaxVertexShaderConst
= 0;
4728 caps
->VertexShaderVersion
= shader_caps
.VertexShaderVersion
;
4729 caps
->MaxVertexShaderConst
= shader_caps
.MaxVertexShaderConst
;
4732 if (ps_selected_mode
== SHADER_NONE
)
4734 TRACE_(d3d_caps
)("Pixel shader disabled in config, reporting version 0.0\n");
4735 caps
->PixelShaderVersion
= WINED3DPS_VERSION(0,0);
4736 caps
->PixelShader1xMaxValue
= 0.0f
;
4738 caps
->PixelShaderVersion
= shader_caps
.PixelShaderVersion
;
4739 caps
->PixelShader1xMaxValue
= shader_caps
.PixelShader1xMaxValue
;
4742 caps
->TextureOpCaps
= fragment_caps
.TextureOpCaps
;
4743 caps
->MaxTextureBlendStages
= fragment_caps
.MaxTextureBlendStages
;
4744 caps
->MaxSimultaneousTextures
= fragment_caps
.MaxSimultaneousTextures
;
4746 /* The following caps are shader specific, but they are things we cannot detect, or which
4747 * are the same among all shader models. So to avoid code duplication set the shader version
4748 * specific, but otherwise constant caps here
4750 if (caps
->VertexShaderVersion
== WINED3DVS_VERSION(3,0))
4752 /* Where possible set the caps based on OpenGL extensions and if they
4753 * aren't set (in case of software rendering) use the VS 3.0 from
4754 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4756 caps
->VS20Caps
.Caps
= WINED3DVS20CAPS_PREDICATION
;
4757 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4758 caps
->VS20Caps
.DynamicFlowControlDepth
= WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4759 caps
->VS20Caps
.NumTemps
= max(32, adapter
->gl_info
.limits
.arb_vs_temps
);
4760 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
4761 caps
->VS20Caps
.StaticFlowControlDepth
= WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
4763 caps
->MaxVShaderInstructionsExecuted
= 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
4764 caps
->MaxVertexShader30InstructionSlots
= max(512, adapter
->gl_info
.limits
.arb_vs_instructions
);
4766 else if (caps
->VertexShaderVersion
== WINED3DVS_VERSION(2,0))
4768 caps
->VS20Caps
.Caps
= 0;
4769 caps
->VS20Caps
.DynamicFlowControlDepth
= WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
;
4770 caps
->VS20Caps
.NumTemps
= max(12, adapter
->gl_info
.limits
.arb_vs_temps
);
4771 caps
->VS20Caps
.StaticFlowControlDepth
= 1;
4773 caps
->MaxVShaderInstructionsExecuted
= 65535;
4774 caps
->MaxVertexShader30InstructionSlots
= 0;
4778 caps
->VS20Caps
.Caps
= 0;
4779 caps
->VS20Caps
.DynamicFlowControlDepth
= 0;
4780 caps
->VS20Caps
.NumTemps
= 0;
4781 caps
->VS20Caps
.StaticFlowControlDepth
= 0;
4783 caps
->MaxVShaderInstructionsExecuted
= 0;
4784 caps
->MaxVertexShader30InstructionSlots
= 0;
4787 if (caps
->PixelShaderVersion
== WINED3DPS_VERSION(3,0))
4789 /* Where possible set the caps based on OpenGL extensions and if they
4790 * aren't set (in case of software rendering) use the PS 3.0 from
4791 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4794 /* Caps is more or less undocumented on MSDN but it appears to be
4795 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
4796 * cards from Windows */
4797 caps
->PS20Caps
.Caps
= WINED3DPS20CAPS_ARBITRARYSWIZZLE
|
4798 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS
|
4799 WINED3DPS20CAPS_PREDICATION
|
4800 WINED3DPS20CAPS_NODEPENDENTREADLIMIT
|
4801 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
4802 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4803 caps
->PS20Caps
.DynamicFlowControlDepth
= WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4804 caps
->PS20Caps
.NumTemps
= max(32, adapter
->gl_info
.limits
.arb_ps_temps
);
4805 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
4806 caps
->PS20Caps
.StaticFlowControlDepth
= WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
4807 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
4808 caps
->PS20Caps
.NumInstructionSlots
= WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
4810 caps
->MaxPShaderInstructionsExecuted
= 65535;
4811 caps
->MaxPixelShader30InstructionSlots
= max(WINED3DMIN30SHADERINSTRUCTIONS
,
4812 adapter
->gl_info
.limits
.arb_ps_instructions
);
4814 else if(caps
->PixelShaderVersion
== WINED3DPS_VERSION(2,0))
4816 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
4817 caps
->PS20Caps
.Caps
= 0;
4818 caps
->PS20Caps
.DynamicFlowControlDepth
= 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
4819 caps
->PS20Caps
.NumTemps
= max(12, adapter
->gl_info
.limits
.arb_ps_temps
);
4820 caps
->PS20Caps
.StaticFlowControlDepth
= WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH
; /* Minimum: 1 */
4821 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
4822 caps
->PS20Caps
.NumInstructionSlots
= WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS
;
4824 caps
->MaxPShaderInstructionsExecuted
= 512; /* Minimum value, a GeforceFX uses 1024 */
4825 caps
->MaxPixelShader30InstructionSlots
= 0;
4829 caps
->PS20Caps
.Caps
= 0;
4830 caps
->PS20Caps
.DynamicFlowControlDepth
= 0;
4831 caps
->PS20Caps
.NumTemps
= 0;
4832 caps
->PS20Caps
.StaticFlowControlDepth
= 0;
4833 caps
->PS20Caps
.NumInstructionSlots
= 0;
4835 caps
->MaxPShaderInstructionsExecuted
= 0;
4836 caps
->MaxPixelShader30InstructionSlots
= 0;
4839 if (caps
->VertexShaderVersion
>= WINED3DVS_VERSION(2,0))
4841 /* OpenGL supports all the formats below, perhaps not always
4842 * without conversion, but it supports them.
4843 * Further GLSL doesn't seem to have an official unsigned type so
4844 * don't advertise it yet as I'm not sure how we handle it.
4845 * We might need to add some clamping in the shader engine to
4847 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
4848 caps
->DeclTypes
= WINED3DDTCAPS_UBYTE4
|
4849 WINED3DDTCAPS_UBYTE4N
|
4850 WINED3DDTCAPS_SHORT2N
|
4851 WINED3DDTCAPS_SHORT4N
;
4852 if (gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
])
4854 caps
->DeclTypes
|= WINED3DDTCAPS_FLOAT16_2
|
4855 WINED3DDTCAPS_FLOAT16_4
;
4860 caps
->DeclTypes
= 0;
4863 /* Set DirectDraw helper Caps */
4864 ckey_caps
= WINEDDCKEYCAPS_DESTBLT
|
4865 WINEDDCKEYCAPS_SRCBLT
;
4866 fx_caps
= WINEDDFXCAPS_BLTALPHA
|
4867 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT
|
4868 WINEDDFXCAPS_BLTMIRRORUPDOWN
|
4869 WINEDDFXCAPS_BLTROTATION90
|
4870 WINEDDFXCAPS_BLTSHRINKX
|
4871 WINEDDFXCAPS_BLTSHRINKXN
|
4872 WINEDDFXCAPS_BLTSHRINKY
|
4873 WINEDDFXCAPS_BLTSHRINKXN
|
4874 WINEDDFXCAPS_BLTSTRETCHX
|
4875 WINEDDFXCAPS_BLTSTRETCHXN
|
4876 WINEDDFXCAPS_BLTSTRETCHY
|
4877 WINEDDFXCAPS_BLTSTRETCHYN
;
4878 blit_caps
= WINEDDCAPS_BLT
|
4879 WINEDDCAPS_BLTCOLORFILL
|
4880 WINEDDCAPS_BLTDEPTHFILL
|
4881 WINEDDCAPS_BLTSTRETCH
|
4882 WINEDDCAPS_CANBLTSYSMEM
|
4883 WINEDDCAPS_CANCLIP
|
4884 WINEDDCAPS_CANCLIPSTRETCHED
|
4885 WINEDDCAPS_COLORKEY
|
4886 WINEDDCAPS_COLORKEYHWASSIST
|
4887 WINEDDCAPS_ALIGNBOUNDARYSRC
;
4888 pal_caps
= WINEDDPCAPS_8BIT
|
4889 WINEDDPCAPS_PRIMARYSURFACE
;
4891 /* Fill the ddraw caps structure */
4892 caps
->DirectDrawCaps
.Caps
= WINEDDCAPS_GDI
|
4893 WINEDDCAPS_PALETTE
|
4895 caps
->DirectDrawCaps
.Caps2
= WINEDDCAPS2_CERTIFIED
|
4896 WINEDDCAPS2_NOPAGELOCKREQUIRED
|
4897 WINEDDCAPS2_PRIMARYGAMMA
|
4898 WINEDDCAPS2_WIDESURFACES
|
4899 WINEDDCAPS2_CANRENDERWINDOWED
;
4900 caps
->DirectDrawCaps
.CKeyCaps
= ckey_caps
;
4901 caps
->DirectDrawCaps
.FXCaps
= fx_caps
;
4902 caps
->DirectDrawCaps
.PalCaps
= pal_caps
;
4903 caps
->DirectDrawCaps
.SVBCaps
= blit_caps
;
4904 caps
->DirectDrawCaps
.SVBCKeyCaps
= ckey_caps
;
4905 caps
->DirectDrawCaps
.SVBFXCaps
= fx_caps
;
4906 caps
->DirectDrawCaps
.VSBCaps
= blit_caps
;
4907 caps
->DirectDrawCaps
.VSBCKeyCaps
= ckey_caps
;
4908 caps
->DirectDrawCaps
.VSBFXCaps
= fx_caps
;
4909 caps
->DirectDrawCaps
.SSBCaps
= blit_caps
;
4910 caps
->DirectDrawCaps
.SSBCKeyCaps
= ckey_caps
;
4911 caps
->DirectDrawCaps
.SSBFXCaps
= fx_caps
;
4913 caps
->DirectDrawCaps
.ddsCaps
= WINEDDSCAPS_ALPHA
|
4914 WINEDDSCAPS_BACKBUFFER
|
4916 WINEDDSCAPS_FRONTBUFFER
|
4917 WINEDDSCAPS_OFFSCREENPLAIN
|
4918 WINEDDSCAPS_PALETTE
|
4919 WINEDDSCAPS_PRIMARYSURFACE
|
4920 WINEDDSCAPS_SYSTEMMEMORY
|
4921 WINEDDSCAPS_VIDEOMEMORY
|
4922 WINEDDSCAPS_VISIBLE
;
4923 caps
->DirectDrawCaps
.StrideAlign
= DDRAW_PITCH_ALIGNMENT
;
4925 /* Set D3D caps if OpenGL is available. */
4926 if (adapter
->opengl
)
4928 caps
->DirectDrawCaps
.ddsCaps
|= WINEDDSCAPS_3DDEVICE
|
4929 WINEDDSCAPS_MIPMAP
|
4930 WINEDDSCAPS_TEXTURE
|
4931 WINEDDSCAPS_ZBUFFER
;
4932 caps
->DirectDrawCaps
.Caps
|= WINEDDCAPS_3D
;
4938 HRESULT CDECL
wined3d_device_create(struct wined3d
*wined3d
, UINT adapter_idx
, WINED3DDEVTYPE device_type
,
4939 HWND focus_window
, DWORD flags
, BYTE surface_alignment
, struct wined3d_device_parent
*device_parent
,
4940 struct wined3d_device
**device
)
4942 struct wined3d_device
*object
;
4945 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
4946 wined3d
, adapter_idx
, device_type
, focus_window
, flags
, device_parent
, device
);
4948 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
4949 * number and create a device without a 3D adapter for 2D only operation. */
4950 if (wined3d
->adapter_count
&& adapter_idx
>= wined3d
->adapter_count
)
4951 return WINED3DERR_INVALIDCALL
;
4953 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
4956 ERR("Failed to allocate device memory.\n");
4957 return E_OUTOFMEMORY
;
4960 hr
= device_init(object
, wined3d
, adapter_idx
, device_type
,
4961 focus_window
, flags
, surface_alignment
, device_parent
);
4964 WARN("Failed to initialize device, hr %#x.\n", hr
);
4965 HeapFree(GetProcessHeap(), 0, object
);
4969 TRACE("Created device %p.\n", object
);
4972 device_parent
->ops
->wined3d_device_created(device_parent
, *device
);
4977 void * CDECL
wined3d_get_parent(const struct wined3d
*wined3d
)
4979 TRACE("wined3d %p.\n", wined3d
);
4981 return wined3d
->parent
;
4984 static void WINE_GLAPI
invalid_func(const void *data
)
4986 ERR("Invalid vertex attribute function called\n");
4990 static void WINE_GLAPI
invalid_texcoord_func(GLenum unit
, const void *data
)
4992 ERR("Invalid texcoord function called\n");
4996 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
4997 * the extension detection and are used in drawStridedSlow
4999 static void WINE_GLAPI
position_d3dcolor(const void *data
)
5001 DWORD pos
= *((const DWORD
*)data
);
5003 FIXME("Add a test for fixed function position from d3dcolor type\n");
5004 glVertex4s(D3DCOLOR_B_R(pos
),
5010 static void WINE_GLAPI
position_float4(const void *data
)
5012 const GLfloat
*pos
= data
;
5014 if (pos
[3] != 0.0f
&& pos
[3] != 1.0f
)
5016 float w
= 1.0f
/ pos
[3];
5018 glVertex4f(pos
[0] * w
, pos
[1] * w
, pos
[2] * w
, w
);
5026 static void WINE_GLAPI
diffuse_d3dcolor(const void *data
)
5028 DWORD diffuseColor
= *((const DWORD
*)data
);
5030 glColor4ub(D3DCOLOR_B_R(diffuseColor
),
5031 D3DCOLOR_B_G(diffuseColor
),
5032 D3DCOLOR_B_B(diffuseColor
),
5033 D3DCOLOR_B_A(diffuseColor
));
5036 static void WINE_GLAPI
specular_d3dcolor(const void *data
)
5038 DWORD specularColor
= *((const DWORD
*)data
);
5039 GLbyte d
[] = {D3DCOLOR_B_R(specularColor
),
5040 D3DCOLOR_B_G(specularColor
),
5041 D3DCOLOR_B_B(specularColor
)};
5043 specular_func_3ubv(d
);
5046 static void WINE_GLAPI
warn_no_specular_func(const void *data
)
5048 WARN("GL_EXT_secondary_color not supported\n");
5051 static void fillGLAttribFuncs(const struct wined3d_gl_info
*gl_info
)
5053 position_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5054 position_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5055 position_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glVertex3fv
;
5056 position_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = position_float4
;
5057 position_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = position_d3dcolor
;
5058 position_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5059 position_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5060 position_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glAttribFunc
)glVertex2sv
;
5061 position_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5062 position_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5063 position_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5064 position_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5065 position_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5066 position_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5067 position_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5068 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5069 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5071 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5072 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5073 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glColor3fv
;
5074 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glColor4fv
;
5075 diffuse_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = diffuse_d3dcolor
;
5076 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5077 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5078 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5079 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = (glAttribFunc
)glColor4ubv
;
5080 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5081 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = (glAttribFunc
)glColor4sv
;
5082 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5083 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = (glAttribFunc
)glColor4usv
;
5084 diffuse_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5085 diffuse_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5086 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5087 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5089 /* No 4 component entry points here */
5090 specular_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5091 specular_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5092 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5094 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)GL_EXTCALL(glSecondaryColor3fvEXT
);
5098 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = warn_no_specular_func
;
5100 specular_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = invalid_func
;
5101 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5103 specular_func_3ubv
= (glAttribFunc
)GL_EXTCALL(glSecondaryColor3ubvEXT
);
5104 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = specular_d3dcolor
;
5108 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = warn_no_specular_func
;
5110 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5111 specular_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5112 specular_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5113 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5114 specular_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5115 specular_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5116 specular_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5117 specular_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5118 specular_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5119 specular_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5120 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5121 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5123 /* Only 3 component entry points here. Test how others behave. Float4 normals are used
5124 * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
5126 normal_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5127 normal_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5128 normal_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glNormal3fv
;
5129 normal_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glNormal3fv
; /* Just ignore the 4th value */
5130 normal_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_func
;
5131 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5132 normal_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5133 normal_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5134 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5135 normal_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5136 normal_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5137 normal_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5138 normal_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5139 normal_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5140 normal_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5141 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5142 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5144 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord1fvARB
);
5145 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2fvARB
);
5146 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord3fvARB
);
5147 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4fvARB
);
5148 multi_texcoord_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_texcoord_func
;
5149 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_texcoord_func
;
5150 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2svARB
);
5151 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4svARB
);
5152 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_texcoord_func
;
5153 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_texcoord_func
;
5154 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_texcoord_func
;
5155 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_texcoord_func
;
5156 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_texcoord_func
;
5157 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_texcoord_func
;
5158 multi_texcoord_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_texcoord_func
;
5159 if (gl_info
->supported
[NV_HALF_FLOAT
])
5161 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
5162 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2hvNV
);
5163 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4hvNV
);
5165 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_texcoord_func
;
5166 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_texcoord_func
;
5170 /* Do not call while under the GL lock. */
5171 static BOOL
InitAdapters(struct wined3d
*wined3d
)
5173 static HMODULE mod_gl
;
5175 int ps_selected_mode
, vs_selected_mode
;
5177 /* No need to hold any lock. The calling library makes sure only one thread calls
5178 * wined3d simultaneously
5181 TRACE("Initializing adapters\n");
5184 #ifdef USE_WIN32_OPENGL
5185 #define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
5186 mod_gl
= LoadLibraryA("opengl32.dll");
5188 ERR("Can't load opengl32.dll!\n");
5192 #define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
5193 /* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
5194 mod_gl
= GetModuleHandleA("gdi32.dll");
5198 /* Load WGL core functions from opengl32.dll */
5199 #define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
5203 if(!pwglGetProcAddress
) {
5204 ERR("Unable to load wglGetProcAddress!\n");
5208 /* Dynamically load all GL core functions */
5212 /* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl
5213 * otherwise because we have to use winex11.drv's override
5215 #ifdef USE_WIN32_OPENGL
5216 wglFinish
= (void*)GetProcAddress(mod_gl
, "glFinish");
5217 wglFlush
= (void*)GetProcAddress(mod_gl
, "glFlush");
5219 wglFinish
= (void*)pwglGetProcAddress("wglFinish");
5220 wglFlush
= (void*)pwglGetProcAddress("wglFlush");
5223 glEnableWINE
= glEnable
;
5224 glDisableWINE
= glDisable
;
5226 /* For now only one default adapter */
5228 struct wined3d_adapter
*adapter
= &wined3d
->adapters
[0];
5229 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
5230 struct wined3d_fake_gl_ctx fake_gl_ctx
= {0};
5231 struct wined3d_pixel_format
*cfgs
;
5235 DISPLAY_DEVICEW DisplayDevice
;
5238 TRACE("Initializing default adapter\n");
5239 adapter
->ordinal
= 0;
5240 adapter
->monitorPoint
.x
= -1;
5241 adapter
->monitorPoint
.y
= -1;
5243 if (!AllocateLocallyUniqueId(&adapter
->luid
))
5245 DWORD err
= GetLastError();
5246 ERR("Failed to set adapter LUID (%#x).\n", err
);
5249 TRACE("Allocated LUID %08x:%08x for adapter.\n",
5250 adapter
->luid
.HighPart
, adapter
->luid
.LowPart
);
5252 if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx
))
5254 ERR("Failed to get a gl context for default adapter\n");
5258 ret
= wined3d_adapter_init_gl_caps(adapter
);
5260 ERR("Failed to initialize gl caps for default adapter\n");
5261 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5264 ret
= initPixelFormats(&adapter
->gl_info
, adapter
->driver_info
.vendor
);
5266 ERR("Failed to init gl formats\n");
5267 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5271 hdc
= fake_gl_ctx
.dc
;
5273 adapter
->TextureRam
= adapter
->driver_info
.vidmem
;
5274 adapter
->UsedTextureRam
= 0;
5275 TRACE("Emulating %dMB of texture ram\n", adapter
->TextureRam
/(1024*1024));
5277 /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
5278 DisplayDevice
.cb
= sizeof(DisplayDevice
);
5279 EnumDisplayDevicesW(NULL
, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice
, 0);
5280 TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice
.DeviceName
));
5281 strcpyW(adapter
->DeviceName
, DisplayDevice
.DeviceName
);
5283 if (gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
])
5290 attribute
= WGL_NUMBER_PIXEL_FORMATS_ARB
;
5291 GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, 0, 0, 1, &attribute
, &adapter
->nCfgs
));
5293 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, adapter
->nCfgs
* sizeof(*adapter
->cfgs
));
5294 cfgs
= adapter
->cfgs
;
5295 attribs
[nAttribs
++] = WGL_RED_BITS_ARB
;
5296 attribs
[nAttribs
++] = WGL_GREEN_BITS_ARB
;
5297 attribs
[nAttribs
++] = WGL_BLUE_BITS_ARB
;
5298 attribs
[nAttribs
++] = WGL_ALPHA_BITS_ARB
;
5299 attribs
[nAttribs
++] = WGL_COLOR_BITS_ARB
;
5300 attribs
[nAttribs
++] = WGL_DEPTH_BITS_ARB
;
5301 attribs
[nAttribs
++] = WGL_STENCIL_BITS_ARB
;
5302 attribs
[nAttribs
++] = WGL_DRAW_TO_WINDOW_ARB
;
5303 attribs
[nAttribs
++] = WGL_PIXEL_TYPE_ARB
;
5304 attribs
[nAttribs
++] = WGL_DOUBLE_BUFFER_ARB
;
5305 attribs
[nAttribs
++] = WGL_AUX_BUFFERS_ARB
;
5307 for (iPixelFormat
=1; iPixelFormat
<= adapter
->nCfgs
; ++iPixelFormat
)
5309 res
= GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, nAttribs
, attribs
, values
));
5314 /* Cache the pixel format */
5315 cfgs
->iPixelFormat
= iPixelFormat
;
5316 cfgs
->redSize
= values
[0];
5317 cfgs
->greenSize
= values
[1];
5318 cfgs
->blueSize
= values
[2];
5319 cfgs
->alphaSize
= values
[3];
5320 cfgs
->colorSize
= values
[4];
5321 cfgs
->depthSize
= values
[5];
5322 cfgs
->stencilSize
= values
[6];
5323 cfgs
->windowDrawable
= values
[7];
5324 cfgs
->iPixelType
= values
[8];
5325 cfgs
->doubleBuffer
= values
[9];
5326 cfgs
->auxBuffers
= values
[10];
5328 cfgs
->numSamples
= 0;
5329 /* Check multisample support */
5330 if (gl_info
->supported
[ARB_MULTISAMPLE
])
5332 int attrib
[2] = {WGL_SAMPLE_BUFFERS_ARB
, WGL_SAMPLES_ARB
};
5334 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, 2, attrib
, value
))) {
5335 /* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
5336 * value[1] = number of multi sample buffers*/
5338 cfgs
->numSamples
= value
[1];
5342 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5343 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
5344 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5345 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5346 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->numSamples
, cfgs
->windowDrawable
);
5352 int nCfgs
= DescribePixelFormat(hdc
, 0, 0, 0);
5353 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, nCfgs
* sizeof(*adapter
->cfgs
));
5354 adapter
->nCfgs
= 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
5356 cfgs
= adapter
->cfgs
;
5357 for(iPixelFormat
=1; iPixelFormat
<=nCfgs
; iPixelFormat
++)
5359 PIXELFORMATDESCRIPTOR ppfd
;
5361 res
= DescribePixelFormat(hdc
, iPixelFormat
, sizeof(PIXELFORMATDESCRIPTOR
), &ppfd
);
5365 /* We only want HW acceleration using an OpenGL ICD driver.
5366 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
5367 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
5369 if(ppfd
.dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
))
5371 TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat
);
5375 cfgs
->iPixelFormat
= iPixelFormat
;
5376 cfgs
->redSize
= ppfd
.cRedBits
;
5377 cfgs
->greenSize
= ppfd
.cGreenBits
;
5378 cfgs
->blueSize
= ppfd
.cBlueBits
;
5379 cfgs
->alphaSize
= ppfd
.cAlphaBits
;
5380 cfgs
->colorSize
= ppfd
.cColorBits
;
5381 cfgs
->depthSize
= ppfd
.cDepthBits
;
5382 cfgs
->stencilSize
= ppfd
.cStencilBits
;
5383 cfgs
->windowDrawable
= (ppfd
.dwFlags
& PFD_DRAW_TO_WINDOW
) ? 1 : 0;
5384 cfgs
->iPixelType
= (ppfd
.iPixelType
== PFD_TYPE_RGBA
) ? WGL_TYPE_RGBA_ARB
: WGL_TYPE_COLORINDEX_ARB
;
5385 cfgs
->doubleBuffer
= (ppfd
.dwFlags
& PFD_DOUBLEBUFFER
) ? 1 : 0;
5386 cfgs
->auxBuffers
= ppfd
.cAuxBuffers
;
5387 cfgs
->numSamples
= 0;
5389 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5390 "depth=%d, stencil=%d, windowDrawable=%d\n",
5391 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5392 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5393 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->windowDrawable
);
5398 /* Yikes we haven't found any suitable formats. This should only happen in case of GDI software rendering which we can't use anyway as its 3D functionality is very, very limited */
5401 ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
5403 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5404 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
5409 /* D16, D24X8 and D24S8 are common depth / depth+stencil formats. All drivers support them though this doesn't
5410 * mean that the format is offered in hardware. For instance Geforce8 cards don't have offer D16 in hardware
5411 * but just fake it using D24(X8?) which is fine. D3D also allows that.
5412 * Some display drivers (i915 on Linux) only report mixed depth+stencil formats like D24S8. MSDN clearly mentions
5413 * that only on lockable formats (e.g. D16_locked) the bit order is guaranteed and that on other formats the
5414 * driver is allowed to consume more bits EXCEPT for stencil bits.
5416 * Mark an adapter with this broken stencil behavior.
5418 adapter
->brokenStencil
= TRUE
;
5419 for (i
= 0, cfgs
= adapter
->cfgs
; i
< adapter
->nCfgs
; ++i
)
5421 /* Nearly all drivers offer depth formats without stencil, only on i915 this if-statement won't be entered. */
5422 if(cfgs
[i
].depthSize
&& !cfgs
[i
].stencilSize
) {
5423 adapter
->brokenStencil
= FALSE
;
5428 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5430 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
5431 fillGLAttribFuncs(&adapter
->gl_info
);
5432 adapter
->opengl
= TRUE
;
5434 wined3d
->adapter_count
= 1;
5435 TRACE("%u adapters successfully initialized.\n", wined3d
->adapter_count
);
5440 /* Initialize an adapter for ddraw-only memory counting */
5441 memset(wined3d
->adapters
, 0, sizeof(wined3d
->adapters
));
5442 wined3d
->adapters
[0].ordinal
= 0;
5443 wined3d
->adapters
[0].opengl
= FALSE
;
5444 wined3d
->adapters
[0].monitorPoint
.x
= -1;
5445 wined3d
->adapters
[0].monitorPoint
.y
= -1;
5447 wined3d
->adapters
[0].driver_info
.name
= "Display";
5448 wined3d
->adapters
[0].driver_info
.description
= "WineD3D DirectDraw Emulation";
5449 if (wined3d_settings
.emulated_textureram
)
5450 wined3d
->adapters
[0].TextureRam
= wined3d_settings
.emulated_textureram
;
5452 wined3d
->adapters
[0].TextureRam
= 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
5454 initPixelFormatsNoGL(&wined3d
->adapters
[0].gl_info
);
5456 wined3d
->adapter_count
= 1;
5460 static void STDMETHODCALLTYPE
wined3d_null_wined3d_object_destroyed(void *parent
) {}
5462 const struct wined3d_parent_ops wined3d_null_parent_ops
=
5464 wined3d_null_wined3d_object_destroyed
,
5467 /* Do not call while under the GL lock. */
5468 HRESULT
wined3d_init(struct wined3d
*wined3d
, UINT version
, DWORD flags
, void *parent
)
5470 wined3d
->dxVersion
= version
;
5472 wined3d
->parent
= parent
;
5473 wined3d
->flags
= flags
;
5475 if (!InitAdapters(wined3d
))
5477 WARN("Failed to initialize adapters.\n");
5480 MESSAGE("Direct3D%u is not available without OpenGL.\n", version
);