2 * Copyright 2002-2004 Jason Edmeades
3 * Copyright 2003-2004 Raphael Junqueira
4 * Copyright 2004 Christian Costa
5 * Copyright 2005 Oliver Stieber
6 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
7 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wined3d_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
29 WINE_DECLARE_DEBUG_CHANNEL(d3d_caps
);
31 #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
33 /* The driver names reflect the lowest GPU supported
34 * by a certain driver, so DRIVER_AMD_R300 supports
35 * R3xx, R4xx and R5xx GPUs. */
36 enum wined3d_display_driver
38 DRIVER_AMD_RAGE_128PRO
,
47 DRIVER_NVIDIA_GEFORCE2MX
,
48 DRIVER_NVIDIA_GEFORCEFX
,
49 DRIVER_NVIDIA_GEFORCE6
,
53 enum wined3d_driver_model
61 enum wined3d_gl_vendor
71 /* The d3d device ID */
72 static const GUID IID_D3DDEVICE_D3DUID
= { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
74 /* Extension detection */
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_alignment", ARB_MAP_BUFFER_ALIGNMENT
, 0 },
105 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE
, 0 },
106 {"GL_ARB_multisample", ARB_MULTISAMPLE
, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */
107 {"GL_ARB_multitexture", ARB_MULTITEXTURE
, 0 },
108 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY
, 0 },
109 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT
, 0 },
110 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS
, 0 },
111 {"GL_ARB_point_sprite", ARB_POINT_SPRITE
, 0 },
112 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX
, 0 },
113 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS
, 0 },
114 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD
, 0 },
115 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100
, 0 },
116 {"GL_ARB_shadow", ARB_SHADOW
, 0 },
117 {"GL_ARB_sync", ARB_SYNC
, 0 },
118 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP
, 0 },
119 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION
, 0 },
120 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC
, 0 },
121 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP
, 0 },
122 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD
, 0 },
123 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE
, 0 },
124 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3
, 0 },
125 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT
, 0 },
126 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT
, 0 },
127 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO
, MAKEDWORD_VERSION(2, 0) },
128 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE
, 0 },
129 {"GL_ARB_texture_rg", ARB_TEXTURE_RG
, 0 },
130 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
, 0 },
131 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND
, 0 },
132 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT
, 0 },
133 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM
, 0 },
134 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER
, 0 },
137 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER
, 0 },
138 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL
, 0 },
139 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC
, 0 },
140 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3
, 0 },
141 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE
, 0 },
144 {"GL_EXT_blend_color", EXT_BLEND_COLOR
, 0 },
145 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE
, 0 },
146 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE
, 0 },
147 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX
, 0 },
148 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT
, 0 },
149 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST
, 0 },
150 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2
, 0 },
151 {"GL_EXT_fog_coord", EXT_FOG_COORD
, 0 },
152 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT
, 0 },
153 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE
, 0 },
154 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT
, 0 },
155 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS
, 0 },
156 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4
, 0 },
157 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL
, 0 },
158 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE
, 0 },
159 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS
, 0 },
160 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX
, 0 },
161 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR
, 0 },
162 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE
, 0 },
163 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP
, 0 },
164 {"GL_EXT_texture3D", EXT_TEXTURE3D
, MAKEDWORD_VERSION(1, 2) },
165 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC
, 0 },
166 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC
, 0 },
167 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD
, 0 },
168 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE
, 0 },
169 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3
, 0 },
170 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC
, 0 },
171 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS
, 0 },
172 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB
, 0 },
173 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE
, 0 },
174 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA
, 0 },
177 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP
, 0 },
178 {"GL_NV_fence", NV_FENCE
, 0 },
179 {"GL_NV_fog_distance", NV_FOG_DISTANCE
, 0 },
180 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM
, 0 },
181 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2
, 0 },
182 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION
, 0 },
183 {"GL_NV_half_float", NV_HALF_FLOAT
, 0 },
184 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT
, 0 },
185 {"GL_NV_point_sprite", NV_POINT_SPRITE
, 0 },
186 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS
, 0 },
187 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2
, 0 },
188 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION
, 0 },
189 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4
, 0 },
190 {"GL_NV_texture_shader", NV_TEXTURE_SHADER
, 0 },
191 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2
, 0 },
192 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM
, 0 },
193 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1
, 0 },
194 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2
, 0 },
195 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION
, 0 },
196 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3
, 0 },
199 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP
, 0 },
202 /**********************************************************
203 * Utility functions follow
204 **********************************************************/
206 const struct min_lookup minMipLookup
[] =
208 /* NONE POINT LINEAR */
209 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
210 {{GL_NEAREST
, GL_NEAREST_MIPMAP_NEAREST
, GL_NEAREST_MIPMAP_LINEAR
}}, /* POINT*/
211 {{GL_LINEAR
, GL_LINEAR_MIPMAP_NEAREST
, GL_LINEAR_MIPMAP_LINEAR
}}, /* LINEAR */
214 const struct min_lookup minMipLookup_noFilter
[] =
216 /* NONE POINT LINEAR */
217 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
218 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
219 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* LINEAR */
222 const struct min_lookup minMipLookup_noMip
[] =
224 /* NONE POINT LINEAR */
225 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
226 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
227 {{GL_LINEAR
, GL_LINEAR
, GL_LINEAR
}}, /* LINEAR */
230 const GLenum magLookup
[] =
232 /* NONE POINT LINEAR */
233 GL_NEAREST
, GL_NEAREST
, GL_LINEAR
,
236 const GLenum magLookup_noFilter
[] =
238 /* NONE POINT LINEAR */
239 GL_NEAREST
, GL_NEAREST
, GL_NEAREST
,
242 /* drawStridedSlow attributes */
243 glAttribFunc position_funcs
[WINED3D_FFP_EMIT_COUNT
];
244 glAttribFunc diffuse_funcs
[WINED3D_FFP_EMIT_COUNT
];
245 glAttribFunc specular_func_3ubv
;
246 glAttribFunc specular_funcs
[WINED3D_FFP_EMIT_COUNT
];
247 glAttribFunc normal_funcs
[WINED3D_FFP_EMIT_COUNT
];
248 glMultiTexCoordFunc multi_texcoord_funcs
[WINED3D_FFP_EMIT_COUNT
];
251 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
252 * i.e., there is no GL Context - Get a default rendering context to enable the
253 * function query some info from GL.
256 struct wined3d_fake_gl_ctx
262 HGLRC restore_gl_ctx
;
265 static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx
*ctx
)
267 TRACE_(d3d_caps
)("Destroying fake GL context.\n");
269 if (!pwglMakeCurrent(NULL
, NULL
))
271 ERR_(d3d_caps
)("Failed to disable fake GL context.\n");
274 if (!pwglDeleteContext(ctx
->gl_ctx
))
276 DWORD err
= GetLastError();
277 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx
->gl_ctx
, err
);
280 ReleaseDC(ctx
->wnd
, ctx
->dc
);
281 DestroyWindow(ctx
->wnd
);
283 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
285 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
289 /* Do not call while under the GL lock. */
290 static BOOL
WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx
*ctx
)
292 PIXELFORMATDESCRIPTOR pfd
;
295 TRACE("getting context...\n");
297 ctx
->restore_dc
= pwglGetCurrentDC();
298 ctx
->restore_gl_ctx
= pwglGetCurrentContext();
300 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
301 ctx
->wnd
= CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME
, "WineD3D fake window",
302 WS_OVERLAPPEDWINDOW
, 10, 10, 10, 10, NULL
, NULL
, NULL
, NULL
);
305 ERR_(d3d_caps
)("Failed to create a window.\n");
309 ctx
->dc
= GetDC(ctx
->wnd
);
312 ERR_(d3d_caps
)("Failed to get a DC.\n");
316 /* PixelFormat selection */
317 ZeroMemory(&pfd
, sizeof(pfd
));
318 pfd
.nSize
= sizeof(pfd
);
320 pfd
.dwFlags
= PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
; /* PFD_GENERIC_ACCELERATED */
321 pfd
.iPixelType
= PFD_TYPE_RGBA
;
323 pfd
.iLayerType
= PFD_MAIN_PLANE
;
325 iPixelFormat
= ChoosePixelFormat(ctx
->dc
, &pfd
);
328 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
329 ERR_(d3d_caps
)("Can't find a suitable iPixelFormat.\n");
332 DescribePixelFormat(ctx
->dc
, iPixelFormat
, sizeof(pfd
), &pfd
);
333 SetPixelFormat(ctx
->dc
, iPixelFormat
, &pfd
);
335 /* Create a GL context. */
336 ctx
->gl_ctx
= pwglCreateContext(ctx
->dc
);
339 WARN_(d3d_caps
)("Error creating default context for capabilities initialization.\n");
343 /* Make it the current GL context. */
344 if (!context_set_current(NULL
))
346 ERR_(d3d_caps
)("Failed to clear current D3D context.\n");
349 if (!pwglMakeCurrent(ctx
->dc
, ctx
->gl_ctx
))
351 ERR_(d3d_caps
)("Failed to make fake GL context current.\n");
358 if (ctx
->gl_ctx
) pwglDeleteContext(ctx
->gl_ctx
);
360 if (ctx
->dc
) ReleaseDC(ctx
->wnd
, ctx
->dc
);
362 if (ctx
->wnd
) DestroyWindow(ctx
->wnd
);
364 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
366 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
372 /* Adjust the amount of used texture memory */
373 unsigned int adapter_adjust_memory(struct wined3d_adapter
*adapter
, int amount
)
375 adapter
->UsedTextureRam
+= amount
;
376 TRACE("Adjusted adapter memory by %d to %d.\n", amount
, adapter
->UsedTextureRam
);
377 return adapter
->UsedTextureRam
;
380 static void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
)
382 HeapFree(GetProcessHeap(), 0, adapter
->gl_info
.formats
);
383 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
386 ULONG CDECL
wined3d_incref(struct wined3d
*wined3d
)
388 ULONG refcount
= InterlockedIncrement(&wined3d
->ref
);
390 TRACE("%p increasing refcount to %u.\n", wined3d
, refcount
);
395 ULONG CDECL
wined3d_decref(struct wined3d
*wined3d
)
397 ULONG refcount
= InterlockedDecrement(&wined3d
->ref
);
399 TRACE("%p decreasing refcount to %u.\n", wined3d
, refcount
);
405 for (i
= 0; i
< wined3d
->adapter_count
; ++i
)
407 wined3d_adapter_cleanup(&wined3d
->adapters
[i
]);
409 HeapFree(GetProcessHeap(), 0, wined3d
);
415 /* GL locking is done by the caller */
416 static inline BOOL
test_arb_vs_offset_limit(const struct wined3d_gl_info
*gl_info
)
420 const char *testcode
=
422 "PARAM C[66] = { program.env[0..65] };\n"
424 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
425 "ARL A0.x, zero.x;\n"
426 "MOV result.position, C[A0.x + 65];\n"
430 GL_EXTCALL(glGenProgramsARB(1, &prog
));
432 ERR("Failed to create an ARB offset limit test program\n");
434 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
435 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
436 strlen(testcode
), testcode
));
439 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
440 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
442 } else TRACE("OpenGL implementation allows offsets > 63\n");
444 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
445 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
446 checkGLcall("ARB vp offset limit test cleanup");
451 static DWORD
ver_for_ext(enum wined3d_gl_extension ext
)
454 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
) {
455 if(EXTENSION_MAP
[i
].extension
== ext
) {
456 return EXTENSION_MAP
[i
].version
;
462 static BOOL
match_amd_r300_to_500(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
463 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
465 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
466 if (device
== CARD_AMD_RADEON_9500
) return TRUE
;
467 if (device
== CARD_AMD_RADEON_X700
) return TRUE
;
468 if (device
== CARD_AMD_RADEON_X1600
) return TRUE
;
472 static BOOL
match_geforce5(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
473 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
475 if (card_vendor
== HW_VENDOR_NVIDIA
)
477 if (device
== CARD_NVIDIA_GEFORCEFX_5200
||
478 device
== CARD_NVIDIA_GEFORCEFX_5600
||
479 device
== CARD_NVIDIA_GEFORCEFX_5800
)
487 static BOOL
match_apple(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
488 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
490 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
491 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
492 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
494 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
495 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
496 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
497 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
498 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
499 * the chance that other implementations support them is rather small since Win32 QuickTime uses
500 * DirectDraw, not OpenGL.
502 * This test has been moved into wined3d_guess_gl_vendor()
504 if (gl_vendor
== GL_VENDOR_APPLE
)
511 /* Context activation is done by the caller. */
512 static void test_pbo_functionality(struct wined3d_gl_info
*gl_info
)
514 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
515 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
516 * all the texture. This function detects this bug by its symptom and disables PBOs
519 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
520 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
521 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
522 * read back is compared to the original. If they are equal PBOs are assumed to work,
523 * otherwise the PBO extension is disabled. */
525 static const unsigned int pattern
[] =
527 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
528 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
529 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
530 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
532 unsigned int check
[sizeof(pattern
) / sizeof(pattern
[0])];
534 /* No PBO -> No point in testing them. */
535 if (!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
]) return;
539 while (glGetError());
540 glGenTextures(1, &texture
);
541 glBindTexture(GL_TEXTURE_2D
, texture
);
543 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAX_LEVEL
, 0);
544 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0);
545 checkGLcall("Specifying the PBO test texture");
547 GL_EXTCALL(glGenBuffersARB(1, &pbo
));
548 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, pbo
));
549 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB
, sizeof(pattern
), pattern
, GL_STREAM_DRAW_ARB
));
550 checkGLcall("Specifying the PBO test pbo");
552 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
553 checkGLcall("Loading the PBO test texture");
555 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, 0));
558 wglFinish(); /* just to be sure */
560 memset(check
, 0, sizeof(check
));
562 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, check
);
563 checkGLcall("Reading back the PBO test texture");
565 glDeleteTextures(1, &texture
);
566 GL_EXTCALL(glDeleteBuffersARB(1, &pbo
));
567 checkGLcall("PBO test cleanup");
571 if (memcmp(check
, pattern
, sizeof(check
)))
573 WARN_(d3d_caps
)("PBO test failed, read back data doesn't match original.\n");
574 WARN_(d3d_caps
)("Disabling PBOs. This may result in slower performance.\n");
575 gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
] = FALSE
;
579 TRACE_(d3d_caps
)("PBO test successful.\n");
583 static BOOL
match_apple_intel(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
584 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
586 return (card_vendor
== HW_VENDOR_INTEL
) && (gl_vendor
== GL_VENDOR_APPLE
);
589 static BOOL
match_apple_nonr500ati(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
590 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
592 if (gl_vendor
!= GL_VENDOR_APPLE
) return FALSE
;
593 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
594 if (device
== CARD_AMD_RADEON_X1600
) return FALSE
;
598 static BOOL
match_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
599 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
601 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
602 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
603 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
604 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
607 * dx10 cards usually have 64 varyings */
608 return gl_info
->limits
.glsl_varyings
> 44;
611 static BOOL
match_not_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
612 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
614 return !match_dx10_capable(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
);
617 /* A GL context is provided by the caller */
618 static BOOL
match_allows_spec_alpha(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
619 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
624 if (!gl_info
->supported
[EXT_SECONDARY_COLOR
]) return FALSE
;
628 GL_EXTCALL(glSecondaryColorPointerEXT
)(4, GL_UNSIGNED_BYTE
, 4, data
);
629 error
= glGetError();
632 if(error
== GL_NO_ERROR
)
634 TRACE("GL Implementation accepts 4 component specular color pointers\n");
639 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
640 debug_glerror(error
));
645 static BOOL
match_apple_nvts(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
646 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
648 if (!match_apple(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) return FALSE
;
649 return gl_info
->supported
[NV_TEXTURE_SHADER
];
652 /* A GL context is provided by the caller */
653 static BOOL
match_broken_nv_clip(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
654 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
659 const char *testcode
=
661 "OPTION NV_vertex_program2;\n"
662 "MOV result.clip[0], 0.0;\n"
663 "MOV result.position, 0.0;\n"
666 if (!gl_info
->supported
[NV_VERTEX_PROGRAM2_OPTION
]) return FALSE
;
671 GL_EXTCALL(glGenProgramsARB(1, &prog
));
674 ERR("Failed to create the NVvp clip test program\n");
678 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
679 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
680 strlen(testcode
), testcode
));
681 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &pos
);
684 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
685 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
689 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
691 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
692 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
693 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
699 /* Context activation is done by the caller. */
700 static BOOL
match_fbo_tex_update(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
701 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
703 char data
[4 * 4 * 4];
707 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
) return FALSE
;
709 memset(data
, 0xcc, sizeof(data
));
713 glGenTextures(1, &tex
);
714 glBindTexture(GL_TEXTURE_2D
, tex
);
715 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
716 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
717 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
718 checkGLcall("glTexImage2D");
720 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
721 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
722 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
723 checkGLcall("glFramebufferTexture2D");
725 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
726 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
727 checkGLcall("glCheckFramebufferStatus");
729 memset(data
, 0x11, sizeof(data
));
730 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
731 checkGLcall("glTexSubImage2D");
733 glClearColor(0.996f
, 0.729f
, 0.745f
, 0.792f
);
734 glClear(GL_COLOR_BUFFER_BIT
);
735 checkGLcall("glClear");
737 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
738 checkGLcall("glGetTexImage");
740 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
741 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
742 glBindTexture(GL_TEXTURE_2D
, 0);
743 checkGLcall("glBindTexture");
745 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
746 glDeleteTextures(1, &tex
);
747 checkGLcall("glDeleteTextures");
751 return *(DWORD
*)data
== 0x11111111;
754 /* Context activation is done by the caller. */
755 static BOOL
match_broken_rgba16(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
756 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
758 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
759 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
765 glGenTextures(1, &tex
);
766 glBindTexture(GL_TEXTURE_2D
, tex
);
767 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA16
, 4, 4, 0, GL_RGBA
, GL_UNSIGNED_SHORT
, NULL
);
768 checkGLcall("glTexImage2D");
770 glGetTexLevelParameteriv(GL_TEXTURE_2D
, 0, GL_TEXTURE_RED_SIZE
, &size
);
771 checkGLcall("glGetTexLevelParameteriv");
772 TRACE("Real color depth is %d\n", size
);
774 glBindTexture(GL_TEXTURE_2D
, 0);
775 checkGLcall("glBindTexture");
776 glDeleteTextures(1, &tex
);
777 checkGLcall("glDeleteTextures");
784 static BOOL
match_fglrx(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
785 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
787 return gl_vendor
== GL_VENDOR_FGLRX
;
790 static void quirk_arb_constants(struct wined3d_gl_info
*gl_info
)
792 TRACE_(d3d_caps
)("Using ARB vs constant limit(=%u) for GLSL.\n", gl_info
->limits
.arb_vs_native_constants
);
793 gl_info
->limits
.glsl_vs_float_constants
= gl_info
->limits
.arb_vs_native_constants
;
794 TRACE_(d3d_caps
)("Using ARB ps constant limit(=%u) for GLSL.\n", gl_info
->limits
.arb_ps_native_constants
);
795 gl_info
->limits
.glsl_ps_float_constants
= gl_info
->limits
.arb_ps_native_constants
;
798 static void quirk_apple_glsl_constants(struct wined3d_gl_info
*gl_info
)
800 quirk_arb_constants(gl_info
);
801 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
802 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
803 * allow 48 different offsets or other helper immediate values. */
804 TRACE_(d3d_caps
)("Reserving 12 GLSL constants for compiler private use.\n");
805 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 12);
808 static void quirk_amd_dx9(struct wined3d_gl_info
*gl_info
)
810 quirk_arb_constants(gl_info
);
812 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
813 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
814 * If real NP2 textures are used, the driver falls back to software. We could just remove the
815 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
816 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
817 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
818 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
820 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
821 * has this extension promoted to core. The extension loading code sets this extension supported
822 * due to that, so this code works on fglrx as well. */
823 if(gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
825 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
826 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
827 gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
] = TRUE
;
830 /* fglrx has the same structural issues as the one described in quirk_apple_glsl_constants, although
831 * it is generally more efficient. Reserve just 8 constants. */
832 TRACE_(d3d_caps
)("Reserving 8 GLSL constants for compiler private use.\n");
833 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 8);
836 static void quirk_no_np2(struct wined3d_gl_info
*gl_info
)
838 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
839 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
840 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
841 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
842 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
843 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
845 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
846 * triggering the software fallback. There is not much we can do here apart from disabling the
847 * software-emulated extension and reenable ARB_tex_rect (which was previously disabled
848 * in wined3d_adapter_init_gl_caps).
849 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
850 * post-processing effects in the game "Max Payne 2").
851 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
852 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
853 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
854 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = TRUE
;
857 static void quirk_texcoord_w(struct wined3d_gl_info
*gl_info
)
859 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
860 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
861 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
862 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
863 * according to the spec.
865 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
866 * makes the shader slower and eats instruction slots which should be available to the d3d app.
868 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
869 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
870 * this workaround is activated on cards that do not need it, it won't break things, just affect
871 * performance negatively. */
872 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
873 gl_info
->quirks
|= WINED3D_QUIRK_SET_TEXCOORD_W
;
876 static void quirk_clip_varying(struct wined3d_gl_info
*gl_info
)
878 gl_info
->quirks
|= WINED3D_QUIRK_GLSL_CLIP_VARYING
;
881 static void quirk_allows_specular_alpha(struct wined3d_gl_info
*gl_info
)
883 gl_info
->quirks
|= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
;
886 static void quirk_apple_nvts(struct wined3d_gl_info
*gl_info
)
888 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
889 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
892 static void quirk_disable_nvvp_clip(struct wined3d_gl_info
*gl_info
)
894 gl_info
->quirks
|= WINED3D_QUIRK_NV_CLIP_BROKEN
;
897 static void quirk_fbo_tex_update(struct wined3d_gl_info
*gl_info
)
899 gl_info
->quirks
|= WINED3D_QUIRK_FBO_TEX_UPDATE
;
902 static void quirk_broken_rgba16(struct wined3d_gl_info
*gl_info
)
904 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_RGBA16
;
907 static void quirk_infolog_spam(struct wined3d_gl_info
*gl_info
)
909 gl_info
->quirks
|= WINED3D_QUIRK_INFO_LOG_SPAM
;
912 static void quirk_limited_tex_filtering(struct wined3d_gl_info
*gl_info
)
914 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
915 selected texture formats. They are apparently the only DX9 class GPUs
917 Also, DX9-era GPUs are somewhat limited with float textures
918 filtering and blending. */
919 gl_info
->quirks
|= WINED3D_QUIRK_LIMITED_TEX_FILTERING
;
924 BOOL (*match
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
925 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
);
926 void (*apply
)(struct wined3d_gl_info
*gl_info
);
927 const char *description
;
930 static const struct driver_quirk quirk_table
[] =
933 match_amd_r300_to_500
,
935 "AMD GLSL constant and normalized texrect quirk"
937 /* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
938 * used it falls back to software. While the compiler can detect if the shader uses all declared
939 * uniforms, the optimization fails if the shader uses relative addressing. So any GLSL shader
940 * using relative addressing falls back to software.
942 * ARB vp gives the correct amount of uniforms, so use it instead of GLSL. */
945 quirk_apple_glsl_constants
,
946 "Apple GLSL uniform override"
951 "Geforce 5 NP2 disable"
956 "Init texcoord .w for Apple Intel GPU driver"
959 match_apple_nonr500ati
,
961 "Init texcoord .w for Apple ATI >= r600 GPU driver"
966 "Reserved varying for gl_ClipPos"
969 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
970 * GL implementations accept it. The Mac GL is the only implementation known to
973 * If we can pass 4 component specular colors, do it, because (a) we don't have
974 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
975 * passes specular alpha to the pixel shader if any is used. Otherwise the
976 * specular alpha is used to pass the fog coordinate, which we pass to opengl
977 * via GL_EXT_fog_coord.
979 match_allows_spec_alpha
,
980 quirk_allows_specular_alpha
,
981 "Allow specular alpha quirk"
984 /* The pixel formats provided by GL_NV_texture_shader are broken on OSX
989 "Apple NV_texture_shader disable"
992 match_broken_nv_clip
,
993 quirk_disable_nvvp_clip
,
994 "Apple NV_vertex_program clip bug quirk"
997 match_fbo_tex_update
,
998 quirk_fbo_tex_update
,
999 "FBO rebind for attachment updates"
1002 match_broken_rgba16
,
1003 quirk_broken_rgba16
,
1004 "True RGBA16 is not available"
1009 "Not printing GLSL infolog"
1012 match_not_dx10_capable
,
1013 quirk_limited_tex_filtering
,
1014 "Texture filtering, blending and VTF support is limited"
1018 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
1019 * reporting a driver version is moot because we are not the Windows driver, and we have different
1020 * bugs, features, etc.
1022 * The driver version has the form "x.y.z.w".
1024 * "x" is the Windows version the driver is meant for:
1031 * "y" is the maximum Direct3D version the driver supports.
1032 * y -> d3d version mapping:
1041 * "z" is the subversion number.
1043 * "w" is the vendor specific driver build number.
1046 struct driver_version_information
1048 enum wined3d_display_driver driver
;
1049 enum wined3d_driver_model driver_model
;
1050 const char *driver_name
; /* name of Windows driver */
1051 WORD version
; /* version word ('y'), contained in low word of DriverVersion.HighPart */
1052 WORD subversion
; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
1053 WORD build
; /* build number ('w'), contained in low word of DriverVersion.LowPart */
1056 /* The driver version table contains driver information for different devices on several OS versions. */
1057 static const struct driver_version_information driver_version_table
[] =
1060 * - Radeon HD2x00 (R600) and up supported by current drivers.
1061 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1062 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1063 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1064 {DRIVER_AMD_RAGE_128PRO
, DRIVER_MODEL_NT5X
, "ati2dvaa.dll", 13, 3279, 0},
1065 {DRIVER_AMD_R100
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6614},
1066 {DRIVER_AMD_R300
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6764},
1067 {DRIVER_AMD_R600
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 8681},
1068 {DRIVER_AMD_R300
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1069 {DRIVER_AMD_R600
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1072 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1073 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1074 * igxprd32.dll but the GMA800 driver was never updated. */
1075 {DRIVER_INTEL_GMA800
, DRIVER_MODEL_NT5X
, "ialmrnt5.dll", 14, 10, 3889},
1076 {DRIVER_INTEL_GMA900
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4764},
1077 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4926},
1078 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 5218},
1079 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 14, 10, 1504},
1080 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 15, 10, 1666},
1083 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1084 * - GeforceFX support is up to 173.x on <= XP
1085 * - Geforce2MX/3/4 up to 96.x on <= XP
1086 * - TNT/Geforce1/2 up to 71.x on <= XP
1087 * All version numbers used below are from the Linux nvidia drivers. */
1088 {DRIVER_NVIDIA_TNT
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 7186},
1089 {DRIVER_NVIDIA_GEFORCE2MX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 9371},
1090 {DRIVER_NVIDIA_GEFORCEFX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 11, 7516},
1091 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 15, 12, 6658},
1092 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 15, 12, 6658},
1095 struct gpu_description
1097 WORD vendor
; /* reported PCI card vendor ID */
1098 WORD card
; /* reported PCI card device ID */
1099 const char *description
; /* Description of the card e.g. NVIDIA RIVA TNT */
1100 enum wined3d_display_driver driver
;
1101 unsigned int vidmem
;
1104 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1105 * found on a board containing a specific GPU. */
1106 static const struct gpu_description gpu_description_table
[] =
1109 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT
, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT
, 16 },
1110 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT2
, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1111 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE
, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT
, 32 },
1112 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2
, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1113 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2_MX
, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX
,32 },
1114 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE3
, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1115 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_MX
, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1116 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_TI4200
, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX
,64, },
1117 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5200
, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX
, 64 },
1118 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5600
, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX
, 128 },
1119 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5800
, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX
, 256 },
1120 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6200
, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6
, 64 },
1121 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6600GT
, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6
, 128 },
1122 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6800
, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6
, 128 },
1123 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7300
, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6
, 256 },
1124 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7400
, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6
, 256 },
1125 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7600
, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1126 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7800GT
, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1127 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8300GS
, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1128 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8400GS
, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1129 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600GT
, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1130 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600MGT
, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1131 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTS
, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6
, 320 },
1132 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTX
, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6
, 768 },
1133 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9200
, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6
, 256 },
1134 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400GT
, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1135 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9500GT
, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1136 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9600GT
, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6
, 384 },
1137 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9800GT
, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1138 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_210
, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6
, 512 },
1139 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT220
, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6
, 512 },
1140 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT240
, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6
, 512 },
1141 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX260
, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6
, 1024},
1142 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX275
, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6
, 896 },
1143 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX280
, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6
, 1024},
1144 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT320M
, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1145 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT325M
, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1146 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT330
, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6
, 1024},
1147 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS350M
, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1148 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT420
, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6
, 2048},
1149 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT430
, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6
, 1024},
1150 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT440
, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6
, 1024},
1151 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS450
, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6
, 1024},
1152 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460
, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6
, 768 },
1153 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460M
, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE6
, 1536},
1154 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX465
, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6
, 1024},
1155 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX470
, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6
, 1280},
1156 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX480
, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6
, 1536},
1157 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX550
, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1158 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT555M
, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1159 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560TI
, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1160 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560
, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE6
, 1024},
1161 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX570
, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6
, 1280},
1162 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX580
, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6
, 1536},
1165 {HW_VENDOR_AMD
, CARD_AMD_RAGE_128PRO
, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO
, 16 },
1166 {HW_VENDOR_AMD
, CARD_AMD_RADEON_7200
, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100
, 32 },
1167 {HW_VENDOR_AMD
, CARD_AMD_RADEON_8500
, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100
, 64 },
1168 {HW_VENDOR_AMD
, CARD_AMD_RADEON_9500
, "ATI Radeon 9500", DRIVER_AMD_R300
, 64 },
1169 {HW_VENDOR_AMD
, CARD_AMD_RADEON_XPRESS_200M
, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300
, 64 },
1170 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X700
, "ATI Radeon X700 SE", DRIVER_AMD_R300
, 128 },
1171 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X1600
, "ATI Radeon X1600 Series", DRIVER_AMD_R300
, 128 },
1172 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2350
, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600
, 256 },
1173 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2600
, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600
, 256 },
1174 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2900
, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600
, 512 },
1175 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD3200
, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600
, 128 },
1176 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4350
, "ATI Radeon HD 4350", DRIVER_AMD_R600
, 256 },
1177 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4600
, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600
, 512 },
1178 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4700
, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600
, 512 },
1179 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4800
, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600
, 512 },
1180 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5400
, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600
, 512 },
1181 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5600
, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600
, 512 },
1182 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5700
, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600
, 512 },
1183 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5800
, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600
, 1024},
1184 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5900
, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600
, 1024},
1185 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6300
, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600
, 1024},
1186 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6400
, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600
, 1024},
1187 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6410D
, "AMD Radeon HD 6410D", DRIVER_AMD_R600
, 1024},
1188 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6550D
, "AMD Radeon HD 6550D", DRIVER_AMD_R600
, 1024},
1189 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600
, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600
, 1024},
1190 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600M
, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600
, 512 },
1191 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6800
, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600
, 1024},
1192 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6900
, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600
, 2048},
1194 {HW_VENDOR_INTEL
, CARD_INTEL_I830G
, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1195 {HW_VENDOR_INTEL
, CARD_INTEL_I855G
, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1196 {HW_VENDOR_INTEL
, CARD_INTEL_I865G
, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1197 {HW_VENDOR_INTEL
, CARD_INTEL_I915G
, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1198 {HW_VENDOR_INTEL
, CARD_INTEL_I915GM
, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1199 {HW_VENDOR_INTEL
, CARD_INTEL_I945GM
, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950
, 64 },
1200 {HW_VENDOR_INTEL
, CARD_INTEL_X3100
, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000
, 128},
1201 {HW_VENDOR_INTEL
, CARD_INTEL_GM45
, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000
, 512}
1204 static const struct driver_version_information
*get_driver_version_info(enum wined3d_display_driver driver
,
1205 enum wined3d_driver_model driver_model
)
1209 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver
, driver_model
);
1210 for (i
= 0; i
< (sizeof(driver_version_table
) / sizeof(driver_version_table
[0])); i
++)
1212 const struct driver_version_information
*entry
= &driver_version_table
[i
];
1214 if (entry
->driver
== driver
&& entry
->driver_model
== driver_model
)
1216 TRACE_(d3d_caps
)("Found driver '%s' version=%d subversion=%d build=%d\n",
1217 entry
->driver_name
, entry
->version
, entry
->subversion
, entry
->build
);
1225 static void init_driver_info(struct wined3d_driver_info
*driver_info
,
1226 enum wined3d_pci_vendor vendor
, enum wined3d_pci_device device
)
1228 OSVERSIONINFOW os_version
;
1229 WORD driver_os_version
;
1231 enum wined3d_display_driver driver
= DRIVER_UNKNOWN
;
1232 enum wined3d_driver_model driver_model
;
1233 const struct driver_version_information
*version_info
;
1235 if (wined3d_settings
.pci_vendor_id
!= PCI_VENDOR_NONE
)
1237 TRACE_(d3d_caps
)("Overriding PCI vendor ID with: %04x\n", wined3d_settings
.pci_vendor_id
);
1238 vendor
= wined3d_settings
.pci_vendor_id
;
1240 driver_info
->vendor
= vendor
;
1242 if (wined3d_settings
.pci_device_id
!= PCI_DEVICE_NONE
)
1244 TRACE_(d3d_caps
)("Overriding PCI device ID with: %04x\n", wined3d_settings
.pci_device_id
);
1245 device
= wined3d_settings
.pci_device_id
;
1247 driver_info
->device
= device
;
1249 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1250 * overrides the pci ids to a card which is not in our database. */
1251 driver_info
->vidmem
= WINE_DEFAULT_VIDMEM
;
1253 memset(&os_version
, 0, sizeof(os_version
));
1254 os_version
.dwOSVersionInfoSize
= sizeof(os_version
);
1255 if (!GetVersionExW(&os_version
))
1257 ERR("Failed to get OS version, reporting 2000/XP.\n");
1258 driver_os_version
= 6;
1259 driver_model
= DRIVER_MODEL_NT5X
;
1263 TRACE("OS version %u.%u.\n", os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1264 switch (os_version
.dwMajorVersion
)
1267 /* If needed we could distinguish between 9x and NT4, but this code won't make
1268 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1270 driver_os_version
= 4;
1271 driver_model
= DRIVER_MODEL_WIN9X
;
1275 driver_os_version
= 6;
1276 driver_model
= DRIVER_MODEL_NT5X
;
1280 if (os_version
.dwMinorVersion
== 0)
1282 driver_os_version
= 7;
1283 driver_model
= DRIVER_MODEL_NT6X
;
1287 if (os_version
.dwMinorVersion
> 1)
1289 FIXME("Unhandled OS version %u.%u, reporting Win 7.\n",
1290 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1292 driver_os_version
= 8;
1293 driver_model
= DRIVER_MODEL_NT6X
;
1298 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1299 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1300 driver_os_version
= 6;
1301 driver_model
= DRIVER_MODEL_NT5X
;
1306 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1307 * This means that unless the ids are overriden, we will always find a GPU description. */
1308 for (i
= 0; i
< (sizeof(gpu_description_table
) / sizeof(gpu_description_table
[0])); i
++)
1310 if (vendor
== gpu_description_table
[i
].vendor
&& device
== gpu_description_table
[i
].card
)
1312 TRACE_(d3d_caps
)("Found card %04x:%04x in driver DB.\n", vendor
, device
);
1314 driver_info
->description
= gpu_description_table
[i
].description
;
1315 driver_info
->vidmem
= gpu_description_table
[i
].vidmem
* 1024*1024;
1316 driver
= gpu_description_table
[i
].driver
;
1321 if (wined3d_settings
.emulated_textureram
)
1323 TRACE_(d3d_caps
)("Overriding amount of video memory with: %d byte\n", wined3d_settings
.emulated_textureram
);
1324 driver_info
->vidmem
= wined3d_settings
.emulated_textureram
;
1327 /* Try to obtain driver version information for the current Windows version. This fails in
1329 * - the gpu is not available on the currently selected OS version:
1330 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1331 * version information for the current Windows version is returned instead of faked info.
1332 * We do the same and assume the default Windows version to emulate is WinXP.
1334 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1335 * For now return the XP driver info. Perhaps later on we should return VESA.
1337 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1338 * This could be an indication that our database is not up to date, so this should be fixed.
1340 version_info
= get_driver_version_info(driver
, driver_model
);
1343 driver_info
->name
= version_info
->driver_name
;
1344 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1345 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1349 version_info
= get_driver_version_info(driver
, DRIVER_MODEL_NT5X
);
1352 driver_info
->name
= version_info
->driver_name
;
1353 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1354 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1358 driver_info
->description
= "Direct3D HAL";
1359 driver_info
->name
= "Display";
1360 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, 15);
1361 driver_info
->version_low
= MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1363 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1364 vendor
, device
, driver_model
);
1368 TRACE_(d3d_caps
)("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1369 driver_info
->version_high
, driver_info
->version_low
);
1372 /* Context activation is done by the caller. */
1373 static void fixup_extensions(struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
1374 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
1378 for (i
= 0; i
< (sizeof(quirk_table
) / sizeof(*quirk_table
)); ++i
)
1380 if (!quirk_table
[i
].match(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) continue;
1381 TRACE_(d3d_caps
)("Applying driver quirk \"%s\".\n", quirk_table
[i
].description
);
1382 quirk_table
[i
].apply(gl_info
);
1385 /* Find out if PBOs work as they are supposed to. */
1386 test_pbo_functionality(gl_info
);
1389 static DWORD
wined3d_parse_gl_version(const char *gl_version
)
1391 const char *ptr
= gl_version
;
1395 if (major
<= 0) ERR_(d3d_caps
)("Invalid opengl major version: %d.\n", major
);
1397 while (isdigit(*ptr
)) ++ptr
;
1398 if (*ptr
++ != '.') ERR_(d3d_caps
)("Invalid opengl version string: %s.\n", debugstr_a(gl_version
));
1402 TRACE_(d3d_caps
)("Found OpenGL version: %d.%d.\n", major
, minor
);
1404 return MAKEDWORD_VERSION(major
, minor
);
1407 static enum wined3d_gl_vendor
wined3d_guess_gl_vendor(const struct wined3d_gl_info
*gl_info
,
1408 const char *gl_vendor_string
, const char *gl_renderer
)
1411 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1412 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1413 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1415 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1416 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1417 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1418 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1419 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1420 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1421 * DirectDraw, not OpenGL. */
1422 if (gl_info
->supported
[APPLE_FENCE
]
1423 && gl_info
->supported
[APPLE_CLIENT_STORAGE
]
1424 && gl_info
->supported
[APPLE_FLUSH_RENDER
]
1425 && gl_info
->supported
[APPLE_YCBCR_422
])
1426 return GL_VENDOR_APPLE
;
1428 if (strstr(gl_vendor_string
, "NVIDIA"))
1429 return GL_VENDOR_NVIDIA
;
1431 if (strstr(gl_vendor_string
, "ATI"))
1432 return GL_VENDOR_FGLRX
;
1434 if (strstr(gl_vendor_string
, "Intel(R)")
1435 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1436 || strstr(gl_renderer
, "Intel")
1437 || strstr(gl_vendor_string
, "Intel Inc."))
1438 return GL_VENDOR_INTEL
;
1440 if (strstr(gl_vendor_string
, "Mesa")
1441 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1442 || strstr(gl_vendor_string
, "DRI R300 Project")
1443 || strstr(gl_vendor_string
, "X.Org R300 Project")
1444 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1445 || strstr(gl_vendor_string
, "VMware, Inc.")
1446 || strstr(gl_renderer
, "Mesa")
1447 || strstr(gl_renderer
, "Gallium"))
1448 return GL_VENDOR_MESA
;
1450 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1451 debugstr_a(gl_vendor_string
));
1453 return GL_VENDOR_UNKNOWN
;
1456 static enum wined3d_pci_vendor
wined3d_guess_card_vendor(const char *gl_vendor_string
, const char *gl_renderer
)
1458 if (strstr(gl_vendor_string
, "NVIDIA")
1459 || strstr(gl_vendor_string
, "nouveau"))
1460 return HW_VENDOR_NVIDIA
;
1462 if (strstr(gl_vendor_string
, "ATI")
1463 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1464 || strstr(gl_vendor_string
, "X.Org R300 Project")
1465 || strstr(gl_renderer
, "AMD")
1466 || strstr(gl_renderer
, "R100")
1467 || strstr(gl_renderer
, "R200")
1468 || strstr(gl_renderer
, "R300")
1469 || strstr(gl_renderer
, "R600")
1470 || strstr(gl_renderer
, "R700"))
1471 return HW_VENDOR_AMD
;
1473 if (strstr(gl_vendor_string
, "Intel(R)")
1474 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1475 || strstr(gl_renderer
, "Intel")
1476 || strstr(gl_vendor_string
, "Intel Inc."))
1477 return HW_VENDOR_INTEL
;
1479 if (strstr(gl_vendor_string
, "Mesa")
1480 || strstr(gl_vendor_string
, "Brian Paul")
1481 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1482 || strstr(gl_vendor_string
, "VMware, Inc."))
1483 return HW_VENDOR_SOFTWARE
;
1485 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string
));
1487 return HW_VENDOR_NVIDIA
;
1490 static UINT
d3d_level_from_gl_info(const struct wined3d_gl_info
*gl_info
)
1494 if (gl_info
->supported
[ARB_MULTITEXTURE
])
1496 if (gl_info
->supported
[ARB_TEXTURE_COMPRESSION
]
1497 && gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
]
1498 && gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
1500 if (level
== 7 && gl_info
->supported
[ARB_MULTISAMPLE
]
1501 && gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
1503 if (level
== 8 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]
1504 && gl_info
->supported
[ARB_VERTEX_SHADER
])
1506 if (level
== 9 && gl_info
->supported
[EXT_GPU_SHADER4
])
1512 static enum wined3d_pci_device
select_card_nvidia_binary(const struct wined3d_gl_info
*gl_info
,
1513 const char *gl_renderer
)
1515 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1518 if (d3d_level
>= 10)
1522 const char *renderer
;
1523 enum wined3d_pci_device id
;
1527 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580
}, /* Geforce 500 - highend */
1528 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570
}, /* Geforce 500 - midend high */
1529 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI
}, /* Geforce 500 - midend */
1530 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560
}, /* Geforce 500 - midend */
1531 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M
}, /* Geforce 500 - midend mobile */
1532 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550
}, /* Geforce 500 - midend */
1533 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480
}, /* Geforce 400 - highend */
1534 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470
}, /* Geforce 400 - midend high */
1535 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465
}, /* Geforce 400 - midend */
1536 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M
}, /* Geforce 400 - highend mobile */
1537 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460
}, /* Geforce 400 - midend */
1538 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450
}, /* Geforce 400 - midend low */
1539 {"GT 440", CARD_NVIDIA_GEFORCE_GT440
}, /* Geforce 400 - lowend */
1540 {"GT 430", CARD_NVIDIA_GEFORCE_GT430
}, /* Geforce 400 - lowend */
1541 {"GT 420", CARD_NVIDIA_GEFORCE_GT420
}, /* Geforce 400 - lowend */
1542 {"GT 330", CARD_NVIDIA_GEFORCE_GT330
}, /* Geforce 300 - highend */
1543 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1544 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1545 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1546 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1547 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M
}, /* Geforce 300 - midend mobile */
1548 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1549 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1550 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1551 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275
}, /* Geforce 200 - midend high */
1552 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260
}, /* Geforce 200 - midend */
1553 {"GT 240", CARD_NVIDIA_GEFORCE_GT240
}, /* Geforce 200 - midend */
1554 {"GT 220", CARD_NVIDIA_GEFORCE_GT220
}, /* Geforce 200 - lowend */
1555 {"Geforce 310", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1556 {"Geforce 305", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1557 {"Geforce 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1558 {"G 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1559 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1560 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1561 {"9800", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1562 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1563 {"9600", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1564 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1565 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1566 {"9500", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1567 {"9400", CARD_NVIDIA_GEFORCE_9400GT
}, /* Geforce 9 - lowend */
1568 {"9300", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1569 {"9200", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1570 {"9100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1571 {"G 100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1572 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX
}, /* Geforce 8 - highend high */
1573 {"8800", CARD_NVIDIA_GEFORCE_8800GTS
}, /* Geforce 8 - highend */
1574 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1575 {"8700", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1576 {"8600", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1577 {"8500", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1578 {"8400", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1579 {"8300", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1580 {"8200", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1581 {"8100", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1584 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1586 if (strstr(gl_renderer
, cards
[i
].renderer
))
1590 /* Geforce8-compatible fall back if the GPU is not in the list yet */
1591 return CARD_NVIDIA_GEFORCE_8300GS
;
1594 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1595 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1597 if (d3d_level
>= 9 && gl_info
->supported
[NV_VERTEX_PROGRAM3
])
1601 const char *renderer
;
1602 enum wined3d_pci_device id
;
1606 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1607 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1608 {"7950", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1609 {"7900", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1610 {"7800", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1611 {"7700", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1612 {"7600", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1613 {"7400", CARD_NVIDIA_GEFORCE_7400
}, /* Geforce 7 - lower medium */
1614 {"7300", CARD_NVIDIA_GEFORCE_7300
}, /* Geforce 7 - lowend */
1615 {"6800", CARD_NVIDIA_GEFORCE_6800
}, /* Geforce 6 - highend */
1616 {"6700", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1617 {"6610", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1618 {"6600", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1621 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1623 if (strstr(gl_renderer
, cards
[i
].renderer
))
1627 /* Geforce 6/7 - lowend */
1628 return CARD_NVIDIA_GEFORCE_6200
; /* Geforce 6100/6150/6200/7300/7400/7500 */
1633 /* GeforceFX - highend */
1634 if (strstr(gl_renderer
, "5800")
1635 || strstr(gl_renderer
, "5900")
1636 || strstr(gl_renderer
, "5950")
1637 || strstr(gl_renderer
, "Quadro FX"))
1639 return CARD_NVIDIA_GEFORCEFX_5800
;
1642 /* GeforceFX - midend */
1643 if (strstr(gl_renderer
, "5600")
1644 || strstr(gl_renderer
, "5650")
1645 || strstr(gl_renderer
, "5700")
1646 || strstr(gl_renderer
, "5750"))
1648 return CARD_NVIDIA_GEFORCEFX_5600
;
1651 /* GeforceFX - lowend */
1652 return CARD_NVIDIA_GEFORCEFX_5200
; /* GeforceFX 5100/5200/5250/5300/5500 */
1657 if (strstr(gl_renderer
, "GeForce4 Ti") || strstr(gl_renderer
, "Quadro4"))
1659 return CARD_NVIDIA_GEFORCE4_TI4200
; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1662 return CARD_NVIDIA_GEFORCE3
; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1667 if (strstr(gl_renderer
, "GeForce4 MX"))
1669 return CARD_NVIDIA_GEFORCE4_MX
; /* MX420/MX440/MX460/MX4000 */
1672 if (strstr(gl_renderer
, "GeForce2 MX") || strstr(gl_renderer
, "Quadro2 MXR"))
1674 return CARD_NVIDIA_GEFORCE2_MX
; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1677 if (strstr(gl_renderer
, "GeForce2") || strstr(gl_renderer
, "Quadro2"))
1679 return CARD_NVIDIA_GEFORCE2
; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1682 return CARD_NVIDIA_GEFORCE
; /* Geforce 256/DDR, Quadro */
1685 if (strstr(gl_renderer
, "TNT2"))
1687 return CARD_NVIDIA_RIVA_TNT2
; /* Riva TNT2 standard/M64/Pro/Ultra */
1690 return CARD_NVIDIA_RIVA_TNT
; /* Riva TNT, Vanta */
1693 static enum wined3d_pci_device
select_card_amd_binary(const struct wined3d_gl_info
*gl_info
,
1694 const char *gl_renderer
)
1696 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1698 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1700 * Beware: renderer string do not match exact card model,
1701 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1702 if (d3d_level
>= 10)
1708 const char *renderer
;
1709 enum wined3d_pci_device id
;
1713 /* Northern Islands */
1714 {"HD 6900", CARD_AMD_RADEON_HD6900
},
1715 {"HD 6800", CARD_AMD_RADEON_HD6800
},
1716 {"HD 6630M",CARD_AMD_RADEON_HD6600M
},
1717 {"HD 6600M",CARD_AMD_RADEON_HD6600M
},
1718 {"HD 6600", CARD_AMD_RADEON_HD6600
},
1719 {"HD 6500M",CARD_AMD_RADEON_HD6600M
},
1720 {"HD 6500", CARD_AMD_RADEON_HD6600
},
1721 {"HD 6400", CARD_AMD_RADEON_HD6400
},
1722 {"HD 6300", CARD_AMD_RADEON_HD6300
},
1723 {"HD 6200", CARD_AMD_RADEON_HD6300
},
1725 {"HD 5870", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS PRO */
1726 {"HD 5850", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS XT */
1727 {"HD 5800", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1728 {"HD 5770", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER XT */
1729 {"HD 5750", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER LE */
1730 {"HD 5700", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1731 {"HD 5670", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD XT */
1732 {"HD 5570", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1733 {"HD 5550", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1734 {"HD 5450", CARD_AMD_RADEON_HD5400
}, /* Radeon EG CEDAR PRO */
1736 {"HD 4890", CARD_AMD_RADEON_HD4800
}, /* Radeon RV790 */
1737 {"HD 4870", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1738 {"HD 4850", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1739 {"HD 4830", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1740 {"HD 4800", CARD_AMD_RADEON_HD4800
}, /* Radeon RV7xx HD48xx generic renderer string */
1741 {"HD 4770", CARD_AMD_RADEON_HD4700
}, /* Radeon RV740 */
1742 {"HD 4700", CARD_AMD_RADEON_HD4700
}, /* Radeon RV7xx HD47xx generic renderer string */
1743 {"HD 4670", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1744 {"HD 4650", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1745 {"HD 4600", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1746 {"HD 4550", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1747 {"HD 4350", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1748 /* R600/R700 integrated */
1749 {"HD 3300", CARD_AMD_RADEON_HD3200
},
1750 {"HD 3200", CARD_AMD_RADEON_HD3200
},
1751 {"HD 3100", CARD_AMD_RADEON_HD3200
},
1753 {"HD 3870", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1754 {"HD 3850", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1755 {"HD 2900", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1756 {"HD 3830", CARD_AMD_RADEON_HD2600
}, /* China-only midend */
1757 {"HD 3690", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1758 {"HD 3650", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1759 {"HD 2600", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1760 {"HD 3470", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1761 {"HD 3450", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1762 {"HD 3430", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1763 {"HD 3400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1764 {"HD 2400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1765 {"HD 2350", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1768 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1770 if (strstr(gl_renderer
, cards
[i
].renderer
))
1774 /* Default for when no GPU has been found */
1775 return CARD_AMD_RADEON_HD3200
;
1781 if (strstr(gl_renderer
, "X1600")
1782 || strstr(gl_renderer
, "X1650")
1783 || strstr(gl_renderer
, "X1800")
1784 || strstr(gl_renderer
, "X1900")
1785 || strstr(gl_renderer
, "X1950"))
1787 return CARD_AMD_RADEON_X1600
;
1790 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1791 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1792 if (strstr(gl_renderer
, "X700")
1793 || strstr(gl_renderer
, "X800")
1794 || strstr(gl_renderer
, "X850")
1795 || strstr(gl_renderer
, "X1300")
1796 || strstr(gl_renderer
, "X1400")
1797 || strstr(gl_renderer
, "X1450")
1798 || strstr(gl_renderer
, "X1550")
1799 || strstr(gl_renderer
, "X2300")
1800 || strstr(gl_renderer
, "X2500")
1801 || strstr(gl_renderer
, "HD 2300")
1804 return CARD_AMD_RADEON_X700
;
1807 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1808 if (strstr(gl_renderer
, "Radeon Xpress"))
1810 return CARD_AMD_RADEON_XPRESS_200M
;
1814 return CARD_AMD_RADEON_9500
; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
1818 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1821 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1823 return CARD_AMD_RAGE_128PRO
;
1826 static enum wined3d_pci_device
select_card_intel(const struct wined3d_gl_info
*gl_info
,
1827 const char *gl_renderer
)
1829 if (strstr(gl_renderer
, "GM45")) return CARD_INTEL_GM45
;
1830 if (strstr(gl_renderer
, "X3100") || strstr(gl_renderer
, "965GM"))
1832 /* MacOS calls the card GMA X3100, otherwise known as GM965/GL960 */
1833 return CARD_INTEL_X3100
;
1836 if (strstr(gl_renderer
, "GMA 950") || strstr(gl_renderer
, "945GM"))
1838 /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
1839 return CARD_INTEL_I945GM
;
1842 if (strstr(gl_renderer
, "915GM")) return CARD_INTEL_I915GM
;
1843 if (strstr(gl_renderer
, "915G")) return CARD_INTEL_I915G
;
1844 if (strstr(gl_renderer
, "865G")) return CARD_INTEL_I865G
;
1845 if (strstr(gl_renderer
, "855G")) return CARD_INTEL_I855G
;
1846 if (strstr(gl_renderer
, "830G")) return CARD_INTEL_I830G
;
1847 return CARD_INTEL_I915G
;
1851 static enum wined3d_pci_device
select_card_amd_mesa(const struct wined3d_gl_info
*gl_info
,
1852 const char *gl_renderer
)
1857 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1859 * Beware: renderer string do not match exact card model,
1860 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1861 if (strstr(gl_renderer
, "Gallium"))
1863 /* 20101109 - These are never returned by current Gallium radeon
1864 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
1866 * These are returned but not handled: RC410, RV380. */
1869 const char *renderer
;
1870 enum wined3d_pci_device id
;
1874 /* Northern Islands */
1875 {"CAYMAN", CARD_AMD_RADEON_HD6900
},
1876 {"BARTS", CARD_AMD_RADEON_HD6800
},
1877 {"TURKS", CARD_AMD_RADEON_HD6600
},
1878 {"SUMO2", CARD_AMD_RADEON_HD6410D
}, /* SUMO2 first, because we do a strstr(). */
1879 {"SUMO", CARD_AMD_RADEON_HD6550D
},
1880 {"CAICOS", CARD_AMD_RADEON_HD6400
},
1881 {"PALM", CARD_AMD_RADEON_HD6300
},
1883 {"HEMLOCK", CARD_AMD_RADEON_HD5900
},
1884 {"CYPRESS", CARD_AMD_RADEON_HD5800
},
1885 {"JUNIPER", CARD_AMD_RADEON_HD5700
},
1886 {"REDWOOD", CARD_AMD_RADEON_HD5600
},
1887 {"CEDAR", CARD_AMD_RADEON_HD5400
},
1889 {"R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1890 {"RV790", CARD_AMD_RADEON_HD4800
},
1891 {"RV770", CARD_AMD_RADEON_HD4800
},
1892 {"RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1893 {"RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1894 {"RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1895 /* R600/R700 integrated */
1896 {"RS880", CARD_AMD_RADEON_HD3200
},
1897 {"RS780", CARD_AMD_RADEON_HD3200
},
1899 {"R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1900 {"R600", CARD_AMD_RADEON_HD2900
},
1901 {"RV670", CARD_AMD_RADEON_HD2900
},
1902 {"RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1903 {"RV630", CARD_AMD_RADEON_HD2600
},
1904 {"RV620", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1905 {"RV610", CARD_AMD_RADEON_HD2350
},
1907 {"R580", CARD_AMD_RADEON_X1600
},
1908 {"R520", CARD_AMD_RADEON_X1600
},
1909 {"RV570", CARD_AMD_RADEON_X1600
},
1910 {"RV560", CARD_AMD_RADEON_X1600
},
1911 {"RV535", CARD_AMD_RADEON_X1600
},
1912 {"RV530", CARD_AMD_RADEON_X1600
},
1913 {"RV516", CARD_AMD_RADEON_X700
}, /* X700 is actually R400. */
1914 {"RV515", CARD_AMD_RADEON_X700
},
1916 {"R481", CARD_AMD_RADEON_X700
},
1917 {"R480", CARD_AMD_RADEON_X700
},
1918 {"R430", CARD_AMD_RADEON_X700
},
1919 {"R423", CARD_AMD_RADEON_X700
},
1920 {"R420", CARD_AMD_RADEON_X700
},
1921 {"R410", CARD_AMD_RADEON_X700
},
1922 {"RV410", CARD_AMD_RADEON_X700
},
1923 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
1924 {"RS740", CARD_AMD_RADEON_XPRESS_200M
},
1925 {"RS690", CARD_AMD_RADEON_XPRESS_200M
},
1926 {"RS600", CARD_AMD_RADEON_XPRESS_200M
},
1927 {"RS485", CARD_AMD_RADEON_XPRESS_200M
},
1928 {"RS482", CARD_AMD_RADEON_XPRESS_200M
},
1929 {"RS480", CARD_AMD_RADEON_XPRESS_200M
},
1930 {"RS400", CARD_AMD_RADEON_XPRESS_200M
},
1932 {"R360", CARD_AMD_RADEON_9500
},
1933 {"R350", CARD_AMD_RADEON_9500
},
1934 {"R300", CARD_AMD_RADEON_9500
},
1935 {"RV370", CARD_AMD_RADEON_9500
},
1936 {"RV360", CARD_AMD_RADEON_9500
},
1937 {"RV351", CARD_AMD_RADEON_9500
},
1938 {"RV350", CARD_AMD_RADEON_9500
},
1941 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1943 if (strstr(gl_renderer
, cards
[i
].renderer
))
1948 d3d_level
= d3d_level_from_gl_info(gl_info
);
1949 if (d3d_level
>= 10)
1950 return CARD_AMD_RADEON_HD2600
;
1956 const char *renderer
;
1957 enum wined3d_pci_device id
;
1962 {"(R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1963 {"(RV790", CARD_AMD_RADEON_HD4800
},
1964 {"(RV770", CARD_AMD_RADEON_HD4800
},
1965 {"(RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1966 {"(RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1967 {"(RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1968 /* R600/R700 integrated */
1969 {"RS880", CARD_AMD_RADEON_HD3200
},
1970 {"RS780", CARD_AMD_RADEON_HD3200
},
1972 {"(R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1973 {"(R600", CARD_AMD_RADEON_HD2900
},
1974 {"(RV670", CARD_AMD_RADEON_HD2900
},
1975 {"(RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1976 {"(RV630", CARD_AMD_RADEON_HD2600
},
1977 {"(RV620", CARD_AMD_RADEON_HD2350
}, /* HD2300/HD2400/HD3400 - lowend */
1978 {"(RV610", CARD_AMD_RADEON_HD2350
},
1981 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1983 if (strstr(gl_renderer
, cards
[i
].renderer
))
1987 return CARD_AMD_RADEON_9500
;
1991 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1994 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1996 return CARD_AMD_RAGE_128PRO
;
1999 static enum wined3d_pci_device
select_card_nvidia_mesa(const struct wined3d_gl_info
*gl_info
,
2000 const char *gl_renderer
)
2004 if (strstr(gl_renderer
, "Gallium"))
2010 const char *renderer
;
2011 enum wined3d_pci_device id
;
2015 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570
},
2016 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460
},
2017 {"NVC3", CARD_NVIDIA_GEFORCE_GT440
},
2018 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480
},
2019 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M
},
2020 {"NVAC", CARD_NVIDIA_GEFORCE_8200
},
2021 {"NVAA", CARD_NVIDIA_GEFORCE_8200
},
2022 {"NVA8", CARD_NVIDIA_GEFORCE_210
},
2023 {"NVA5", CARD_NVIDIA_GEFORCE_GT220
},
2024 {"NVA3", CARD_NVIDIA_GEFORCE_GT240
},
2025 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280
},
2026 {"NV98", CARD_NVIDIA_GEFORCE_9200
},
2027 {"NV96", CARD_NVIDIA_GEFORCE_9400GT
},
2028 {"NV94", CARD_NVIDIA_GEFORCE_9600GT
},
2029 {"NV92", CARD_NVIDIA_GEFORCE_9800GT
},
2030 {"NV86", CARD_NVIDIA_GEFORCE_8500GT
},
2031 {"NV84", CARD_NVIDIA_GEFORCE_8600GT
},
2032 {"NV68", CARD_NVIDIA_GEFORCE_6200
}, /* 7050 */
2033 {"NV67", CARD_NVIDIA_GEFORCE_6200
}, /* 7000M */
2034 {"NV63", CARD_NVIDIA_GEFORCE_6200
}, /* 7100 */
2035 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX
},
2036 {"NV4E", CARD_NVIDIA_GEFORCE_6200
}, /* 6100 Go / 6150 Go */
2037 {"NV4C", CARD_NVIDIA_GEFORCE_6200
}, /* 6150SE */
2038 {"NV4B", CARD_NVIDIA_GEFORCE_7600
},
2039 {"NV4A", CARD_NVIDIA_GEFORCE_6200
},
2040 {"NV49", CARD_NVIDIA_GEFORCE_7800GT
}, /* 7900 */
2041 {"NV47", CARD_NVIDIA_GEFORCE_7800GT
},
2042 {"NV46", CARD_NVIDIA_GEFORCE_7400
},
2043 {"NV45", CARD_NVIDIA_GEFORCE_6800
},
2044 {"NV44", CARD_NVIDIA_GEFORCE_6200
},
2045 {"NV43", CARD_NVIDIA_GEFORCE_6600GT
},
2046 {"NV42", CARD_NVIDIA_GEFORCE_6800
},
2047 {"NV41", CARD_NVIDIA_GEFORCE_6800
},
2048 {"NV40", CARD_NVIDIA_GEFORCE_6800
},
2049 {"NV38", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5950 Ultra */
2050 {"NV36", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5700/5750 */
2051 {"NV35", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5900 */
2052 {"NV34", CARD_NVIDIA_GEFORCEFX_5200
},
2053 {"NV31", CARD_NVIDIA_GEFORCEFX_5600
},
2054 {"NV30", CARD_NVIDIA_GEFORCEFX_5800
},
2055 {"NV28", CARD_NVIDIA_GEFORCE4_TI4200
},
2056 {"NV25", CARD_NVIDIA_GEFORCE4_TI4200
},
2057 {"NV20", CARD_NVIDIA_GEFORCE3
},
2058 {"NV1F", CARD_NVIDIA_GEFORCE4_MX
}, /* GF4 MX IGP */
2059 {"NV1A", CARD_NVIDIA_GEFORCE2
}, /* GF2 IGP */
2060 {"NV18", CARD_NVIDIA_GEFORCE4_MX
},
2061 {"NV17", CARD_NVIDIA_GEFORCE4_MX
},
2062 {"NV16", CARD_NVIDIA_GEFORCE2
},
2063 {"NV15", CARD_NVIDIA_GEFORCE2
},
2064 {"NV11", CARD_NVIDIA_GEFORCE2_MX
},
2065 {"NV10", CARD_NVIDIA_GEFORCE
},
2066 {"NV05", CARD_NVIDIA_RIVA_TNT2
},
2067 {"NV04", CARD_NVIDIA_RIVA_TNT
},
2068 {"NV03", CARD_NVIDIA_RIVA_128
},
2071 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
2073 if (strstr(gl_renderer
, cards
[i
].renderer
))
2078 FIXME_(d3d_caps
)("Unknown renderer %s.\n", debugstr_a(gl_renderer
));
2080 d3d_level
= d3d_level_from_gl_info(gl_info
);
2082 return CARD_NVIDIA_GEFORCEFX_5600
;
2084 return CARD_NVIDIA_GEFORCE3
;
2086 return CARD_NVIDIA_GEFORCE
;
2088 return CARD_NVIDIA_RIVA_TNT
;
2089 return CARD_NVIDIA_RIVA_128
;
2093 struct vendor_card_selection
2095 enum wined3d_gl_vendor gl_vendor
;
2096 enum wined3d_pci_vendor card_vendor
;
2097 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
2098 enum wined3d_pci_device (*select_card
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
);
2101 static const struct vendor_card_selection vendor_card_select_table
[] =
2103 {GL_VENDOR_NVIDIA
, HW_VENDOR_NVIDIA
, "Nvidia binary driver", select_card_nvidia_binary
},
2104 {GL_VENDOR_APPLE
, HW_VENDOR_NVIDIA
, "Apple OSX NVidia binary driver", select_card_nvidia_binary
},
2105 {GL_VENDOR_APPLE
, HW_VENDOR_AMD
, "Apple OSX AMD/ATI binary driver", select_card_amd_binary
},
2106 {GL_VENDOR_APPLE
, HW_VENDOR_INTEL
, "Apple OSX Intel binary driver", select_card_intel
},
2107 {GL_VENDOR_FGLRX
, HW_VENDOR_AMD
, "AMD/ATI binary driver", select_card_amd_binary
},
2108 {GL_VENDOR_MESA
, HW_VENDOR_AMD
, "Mesa AMD/ATI driver", select_card_amd_mesa
},
2109 {GL_VENDOR_MESA
, HW_VENDOR_NVIDIA
, "Mesa Nouveau driver", select_card_nvidia_mesa
},
2110 {GL_VENDOR_MESA
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
},
2111 {GL_VENDOR_INTEL
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
}
2115 static enum wined3d_pci_device
wined3d_guess_card(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
2116 enum wined3d_gl_vendor
*gl_vendor
, enum wined3d_pci_vendor
*card_vendor
)
2120 /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of
2121 * different GPUs with roughly the same features. In most cases GPUs from a
2122 * certain family differ in clockspeeds, the amount of video memory and the
2123 * number of shader pipelines.
2125 * A Direct3D device object contains the PCI id (vendor + device) of the
2126 * videocard which is used for rendering. Various applications use this
2127 * information to get a rough estimation of the features of the card and
2128 * some might use it for enabling 3d effects only on certain types of
2129 * videocards. In some cases games might even use it to work around bugs
2130 * which happen on certain videocards/driver combinations. The problem is
2131 * that OpenGL only exposes a rendering string containing the name of the
2132 * videocard and not the PCI id.
2134 * Various games depend on the PCI id, so somehow we need to provide one.
2135 * A simple option is to parse the renderer string and translate this to
2136 * the right PCI id. This is a lot of work because there are more than 200
2137 * GPUs just for Nvidia. Various cards share the same renderer string, so
2138 * the amount of code might be 'small' but there are quite a number of
2139 * exceptions which would make this a pain to maintain. Another way would
2140 * be to query the PCI id from the operating system (assuming this is the
2141 * videocard which is used for rendering which is not always the case).
2142 * This would work but it is not very portable. Second it would not work
2143 * well in, let's say, a remote X situation in which the amount of 3d
2144 * features which can be used is limited.
2146 * As said most games only use the PCI id to get an indication of the
2147 * capabilities of the card. It doesn't really matter if the given id is
2148 * the correct one if we return the id of a card with similar 3d features.
2150 * The code below checks the OpenGL capabilities of a videocard and matches
2151 * that to a certain level of Direct3D functionality. Once a card passes
2152 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2153 * least a GeforceFX. To give a better estimate we do a basic check on the
2154 * renderer string but if that won't pass we return a default card. This
2155 * way is better than maintaining a full card database as even without a
2156 * full database we can return a card with similar features. Second the
2157 * size of the database can be made quite small because when you know what
2158 * type of 3d functionality a card has, you know to which GPU family the
2159 * GPU must belong. Because of this you only have to check a small part of
2160 * the renderer string to distinguishes between different models from that
2163 * The code also selects a default amount of video memory which we will
2164 * use for an estimation of the amount of free texture memory. In case of
2165 * real D3D the amount of texture memory includes video memory and system
2166 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2167 * HyperMemory). We don't know how much system memory can be addressed by
2168 * the system but we can make a reasonable estimation about the amount of
2169 * video memory. If the value is slightly wrong it doesn't matter as we
2170 * didn't include AGP-like memory which makes the amount of addressable
2171 * memory higher and second OpenGL isn't that critical it moves to system
2172 * memory behind our backs if really needed. Note that the amount of video
2173 * memory can be overruled using a registry setting. */
2177 for (i
= 0; i
< (sizeof(vendor_card_select_table
) / sizeof(*vendor_card_select_table
)); ++i
)
2179 if ((vendor_card_select_table
[i
].gl_vendor
!= *gl_vendor
)
2180 || (vendor_card_select_table
[i
].card_vendor
!= *card_vendor
))
2182 TRACE_(d3d_caps
)("Applying card_selector \"%s\".\n", vendor_card_select_table
[i
].description
);
2183 return vendor_card_select_table
[i
].select_card(gl_info
, gl_renderer
);
2186 FIXME_(d3d_caps
)("No card selector available for GL vendor %d and card vendor %04x.\n",
2187 *gl_vendor
, *card_vendor
);
2189 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
2190 * for Nvidia was because the hardware and drivers they make are of good quality. This makes
2191 * them a good generic choice. */
2192 *card_vendor
= HW_VENDOR_NVIDIA
;
2193 d3d_level
= d3d_level_from_gl_info(gl_info
);
2195 return CARD_NVIDIA_GEFORCEFX_5600
;
2197 return CARD_NVIDIA_GEFORCE3
;
2199 return CARD_NVIDIA_GEFORCE
;
2201 return CARD_NVIDIA_RIVA_TNT
;
2202 return CARD_NVIDIA_RIVA_128
;
2205 static const struct fragment_pipeline
*select_fragment_implementation(const struct wined3d_gl_info
*gl_info
)
2207 int vs_selected_mode
, ps_selected_mode
;
2209 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2210 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2211 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_fragment_pipeline
;
2212 else if (ps_selected_mode
== SHADER_ATI
) return &atifs_fragment_pipeline
;
2213 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]
2214 && gl_info
->supported
[NV_TEXTURE_SHADER2
]) return &nvts_fragment_pipeline
;
2215 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]) return &nvrc_fragment_pipeline
;
2216 else return &ffp_fragment_pipeline
;
2219 static const struct wined3d_shader_backend_ops
*select_shader_backend(const struct wined3d_gl_info
*gl_info
)
2221 int vs_selected_mode
, ps_selected_mode
;
2223 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2224 if (vs_selected_mode
== SHADER_GLSL
|| ps_selected_mode
== SHADER_GLSL
) return &glsl_shader_backend
;
2225 if (vs_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_ARB
) return &arb_program_shader_backend
;
2226 return &none_shader_backend
;
2229 static const struct blit_shader
*select_blit_implementation(const struct wined3d_gl_info
*gl_info
)
2231 int vs_selected_mode
, ps_selected_mode
;
2233 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2234 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2235 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_blit
;
2236 else return &ffp_blit
;
2239 static void load_gl_funcs(struct wined3d_gl_info
*gl_info
, DWORD gl_version
)
2243 #define USE_GL_FUNC(type, pfn, ext, replace) \
2244 if (gl_info->supported[ext]) gl_info->pfn = (type)pwglGetProcAddress(#pfn); \
2245 else if ((ver = ver_for_ext(ext)) && ver <= gl_version) gl_info->pfn = (type)pwglGetProcAddress(#replace); \
2246 else gl_info->pfn = NULL;
2251 #define USE_GL_FUNC(type, pfn, ext, replace) gl_info->pfn = (type)pwglGetProcAddress(#pfn);
2256 /* Context activation is done by the caller. */
2257 static BOOL
wined3d_adapter_init_gl_caps(struct wined3d_adapter
*adapter
)
2259 struct wined3d_driver_info
*driver_info
= &adapter
->driver_info
;
2260 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2261 const char *GL_Extensions
= NULL
;
2262 const char *WGL_Extensions
= NULL
;
2263 const char *gl_vendor_str
, *gl_renderer_str
, *gl_version_str
;
2264 struct fragment_caps fragment_caps
;
2265 enum wined3d_gl_vendor gl_vendor
;
2266 enum wined3d_pci_vendor card_vendor
;
2267 enum wined3d_pci_device device
;
2269 GLfloat gl_floatv
[2];
2275 TRACE_(d3d_caps
)("(%p)\n", gl_info
);
2279 gl_renderer_str
= (const char *)glGetString(GL_RENDERER
);
2280 TRACE_(d3d_caps
)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str
));
2281 if (!gl_renderer_str
)
2284 ERR_(d3d_caps
)("Received a NULL GL_RENDERER.\n");
2288 gl_vendor_str
= (const char *)glGetString(GL_VENDOR
);
2289 TRACE_(d3d_caps
)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str
));
2293 ERR_(d3d_caps
)("Received a NULL GL_VENDOR.\n");
2297 /* Parse the GL_VERSION field into major and minor information */
2298 gl_version_str
= (const char *)glGetString(GL_VERSION
);
2299 TRACE_(d3d_caps
)("GL_VERSION: %s.\n", debugstr_a(gl_version_str
));
2300 if (!gl_version_str
)
2303 ERR_(d3d_caps
)("Received a NULL GL_VERSION.\n");
2306 gl_version
= wined3d_parse_gl_version(gl_version_str
);
2309 * Initialize openGL extension related variables
2310 * with Default values
2312 memset(gl_info
->supported
, 0, sizeof(gl_info
->supported
));
2313 gl_info
->limits
.blends
= 1;
2314 gl_info
->limits
.buffers
= 1;
2315 gl_info
->limits
.textures
= 1;
2316 gl_info
->limits
.texture_coords
= 1;
2317 gl_info
->limits
.fragment_samplers
= 1;
2318 gl_info
->limits
.vertex_samplers
= 0;
2319 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
+ gl_info
->limits
.vertex_samplers
;
2320 gl_info
->limits
.sampler_stages
= 1;
2321 gl_info
->limits
.vertex_attribs
= 16;
2322 gl_info
->limits
.glsl_vs_float_constants
= 0;
2323 gl_info
->limits
.glsl_ps_float_constants
= 0;
2324 gl_info
->limits
.arb_vs_float_constants
= 0;
2325 gl_info
->limits
.arb_vs_native_constants
= 0;
2326 gl_info
->limits
.arb_vs_instructions
= 0;
2327 gl_info
->limits
.arb_vs_temps
= 0;
2328 gl_info
->limits
.arb_ps_float_constants
= 0;
2329 gl_info
->limits
.arb_ps_local_constants
= 0;
2330 gl_info
->limits
.arb_ps_instructions
= 0;
2331 gl_info
->limits
.arb_ps_temps
= 0;
2333 /* Retrieve opengl defaults */
2334 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
2335 gl_info
->limits
.clipplanes
= min(WINED3DMAXUSERCLIPPLANES
, gl_max
);
2336 TRACE_(d3d_caps
)("ClipPlanes support - num Planes=%d\n", gl_max
);
2338 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
2339 gl_info
->limits
.lights
= gl_max
;
2340 TRACE_(d3d_caps
)("Lights support - max lights=%d\n", gl_max
);
2342 glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_max
);
2343 gl_info
->limits
.texture_size
= gl_max
;
2344 TRACE_(d3d_caps
)("Maximum texture size support - max texture size=%d\n", gl_max
);
2346 glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE
, gl_floatv
);
2347 gl_info
->limits
.pointsize_min
= gl_floatv
[0];
2348 gl_info
->limits
.pointsize_max
= gl_floatv
[1];
2349 TRACE_(d3d_caps
)("Maximum point size support - max point size=%f\n", gl_floatv
[1]);
2351 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2352 GL_Extensions
= (const char *)glGetString(GL_EXTENSIONS
);
2356 ERR_(d3d_caps
)("Received a NULL GL_EXTENSIONS.\n");
2362 TRACE_(d3d_caps
)("GL_Extensions reported:\n");
2364 gl_info
->supported
[WINED3D_GL_EXT_NONE
] = TRUE
;
2366 while (*GL_Extensions
)
2370 while (isspace(*GL_Extensions
)) ++GL_Extensions
;
2371 start
= GL_Extensions
;
2372 while (!isspace(*GL_Extensions
) && *GL_Extensions
) ++GL_Extensions
;
2374 len
= GL_Extensions
- start
;
2377 TRACE_(d3d_caps
)("- %s\n", debugstr_an(start
, len
));
2379 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
)
2381 if (len
== strlen(EXTENSION_MAP
[i
].extension_string
)
2382 && !memcmp(start
, EXTENSION_MAP
[i
].extension_string
, len
))
2384 TRACE_(d3d_caps
)(" FOUND: %s support.\n", EXTENSION_MAP
[i
].extension_string
);
2385 gl_info
->supported
[EXTENSION_MAP
[i
].extension
] = TRUE
;
2391 /* Now work out what GL support this card really has */
2392 load_gl_funcs( gl_info
, gl_version
);
2396 /* Now mark all the extensions supported which are included in the opengl core version. Do this *after*
2397 * loading the functions, otherwise the code above will load the extension entry points instead of the
2398 * core functions, which may not work. */
2399 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
)
2401 if (!gl_info
->supported
[EXTENSION_MAP
[i
].extension
]
2402 && EXTENSION_MAP
[i
].version
<= gl_version
&& EXTENSION_MAP
[i
].version
)
2404 TRACE_(d3d_caps
)(" GL CORE: %s support.\n", EXTENSION_MAP
[i
].extension_string
);
2405 gl_info
->supported
[EXTENSION_MAP
[i
].extension
] = TRUE
;
2409 if (gl_version
>= MAKEDWORD_VERSION(2, 0)) gl_info
->supported
[WINED3D_GL_VERSION_2_0
] = TRUE
;
2411 if (gl_info
->supported
[APPLE_FENCE
])
2413 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2414 * The apple extension interacts with some other apple exts. Disable the NV
2415 * extension if the apple one is support to prevent confusion in other parts
2417 gl_info
->supported
[NV_FENCE
] = FALSE
;
2419 if (gl_info
->supported
[APPLE_FLOAT_PIXELS
])
2421 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2423 * The enums are the same:
2424 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881A
2425 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881B
2426 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2427 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2428 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140B
2430 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
])
2432 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_texture_float support(from GL_APPLE_float_pixels.\n");
2433 gl_info
->supported
[ARB_TEXTURE_FLOAT
] = TRUE
;
2435 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
2437 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_half_float_pixel support(from GL_APPLE_float_pixels.\n");
2438 gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
] = TRUE
;
2441 if (gl_info
->supported
[ARB_MAP_BUFFER_RANGE
])
2443 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2444 * functionality. Prefer the ARB extension */
2445 gl_info
->supported
[APPLE_FLUSH_BUFFER_RANGE
] = FALSE
;
2447 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
2449 TRACE_(d3d_caps
)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2450 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
2452 if (!gl_info
->supported
[ARB_DEPTH_CLAMP
] && gl_info
->supported
[NV_DEPTH_CLAMP
])
2454 TRACE_(d3d_caps
)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2455 gl_info
->supported
[ARB_DEPTH_CLAMP
] = TRUE
;
2457 if (!gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] && gl_info
->supported
[EXT_VERTEX_ARRAY_BGRA
])
2459 TRACE_(d3d_caps
)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2460 gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] = TRUE
;
2462 if (!gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
])
2464 TRACE_(d3d_caps
)(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
2465 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
2467 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2469 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2471 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2472 * are supported. The nv extensions provide the same functionality as the
2473 * ATI one, and a bit more(signed pixelformats). */
2474 gl_info
->supported
[ATI_FRAGMENT_SHADER
] = FALSE
;
2478 if (gl_info
->supported
[ARB_MAP_BUFFER_ALIGNMENT
])
2480 glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT
, &gl_max
);
2481 TRACE_(d3d_caps
)("Minimum buffer map alignment: %d.\n", gl_max
);
2485 WARN_(d3d_caps
)("Driver doesn't guarantee a minimum buffer map alignment.\n");
2487 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2489 glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV
, &gl_max
);
2490 gl_info
->limits
.general_combiners
= gl_max
;
2491 TRACE_(d3d_caps
)("Max general combiners: %d.\n", gl_max
);
2493 if (gl_info
->supported
[ARB_DRAW_BUFFERS
])
2495 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &gl_max
);
2496 gl_info
->limits
.buffers
= gl_max
;
2497 TRACE_(d3d_caps
)("Max draw buffers: %u.\n", gl_max
);
2499 if (gl_info
->supported
[ARB_MULTITEXTURE
])
2501 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
2502 gl_info
->limits
.textures
= min(MAX_TEXTURES
, gl_max
);
2503 TRACE_(d3d_caps
)("Max textures: %d.\n", gl_info
->limits
.textures
);
2504 glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB
, &gl_max
);
2505 gl_info
->limits
.texture_coords
= min(MAX_TEXTURES
, gl_max
);
2506 TRACE_(d3d_caps
)("Max texture coords: %d.\n", gl_info
->limits
.texture_coords
);
2508 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2511 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2512 gl_info
->limits
.fragment_samplers
= min(MAX_FRAGMENT_SAMPLERS
, tmp
);
2516 gl_info
->limits
.fragment_samplers
= max(gl_info
->limits
.fragment_samplers
, gl_max
);
2518 TRACE_(d3d_caps
)("Max fragment samplers: %d.\n", gl_info
->limits
.fragment_samplers
);
2520 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2523 glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2524 gl_info
->limits
.vertex_samplers
= tmp
;
2525 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2526 gl_info
->limits
.combined_samplers
= tmp
;
2527 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &tmp
);
2528 gl_info
->limits
.vertex_attribs
= tmp
;
2530 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2531 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2532 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2533 * shader is used with fixed function vertex processing we're fine too because fixed function
2534 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2535 * used we have to make sure that all vertex sampler setups are valid together with all
2536 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2537 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2538 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2539 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2540 * a fixed function pipeline anymore.
2542 * So this is just a check to check that our assumption holds true. If not, write a warning
2543 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2544 if (gl_info
->limits
.vertex_samplers
&& gl_info
->limits
.combined_samplers
< 12
2545 && MAX_TEXTURES
+ gl_info
->limits
.vertex_samplers
> gl_info
->limits
.combined_samplers
)
2547 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2548 gl_info
->limits
.vertex_samplers
, gl_info
->limits
.combined_samplers
);
2549 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2550 if (gl_info
->limits
.combined_samplers
> MAX_TEXTURES
)
2551 gl_info
->limits
.vertex_samplers
= gl_info
->limits
.combined_samplers
- MAX_TEXTURES
;
2553 gl_info
->limits
.vertex_samplers
= 0;
2558 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
;
2560 TRACE_(d3d_caps
)("Max vertex samplers: %u.\n", gl_info
->limits
.vertex_samplers
);
2561 TRACE_(d3d_caps
)("Max combined samplers: %u.\n", gl_info
->limits
.combined_samplers
);
2563 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
2565 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
2566 gl_info
->limits
.blends
= gl_max
;
2567 TRACE_(d3d_caps
)("Max blends: %u.\n", gl_info
->limits
.blends
);
2569 if (gl_info
->supported
[EXT_TEXTURE3D
])
2571 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT
, &gl_max
);
2572 gl_info
->limits
.texture3d_size
= gl_max
;
2573 TRACE_(d3d_caps
)("Max texture3D size: %d.\n", gl_info
->limits
.texture3d_size
);
2575 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
2577 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
2578 gl_info
->limits
.anisotropy
= gl_max
;
2579 TRACE_(d3d_caps
)("Max anisotropy: %d.\n", gl_info
->limits
.anisotropy
);
2581 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2583 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2584 gl_info
->limits
.arb_ps_float_constants
= gl_max
;
2585 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_ps_float_constants
);
2586 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2587 gl_info
->limits
.arb_ps_native_constants
= gl_max
;
2588 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2589 gl_info
->limits
.arb_ps_native_constants
);
2590 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2591 gl_info
->limits
.arb_ps_temps
= gl_max
;
2592 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_ps_temps
);
2593 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2594 gl_info
->limits
.arb_ps_instructions
= gl_max
;
2595 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2596 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, &gl_max
));
2597 gl_info
->limits
.arb_ps_local_constants
= gl_max
;
2598 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2600 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
])
2602 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2603 gl_info
->limits
.arb_vs_float_constants
= gl_max
;
2604 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_vs_float_constants
);
2605 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2606 gl_info
->limits
.arb_vs_native_constants
= gl_max
;
2607 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2608 gl_info
->limits
.arb_vs_native_constants
);
2609 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2610 gl_info
->limits
.arb_vs_temps
= gl_max
;
2611 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_vs_temps
);
2612 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2613 gl_info
->limits
.arb_vs_instructions
= gl_max
;
2614 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_vs_instructions
);
2616 if (test_arb_vs_offset_limit(gl_info
)) gl_info
->quirks
|= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
;
2618 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2620 glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2621 gl_info
->limits
.glsl_vs_float_constants
= gl_max
/ 4;
2622 TRACE_(d3d_caps
)("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info
->limits
.glsl_vs_float_constants
);
2624 if (gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2626 glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2627 gl_info
->limits
.glsl_ps_float_constants
= gl_max
/ 4;
2628 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info
->limits
.glsl_ps_float_constants
);
2629 glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB
, &gl_max
);
2630 gl_info
->limits
.glsl_varyings
= gl_max
;
2631 TRACE_(d3d_caps
)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max
, gl_max
/ 4);
2633 if (gl_info
->supported
[ARB_SHADING_LANGUAGE_100
])
2635 const char *str
= (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB
);
2636 unsigned int major
, minor
;
2638 TRACE_(d3d_caps
)("GLSL version string: %s.\n", debugstr_a(str
));
2640 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2641 sscanf(str
, "%u.%u", &major
, &minor
);
2642 gl_info
->glsl_version
= MAKEDWORD_VERSION(major
, minor
);
2644 if (gl_info
->supported
[NV_LIGHT_MAX_EXPONENT
])
2646 glGetFloatv(GL_MAX_SHININESS_NV
, &gl_info
->limits
.shininess
);
2650 gl_info
->limits
.shininess
= 128.0f
;
2652 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
2654 /* If we have full NP2 texture support, disable
2655 * GL_ARB_texture_rectangle because we will never use it.
2656 * This saves a few redundant glDisable calls. */
2657 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = FALSE
;
2659 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
2661 /* Disable NV_register_combiners and fragment shader if this is supported.
2662 * generally the NV extensions are preferred over the ATI ones, and this
2663 * extension is disabled if register_combiners and texture_shader2 are both
2664 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2665 * fragment processing support. */
2666 gl_info
->supported
[NV_REGISTER_COMBINERS
] = FALSE
;
2667 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = FALSE
;
2668 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
2669 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
2671 if (gl_info
->supported
[NV_HALF_FLOAT
])
2673 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2674 gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
] = TRUE
;
2676 checkGLcall("extension detection");
2680 adapter
->fragment_pipe
= select_fragment_implementation(gl_info
);
2681 adapter
->shader_backend
= select_shader_backend(gl_info
);
2682 adapter
->blitter
= select_blit_implementation(gl_info
);
2684 adapter
->fragment_pipe
->get_caps(gl_info
, &fragment_caps
);
2685 gl_info
->limits
.texture_stages
= fragment_caps
.MaxTextureBlendStages
;
2686 TRACE_(d3d_caps
)("Max texture stages: %u.\n", gl_info
->limits
.texture_stages
);
2688 /* In some cases the number of texture stages can be larger than the number
2689 * of samplers. The GF4 for example can use only 2 samplers (no fragment
2690 * shaders), but 8 texture stages (register combiners). */
2691 gl_info
->limits
.sampler_stages
= max(gl_info
->limits
.fragment_samplers
, gl_info
->limits
.texture_stages
);
2693 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
2695 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbuffer
;
2696 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbuffer
;
2697 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffers
;
2698 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffers
;
2699 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorage
;
2700 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisample
;
2701 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameteriv
;
2702 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebuffer
;
2703 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebuffer
;
2704 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffers
;
2705 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffers
;
2706 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatus
;
2707 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1D
;
2708 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2D
;
2709 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3D
;
2710 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbuffer
;
2711 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameteriv
;
2712 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebuffer
;
2713 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmap
;
2714 if (wined3d_settings
.allow_multisampling
)
2716 glGetIntegerv(GL_MAX_SAMPLES
, &gl_max
);
2717 gl_info
->limits
.samples
= gl_max
;
2722 if (gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
2724 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbufferEXT
;
2725 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbufferEXT
;
2726 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffersEXT
;
2727 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffersEXT
;
2728 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorageEXT
;
2729 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameterivEXT
;
2730 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebufferEXT
;
2731 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebufferEXT
;
2732 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffersEXT
;
2733 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffersEXT
;
2734 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatusEXT
;
2735 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1DEXT
;
2736 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2DEXT
;
2737 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3DEXT
;
2738 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbufferEXT
;
2739 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameterivEXT
;
2740 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmapEXT
;
2742 else if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2744 WARN_(d3d_caps
)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
2745 wined3d_settings
.offscreen_rendering_mode
= ORM_BACKBUFFER
;
2747 if (gl_info
->supported
[EXT_FRAMEBUFFER_BLIT
])
2749 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebufferEXT
;
2751 if (gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
2753 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisampleEXT
;
2754 if (wined3d_settings
.allow_multisampling
)
2756 glGetIntegerv(GL_MAX_SAMPLES
, &gl_max
);
2757 gl_info
->limits
.samples
= gl_max
;
2762 /* MRTs are currently only supported when FBOs are used. */
2763 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
2765 gl_info
->limits
.buffers
= 1;
2768 gl_vendor
= wined3d_guess_gl_vendor(gl_info
, gl_vendor_str
, gl_renderer_str
);
2769 card_vendor
= wined3d_guess_card_vendor(gl_vendor_str
, gl_renderer_str
);
2770 TRACE_(d3d_caps
)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str
), gl_vendor
, card_vendor
);
2772 device
= wined3d_guess_card(gl_info
, gl_renderer_str
, &gl_vendor
, &card_vendor
);
2773 TRACE_(d3d_caps
)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor
, device
);
2775 gl_info
->wrap_lookup
[WINED3DTADDRESS_WRAP
- WINED3DTADDRESS_WRAP
] = GL_REPEAT
;
2776 gl_info
->wrap_lookup
[WINED3DTADDRESS_MIRROR
- WINED3DTADDRESS_WRAP
] =
2777 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] ? GL_MIRRORED_REPEAT_ARB
: GL_REPEAT
;
2778 gl_info
->wrap_lookup
[WINED3DTADDRESS_CLAMP
- WINED3DTADDRESS_WRAP
] = GL_CLAMP_TO_EDGE
;
2779 gl_info
->wrap_lookup
[WINED3DTADDRESS_BORDER
- WINED3DTADDRESS_WRAP
] =
2780 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] ? GL_CLAMP_TO_BORDER_ARB
: GL_REPEAT
;
2781 gl_info
->wrap_lookup
[WINED3DTADDRESS_MIRRORONCE
- WINED3DTADDRESS_WRAP
] =
2782 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] ? GL_MIRROR_CLAMP_TO_EDGE_ATI
: GL_REPEAT
;
2784 /* Make sure there's an active HDC else the WGL extensions will fail */
2785 hdc
= pwglGetCurrentDC();
2787 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox */
2788 if(GL_EXTCALL(wglGetExtensionsStringARB
))
2789 WGL_Extensions
= GL_EXTCALL(wglGetExtensionsStringARB(hdc
));
2791 if (!WGL_Extensions
)
2793 ERR(" WGL_Extensions returns NULL\n");
2797 TRACE_(d3d_caps
)("WGL_Extensions reported:\n");
2798 while (*WGL_Extensions
)
2803 while (isspace(*WGL_Extensions
)) WGL_Extensions
++;
2804 Start
= WGL_Extensions
;
2805 while (!isspace(*WGL_Extensions
) && *WGL_Extensions
) ++WGL_Extensions
;
2807 len
= WGL_Extensions
- Start
;
2808 if (!len
|| len
>= sizeof(ThisExtn
))
2811 memcpy(ThisExtn
, Start
, len
);
2812 ThisExtn
[len
] = '\0';
2813 TRACE_(d3d_caps
)("- %s\n", debugstr_a(ThisExtn
));
2815 if (!strcmp(ThisExtn
, "WGL_ARB_pixel_format")) {
2816 gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
] = TRUE
;
2817 TRACE_(d3d_caps
)("FOUND: WGL_ARB_pixel_format support\n");
2819 if (!strcmp(ThisExtn
, "WGL_EXT_swap_control")) {
2820 gl_info
->supported
[WGL_EXT_SWAP_CONTROL
] = TRUE
;
2821 TRACE_(d3d_caps
)("FOUND: WGL_EXT_swap_control support\n");
2823 if (!strcmp(ThisExtn
, "WGL_WINE_pixel_format_passthrough")) {
2824 gl_info
->supported
[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
] = TRUE
;
2825 TRACE_(d3d_caps
)("FOUND: WGL_WINE_pixel_format_passthrough support\n");
2831 fixup_extensions(gl_info
, gl_renderer_str
, gl_vendor
, card_vendor
, device
);
2832 init_driver_info(driver_info
, card_vendor
, device
);
2833 add_gl_compat_wrappers(gl_info
);
2838 UINT CDECL
wined3d_get_adapter_count(const struct wined3d
*wined3d
)
2840 TRACE_(d3d_caps
)("wined3d %p, reporting %u adapters.\n",
2841 wined3d
, wined3d
->adapter_count
);
2843 return wined3d
->adapter_count
;
2846 HRESULT CDECL
wined3d_register_software_device(struct wined3d
*wined3d
, void *init_function
)
2848 FIXME("wined3d %p, init_function %p stub!\n", wined3d
, init_function
);
2853 HMONITOR CDECL
wined3d_get_adapter_monitor(const struct wined3d
*wined3d
, UINT adapter_idx
)
2855 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u.\n", wined3d
, adapter_idx
);
2857 if (adapter_idx
>= wined3d
->adapter_count
)
2860 return MonitorFromPoint(wined3d
->adapters
[adapter_idx
].monitorPoint
, MONITOR_DEFAULTTOPRIMARY
);
2863 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2864 of the same bpp but different resolutions */
2866 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2867 UINT CDECL
wined3d_get_adapter_mode_count(const struct wined3d
*wined3d
, UINT adapter_idx
,
2868 enum wined3d_format_id format_id
)
2870 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s.\n", wined3d
, adapter_idx
, debug_d3dformat(format_id
));
2872 if (adapter_idx
>= wined3d
->adapter_count
)
2875 /* TODO: Store modes per adapter and read it from the adapter structure */
2878 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2879 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2884 memset(&mode
, 0, sizeof(mode
));
2885 mode
.dmSize
= sizeof(mode
);
2887 while (EnumDisplaySettingsExW(NULL
, j
, &mode
, 0))
2891 if (format_id
== WINED3DFMT_UNKNOWN
)
2893 /* This is for D3D8, do not enumerate P8 here */
2894 if (mode
.dmBitsPerPel
== 32 || mode
.dmBitsPerPel
== 16) ++i
;
2896 else if (mode
.dmBitsPerPel
== format_bits
)
2902 TRACE_(d3d_caps
)("Returning %u matching modes (out of %u total) for adapter %u.\n", i
, j
, adapter_idx
);
2908 FIXME_(d3d_caps
)("Adapter not primary display.\n");
2914 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2915 HRESULT CDECL
wined3d_enum_adapter_modes(const struct wined3d
*wined3d
, UINT adapter_idx
,
2916 enum wined3d_format_id format_id
, UINT mode_idx
, struct wined3d_display_mode
*mode
)
2918 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n",
2919 wined3d
, adapter_idx
, debug_d3dformat(format_id
), mode_idx
, mode
);
2921 /* Validate the parameters as much as possible */
2922 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
2923 || mode_idx
>= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, format_id
))
2925 return WINED3DERR_INVALIDCALL
;
2928 /* TODO: Store modes per adapter and read it from the adapter structure */
2931 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2932 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2938 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
2939 DevModeW
.dmSize
= sizeof(DevModeW
);
2941 /* If we are filtering to a specific format (D3D9), then need to skip
2942 all unrelated modes, but if mode is irrelevant (D3D8), then we can
2943 just count through the ones with valid bit depths */
2944 while (i
<= mode_idx
&& EnumDisplaySettingsExW(NULL
, j
++, &DevModeW
, 0))
2946 if (format_id
== WINED3DFMT_UNKNOWN
)
2948 /* This is for D3D8, do not enumerate P8 here */
2949 if (DevModeW
.dmBitsPerPel
== 32 || DevModeW
.dmBitsPerPel
== 16) ++i
;
2951 else if (DevModeW
.dmBitsPerPel
== format_bits
)
2959 TRACE_(d3d_caps
)("No modes found for format (%x - %s)\n", format_id
, debug_d3dformat(format_id
));
2960 return WINED3DERR_INVALIDCALL
;
2964 /* Now get the display mode via the calculated index */
2965 if (EnumDisplaySettingsExW(NULL
, ModeIdx
, &DevModeW
, 0))
2967 mode
->width
= DevModeW
.dmPelsWidth
;
2968 mode
->height
= DevModeW
.dmPelsHeight
;
2969 mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
2970 if (DevModeW
.dmFields
& DM_DISPLAYFREQUENCY
)
2971 mode
->refresh_rate
= DevModeW
.dmDisplayFrequency
;
2973 if (format_id
== WINED3DFMT_UNKNOWN
)
2974 mode
->format_id
= pixelformat_for_depth(DevModeW
.dmBitsPerPel
);
2976 mode
->format_id
= format_id
;
2980 TRACE_(d3d_caps
)("Requested mode %u out of range.\n", mode_idx
);
2981 return WINED3DERR_INVALIDCALL
;
2984 TRACE_(d3d_caps
)("W %d H %d rr %d fmt (%x - %s) bpp %u\n",
2985 mode
->width
, mode
->height
, mode
->refresh_rate
, mode
->format_id
,
2986 debug_d3dformat(mode
->format_id
), DevModeW
.dmBitsPerPel
);
2990 FIXME_(d3d_caps
)("Adapter not primary display\n");
2996 HRESULT CDECL
wined3d_get_adapter_display_mode(const struct wined3d
*wined3d
, UINT adapter_idx
,
2997 struct wined3d_display_mode
*mode
)
2999 TRACE("wined3d %p, adapter_idx %u, display_mode %p.\n", wined3d
, adapter_idx
, mode
);
3001 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
)
3002 return WINED3DERR_INVALIDCALL
;
3009 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
3010 DevModeW
.dmSize
= sizeof(DevModeW
);
3012 EnumDisplaySettingsExW(NULL
, ENUM_CURRENT_SETTINGS
, &DevModeW
, 0);
3013 mode
->width
= DevModeW
.dmPelsWidth
;
3014 mode
->height
= DevModeW
.dmPelsHeight
;
3015 bpp
= DevModeW
.dmBitsPerPel
;
3016 mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
3017 if (DevModeW
.dmFields
& DM_DISPLAYFREQUENCY
)
3018 mode
->refresh_rate
= DevModeW
.dmDisplayFrequency
;
3019 mode
->format_id
= pixelformat_for_depth(bpp
);
3023 FIXME_(d3d_caps
)("Adapter not primary display\n");
3026 TRACE_(d3d_caps
)("returning w:%d, h:%d, ref:%d, fmt:%s\n", mode
->width
,
3027 mode
->height
, mode
->refresh_rate
, debug_d3dformat(mode
->format_id
));
3031 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
3032 and fields being inserted in the middle, a new structure is used in place */
3033 HRESULT CDECL
wined3d_get_adapter_identifier(const struct wined3d
*wined3d
,
3034 UINT adapter_idx
, DWORD flags
, struct wined3d_adapter_identifier
*identifier
)
3036 const struct wined3d_adapter
*adapter
;
3039 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, flags %#x, indentifier %p.\n",
3040 wined3d
, adapter_idx
, flags
, identifier
);
3042 if (adapter_idx
>= wined3d
->adapter_count
)
3043 return WINED3DERR_INVALIDCALL
;
3045 adapter
= &wined3d
->adapters
[adapter_idx
];
3047 /* Return the information requested */
3048 TRACE_(d3d_caps
)("device/Vendor Name and Version detection using FillGLCaps\n");
3050 if (identifier
->driver_size
)
3052 const char *name
= adapter
->driver_info
.name
;
3053 len
= min(strlen(name
), identifier
->driver_size
- 1);
3054 memcpy(identifier
->driver
, name
, len
);
3055 identifier
->driver
[len
] = '\0';
3058 if (identifier
->description_size
)
3060 const char *description
= adapter
->driver_info
.description
;
3061 len
= min(strlen(description
), identifier
->description_size
- 1);
3062 memcpy(identifier
->description
, description
, len
);
3063 identifier
->description
[len
] = '\0';
3066 /* Note that d3d8 doesn't supply a device name. */
3067 if (identifier
->device_name_size
)
3069 static const char *device_name
= "\\\\.\\DISPLAY1"; /* FIXME: May depend on desktop? */
3071 len
= strlen(device_name
);
3072 if (len
>= identifier
->device_name_size
)
3074 ERR("Device name size too small.\n");
3075 return WINED3DERR_INVALIDCALL
;
3078 memcpy(identifier
->device_name
, device_name
, len
);
3079 identifier
->device_name
[len
] = '\0';
3082 identifier
->driver_version
.u
.HighPart
= adapter
->driver_info
.version_high
;
3083 identifier
->driver_version
.u
.LowPart
= adapter
->driver_info
.version_low
;
3084 identifier
->vendor_id
= adapter
->driver_info
.vendor
;
3085 identifier
->device_id
= adapter
->driver_info
.device
;
3086 identifier
->subsystem_id
= 0;
3087 identifier
->revision
= 0;
3088 memcpy(&identifier
->device_identifier
, &IID_D3DDEVICE_D3DUID
, sizeof(identifier
->device_identifier
));
3089 identifier
->whql_level
= (flags
& WINED3DENUM_NO_WHQL_LEVEL
) ? 0 : 1;
3090 memcpy(&identifier
->adapter_luid
, &adapter
->luid
, sizeof(identifier
->adapter_luid
));
3091 identifier
->video_memory
= adapter
->TextureRam
;
3096 static BOOL
wined3d_check_pixel_format_color(const struct wined3d_gl_info
*gl_info
,
3097 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3099 BYTE redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
3101 /* Float formats need FBOs. If FBOs are used this function isn't called */
3102 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3104 if(cfg
->iPixelType
== WGL_TYPE_RGBA_ARB
) { /* Integer RGBA formats */
3105 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
3107 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3111 if(cfg
->redSize
< redSize
)
3114 if(cfg
->greenSize
< greenSize
)
3117 if(cfg
->blueSize
< blueSize
)
3120 if(cfg
->alphaSize
< alphaSize
)
3126 /* Probably a RGBA_float or color index mode */
3130 static BOOL
wined3d_check_pixel_format_depth(const struct wined3d_gl_info
*gl_info
,
3131 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3133 BYTE depthSize
, stencilSize
;
3134 BOOL lockable
= FALSE
;
3136 if (!getDepthStencilBits(format
, &depthSize
, &stencilSize
))
3138 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3142 /* Float formats need FBOs. If FBOs are used this function isn't called */
3143 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3145 if ((format
->id
== WINED3DFMT_D16_LOCKABLE
) || (format
->id
== WINED3DFMT_D32_FLOAT
))
3148 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
3149 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
3150 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
3151 if(!(cfg
->depthSize
== depthSize
|| (!lockable
&& cfg
->depthSize
> depthSize
)))
3154 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
3155 * allow more stencil bits than requested. */
3156 if(cfg
->stencilSize
< stencilSize
)
3162 HRESULT CDECL
wined3d_check_depth_stencil_match(const struct wined3d
*wined3d
,
3163 UINT adapter_idx
, WINED3DDEVTYPE device_type
, enum wined3d_format_id adapter_format_id
,
3164 enum wined3d_format_id render_target_format_id
, enum wined3d_format_id depth_stencil_format_id
)
3166 const struct wined3d_format
*rt_format
;
3167 const struct wined3d_format
*ds_format
;
3168 const struct wined3d_adapter
*adapter
;
3170 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s,\n"
3171 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
3172 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3173 debug_d3dformat(render_target_format_id
), debug_d3dformat(depth_stencil_format_id
));
3175 if (adapter_idx
>= wined3d
->adapter_count
)
3176 return WINED3DERR_INVALIDCALL
;
3178 adapter
= &wined3d
->adapters
[adapter_idx
];
3179 rt_format
= wined3d_get_format(&adapter
->gl_info
, render_target_format_id
);
3180 ds_format
= wined3d_get_format(&adapter
->gl_info
, depth_stencil_format_id
);
3181 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3183 if ((rt_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3184 && (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)))
3186 TRACE_(d3d_caps
)("Formats match.\n");
3192 const struct wined3d_pixel_format
*cfgs
;
3193 unsigned int cfg_count
;
3196 cfgs
= adapter
->cfgs
;
3197 cfg_count
= adapter
->cfg_count
;
3198 for (i
= 0; i
< cfg_count
; ++i
)
3200 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], rt_format
)
3201 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, &cfgs
[i
], ds_format
))
3203 TRACE_(d3d_caps
)("Formats match.\n");
3209 TRACE_(d3d_caps
)("Unsupported format pair: %s and %s.\n",
3210 debug_d3dformat(render_target_format_id
),
3211 debug_d3dformat(depth_stencil_format_id
));
3213 return WINED3DERR_NOTAVAILABLE
;
3216 HRESULT CDECL
wined3d_check_device_multisample_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
3217 WINED3DDEVTYPE device_type
, enum wined3d_format_id surface_format_id
, BOOL windowed
,
3218 WINED3DMULTISAMPLE_TYPE multisample_type
, DWORD
*quality_levels
)
3220 const struct wined3d_gl_info
*gl_info
;
3222 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
3223 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
3224 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(surface_format_id
),
3225 windowed
, multisample_type
, quality_levels
);
3227 if (adapter_idx
>= wined3d
->adapter_count
)
3228 return WINED3DERR_INVALIDCALL
;
3230 gl_info
= &wined3d
->adapters
[adapter_idx
].gl_info
;
3232 if (multisample_type
> gl_info
->limits
.samples
)
3234 TRACE("Returning not supported.\n");
3236 *quality_levels
= 0;
3238 return WINED3DERR_NOTAVAILABLE
;
3243 if (multisample_type
== WINED3DMULTISAMPLE_NONMASKABLE
)
3244 /* FIXME: This is probably wrong. */
3245 *quality_levels
= gl_info
->limits
.samples
;
3247 *quality_levels
= 1;
3253 /* Check if we support bumpmapping for a format */
3254 static BOOL
CheckBumpMapCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3256 /* Ask the fixed function pipeline implementation if it can deal
3257 * with the conversion. If we've got a GL extension giving native
3258 * support this will be an identity conversion. */
3259 return (format
->flags
& WINED3DFMT_FLAG_BUMPMAP
)
3260 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
);
3263 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
3264 static BOOL
CheckDepthStencilCapability(const struct wined3d_adapter
*adapter
,
3265 const struct wined3d_format
*display_format
, const struct wined3d_format
*ds_format
)
3267 /* Only allow depth/stencil formats */
3268 if (!(ds_format
->depth_size
|| ds_format
->stencil_size
)) return FALSE
;
3270 /* Blacklist formats not supported on Windows */
3271 switch (ds_format
->id
)
3273 case WINED3DFMT_S1_UINT_D15_UNORM
: /* Breaks the shadowvol2 dx7 sdk sample */
3274 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3275 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3282 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3284 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
3285 if (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)) return TRUE
;
3291 /* Walk through all WGL pixel formats to find a match */
3292 for (i
= 0; i
< adapter
->cfg_count
; ++i
)
3294 const struct wined3d_pixel_format
*cfg
= &adapter
->cfgs
[i
];
3295 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, cfg
, display_format
)
3296 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, cfg
, ds_format
))
3304 static BOOL
CheckFilterCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3306 /* The flags entry of a format contains the filtering capability */
3307 if ((format
->flags
& WINED3DFMT_FLAG_FILTERING
)
3308 || !(adapter
->gl_info
.quirks
& WINED3D_QUIRK_LIMITED_TEX_FILTERING
))
3314 /* Check the render target capabilities of a format */
3315 static BOOL
CheckRenderTargetCapability(const struct wined3d_adapter
*adapter
,
3316 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*check_format
)
3318 /* Filter out non-RT formats */
3319 if (!(check_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)) return FALSE
;
3320 if (wined3d_settings
.offscreen_rendering_mode
== ORM_BACKBUFFER
)
3322 BYTE AdapterRed
, AdapterGreen
, AdapterBlue
, AdapterAlpha
, AdapterTotalSize
;
3323 BYTE CheckRed
, CheckGreen
, CheckBlue
, CheckAlpha
, CheckTotalSize
;
3324 const struct wined3d_pixel_format
*cfgs
= adapter
->cfgs
;
3327 getColorBits(adapter_format
, &AdapterRed
, &AdapterGreen
, &AdapterBlue
, &AdapterAlpha
, &AdapterTotalSize
);
3328 getColorBits(check_format
, &CheckRed
, &CheckGreen
, &CheckBlue
, &CheckAlpha
, &CheckTotalSize
);
3330 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
3331 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
3332 if(!((AdapterRed
== CheckRed
) && (AdapterGreen
== CheckGreen
) && (AdapterBlue
== CheckBlue
))) {
3333 TRACE_(d3d_caps
)("[FAILED]\n");
3337 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
3338 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
3339 for (i
= 0; i
< adapter
->cfg_count
; ++i
)
3341 if (cfgs
[i
].windowDrawable
3342 && wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], check_format
))
3344 TRACE_(d3d_caps
)("Pixel format %d is compatible with format %s.\n",
3345 cfgs
[i
].iPixelFormat
, debug_d3dformat(check_format
->id
));
3350 else if(wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3352 /* For now return TRUE for FBOs until we have some proper checks.
3353 * Note that this function will only be called when the format is around for texturing. */
3359 static BOOL
CheckSrgbReadCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3361 return format
->flags
& WINED3DFMT_FLAG_SRGB_READ
;
3364 static BOOL
CheckSrgbWriteCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3366 /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
3367 * doing the color fixup in shaders.
3368 * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
3369 if (format
->flags
& WINED3DFMT_FLAG_SRGB_WRITE
)
3371 int vs_selected_mode
;
3372 int ps_selected_mode
;
3373 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
3375 if((ps_selected_mode
== SHADER_ARB
) || (ps_selected_mode
== SHADER_GLSL
)) {
3376 TRACE_(d3d_caps
)("[OK]\n");
3381 TRACE_(d3d_caps
)("[FAILED] - sRGB writes not supported by format %s.\n", debug_d3dformat(format
->id
));
3385 /* Check if a format support blending in combination with pixel shaders */
3386 static BOOL
CheckPostPixelShaderBlendingCapability(const struct wined3d_adapter
*adapter
,
3387 const struct wined3d_format
*format
)
3389 /* The flags entry of a format contains the post pixel shader blending capability */
3390 if (format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
) return TRUE
;
3395 static BOOL
CheckWrapAndMipCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3397 /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
3398 * but we have to report mipmapping so we cannot reject this flag. Tests show that
3399 * windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to show
3400 * that wrapping is supported. The lack of filtering will sort out the mipmapping
3401 * capability anyway.
3403 * For now lets report this on all formats, but in the future we may want to
3404 * restrict it to some should games need that
3409 /* Check if a texture format is supported on the given adapter */
3410 static BOOL
CheckTextureCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3412 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3417 * supported: RGB(A) formats
3419 case WINED3DFMT_B8G8R8_UNORM
:
3420 TRACE_(d3d_caps
)("[FAILED] - Not enumerated on Windows\n");
3422 case WINED3DFMT_B8G8R8A8_UNORM
:
3423 case WINED3DFMT_B8G8R8X8_UNORM
:
3424 case WINED3DFMT_B5G6R5_UNORM
:
3425 case WINED3DFMT_B5G5R5X1_UNORM
:
3426 case WINED3DFMT_B5G5R5A1_UNORM
:
3427 case WINED3DFMT_B4G4R4A4_UNORM
:
3428 case WINED3DFMT_A8_UNORM
:
3429 case WINED3DFMT_B4G4R4X4_UNORM
:
3430 case WINED3DFMT_R8G8B8A8_UNORM
:
3431 case WINED3DFMT_R8G8B8X8_UNORM
:
3432 case WINED3DFMT_B10G10R10A2_UNORM
:
3433 case WINED3DFMT_R10G10B10A2_UNORM
:
3434 case WINED3DFMT_R16G16_UNORM
:
3435 TRACE_(d3d_caps
)("[OK]\n");
3438 case WINED3DFMT_B2G3R3_UNORM
:
3439 TRACE_(d3d_caps
)("[FAILED] - Not supported on Windows\n");
3443 * Not supported: Palettized
3444 * Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of <=Direct3D7.
3445 * Since it is not widely available, don't offer it. Further no Windows driver offers
3446 * WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
3448 case WINED3DFMT_P8_UINT
:
3449 case WINED3DFMT_P8_UINT_A8_UNORM
:
3453 * Supported: (Alpha)-Luminance
3455 case WINED3DFMT_L8_UNORM
:
3456 case WINED3DFMT_L8A8_UNORM
:
3457 case WINED3DFMT_L16_UNORM
:
3458 TRACE_(d3d_caps
)("[OK]\n");
3461 /* Not supported on Windows, thus disabled */
3462 case WINED3DFMT_L4A4_UNORM
:
3463 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3467 * Supported: Depth/Stencil formats
3469 case WINED3DFMT_D16_LOCKABLE
:
3470 case WINED3DFMT_D16_UNORM
:
3471 case WINED3DFMT_X8D24_UNORM
:
3472 case WINED3DFMT_D24_UNORM_S8_UINT
:
3473 case WINED3DFMT_S8_UINT_D24_FLOAT
:
3474 case WINED3DFMT_D32_UNORM
:
3475 case WINED3DFMT_D32_FLOAT
:
3478 case WINED3DFMT_INTZ
:
3479 if (gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
]
3480 || gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3484 /* Not supported on Windows */
3485 case WINED3DFMT_S1_UINT_D15_UNORM
:
3486 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3487 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3491 * Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
3492 * GL_NV_texture_shader). Emulated by shaders
3494 case WINED3DFMT_R8G8_SNORM
:
3495 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
3496 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
3497 case WINED3DFMT_R8G8B8A8_SNORM
:
3498 case WINED3DFMT_R16G16_SNORM
:
3499 /* Ask the shader backend if it can deal with the conversion. If
3500 * we've got a GL extension giving native support this will be an
3501 * identity conversion. */
3502 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
))
3504 TRACE_(d3d_caps
)("[OK]\n");
3507 TRACE_(d3d_caps
)("[FAILED]\n");
3510 case WINED3DFMT_DXT1
:
3511 case WINED3DFMT_DXT2
:
3512 case WINED3DFMT_DXT3
:
3513 case WINED3DFMT_DXT4
:
3514 case WINED3DFMT_DXT5
:
3515 if (gl_info
->supported
[EXT_TEXTURE_COMPRESSION_S3TC
])
3517 TRACE_(d3d_caps
)("[OK]\n");
3520 TRACE_(d3d_caps
)("[FAILED]\n");
3525 * Odd formats - not supported
3527 case WINED3DFMT_VERTEXDATA
:
3528 case WINED3DFMT_R16_UINT
:
3529 case WINED3DFMT_R32_UINT
:
3530 case WINED3DFMT_R16G16B16A16_SNORM
:
3531 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM
:
3532 case WINED3DFMT_R10G11B11_SNORM
:
3533 case WINED3DFMT_R16
:
3534 case WINED3DFMT_AL16
:
3535 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3539 * WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
3541 case WINED3DFMT_R8G8_SNORM_Cx
:
3542 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3546 case WINED3DFMT_UYVY
:
3547 case WINED3DFMT_YUY2
:
3548 if (gl_info
->supported
[APPLE_YCBCR_422
])
3550 TRACE_(d3d_caps
)("[OK]\n");
3553 TRACE_(d3d_caps
)("[FAILED]\n");
3555 case WINED3DFMT_YV12
:
3556 TRACE_(d3d_caps
)("[FAILED]\n");
3559 case WINED3DFMT_R16G16B16A16_UNORM
:
3560 if (gl_info
->quirks
& WINED3D_QUIRK_BROKEN_RGBA16
)
3562 TRACE_(d3d_caps
)("[FAILED]\n");
3565 TRACE_(d3d_caps
)("[OK]\n");
3569 case WINED3DFMT_B2G3R3A8_UNORM
:
3570 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3573 /* Floating point formats */
3574 case WINED3DFMT_R16_FLOAT
:
3575 case WINED3DFMT_R16G16_FLOAT
:
3576 case WINED3DFMT_R16G16B16A16_FLOAT
:
3577 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
] && gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
3579 TRACE_(d3d_caps
)("[OK]\n");
3582 TRACE_(d3d_caps
)("[FAILED]\n");
3585 case WINED3DFMT_R32_FLOAT
:
3586 case WINED3DFMT_R32G32_FLOAT
:
3587 case WINED3DFMT_R32G32B32A32_FLOAT
:
3588 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
])
3590 TRACE_(d3d_caps
)("[OK]\n");
3593 TRACE_(d3d_caps
)("[FAILED]\n");
3596 /* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
3597 * instancing. To query if the card supports instancing CheckDeviceFormat with the special format
3598 * MAKEFOURCC('I','N','S','T') is used. Should a (broken) app check for this provide a proper return value.
3599 * We can do instancing with all shader versions, but we need vertex shaders.
3601 * Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC('I','N','S','T') once
3602 * to enable instancing. WineD3D doesn't need that and just ignores it.
3604 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows.
3606 case WINED3DFMT_INST
:
3607 TRACE("ATI Instancing check hack\n");
3608 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_VERTEX_SHADER
])
3610 TRACE_(d3d_caps
)("[OK]\n");
3613 TRACE_(d3d_caps
)("[FAILED]\n");
3616 /* Some weird FOURCC formats */
3617 case WINED3DFMT_R8G8_B8G8
:
3618 case WINED3DFMT_G8R8_G8B8
:
3619 case WINED3DFMT_MULTI2_ARGB8
:
3620 TRACE_(d3d_caps
)("[FAILED]\n");
3623 /* Vendor specific formats */
3624 case WINED3DFMT_ATI2N
:
3625 if (gl_info
->supported
[ATI_TEXTURE_COMPRESSION_3DC
]
3626 || gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
])
3628 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
)
3629 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
))
3631 TRACE_(d3d_caps
)("[OK]\n");
3635 TRACE_(d3d_caps
)("[OK]\n");
3638 TRACE_(d3d_caps
)("[FAILED]\n");
3641 /* Depth bound test. To query if the card supports it CheckDeviceFormat with the special
3642 * format MAKEFOURCC('N','V','D','B') is used.
3643 * It is enabled by setting D3DRS_ADAPTIVETESS_X render state to MAKEFOURCC('N','V','D','B') and
3644 * then controlled by setting D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax)
3647 case WINED3DFMT_NVDB
:
3648 if (gl_info
->supported
[EXT_DEPTH_BOUNDS_TEST
])
3650 TRACE_(d3d_caps
)("[OK]\n");
3653 TRACE_(d3d_caps
)("[FAILED]\n");
3656 case WINED3DFMT_NVHU
:
3657 case WINED3DFMT_NVHS
:
3658 /* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
3659 * is said to be GL_UNSIGNED_HILO16, NVHS GL_SIGNED_HILO16. Rumours say that d3d computes
3660 * a 3rd channel similarly to D3DFMT_CxV8U8(So NVHS could be called D3DFMT_CxV16U16).
3661 * ATI refused to support formats which can easily be emulated with pixel shaders, so
3662 * Applications have to deal with not having NVHS and NVHU.
3664 TRACE_(d3d_caps
)("[FAILED]\n");
3667 case WINED3DFMT_NULL
:
3668 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3672 case WINED3DFMT_UNKNOWN
:
3676 ERR("Unhandled format %s.\n", debug_d3dformat(format
->id
));
3682 static BOOL
CheckSurfaceCapability(const struct wined3d_adapter
*adapter
,
3683 const struct wined3d_format
*adapter_format
,
3684 const struct wined3d_format
*check_format
,
3685 WINED3DSURFTYPE SurfaceType
)
3687 if (SurfaceType
== SURFACE_GDI
)
3689 switch (check_format
->id
)
3691 case WINED3DFMT_B8G8R8_UNORM
:
3692 TRACE_(d3d_caps
)("[FAILED] - Not enumerated on Windows\n");
3694 case WINED3DFMT_B8G8R8A8_UNORM
:
3695 case WINED3DFMT_B8G8R8X8_UNORM
:
3696 case WINED3DFMT_B5G6R5_UNORM
:
3697 case WINED3DFMT_B5G5R5X1_UNORM
:
3698 case WINED3DFMT_B5G5R5A1_UNORM
:
3699 case WINED3DFMT_B4G4R4A4_UNORM
:
3700 case WINED3DFMT_B2G3R3_UNORM
:
3701 case WINED3DFMT_A8_UNORM
:
3702 case WINED3DFMT_B2G3R3A8_UNORM
:
3703 case WINED3DFMT_B4G4R4X4_UNORM
:
3704 case WINED3DFMT_R10G10B10A2_UNORM
:
3705 case WINED3DFMT_R8G8B8A8_UNORM
:
3706 case WINED3DFMT_R8G8B8X8_UNORM
:
3707 case WINED3DFMT_R16G16_UNORM
:
3708 case WINED3DFMT_B10G10R10A2_UNORM
:
3709 case WINED3DFMT_R16G16B16A16_UNORM
:
3710 case WINED3DFMT_P8_UINT
:
3711 TRACE_(d3d_caps
)("[OK]\n");
3714 TRACE_(d3d_caps
)("[FAILED] - not available on GDI surfaces\n");
3719 /* All format that are supported for textures are supported for surfaces as well */
3720 if (CheckTextureCapability(adapter
, check_format
)) return TRUE
;
3721 /* All depth stencil formats are supported on surfaces */
3722 if (CheckDepthStencilCapability(adapter
, adapter_format
, check_format
)) return TRUE
;
3724 /* If opengl can't process the format natively, the blitter may be able to convert it */
3725 if (adapter
->blitter
->blit_supported(&adapter
->gl_info
, WINED3D_BLIT_OP_COLOR_BLIT
,
3726 NULL
, WINED3DPOOL_DEFAULT
, 0, check_format
,
3727 NULL
, WINED3DPOOL_DEFAULT
, 0, adapter_format
))
3729 TRACE_(d3d_caps
)("[OK]\n");
3733 /* Reject other formats */
3734 TRACE_(d3d_caps
)("[FAILED]\n");
3738 static BOOL
CheckVertexTextureCapability(const struct wined3d_adapter
*adapter
,
3739 const struct wined3d_format
*format
)
3741 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3743 if (!gl_info
->limits
.vertex_samplers
|| !(format
->flags
& WINED3DFMT_FLAG_VTF
))
3748 case WINED3DFMT_R32G32B32A32_FLOAT
:
3749 case WINED3DFMT_R32_FLOAT
:
3752 return !(gl_info
->quirks
& WINED3D_QUIRK_LIMITED_TEX_FILTERING
);
3756 HRESULT CDECL
wined3d_check_device_format(const struct wined3d
*wined3d
, UINT adapter_idx
,
3757 WINED3DDEVTYPE device_type
, enum wined3d_format_id adapter_format_id
, DWORD usage
,
3758 WINED3DRESOURCETYPE resource_type
, enum wined3d_format_id check_format_id
, WINED3DSURFTYPE surface_type
)
3760 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
3761 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3762 const struct wined3d_format
*adapter_format
= wined3d_get_format(gl_info
, adapter_format_id
);
3763 const struct wined3d_format
*format
= wined3d_get_format(gl_info
, check_format_id
);
3764 DWORD usage_caps
= 0;
3766 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
3767 "resource_type %s, check_format %s, surface_type %#x.\n",
3768 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3769 debug_d3dusage(usage
), debug_d3dusagequery(usage
), debug_d3dresourcetype(resource_type
),
3770 debug_d3dformat(check_format_id
), surface_type
);
3772 if (adapter_idx
>= wined3d
->adapter_count
)
3773 return WINED3DERR_INVALIDCALL
;
3775 switch (resource_type
)
3777 case WINED3DRTYPE_CUBETEXTURE
:
3778 /* Cubetexture allows:
3779 * - WINED3DUSAGE_AUTOGENMIPMAP
3780 * - WINED3DUSAGE_DEPTHSTENCIL
3781 * - WINED3DUSAGE_DYNAMIC
3782 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3783 * - WINED3DUSAGE_RENDERTARGET
3784 * - WINED3DUSAGE_SOFTWAREPROCESSING
3785 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3787 if (surface_type
!= SURFACE_OPENGL
)
3789 TRACE_(d3d_caps
)("[FAILED]\n");
3790 return WINED3DERR_NOTAVAILABLE
;
3793 if (!gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3795 TRACE_(d3d_caps
)("[FAILED] - No cube texture support\n");
3796 return WINED3DERR_NOTAVAILABLE
;
3799 if (!CheckTextureCapability(adapter
, format
))
3801 TRACE_(d3d_caps
)("[FAILED] - Cube texture format not supported\n");
3802 return WINED3DERR_NOTAVAILABLE
;
3805 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3807 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3808 /* When autogenmipmap isn't around continue and return
3809 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3810 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3812 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3815 /* Always report dynamic locking. */
3816 if (usage
& WINED3DUSAGE_DYNAMIC
)
3817 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3819 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3821 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3823 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3824 return WINED3DERR_NOTAVAILABLE
;
3826 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3829 /* Always report software processing. */
3830 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
3831 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
3833 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3835 if (!CheckFilterCapability(adapter
, format
))
3837 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
3838 return WINED3DERR_NOTAVAILABLE
;
3840 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
3843 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3845 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3847 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3848 return WINED3DERR_NOTAVAILABLE
;
3850 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3853 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
3855 if (!CheckSrgbReadCapability(adapter
, format
))
3857 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
3858 return WINED3DERR_NOTAVAILABLE
;
3860 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
3863 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
3865 if (!CheckSrgbWriteCapability(adapter
, format
))
3867 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
3868 return WINED3DERR_NOTAVAILABLE
;
3870 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
3873 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
3875 if (!CheckVertexTextureCapability(adapter
, format
))
3877 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
3878 return WINED3DERR_NOTAVAILABLE
;
3880 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
3883 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
3885 if (!CheckWrapAndMipCapability(adapter
, format
))
3887 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
3888 return WINED3DERR_NOTAVAILABLE
;
3890 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
3894 case WINED3DRTYPE_SURFACE
:
3896 * - WINED3DUSAGE_DEPTHSTENCIL
3897 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3898 * - WINED3DUSAGE_RENDERTARGET
3900 if (!CheckSurfaceCapability(adapter
, adapter_format
, format
, surface_type
))
3902 TRACE_(d3d_caps
)("[FAILED] - Not supported for plain surfaces\n");
3903 return WINED3DERR_NOTAVAILABLE
;
3906 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
3908 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
3910 TRACE_(d3d_caps
)("[FAILED] - No depthstencil support\n");
3911 return WINED3DERR_NOTAVAILABLE
;
3913 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
3916 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3918 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3920 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3921 return WINED3DERR_NOTAVAILABLE
;
3923 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3926 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3928 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3930 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3931 return WINED3DERR_NOTAVAILABLE
;
3933 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3937 case WINED3DRTYPE_TEXTURE
:
3939 * - WINED3DUSAGE_AUTOGENMIPMAP
3940 * - WINED3DUSAGE_DEPTHSTENCIL
3941 * - WINED3DUSAGE_DMAP
3942 * - WINED3DUSAGE_DYNAMIC
3943 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3944 * - WINED3DUSAGE_RENDERTARGET
3945 * - WINED3DUSAGE_SOFTWAREPROCESSING
3946 * - WINED3DUSAGE_TEXTAPI (d3d9ex)
3947 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3949 if (surface_type
!= SURFACE_OPENGL
)
3951 TRACE_(d3d_caps
)("[FAILED]\n");
3952 return WINED3DERR_NOTAVAILABLE
;
3955 if (!CheckTextureCapability(adapter
, format
))
3957 TRACE_(d3d_caps
)("[FAILED] - Texture format not supported\n");
3958 return WINED3DERR_NOTAVAILABLE
;
3961 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3963 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3964 /* When autogenmipmap isn't around continue and return
3965 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3966 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3968 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3971 /* Always report dynamic locking. */
3972 if (usage
& WINED3DUSAGE_DYNAMIC
)
3973 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3975 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3977 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3979 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3980 return WINED3DERR_NOTAVAILABLE
;
3982 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3985 /* Always report software processing. */
3986 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
3987 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
3989 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3991 if (!CheckFilterCapability(adapter
, format
))
3993 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
3994 return WINED3DERR_NOTAVAILABLE
;
3996 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
3999 if (usage
& WINED3DUSAGE_QUERY_LEGACYBUMPMAP
)
4001 if (!CheckBumpMapCapability(adapter
, format
))
4003 TRACE_(d3d_caps
)("[FAILED] - No legacy bumpmap support\n");
4004 return WINED3DERR_NOTAVAILABLE
;
4006 usage_caps
|= WINED3DUSAGE_QUERY_LEGACYBUMPMAP
;
4009 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4011 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4013 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
4014 return WINED3DERR_NOTAVAILABLE
;
4016 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4019 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4021 if (!CheckSrgbReadCapability(adapter
, format
))
4023 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
4024 return WINED3DERR_NOTAVAILABLE
;
4026 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4029 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4031 if (!CheckSrgbWriteCapability(adapter
, format
))
4033 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
4034 return WINED3DERR_NOTAVAILABLE
;
4036 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4039 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4041 if (!CheckVertexTextureCapability(adapter
, format
))
4043 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
4044 return WINED3DERR_NOTAVAILABLE
;
4046 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4049 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4051 if (!CheckWrapAndMipCapability(adapter
, format
))
4053 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
4054 return WINED3DERR_NOTAVAILABLE
;
4056 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4059 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
4061 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
4063 TRACE_(d3d_caps
)("[FAILED] - No depth stencil support\n");
4064 return WINED3DERR_NOTAVAILABLE
;
4066 if ((format
->flags
& WINED3DFMT_FLAG_SHADOW
) && !gl_info
->supported
[ARB_SHADOW
])
4068 TRACE_(d3d_caps
)("[FAILED] - No shadow sampler support.\n");
4069 return WINED3DERR_NOTAVAILABLE
;
4071 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
4075 case WINED3DRTYPE_VOLUMETEXTURE
:
4076 case WINED3DRTYPE_VOLUME
:
4077 /* Volume is to VolumeTexture what Surface is to Texture, but its
4078 * usage caps are not documented. Most driver seem to offer
4079 * (nearly) the same on Volume and VolumeTexture, so do that too.
4081 * Volumetexture allows:
4082 * - D3DUSAGE_DYNAMIC
4083 * - D3DUSAGE_NONSECURE (d3d9ex)
4084 * - D3DUSAGE_SOFTWAREPROCESSING
4085 * - D3DUSAGE_QUERY_WRAPANDMIP
4087 if (surface_type
!= SURFACE_OPENGL
)
4089 TRACE_(d3d_caps
)("[FAILED]\n");
4090 return WINED3DERR_NOTAVAILABLE
;
4093 if (!gl_info
->supported
[EXT_TEXTURE3D
])
4095 TRACE_(d3d_caps
)("[FAILED] - No volume texture support\n");
4096 return WINED3DERR_NOTAVAILABLE
;
4099 if (!CheckTextureCapability(adapter
, format
))
4101 TRACE_(d3d_caps
)("[FAILED] - Format not supported\n");
4102 return WINED3DERR_NOTAVAILABLE
;
4105 /* Filter formats that need conversion; For one part, this
4106 * conversion is unimplemented, and volume textures are huge, so
4107 * it would be a big performance hit. Unless we hit an application
4108 * needing one of those formats, don't advertize them to avoid
4109 * leading applications into temptation. The windows drivers don't
4110 * support most of those formats on volumes anyway, except for
4111 * WINED3DFMT_R32_FLOAT. */
4112 switch (check_format_id
)
4114 case WINED3DFMT_P8_UINT
:
4115 case WINED3DFMT_L4A4_UNORM
:
4116 case WINED3DFMT_R32_FLOAT
:
4117 case WINED3DFMT_R16_FLOAT
:
4118 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
4119 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
4120 case WINED3DFMT_R16G16_UNORM
:
4121 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4122 return WINED3DERR_NOTAVAILABLE
;
4124 case WINED3DFMT_R8G8B8A8_SNORM
:
4125 case WINED3DFMT_R16G16_SNORM
:
4126 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4128 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4129 return WINED3DERR_NOTAVAILABLE
;
4133 case WINED3DFMT_R8G8_SNORM
:
4134 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4136 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4137 return WINED3DERR_NOTAVAILABLE
;
4141 case WINED3DFMT_DXT1
:
4142 case WINED3DFMT_DXT2
:
4143 case WINED3DFMT_DXT3
:
4144 case WINED3DFMT_DXT4
:
4145 case WINED3DFMT_DXT5
:
4146 /* The GL_EXT_texture_compression_s3tc spec requires that
4147 * loading an s3tc compressed texture results in an error.
4148 * While the D3D refrast does support s3tc volumes, at
4149 * least the nvidia windows driver does not, so we're free
4150 * not to support this format. */
4151 TRACE_(d3d_caps
)("[FAILED] - DXTn does not support 3D textures\n");
4152 return WINED3DERR_NOTAVAILABLE
;
4155 /* Do nothing, continue with checking the format below */
4159 /* Always report dynamic locking. */
4160 if (usage
& WINED3DUSAGE_DYNAMIC
)
4161 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
4163 /* Always report software processing. */
4164 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
4165 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
4167 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
4169 if (!CheckFilterCapability(adapter
, format
))
4171 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
4172 return WINED3DERR_NOTAVAILABLE
;
4174 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
4177 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4179 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4181 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
4182 return WINED3DERR_NOTAVAILABLE
;
4184 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4187 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4189 if (!CheckSrgbReadCapability(adapter
, format
))
4191 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
4192 return WINED3DERR_NOTAVAILABLE
;
4194 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4197 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4199 if (!CheckSrgbWriteCapability(adapter
, format
))
4201 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
4202 return WINED3DERR_NOTAVAILABLE
;
4204 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4207 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4209 if (!CheckVertexTextureCapability(adapter
, format
))
4211 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
4212 return WINED3DERR_NOTAVAILABLE
;
4214 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4217 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4219 if (!CheckWrapAndMipCapability(adapter
, format
))
4221 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
4222 return WINED3DERR_NOTAVAILABLE
;
4224 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4229 FIXME_(d3d_caps
)("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type
));
4230 return WINED3DERR_NOTAVAILABLE
;
4233 /* When the usage_caps exactly matches usage return WINED3D_OK except for
4234 * the situation in which WINED3DUSAGE_AUTOGENMIPMAP isn't around, then
4235 * WINED3DOK_NOAUTOGEN is returned if all the other usage flags match. */
4236 if (usage_caps
== usage
)
4238 if (usage_caps
== (usage
& ~WINED3DUSAGE_AUTOGENMIPMAP
))
4239 return WINED3DOK_NOAUTOGEN
;
4241 TRACE_(d3d_caps
)("[FAILED] - Usage %#x requested for format %s and resource_type %s but only %#x is available.\n",
4242 usage
, debug_d3dformat(check_format_id
), debug_d3dresourcetype(resource_type
), usage_caps
);
4244 return WINED3DERR_NOTAVAILABLE
;
4247 HRESULT CDECL
wined3d_check_device_format_conversion(const struct wined3d
*wined3d
, UINT adapter_idx
,
4248 WINED3DDEVTYPE device_type
, enum wined3d_format_id src_format
, enum wined3d_format_id dst_format
)
4250 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
4251 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(src_format
),
4252 debug_d3dformat(dst_format
));
4257 HRESULT CDECL
wined3d_check_device_type(const struct wined3d
*wined3d
, UINT adapter_idx
, WINED3DDEVTYPE device_type
,
4258 enum wined3d_format_id display_format
, enum wined3d_format_id backbuffer_format
, BOOL windowed
)
4263 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
4264 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(display_format
),
4265 debug_d3dformat(backbuffer_format
), windowed
);
4267 if (adapter_idx
>= wined3d
->adapter_count
)
4268 return WINED3DERR_INVALIDCALL
;
4270 /* The task of this function is to check whether a certain display / backbuffer format
4271 * combination is available on the given adapter. In fullscreen mode microsoft specified
4272 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
4273 * and display format should match exactly.
4274 * In windowed mode format conversion can occur and this depends on the driver. When format
4275 * conversion is done, this function should nevertheless fail and applications need to use
4276 * CheckDeviceFormatConversion.
4277 * At the moment we assume that fullscreen and windowed have the same capabilities. */
4279 /* There are only 4 display formats. */
4280 if (!(display_format
== WINED3DFMT_B5G6R5_UNORM
4281 || display_format
== WINED3DFMT_B5G5R5X1_UNORM
4282 || display_format
== WINED3DFMT_B8G8R8X8_UNORM
4283 || display_format
== WINED3DFMT_B10G10R10A2_UNORM
))
4285 TRACE_(d3d_caps
)("Format %s is not supported as display format.\n", debug_d3dformat(display_format
));
4286 return WINED3DERR_NOTAVAILABLE
;
4289 /* If the requested display format is not available, don't continue. */
4290 mode_count
= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, display_format
);
4293 TRACE_(d3d_caps
)("No available modes for display format %s.\n", debug_d3dformat(display_format
));
4294 return WINED3DERR_NOTAVAILABLE
;
4297 /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format,
4298 * it means 'reuse' the display format for the backbuffer. */
4299 if (!windowed
&& backbuffer_format
== WINED3DFMT_UNKNOWN
)
4301 TRACE_(d3d_caps
)("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n");
4302 return WINED3DERR_NOTAVAILABLE
;
4305 /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with
4306 * backbuffer format WINED3DFMT_B5G6R5_UNORM. */
4307 if (display_format
== WINED3DFMT_B5G6R5_UNORM
&& backbuffer_format
!= WINED3DFMT_B5G6R5_UNORM
)
4309 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4310 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4311 return WINED3DERR_NOTAVAILABLE
;
4314 /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with
4315 * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and
4316 * WINED3DFMT_B5G5R5A1_UNORM. */
4317 if (display_format
== WINED3DFMT_B5G5R5X1_UNORM
4318 && !(backbuffer_format
== WINED3DFMT_B5G5R5X1_UNORM
|| backbuffer_format
== WINED3DFMT_B5G5R5A1_UNORM
))
4320 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4321 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4322 return WINED3DERR_NOTAVAILABLE
;
4325 /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with
4326 * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and
4327 * WINED3DFMT_B8G8R8A8_UNORM. */
4328 if (display_format
== WINED3DFMT_B8G8R8X8_UNORM
4329 && !(backbuffer_format
== WINED3DFMT_B8G8R8X8_UNORM
|| backbuffer_format
== WINED3DFMT_B8G8R8A8_UNORM
))
4331 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4332 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4333 return WINED3DERR_NOTAVAILABLE
;
4336 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it
4337 * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */
4338 if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
4339 && (backbuffer_format
!= WINED3DFMT_B10G10R10A2_UNORM
|| windowed
))
4341 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4342 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4343 return WINED3DERR_NOTAVAILABLE
;
4346 /* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
4347 hr
= wined3d_check_device_format(wined3d
, adapter_idx
, device_type
, display_format
,
4348 WINED3DUSAGE_RENDERTARGET
, WINED3DRTYPE_SURFACE
, backbuffer_format
, SURFACE_OPENGL
);
4350 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4351 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4356 HRESULT CDECL
wined3d_get_device_caps(const struct wined3d
*wined3d
, UINT adapter_idx
,
4357 WINED3DDEVTYPE device_type
, WINED3DCAPS
*caps
)
4359 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
4360 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4361 int vs_selected_mode
;
4362 int ps_selected_mode
;
4363 struct shader_caps shader_caps
;
4364 struct fragment_caps fragment_caps
;
4365 DWORD ckey_caps
, blit_caps
, fx_caps
, pal_caps
;
4367 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
4368 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), caps
);
4370 if (adapter_idx
>= wined3d
->adapter_count
)
4371 return WINED3DERR_INVALIDCALL
;
4373 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
4375 /* ------------------------------------------------
4376 The following fields apply to both d3d8 and d3d9
4377 ------------------------------------------------ */
4378 /* Not quite true, but use h/w supported by opengl I suppose */
4379 caps
->DeviceType
= (device_type
== WINED3DDEVTYPE_HAL
) ? WINED3DDEVTYPE_HAL
: WINED3DDEVTYPE_REF
;
4380 caps
->AdapterOrdinal
= adapter_idx
;
4383 caps
->Caps2
= WINED3DCAPS2_CANRENDERWINDOWED
|
4384 WINED3DCAPS2_FULLSCREENGAMMA
|
4385 WINED3DCAPS2_DYNAMICTEXTURES
;
4386 if (gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
4387 caps
->Caps2
|= WINED3DCAPS2_CANAUTOGENMIPMAP
;
4389 caps
->Caps3
= WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
4390 WINED3DCAPS3_COPY_TO_VIDMEM
|
4391 WINED3DCAPS3_COPY_TO_SYSTEMMEM
;
4393 caps
->PresentationIntervals
= WINED3DPRESENT_INTERVAL_IMMEDIATE
|
4394 WINED3DPRESENT_INTERVAL_ONE
;
4396 caps
->CursorCaps
= WINED3DCURSORCAPS_COLOR
|
4397 WINED3DCURSORCAPS_LOWRES
;
4399 caps
->DevCaps
= WINED3DDEVCAPS_FLOATTLVERTEX
|
4400 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY
|
4401 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
4402 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY
|
4403 WINED3DDEVCAPS_DRAWPRIMTLVERTEX
|
4404 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT
|
4405 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY
|
4406 WINED3DDEVCAPS_PUREDEVICE
|
4407 WINED3DDEVCAPS_HWRASTERIZATION
|
4408 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY
|
4409 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY
|
4410 WINED3DDEVCAPS_CANRENDERAFTERFLIP
|
4411 WINED3DDEVCAPS_DRAWPRIMITIVES2
|
4412 WINED3DDEVCAPS_DRAWPRIMITIVES2EX
|
4413 WINED3DDEVCAPS_RTPATCHES
;
4415 caps
->PrimitiveMiscCaps
= WINED3DPMISCCAPS_CULLNONE
|
4416 WINED3DPMISCCAPS_CULLCCW
|
4417 WINED3DPMISCCAPS_CULLCW
|
4418 WINED3DPMISCCAPS_COLORWRITEENABLE
|
4419 WINED3DPMISCCAPS_CLIPTLVERTS
|
4420 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
4421 WINED3DPMISCCAPS_MASKZ
|
4422 WINED3DPMISCCAPS_BLENDOP
|
4423 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
;
4425 WINED3DPMISCCAPS_NULLREFERENCE
4426 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
4427 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
4428 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
4430 if (gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
] && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
4431 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_SEPARATEALPHABLEND
;
4432 if (gl_info
->supported
[EXT_DRAW_BUFFERS2
])
4433 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
;
4435 caps
->RasterCaps
= WINED3DPRASTERCAPS_DITHER
|
4436 WINED3DPRASTERCAPS_PAT
|
4437 WINED3DPRASTERCAPS_WFOG
|
4438 WINED3DPRASTERCAPS_ZFOG
|
4439 WINED3DPRASTERCAPS_FOGVERTEX
|
4440 WINED3DPRASTERCAPS_FOGTABLE
|
4441 WINED3DPRASTERCAPS_STIPPLE
|
4442 WINED3DPRASTERCAPS_SUBPIXEL
|
4443 WINED3DPRASTERCAPS_ZTEST
|
4444 WINED3DPRASTERCAPS_SCISSORTEST
|
4445 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
4446 WINED3DPRASTERCAPS_DEPTHBIAS
;
4448 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4450 caps
->RasterCaps
|= WINED3DPRASTERCAPS_ANISOTROPY
|
4451 WINED3DPRASTERCAPS_ZBIAS
|
4452 WINED3DPRASTERCAPS_MIPMAPLODBIAS
;
4454 if (gl_info
->supported
[NV_FOG_DISTANCE
])
4456 caps
->RasterCaps
|= WINED3DPRASTERCAPS_FOGRANGE
;
4459 WINED3DPRASTERCAPS_COLORPERSPECTIVE
4460 WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
4461 WINED3DPRASTERCAPS_ANTIALIASEDGES
4462 WINED3DPRASTERCAPS_ZBUFFERLESSHSR
4463 WINED3DPRASTERCAPS_WBUFFER */
4465 caps
->ZCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4466 WINED3DPCMPCAPS_EQUAL
|
4467 WINED3DPCMPCAPS_GREATER
|
4468 WINED3DPCMPCAPS_GREATEREQUAL
|
4469 WINED3DPCMPCAPS_LESS
|
4470 WINED3DPCMPCAPS_LESSEQUAL
|
4471 WINED3DPCMPCAPS_NEVER
|
4472 WINED3DPCMPCAPS_NOTEQUAL
;
4474 caps
->SrcBlendCaps
= WINED3DPBLENDCAPS_BOTHINVSRCALPHA
|
4475 WINED3DPBLENDCAPS_BOTHSRCALPHA
|
4476 WINED3DPBLENDCAPS_DESTALPHA
|
4477 WINED3DPBLENDCAPS_DESTCOLOR
|
4478 WINED3DPBLENDCAPS_INVDESTALPHA
|
4479 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4480 WINED3DPBLENDCAPS_INVSRCALPHA
|
4481 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4482 WINED3DPBLENDCAPS_ONE
|
4483 WINED3DPBLENDCAPS_SRCALPHA
|
4484 WINED3DPBLENDCAPS_SRCALPHASAT
|
4485 WINED3DPBLENDCAPS_SRCCOLOR
|
4486 WINED3DPBLENDCAPS_ZERO
;
4488 caps
->DestBlendCaps
= WINED3DPBLENDCAPS_DESTALPHA
|
4489 WINED3DPBLENDCAPS_DESTCOLOR
|
4490 WINED3DPBLENDCAPS_INVDESTALPHA
|
4491 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4492 WINED3DPBLENDCAPS_INVSRCALPHA
|
4493 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4494 WINED3DPBLENDCAPS_ONE
|
4495 WINED3DPBLENDCAPS_SRCALPHA
|
4496 WINED3DPBLENDCAPS_SRCCOLOR
|
4497 WINED3DPBLENDCAPS_ZERO
;
4498 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
4499 * according to the glBlendFunc manpage
4501 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
4502 * legacy settings for srcblend only
4505 if (gl_info
->supported
[EXT_BLEND_COLOR
])
4507 caps
->SrcBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4508 caps
->DestBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4512 caps
->AlphaCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4513 WINED3DPCMPCAPS_EQUAL
|
4514 WINED3DPCMPCAPS_GREATER
|
4515 WINED3DPCMPCAPS_GREATEREQUAL
|
4516 WINED3DPCMPCAPS_LESS
|
4517 WINED3DPCMPCAPS_LESSEQUAL
|
4518 WINED3DPCMPCAPS_NEVER
|
4519 WINED3DPCMPCAPS_NOTEQUAL
;
4521 caps
->ShadeCaps
= WINED3DPSHADECAPS_SPECULARGOURAUDRGB
|
4522 WINED3DPSHADECAPS_COLORGOURAUDRGB
|
4523 WINED3DPSHADECAPS_ALPHAFLATBLEND
|
4524 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND
|
4525 WINED3DPSHADECAPS_COLORFLATRGB
|
4526 WINED3DPSHADECAPS_FOGFLAT
|
4527 WINED3DPSHADECAPS_FOGGOURAUD
|
4528 WINED3DPSHADECAPS_SPECULARFLATRGB
;
4530 caps
->TextureCaps
= WINED3DPTEXTURECAPS_ALPHA
|
4531 WINED3DPTEXTURECAPS_ALPHAPALETTE
|
4532 WINED3DPTEXTURECAPS_TRANSPARENCY
|
4533 WINED3DPTEXTURECAPS_BORDER
|
4534 WINED3DPTEXTURECAPS_MIPMAP
|
4535 WINED3DPTEXTURECAPS_PROJECTED
|
4536 WINED3DPTEXTURECAPS_PERSPECTIVE
;
4538 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4540 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_POW2
|
4541 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL
;
4544 if (gl_info
->supported
[EXT_TEXTURE3D
])
4546 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP
|
4547 WINED3DPTEXTURECAPS_MIPVOLUMEMAP
;
4548 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4550 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2
;
4554 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4556 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP
|
4557 WINED3DPTEXTURECAPS_MIPCUBEMAP
;
4558 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4560 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP_POW2
;
4564 caps
->TextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4565 WINED3DPTFILTERCAPS_MAGFPOINT
|
4566 WINED3DPTFILTERCAPS_MINFLINEAR
|
4567 WINED3DPTFILTERCAPS_MINFPOINT
|
4568 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4569 WINED3DPTFILTERCAPS_MIPFPOINT
|
4570 WINED3DPTFILTERCAPS_LINEAR
|
4571 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4572 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4573 WINED3DPTFILTERCAPS_MIPLINEAR
|
4574 WINED3DPTFILTERCAPS_MIPNEAREST
|
4575 WINED3DPTFILTERCAPS_NEAREST
;
4577 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4579 caps
->TextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4580 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4583 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4585 caps
->CubeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4586 WINED3DPTFILTERCAPS_MAGFPOINT
|
4587 WINED3DPTFILTERCAPS_MINFLINEAR
|
4588 WINED3DPTFILTERCAPS_MINFPOINT
|
4589 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4590 WINED3DPTFILTERCAPS_MIPFPOINT
|
4591 WINED3DPTFILTERCAPS_LINEAR
|
4592 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4593 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4594 WINED3DPTFILTERCAPS_MIPLINEAR
|
4595 WINED3DPTFILTERCAPS_MIPNEAREST
|
4596 WINED3DPTFILTERCAPS_NEAREST
;
4598 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4600 caps
->CubeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4601 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4606 caps
->CubeTextureFilterCaps
= 0;
4609 if (gl_info
->supported
[EXT_TEXTURE3D
])
4611 caps
->VolumeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4612 WINED3DPTFILTERCAPS_MAGFPOINT
|
4613 WINED3DPTFILTERCAPS_MINFLINEAR
|
4614 WINED3DPTFILTERCAPS_MINFPOINT
|
4615 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4616 WINED3DPTFILTERCAPS_MIPFPOINT
|
4617 WINED3DPTFILTERCAPS_LINEAR
|
4618 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4619 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4620 WINED3DPTFILTERCAPS_MIPLINEAR
|
4621 WINED3DPTFILTERCAPS_MIPNEAREST
|
4622 WINED3DPTFILTERCAPS_NEAREST
;
4626 caps
->VolumeTextureFilterCaps
= 0;
4629 caps
->TextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4630 WINED3DPTADDRESSCAPS_CLAMP
|
4631 WINED3DPTADDRESSCAPS_WRAP
;
4633 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4635 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4637 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4639 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4641 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4643 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4646 if (gl_info
->supported
[EXT_TEXTURE3D
])
4648 caps
->VolumeTextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4649 WINED3DPTADDRESSCAPS_CLAMP
|
4650 WINED3DPTADDRESSCAPS_WRAP
;
4651 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4653 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4655 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4657 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4659 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4661 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4666 caps
->VolumeTextureAddressCaps
= 0;
4669 caps
->LineCaps
= WINED3DLINECAPS_TEXTURE
|
4670 WINED3DLINECAPS_ZTEST
|
4671 WINED3DLINECAPS_BLEND
|
4672 WINED3DLINECAPS_ALPHACMP
|
4673 WINED3DLINECAPS_FOG
;
4674 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
4675 * idea how generating the smoothing alpha values works; the result is different
4678 caps
->MaxTextureWidth
= gl_info
->limits
.texture_size
;
4679 caps
->MaxTextureHeight
= gl_info
->limits
.texture_size
;
4681 if (gl_info
->supported
[EXT_TEXTURE3D
])
4682 caps
->MaxVolumeExtent
= gl_info
->limits
.texture3d_size
;
4684 caps
->MaxVolumeExtent
= 0;
4686 caps
->MaxTextureRepeat
= 32768;
4687 caps
->MaxTextureAspectRatio
= gl_info
->limits
.texture_size
;
4688 caps
->MaxVertexW
= 1.0f
;
4690 caps
->GuardBandLeft
= 0.0f
;
4691 caps
->GuardBandTop
= 0.0f
;
4692 caps
->GuardBandRight
= 0.0f
;
4693 caps
->GuardBandBottom
= 0.0f
;
4695 caps
->ExtentsAdjust
= 0.0f
;
4697 caps
->StencilCaps
= WINED3DSTENCILCAPS_DECRSAT
|
4698 WINED3DSTENCILCAPS_INCRSAT
|
4699 WINED3DSTENCILCAPS_INVERT
|
4700 WINED3DSTENCILCAPS_KEEP
|
4701 WINED3DSTENCILCAPS_REPLACE
|
4702 WINED3DSTENCILCAPS_ZERO
;
4703 if (gl_info
->supported
[EXT_STENCIL_WRAP
])
4705 caps
->StencilCaps
|= WINED3DSTENCILCAPS_DECR
|
4706 WINED3DSTENCILCAPS_INCR
;
4708 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
] || gl_info
->supported
[ATI_SEPARATE_STENCIL
])
4710 caps
->StencilCaps
|= WINED3DSTENCILCAPS_TWOSIDED
;
4713 caps
->FVFCaps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
4715 caps
->MaxUserClipPlanes
= gl_info
->limits
.clipplanes
;
4716 caps
->MaxActiveLights
= gl_info
->limits
.lights
;
4718 caps
->MaxVertexBlendMatrices
= gl_info
->limits
.blends
;
4719 caps
->MaxVertexBlendMatrixIndex
= 0;
4721 caps
->MaxAnisotropy
= gl_info
->limits
.anisotropy
;
4722 caps
->MaxPointSize
= gl_info
->limits
.pointsize_max
;
4725 /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
4726 caps
->VertexProcessingCaps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
|
4727 WINED3DVTXPCAPS_MATERIALSOURCE7
|
4728 WINED3DVTXPCAPS_POSITIONALLIGHTS
|
4729 WINED3DVTXPCAPS_LOCALVIEWER
|
4730 WINED3DVTXPCAPS_VERTEXFOG
|
4731 WINED3DVTXPCAPS_TEXGEN
;
4733 caps
->MaxPrimitiveCount
= 0xFFFFF; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4734 caps
->MaxVertexIndex
= 0xFFFFF;
4735 caps
->MaxStreams
= MAX_STREAMS
;
4736 caps
->MaxStreamStride
= 1024;
4738 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4739 caps
->DevCaps2
= WINED3DDEVCAPS2_STREAMOFFSET
|
4740 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
;
4741 caps
->MaxNpatchTessellationLevel
= 0;
4742 caps
->MasterAdapterOrdinal
= 0;
4743 caps
->AdapterOrdinalInGroup
= 0;
4744 caps
->NumberOfAdaptersInGroup
= 1;
4746 caps
->NumSimultaneousRTs
= gl_info
->limits
.buffers
;
4748 caps
->StretchRectFilterCaps
= WINED3DPTFILTERCAPS_MINFPOINT
|
4749 WINED3DPTFILTERCAPS_MAGFPOINT
|
4750 WINED3DPTFILTERCAPS_MINFLINEAR
|
4751 WINED3DPTFILTERCAPS_MAGFLINEAR
;
4752 caps
->VertexTextureFilterCaps
= 0;
4754 adapter
->shader_backend
->shader_get_caps(&adapter
->gl_info
, &shader_caps
);
4755 adapter
->fragment_pipe
->get_caps(&adapter
->gl_info
, &fragment_caps
);
4757 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4758 caps
->PrimitiveMiscCaps
|= fragment_caps
.PrimitiveMiscCaps
;
4760 /* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
4761 * Ignore shader model capabilities if disabled in config
4763 if (vs_selected_mode
== SHADER_NONE
)
4765 TRACE_(d3d_caps
)("Vertex shader disabled in config, reporting version 0.0\n");
4766 caps
->VertexShaderVersion
= 0;
4767 caps
->MaxVertexShaderConst
= 0;
4771 caps
->VertexShaderVersion
= shader_caps
.VertexShaderVersion
;
4772 caps
->MaxVertexShaderConst
= shader_caps
.MaxVertexShaderConst
;
4775 if (ps_selected_mode
== SHADER_NONE
)
4777 TRACE_(d3d_caps
)("Pixel shader disabled in config, reporting version 0.0\n");
4778 caps
->PixelShaderVersion
= 0;
4779 caps
->PixelShader1xMaxValue
= 0.0f
;
4781 caps
->PixelShaderVersion
= shader_caps
.PixelShaderVersion
;
4782 caps
->PixelShader1xMaxValue
= shader_caps
.PixelShader1xMaxValue
;
4785 caps
->TextureOpCaps
= fragment_caps
.TextureOpCaps
;
4786 caps
->MaxTextureBlendStages
= fragment_caps
.MaxTextureBlendStages
;
4787 caps
->MaxSimultaneousTextures
= fragment_caps
.MaxSimultaneousTextures
;
4789 /* The following caps are shader specific, but they are things we cannot detect, or which
4790 * are the same among all shader models. So to avoid code duplication set the shader version
4791 * specific, but otherwise constant caps here
4793 if (caps
->VertexShaderVersion
>= 3)
4795 /* Where possible set the caps based on OpenGL extensions and if they
4796 * aren't set (in case of software rendering) use the VS 3.0 from
4797 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4799 caps
->VS20Caps
.Caps
= WINED3DVS20CAPS_PREDICATION
;
4800 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4801 caps
->VS20Caps
.DynamicFlowControlDepth
= WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4802 caps
->VS20Caps
.NumTemps
= max(32, adapter
->gl_info
.limits
.arb_vs_temps
);
4803 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
4804 caps
->VS20Caps
.StaticFlowControlDepth
= WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
4806 caps
->MaxVShaderInstructionsExecuted
= 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
4807 caps
->MaxVertexShader30InstructionSlots
= max(512, adapter
->gl_info
.limits
.arb_vs_instructions
);
4809 else if (caps
->VertexShaderVersion
== 2)
4811 caps
->VS20Caps
.Caps
= 0;
4812 caps
->VS20Caps
.DynamicFlowControlDepth
= WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
;
4813 caps
->VS20Caps
.NumTemps
= max(12, adapter
->gl_info
.limits
.arb_vs_temps
);
4814 caps
->VS20Caps
.StaticFlowControlDepth
= 1;
4816 caps
->MaxVShaderInstructionsExecuted
= 65535;
4817 caps
->MaxVertexShader30InstructionSlots
= 0;
4821 caps
->VS20Caps
.Caps
= 0;
4822 caps
->VS20Caps
.DynamicFlowControlDepth
= 0;
4823 caps
->VS20Caps
.NumTemps
= 0;
4824 caps
->VS20Caps
.StaticFlowControlDepth
= 0;
4826 caps
->MaxVShaderInstructionsExecuted
= 0;
4827 caps
->MaxVertexShader30InstructionSlots
= 0;
4830 if (caps
->PixelShaderVersion
>= 3)
4832 /* Where possible set the caps based on OpenGL extensions and if they
4833 * aren't set (in case of software rendering) use the PS 3.0 from
4834 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4837 /* Caps is more or less undocumented on MSDN but it appears to be
4838 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
4839 * cards from Windows */
4840 caps
->PS20Caps
.Caps
= WINED3DPS20CAPS_ARBITRARYSWIZZLE
|
4841 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS
|
4842 WINED3DPS20CAPS_PREDICATION
|
4843 WINED3DPS20CAPS_NODEPENDENTREADLIMIT
|
4844 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
4845 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4846 caps
->PS20Caps
.DynamicFlowControlDepth
= WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4847 caps
->PS20Caps
.NumTemps
= max(32, adapter
->gl_info
.limits
.arb_ps_temps
);
4848 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
4849 caps
->PS20Caps
.StaticFlowControlDepth
= WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
4850 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
4851 caps
->PS20Caps
.NumInstructionSlots
= WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
4853 caps
->MaxPShaderInstructionsExecuted
= 65535;
4854 caps
->MaxPixelShader30InstructionSlots
= max(WINED3DMIN30SHADERINSTRUCTIONS
,
4855 adapter
->gl_info
.limits
.arb_ps_instructions
);
4857 else if(caps
->PixelShaderVersion
== 2)
4859 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
4860 caps
->PS20Caps
.Caps
= 0;
4861 caps
->PS20Caps
.DynamicFlowControlDepth
= 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
4862 caps
->PS20Caps
.NumTemps
= max(12, adapter
->gl_info
.limits
.arb_ps_temps
);
4863 caps
->PS20Caps
.StaticFlowControlDepth
= WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH
; /* Minimum: 1 */
4864 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
4865 caps
->PS20Caps
.NumInstructionSlots
= WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS
;
4867 caps
->MaxPShaderInstructionsExecuted
= 512; /* Minimum value, a GeforceFX uses 1024 */
4868 caps
->MaxPixelShader30InstructionSlots
= 0;
4872 caps
->PS20Caps
.Caps
= 0;
4873 caps
->PS20Caps
.DynamicFlowControlDepth
= 0;
4874 caps
->PS20Caps
.NumTemps
= 0;
4875 caps
->PS20Caps
.StaticFlowControlDepth
= 0;
4876 caps
->PS20Caps
.NumInstructionSlots
= 0;
4878 caps
->MaxPShaderInstructionsExecuted
= 0;
4879 caps
->MaxPixelShader30InstructionSlots
= 0;
4882 if (caps
->VertexShaderVersion
>= 2)
4884 /* OpenGL supports all the formats below, perhaps not always
4885 * without conversion, but it supports them.
4886 * Further GLSL doesn't seem to have an official unsigned type so
4887 * don't advertise it yet as I'm not sure how we handle it.
4888 * We might need to add some clamping in the shader engine to
4890 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
4891 caps
->DeclTypes
= WINED3DDTCAPS_UBYTE4
|
4892 WINED3DDTCAPS_UBYTE4N
|
4893 WINED3DDTCAPS_SHORT2N
|
4894 WINED3DDTCAPS_SHORT4N
;
4895 if (gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
])
4897 caps
->DeclTypes
|= WINED3DDTCAPS_FLOAT16_2
|
4898 WINED3DDTCAPS_FLOAT16_4
;
4903 caps
->DeclTypes
= 0;
4906 /* Set DirectDraw helper Caps */
4907 ckey_caps
= WINEDDCKEYCAPS_DESTBLT
|
4908 WINEDDCKEYCAPS_SRCBLT
;
4909 fx_caps
= WINEDDFXCAPS_BLTALPHA
|
4910 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT
|
4911 WINEDDFXCAPS_BLTMIRRORUPDOWN
|
4912 WINEDDFXCAPS_BLTROTATION90
|
4913 WINEDDFXCAPS_BLTSHRINKX
|
4914 WINEDDFXCAPS_BLTSHRINKXN
|
4915 WINEDDFXCAPS_BLTSHRINKY
|
4916 WINEDDFXCAPS_BLTSHRINKXN
|
4917 WINEDDFXCAPS_BLTSTRETCHX
|
4918 WINEDDFXCAPS_BLTSTRETCHXN
|
4919 WINEDDFXCAPS_BLTSTRETCHY
|
4920 WINEDDFXCAPS_BLTSTRETCHYN
;
4921 blit_caps
= WINEDDCAPS_BLT
|
4922 WINEDDCAPS_BLTCOLORFILL
|
4923 WINEDDCAPS_BLTDEPTHFILL
|
4924 WINEDDCAPS_BLTSTRETCH
|
4925 WINEDDCAPS_CANBLTSYSMEM
|
4926 WINEDDCAPS_CANCLIP
|
4927 WINEDDCAPS_CANCLIPSTRETCHED
|
4928 WINEDDCAPS_COLORKEY
|
4929 WINEDDCAPS_COLORKEYHWASSIST
|
4930 WINEDDCAPS_ALIGNBOUNDARYSRC
;
4931 pal_caps
= WINEDDPCAPS_8BIT
|
4932 WINEDDPCAPS_PRIMARYSURFACE
;
4934 /* Fill the ddraw caps structure */
4935 caps
->DirectDrawCaps
.Caps
= WINEDDCAPS_GDI
|
4936 WINEDDCAPS_PALETTE
|
4938 caps
->DirectDrawCaps
.Caps2
= WINEDDCAPS2_CERTIFIED
|
4939 WINEDDCAPS2_NOPAGELOCKREQUIRED
|
4940 WINEDDCAPS2_PRIMARYGAMMA
|
4941 WINEDDCAPS2_WIDESURFACES
|
4942 WINEDDCAPS2_CANRENDERWINDOWED
;
4943 caps
->DirectDrawCaps
.CKeyCaps
= ckey_caps
;
4944 caps
->DirectDrawCaps
.FXCaps
= fx_caps
;
4945 caps
->DirectDrawCaps
.PalCaps
= pal_caps
;
4946 caps
->DirectDrawCaps
.SVBCaps
= blit_caps
;
4947 caps
->DirectDrawCaps
.SVBCKeyCaps
= ckey_caps
;
4948 caps
->DirectDrawCaps
.SVBFXCaps
= fx_caps
;
4949 caps
->DirectDrawCaps
.VSBCaps
= blit_caps
;
4950 caps
->DirectDrawCaps
.VSBCKeyCaps
= ckey_caps
;
4951 caps
->DirectDrawCaps
.VSBFXCaps
= fx_caps
;
4952 caps
->DirectDrawCaps
.SSBCaps
= blit_caps
;
4953 caps
->DirectDrawCaps
.SSBCKeyCaps
= ckey_caps
;
4954 caps
->DirectDrawCaps
.SSBFXCaps
= fx_caps
;
4956 caps
->DirectDrawCaps
.ddsCaps
= WINEDDSCAPS_ALPHA
|
4957 WINEDDSCAPS_BACKBUFFER
|
4959 WINEDDSCAPS_FRONTBUFFER
|
4960 WINEDDSCAPS_OFFSCREENPLAIN
|
4961 WINEDDSCAPS_PALETTE
|
4962 WINEDDSCAPS_PRIMARYSURFACE
|
4963 WINEDDSCAPS_SYSTEMMEMORY
|
4964 WINEDDSCAPS_VIDEOMEMORY
|
4965 WINEDDSCAPS_VISIBLE
;
4966 caps
->DirectDrawCaps
.StrideAlign
= DDRAW_PITCH_ALIGNMENT
;
4968 /* Set D3D caps if OpenGL is available. */
4969 if (adapter
->opengl
)
4971 caps
->DirectDrawCaps
.ddsCaps
|= WINEDDSCAPS_3DDEVICE
|
4972 WINEDDSCAPS_MIPMAP
|
4973 WINEDDSCAPS_TEXTURE
|
4974 WINEDDSCAPS_ZBUFFER
;
4975 caps
->DirectDrawCaps
.Caps
|= WINEDDCAPS_3D
;
4981 HRESULT CDECL
wined3d_device_create(struct wined3d
*wined3d
, UINT adapter_idx
, WINED3DDEVTYPE device_type
,
4982 HWND focus_window
, DWORD flags
, BYTE surface_alignment
, struct wined3d_device_parent
*device_parent
,
4983 struct wined3d_device
**device
)
4985 struct wined3d_device
*object
;
4988 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
4989 wined3d
, adapter_idx
, device_type
, focus_window
, flags
, device_parent
, device
);
4991 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
4992 * number and create a device without a 3D adapter for 2D only operation. */
4993 if (wined3d
->adapter_count
&& adapter_idx
>= wined3d
->adapter_count
)
4994 return WINED3DERR_INVALIDCALL
;
4996 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
4999 ERR("Failed to allocate device memory.\n");
5000 return E_OUTOFMEMORY
;
5003 hr
= device_init(object
, wined3d
, adapter_idx
, device_type
,
5004 focus_window
, flags
, surface_alignment
, device_parent
);
5007 WARN("Failed to initialize device, hr %#x.\n", hr
);
5008 HeapFree(GetProcessHeap(), 0, object
);
5012 TRACE("Created device %p.\n", object
);
5015 device_parent
->ops
->wined3d_device_created(device_parent
, *device
);
5020 void * CDECL
wined3d_get_parent(const struct wined3d
*wined3d
)
5022 TRACE("wined3d %p.\n", wined3d
);
5024 return wined3d
->parent
;
5027 static void WINE_GLAPI
invalid_func(const void *data
)
5029 ERR("Invalid vertex attribute function called\n");
5033 static void WINE_GLAPI
invalid_texcoord_func(GLenum unit
, const void *data
)
5035 ERR("Invalid texcoord function called\n");
5039 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
5040 * the extension detection and are used in drawStridedSlow
5042 static void WINE_GLAPI
position_d3dcolor(const void *data
)
5044 DWORD pos
= *((const DWORD
*)data
);
5046 FIXME("Add a test for fixed function position from d3dcolor type\n");
5047 glVertex4s(D3DCOLOR_B_R(pos
),
5053 static void WINE_GLAPI
position_float4(const void *data
)
5055 const GLfloat
*pos
= data
;
5057 if (pos
[3] != 0.0f
&& pos
[3] != 1.0f
)
5059 float w
= 1.0f
/ pos
[3];
5061 glVertex4f(pos
[0] * w
, pos
[1] * w
, pos
[2] * w
, w
);
5069 static void WINE_GLAPI
diffuse_d3dcolor(const void *data
)
5071 DWORD diffuseColor
= *((const DWORD
*)data
);
5073 glColor4ub(D3DCOLOR_B_R(diffuseColor
),
5074 D3DCOLOR_B_G(diffuseColor
),
5075 D3DCOLOR_B_B(diffuseColor
),
5076 D3DCOLOR_B_A(diffuseColor
));
5079 static void WINE_GLAPI
specular_d3dcolor(const void *data
)
5081 DWORD specularColor
= *((const DWORD
*)data
);
5082 GLbyte d
[] = {D3DCOLOR_B_R(specularColor
),
5083 D3DCOLOR_B_G(specularColor
),
5084 D3DCOLOR_B_B(specularColor
)};
5086 specular_func_3ubv(d
);
5089 static void WINE_GLAPI
warn_no_specular_func(const void *data
)
5091 WARN("GL_EXT_secondary_color not supported\n");
5094 static void fillGLAttribFuncs(const struct wined3d_gl_info
*gl_info
)
5096 position_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5097 position_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5098 position_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glVertex3fv
;
5099 position_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = position_float4
;
5100 position_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = position_d3dcolor
;
5101 position_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5102 position_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5103 position_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glAttribFunc
)glVertex2sv
;
5104 position_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5105 position_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5106 position_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5107 position_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5108 position_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5109 position_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5110 position_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5111 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5112 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5114 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5115 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5116 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glColor3fv
;
5117 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glColor4fv
;
5118 diffuse_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = diffuse_d3dcolor
;
5119 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5120 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5121 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5122 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = (glAttribFunc
)glColor4ubv
;
5123 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5124 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = (glAttribFunc
)glColor4sv
;
5125 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5126 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = (glAttribFunc
)glColor4usv
;
5127 diffuse_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5128 diffuse_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5129 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5130 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5132 /* No 4 component entry points here */
5133 specular_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5134 specular_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5135 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5137 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)GL_EXTCALL(glSecondaryColor3fvEXT
);
5141 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = warn_no_specular_func
;
5143 specular_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = invalid_func
;
5144 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5146 specular_func_3ubv
= (glAttribFunc
)GL_EXTCALL(glSecondaryColor3ubvEXT
);
5147 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = specular_d3dcolor
;
5151 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = warn_no_specular_func
;
5153 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5154 specular_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5155 specular_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5156 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5157 specular_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5158 specular_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5159 specular_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5160 specular_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5161 specular_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5162 specular_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5163 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5164 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5166 /* Only 3 component entry points here. Test how others behave. Float4 normals are used
5167 * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
5169 normal_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5170 normal_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5171 normal_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glNormal3fv
;
5172 normal_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glNormal3fv
; /* Just ignore the 4th value */
5173 normal_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_func
;
5174 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5175 normal_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5176 normal_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5177 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5178 normal_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5179 normal_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5180 normal_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5181 normal_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5182 normal_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5183 normal_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5184 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5185 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5187 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord1fvARB
);
5188 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2fvARB
);
5189 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord3fvARB
);
5190 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4fvARB
);
5191 multi_texcoord_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_texcoord_func
;
5192 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_texcoord_func
;
5193 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2svARB
);
5194 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4svARB
);
5195 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_texcoord_func
;
5196 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_texcoord_func
;
5197 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_texcoord_func
;
5198 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_texcoord_func
;
5199 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_texcoord_func
;
5200 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_texcoord_func
;
5201 multi_texcoord_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_texcoord_func
;
5202 if (gl_info
->supported
[NV_HALF_FLOAT
])
5204 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
5205 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2hvNV
);
5206 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4hvNV
);
5208 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_texcoord_func
;
5209 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_texcoord_func
;
5213 /* Do not call while under the GL lock. */
5214 static BOOL
InitAdapters(struct wined3d
*wined3d
)
5216 static HMODULE mod_gl
;
5218 int ps_selected_mode
, vs_selected_mode
;
5220 /* No need to hold any lock. The calling library makes sure only one thread calls
5221 * wined3d simultaneously
5224 TRACE("Initializing adapters\n");
5227 #ifdef USE_WIN32_OPENGL
5228 #define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
5229 mod_gl
= LoadLibraryA("opengl32.dll");
5231 ERR("Can't load opengl32.dll!\n");
5235 #define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
5236 /* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
5237 mod_gl
= GetModuleHandleA("gdi32.dll");
5241 /* Load WGL core functions from opengl32.dll */
5242 #define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
5246 if(!pwglGetProcAddress
) {
5247 ERR("Unable to load wglGetProcAddress!\n");
5251 /* Dynamically load all GL core functions */
5255 /* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl
5256 * otherwise because we have to use winex11.drv's override
5258 #ifdef USE_WIN32_OPENGL
5259 wglFinish
= (void*)GetProcAddress(mod_gl
, "glFinish");
5260 wglFlush
= (void*)GetProcAddress(mod_gl
, "glFlush");
5262 wglFinish
= (void*)pwglGetProcAddress("wglFinish");
5263 wglFlush
= (void*)pwglGetProcAddress("wglFlush");
5266 glEnableWINE
= glEnable
;
5267 glDisableWINE
= glDisable
;
5269 /* For now only one default adapter */
5271 struct wined3d_adapter
*adapter
= &wined3d
->adapters
[0];
5272 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
5273 struct wined3d_fake_gl_ctx fake_gl_ctx
= {0};
5274 struct wined3d_pixel_format
*cfgs
;
5277 DISPLAY_DEVICEW DisplayDevice
;
5280 TRACE("Initializing default adapter\n");
5281 adapter
->ordinal
= 0;
5282 adapter
->monitorPoint
.x
= -1;
5283 adapter
->monitorPoint
.y
= -1;
5285 if (!AllocateLocallyUniqueId(&adapter
->luid
))
5287 DWORD err
= GetLastError();
5288 ERR("Failed to set adapter LUID (%#x).\n", err
);
5291 TRACE("Allocated LUID %08x:%08x for adapter.\n",
5292 adapter
->luid
.HighPart
, adapter
->luid
.LowPart
);
5294 if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx
))
5296 ERR("Failed to get a gl context for default adapter\n");
5300 ret
= wined3d_adapter_init_gl_caps(adapter
);
5302 ERR("Failed to initialize gl caps for default adapter\n");
5303 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5306 ret
= initPixelFormats(&adapter
->gl_info
, adapter
->driver_info
.vendor
);
5308 ERR("Failed to init gl formats\n");
5309 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5313 hdc
= fake_gl_ctx
.dc
;
5315 adapter
->TextureRam
= adapter
->driver_info
.vidmem
;
5316 adapter
->UsedTextureRam
= 0;
5317 TRACE("Emulating %dMB of texture ram\n", adapter
->TextureRam
/(1024*1024));
5319 /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
5320 DisplayDevice
.cb
= sizeof(DisplayDevice
);
5321 EnumDisplayDevicesW(NULL
, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice
, 0);
5322 TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice
.DeviceName
));
5323 strcpyW(adapter
->DeviceName
, DisplayDevice
.DeviceName
);
5325 if (gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
])
5333 attribute
= WGL_NUMBER_PIXEL_FORMATS_ARB
;
5334 GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, 0, 0, 1, &attribute
, &cfg_count
));
5335 adapter
->cfg_count
= cfg_count
;
5337 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, adapter
->cfg_count
* sizeof(*adapter
->cfgs
));
5338 cfgs
= adapter
->cfgs
;
5339 attribs
[nAttribs
++] = WGL_RED_BITS_ARB
;
5340 attribs
[nAttribs
++] = WGL_GREEN_BITS_ARB
;
5341 attribs
[nAttribs
++] = WGL_BLUE_BITS_ARB
;
5342 attribs
[nAttribs
++] = WGL_ALPHA_BITS_ARB
;
5343 attribs
[nAttribs
++] = WGL_COLOR_BITS_ARB
;
5344 attribs
[nAttribs
++] = WGL_DEPTH_BITS_ARB
;
5345 attribs
[nAttribs
++] = WGL_STENCIL_BITS_ARB
;
5346 attribs
[nAttribs
++] = WGL_DRAW_TO_WINDOW_ARB
;
5347 attribs
[nAttribs
++] = WGL_PIXEL_TYPE_ARB
;
5348 attribs
[nAttribs
++] = WGL_DOUBLE_BUFFER_ARB
;
5349 attribs
[nAttribs
++] = WGL_AUX_BUFFERS_ARB
;
5351 for (iPixelFormat
=1; iPixelFormat
<= adapter
->cfg_count
; ++iPixelFormat
)
5353 res
= GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, nAttribs
, attribs
, values
));
5358 /* Cache the pixel format */
5359 cfgs
->iPixelFormat
= iPixelFormat
;
5360 cfgs
->redSize
= values
[0];
5361 cfgs
->greenSize
= values
[1];
5362 cfgs
->blueSize
= values
[2];
5363 cfgs
->alphaSize
= values
[3];
5364 cfgs
->colorSize
= values
[4];
5365 cfgs
->depthSize
= values
[5];
5366 cfgs
->stencilSize
= values
[6];
5367 cfgs
->windowDrawable
= values
[7];
5368 cfgs
->iPixelType
= values
[8];
5369 cfgs
->doubleBuffer
= values
[9];
5370 cfgs
->auxBuffers
= values
[10];
5372 cfgs
->numSamples
= 0;
5373 /* Check multisample support */
5374 if (gl_info
->supported
[ARB_MULTISAMPLE
])
5376 int attrib
[2] = {WGL_SAMPLE_BUFFERS_ARB
, WGL_SAMPLES_ARB
};
5378 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, 2, attrib
, value
))) {
5379 /* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
5380 * value[1] = number of multi sample buffers*/
5382 cfgs
->numSamples
= value
[1];
5386 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5387 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
5388 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5389 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5390 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->numSamples
, cfgs
->windowDrawable
);
5396 int nCfgs
= DescribePixelFormat(hdc
, 0, 0, 0);
5397 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, nCfgs
* sizeof(*adapter
->cfgs
));
5398 adapter
->cfg_count
= 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
5400 cfgs
= adapter
->cfgs
;
5401 for(iPixelFormat
=1; iPixelFormat
<=nCfgs
; iPixelFormat
++)
5403 PIXELFORMATDESCRIPTOR ppfd
;
5405 res
= DescribePixelFormat(hdc
, iPixelFormat
, sizeof(PIXELFORMATDESCRIPTOR
), &ppfd
);
5409 /* We only want HW acceleration using an OpenGL ICD driver.
5410 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
5411 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
5413 if(ppfd
.dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
))
5415 TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat
);
5419 cfgs
->iPixelFormat
= iPixelFormat
;
5420 cfgs
->redSize
= ppfd
.cRedBits
;
5421 cfgs
->greenSize
= ppfd
.cGreenBits
;
5422 cfgs
->blueSize
= ppfd
.cBlueBits
;
5423 cfgs
->alphaSize
= ppfd
.cAlphaBits
;
5424 cfgs
->colorSize
= ppfd
.cColorBits
;
5425 cfgs
->depthSize
= ppfd
.cDepthBits
;
5426 cfgs
->stencilSize
= ppfd
.cStencilBits
;
5427 cfgs
->windowDrawable
= (ppfd
.dwFlags
& PFD_DRAW_TO_WINDOW
) ? 1 : 0;
5428 cfgs
->iPixelType
= (ppfd
.iPixelType
== PFD_TYPE_RGBA
) ? WGL_TYPE_RGBA_ARB
: WGL_TYPE_COLORINDEX_ARB
;
5429 cfgs
->doubleBuffer
= (ppfd
.dwFlags
& PFD_DOUBLEBUFFER
) ? 1 : 0;
5430 cfgs
->auxBuffers
= ppfd
.cAuxBuffers
;
5431 cfgs
->numSamples
= 0;
5433 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5434 "depth=%d, stencil=%d, windowDrawable=%d\n",
5435 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5436 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5437 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->windowDrawable
);
5439 adapter
->cfg_count
++;
5442 /* We haven't found any suitable formats. This should only happen
5443 * in case of GDI software rendering, which is pretty useless
5445 if (!adapter
->cfg_count
)
5447 ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
5449 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5450 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
5455 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5457 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
5458 fillGLAttribFuncs(&adapter
->gl_info
);
5459 adapter
->opengl
= TRUE
;
5461 wined3d
->adapter_count
= 1;
5462 TRACE("%u adapters successfully initialized.\n", wined3d
->adapter_count
);
5467 /* Initialize an adapter for ddraw-only memory counting */
5468 memset(wined3d
->adapters
, 0, sizeof(wined3d
->adapters
));
5469 wined3d
->adapters
[0].ordinal
= 0;
5470 wined3d
->adapters
[0].opengl
= FALSE
;
5471 wined3d
->adapters
[0].monitorPoint
.x
= -1;
5472 wined3d
->adapters
[0].monitorPoint
.y
= -1;
5474 wined3d
->adapters
[0].driver_info
.name
= "Display";
5475 wined3d
->adapters
[0].driver_info
.description
= "WineD3D DirectDraw Emulation";
5476 if (wined3d_settings
.emulated_textureram
)
5477 wined3d
->adapters
[0].TextureRam
= wined3d_settings
.emulated_textureram
;
5479 wined3d
->adapters
[0].TextureRam
= 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
5481 initPixelFormatsNoGL(&wined3d
->adapters
[0].gl_info
);
5483 wined3d
->adapter_count
= 1;
5487 static void STDMETHODCALLTYPE
wined3d_null_wined3d_object_destroyed(void *parent
) {}
5489 const struct wined3d_parent_ops wined3d_null_parent_ops
=
5491 wined3d_null_wined3d_object_destroyed
,
5494 /* Do not call while under the GL lock. */
5495 HRESULT
wined3d_init(struct wined3d
*wined3d
, UINT version
, DWORD flags
, void *parent
)
5497 wined3d
->dxVersion
= version
;
5499 wined3d
->parent
= parent
;
5500 wined3d
->flags
= flags
;
5502 if (!InitAdapters(wined3d
))
5504 WARN("Failed to initialize adapters.\n");
5507 MESSAGE("Direct3D%u is not available without OpenGL.\n", version
);